#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, int);
main() {
  int k;
  FILE *fc;
  fc = fopen("primer1.txt", "w");
  for (k = 1; k < 100; k++) {
    fprintf(fc, "%4d%6d%8d\n", k, k * k, k * k * k);
  }
  fclose(fc);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeba(%rip),%rdi
lea    0xebf(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,-0x10(%rbp)
movl   $0x1,-0x8(%rbp)
cmpl   $0x64,-0x8(%rbp)
jge    119d <main+0x6d>
mov    -0x10(%rbp),%rdi
mov    -0x8(%rbp),%edx
mov    -0x8(%rbp),%ecx
imul   -0x8(%rbp),%ecx
mov    -0x8(%rbp),%r8d
imul   -0x8(%rbp),%r8d
imul   -0x8(%rbp),%r8d
lea    0xe84(%rip),%rsi
call   1040 <fprintf@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    115d <main+0x2d>
mov    -0x10(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
lea    0xec5(%rip),%rdi
lea    0xeca(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,%rbx
mov    $0x1,%ebp
lea    0xeb8(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
mov    %ebp,%ecx
imul   %ebp,%ecx
mov    %ecx,%r8d
imul   %ebp,%r8d
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %ebp,%edx
call   1040 <fprintf@plt>
add    $0x1,%ebp
cmp    $0x64,%ebp
jne    1160 <main+0x30>
mov    %rbx,%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [12 x i8] c"primer1.txt\00"
@.str.1 = [2 x i8] c"w\00"
@.str.2 = [11 x i8] c"%4d%6d%8d\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 ([12 x i8], [12 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** %3
store i32 1, i32* %2
br label %5
5: ; preds = %20, %0
%6 = load i32, i32* %2
%7 = icmp slt i32 %6, 100
br i1 %7, label %8, label %23
8: ; preds = %5
%9 = load i32*, i32** %3
%10 = load i32, i32* %2
%11 = load i32, i32* %2
%12 = load i32, i32* %2
%13 = mul nsw i32 %11, %12
%14 = load i32, i32* %2
%15 = load i32, i32* %2
%16 = mul nsw i32 %14, %15
%17 = load i32, i32* %2
%18 = mul nsw i32 %16, %17
%19 = call i32 @fprintf(i32* %9, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i32 %10, i32 %13, i32 %18)
br label %20
20: ; preds = %8
%21 = load i32, i32* %2
%22 = add nsw i32 %21, 1
store i32 %22, i32* %2
br label %5
23: ; preds = %5
%24 = load i32*, i32** %3
%25 = call i32 @fclose(i32* %24)
%26 = load i32, i32* %1
ret i32 %26
}

LLVM IR (-O2):
@.str = [12 x i8] c"primer1.txt\00"
@.str.1 = [2 x i8] c"w\00"
@.str.2 = [11 x i8] c"%4d%6d%8d\0A\00"
define i32 @main() {
%1 = tail call i32* @fopen(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %2
2: ; preds = %0, %2
%3 = phi i32 [ 1, %0 ], [ %7, %2 ]
%4 = mul nuw nsw i32 %3, %3
%5 = mul nuw nsw i32 %4, %3
%6 = tail call i32 @fprintf(i32* %1, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i32 %3, i32 %4, i32 %5)
%7 = add nuw nsw i32 %3, 1
%8 = icmp eq i32 %7, 100
br i1 %8, label %9, label %2
9: ; preds = %2
%10 = tail call i32 @fclose(i32* %1)
ret i32 0
}