// File: /workspace/github_c_makefile_star2_O0/rb-de0[P]hashverifier-for-monacoin/Lyra2RE/bmw.c
// Function: bmw32_close
static void
bmw32_close(sph_bmw_small_context *sc, unsigned ub, unsigned n,
	void *dst, size_t out_size_w32)
{
	unsigned char *buf, *out;
	size_t ptr, u, v;
	unsigned z;
	sph_u32 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_small(buf, h, h1);
		ptr = 0;
		h = h1;
	}
	memset(buf + ptr, 0, (sizeof sc->buf) - 8 - ptr);
#if SPH_64
	sph_enc64le_aligned(buf + (sizeof sc->buf) - 8,
		SPH_T64(sc->bit_count + n));
#else
	sph_enc32le_aligned(buf + (sizeof sc->buf) - 8,
		sc->bit_count_low + n);
	sph_enc32le_aligned(buf + (sizeof sc->buf) - 4,
		SPH_T32(sc->bit_count_high));
#endif
	compress_small(buf, h, h2);
	for (u = 0; u < 16; u ++)
		sph_enc32le_aligned(buf + 4 * u, h2[u]);
	compress_small(buf, final_s, h1);
	out = dst;
	for (u = 0, v = 16 - out_size_w32; u < out_size_w32; u ++, v ++)
		sph_enc32le(out + 4 * u, h1[v]);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xe0, %rsp
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 0x40(%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 $0x48, %rax
movq %rax, -0xd8(%rbp)
cmpq $0x38, -0x38(%rbp)
jbe 0x28063
movq -0x28(%rbp), %rdi
addq -0x38(%rbp), %rdi
movl $0x40, %edx
subq -0x38(%rbp), %rdx
xorl %esi, %esi
callq 0x1060
movq -0x28(%rbp), %rdi
movq -0xd8(%rbp), %rsi
leaq -0x90(%rbp), %rdx
callq 0x287b0
movq $0x0, -0x38(%rbp)
leaq -0x90(%rbp), %rax
movq %rax, -0xd8(%rbp)
movq -0x28(%rbp), %rdi
addq -0x38(%rbp), %rdi
movl $0x38, %edx
subq -0x38(%rbp), %rdx
xorl %esi, %esi
callq 0x1060
movq -0x28(%rbp), %rdi
addq $0x40, %rdi
addq $-0x8, %rdi
movq -0x8(%rbp), %rax
movq 0x88(%rax), %rsi
movl -0x10(%rbp), %eax
addq %rax, %rsi
andq $-0x1, %rsi
callq 0x2e950
movq -0x28(%rbp), %rdi
movq -0xd8(%rbp), %rsi
leaq -0xd0(%rbp), %rdx
callq 0x287b0
movq $0x0, -0x40(%rbp)
cmpq $0x10, -0x40(%rbp)
jae 0x280f4
movq -0x28(%rbp), %rdi
movq -0x40(%rbp), %rax
shlq $0x2, %rax
addq %rax, %rdi
movq -0x40(%rbp), %rax
movl -0xd0(%rbp,%rax,4), %esi
callq 0x2e970
movq -0x40(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x40(%rbp)
jmp 0x280c0
movq -0x28(%rbp), %rdi
leaq -0x90(%rbp), %rdx
leaq 0x3723a(%rip), %rsi     # 0x5f340
callq 0x287b0
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 0x2816b
movq -0x30(%rbp), %rdi
movq -0x40(%rbp), %rax
shlq $0x2, %rax
addq %rax, %rdi
movq -0x48(%rbp), %rax
movl -0x90(%rbp,%rax,4), %esi
callq 0x2e990
movq -0x40(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x40(%rbp)
movq -0x48(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x48(%rbp)
jmp 0x28128
addq $0xe0, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)