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

/* Variables and functions */
int atoi(char *);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fwrite(char *, int, int, int /*<<< orphan*/ *);
int main(int argc, char **argv) {
  FILE *fp;
  int i;
  char x[1024];
  int limit = 25000;
  if (argc > 1) {
    int j;
    j = atoi(argv[1]);
    if (j > 0)
      limit = j;
  }
  fp = fopen("bigfile", "w");
  for (i = 0; i < 1024; i++)
    x[i] = (char)i;
  for (i = 0; i < limit; i++)
    fwrite(x, sizeof(x[0]), sizeof(x) / sizeof(x[0]), fp);
  fclose(fp);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x430,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x61a8,-0x424(%rbp)
cmpl   $0x1,-0x8(%rbp)
jle    119e <main+0x5e>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1050 <atoi@plt>
mov    %eax,-0x428(%rbp)
cmpl   $0x0,-0x428(%rbp)
jle    1199 <main+0x59>
mov    -0x428(%rbp),%eax
mov    %eax,-0x424(%rbp)
jmp    119e <main+0x5e>
lea    0xe5b(%rip),%rdi
lea    0xe5c(%rip),%rsi
call   1040 <fopen@plt>
mov    %rax,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
cmpl   $0x400,-0x1c(%rbp)
jge    11e7 <main+0xa7>
mov    -0x1c(%rbp),%eax
mov    %al,%cl
movslq -0x1c(%rbp),%rax
mov    %cl,-0x420(%rbp,%rax,1)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    11bc <main+0x7c>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x424(%rbp),%eax
jge    1225 <main+0xe5>
lea    -0x420(%rbp),%rdi
mov    -0x18(%rbp),%rcx
mov    $0x1,%esi
mov    $0x400,%edx
call   1060 <fwrite@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    11ee <main+0xae>
mov    -0x18(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x4(%rbp),%eax
add    $0x430,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x400,%rsp
mov    $0x61a8,%ebp
cmp    $0x2,%edi
jl     1168 <main+0x28>
mov    0x8(%rsi),%rdi
call   1050 <atoi@plt>
test   %eax,%eax
mov    $0x61a8,%ebp
cmovg  %eax,%ebp
lea    0xf21(%rip),%rdi
lea    0xf22(%rip),%rsi
call   1040 <fopen@plt>
mov    %rax,%r14
movdqa 0xe7a(%rip),%xmm2
xor    %eax,%eax
movdqa 0xe7f(%rip),%xmm8
movdqa 0xe86(%rip),%xmm9
movdqa 0xe8e(%rip),%xmm3
movdqa 0xe96(%rip),%xmm4
movdqa 0xe9e(%rip),%xmm5
movdqa 0xea6(%rip),%xmm6
movdqa 0xeae(%rip),%xmm7
movdqa 0xeb6(%rip),%xmm1
nopw   0x0(%rax,%rax,1)
movdqa %xmm2,(%rsp,%rax,1)
movdqa %xmm2,%xmm0
paddb  %xmm8,%xmm0
movdqa %xmm0,0x10(%rsp,%rax,1)
movdqa %xmm2,%xmm0
paddb  %xmm9,%xmm0
movdqa %xmm0,0x20(%rsp,%rax,1)
movdqa %xmm2,%xmm0
paddb  %xmm3,%xmm0
movdqa %xmm0,0x30(%rsp,%rax,1)
movdqa %xmm2,%xmm0
paddb  %xmm4,%xmm0
movdqa %xmm0,0x40(%rsp,%rax,1)
movdqa %xmm2,%xmm0
paddb  %xmm5,%xmm0
movdqa %xmm0,0x50(%rsp,%rax,1)
movdqa %xmm2,%xmm0
paddb  %xmm6,%xmm0
movdqa %xmm0,0x60(%rsp,%rax,1)
movdqa %xmm2,%xmm0
paddb  %xmm7,%xmm0
movdqa %xmm0,0x70(%rsp,%rax,1)
sub    $0xffffffffffffff80,%rax
pxor   %xmm1,%xmm2
cmp    $0x400,%rax
jne    11d0 <main+0x90>
cmp    $0x2,%ebp
mov    $0x1,%eax
cmovl  %eax,%ebp
mov    %rsp,%rbx
nopw   0x0(%rax,%rax,1)
mov    %rbx,%rdi
mov    $0x1,%esi
mov    $0x400,%edx
mov    %r14,%rcx
call   1060 <fwrite@plt>
add    $0xffffffff,%ebp
jne    1260 <main+0x120>
mov    %r14,%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
add    $0x400,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [8 x i8] c"bigfile\00"
@.str.1 = [2 x i8] c"w\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 [1024 x i8]
%9 = alloca i32
%10 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 25000, i32* %9
%11 = load i32, i32* %4
%12 = icmp sgt i32 %11, 1
br i1 %12, label %13, label %23
13: ; preds = %2
%14 = load i8**, i8*** %5
%15 = getelementptr inbounds i8*, i8** %14, i64 1
%16 = load i8*, i8** %15
%17 = call i32 @atoi(i8* %16)
store i32 %17, i32* %10
%18 = load i32, i32* %10
%19 = icmp sgt i32 %18, 0
br i1 %19, label %20, label %22
20: ; preds = %13
%21 = load i32, i32* %10
store i32 %21, i32* %9
br label %22
22: ; preds = %20, %13
br label %23
23: ; preds = %22, %2
%24 = call i32* @fopen(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %24, i32** %6
store i32 0, i32* %7
br label %25
25: ; preds = %34, %23
%26 = load i32, i32* %7
%27 = icmp slt i32 %26, 1024
br i1 %27, label %28, label %37
28: ; preds = %25
%29 = load i32, i32* %7
%30 = trunc i32 %29 to i8
%31 = load i32, i32* %7
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 %32
store i8 %30, i8* %33
br label %34
34: ; preds = %28
%35 = load i32, i32* %7
%36 = add nsw i32 %35, 1
store i32 %36, i32* %7
br label %25
37: ; preds = %25
store i32 0, i32* %7
br label %38
38: ; preds = %46, %37
%39 = load i32, i32* %7
%40 = load i32, i32* %9
%41 = icmp slt i32 %39, %40
br i1 %41, label %42, label %49
42: ; preds = %38
%43 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 0
%44 = load i32*, i32** %6
%45 = call i32 @fwrite(i8* %43, i32 1, i32 1024, i32* %44)
br label %46
46: ; preds = %42
%47 = load i32, i32* %7
%48 = add nsw i32 %47, 1
store i32 %48, i32* %7
br label %38
49: ; preds = %38
%50 = load i32*, i32** %6
%51 = call i32 @fclose(i32* %50)
%52 = load i32, i32* %3
ret i32 %52
}

LLVM IR (-O2):
@.str = [8 x i8] c"bigfile\00"
@.str.1 = [2 x i8] c"w\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [1024 x i8]
%4 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%5 = icmp sgt i32 %0, 1
br i1 %5, label %6, label %12
6: ; preds = %2
%7 = getelementptr inbounds i8*, i8** %1, i64 1
%8 = load i8*, i8** %7
%9 = tail call i32 @atoi(i8* %8)
%10 = icmp sgt i32 %9, 0
%11 = select i1 %10, i32 %9, i32 25000
br label %12
12: ; preds = %6, %2
%13 = phi i32 [ %11, %6 ], [ 25000, %2 ]
%14 = tail call i32* @fopen(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %15
15: ; preds = %15, %12
%16 = phi i64 [ 0, %12 ], [ %48, %15 ]
%17 = phi <16 x i8> [ <i8 0, i8 1, i8 2, i8 3, i8 4, i8 5, i8 6, i8 7, i8 8, i8 9, i8 10, i8 11, i8 12, i8 13, i8 14, i8 15>, %12 ], [ %49, %15 ]
%18 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 %16
%19 = bitcast i8* %18 to <16 x i8>*
store <16 x i8> %17, <16 x i8>* %19
%20 = or i64 %16, 16
%21 = add <16 x i8> %17, <i8 16, i8 16, i8 16, i8 16, i8 16, i8 16, i8 16, i8 16, i8 16, i8 16, i8 16, i8 16, i8 16, i8 16, i8 16, i8 16>
%22 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 %20
%23 = bitcast i8* %22 to <16 x i8>*
store <16 x i8> %21, <16 x i8>* %23
%24 = or i64 %16, 32
%25 = add <16 x i8> %17, <i8 32, i8 32, i8 32, i8 32, i8 32, i8 32, i8 32, i8 32, i8 32, i8 32, i8 32, i8 32, i8 32, i8 32, i8 32, i8 32>
%26 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 %24
%27 = bitcast i8* %26 to <16 x i8>*
store <16 x i8> %25, <16 x i8>* %27
%28 = or i64 %16, 48
%29 = add <16 x i8> %17, <i8 48, i8 48, i8 48, i8 48, i8 48, i8 48, i8 48, i8 48, i8 48, i8 48, i8 48, i8 48, i8 48, i8 48, i8 48, i8 48>
%30 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 %28
%31 = bitcast i8* %30 to <16 x i8>*
store <16 x i8> %29, <16 x i8>* %31
%32 = or i64 %16, 64
%33 = add <16 x i8> %17, <i8 64, i8 64, i8 64, i8 64, i8 64, i8 64, i8 64, i8 64, i8 64, i8 64, i8 64, i8 64, i8 64, i8 64, i8 64, i8 64>
%34 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 %32
%35 = bitcast i8* %34 to <16 x i8>*
store <16 x i8> %33, <16 x i8>* %35
%36 = or i64 %16, 80
%37 = add <16 x i8> %17, <i8 80, i8 80, i8 80, i8 80, i8 80, i8 80, i8 80, i8 80, i8 80, i8 80, i8 80, i8 80, i8 80, i8 80, i8 80, i8 80>
%38 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 %36
%39 = bitcast i8* %38 to <16 x i8>*
store <16 x i8> %37, <16 x i8>* %39
%40 = or i64 %16, 96
%41 = add <16 x i8> %17, <i8 96, i8 96, i8 96, i8 96, i8 96, i8 96, i8 96, i8 96, i8 96, i8 96, i8 96, i8 96, i8 96, i8 96, i8 96, i8 96>
%42 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 %40
%43 = bitcast i8* %42 to <16 x i8>*
store <16 x i8> %41, <16 x i8>* %43
%44 = or i64 %16, 112
%45 = add <16 x i8> %17, <i8 112, i8 112, i8 112, i8 112, i8 112, i8 112, i8 112, i8 112, i8 112, i8 112, i8 112, i8 112, i8 112, i8 112, i8 112, i8 112>
%46 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 %44
%47 = bitcast i8* %46 to <16 x i8>*
store <16 x i8> %45, <16 x i8>* %47
%48 = add nuw nsw i64 %16, 128
%49 = xor <16 x i8> %17, <i8 -128, i8 -128, i8 -128, i8 -128, i8 -128, i8 -128, i8 -128, i8 -128, i8 -128, i8 -128, i8 -128, i8 -128, i8 -128, i8 -128, i8 -128, i8 -128>
%50 = icmp eq i64 %48, 1024
br i1 %50, label %51, label %15
51: ; preds = %15
%52 = call i32 @llvm.smax.i32(i32 %13, i32 1)
br label %53
53: ; preds = %51, %53
%54 = phi i32 [ %56, %53 ], [ 0, %51 ]
%55 = call i32 @fwrite(i8* %4, i32 1, i32 1024, i32* %14)
%56 = add nuw nsw i32 %54, 1
%57 = icmp eq i32 %56, %52
br i1 %57, label %58, label %53
58: ; preds = %53
%59 = tail call i32 @fclose(i32* %14)
ret i32 0
}