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

/* Variables and functions */
int /*<<< orphan*/ cmp(int /*<<< orphan*/);
int rand();
void rand_int() {
  int rounds;
  uint64_t vali = 0;
  unsigned char *valc = (unsigned char *)&vali;
  int i;
  for (rounds = 0; rounds < 10000; ++rounds) {
    for (i = 0; i < 8; ++i)
      valc[i] = rand() % 256;
    cmp(vali);
  }
}


x86 assembly (clang, -O0):
<rand_int>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x8(%rbp)
lea    -0x8(%rbp),%rax
mov    %rax,-0x10(%rbp)
movl   $0x0,-0x4(%rbp)
cmpl   $0x2710,-0x4(%rbp)
jge    119a <rand_int+0x7a>
movl   $0x0,-0x14(%rbp)
cmpl   $0x8,-0x14(%rbp)
jge    1184 <rand_int+0x64>
mov    $0x0,%al
call   1040 <rand@plt>
mov    $0x100,%ecx
cltd
idiv   %ecx
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1152 <rand_int+0x32>
mov    -0x8(%rbp),%edi
call   1030 <cmp@plt>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    113e <rand_int+0x1e>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<rand_int>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    $0x2710,%ebp
nopl   (%rax)
xor    %eax,%eax
call   1040 <rand@plt>
mov    %eax,%r14d
xor    %eax,%eax
call   1040 <rand@plt>
mov    %eax,%r12d
xor    %eax,%eax
call   1040 <rand@plt>
mov    %eax,%r15d
xor    %eax,%eax
call   1040 <rand@plt>
mov    %eax,%ebx
xor    %eax,%eax
call   1040 <rand@plt>
xor    %eax,%eax
call   1040 <rand@plt>
xor    %eax,%eax
call   1040 <rand@plt>
xor    %eax,%eax
call   1040 <rand@plt>
shl    $0x18,%ebx
movzbl %r15b,%eax
shl    $0x10,%eax
or     %ebx,%eax
shl    $0x8,%r12d
movzwl %r12w,%ecx
or     %eax,%ecx
movzbl %r14b,%edi
or     %ecx,%edi
call   1030 <cmp@plt>
add    $0xffffffff,%ebp
jne    1130 <rand_int+0x10>
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @rand_int() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i32
store i32 0, i32* %2
%5 = bitcast i32* %2 to i8*
store i8* %5, i8** %3
store i32 0, i32* %1
br label %6
6: ; preds = %27, %0
%7 = load i32, i32* %1
%8 = icmp slt i32 %7, 10000
br i1 %8, label %9, label %30
9: ; preds = %6
store i32 0, i32* %4
br label %10
10: ; preds = %21, %9
%11 = load i32, i32* %4
%12 = icmp slt i32 %11, 8
br i1 %12, label %13, label %24
13: ; preds = %10
%14 = call i32 (...) @rand()
%15 = srem i32 %14, 256
%16 = trunc i32 %15 to i8
%17 = load i8*, i8** %3
%18 = load i32, i32* %4
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds i8, i8* %17, i64 %19
store i8 %16, i8* %20
br label %21
21: ; preds = %13
%22 = load i32, i32* %4
%23 = add nsw i32 %22, 1
store i32 %23, i32* %4
br label %10
24: ; preds = %10
%25 = load i32, i32* %2
%26 = call i32 @cmp(i32 %25)
br label %27
27: ; preds = %24
%28 = load i32, i32* %1
%29 = add nsw i32 %28, 1
store i32 %29, i32* %1
br label %6
30: ; preds = %6
ret void
}

LLVM IR (-O2):
define void @rand_int() {
br label %1
1: ; preds = %0, %1
%2 = phi i32 [ 0, %0 ], [ %21, %1 ]
%3 = tail call i32 (...) @rand()
%4 = tail call i32 (...) @rand()
%5 = tail call i32 (...) @rand()
%6 = tail call i32 (...) @rand()
%7 = tail call i32 (...) @rand()
%8 = tail call i32 (...) @rand()
%9 = tail call i32 (...) @rand()
%10 = tail call i32 (...) @rand()
%11 = shl i32 %6, 24
%12 = shl i32 %5, 16
%13 = and i32 %12, 16711680
%14 = or i32 %11, %13
%15 = shl i32 %4, 8
%16 = and i32 %15, 65280
%17 = or i32 %14, %16
%18 = and i32 %3, 255
%19 = or i32 %17, %18
%20 = tail call i32 @cmp(i32 %19)
%21 = add nuw nsw i32 %2, 1
%22 = icmp eq i32 %21, 10000
br i1 %22, label %23, label %1
23: ; preds = %1
ret void
}