def gear_for_speed_profiles(gs, curr_speed, current_gear, gear_cnt,
    clutch_duration=5):
    """
    Return the gear that must be used and the clutch condition.

    :param gs:
        Gear limits.
    :type gs: list

    :param curr_speed:
        Current speed.
    :type curr_speed: int

    :param current_gear:
        Current speed.
    :type current_gear: int

    :param gear_cnt:
        Gear count.
    :type gear_cnt: int

    :param clutch_duration:
        Clutch duration in sim step
    :type clutch_duration: int

    :return:
        Current gear & gear count
    :rtype: int, int
    """
    up_shift_offs = 0.0
    downshift_off = 0.1
    gear_limits = [0]
    gear_limits.extend(gs)
    gear_limits.append(200)
    if gear_limits[current_gear - 1] - gear_limits[current_gear - 1
        ] * downshift_off <= curr_speed < gear_limits[current_gear
        ] + gear_limits[current_gear] * up_shift_offs:
        if gear_cnt == 0:
            return current_gear, gear_cnt
        else:
            gear_cnt -= 1
            return current_gear, gear_cnt
    else:
        itr = 1
        gear_search = 1
        while itr == 1 and gear_search < len(gear_limits):
            if gear_limits[gear_search - 1] <= curr_speed < gear_limits[
                gear_search]:
                gear_cnt = clutch_duration
                current_gear = gear_search
                itr = 0
            else:
                gear_search += 1
        return current_gear, gear_cnt
