// File: /workspace/github_c_makefile_star2_O0/aerospike[P]aerospike-common/src/main/citrusleaf/cf_crypto.c
// Function: cf_RIPEMD160_Final
int
cf_RIPEMD160_Final(unsigned char* output, cf_RIPEMD160_CTX* ctx)
{
	uint32_t high = (ctx->total[0] >> 29) | (ctx->total[1] <<  3);
	uint32_t low  = (ctx->total[0] <<  3);

	unsigned char msglen[8];

	PUT_UINT32_LE(low,  msglen, 0);
	PUT_UINT32_LE(high, msglen, 4);

	uint32_t last = ctx->total[0] & 0x3F;
	uint32_t padn = (last < 56) ? (56 - last) : (120 - last);

	int ret = cf_RIPEMD160_Update(ctx, cf_ripemd160_padding, padn);

	if (ret != 0) {
		return ret;
	}

	ret = cf_RIPEMD160_Update(ctx, msglen, 8);

	if (ret != 0) {
		return ret;
	}

	PUT_UINT32_LE(ctx->state[0], output,  0);
	PUT_UINT32_LE(ctx->state[1], output,  4);
	PUT_UINT32_LE(ctx->state[2], output,  8);
	PUT_UINT32_LE(ctx->state[3], output, 12);
	PUT_UINT32_LE(ctx->state[4], output, 16);

	return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq -0x18(%rbp), %rax
movl (%rax), %eax
shrl $0x1d, %eax
movq -0x18(%rbp), %rcx
movl 0x4(%rcx), %ecx
shll $0x3, %ecx
orl %ecx, %eax
movl %eax, -0x1c(%rbp)
movq -0x18(%rbp), %rax
movl (%rax), %eax
shll $0x3, %eax
movl %eax, -0x20(%rbp)
movl -0x20(%rbp), %eax
andl $0xff, %eax
movb %al, -0x28(%rbp)
movl -0x20(%rbp), %eax
shrl $0x8, %eax
andl $0xff, %eax
movb %al, -0x27(%rbp)
movl -0x20(%rbp), %eax
shrl $0x10, %eax
andl $0xff, %eax
movb %al, -0x26(%rbp)
movl -0x20(%rbp), %eax
shrl $0x18, %eax
andl $0xff, %eax
movb %al, -0x25(%rbp)
movl -0x1c(%rbp), %eax
andl $0xff, %eax
movb %al, -0x24(%rbp)
movl -0x1c(%rbp), %eax
shrl $0x8, %eax
andl $0xff, %eax
movb %al, -0x23(%rbp)
movl -0x1c(%rbp), %eax
shrl $0x10, %eax
andl $0xff, %eax
movb %al, -0x22(%rbp)
movl -0x1c(%rbp), %eax
shrl $0x18, %eax
andl $0xff, %eax
movb %al, -0x21(%rbp)
movq -0x18(%rbp), %rax
movl (%rax), %eax
andl $0x3f, %eax
movl %eax, -0x2c(%rbp)
cmpl $0x38, -0x2c(%rbp)
jae 0x20bcd
movl $0x38, %eax
subl -0x2c(%rbp), %eax
movl %eax, -0x38(%rbp)
jmp 0x20bd8
movl $0x78, %eax
subl -0x2c(%rbp), %eax
movl %eax, -0x38(%rbp)
movl -0x38(%rbp), %eax
movl %eax, -0x30(%rbp)
movq -0x18(%rbp), %rdi
movl -0x30(%rbp), %eax
movl %eax, %edx
leaq 0x6c02(%rip), %rsi      # 0x277f0
callq 0x84d0
movl %eax, -0x34(%rbp)
cmpl $0x0, -0x34(%rbp)
je 0x20c07
movl -0x34(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x20e04
movq -0x18(%rbp), %rdi
leaq -0x28(%rbp), %rsi
movl $0x8, %edx
callq 0x84d0
movl %eax, -0x34(%rbp)
cmpl $0x0, -0x34(%rbp)
je 0x20c2d
movl -0x34(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x20e04
movq -0x18(%rbp), %rax
movl 0x8(%rax), %eax
andl $0xff, %eax
movb %al, %cl
movq -0x10(%rbp), %rax
movb %cl, (%rax)
movq -0x18(%rbp), %rax
movl 0x8(%rax), %eax
shrl $0x8, %eax
andl $0xff, %eax
movb %al, %cl
movq -0x10(%rbp), %rax
movb %cl, 0x1(%rax)
movq -0x18(%rbp), %rax
movl 0x8(%rax), %eax
shrl $0x10, %eax
andl $0xff, %eax
movb %al, %cl
movq -0x10(%rbp), %rax
movb %cl, 0x2(%rax)
movq -0x18(%rbp), %rax
movl 0x8(%rax), %eax
shrl $0x18, %eax
andl $0xff, %eax
movb %al, %cl
movq -0x10(%rbp), %rax
movb %cl, 0x3(%rax)
movq -0x18(%rbp), %rax
movl 0xc(%rax), %eax
andl $0xff, %eax
movb %al, %cl
movq -0x10(%rbp), %rax
movb %cl, 0x4(%rax)
movq -0x18(%rbp), %rax
movl 0xc(%rax), %eax
shrl $0x8, %eax
andl $0xff, %eax
movb %al, %cl
movq -0x10(%rbp), %rax
movb %cl, 0x5(%rax)
movq -0x18(%rbp), %rax
movl 0xc(%rax), %eax
shrl $0x10, %eax
andl $0xff, %eax
movb %al, %cl
movq -0x10(%rbp), %rax
movb %cl, 0x6(%rax)
movq -0x18(%rbp), %rax
movl 0xc(%rax), %eax
shrl $0x18, %eax
andl $0xff, %eax
movb %al, %cl
movq -0x10(%rbp), %rax
movb %cl, 0x7(%rax)
movq -0x18(%rbp), %rax
movl 0x10(%rax), %eax
andl $0xff, %eax
movb %al, %cl
movq -0x10(%rbp), %rax
movb %cl, 0x8(%rax)
movq -0x18(%rbp), %rax
movl 0x10(%rax), %eax
shrl $0x8, %eax
andl $0xff, %eax
movb %al, %cl
movq -0x10(%rbp), %rax
movb %cl, 0x9(%rax)
movq -0x18(%rbp), %rax
movl 0x10(%rax), %eax
shrl $0x10, %eax
andl $0xff, %eax
movb %al, %cl
movq -0x10(%rbp), %rax
movb %cl, 0xa(%rax)
movq -0x18(%rbp), %rax
movl 0x10(%rax), %eax
shrl $0x18, %eax
andl $0xff, %eax
movb %al, %cl
movq -0x10(%rbp), %rax
movb %cl, 0xb(%rax)
movq -0x18(%rbp), %rax
movl 0x14(%rax), %eax
andl $0xff, %eax
movb %al, %cl
movq -0x10(%rbp), %rax
movb %cl, 0xc(%rax)
movq -0x18(%rbp), %rax
movl 0x14(%rax), %eax
shrl $0x8, %eax
andl $0xff, %eax
movb %al, %cl
movq -0x10(%rbp), %rax
movb %cl, 0xd(%rax)
movq -0x18(%rbp), %rax
movl 0x14(%rax), %eax
shrl $0x10, %eax
andl $0xff, %eax
movb %al, %cl
movq -0x10(%rbp), %rax
movb %cl, 0xe(%rax)
movq -0x18(%rbp), %rax
movl 0x14(%rax), %eax
shrl $0x18, %eax
andl $0xff, %eax
movb %al, %cl
movq -0x10(%rbp), %rax
movb %cl, 0xf(%rax)
movq -0x18(%rbp), %rax
movl 0x18(%rax), %eax
andl $0xff, %eax
movb %al, %cl
movq -0x10(%rbp), %rax
movb %cl, 0x10(%rax)
movq -0x18(%rbp), %rax
movl 0x18(%rax), %eax
shrl $0x8, %eax
andl $0xff, %eax
movb %al, %cl
movq -0x10(%rbp), %rax
movb %cl, 0x11(%rax)
movq -0x18(%rbp), %rax
movl 0x18(%rax), %eax
shrl $0x10, %eax
andl $0xff, %eax
movb %al, %cl
movq -0x10(%rbp), %rax
movb %cl, 0x12(%rax)
movq -0x18(%rbp), %rax
movl 0x18(%rax), %eax
shrl $0x18, %eax
andl $0xff, %eax
movb %al, %cl
movq -0x10(%rbp), %rax
movb %cl, 0x13(%rax)
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x40, %rsp
popq %rbp
retq
nopl (%rax)