#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*/ fputs(char *, int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *, int, int);
void main() {
  int i = 0;
  char string1[10] = "";
  FILE *f = fopen("test_file1", "a+");
  for (i = 0; i < 256; i++) {
    printf("i in char = '%c' and %d in digit;\n", i, i);
    string1[0] = i;
    string1[1] = '\n';
    fputs(string1, f);
    string1[0] = string1[1] = 0;
  }
  fclose(f);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0xe(%rbp),%rdi
xor    %esi,%esi
mov    $0xa,%edx
call   1060 <memset@plt>
lea    0xe8a(%rip),%rdi
lea    0xe8e(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x18(%rbp)
movl   $0x0,-0x4(%rbp)
cmpl   $0x100,-0x4(%rbp)
jge    11d9 <main+0x89>
mov    -0x4(%rbp),%esi
mov    -0x4(%rbp),%edx
lea    0xe67(%rip),%rdi
call   1040 <printf@plt>
mov    -0x4(%rbp),%eax
mov    %al,-0xe(%rbp)
movb   $0xa,-0xd(%rbp)
lea    -0xe(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1050 <fputs@plt>
movb   $0x0,-0xd(%rbp)
movb   $0x0,-0xe(%rbp)
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    118d <main+0x3d>
mov    -0x18(%rbp),%rdi
call   1030 <fclose@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x18,%rsp
movq   $0x0,0x10(%rsp)
lea    0xea6(%rip),%rdi
lea    0xeaa(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,%rbx
xor    %ebp,%ebp
lea    0xe9c(%rip),%r14
lea    0xe(%rsp),%r15
nopw   0x0(%rax,%rax,1)
mov    %r14,%rdi
mov    %ebp,%esi
mov    %ebp,%edx
call   1040 <printf@plt>
mov    %bpl,0xe(%rsp)
movb   $0xa,0xf(%rsp)
mov    %r15,%rdi
mov    %rbx,%rsi
call   1050 <fputs@plt>
movw   $0x0,0xe(%rsp)
add    $0x1,%ebp
cmp    $0x100,%ebp
jne    1180 <main+0x40>
mov    %rbx,%rdi
add    $0x18,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <fclose@plt>

LLVM IR (-O0):
@.str = [11 x i8] c"test_file1\00"
@.str.1 = [3 x i8] c"a+\00"
@.str.2 = [35 x i8] c"i in char = '%c' and %d in digit;\0A\00"
define void @main() {
%1 = alloca i32
%2 = alloca [10 x i8]
%3 = alloca i32*
store i32 0, i32* %1
%4 = bitcast [10 x i8]* %2 to i8*
%5 = call i32* @fopen(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
store i32* %5, i32** %3
store i32 0, i32* %1
br label %6
6: ; preds = %22, %0
%7 = load i32, i32* %1
%8 = icmp slt i32 %7, 256
br i1 %8, label %9, label %25
9: ; preds = %6
%10 = load i32, i32* %1
%11 = load i32, i32* %1
%12 = call i32 @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.2, i64 0, i64 0), i32 %10, i32 %11)
%13 = load i32, i32* %1
%14 = trunc i32 %13 to i8
%15 = getelementptr inbounds [10 x i8], [10 x i8]* %2, i64 0, i64 0
store i8 %14, i8* %15
%16 = getelementptr inbounds [10 x i8], [10 x i8]* %2, i64 0, i64 1
store i8 10, i8* %16
%17 = getelementptr inbounds [10 x i8], [10 x i8]* %2, i64 0, i64 0
%18 = load i32*, i32** %3
%19 = call i32 @fputs(i8* %17, i32* %18)
%20 = getelementptr inbounds [10 x i8], [10 x i8]* %2, i64 0, i64 1
store i8 0, i8* %20
%21 = getelementptr inbounds [10 x i8], [10 x i8]* %2, i64 0, i64 0
store i8 0, i8* %21
br label %22
22: ; preds = %9
%23 = load i32, i32* %1
%24 = add nsw i32 %23, 1
store i32 %24, i32* %1
br label %6
25: ; preds = %6
%26 = load i32*, i32** %3
%27 = call i32 @fclose(i32* %26)
ret void
}

LLVM IR (-O2):
@.str = [11 x i8] c"test_file1\00"
@.str.1 = [3 x i8] c"a+\00"
@.str.2 = [35 x i8] c"i in char = '%c' and %d in digit;\0A\00"
define void @main() {
%1 = alloca [10 x i8]
%2 = getelementptr inbounds [10 x i8], [10 x i8]* %1, i64 0, i64 0
%3 = getelementptr inbounds [10 x i8], [10 x i8]* %1, i64 0, i64 2
%4 = bitcast i8* %3 to i64*
store i64 0, i64* %4
%5 = tail call i32* @fopen(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%6 = getelementptr inbounds [10 x i8], [10 x i8]* %1, i64 0, i64 1
br label %7
7: ; preds = %0, %7
%8 = phi i32 [ 0, %0 ], [ %12, %7 ]
%9 = tail call i32 @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.2, i64 0, i64 0), i32 %8, i32 %8)
%10 = trunc i32 %8 to i8
store i8 %10, i8* %2
store i8 10, i8* %6
%11 = call i32 @fputs(i8* %2, i32* %5)
store i8 0, i8* %6
store i8 0, i8* %2
%12 = add nuw nsw i32 %8, 1
%13 = icmp eq i32 %12, 256
br i1 %13, label %14, label %7
14: ; preds = %7
%15 = tail call i32 @fclose(i32* %5)
ret void
}