// File: /workspace/github_cpp_makefile_star2_O3/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 0x7dff(%rip), %xmm0     # 0x120f0
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 0xa45f
cmpl %r15d, %r12d
setb %al
cmpl $0x37, %r15d
setb %cl
orb %al, %cl
je 0xa47e
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 0xa36c
movl %ecx, %ecx
movb (%rsi,%rcx), %dl
movl %eax, %edi
movb %dl, 0x30(%rsp,%rdi)
incl %eax
incq %rcx
cmpl %r15d, %ecx
jb 0xa359
movl %eax, %ecx
movb $-0x80, 0x30(%rsp,%rcx)
leal 0x1(%rax), %ebp
cmpl $0x7a, %ebp
movq %rsi, 0x8(%rsp)
ja 0xa3b1
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 0xa49d
testl %r8d, %r8d
je 0xa439
addl $0x40, %r12d
movl %r8d, %ebp
movl %r13d, %r13d
xorl %edi, %edi
leaq 0x10(%rsp), %r15
leaq 0x40(%rdi), %r14
cmpq %r12, %r14
jae 0xa41f
addq 0x8(%rsp), %rdi
jmp 0xa429
addl %r13d, %edi
addq %rsp, %rdi
addq $0x30, %rdi
movq %r15, %rsi
callq 0xa4bc
movq %r14, %rdi
cmpq %rbp, %r14
jb 0xa40f
xorl %eax, %eax
movl 0x10(%rsp,%rax,4), %ecx
bswapl %ecx
movl %ecx, (%rbx,%rax,4)
incq %rax
cmpq $0x5, %rax
jne 0xa43b
addq $0xb8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x8471(%rip), %rdi      # 0x128d7
leaq 0x8044(%rip), %rsi      # 0x124b1
leaq 0x847c(%rip), %rcx      # 0x128f0
movl $0x18d1, %edx           # imm = 0x18D1
callq 0x2140
leaq 0x849d(%rip), %rdi      # 0x12922
leaq 0x8025(%rip), %rsi      # 0x124b1
leaq 0x845d(%rip), %rcx      # 0x128f0
movl $0x18d2, %edx           # imm = 0x18D2
callq 0x2140
leaq 0x849c(%rip), %rdi      # 0x12940
leaq 0x8006(%rip), %rsi      # 0x124b1
leaq 0x843e(%rip), %rcx      # 0x128f0
movl $0x18e3, %edx           # imm = 0x18E3
callq 0x2140