// File: /workspace/github_c_makefile_star2_O0/rb-de0[P]hashverifier-for-monacoin/Lyra2RE/blake.c
// Function: blake32_close
static void
blake32_close(sph_blake_small_context *sc,
	unsigned ub, unsigned n, void *dst, size_t out_size_w32)
{
	union {
		unsigned char buf[64];
		sph_u32 dummy;
	} u;
	size_t ptr, k;
	unsigned bit_len;
	unsigned z;
	sph_u32 th, tl;
	unsigned char *out;

	ptr = sc->ptr;
	bit_len = ((unsigned)ptr << 3) + n;
	z = 0x80 >> n;
	u.buf[ptr] = ((ub & -z) | z) & 0xFF;
	tl = sc->T0 + bit_len;
	th = sc->T1;
	if (ptr == 0 && n == 0) {
		sc->T0 = SPH_C32(0xFFFFFE00);
		sc->T1 = SPH_C32(0xFFFFFFFF);
	} else if (sc->T0 == 0) {
		sc->T0 = SPH_C32(0xFFFFFE00) + bit_len;
		sc->T1 = SPH_T32(sc->T1 - 1);
	} else {
		sc->T0 -= 512 - bit_len;
	}
	if (bit_len <= 446) {
		memset(u.buf + ptr + 1, 0, 55 - ptr);
		if (out_size_w32 == 8)
			u.buf[55] |= 1;
		sph_enc32be_aligned(u.buf + 56, th);
		sph_enc32be_aligned(u.buf + 60, tl);
		blake32(sc, u.buf + ptr, 64 - ptr);
	} else {
		memset(u.buf + ptr + 1, 0, 63 - ptr);
		blake32(sc, u.buf + ptr, 64 - ptr);
		sc->T0 = SPH_C32(0xFFFFFE00);
		sc->T1 = SPH_C32(0xFFFFFFFF);
		memset(u.buf, 0, 56);
		if (out_size_w32 == 8)
			u.buf[55] = 1;
		sph_enc32be_aligned(u.buf + 56, th);
		sph_enc32be_aligned(u.buf + 60, tl);
		blake32(sc, u.buf, 64);
	}
	out = dst;
	for (k = 0; k < out_size_w32; k ++)
		sph_enc32be(out + (k << 2), sc->H[k]);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x90, %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 0x40(%rax), %rax
movq %rax, -0x68(%rbp)
movq -0x68(%rbp), %rax
shll $0x3, %eax
addl -0x10(%rbp), %eax
movl %eax, -0x74(%rbp)
movl -0x10(%rbp), %ecx
movl $0x80, %eax
sarl %cl, %eax
movl %eax, -0x78(%rbp)
movl -0xc(%rbp), %eax
xorl %ecx, %ecx
subl -0x78(%rbp), %ecx
andl %ecx, %eax
orl -0x78(%rbp), %eax
andl $0xff, %eax
movb %al, %cl
movq -0x68(%rbp), %rax
movb %cl, -0x60(%rbp,%rax)
movq -0x8(%rbp), %rax
movl 0x78(%rax), %eax
addl -0x74(%rbp), %eax
movl %eax, -0x80(%rbp)
movq -0x8(%rbp), %rax
movl 0x7c(%rax), %eax
movl %eax, -0x7c(%rbp)
cmpq $0x0, -0x68(%rbp)
jne 0x1c27b
cmpl $0x0, -0x10(%rbp)
jne 0x1c27b
movq -0x8(%rbp), %rax
movl $0xfffffe00, 0x78(%rax) # imm = 0xFFFFFE00
movq -0x8(%rbp), %rax
movl $0xffffffff, 0x7c(%rax) # imm = 0xFFFFFFFF
jmp 0x1c2c1
movq -0x8(%rbp), %rax
cmpl $0x0, 0x78(%rax)
jne 0x1c2ab
movl -0x74(%rbp), %ecx
addl $0xfffffe00, %ecx       # imm = 0xFFFFFE00
movq -0x8(%rbp), %rax
movl %ecx, 0x78(%rax)
movq -0x8(%rbp), %rax
movl 0x7c(%rax), %ecx
subl $0x1, %ecx
andl $-0x1, %ecx
movq -0x8(%rbp), %rax
movl %ecx, 0x7c(%rax)
jmp 0x1c2bf
movl $0x200, %edx            # imm = 0x200
subl -0x74(%rbp), %edx
movq -0x8(%rbp), %rax
movl 0x78(%rax), %ecx
subl %edx, %ecx
movl %ecx, 0x78(%rax)
jmp 0x1c2c1
cmpl $0x1be, -0x74(%rbp)     # imm = 0x1BE
ja 0x1c336
leaq -0x60(%rbp), %rdi
addq -0x68(%rbp), %rdi
addq $0x1, %rdi
movl $0x37, %edx
subq -0x68(%rbp), %rdx
xorl %esi, %esi
callq 0x1060
cmpq $0x8, -0x20(%rbp)
jne 0x1c2f7
movzbl -0x29(%rbp), %eax
orl $0x1, %eax
movb %al, -0x29(%rbp)
leaq -0x60(%rbp), %rdi
addq $0x38, %rdi
movl -0x7c(%rbp), %esi
callq 0x27c20
leaq -0x60(%rbp), %rdi
addq $0x3c, %rdi
movl -0x80(%rbp), %esi
callq 0x27c20
movq -0x8(%rbp), %rdi
leaq -0x60(%rbp), %rsi
addq -0x68(%rbp), %rsi
movl $0x40, %edx
subq -0x68(%rbp), %rdx
callq 0x143d0
jmp 0x1c3cf
leaq -0x60(%rbp), %rdi
addq -0x68(%rbp), %rdi
addq $0x1, %rdi
movl $0x3f, %edx
subq -0x68(%rbp), %rdx
xorl %esi, %esi
callq 0x1060
movq -0x8(%rbp), %rdi
leaq -0x60(%rbp), %rsi
addq -0x68(%rbp), %rsi
movl $0x40, %edx
subq -0x68(%rbp), %rdx
callq 0x143d0
movq -0x8(%rbp), %rax
movl $0xfffffe00, 0x78(%rax) # imm = 0xFFFFFE00
movq -0x8(%rbp), %rax
movl $0xffffffff, 0x7c(%rax) # imm = 0xFFFFFFFF
leaq -0x60(%rbp), %rdi
xorl %esi, %esi
movl $0x38, %edx
callq 0x1060
cmpq $0x8, -0x20(%rbp)
jne 0x1c39d
movb $0x1, -0x29(%rbp)
leaq -0x60(%rbp), %rdi
addq $0x38, %rdi
movl -0x7c(%rbp), %esi
callq 0x27c20
leaq -0x60(%rbp), %rdi
addq $0x3c, %rdi
movl -0x80(%rbp), %esi
callq 0x27c20
movq -0x8(%rbp), %rdi
leaq -0x60(%rbp), %rsi
movl $0x40, %edx
callq 0x143d0
movq -0x18(%rbp), %rax
movq %rax, -0x88(%rbp)
movq $0x0, -0x70(%rbp)
movq -0x70(%rbp), %rax
cmpq -0x20(%rbp), %rax
jae 0x1c41d
movq -0x88(%rbp), %rdi
movq -0x70(%rbp), %rax
shlq $0x2, %rax
addq %rax, %rdi
movq -0x8(%rbp), %rax
movq -0x70(%rbp), %rcx
movl 0x48(%rax,%rcx,4), %esi
callq 0x27c50
movq -0x70(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x70(%rbp)
jmp 0x1c3e2
addq $0x90, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)