





from collections.abc import Generator
from math import sin




def     a__ (					lowercase__  ):






   '''simple docstring'''






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

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




def     a__ (					lowercase__  ):






   '''simple docstring'''






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

   UpperCAmelCase_											=format(snake_case_  ,    "08x"  )[-8:]
   UpperCAmelCase_											=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__ (					lowercase__  ):






   '''simple docstring'''






   UpperCAmelCase_											=b''''''
   for char in message:
      bit_string += format(snake_case_  ,    "08b"  ).encode("utf-8"  )
   UpperCAmelCase_											=format(len(snake_case_  )  ,    "064b"  ).encode("utf-8"  )

   # Pad bit_string to a multiple of 512 chars
   bit_string += b"1"
   while len(snake_case_  ) % 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     a__ (					lowercase__  ):






   '''simple docstring'''






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

   for pos in range(0  ,    len(snake_case_  )  ,    5_1_2  ):
      UpperCAmelCase_											=bit_string[pos : pos + 5_1_2]
      UpperCAmelCase_											=[]
      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     a__ (					lowercase__  ):






   '''simple docstring'''






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

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




def     a__ (					lowercase__  ,    lowercase__  ):






   '''simple docstring'''






   return (a + b) % 2**3_2




def     a__ (					lowercase__  ,    lowercase__  ):






   '''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 >> (3_2 - shift))) % 2**3_2




def     a__ (					lowercase__  ):






   '''simple docstring'''






   UpperCAmelCase_											=preprocess(snake_case_  )

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

   # Starting states
   UpperCAmelCase_											=0x67_45_23_01
   UpperCAmelCase_											=0xEF_CD_AB_89
   UpperCAmelCase_											=0x98_BA_DC_FE
   UpperCAmelCase_											=0x10_32_54_76

   UpperCAmelCase_											=[
       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(snake_case_  ):
      UpperCAmelCase_											=aa
      UpperCAmelCase_											=ba
      UpperCAmelCase_											=ca
      UpperCAmelCase_											=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
            UpperCAmelCase_											=d ^ (b & (c ^ d))
            UpperCAmelCase_											=i
         elif i <= 3_1:
            # f = (d & b) | (not_32(d) & c)     # Alternate definition for f
            UpperCAmelCase_											=c ^ (d & (b ^ c))
            UpperCAmelCase_											=(5 * i + 1) % 1_6
         elif i <= 4_7:
            UpperCAmelCase_											=b ^ c ^ d
            UpperCAmelCase_											=(3 * i + 5) % 1_6
         else:
            UpperCAmelCase_											=c ^ (b | not_aa(snake_case_  ))
            UpperCAmelCase_											=(7 * i) % 1_6
         UpperCAmelCase_											=(f + a + added_consts[i] + block_words[g]) % 2**3_2
         UpperCAmelCase_											=d
         UpperCAmelCase_											=c
         UpperCAmelCase_											=b
         UpperCAmelCase_											=sum_aa(snake_case_  ,    left_rotate_aa(snake_case_  ,    shift_amounts[i]  )  )

      # Add hashed chunk to running total
      UpperCAmelCase_											=sum_aa(snake_case_  ,    snake_case_  )
      UpperCAmelCase_											=sum_aa(snake_case_  ,    snake_case_  )
      UpperCAmelCase_											=sum_aa(snake_case_  ,    snake_case_  )
      UpperCAmelCase_											=sum_aa(snake_case_  ,    snake_case_  )

   UpperCAmelCase_											=reformat_hex(snake_case_  ) + reformat_hex(snake_case_  ) + reformat_hex(snake_case_  ) + reformat_hex(snake_case_  )
   return digest


if __name__ == "__main__":
     import doctest

     doctest.testmod()











__lowercase  :   Optional[Any]						      =[
    (1000, """M"""),
    (900, """CM"""),
    (500, """D"""),
    (400, """CD"""),
    (100, """C"""),
    (90, """XC"""),
    (50, """L"""),
    (40, """XL"""),
    (10, """X"""),
    (9, """IX"""),
    (5, """V"""),
    (4, """IV"""),
    (1, """I"""),
]




def     a__ (					lowercase__  ):






   '''simple docstring'''






   UpperCAmelCase_											={"I": 1, "V": 5, "X": 1_0, "L": 5_0, "C": 1_0_0, "D": 5_0_0, "M": 1_0_0_0}
   UpperCAmelCase_											=0
   UpperCAmelCase_											=0
   while place < len(lowercase__  ):
      if (place + 1 < len(lowercase__  )) and (vals[roman[place]] < vals[roman[place + 1]]):
         total += vals[roman[place + 1]] - vals[roman[place]]
         place += 2
      else:
         total += vals[roman[place]]
         place += 1
   return total




def     a__ (					lowercase__  ):






   '''simple docstring'''






   UpperCAmelCase_											=[]
   for arabic, roman in ROMAN:
      ((UpperCAmelCase_)						,       (UpperCAmelCase_))											=divmod(lowercase__  ,    lowercase__  )
      result.append(roman * factor  )
      if number == 0:
         break
   return "".join(lowercase__  )


if __name__ == "__main__":
     import doctest

     doctest.testmod()




