#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 uint64_t;
typedef int uint32_t;

/* Variables and functions */
int crc32_rand();
int /*<<< orphan*/ printf(char *, ...);
int rdrand32();
int rdrand64();
int main() {
  uint32_t i = 0;
  printf("iteration,type,value\n");
  for (; i <= 10000; i++) {
    uint32_t r32 = rdrand32();
    uint64_t r64 = rdrand64();
    uint32_t crc32 = crc32_rand();
    printf("%u,%s,%u\n", i, "rdrand32", r32);
    printf("%u,%s,%u\n", i, "crc32_rand", crc32);
    printf("%u,%s,%lu\n", i, "rdrand64", r64);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
lea    0xea3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cmpl   $0x2710,-0x8(%rbp)
jg     11ee <main+0xae>
mov    $0x0,%al
call   1050 <rdrand32@plt>
mov    %eax,-0xc(%rbp)
mov    $0x0,%al
call   1040 <rdrand64@plt>
mov    %eax,-0x10(%rbp)
mov    $0x0,%al
call   1060 <crc32_rand@plt>
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%ecx
lea    0xe7a(%rip),%rdi
lea    0xe7d(%rip),%rdx
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%esi
mov    -0x14(%rbp),%ecx
lea    0xe5f(%rip),%rdi
lea    0xe6b(%rip),%rdx
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%esi
mov    -0x10(%rbp),%ecx
lea    0xe62(%rip),%rdi
lea    0xe66(%rip),%rdx
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1164 <main+0x24>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
lea    0xed0(%rip),%rdi
call   1030 <puts@plt>
lea    0xe92(%rip),%rbx
lea    0xeb4(%rip),%r13
xor    %ebp,%ebp
nopw   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1060 <rdrand32@plt>
mov    %eax,%r14d
xor    %eax,%eax
call   1050 <rdrand64@plt>
mov    %eax,%r15d
xor    %eax,%eax
call   1070 <crc32_rand@plt>
mov    %eax,%r12d
mov    %rbx,%rdi
mov    %ebp,%esi
lea    0xe60(%rip),%rdx
mov    %r14d,%ecx
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    %ebp,%esi
lea    0xe53(%rip),%rdx
mov    %r12d,%ecx
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe4d(%rip),%rdi
mov    %ebp,%esi
mov    %r13,%rdx
mov    %r15d,%ecx
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%ebp
cmp    $0x2711,%ebp
jne    1180 <main+0x30>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [22 x i8] c"iteration,type,value\0A\00"
@.str.1 = [10 x i8] c"%u,%s,%u\0A\00"
@.str.2 = [9 x i8] c"rdrand32\00"
@.str.3 = [11 x i8] c"crc32_rand\00"
@.str.4 = [11 x i8] c"%u,%s,%lu\0A\00"
@.str.5 = [9 x i8] c"rdrand64\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %2
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
br label %7
7: ; preds = %23, %0
%8 = load i32, i32* %2
%9 = icmp sle i32 %8, 10000
br i1 %9, label %10, label %26
10: ; preds = %7
%11 = call i32 (...) @rdrand32()
store i32 %11, i32* %3
%12 = call i32 (...) @rdrand64()
store i32 %12, i32* %4
%13 = call i32 (...) @crc32_rand()
store i32 %13, i32* %5
%14 = load i32, i32* %2
%15 = load i32, i32* %3
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i32 %14, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i32 %15)
%17 = load i32, i32* %2
%18 = load i32, i32* %5
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i32 %17, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), i32 %18)
%20 = load i32, i32* %2
%21 = load i32, i32* %4
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0), i32 %20, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0), i32 %21)
br label %23
23: ; preds = %10
%24 = load i32, i32* %2
%25 = add nsw i32 %24, 1
store i32 %25, i32* %2
br label %7
26: ; preds = %7
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [10 x i8] c"%u,%s,%u\0A\00"
@.str.2 = [9 x i8] c"rdrand32\00"
@.str.3 = [11 x i8] c"crc32_rand\00"
@.str.4 = [11 x i8] c"%u,%s,%lu\0A\00"
@.str.5 = [9 x i8] c"rdrand64\00"
@str = [21 x i8] c"iteration,type,value\00"
define i32 @main() {
%1 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @str, i64 0, i64 0))
br label %2
2: ; preds = %0, %2
%3 = phi i32 [ 0, %0 ], [ %10, %2 ]
%4 = tail call i32 (...) @rdrand32()
%5 = tail call i32 (...) @rdrand64()
%6 = tail call i32 (...) @crc32_rand()
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i32 %3, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i32 %4)
%8 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i32 %3, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), i32 %6)
%9 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0), i32 %3, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0), i32 %5)
%10 = add nuw nsw i32 %3, 1
%11 = icmp eq i32 %10, 10001
br i1 %11, label %12, label %2
12: ; preds = %2
ret i32 0
}