// File: /workspace/github_cpp_makefile_star2_O1/attractivechaos[P]udb2/stb/./stb.h
// Function: stb_sha1
void stb_sha1(stb_uchar output[20], stb_uchar *buffer, stb_uint len)
{
   unsigned char final_block[128];
   stb_uint end_start, final_len, j;
   int i;

   stb_uint h[5];

   h[0] = 0x67452301;
   h[1] = 0xefcdab89;
   h[2] = 0x98badcfe;
   h[3] = 0x10325476;
   h[4] = 0xc3d2e1f0;

   // we need to write padding to the last one or two
   // blocks, so build those first into 'final_block'

   // we have to write one special byte, plus the 8-byte length

   // compute the block where the data runs out
   end_start = len & ~63;

   // compute the earliest we can encode the length
   if (((len+9) & ~63) == end_start) {
      // it all fits in one block, so fill a second-to-last block
      end_start -= 64;
   }

   final_len = end_start + 128;

   // now we need to copy the data in
   assert(end_start + 128 >= len+9);
   assert(end_start < len || len < 64-9);

   j = 0;
   if (end_start > len)
      j = (stb_uint) - (int) end_start;

   for (; end_start + j < len; ++j)
      final_block[j] = buffer[end_start + j];
   final_block[j++] = 0x80;
   while (j < 128-5) // 5 byte length, so write 4 extra padding bytes
      final_block[j++] = 0;
   // big-endian size
   final_block[j++] = len >> 29;
   final_block[j++] = len >> 21;
   final_block[j++] = len >> 13;
   final_block[j++] = len >>  5;
   final_block[j++] = len <<  3;
   assert(j == 128 && end_start + j == final_len);

   for (j=0; j < final_len; j += 64) { // 512-bit chunks
      if (j+64 >= end_start+64)
         stb__sha1(&final_block[j - end_start], h);
      else
         stb__sha1(&buffer[j], h);
   }

   for (i=0; i < 5; ++i) {
      output[i*4 + 0] = h[i] >> 24;
      output[i*4 + 1] = h[i] >> 16;
      output[i*4 + 2] = h[i] >>  8;
      output[i*4 + 3] = h[i] >>  0;
   }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xb8, %rsp
movl %edx, %r15d
movaps 0x7d07(%rip), %xmm0     # 0x12150
movaps %xmm0, 0x10(%rsp)
movl $0xc3d2e1f0, 0x20(%rsp) # imm = 0xC3D2E1F0
movl %edx, %eax
andl $-0x40, %eax
leal 0x9(%r15), %ecx
movl %ecx, %edx
andl $-0x40, %edx
leal -0x40(%rax), %r12d
cmpl %eax, %edx
cmovnel %eax, %r12d
leal 0x80(%r12), %r8d
cmpl %ecx, %r8d
jb 0xa5b7
cmpl %r15d, %r12d
setb %al
cmpl $0x37, %r15d
setb %cl
orb %al, %cl
je 0xa5d6
movq %rdi, %rbx
movl %r12d, %r13d
negl %r13d
xorl %eax, %eax
cmpl %r15d, %r12d
cmoval %r13d, %eax
leal (%rax,%r12), %ecx
cmpl %r15d, %ecx
jae 0xa4c4
movl %ecx, %ecx
movb (%rsi,%rcx), %dl
movl %eax, %edi
movb %dl, 0x30(%rsp,%rdi)
incl %eax
incq %rcx
cmpl %r15d, %ecx
jb 0xa4b1
movl %eax, %ecx
movb $-0x80, 0x30(%rsp,%rcx)
leal 0x1(%rax), %ebp
cmpl $0x7a, %ebp
movq %rsi, 0x8(%rsp)
ja 0xa509
movl %ebp, %ecx
leaq (%rsp,%rcx), %rdi
addq $0x30, %rdi
movl $0x79, %r14d
subl %eax, %r14d
leaq 0x1(%r14), %rdx
xorl %esi, %esi
movl %r8d, 0x4(%rsp)
callq 0x2160
movl 0x4(%rsp), %r8d
leal (%r14,%rbp), %eax
addl %r14d, %ebp
incl %ebp
movl %r15d, %ecx
shrl $0x1d, %ecx
leal 0x2(%rax), %edx
movl %ebp, %esi
movb %cl, 0x30(%rsp,%rsi)
movl %r15d, %ecx
shrl $0x15, %ecx
leal 0x3(%rax), %esi
movb %cl, 0x30(%rsp,%rdx)
movl %r15d, %ecx
shrl $0xd, %ecx
leal 0x4(%rax), %edx
movb %cl, 0x30(%rsp,%rsi)
movl %r15d, %ecx
shrl $0x5, %ecx
leal 0x5(%rax), %esi
movb %cl, 0x30(%rsp,%rdx)
shlb $0x3, %r15b
movb %r15b, 0x30(%rsp,%rsi)
cmpl $0x7a, %eax
jne 0xa5f5
testl %r8d, %r8d
je 0xa591
addl $0x40, %r12d
movl %r8d, %ebp
movl %r13d, %r13d
xorl %edi, %edi
leaq 0x10(%rsp), %r15
leaq 0x40(%rdi), %r14
cmpq %r12, %r14
jae 0xa577
addq 0x8(%rsp), %rdi
jmp 0xa581
addl %r13d, %edi
addq %rsp, %rdi
addq $0x30, %rdi
movq %r15, %rsi
callq 0xa614
movq %r14, %rdi
cmpq %rbp, %r14
jb 0xa567
xorl %eax, %eax
movl 0x10(%rsp,%rax,4), %ecx
bswapl %ecx
movl %ecx, (%rbx,%rax,4)
incq %rax
cmpq $0x5, %rax
jne 0xa593
addq $0xb8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x8369(%rip), %rdi      # 0x12927
leaq 0x7f3c(%rip), %rsi      # 0x12501
leaq 0x8374(%rip), %rcx      # 0x12940
movl $0x18d1, %edx           # imm = 0x18D1
callq 0x2140
leaq 0x8395(%rip), %rdi      # 0x12972
leaq 0x7f1d(%rip), %rsi      # 0x12501
leaq 0x8355(%rip), %rcx      # 0x12940
movl $0x18d2, %edx           # imm = 0x18D2
callq 0x2140
leaq 0x8394(%rip), %rdi      # 0x12990
leaq 0x7efe(%rip), %rsi      # 0x12501
leaq 0x8336(%rip), %rcx      # 0x12940
movl $0x18e3, %edx           # imm = 0x18E3
callq 0x2140