#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*/ fcloseall();
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, int, int, int);
int main() {
  FILE *f2;
  int i, j;
  f2 = fopen("dest.txt", "w");
  for (i = 1; i <= 10; i++) {
    for (j = 1; j <= 10; j++) {
      fprintf(f2, "%i %i %i\n", i, j, i * j);
    }
  }
  fcloseall();
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeba(%rip),%rdi
lea    0xebc(%rip),%rsi
call   1040 <fopen@plt>
mov    %rax,-0x10(%rbp)
movl   $0x1,-0x14(%rbp)
cmpl   $0xa,-0x14(%rbp)
jg     11b8 <main+0x88>
movl   $0x1,-0x18(%rbp)
cmpl   $0xa,-0x18(%rbp)
jg     11a5 <main+0x75>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%edx
mov    -0x18(%rbp),%ecx
mov    -0x14(%rbp),%r8d
imul   -0x18(%rbp),%r8d
lea    0xe79(%rip),%rsi
call   1030 <fprintf@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    116e <main+0x3e>
jmp    11aa <main+0x7a>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    115d <main+0x2d>
mov    $0x0,%al
call   1050 <fcloseall@plt>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
lea    0xebb(%rip),%rdi
lea    0xebd(%rip),%rsi
call   1040 <fopen@plt>
mov    %rax,%r15
mov    $0x1,%r14d
movl   $0x8,0x8(%rsp)
movl   $0x4,0x14(%rsp)
movl   $0x2,0x10(%rsp)
movl   $0xa,0x18(%rsp)
movl   $0x9,0xc(%rsp)
mov    $0x7,%ebp
movl   $0x6,0x4(%rsp)
mov    $0x5,%r12d
mov    $0x3,%r13d
nopl   0x0(%rax,%rax,1)
mov    %ebp,0x24(%rsp)
mov    %r15,%rdi
lea    0xe5d(%rip),%rbx
mov    %rbx,%rsi
mov    %r14d,%edx
mov    $0x1,%ecx
mov    %r14d,%r8d
call   1030 <fprintf@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
mov    %r14d,%edx
mov    $0x2,%ecx
mov    0x10(%rsp),%r8d
call   1030 <fprintf@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
mov    %r14d,%edx
mov    $0x3,%ecx
mov    %r13d,0x20(%rsp)
mov    %r13d,%r8d
call   1030 <fprintf@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
mov    %r14d,%edx
mov    $0x4,%ecx
mov    0x14(%rsp),%r8d
call   1030 <fprintf@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
mov    %r14d,%edx
mov    $0x5,%ecx
mov    %r12d,0x1c(%rsp)
mov    %r12d,%r8d
call   1030 <fprintf@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
mov    %r14d,%edx
mov    $0x6,%ecx
mov    0x4(%rsp),%r12d
mov    %r12d,%r8d
call   1030 <fprintf@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
mov    %r14d,%edx
mov    $0x7,%ecx
mov    %ebp,%r8d
call   1030 <fprintf@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
mov    %rbx,%rbp
mov    %r14d,%edx
mov    $0x8,%ecx
mov    0x8(%rsp),%ebx
mov    %ebx,%r8d
call   1030 <fprintf@plt>
mov    %r15,%rdi
mov    %rbp,%rsi
mov    %r14d,%edx
mov    $0x9,%ecx
mov    0xc(%rsp),%r13d
mov    %r13d,%r8d
call   1030 <fprintf@plt>
mov    %r15,%rdi
mov    %rbp,%rsi
mov    %r14d,%edx
mov    $0xa,%ecx
mov    0x18(%rsp),%ebp
mov    %ebp,%r8d
call   1030 <fprintf@plt>
add    $0x1,%r14d
add    $0x8,%ebx
addl   $0x4,0x14(%rsp)
addl   $0x2,0x10(%rsp)
add    $0xa,%ebp
mov    %ebp,0x18(%rsp)
mov    0x24(%rsp),%ebp
add    $0x9,%r13d
mov    %r13d,0xc(%rsp)
add    $0x7,%ebp
add    $0x6,%r12d
mov    %r12d,0x4(%rsp)
mov    0x1c(%rsp),%r12d
add    $0x5,%r12d
mov    0x20(%rsp),%r13d
add    $0x3,%r13d
mov    %ebx,0x8(%rsp)
cmp    $0x58,%ebx
jne    11a0 <main+0x70>
xor    %eax,%eax
call   1050 <fcloseall@plt>
xor    %eax,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [9 x i8] c"dest.txt\00"
@.str.1 = [2 x i8] c"w\00"
@.str.2 = [10 x i8] c"%i %i %i\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32*
%3 = alloca i32
%4 = alloca i32
store i32 0, i32* %1
%5 = call i32* @fopen(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %5, i32** %2
store i32 1, i32* %3
br label %6
6: ; preds = %25, %0
%7 = load i32, i32* %3
%8 = icmp sle i32 %7, 10
br i1 %8, label %9, label %28
9: ; preds = %6
store i32 1, i32* %4
br label %10
10: ; preds = %21, %9
%11 = load i32, i32* %4
%12 = icmp sle i32 %11, 10
br i1 %12, label %13, label %24
13: ; preds = %10
%14 = load i32*, i32** %2
%15 = load i32, i32* %3
%16 = load i32, i32* %4
%17 = load i32, i32* %3
%18 = load i32, i32* %4
%19 = mul nsw i32 %17, %18
%20 = call i32 @fprintf(i32* %14, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i32 %15, i32 %16, i32 %19)
br label %21
21: ; preds = %13
%22 = load i32, i32* %4
%23 = add nsw i32 %22, 1
store i32 %23, i32* %4
br label %10
24: ; preds = %10
br label %25
25: ; preds = %24
%26 = load i32, i32* %3
%27 = add nsw i32 %26, 1
store i32 %27, i32* %3
br label %6
28: ; preds = %6
%29 = call i32 (...) @fcloseall()
%30 = load i32, i32* %1
ret i32 %30
}

LLVM IR (-O2):
@.str = [9 x i8] c"dest.txt\00"
@.str.1 = [2 x i8] c"w\00"
@.str.2 = [10 x i8] c"%i %i %i\0A\00"
define i32 @main() {
%1 = tail call i32* @fopen(i8* getelementptr inbounds ([9 x i8], [9 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 ], [ %23, %2 ]
%4 = tail call i32 @fprintf(i32* %1, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i32 %3, i32 1, i32 %3)
%5 = shl nuw nsw i32 %3, 1
%6 = tail call i32 @fprintf(i32* %1, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i32 %3, i32 2, i32 %5)
%7 = mul nuw nsw i32 %3, 3
%8 = tail call i32 @fprintf(i32* %1, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i32 %3, i32 3, i32 %7)
%9 = shl nuw nsw i32 %3, 2
%10 = tail call i32 @fprintf(i32* %1, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i32 %3, i32 4, i32 %9)
%11 = mul nuw nsw i32 %3, 5
%12 = tail call i32 @fprintf(i32* %1, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i32 %3, i32 5, i32 %11)
%13 = mul nuw nsw i32 %3, 6
%14 = tail call i32 @fprintf(i32* %1, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i32 %3, i32 6, i32 %13)
%15 = mul nuw nsw i32 %3, 7
%16 = tail call i32 @fprintf(i32* %1, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i32 %3, i32 7, i32 %15)
%17 = shl nuw nsw i32 %3, 3
%18 = tail call i32 @fprintf(i32* %1, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i32 %3, i32 8, i32 %17)
%19 = mul nuw nsw i32 %3, 9
%20 = tail call i32 @fprintf(i32* %1, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i32 %3, i32 9, i32 %19)
%21 = mul nuw nsw i32 %3, 10
%22 = tail call i32 @fprintf(i32* %1, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i32 %3, i32 10, i32 %21)
%23 = add nuw nsw i32 %3, 1
%24 = icmp eq i32 %23, 11
br i1 %24, label %25, label %2
25: ; preds = %2
%26 = tail call i32 (...) @fcloseall()
ret i32 0
}