'''simple docstring'''




from collections.abc import Generator
from math import sin

def _lowercase	(      lowerCamelCase__						)					->       bytes:





       """simple docstring"""


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

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

def _lowercase	(      lowerCamelCase__						)					->       bytes:





       """simple docstring"""


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

       __UpperCAmelCase  :				Dict       				=		format(lowerCamelCase__							,    "08x"						)[-8:]
       __UpperCAmelCase  :				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 _lowercase	(      lowerCamelCase__						)					->       bytes:





       """simple docstring"""


       __UpperCAmelCase  :				Tuple       				=		b""
       for char in message:
              bit_string += format(lowerCamelCase__							,    "08b"						).encode("utf-8"						)
       __UpperCAmelCase  :				str       				=		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 _lowercase	(      lowerCamelCase__						)					->       Generator[list[int], None, None]:





       """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						):
              __UpperCAmelCase  :				Dict       				=		bit_string[pos : pos + 512]
              __UpperCAmelCase  :				int       				=		[]
              for i in range(0							,    512							,    32						):
                     block_words.append(int(to_little_endian(block[i : i + 32]						)							,    2						)						)
              yield block_words

def _lowercase	(      lowerCamelCase__						)					->       int:





       """simple docstring"""


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

       __UpperCAmelCase  :				Union[str, Any]       				=		format(lowerCamelCase__							,    "032b"						)
       __UpperCAmelCase  :				Tuple       				=		""
       for c in i_str:
              new_str += "1" if c == "0" else "0"
       return int(lowerCamelCase__							,    2						)

def _lowercase	(      lowerCamelCase__							,    lowerCamelCase__						)					->       int:





       """simple docstring"""


       return (a + b) % 2**32

def _lowercase	(      lowerCamelCase__							,    lowerCamelCase__						)					->       int:





       """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 _lowercase	(      lowerCamelCase__						)					->       bytes:





       """simple docstring"""


       __UpperCAmelCase  :				Any       				=		preprocess(lowerCamelCase__						)

       __UpperCAmelCase  :				List[Any]       				=		[int(2**32 * abs(sin(i + 1						)						)						) for i in range(64						)]

       # Starting states
       __UpperCAmelCase  :				Tuple       				=		0X6_7_4_5_2_3_0_1
       __UpperCAmelCase  :				str       				=		0Xe_f_c_d_a_b_8_9
       __UpperCAmelCase  :				Dict       				=		0X9_8_b_a_d_c_f_e
       __UpperCAmelCase  :				str       				=		0X1_0_3_2_5_4_7_6

       __UpperCAmelCase  :				Optional[Any]       				=		[
           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__						):
              __UpperCAmelCase  :				str       				=		aa
              __UpperCAmelCase  :				Optional[int]       				=		ba
              __UpperCAmelCase  :				Optional[int]       				=		ca
              __UpperCAmelCase  :				Tuple       				=		da

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

              # Add hashed chunk to running total
              __UpperCAmelCase  :				Dict       				=		sum_aa(lowerCamelCase__							,    lowerCamelCase__						)
              __UpperCAmelCase  :				Union[str, Any]       				=		sum_aa(lowerCamelCase__							,    lowerCamelCase__						)
              __UpperCAmelCase  :				Optional[Any]       				=		sum_aa(lowerCamelCase__							,    lowerCamelCase__						)
              __UpperCAmelCase  :				Optional[Any]       				=		sum_aa(lowerCamelCase__							,    lowerCamelCase__						)

       __UpperCAmelCase  :				List[str]       				=		reformat_hex(lowerCamelCase__						) + reformat_hex(lowerCamelCase__						) + reformat_hex(lowerCamelCase__						) + reformat_hex(lowerCamelCase__						)
       return digest


if __name__ == "__main__":
   import doctest

   doctest.testmod()







'''simple docstring'''




def _lowercase	(      lowerCamelCase__							,    lowerCamelCase__						)					->       float:





       """simple docstring"""


       if discount_rate < 0:
              raise ValueError("Discount rate cannot be negative"						)
       if not cash_flows:
              raise ValueError("Cash flows list cannot be empty"						)
       __UpperCAmelCase  :				Tuple       				=		sum(
           cash_flow / ((1 + discount_rate) ** i) for i, cash_flow in enumerate(lowerCamelCase__						)						)
       return round(lowerCamelCase__							,    ndigits=2						)


if __name__ == "__main__":
   import doctest

   doctest.testmod()






