#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */
typedef int /*<<< orphan*/ uint8_t;

/* Variables and functions */
int /*<<< orphan*/ entropium_getRandomBlock(void *);
int /*<<< orphan*/ entropium_getRandomByte();
void entropium_fillBlockRandom(void *block, unsigned length_B) {
  while (length_B > 32) {
    entropium_getRandomBlock(block);
    block = (uint8_t *)block + 32;
    length_B -= 32;
  }
  while (length_B) {
    *((uint8_t *)block) = entropium_getRandomByte();
    block = (uint8_t *)block + 1;
    --length_B;
  }
}


x86 assembly (clang, -O0):
<entropium_fillBlockRandom>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
cmpl   $0x20,-0xc(%rbp)
jbe    115e <entropium_fillBlockRandom+0x3e>
mov    -0x8(%rbp),%rdi
call   1040 <entropium_getRandomBlock@plt>
mov    -0x8(%rbp),%rax
add    $0x80,%rax
mov    %rax,-0x8(%rbp)
mov    -0xc(%rbp),%eax
sub    $0x20,%eax
mov    %eax,-0xc(%rbp)
jmp    112f <entropium_fillBlockRandom+0xf>
jmp    1163 <entropium_fillBlockRandom+0x43>
cmpl   $0x0,-0xc(%rbp)
je     1196 <entropium_fillBlockRandom+0x76>
mov    $0x0,%al
call   1030 <entropium_getRandomByte@plt>
mov    %eax,%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x8(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x8(%rbp)
mov    -0xc(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0xc(%rbp)
jmp    1163 <entropium_fillBlockRandom+0x43>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<entropium_fillBlockRandom>:
push   %rbp
push   %r14
push   %rbx
mov    %esi,%ebp
mov    %rdi,%rbx
cmp    $0x21,%esi
jb     1146 <entropium_fillBlockRandom+0x26>
xchg   %ax,%ax
mov    %rbx,%rdi
call   1040 <entropium_getRandomBlock@plt>
sub    $0xffffffffffffff80,%rbx
add    $0xffffffe0,%ebp
cmp    $0x20,%ebp
ja     1130 <entropium_fillBlockRandom+0x10>
jmp    114a <entropium_fillBlockRandom+0x2a>
test   %ebp,%ebp
je     1163 <entropium_fillBlockRandom+0x43>
mov    %ebp,%r14d
xor    %ebp,%ebp
nop
xor    %eax,%eax
call   1030 <entropium_getRandomByte@plt>
mov    %eax,(%rbx,%rbp,4)
add    $0x1,%rbp
cmp    %ebp,%r14d
jne    1150 <entropium_fillBlockRandom+0x30>
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define void @entropium_fillBlockRandom(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
store i8* %0, i8** %3
store i32 %1, i32* %4
br label %5
5: ; preds = %8, %2
%6 = load i32, i32* %4
%7 = icmp ugt i32 %6, 32
br i1 %7, label %8, label %17
8: ; preds = %5
%9 = load i8*, i8** %3
%10 = call i32 @entropium_getRandomBlock(i8* %9)
%11 = load i8*, i8** %3
%12 = bitcast i8* %11 to i32*
%13 = getelementptr inbounds i32, i32* %12, i64 32
%14 = bitcast i32* %13 to i8*
store i8* %14, i8** %3
%15 = load i32, i32* %4
%16 = sub i32 %15, 32
store i32 %16, i32* %4
br label %5
17: ; preds = %5
br label %18
18: ; preds = %21, %17
%19 = load i32, i32* %4
%20 = icmp ne i32 %19, 0
br i1 %20, label %21, label %31
21: ; preds = %18
%22 = call i32 (...) @entropium_getRandomByte()
%23 = load i8*, i8** %3
%24 = bitcast i8* %23 to i32*
store i32 %22, i32* %24
%25 = load i8*, i8** %3
%26 = bitcast i8* %25 to i32*
%27 = getelementptr inbounds i32, i32* %26, i64 1
%28 = bitcast i32* %27 to i8*
store i8* %28, i8** %3
%29 = load i32, i32* %4
%30 = add i32 %29, -1
store i32 %30, i32* %4
br label %18
31: ; preds = %18
ret void
}

LLVM IR (-O2):
define void @entropium_fillBlockRandom(i8* %0, i32 %1) {
%3 = icmp ugt i32 %1, 32
br i1 %3, label %6, label %4
4: ; preds = %2
%5 = icmp eq i32 %1, 0
br i1 %5, label %24, label %13
6: ; preds = %2, %6
%7 = phi i32 [ %11, %6 ], [ %1, %2 ]
%8 = phi i8* [ %10, %6 ], [ %0, %2 ]
%9 = tail call i32 @entropium_getRandomBlock(i8* %8)
%10 = getelementptr inbounds i8, i8* %8, i64 128
%11 = add i32 %7, -32
%12 = icmp ugt i32 %11, 32
br i1 %12, label %6, label %13
13: ; preds = %6, %4
%14 = phi i32 [ %1, %4 ], [ %11, %6 ]
%15 = phi i8* [ %0, %4 ], [ %10, %6 ]
br label %16
16: ; preds = %13, %16
%17 = phi i32 [ %22, %16 ], [ %14, %13 ]
%18 = phi i8* [ %21, %16 ], [ %15, %13 ]
%19 = tail call i32 (...) @entropium_getRandomByte()
%20 = bitcast i8* %18 to i32*
store i32 %19, i32* %20
%21 = getelementptr inbounds i8, i8* %18, i64 4
%22 = add i32 %17, -1
%23 = icmp eq i32 %22, 0
br i1 %23, label %24, label %16
24: ; preds = %16, %4
ret void
}