






from collections.abc import Generator
from math import sin


def 				snake_case__							(							UpperCAmelCase							:  bytes       ):
    if len(UpperCAmelCase       ) != 3_2:
        raise ValueError("Input must be of length 32"       )

    lowerCAmelCase__   :Any      							=				B""
    for i in [3, 2, 1, 0]:
        little_endian += string_aa[8 * i : 8 * i + 8]
    return little_endian


def 				snake_case__							(							UpperCAmelCase							:  int       ):
    if i < 0:
        raise ValueError("Input must be non-negative"       )

    lowerCAmelCase__   :List[str]      							=				format(UpperCAmelCase    ,			"08x"       )[-8:]
    lowerCAmelCase__   :Union[str, Any]      							=				B""
    for i in [3, 2, 1, 0]:
        little_endian_hex += hex_rep[2 * i : 2 * i + 2].encode("utf-8"       )
    return little_endian_hex


def 				snake_case__							(							UpperCAmelCase							:  bytes       ):
    lowerCAmelCase__   :Tuple      							=				B""
    for char in message:
        bit_string += format(UpperCAmelCase    ,			"08b"       ).encode("utf-8"       )
    lowerCAmelCase__   :Optional[Any]      							=				format(len(UpperCAmelCase       )    ,			"064b"       ).encode("utf-8"       )

    # Pad bit_string to a multiple of 512 chars
    bit_string += b"1"
    while len(UpperCAmelCase       ) % 5_1_2 != 4_4_8:
        bit_string += b"0"
    bit_string += to_little_endian(start_len[3_2:]       ) + to_little_endian(start_len[:3_2]       )

    return bit_string


def 				snake_case__							(							UpperCAmelCase							:  bytes       ):
    if len(UpperCAmelCase       ) % 5_1_2 != 0:
        raise ValueError("Input must have length that's a multiple of 512"       )

    for pos in range(0    ,			len(UpperCAmelCase       )    ,			5_1_2       ):
        lowerCAmelCase__   :Optional[int]      							=				bit_string[pos : pos + 5_1_2]
        lowerCAmelCase__   :Any      							=				[]
        for i in range(0    ,			5_1_2    ,			3_2       ):
            block_words.append(int(to_little_endian(block[i : i + 3_2]       )    ,			2       )       )
        yield block_words


def 				snake_case__							(							UpperCAmelCase							:  int       ):
    if i < 0:
        raise ValueError("Input must be non-negative"       )

    lowerCAmelCase__   :int      							=				format(UpperCAmelCase    ,			"032b"       )
    lowerCAmelCase__   :Dict      							=				""
    for c in i_str:
        new_str += "1" if c == "0" else "0"
    return int(UpperCAmelCase    ,			2       )


def 				snake_case__							(							UpperCAmelCase							:  int    ,			UpperCAmelCase							:  int       ):
    return (a + b) % 2**3_2


def 				snake_case__							(							UpperCAmelCase							:  int    ,			UpperCAmelCase							:  int       ):
    if i < 0:
        raise ValueError("Input must be non-negative"       )
    if shift < 0:
        raise ValueError("Shift must be non-negative"       )
    return ((i << shift) ^ (i >> (3_2 - shift))) % 2**3_2


def 				snake_case__							(							UpperCAmelCase							:  bytes       ):
    lowerCAmelCase__   :Union[str, Any]      							=				preprocess(UpperCAmelCase       )

    lowerCAmelCase__   :List[str]      							=				[int(2**3_2 * abs(sin(i + 1       )       )       ) for i in range(6_4       )]

    # Starting states
    lowerCAmelCase__   :Tuple      							=				0X67_452_301
    lowerCAmelCase__   :List[Any]      							=				0XEF_CDA_B89
    lowerCAmelCase__   :Dict      							=				0X98_BAD_CFE
    lowerCAmelCase__   :Optional[Any]      							=				0X10_325_476

    lowerCAmelCase__   :Optional[int]      							=				[
        7,
        1_2,
        1_7,
        2_2,
        7,
        1_2,
        1_7,
        2_2,
        7,
        1_2,
        1_7,
        2_2,
        7,
        1_2,
        1_7,
        2_2,
        5,
        9,
        1_4,
        2_0,
        5,
        9,
        1_4,
        2_0,
        5,
        9,
        1_4,
        2_0,
        5,
        9,
        1_4,
        2_0,
        4,
        1_1,
        1_6,
        2_3,
        4,
        1_1,
        1_6,
        2_3,
        4,
        1_1,
        1_6,
        2_3,
        4,
        1_1,
        1_6,
        2_3,
        6,
        1_0,
        1_5,
        2_1,
        6,
        1_0,
        1_5,
        2_1,
        6,
        1_0,
        1_5,
        2_1,
        6,
        1_0,
        1_5,
        2_1,
    ]

    # Process bit string in chunks, each with 16 32-char words
    for block_words in get_block_words(UpperCAmelCase       ):
        lowerCAmelCase__   :Optional[Any]      							=				aa
        lowerCAmelCase__   :Any      							=				ba
        lowerCAmelCase__   :Tuple      							=				ca
        lowerCAmelCase__   :Optional[Any]      							=				da

        # Hash current chunk
        for i in range(6_4       ):
            if i <= 1_5:
                # f = (b & c) | (not_32(b) & d)     # Alternate definition for f
                lowerCAmelCase__   :Optional[int]      							=				d ^ (b & (c ^ d))
                lowerCAmelCase__   :str      							=				i
            elif i <= 3_1:
                # f = (d & b) | (not_32(d) & c)     # Alternate definition for f
                lowerCAmelCase__   :Tuple      							=				c ^ (d & (b ^ c))
                lowerCAmelCase__   :int      							=				(5 * i + 1) % 1_6
            elif i <= 4_7:
                lowerCAmelCase__   :Optional[Any]      							=				b ^ c ^ d
                lowerCAmelCase__   :List[str]      							=				(3 * i + 5) % 1_6
            else:
                lowerCAmelCase__   :Dict      							=				c ^ (b | not_aa(UpperCAmelCase       ))
                lowerCAmelCase__   :int      							=				(7 * i) % 1_6
            lowerCAmelCase__   :int      							=				(f + a + added_consts[i] + block_words[g]) % 2**3_2
            lowerCAmelCase__   :Optional[Any]      							=				d
            lowerCAmelCase__   :Tuple      							=				c
            lowerCAmelCase__   :Any      							=				b
            lowerCAmelCase__   :List[str]      							=				sum_aa(UpperCAmelCase    ,			left_rotate_aa(UpperCAmelCase    ,			shift_amounts[i]       )       )

        # Add hashed chunk to running total
        lowerCAmelCase__   :Any      							=				sum_aa(UpperCAmelCase    ,			UpperCAmelCase       )
        lowerCAmelCase__   :Tuple      							=				sum_aa(UpperCAmelCase    ,			UpperCAmelCase       )
        lowerCAmelCase__   :Union[str, Any]      							=				sum_aa(UpperCAmelCase    ,			UpperCAmelCase       )
        lowerCAmelCase__   :Optional[Any]      							=				sum_aa(UpperCAmelCase    ,			UpperCAmelCase       )

    lowerCAmelCase__   :Tuple      							=				reformat_hex(UpperCAmelCase       ) + reformat_hex(UpperCAmelCase       ) + reformat_hex(UpperCAmelCase       ) + reformat_hex(UpperCAmelCase       )
    return digest


if __name__ == "__main__":
 import doctest

 doctest.testmod()











import re


def 				snake_case__							(							UpperCAmelCase							:  str       ):
    return [char.split() for char in re.split(R"[^ a-z A-Z 0-9 \s]"    ,			str_       )]


def 				snake_case__							(							UpperCAmelCase							:  str       ):
    lowerCAmelCase__   :List[Any]      							=				split_input(str_       )
    return "".join(
        ["".join([char.capitalize() for char in sub_str]       ) for sub_str in string_split]       )


def 				snake_case__							(							UpperCAmelCase							:  str    ,			UpperCAmelCase							:  bool    ,			UpperCAmelCase							:  str       ):
    try:
        lowerCAmelCase__   :Dict      							=				split_input(UpperCAmelCase       )
        if upper:
            lowerCAmelCase__   :Dict      							=				"".join(
                [
                    separator.join([char.upper() for char in sub_str]       )
                    for sub_str in string_split
                ]       )
        else:
            lowerCAmelCase__   :Any      							=				"".join(
                [
                    separator.join([char.lower() for char in sub_str]       )
                    for sub_str in string_split
                ]       )
        return res_str
    except IndexError:
        return "not valid string"


def 				snake_case__							(							UpperCAmelCase							:  str       ):
    return to_simple_case(UpperCAmelCase       )


def 				snake_case__							(							UpperCAmelCase							:  str       ):
    try:
        lowerCAmelCase__   :Any      							=				to_simple_case(UpperCAmelCase       )
        return res_str[0].lower() + res_str[1:]
    except IndexError:
        return "not valid string"


def 				snake_case__							(							UpperCAmelCase							:  str    ,			UpperCAmelCase							:  bool       ):
    return to_complex_case(UpperCAmelCase    ,			UpperCAmelCase    ,			"_"       )


def 				snake_case__							(							UpperCAmelCase							:  str    ,			UpperCAmelCase							:  bool       ):
    return to_complex_case(UpperCAmelCase    ,			UpperCAmelCase    ,			"-"       )


if __name__ == "__main__":
 __import__("""doctest""").testmod()



