// File: /workspace/github_c_makefile_star2_O0/rb-de0[P]hashverifier-for-monacoin/Lyra2RE/bmw.c
// Function: bmw64_close
static void
bmw64_close(sph_bmw_big_context *sc, unsigned ub, unsigned n,
	void *dst, size_t out_size_w64)
{
	unsigned char *buf, *out;
	size_t ptr, u, v;
	unsigned z;
	sph_u64 h1[16], h2[16], *h;

	buf = sc->buf;
	ptr = sc->ptr;
	z = 0x80 >> n;
	buf[ptr ++] = ((ub & -z) | z) & 0xFF;
	h = sc->H;
	if (ptr > (sizeof sc->buf) - 8) {
		memset(buf + ptr, 0, (sizeof sc->buf) - ptr);
		compress_big(buf, h, h1);
		ptr = 0;
		h = h1;
	}
	memset(buf + ptr, 0, (sizeof sc->buf) - 8 - ptr);
	sph_enc64le_aligned(buf + (sizeof sc->buf) - 8,
		SPH_T64(sc->bit_count + n));
	compress_big(buf, h, h2);
	for (u = 0; u < 16; u ++)
		sph_enc64le_aligned(buf + 8 * u, h2[u]);
	compress_big(buf, final_b, h1);
	out = dst;
	for (u = 0, v = 16 - out_size_w64; u < out_size_w64; u ++, v ++)
		sph_enc64le(out + 8 * u, h1[v]);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x160, %rsp            # imm = 0x160
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movl %edx, -0x10(%rbp)
movq %rcx, -0x18(%rbp)
movq %r8, -0x20(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x28(%rbp)
movq -0x8(%rbp), %rax
movq 0x80(%rax), %rax
movq %rax, -0x38(%rbp)
movl -0x10(%rbp), %ecx
movl $0x80, %eax
sarl %cl, %eax
movl %eax, -0x4c(%rbp)
movl -0xc(%rbp), %eax
xorl %ecx, %ecx
subl -0x4c(%rbp), %ecx
andl %ecx, %eax
orl -0x4c(%rbp), %eax
andl $0xff, %eax
movb %al, %dl
movq -0x28(%rbp), %rax
movq -0x38(%rbp), %rcx
movq %rcx, %rsi
addq $0x1, %rsi
movq %rsi, -0x38(%rbp)
movb %dl, (%rax,%rcx)
movq -0x8(%rbp), %rax
addq $0x88, %rax
movq %rax, -0x158(%rbp)
cmpq $0x78, -0x38(%rbp)
jbe 0x285c8
movq -0x28(%rbp), %rdi
addq -0x38(%rbp), %rdi
movl $0x80, %edx
subq -0x38(%rbp), %rdx
xorl %esi, %esi
callq 0x1060
movq -0x28(%rbp), %rdi
movq -0x158(%rbp), %rsi
leaq -0xd0(%rbp), %rdx
callq 0x2e9b0
movq $0x0, -0x38(%rbp)
leaq -0xd0(%rbp), %rax
movq %rax, -0x158(%rbp)
movq -0x28(%rbp), %rdi
addq -0x38(%rbp), %rdi
movl $0x78, %edx
subq -0x38(%rbp), %rdx
xorl %esi, %esi
callq 0x1060
movq -0x28(%rbp), %rdi
addq $0x80, %rdi
addq $-0x8, %rdi
movq -0x8(%rbp), %rax
movq 0x108(%rax), %rsi
movl -0x10(%rbp), %eax
addq %rax, %rsi
andq $-0x1, %rsi
callq 0x2e950
movq -0x28(%rbp), %rdi
movq -0x158(%rbp), %rsi
leaq -0x150(%rbp), %rdx
callq 0x2e9b0
movq $0x0, -0x40(%rbp)
cmpq $0x10, -0x40(%rbp)
jae 0x2865d
movq -0x28(%rbp), %rdi
movq -0x40(%rbp), %rax
shlq $0x3, %rax
addq %rax, %rdi
movq -0x40(%rbp), %rax
movq -0x150(%rbp,%rax,8), %rsi
callq 0x2e950
movq -0x40(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x40(%rbp)
jmp 0x28628
movq -0x28(%rbp), %rdi
leaq -0xd0(%rbp), %rdx
leaq 0x36d11(%rip), %rsi     # 0x5f380
callq 0x2e9b0
movq -0x18(%rbp), %rax
movq %rax, -0x30(%rbp)
movq $0x0, -0x40(%rbp)
movl $0x10, %eax
subq -0x20(%rbp), %rax
movq %rax, -0x48(%rbp)
movq -0x40(%rbp), %rax
cmpq -0x20(%rbp), %rax
jae 0x286d5
movq -0x30(%rbp), %rdi
movq -0x40(%rbp), %rax
shlq $0x3, %rax
addq %rax, %rdi
movq -0x48(%rbp), %rax
movq -0xd0(%rbp,%rax,8), %rsi
callq 0x361f0
movq -0x40(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x40(%rbp)
movq -0x48(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x48(%rbp)
jmp 0x28691
addq $0x160, %rsp            # imm = 0x160
popq %rbp
retq
nop