#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 *);
char 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) {
    assert(fputc(c, stdout) != 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     11db <main+0x9b>
mov    -0x11(%rbp),%al
mov    0x2e34(%rip),%rcx
mov    (%rcx),%esi
movsbl %al,%edi
call   1040 <fputc@plt>
movsbl %al,%eax
mov    0x2e30(%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     11b4 <main+0x74>
mov    0x2e55(%rip),%r15
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    (%r15),%esi
movsbl %al,%edi
call   1040 <fputc@plt>
xor    %edi,%edi
cmp    (%rbx),%al
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
store i32 0, i32* %1
%4 = 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* %4, i32** %2
%5 = load i32*, i32** %2
%6 = icmp ne i32* %5, null
%7 = zext i1 %6 to i32
%8 = call i32 @assert(i32 %7)
%9 = load i32*, i32** %2
%10 = call signext i8 @fgetc(i32* %9)
store i8 %10, i8* %3
br label %11
11: ; preds = %17, %0
%12 = load i8, i8* %3
%13 = sext i8 %12 to i32
%14 = load i8, i8* @EOF
%15 = sext i8 %14 to i32
%16 = icmp ne i32 %13, %15
br i1 %16, label %17, label %29
17: ; preds = %11
%18 = load i8, i8* %3
%19 = load i32, i32* @stdout
%20 = call signext i8 @fputc(i8 signext %18, i32 %19)
%21 = sext i8 %20 to i32
%22 = load i8, i8* @EOF
%23 = sext i8 %22 to i32
%24 = icmp ne i32 %21, %23
%25 = zext i1 %24 to i32
%26 = call i32 @assert(i32 %25)
%27 = load i32*, i32** %2
%28 = call signext i8 @fgetc(i32* %27)
store i8 %28, i8* %3
br label %11
29: ; preds = %11
%30 = load i32, i32* %1
ret i32 %30
}

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 %19, label %8
8: ; preds = %0, %8
%9 = phi i8 [ %16, %8 ], [ %5, %0 ]
%10 = load i32, i32* @stdout
%11 = tail call signext i8 @fputc(i8 signext %9, i32 %10)
%12 = load i8, i8* @EOF
%13 = icmp ne i8 %11, %12
%14 = zext i1 %13 to i32
%15 = tail call i32 @assert(i32 %14)
%16 = tail call signext i8 @fgetc(i32* %1)
%17 = load i8, i8* @EOF
%18 = icmp eq i8 %16, %17
br i1 %18, label %19, label %8
19: ; preds = %8, %0
ret i32 0
}