#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*/ buf;

/* Variables and functions */
scalar_t__ ent_getentropy(char *, int);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, char);
int /*<<< orphan*/ puts(char *);
int main(void) {
  char buf[256] = {0};
  if (0 != ent_getentropy(buf, sizeof(buf))) {
    perror("getentropy");
    exit(1);
  }
  for (int i = 0; i < sizeof buf; i++) {
    printf("%02hhx", buf[i]);
  }
  puts("");
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x120,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x110(%rbp),%rdi
xor    %esi,%esi
mov    $0x100,%edx
call   1050 <memset@plt>
lea    -0x110(%rbp),%rdi
mov    $0x100,%esi
call   1060 <ent_getentropy@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
je     11ba <main+0x5a>
lea    0xe55(%rip),%rdi
call   1070 <perror@plt>
mov    $0x1,%edi
call   1080 <exit@plt>
movl   $0x0,-0x114(%rbp)
movslq -0x114(%rbp),%rax
cmp    $0x100,%rax
jae    1206 <main+0xa6>
movslq -0x114(%rbp),%rax
lea    0xe26(%rip),%rdi
movsbl -0x110(%rbp,%rax,1),%esi
ff
call   1040 <printf@plt>
mov    -0x114(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x114(%rbp)
jmp    11c4 <main+0x64>
lea    0xe04(%rip),%rdi
call   1030 <puts@plt>
mov    -0x4(%rbp),%eax
add    $0x120,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x108,%rsp
xorps  %xmm0,%xmm0
movaps %xmm0,0xf0(%rsp)
movaps %xmm0,0xe0(%rsp)
movaps %xmm0,0xd0(%rsp)
movaps %xmm0,0xc0(%rsp)
movaps %xmm0,0xb0(%rsp)
movaps %xmm0,0xa0(%rsp)
movaps %xmm0,0x90(%rsp)
movaps %xmm0,0x80(%rsp)
movaps %xmm0,0x70(%rsp)
movaps %xmm0,0x60(%rsp)
movaps %xmm0,0x50(%rsp)
movaps %xmm0,0x40(%rsp)
movaps %xmm0,0x30(%rsp)
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x10(%rsp)
movaps %xmm0,(%rsp)
mov    %rsp,%rdi
mov    $0x100,%esi
call   1050 <ent_getentropy@plt>
test   %rax,%rax
jne    1210 <main+0xc0>
xor    %ebx,%ebx
lea    0xe2c(%rip),%r14
nop
movsbl (%rsp,%rbx,1),%esi
mov    %r14,%rdi
call   1040 <printf@plt>
add    $0x1,%rbx
cmp    $0x100,%rbx
jne    11e0 <main+0x90>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
add    $0x108,%rsp
pop    %rbx
pop    %r14
ret
lea    0xde9(%rip),%rdi
call   1060 <perror@plt>
mov    $0x1,%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@.str = [11 x i8] c"getentropy\00"
@.str.1 = [7 x i8] c"%02hhx\00"
@.str.2 = [1 x i8] zeroinitializer
define i32 @main() {
%1 = alloca i32
%2 = alloca [256 x i8]
%3 = alloca i32
store i32 0, i32* %1
%4 = bitcast [256 x i8]* %2 to i8*
%5 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 0
%6 = call i64 @ent_getentropy(i8* %5, i32 256)
%7 = icmp ne i64 0, %6
br i1 %7, label %8, label %11
8: ; preds = %0
%9 = call i32 @perror(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
%10 = call i32 @exit(i32 1)
unreachable
11: ; preds = %0
store i32 0, i32* %3
br label %12
12: ; preds = %22, %11
%13 = load i32, i32* %3
%14 = sext i32 %13 to i64
%15 = icmp ult i64 %14, 256
br i1 %15, label %16, label %25
16: ; preds = %12
%17 = load i32, i32* %3
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 %18
%20 = load i8, i8* %19
%21 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i8 signext %20)
br label %22
22: ; preds = %16
%23 = load i32, i32* %3
%24 = add nsw i32 %23, 1
store i32 %24, i32* %3
br label %12
25: ; preds = %12
%26 = call i32 @puts(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0))
%27 = load i32, i32* %1
ret i32 %27
}

LLVM IR (-O2):
@.str = [11 x i8] c"getentropy\00"
@.str.1 = [7 x i8] c"%02hhx\00"
define i32 @main() {
%1 = alloca [256 x i8]
%2 = getelementptr inbounds [256 x i8], [256 x i8]* %1, i64 0, i64 0
%3 = call i64 @ent_getentropy(i8* %2, i32 256)
%4 = icmp eq i64 %3, 0
br i1 %4, label %10, label %5
5: ; preds = %0
%6 = call i32 @perror(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
%7 = call i32 @exit(i32 1)
unreachable
8: ; preds = %10
%9 = call i32 @putchar(i32 10)
ret i32 0
10: ; preds = %0, %10
%11 = phi i64 [ %15, %10 ], [ 0, %0 ]
%12 = getelementptr inbounds [256 x i8], [256 x i8]* %1, i64 0, i64 %11
%13 = load i8, i8* %12
%14 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i8 signext %13)
%15 = add nuw nsw i64 %11, 1
%16 = icmp eq i64 %15, 256
br i1 %16, label %8, label %10
}