#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*/ fputc(int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *stdout;
int main() {
  FILE *fp;
  int ch;
  fp = fopen("file.txt", "w+");
  for (ch = 33; ch <= 100; ch++)
    fputc(ch, fp);
  fclose(fp);
  for (ch = 33; ch <= 100; ch++)
    fputc(ch, stdout);
  return (0);
}


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   1050 <fopen@plt>
mov    %rax,-0x10(%rbp)
movl   $0x21,-0x14(%rbp)
cmpl   $0x64,-0x14(%rbp)
jg     1181 <main+0x51>
mov    -0x14(%rbp),%edi
mov    -0x10(%rbp),%rsi
call   1040 <fputc@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    115d <main+0x2d>
mov    -0x10(%rbp),%rdi
call   1030 <fclose@plt>
movl   $0x21,-0x14(%rbp)
cmpl   $0x64,-0x14(%rbp)
jg     11bb <main+0x8b>
mov    -0x14(%rbp),%edi
mov    0x2e3b(%rip),%rax
mov    (%rax),%rsi
call   1040 <fputc@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1191 <main+0x61>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
lea    0xec6(%rip),%rdi
lea    0xec8(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,%rbx
mov    $0x21,%ebp
xchg   %ax,%ax
mov    %ebp,%edi
mov    %rbx,%rsi
call   1040 <fputc@plt>
add    $0x1,%ebp
cmp    $0x65,%ebp
jne    1150 <main+0x20>
mov    %rbx,%rdi
call   1030 <fclose@plt>
mov    $0x21,%ebx
mov    0x2e6a(%rip),%rbp
cs nopw 0x0(%rax,%rax,1)
mov    0x0(%rbp),%rsi
mov    %ebx,%edi
call   1040 <fputc@plt>
add    $0x1,%ebx
cmp    $0x65,%ebx
jne    1180 <main+0x50>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [9 x i8] c"file.txt\00"
@.str.1 = [3 x i8] c"w+\00"
@stdout = global i32* null
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 ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
br label %2
2: ; preds = %0, %2
%3 = phi i32 [ 33, %0 ], [ %5, %2 ]
%4 = tail call i32 @fputc(i32 %3, i32* %1)
%5 = add nuw nsw i32 %3, 1
%6 = icmp eq i32 %5, 101
br i1 %6, label %7, label %2
7: ; preds = %2
%8 = tail call i32 @fclose(i32* %1)
br label %9
9: ; preds = %7, %9
%10 = phi i32 [ 33, %7 ], [ %13, %9 ]
%11 = load i32*, i32** @stdout
%12 = tail call i32 @fputc(i32 %10, i32* %11)
%13 = add nuw nsw i32 %10, 1
%14 = icmp eq i32 %13, 101
br i1 %14, label %15, label %9
15: ; preds = %9
ret i32 0
}