#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() {
  for (int i = 0; i < 2; i++) {
    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)
movl   $0x0,-0x8(%rbp)
cmpl   $0x2,-0x8(%rbp)
jge    11ff <main+0xbf>
lea    0xe99(%rip),%rdi
lea    0xea5(%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    0x2e48(%rip),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
je     11ec <main+0xac>
mov    -0x11(%rbp),%al
mov    0x2e23(%rip),%rcx
mov    (%rcx),%esi
movsbl %al,%edi
call   1040 <fputc@plt>
movsbl %al,%eax
mov    0x2e1f(%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    1195 <main+0x55>
jmp    11f1 <main+0xb1>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1156 <main+0x16>
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>
lea    0xe45(%rip),%rdi
lea    0xe51(%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>
cmp    (%rbx),%al
je     1214 <main+0xd4>
mov    0x2ded(%rip),%r15
nopl   0x0(%rax,%rax,1)
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    11f0 <main+0xb0>
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 i32*
%4 = alloca i8
store i32 0, i32* %1
store i32 0, i32* %2
br label %5
5: ; preds = %35, %0
%6 = load i32, i32* %2
%7 = icmp slt i32 %6, 2
br i1 %7, label %8, label %38
8: ; preds = %5
%9 = 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* %9, i32** %3
%10 = load i32*, i32** %3
%11 = icmp ne i32* %10, null
%12 = zext i1 %11 to i32
%13 = call i32 @assert(i32 %12)
%14 = load i32*, i32** %3
%15 = call signext i8 @fgetc(i32* %14)
store i8 %15, i8* %4
br label %16
16: ; preds = %22, %8
%17 = load i8, i8* %4
%18 = sext i8 %17 to i32
%19 = load i8, i8* @EOF
%20 = sext i8 %19 to i32
%21 = icmp ne i32 %18, %20
br i1 %21, label %22, label %34
22: ; preds = %16
%23 = load i8, i8* %4
%24 = load i32, i32* @stdout
%25 = call signext i8 @fputc(i8 signext %23, i32 %24)
%26 = sext i8 %25 to i32
%27 = load i8, i8* @EOF
%28 = sext i8 %27 to i32
%29 = icmp ne i32 %26, %28
%30 = zext i1 %29 to i32
%31 = call i32 @assert(i32 %30)
%32 = load i32*, i32** %3
%33 = call signext i8 @fgetc(i32* %32)
store i8 %33, i8* %4
br label %16
34: ; preds = %16
br label %35
35: ; preds = %34
%36 = load i32, i32* %2
%37 = add nsw i32 %36, 1
store i32 %37, i32* %2
br label %5
38: ; preds = %5
%39 = load i32, i32* %1
ret i32 %39
}

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
%20 = 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))
%21 = icmp ne i32* %20, null
%22 = zext i1 %21 to i32
%23 = tail call i32 @assert(i32 %22)
%24 = tail call signext i8 @fgetc(i32* %20)
%25 = load i8, i8* @EOF
%26 = icmp eq i8 %24, %25
br i1 %26, label %38, label %27
27: ; preds = %19, %27
%28 = phi i8 [ %35, %27 ], [ %24, %19 ]
%29 = load i32, i32* @stdout
%30 = tail call signext i8 @fputc(i8 signext %28, i32 %29)
%31 = load i8, i8* @EOF
%32 = icmp ne i8 %30, %31
%33 = zext i1 %32 to i32
%34 = tail call i32 @assert(i32 %33)
%35 = tail call signext i8 @fgetc(i32* %20)
%36 = load i8, i8* @EOF
%37 = icmp eq i8 %35, %36
br i1 %37, label %38, label %27
38: ; preds = %27, %19
ret i32 0
}