#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 */
char EOF;
int /*<<< orphan*/ assert(int);
char fgetc(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int fputc(char, int /*<<< orphan*/);
int /*<<< orphan*/ stdout;
int main() {
  FILE *file = fopen("/sandbox/input.txt", "r");
  assert(file != NULL);
  char c = fgetc(file);
  while (c != EOF) {
    int wrote = fputc(c, stdout);
    assert(wrote != EOF);
    c = fgetc(file);
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeaa(%rip),%rdi
lea    0xeb6(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
mov    -0x10(%rbp),%rdi
call   1030 <fgetc@plt>
mov    %al,-0x11(%rbp)
movsbl -0x11(%rbp),%eax
mov    0x2e59(%rip),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
je     11de <main+0x9e>
mov    -0x11(%rbp),%al
mov    0x2e34(%rip),%rcx
mov    (%rcx),%esi
movsbl %al,%edi
call   1040 <fputc@plt>
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%eax
mov    0x2e2d(%rip),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
mov    -0x10(%rbp),%rdi
call   1030 <fgetc@plt>
mov    %al,-0x11(%rbp)
jmp    1184 <main+0x44>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
lea    0xeb4(%rip),%rdi
lea    0xec0(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,%r14
xor    %edi,%edi
test   %rax,%rax
setne  %dil
call   1050 <assert@plt>
mov    %r14,%rdi
call   1030 <fgetc@plt>
mov    0x2e70(%rip),%rbx
cmp    (%rbx),%al
je     11b7 <main+0x77>
mov    0x2e55(%rip),%r15
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    (%r15),%esi
movsbl %al,%edi
call   1040 <fputc@plt>
movsbl (%rbx),%ecx
xor    %edi,%edi
cmp    %ecx,%eax
setne  %dil
call   1050 <assert@plt>
mov    %r14,%rdi
call   1030 <fgetc@plt>
cmp    (%rbx),%al
jne    1190 <main+0x50>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [19 x i8] c"/sandbox/input.txt\00"
@.str.1 = [2 x i8] c"r\00"
@EOF = global i8 0
@stdout = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca i32*
%3 = alloca i8
%4 = alloca i32
store i32 0, i32* %1
%5 = call i32* @fopen(i8* getelementptr inbounds ([19 x i8], [19 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
%6 = load i32*, i32** %2
%7 = icmp ne i32* %6, null
%8 = zext i1 %7 to i32
%9 = call i32 @assert(i32 %8)
%10 = load i32*, i32** %2
%11 = call signext i8 @fgetc(i32* %10)
store i8 %11, i8* %3
br label %12
12: ; preds = %18, %0
%13 = load i8, i8* %3
%14 = sext i8 %13 to i32
%15 = load i8, i8* @EOF
%16 = sext i8 %15 to i32
%17 = icmp ne i32 %14, %16
br i1 %17, label %18, label %30
18: ; preds = %12
%19 = load i8, i8* %3
%20 = load i32, i32* @stdout
%21 = call i32 @fputc(i8 signext %19, i32 %20)
store i32 %21, i32* %4
%22 = load i32, i32* %4
%23 = load i8, i8* @EOF
%24 = sext i8 %23 to i32
%25 = icmp ne i32 %22, %24
%26 = zext i1 %25 to i32
%27 = call i32 @assert(i32 %26)
%28 = load i32*, i32** %2
%29 = call signext i8 @fgetc(i32* %28)
store i8 %29, i8* %3
br label %12
30: ; preds = %12
%31 = load i32, i32* %1
ret i32 %31
}

LLVM IR (-O2):
@.str = [19 x i8] c"/sandbox/input.txt\00"
@.str.1 = [2 x i8] c"r\00"
@EOF = global i8 0
@stdout = global i32 0
define i32 @main() {
%1 = tail call i32* @fopen(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%2 = icmp ne i32* %1, null
%3 = zext i1 %2 to i32
%4 = tail call i32 @assert(i32 %3)
%5 = tail call signext i8 @fgetc(i32* %1)
%6 = load i8, i8* @EOF
%7 = icmp eq i8 %5, %6
br i1 %7, label %20, label %8
8: ; preds = %0, %8
%9 = phi i8 [ %17, %8 ], [ %5, %0 ]
%10 = load i32, i32* @stdout
%11 = tail call i32 @fputc(i8 signext %9, i32 %10)
%12 = load i8, i8* @EOF
%13 = sext i8 %12 to i32
%14 = icmp ne i32 %11, %13
%15 = zext i1 %14 to i32
%16 = tail call i32 @assert(i32 %15)
%17 = tail call signext i8 @fgetc(i32* %1)
%18 = load i8, i8* @EOF
%19 = icmp eq i8 %17, %18
br i1 %19, label %20, label %8
20: ; preds = %8, %0
ret i32 0
}