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

/* Variables and functions */
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, int);
int rand();
int /*<<< orphan*/ srand(int /*<<< orphan*/);
int /*<<< orphan*/ sscanf(char *, char *, int *);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
int main(int argc, char **argv) {
  int i;
  int T = 100;
  FILE *fo = fopen("ram_init", "w");
  if (NULL != fo) {
    sscanf(argv[1], "%d", &T);
    srand(time(NULL));
    for (i = 0; i < T; ++i) {
      fprintf(fo, "%08X\n", rand());
    }
    fclose(fo);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x64,-0x18(%rbp)
lea    0xe6c(%rip),%rdi
lea    0xe6e(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x20(%rbp)
xor    %eax,%eax
cmp    -0x20(%rbp),%rax
je     1223 <main+0xb3>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe4c(%rip),%rsi
lea    -0x18(%rbp),%rdx
call   1070 <sscanf@plt>
xor    %eax,%eax
mov    %eax,%edi
call   1060 <time@plt>
mov    %eax,%edi
call   1040 <srand@plt>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    121a <main+0xaa>
mov    -0x20(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    $0x0,%al
call   1090 <rand@plt>
mov    -0x28(%rbp),%rdi
mov    %eax,%edx
lea    0xe07(%rip),%rsi
call   1050 <fprintf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11df <main+0x6f>
mov    -0x20(%rbp),%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rsi,%r14
movl   $0x64,0xc(%rsp)
lea    0xe76(%rip),%rdi
lea    0xe78(%rip),%rsi
call   1080 <fopen@plt>
test   %rax,%rax
je     1205 <main+0x95>
mov    %rax,%rbx
mov    0x8(%r14),%rdi
lea    0xe62(%rip),%rsi
lea    0xc(%rsp),%rdx
call   1070 <sscanf@plt>
xor    %edi,%edi
call   1060 <time@plt>
mov    %eax,%edi
call   1040 <srand@plt>
cmpl   $0x0,0xc(%rsp)
jle    11fd <main+0x8d>
lea    0xe3f(%rip),%r14
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1090 <rand@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %eax,%edx
call   1050 <fprintf@plt>
add    $0x1,%ebp
cmp    0xc(%rsp),%ebp
jl     11e0 <main+0x70>
mov    %rbx,%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [9 x i8] c"ram_init\00"
@.str.1 = [2 x i8] c"w\00"
@.str.2 = [3 x i8] c"%d\00"
@.str.3 = [6 x i8] c"%08X\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 100, i32* %7
%9 = call i32* @fopen(i8* getelementptr inbounds ([9 x i8], [9 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** %8
%10 = load i32*, i32** %8
%11 = icmp ne i32* null, %10
br i1 %11, label %12, label %33
12: ; preds = %2
%13 = load i8**, i8*** %5
%14 = getelementptr inbounds i8*, i8** %13, i64 1
%15 = load i8*, i8** %14
%16 = call i32 @sscanf(i8* %15, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %7)
%17 = call i32 @time(i32* null)
%18 = call i32 @srand(i32 %17)
store i32 0, i32* %6
br label %19
19: ; preds = %27, %12
%20 = load i32, i32* %6
%21 = load i32, i32* %7
%22 = icmp slt i32 %20, %21
br i1 %22, label %23, label %30
23: ; preds = %19
%24 = load i32*, i32** %8
%25 = call i32 (...) @rand()
%26 = call i32 @fprintf(i32* %24, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i32 %25)
br label %27
27: ; preds = %23
%28 = load i32, i32* %6
%29 = add nsw i32 %28, 1
store i32 %29, i32* %6
br label %19
30: ; preds = %19
%31 = load i32*, i32** %8
%32 = call i32 @fclose(i32* %31)
br label %33
33: ; preds = %30, %2
ret i32 0
}

LLVM IR (-O2):
@.str = [9 x i8] c"ram_init\00"
@.str.1 = [2 x i8] c"w\00"
@.str.2 = [3 x i8] c"%d\00"
@.str.3 = [6 x i8] c"%08X\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i32
%4 = bitcast i32* %3 to i8*
store i32 100, i32* %3
%5 = tail call i32* @fopen(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%6 = icmp eq i32* %5, null
br i1 %6, label %24, label %7
7: ; preds = %2
%8 = getelementptr inbounds i8*, i8** %1, i64 1
%9 = load i8*, i8** %8
%10 = call i32 @sscanf(i8* %9, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %3)
%11 = call i32 @time(i32* null)
%12 = call i32 @srand(i32 %11)
%13 = load i32, i32* %3
%14 = icmp sgt i32 %13, 0
br i1 %14, label %15, label %22
15: ; preds = %7, %15
%16 = phi i32 [ %19, %15 ], [ 0, %7 ]
%17 = call i32 (...) @rand()
%18 = call i32 @fprintf(i32* %5, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i32 %17)
%19 = add nuw nsw i32 %16, 1
%20 = load i32, i32* %3
%21 = icmp slt i32 %19, %20
br i1 %21, label %15, label %22
22: ; preds = %15, %7
%23 = call i32 @fclose(i32* %5)
br label %24
24: ; preds = %22, %2
ret i32 0
}