#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*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
char getc(int /*<<< orphan*/ *);
int /*<<< orphan*/ putc(char, int /*<<< orphan*/ *);
int main() {
  FILE *f1, *f2;
  f1 = fopen("4.in", "r");
  f2 = fopen("4.out", "a");
  char ch;
  while ((ch = getc(f1)) != EOF) {
    putc(ch, f2);
  }
  fclose(f1);
  fclose(f2);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeaa(%rip),%rdi
lea    0xea8(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,-0x10(%rbp)
lea    0xe9a(%rip),%rdi
lea    0xe99(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
call   1060 <getc@plt>
mov    %al,-0x19(%rbp)
movsbl %al,%eax
mov    0x2e55(%rip),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
je     11b2 <main+0x72>
mov    -0x19(%rbp),%al
mov    -0x18(%rbp),%rsi
movsbl %al,%edi
call   1040 <putc@plt>
jmp    117d <main+0x3d>
mov    -0x10(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x18(%rbp),%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
lea    0xeb4(%rip),%rdi
lea    0xeb2(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,%r14
lea    0xea5(%rip),%rdi
lea    0xea4(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,%rbx
mov    %r14,%rdi
call   1060 <getc@plt>
mov    0x2e68(%rip),%r15
cmp    (%r15),%al
je     11a8 <main+0x68>
cs nopw 0x0(%rax,%rax,1)
nop
movsbl %al,%edi
mov    %rbx,%rsi
call   1040 <putc@plt>
mov    %r14,%rdi
call   1060 <getc@plt>
cmp    (%r15),%al
jne    1190 <main+0x50>
mov    %r14,%rdi
call   1030 <fclose@plt>
mov    %rbx,%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [5 x i8] c"4.in\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [6 x i8] c"4.out\00"
@.str.3 = [2 x i8] c"a\00"
@EOF = global i8 0
define i32 @main() {
%1 = alloca i32
%2 = alloca i32*
%3 = alloca i32*
%4 = alloca i8
store i32 0, i32* %1
%5 = call i32* @fopen(i8* getelementptr inbounds ([5 x i8], [5 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 = call i32* @fopen(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
store i32* %6, i32** %3
br label %7
7: ; preds = %14, %0
%8 = load i32*, i32** %2
%9 = call signext i8 @getc(i32* %8)
store i8 %9, i8* %4
%10 = sext i8 %9 to i32
%11 = load i8, i8* @EOF
%12 = sext i8 %11 to i32
%13 = icmp ne i32 %10, %12
br i1 %13, label %14, label %18
14: ; preds = %7
%15 = load i8, i8* %4
%16 = load i32*, i32** %3
%17 = call i32 @putc(i8 signext %15, i32* %16)
br label %7
18: ; preds = %7
%19 = load i32*, i32** %2
%20 = call i32 @fclose(i32* %19)
%21 = load i32*, i32** %3
%22 = call i32 @fclose(i32* %21)
ret i32 0
}

LLVM IR (-O2):
@.str = [5 x i8] c"4.in\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [6 x i8] c"4.out\00"
@.str.3 = [2 x i8] c"a\00"
@EOF = global i8 0
define i32 @main() {
%1 = tail call i32* @fopen(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%2 = tail call i32* @fopen(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%3 = tail call signext i8 @getc(i32* %1)
%4 = load i8, i8* @EOF
%5 = icmp eq i8 %3, %4
br i1 %5, label %12, label %6
6: ; preds = %0, %6
%7 = phi i8 [ %9, %6 ], [ %3, %0 ]
%8 = tail call i32 @putc(i8 signext %7, i32* %2)
%9 = tail call signext i8 @getc(i32* %1)
%10 = load i8, i8* @EOF
%11 = icmp eq i8 %9, %10
br i1 %11, label %12, label %6
12: ; preds = %6, %0
%13 = tail call i32 @fclose(i32* %1)
%14 = tail call i32 @fclose(i32* %2)
ret i32 0
}