#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 /*<<< orphan*/ putw(int /*<<< orphan*/, int /*<<< orphan*/ *);
int /*<<< orphan*/ stderr;
main() {
  FILE *statFyle;
  int i;
  if ((statFyle = fopen("/u0/habitat/fredStats", "w")) != NULL) {
    for (i = 0; i < 128; ++i)
      putw(0, statFyle);
    fclose(statFyle);
  } else
    fprintf(stderr, "couldn't open stat file!\n");
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeaa(%rip),%rdi
lea    0xeb9(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x10(%rbp)
cmp    $0x0,%rax
je     11ab <main+0x6b>
movl   $0x0,-0x14(%rbp)
cmpl   $0x80,-0x14(%rbp)
jge    119d <main+0x5d>
mov    -0x10(%rbp),%rsi
xor    %edi,%edi
call   1040 <putw@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1177 <main+0x37>
mov    -0x10(%rbp),%rdi
call   1030 <fclose@plt>
jmp    11c0 <main+0x80>
mov    0x2e2e(%rip),%rax
mov    (%rax),%edi
lea    0xe5d(%rip),%rsi
call   1050 <fprintf@plt>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
lea    0xeb6(%rip),%rdi
lea    0xec5(%rip),%rsi
call   1060 <fopen@plt>
test   %rax,%rax
je     1189 <main+0x49>
mov    %rax,%rbx
mov    $0x80,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
xor    %edi,%edi
mov    %rbx,%rsi
call   1040 <putw@plt>
add    $0xffffffff,%ebp
jne    1170 <main+0x30>
mov    %rbx,%rdi
call   1030 <fclose@plt>
jmp    119e <main+0x5e>
mov    0x2e50(%rip),%rax
mov    (%rax),%edi
lea    0xe7f(%rip),%rsi
call   1050 <fprintf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [22 x i8] c"/u0/habitat/fredStats\00"
@.str.1 = [2 x i8] c"w\00"
@stderr = global i32 0
@.str.2 = [26 x i8] c"couldn't open stat file!\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32*
%3 = alloca i32
store i32 0, i32* %1
%4 = call i32* @fopen(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %4, i32** %2
%5 = icmp ne i32* %4, null
br i1 %5, label %6, label %19
6: ; preds = %0
store i32 0, i32* %3
br label %7
7: ; preds = %13, %6
%8 = load i32, i32* %3
%9 = icmp slt i32 %8, 128
br i1 %9, label %10, label %16
10: ; preds = %7
%11 = load i32*, i32** %2
%12 = call i32 @putw(i32 0, i32* %11)
br label %13
13: ; preds = %10
%14 = load i32, i32* %3
%15 = add nsw i32 %14, 1
store i32 %15, i32* %3
br label %7
16: ; preds = %7
%17 = load i32*, i32** %2
%18 = call i32 @fclose(i32* %17)
br label %22
19: ; preds = %0
%20 = load i32, i32* @stderr
%21 = call i32 @fprintf(i32 %20, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0))
br label %22
22: ; preds = %19, %16
%23 = load i32, i32* %1
ret i32 %23
}

LLVM IR (-O2):
@.str = [22 x i8] c"/u0/habitat/fredStats\00"
@.str.1 = [2 x i8] c"w\00"
@stderr = global i32 0
@.str.2 = [26 x i8] c"couldn't open stat file!\0A\00"
define i32 @main() {
%1 = tail call i32* @fopen(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%2 = icmp eq i32* %1, null
br i1 %2, label %10, label %3
3: ; preds = %0, %3
%4 = phi i32 [ %6, %3 ], [ 0, %0 ]
%5 = tail call i32 @putw(i32 0, i32* %1)
%6 = add nuw nsw i32 %4, 1
%7 = icmp eq i32 %6, 128
br i1 %7, label %8, label %3
8: ; preds = %3
%9 = tail call i32 @fclose(i32* %1)
br label %13
10: ; preds = %0
%11 = load i32, i32* @stderr
%12 = tail call i32 @fprintf(i32 %11, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0))
br label %13
13: ; preds = %10, %8
ret i32 0
}