#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*/ int0;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fread(unsigned int *, int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *, unsigned int);
int main() {
  FILE *ran_file;
  unsigned int int0;
  int i;
  for (i = 0; i < 50; i++) {
    ran_file = fopen("/dev/urandom", "r");
    fread(&int0, sizeof(int0), 1, ran_file);
    fclose(ran_file);
    int0 = int0 % 100;
    printf("%u\n", int0);
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x18(%rbp)
cmpl   $0x32,-0x18(%rbp)
jge    11c3 <main+0x83>
lea    0xe99(%rip),%rdi
lea    0xe9f(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rcx
lea    -0x14(%rbp),%rdi
mov    $0x4,%esi
mov    $0x1,%edx
call   1030 <fread@plt>
mov    -0x10(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x14(%rbp),%eax
mov    $0x64,%ecx
xor    %edx,%edx
div    %ecx
mov    %edx,-0x14(%rbp)
mov    -0x14(%rbp),%esi
lea    0xe5f(%rip),%rdi
call   1050 <printf@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1156 <main+0x16>
mov    -0x4(%rbp),%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
mov    $0x32,%ebp
lea    0xea9(%rip),%r14
lea    0xeaf(%rip),%r15
lea    0x4(%rsp),%r12
lea    0xea5(%rip),%r13
nopw   0x0(%rax,%rax,1)
mov    %r14,%rdi
mov    %r15,%rsi
call   1060 <fopen@plt>
mov    %rax,%rbx
mov    %r12,%rdi
mov    $0x4,%esi
mov    $0x1,%edx
mov    %rax,%rcx
call   1030 <fread@plt>
mov    %rbx,%rdi
call   1040 <fclose@plt>
mov    0x4(%rsp),%esi
imul   $0x51eb851f,%rsi,%rax
shr    $0x25,%rax
imul   $0x64,%eax,%eax
sub    %eax,%esi
mov    %esi,0x4(%rsp)
mov    %r13,%rdi
call   1050 <printf@plt>
add    $0xffffffff,%ebp
jne    1170 <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 = [13 x i8] c"/dev/urandom\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [4 x i8] c"%u\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32*
%3 = alloca i32
%4 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %4
br label %5
5: ; preds = %18, %0
%6 = load i32, i32* %4
%7 = icmp slt i32 %6, 50
br i1 %7, label %8, label %21
8: ; preds = %5
%9 = call i32* @fopen(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %9, i32** %2
%10 = load i32*, i32** %2
%11 = call i32 @fread(i32* %3, i32 4, i32 1, i32* %10)
%12 = load i32*, i32** %2
%13 = call i32 @fclose(i32* %12)
%14 = load i32, i32* %3
%15 = urem i32 %14, 100
store i32 %15, i32* %3
%16 = load i32, i32* %3
%17 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %16)
br label %18
18: ; preds = %8
%19 = load i32, i32* %4
%20 = add nsw i32 %19, 1
store i32 %20, i32* %4
br label %5
21: ; preds = %5
%22 = load i32, i32* %1
ret i32 %22
}

LLVM IR (-O2):
@.str = [13 x i8] c"/dev/urandom\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [4 x i8] c"%u\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
br label %3
3: ; preds = %0, %3
%4 = phi i32 [ 0, %0 ], [ %11, %3 ]
%5 = tail call i32* @fopen(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%6 = call i32 @fread(i32* %1, i32 4, i32 1, i32* %5)
%7 = tail call i32 @fclose(i32* %5)
%8 = load i32, i32* %1
%9 = urem i32 %8, 100
store i32 %9, i32* %1
%10 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %9)
%11 = add nuw nsw i32 %4, 1
%12 = icmp eq i32 %11, 50
br i1 %12, label %13, label %3
13: ; preds = %3
ret i32 0
}