// File: /workspace/github_c_makefile_star2_O1/Tarsnap[P]spiped/liball/../libcperciva/crypto/crypto_entropy.c
// Function: crypto_entropy_read
int
crypto_entropy_read(uint8_t * buf, size_t buflen)
{
	size_t bytes_to_provide;

	/* Instantiate if needed. */
	if (instantiated == 0) {
		/* Try to instantiate the PRNG. */
		if (instantiate())
			return (-1);

		/* We have instantiated the PRNG. */
		instantiated = 1;
	}

	/* Loop until we've filled the buffer. */
	while (buflen > 0) {
		/* Do we need to reseed? */
		if (drbg.reseed_counter > RESEED_INTERVAL) {
			if (reseed())
				return (-1);
		}

		/* How much data are we generating in this step? */
		if (buflen > GENERATE_MAXLEN)
			bytes_to_provide = GENERATE_MAXLEN;
		else
			bytes_to_provide = buflen;

		/* Generate bytes. */
		generate(buf, bytes_to_provide);

		/* We've done part of the buffer. */
		buf += bytes_to_provide;
		buflen -= bytes_to_provide;
	}

	/* Success! */
	return (0);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %rsi, %rbx
movq %rdi, %r14
cmpb $0x0, 0xaadd(%rip)      # 0x12694
je 0x7d23
testq %rbx, %rbx
je 0x7d40
leaq 0x10(%rsp), %r15
leaq 0xaac6(%rip), %r12      # 0x12698
leaq 0xaadf(%rip), %r13      # 0x126b8
cmpl $0x101, 0xaaf5(%rip)    # imm = 0x101
jb 0x7c52
movl $0x20, %esi
movq %r15, %rdi
callq 0x965b
testl %eax, %eax
jne 0x7d36
movl %eax, %ebp
movl $0x20, %esi
movq %r15, %rdi
callq 0x7e21
leaq 0x1ab58(%rip), %rax     # 0x22768
cmpl $0x0, (%rax)
je 0x7c1c
callq 0x7f94
jmp 0x7c2c
leaq 0x1ab49(%rip), %rax     # 0x2276c
cmpl $0x0, (%rax)
je 0x7cfb
movl $0x1, 0xaaa2(%rip)      # 0x126d8
leaq 0xa99b(%rip), %rax      # 0x125d8
movq (%rax), %rax
movl $0x20, %esi
movq %r15, %rdi
callq *%rax
testl %ebp, %ebp
jne 0x7d36
movl $0x10000, %eax          # imm = 0x10000
cmpq %rax, %rbx
movl $0x10000, %r15d         # imm = 0x10000
movq %rbx, 0x8(%rsp)
cmovbq %rbx, %r15
cmpl $0x100, 0xaa65(%rip)    # imm = 0x100
ja 0x7e02
movq %r15, %rbp
xorl %ebx, %ebx
movl $0x20, %esi
movl $0x20, %ecx
movq %r12, %rdi
movq %r13, %rdx
movq %r13, %r8
callq 0x485d
leaq (%r14,%rbx), %rdi
cmpq $0x20, %rbp
jb 0x7cb7
movups 0xaa21(%rip), %xmm0     # 0x126c8
movups %xmm0, 0x10(%rdi)
movups 0xaa06(%rip), %xmm0     # 0x126b8
movups %xmm0, (%rdi)
jmp 0x7cc2
movq %r13, %rsi
movq %rbp, %rdx
callq 0x24b0
addq $0x20, %rbx
addq $-0x20, %rbp
cmpq %r15, %rbx
jb 0x7c7e
xorl %ebp, %ebp
xorl %edi, %edi
xorl %esi, %esi
callq 0x7e21
incl 0xa9f8(%rip)            # 0x126d8
addq %r15, %r14
movq 0x8(%rsp), %rbx
subq %r15, %rbx
leaq 0x10(%rsp), %r15
jne 0x7bd9
jmp 0x7dcd
callq 0xa6b8
leaq 0x1aa61(%rip), %rcx     # 0x22768
movl %eax, (%rcx)
leaq 0x1aa5c(%rip), %rcx     # 0x2276c
movl $0x1, (%rcx)
testl %eax, %eax
jne 0x7c15
jmp 0x7c2c
leaq 0x10(%rsp), %rdi
movl $0x30, %esi
callq 0x965b
testl %eax, %eax
je 0x7d47
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
jmp 0x7dcd
xorl %ebp, %ebp
jmp 0x7dcd
movl %eax, %r15d
movq %rbx, %r13
xorps %xmm0, %xmm0
movups %xmm0, 0xa951(%rip)     # 0x126a8
movups %xmm0, 0xa93a(%rip)     # 0x12698
movaps 0x508b(%rip), %xmm0     # 0xcdf0
movups %xmm0, 0xa94c(%rip)     # 0x126b8
movups %xmm0, 0xa955(%rip)     # 0x126c8
movl $0x1, 0xa95b(%rip)      # 0x126d8
leaq 0x10(%rsp), %rdi
movl $0x30, %esi
callq 0x7e21
leaq 0x1a9d5(%rip), %rbx     # 0x22768
cmpl $0x0, (%rbx)
je 0x7d9f
callq 0x7f94
jmp 0x7dad
leaq 0x1a9c6(%rip), %r12     # 0x2276c
cmpl $0x0, (%r12)
je 0x7ded
leaq 0xa824(%rip), %rax      # 0x125d8
movq (%rax), %rax
leaq 0x10(%rsp), %rdi
movl $0x30, %esi
callq *%rax
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
testl %r15d, %r15d
je 0x7dde
movl %ebp, %eax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %r13, %rbx
movb $0x1, 0xa8ac(%rip)      # 0x12694
jmp 0x7bbd
callq 0xa6b8
movl %eax, (%rbx)
movl $0x1, (%r12)
testl %eax, %eax
jne 0x7d98
jmp 0x7dad
leaq 0x503f(%rip), %rdi      # 0xce48
leaq 0x4ff0(%rip), %rsi      # 0xce00
leaq 0x5010(%rip), %rcx      # 0xce27
movl $0xb8, %edx
callq 0x2130