#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*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, int, int);
int /*<<< orphan*/ printf(char *);
int main(int argv, char **args) {
  FILE *fp;
  int i;
  fp = fopen("results2.dat", "w");
  if (fp == NULL) {
    printf("I couldn't open results.dat for writing.\n");
    exit(0);
  }
  for (i = 3; i <= 12; ++i) {
    fprintf(fp, "%d, %d\n", i, i * i);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xea3(%rip),%rdi
lea    0xea9(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    118b <main+0x4b>
lea    0xe90(%rip),%rdi
call   1030 <printf@plt>
xor    %edi,%edi
call   1060 <exit@plt>
movl   $0x3,-0x1c(%rbp)
cmpl   $0xc,-0x1c(%rbp)
jg     11c4 <main+0x84>
mov    -0x18(%rbp),%rdi
mov    -0x1c(%rbp),%edx
mov    -0x1c(%rbp),%ecx
imul   -0x1c(%rbp),%ecx
lea    0xe88(%rip),%rsi
call   1040 <fprintf@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1192 <main+0x52>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
lea    0xeb5(%rip),%rdi
lea    0xebb(%rip),%rsi
call   1050 <fopen@plt>
test   %rax,%rax
je     1246 <main+0x106>
mov    %rax,%rbx
lea    0xea5(%rip),%r14
mov    %rax,%rdi
mov    %r14,%rsi
mov    $0x3,%edx
mov    $0x9,%ecx
call   1040 <fprintf@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0x4,%edx
mov    $0x10,%ecx
call   1040 <fprintf@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0x5,%edx
mov    $0x19,%ecx
call   1040 <fprintf@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0x6,%edx
mov    $0x24,%ecx
call   1040 <fprintf@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0x7,%edx
mov    $0x31,%ecx
call   1040 <fprintf@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0x8,%edx
mov    $0x40,%ecx
call   1040 <fprintf@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0x9,%edx
mov    $0x51,%ecx
call   1040 <fprintf@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0xa,%edx
mov    $0x64,%ecx
call   1040 <fprintf@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0xb,%edx
mov    $0x79,%ecx
call   1040 <fprintf@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0xc,%edx
mov    $0x90,%ecx
call   1040 <fprintf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret
lea    0xdca(%rip),%rdi
call   1030 <puts@plt>
xor    %edi,%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@.str = [13 x i8] c"results2.dat\00"
@.str.1 = [2 x i8] c"w\00"
@.str.2 = [42 x i8] c"I couldn't open results.dat for writing.\0A\00"
@.str.3 = [8 x i8] c"%d, %d\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
%7 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = 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* %8, i32** %6
%9 = load i32*, i32** %6
%10 = icmp eq i32* %9, null
br i1 %10, label %11, label %14
11: ; preds = %2
%12 = call i32 @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.2, i64 0, i64 0))
%13 = call i32 @exit(i32 0)
unreachable
14: ; preds = %2
store i32 3, i32* %7
br label %15
15: ; preds = %25, %14
%16 = load i32, i32* %7
%17 = icmp sle i32 %16, 12
br i1 %17, label %18, label %28
18: ; preds = %15
%19 = load i32*, i32** %6
%20 = load i32, i32* %7
%21 = load i32, i32* %7
%22 = load i32, i32* %7
%23 = mul nsw i32 %21, %22
%24 = call i32 @fprintf(i32* %19, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i32 %20, i32 %23)
br label %25
25: ; preds = %18
%26 = load i32, i32* %7
%27 = add nsw i32 %26, 1
store i32 %27, i32* %7
br label %15
28: ; preds = %15
ret i32 0
}

LLVM IR (-O2):
@.str = [13 x i8] c"results2.dat\00"
@.str.1 = [2 x i8] c"w\00"
@.str.3 = [8 x i8] c"%d, %d\0A\00"
@str = [41 x i8] c"I couldn't open results.dat for writing.\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = 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))
%4 = icmp eq i32* %3, null
br i1 %4, label %16, label %5
5: ; preds = %2
%6 = tail call i32 @fprintf(i32* %3, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i32 3, i32 9)
%7 = tail call i32 @fprintf(i32* %3, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i32 4, i32 16)
%8 = tail call i32 @fprintf(i32* %3, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i32 5, i32 25)
%9 = tail call i32 @fprintf(i32* %3, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i32 6, i32 36)
%10 = tail call i32 @fprintf(i32* %3, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i32 7, i32 49)
%11 = tail call i32 @fprintf(i32* %3, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i32 8, i32 64)
%12 = tail call i32 @fprintf(i32* %3, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i32 9, i32 81)
%13 = tail call i32 @fprintf(i32* %3, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i32 10, i32 100)
%14 = tail call i32 @fprintf(i32* %3, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i32 11, i32 121)
%15 = tail call i32 @fprintf(i32* %3, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i32 12, i32 144)
ret i32 0
16: ; preds = %2
%17 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @str, i64 0, i64 0))
%18 = tail call i32 @exit(i32 0)
unreachable
}