// File: /workspace/github_c_makefile_star2_O0/enzo1982[P]smooth/classes/misc/hash/sha1.cpp
// Function: smooth::Hash::SHA1::Finish()
S::String S::Hash::SHA1::Finish()
{
	UnsignedInt64	 bits	= (buffer.Size() + size) * 8;
	Int		 index	= buffer.Size();

	/* Pad out to 56 mod 64.
	 */
	Int		 padLen	= (index < 56) ? (56 - index) : (120 - index);

	UnsignedByte	*end = new UnsignedByte [128];

	memcpy(end, buffer, index);
	memcpy(end + index, PADDING, padLen);

	for (Int i = 0; i < 8; i++) end[index + padLen + i] = bits >> 8 * (7 - i) & 0xFF;

	Transform(end);

	if (padLen > 56) Transform(end + 64);

	delete [] end;

	String	 string;

	for (Int i = 0; i < 5; i++) string.Append(Number((Int64) ((UnsignedInt32 *) state)[i]).ToHexString(8));

	return string;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xa0, %rsp
movq %rdi, -0x88(%rbp)
movq %rdi, %rax
movq %rax, -0x80(%rbp)
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x10(%rbp), %rdi
movq %rdi, -0x78(%rbp)
addq $0x20, %rdi
callq 0x71140
movq -0x78(%rbp), %rdi
cltq
addq 0x18(%rdi), %rax
shlq $0x3, %rax
movq %rax, -0x18(%rbp)
addq $0x20, %rdi
callq 0x71140
movl %eax, -0x1c(%rbp)
cmpl $0x38, -0x1c(%rbp)
jge 0x100c56
movl $0x38, %eax
subl -0x1c(%rbp), %eax
movl %eax, -0x8c(%rbp)
jmp 0x100c64
movl $0x78, %eax
subl -0x1c(%rbp), %eax
movl %eax, -0x8c(%rbp)
movl -0x8c(%rbp), %eax
movl %eax, -0x20(%rbp)
movl $0x80, %edi
callq 0x5ab20
movq -0x78(%rbp), %rdi
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rax
movq %rax, -0x98(%rbp)
addq $0x20, %rdi
callq 0x71100
movq -0x98(%rbp), %rdi
movq %rax, %rsi
movslq -0x1c(%rbp), %rdx
callq 0x593a0
movq -0x28(%rbp), %rdi
movslq -0x1c(%rbp), %rax
addq %rax, %rdi
movslq -0x20(%rbp), %rdx
leaq 0x10ae84(%rip), %rsi    # 0x20bb40
callq 0x593a0
movl $0x0, -0x2c(%rbp)
cmpl $0x8, -0x2c(%rbp)
jge 0x100d08
movq -0x18(%rbp), %rax
movl $0x7, %ecx
subl -0x2c(%rbp), %ecx
shll $0x3, %ecx
movl %ecx, %ecx
shrq %cl, %rax
andq $0xff, %rax
movb %al, %dl
movq -0x28(%rbp), %rax
movl -0x1c(%rbp), %ecx
addl -0x20(%rbp), %ecx
addl -0x2c(%rbp), %ecx
movslq %ecx, %rcx
movb %dl, (%rax,%rcx)
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0x100cc8
movq -0x78(%rbp), %rdi
movq -0x28(%rbp), %rsi
callq 0x5af20
cmpl $0x38, -0x20(%rbp)
jle 0x100d2c
movq -0x78(%rbp), %rdi
movq -0x28(%rbp), %rsi
addq $0x40, %rsi
callq 0x5af20
movq -0x28(%rbp), %rax
movq %rax, -0xa0(%rbp)
cmpq $0x0, %rax
je 0x100d49
movq -0xa0(%rbp), %rdi
callq 0x5a5e0
movq -0x88(%rbp), %rdi
movb $0x0, -0x2d(%rbp)
xorl %esi, %esi
callq 0x5da90
movl $0x0, -0x34(%rbp)
cmpl $0x5, -0x34(%rbp)
jge 0x100e03
movq -0x78(%rbp), %rax
movslq -0x34(%rbp), %rcx
movl (%rax,%rcx,4), %eax
movl %eax, %esi
leaq -0x60(%rbp), %rdi
callq 0x5dd30
jmp 0x100d84
leaq -0x50(%rbp), %rdi
leaq -0x60(%rbp), %rsi
movl $0x8, %edx
callq 0x5bf10
jmp 0x100d98
movq -0x88(%rbp), %rdi
leaq -0x50(%rbp), %rsi
callq 0x5a710
jmp 0x100daa
leaq -0x50(%rbp), %rdi
callq 0x5df00
leaq -0x60(%rbp), %rdi
callq 0x5d990
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x100d62
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
jmp 0x100e26
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
jmp 0x100df8
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
leaq -0x50(%rbp), %rdi
callq 0x5df00
leaq -0x60(%rbp), %rdi
callq 0x5d990
jmp 0x100e26
movb $0x1, -0x2d(%rbp)
testb $0x1, -0x2d(%rbp)
jne 0x100e19
movq -0x88(%rbp), %rdi
callq 0x5df00
movq -0x80(%rbp), %rax
addq $0xa0, %rsp
popq %rbp
retq
movq -0x88(%rbp), %rdi
callq 0x5df00
movq -0x68(%rbp), %rdi
callq 0x5b6b0
nopl (%rax,%rax)