"""simple docstring"""






from collections.abc import Generator
from math import sin




def 						SCREAMING_SNAKE_CASE					(  __UpperCAmelCase       )							->   bytes:
				if len(__UpperCAmelCase       ) != 32:
								raise ValueError("Input must be of length 32"       )

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




def 						SCREAMING_SNAKE_CASE					(  __UpperCAmelCase       )							->   bytes:
				if i < 0:
								raise ValueError("Input must be non-negative"       )

				SCREAMING_SNAKE_CASE__		  =				format(__UpperCAmelCase  ,					"08x"       )[-8:]
				SCREAMING_SNAKE_CASE__		  =				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 						SCREAMING_SNAKE_CASE					(  __UpperCAmelCase       )							->   bytes:
				SCREAMING_SNAKE_CASE__		  =				b""
				for char in message:
								bit_string += format(__UpperCAmelCase  ,					"08b"       ).encode("utf-8"       )
				SCREAMING_SNAKE_CASE__		  =				format(len(__UpperCAmelCase       )  ,					"064b"       ).encode("utf-8"       )

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

				return bit_string




def 						SCREAMING_SNAKE_CASE					(  __UpperCAmelCase       )							->   Generator[list[int], None, None]:
				if len(__UpperCAmelCase       ) % 512 != 0:
								raise ValueError("Input must have length that's a multiple of 512"       )

				for pos in range(0  ,					len(__UpperCAmelCase       )  ,					512       ):
								SCREAMING_SNAKE_CASE__		  =				bit_string[pos : pos + 512]
								SCREAMING_SNAKE_CASE__		  =				[]
								for i in range(0  ,					512  ,					32       ):
												block_words.append(int(to_little_endian(block[i : i + 32]       )  ,					2       )       )
								yield block_words




def 						SCREAMING_SNAKE_CASE					(  __UpperCAmelCase       )							->   int:
				if i < 0:
								raise ValueError("Input must be non-negative"       )

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




def 						SCREAMING_SNAKE_CASE					(  __UpperCAmelCase  ,					__UpperCAmelCase       )							->   int:
				return (a + b) % 2**32




def 						SCREAMING_SNAKE_CASE					(  __UpperCAmelCase  ,					__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 >> (32 - shift))) % 2**32




def 						SCREAMING_SNAKE_CASE					(  __UpperCAmelCase       )							->   bytes:
				SCREAMING_SNAKE_CASE__		  =				preprocess(__UpperCAmelCase       )

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

				# Starting states
				SCREAMING_SNAKE_CASE__		  =				0x67_452_301
				SCREAMING_SNAKE_CASE__		  =				0xEF_CDA_B89
				SCREAMING_SNAKE_CASE__		  =				0x98_BAD_CFE
				SCREAMING_SNAKE_CASE__		  =				0x10_325_476

				SCREAMING_SNAKE_CASE__		  =				[
				    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(__UpperCAmelCase       ):
								SCREAMING_SNAKE_CASE__		  =				aa
								SCREAMING_SNAKE_CASE__		  =				ba
								SCREAMING_SNAKE_CASE__		  =				ca
								SCREAMING_SNAKE_CASE__		  =				da

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

								# Add hashed chunk to running total
								SCREAMING_SNAKE_CASE__		  =				sum_aa(__UpperCAmelCase  ,					__UpperCAmelCase       )
								SCREAMING_SNAKE_CASE__		  =				sum_aa(__UpperCAmelCase  ,					__UpperCAmelCase       )
								SCREAMING_SNAKE_CASE__		  =				sum_aa(__UpperCAmelCase  ,					__UpperCAmelCase       )
								SCREAMING_SNAKE_CASE__		  =				sum_aa(__UpperCAmelCase  ,					__UpperCAmelCase       )

				SCREAMING_SNAKE_CASE__		  =				reformat_hex(__UpperCAmelCase       ) + reformat_hex(__UpperCAmelCase       ) + reformat_hex(__UpperCAmelCase       ) + reformat_hex(__UpperCAmelCase       )
				return digest


if __name__ == "__main__":
						import doctest

						doctest.testmod()





"""simple docstring"""






def 						SCREAMING_SNAKE_CASE					(  __UpperCAmelCase       )							->   int:

				if not isinstance(__UpperCAmelCase  ,					__UpperCAmelCase       ):
								raise ValueError("multiplicative_persistence() only accepts integral values"       )
				if num < 0:
								raise ValueError("multiplicative_persistence() does not accept negative values"       )

				SCREAMING_SNAKE_CASE__		  =				0
				SCREAMING_SNAKE_CASE__		  =				str(__UpperCAmelCase       )

				while len(__UpperCAmelCase       ) != 1:
								SCREAMING_SNAKE_CASE__		  =				[int(__UpperCAmelCase       ) for i in num_string]

								SCREAMING_SNAKE_CASE__		  =				1
								for i in range(0  ,					len(__UpperCAmelCase       )       ):
												total *= numbers[i]

								SCREAMING_SNAKE_CASE__		  =				str(__UpperCAmelCase       )

								steps += 1
				return steps




def 						SCREAMING_SNAKE_CASE					(  __UpperCAmelCase       )							->   int:

				if not isinstance(__UpperCAmelCase  ,					__UpperCAmelCase       ):
								raise ValueError("additive_persistence() only accepts integral values"       )
				if num < 0:
								raise ValueError("additive_persistence() does not accept negative values"       )

				SCREAMING_SNAKE_CASE__		  =				0
				SCREAMING_SNAKE_CASE__		  =				str(__UpperCAmelCase       )

				while len(__UpperCAmelCase       ) != 1:
								SCREAMING_SNAKE_CASE__		  =				[int(__UpperCAmelCase       ) for i in num_string]

								SCREAMING_SNAKE_CASE__		  =				0
								for i in range(0  ,					len(__UpperCAmelCase       )       ):
												total += numbers[i]

								SCREAMING_SNAKE_CASE__		  =				str(__UpperCAmelCase       )

								steps += 1
				return steps


if __name__ == "__main__":
						import doctest

						doctest.testmod()




