



from collections.abc import Generator
from math import sin






def 				A				(					_lowerCamelCase  ):





							'''simple docstring'''




							if len(_lowerCamelCase  ) != 32:
														raise ValueError("Input must be of length 32"  )

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






def 				A				(					_lowerCamelCase  ):





							'''simple docstring'''




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

							_lowerCAmelCase     :							Dict    =    format(_lowerCamelCase				, "08x"  )[-8:]
							_lowerCAmelCase     :							int    =    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 				A				(					_lowerCamelCase  ):





							'''simple docstring'''




							_lowerCAmelCase     :							Tuple    =    b""
							for char in message:
														bit_string += format(_lowerCamelCase				, "08b"  ).encode("utf-8"  )
							_lowerCAmelCase     :							Tuple    =    format(len(_lowerCamelCase  )				, "064b"  ).encode("utf-8"  )

							# Pad bit_string to a multiple of 512 chars
							bit_string += b"1"
							while len(_lowerCamelCase  ) % 512 != 448:
														bit_string += b"0"
							bit_string += to_little_endian(start_len[32:]  ) + to_little_endian(start_len[:32]  )

							return bit_string






def 				A				(					_lowerCamelCase  ):





							'''simple docstring'''




							if len(_lowerCamelCase  ) % 512 != 0:
														raise ValueError("Input must have length that's a multiple of 512"  )

							for pos in range(0				, len(_lowerCamelCase  )				, 512  ):
														_lowerCAmelCase     :							List[str]    =    bit_string[pos : pos + 512]
														_lowerCAmelCase     :							Optional[Any]    =    []
														for i in range(0				, 512				, 32  ):
																					block_words.append(int(to_little_endian(block[i : i + 32]  )				, 2  )  )
														yield block_words






def 				A				(					_lowerCamelCase  ):





							'''simple docstring'''




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

							_lowerCAmelCase     :							str    =    format(_lowerCamelCase				, "032b"  )
							_lowerCAmelCase     :							Optional[Any]    =    ""
							for c in i_str:
														new_str += "1" if c == "0" else "0"
							return int(_lowerCamelCase				, 2  )






def 				A				(					_lowerCamelCase				, _lowerCamelCase  ):





							'''simple docstring'''




							return (a + b) % 2**32






def 				A				(					_lowerCamelCase				, _lowerCamelCase  ):





							'''simple docstring'''




							if i < 0:
														raise ValueError("Input must be non-negative"  )
							if shift < 0:
														raise ValueError("Shift must be non-negative"  )
							return ((i << shift) ^ (i >> (32 - shift))) % 2**32






def 				A				(					_lowerCamelCase  ):





							'''simple docstring'''




							_lowerCAmelCase     :							Dict    =    preprocess(_lowerCamelCase  )

							_lowerCAmelCase     :							Tuple    =    [int(2**32 * abs(sin(i + 1  )  )  ) for i in range(64  )]

							# Starting states
							_lowerCAmelCase     :							int    =    0X67_45_23_01
							_lowerCAmelCase     :							Optional[Any]    =    0XEF_CD_AB_89
							_lowerCAmelCase     :							Union[str, Any]    =    0X98_BA_DC_FE
							_lowerCAmelCase     :							Dict    =    0X10_32_54_76

							_lowerCAmelCase     :							int    =    [
							    7,
							    12,
							    17,
							    22,
							    7,
							    12,
							    17,
							    22,
							    7,
							    12,
							    17,
							    22,
							    7,
							    12,
							    17,
							    22,
							    5,
							    9,
							    14,
							    20,
							    5,
							    9,
							    14,
							    20,
							    5,
							    9,
							    14,
							    20,
							    5,
							    9,
							    14,
							    20,
							    4,
							    11,
							    16,
							    23,
							    4,
							    11,
							    16,
							    23,
							    4,
							    11,
							    16,
							    23,
							    4,
							    11,
							    16,
							    23,
							    6,
							    10,
							    15,
							    21,
							    6,
							    10,
							    15,
							    21,
							    6,
							    10,
							    15,
							    21,
							    6,
							    10,
							    15,
							    21,
							]

							# Process bit string in chunks, each with 16 32-char words
							for block_words in get_block_words(_lowerCamelCase  ):
														_lowerCAmelCase     :							Dict    =    aa
														_lowerCAmelCase     :							Union[str, Any]    =    ba
														_lowerCAmelCase     :							Dict    =    ca
														_lowerCAmelCase     :							Tuple    =    da

														# Hash current chunk
														for i in range(64  ):
																					if i <= 15:
																												# f = (b & c) | (not_32(b) & d)     # Alternate definition for f
																												_lowerCAmelCase     :							List[Any]    =    d ^ (b & (c ^ d))
																												_lowerCAmelCase     :							int    =    i
																					elif i <= 31:
																												# f = (d & b) | (not_32(d) & c)     # Alternate definition for f
																												_lowerCAmelCase     :							List[str]    =    c ^ (d & (b ^ c))
																												_lowerCAmelCase     :							Dict    =    (5 * i + 1) % 16
																					elif i <= 47:
																												_lowerCAmelCase     :							Union[str, Any]    =    b ^ c ^ d
																												_lowerCAmelCase     :							Optional[int]    =    (3 * i + 5) % 16
																					else:
																												_lowerCAmelCase     :							List[str]    =    c ^ (b | not_aa(_lowerCamelCase  ))
																												_lowerCAmelCase     :							int    =    (7 * i) % 16
																					_lowerCAmelCase     :							int    =    (f + a + added_consts[i] + block_words[g]) % 2**32
																					_lowerCAmelCase     :							Optional[int]    =    d
																					_lowerCAmelCase     :							Tuple    =    c
																					_lowerCAmelCase     :							int    =    b
																					_lowerCAmelCase     :							Tuple    =    sum_aa(_lowerCamelCase				, left_rotate_aa(_lowerCamelCase				, shift_amounts[i]  )  )

														# Add hashed chunk to running total
														_lowerCAmelCase     :							List[str]    =    sum_aa(_lowerCamelCase				, _lowerCamelCase  )
														_lowerCAmelCase     :							Any    =    sum_aa(_lowerCamelCase				, _lowerCamelCase  )
														_lowerCAmelCase     :							Any    =    sum_aa(_lowerCamelCase				, _lowerCamelCase  )
														_lowerCAmelCase     :							str    =    sum_aa(_lowerCamelCase				, _lowerCamelCase  )

							_lowerCAmelCase     :							Union[str, Any]    =    reformat_hex(_lowerCamelCase  ) + reformat_hex(_lowerCamelCase  ) + reformat_hex(_lowerCamelCase  ) + reformat_hex(_lowerCamelCase  )
							return digest


if __name__ == "__main__":
						import doctest

						doctest.testmod()





def 				A				(					_lowerCamelCase  ):





							'''simple docstring'''




							if bit_count < 0:
														raise ValueError("The given input must be positive"  )

							# get the generated string sequence
							_lowerCAmelCase     :							List[str]    =    gray_code_sequence_string(_lowerCamelCase  )
							#
							# convert them to integers
							for i in range(len(_lowerCamelCase  )  ):
														_lowerCAmelCase     :							List[str]    =    int(sequence[i]				, 2  )

							return sequence






def 				A				(					_lowerCamelCase  ):





							'''simple docstring'''




							if bit_count == 0:
														return ["0"]

							if bit_count == 1:
														return ["0", "1"]

							_lowerCAmelCase     :							List[Any]    =    1 << bit_count  # defines the length of the sequence
							# 1<< n is equivalent to 2^n

							# recursive answer will generate answer for n-1 bits
							_lowerCAmelCase     :							Optional[int]    =    gray_code_sequence_string(bit_count - 1  )

							_lowerCAmelCase     :							str    =    []

							# append 0 to first half of the smaller sequence generated
							for i in range(seq_len // 2  ):
														_lowerCAmelCase     :							Dict    =    "0" + smaller_sequence[i]
														sequence.append(_lowerCamelCase  )

							# append 1 to second half ... start from the end of the list
							for i in reversed(range(seq_len // 2  )  ):
														_lowerCAmelCase     :							Optional[Any]    =    "1" + smaller_sequence[i]
														sequence.append(_lowerCamelCase  )

							return sequence


if __name__ == "__main__":
						import doctest

						doctest.testmod()
