// File: /workspace/github_cpp_makefile_star2_O2/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
movq %rsi, %r14
movaps 0x6d6b(%rip), %xmm0     # 0x100a0
movaps %xmm0, 0x10(%rsp)
movl $0xc3d2e1f0, 0x20(%rsp) # imm = 0xC3D2E1F0
movl %edx, %eax
andl $-0x40, %eax
leal 0x9(%rdx), %ecx
movl %ecx, %esi
andl $-0x40, %esi
leal -0x40(%rax), %r12d
cmpl %eax, %esi
cmovnel %eax, %r12d
leal 0x80(%r12), %eax
cmpl %ecx, %eax
jb 0x9480
cmpl %edx, %r12d
setb %cl
cmpl $0x37, %edx
setb %sil
orb %cl, %sil
je 0x949f
movl %r12d, %ecx
negl %ecx
xorl %esi, %esi
cmpl %edx, %r12d
cmoval %ecx, %esi
leal (%r12,%rsi), %r8d
cmpl %edx, %r8d
jae 0x93a8
movl %r8d, %r8d
movb (%r14,%r8), %r9b
movl %esi, %r8d
movb %r9b, 0x30(%rsp,%r8)
incl %esi
jmp 0x938c
addl $0x4, %esi
movb $-0x80, %r9b
movl %esi, %r8d
leal -0x4(%r8), %esi
movb %r9b, 0x30(%rsp,%rsi)
leal 0x1(%r8), %esi
addl $-0x3, %r8d
xorl %r9d, %r9d
cmpl $0x7b, %r8d
jb 0x93ae
movq %rdi, 0x8(%rsp)
movl %edx, %edi
shrl $0x1d, %edi
leal -0x3(%rsi), %r8d
leal -0x4(%rsi), %r9d
movb %dil, 0x30(%rsp,%r9)
movl %edx, %edi
shrl $0x15, %edi
leal -0x2(%rsi), %r9d
movb %dil, 0x30(%rsp,%r8)
movl %edx, %edi
shrl $0xd, %edi
leal -0x1(%rsi), %r8d
movb %dil, 0x30(%rsp,%r9)
movl %edx, %edi
shrl $0x5, %edi
movb %dil, 0x30(%rsp,%r8)
shlb $0x3, %dl
movl %esi, %edi
movb %dl, 0x30(%rsp,%rdi)
cmpl $0x7f, %esi
jne 0x94be
addl $0x40, %r12d
movl %eax, %r13d
movl %ecx, %ebp
xorl %edi, %edi
leaq 0x10(%rsp), %r15
cmpq %r13, %rdi
jae 0x9453
leaq 0x40(%rdi), %rbx
cmpq %r12, %rbx
jae 0x943d
addq %r14, %rdi
jmp 0x9446
addl %ebp, %edi
addq %rsp, %rdi
addq $0x30, %rdi
movq %r15, %rsi
callq 0x94dd
movq %rbx, %rdi
jmp 0x942a
xorl %eax, %eax
movq 0x8(%rsp), %rdx
cmpq $0x5, %rax
je 0x946e
movl 0x10(%rsp,%rax,4), %ecx
bswapl %ecx
movl %ecx, (%rdx,%rax,4)
incq %rax
jmp 0x945a
addq $0xb8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x73c0(%rip), %rdi      # 0x10847
leaq 0x6f93(%rip), %rsi      # 0x10421
leaq 0x73cb(%rip), %rcx      # 0x10860
movl $0x18d1, %edx           # imm = 0x18D1
callq 0x2140
leaq 0x73ec(%rip), %rdi      # 0x10892
leaq 0x6f74(%rip), %rsi      # 0x10421
leaq 0x73ac(%rip), %rcx      # 0x10860
movl $0x18d2, %edx           # imm = 0x18D2
callq 0x2140
leaq 0x73eb(%rip), %rdi      # 0x108b0
leaq 0x6f55(%rip), %rsi      # 0x10421
leaq 0x738d(%rip), %rcx      # 0x10860
movl $0x18e3, %edx           # imm = 0x18E3
callq 0x2140