#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 EOF;
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int getc(int /*<<< orphan*/ *);
int /*<<< orphan*/ putc(int, int /*<<< orphan*/ *);
int main(int argc, char *argv[]) {
  FILE *f1, *f2;
  int c;
  f1 = fopen(argv[1], "r");
  f2 = fopen(argv[2], "w");
  while ((c = getc(f1)) != EOF) {
    putc(c, f2);
  }
  fclose(f2);
  fclose(f1);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe9b(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xe85(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
call   1060 <getc@plt>
mov    %eax,-0x24(%rbp)
mov    0x2e4f(%rip),%rcx
cmp    (%rcx),%eax
je     11b2 <main+0x72>
mov    -0x24(%rbp),%edi
mov    -0x20(%rbp),%rsi
call   1040 <putc@plt>
jmp    1186 <main+0x46>
mov    -0x20(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x18(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%rbx
mov    0x8(%rsi),%rdi
lea    0xead(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,%r14
mov    0x10(%rbx),%rdi
lea    0xe9c(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,%rbx
mov    %r14,%rdi
call   1060 <getc@plt>
mov    0x2e6b(%rip),%r15
cmp    (%r15),%eax
je     11a7 <main+0x67>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %eax,%edi
mov    %rbx,%rsi
call   1040 <putc@plt>
mov    %r14,%rdi
call   1060 <getc@plt>
cmp    (%r15),%eax
jne    1190 <main+0x50>
mov    %rbx,%rdi
call   1030 <fclose@plt>
mov    %r14,%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
@.str.1 = [2 x i8] c"w\00"
@EOF = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
%7 = alloca i32*
%8 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = load i8**, i8*** %5
%10 = getelementptr inbounds i8*, i8** %9, i64 1
%11 = load i8*, i8** %10
%12 = call i32* @fopen(i8* %11, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %12, i32** %6
%13 = load i8**, i8*** %5
%14 = getelementptr inbounds i8*, i8** %13, i64 2
%15 = load i8*, i8** %14
%16 = call i32* @fopen(i8* %15, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %16, i32** %7
br label %17
17: ; preds = %22, %2
%18 = load i32*, i32** %6
%19 = call i32 @getc(i32* %18)
store i32 %19, i32* %8
%20 = load i32, i32* @EOF
%21 = icmp ne i32 %19, %20
br i1 %21, label %22, label %26
22: ; preds = %17
%23 = load i32, i32* %8
%24 = load i32*, i32** %7
%25 = call i32 @putc(i32 %23, i32* %24)
br label %17
26: ; preds = %17
%27 = load i32*, i32** %7
%28 = call i32 @fclose(i32* %27)
%29 = load i32*, i32** %6
%30 = call i32 @fclose(i32* %29)
%31 = load i32, i32* %3
ret i32 %31
}

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