def camel_to_snake_base(string: str) ->str:
    """Base function to convert a camel-case string to snake-case string."""
    res = []
    byte = string.encode('ascii')
    max_index = len(byte)
    _index = 0
    while _index < max_index and not 65 <= byte[_index
        ] <= 90 and not 97 <= byte[_index] <= 122:
        res.append(byte[_index])
        _index += 1
    if _index < max_index and 65 <= byte[_index] <= 90:
        res.append(byte[_index] + 32)
        _index += 1
        while _index < max_index and 65 <= byte[_index] <= 90:
            if _index + 1 < max_index:
                if 65 <= byte[_index + 1] <= 90:
                    res.append(byte[_index] + 32)
                    _index += 1
                elif not 97 <= byte[_index + 1] <= 122:
                    res.append(byte[_index] + 32)
                    res.append(byte[_index + 1])
                    _index += 2
                else:
                    if res[-1] != 95:
                        res.append(95)
                    res.append(byte[_index] + 32)
                    res.append(byte[_index + 1])
                    _index += 2
                    break
            else:
                res.append(byte[_index] + 32)
                _index += 1
                break
    while _index < max_index:
        if 65 <= byte[_index] <= 90:
            if res[-1] != 95:
                res.append(95)
            res.append(byte[_index] + 32)
            _index += 1
            while _index < max_index and 65 <= byte[_index] <= 90:
                if _index + 1 < max_index:
                    if 65 <= byte[_index + 1] <= 90:
                        res.append(byte[_index] + 32)
                        _index += 1
                    elif not 97 <= byte[_index + 1] <= 122:
                        res.append(byte[_index] + 32)
                        res.append(byte[_index + 1])
                        _index += 2
                    else:
                        if res[-1] != 95:
                            res.append(95)
                        res.append(byte[_index] + 32)
                        res.append(byte[_index + 1])
                        _index += 2
                        break
                else:
                    res.append(byte[_index] + 32)
                    _index += 1
                    break
        else:
            res.append(byte[_index])
            _index += 1
    res = bytearray(res).decode('ascii')
    return res
