#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 atoi(char *);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fwrite(int *, int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *, ...);
int rand();
int /*<<< orphan*/ srand(int /*<<< orphan*/);
int /*<<< orphan*/ strcpy(char *, char *);
int /*<<< orphan*/ time(int /*<<< orphan*/);
int main(int argc, char *argv[]) {
  if (argc < 3) {
    printf("Usage: ./<prog> numberofints filename.\n");
    exit(1);
  }
  int numberOfInts = atoi(argv[1]);
  char filename[100];
  strcpy(filename, argv[2]);
  printf("Number Of Integers: %d, Filename: %s.\n", numberOfInts, filename);
  srand(time(0));
  int i;
  FILE *file = fopen(filename, "a+");
  for (i = 0; i < numberOfInts; i++) {
    int i = rand();
    fwrite(&i, sizeof(int), 1, file);
  }
  fclose(file);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x3,-0x8(%rbp)
jge    11db <main+0x3b>
lea    0xe36(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    $0x1,%edi
call   10a0 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1090 <atoi@plt>
mov    %eax,-0x14(%rbp)
lea    -0x80(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rsi
call   1030 <strcpy@plt>
mov    -0x14(%rbp),%esi
lea    -0x80(%rbp),%rdx
lea    0xe1e(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
xor    %edi,%edi
call   1070 <time@plt>
mov    %eax,%edi
call   1060 <srand@plt>
lea    -0x80(%rbp),%rdi
lea    0xe25(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x90(%rbp)
movl   $0x0,-0x84(%rbp)
mov    -0x84(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    128d <main+0xed>
mov    $0x0,%al
call   10c0 <rand@plt>
mov    %eax,-0x94(%rbp)
mov    -0x90(%rbp),%rcx
lea    -0x94(%rbp),%rdi
mov    $0x4,%esi
mov    $0x1,%edx
call   10b0 <fwrite@plt>
mov    -0x84(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x84(%rbp)
jmp    1240 <main+0xa0>
mov    -0x90(%rbp),%rdi
call   1040 <fclose@plt>
xor    %eax,%eax
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x80,%rsp
cmp    $0x2,%edi
jle    125c <main+0xac>
mov    %rsi,%r14
mov    0x8(%rsi),%rdi
call   10a0 <atoi@plt>
mov    %eax,%ebx
mov    0x10(%r14),%rsi
lea    0x10(%rsp),%r14
mov    %r14,%rdi
call   1030 <strcpy@plt>
lea    0xe15(%rip),%rdi
mov    %ebx,%esi
mov    %r14,%rdx
xor    %eax,%eax
call   1060 <printf@plt>
xor    %edi,%edi
call   1080 <time@plt>
mov    %eax,%edi
call   1070 <srand@plt>
lea    0xe1b(%rip),%rsi
mov    %r14,%rdi
call   1090 <fopen@plt>
mov    %rax,%r14
test   %ebx,%ebx
jle    1245 <main+0x95>
lea    0xc(%rsp),%r15
xor    %eax,%eax
call   10d0 <rand@plt>
mov    %eax,0xc(%rsp)
mov    %r15,%rdi
mov    $0x4,%esi
mov    $0x1,%edx
mov    %r14,%rcx
call   10c0 <fwrite@plt>
add    $0xffffffff,%ebx
jne    1220 <main+0x70>
mov    %r14,%rdi
call   1050 <fclose@plt>
xor    %eax,%eax
add    $0x80,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret
lea    0xdc7(%rip),%rdi
call   1040 <puts@plt>
mov    $0x1,%edi
call   10b0 <exit@plt>

LLVM IR (-O0):
@.str = [40 x i8] c"Usage: ./<prog> numberofints filename.\0A\00"
@.str.1 = [39 x i8] c"Number Of Integers: %d, Filename: %s.\0A\00"
@.str.2 = [3 x i8] c"a+\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca [100 x i8]
%8 = alloca i32
%9 = alloca i32*
%10 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%11 = load i32, i32* %4
%12 = icmp slt i32 %11, 3
br i1 %12, label %13, label %16
13: ; preds = %2
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str, i64 0, i64 0))
%15 = call i32 @exit(i32 1)
unreachable
16: ; preds = %2
%17 = load i8**, i8*** %5
%18 = getelementptr inbounds i8*, i8** %17, i64 1
%19 = load i8*, i8** %18
%20 = call i32 @atoi(i8* %19)
store i32 %20, i32* %6
%21 = getelementptr inbounds [100 x i8], [100 x i8]* %7, i64 0, i64 0
%22 = load i8**, i8*** %5
%23 = getelementptr inbounds i8*, i8** %22, i64 2
%24 = load i8*, i8** %23
%25 = call i32 @strcpy(i8* %21, i8* %24)
%26 = load i32, i32* %6
%27 = getelementptr inbounds [100 x i8], [100 x i8]* %7, i64 0, i64 0
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.1, i64 0, i64 0), i32 %26, i8* %27)
%29 = call i32 @time(i32 0)
%30 = call i32 @srand(i32 %29)
%31 = getelementptr inbounds [100 x i8], [100 x i8]* %7, i64 0, i64 0
%32 = call i32* @fopen(i8* %31, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
store i32* %32, i32** %9
store i32 0, i32* %8
br label %33
33: ; preds = %41, %16
%34 = load i32, i32* %8
%35 = load i32, i32* %6
%36 = icmp slt i32 %34, %35
br i1 %36, label %37, label %44
37: ; preds = %33
%38 = call i32 (...) @rand()
store i32 %38, i32* %10
%39 = load i32*, i32** %9
%40 = call i32 @fwrite(i32* %10, i32 4, i32 1, i32* %39)
br label %41
41: ; preds = %37
%42 = load i32, i32* %8
%43 = add nsw i32 %42, 1
store i32 %43, i32* %8
br label %33
44: ; preds = %33
%45 = load i32*, i32** %9
%46 = call i32 @fclose(i32* %45)
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [39 x i8] c"Number Of Integers: %d, Filename: %s.\0A\00"
@.str.2 = [3 x i8] c"a+\00"
@str = [39 x i8] c"Usage: ./<prog> numberofints filename.\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [100 x i8]
%4 = alloca i32
%5 = icmp slt i32 %0, 3
br i1 %5, label %6, label %9
6: ; preds = %2
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @str, i64 0, i64 0))
%8 = tail call i32 @exit(i32 1)
unreachable
9: ; preds = %2
%10 = getelementptr inbounds i8*, i8** %1, i64 1
%11 = load i8*, i8** %10
%12 = tail call i32 @atoi(i8* %11)
%13 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%14 = getelementptr inbounds i8*, i8** %1, i64 2
%15 = load i8*, i8** %14
%16 = call i32 @strcpy(i8* %13, i8* %15)
%17 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @.str.1, i64 0, i64 0), i32 %12, i8* %13)
%18 = call i32 @time(i32 0)
%19 = call i32 @srand(i32 %18)
%20 = call i32* @fopen(i8* %13, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%21 = icmp sgt i32 %12, 0
br i1 %21, label %22, label %30
22: ; preds = %9
%23 = bitcast i32* %4 to i8*
br label %24
24: ; preds = %22, %24
%25 = phi i32 [ 0, %22 ], [ %28, %24 ]
%26 = call i32 (...) @rand()
store i32 %26, i32* %4
%27 = call i32 @fwrite(i32* %4, i32 4, i32 1, i32* %20)
%28 = add nuw nsw i32 %25, 1
%29 = icmp eq i32 %28, %12
br i1 %29, label %30, label %24
30: ; preds = %24, %9
%31 = call i32 @fclose(i32* %20)
ret i32 0
}