#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*/ printf(char *);
int /*<<< orphan*/ putc(int, int /*<<< orphan*/ *);
int main(int argc, char *argv[]) {
  FILE *in, *out;
  int c;
  if (argc >= 3) {
    in = fopen(argv[1], "r");
    out = fopen(argv[2], "w");
    if ((in != NULL) && (out != NULL)) {
      while ((c = getc(in)) != EOF) {
        putc(c, out);
      }
    } else {
      printf("Erro ao abrir arquivo\n");
    }
    fclose(in);
    fclose(out);
  } else {
    printf("Utilizacao copy <origem> <destino>\n");
  }
  return 0;
}


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)
cmpl   $0x3,-0x8(%rbp)
jl     120f <main+0xbf>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe81(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xe6b(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     11ec <main+0x9c>
cmpq   $0x0,-0x20(%rbp)
je     11ec <main+0x9c>
jmp    11bb <main+0x6b>
mov    -0x18(%rbp),%rdi
call   1070 <getc@plt>
mov    %eax,-0x24(%rbp)
mov    0x2e1a(%rip),%rcx
cmp    (%rcx),%eax
je     11e7 <main+0x97>
mov    -0x24(%rbp),%edi
mov    -0x20(%rbp),%rsi
call   1050 <putc@plt>
jmp    11bb <main+0x6b>
jmp    11f8 <main+0xa8>
lea    0xe11(%rip),%rdi
call   1040 <printf@plt>
mov    -0x18(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x20(%rbp),%rdi
call   1030 <fclose@plt>
jmp    121b <main+0xcb>
lea    0xe05(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
cmp    $0x3,%edi
jl     11c9 <main+0x79>
mov    %rsi,%r14
mov    0x8(%rsi),%rdi
lea    0xe98(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,%rbx
mov    0x10(%r14),%rdi
lea    0xe87(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,%r14
test   %rbx,%rbx
je     11d7 <main+0x87>
test   %r14,%r14
je     11d7 <main+0x87>
mov    %rbx,%rdi
call   1070 <getc@plt>
mov    0x2e4c(%rip),%r15
cmp    (%r15),%eax
je     11e3 <main+0x93>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %eax,%edi
mov    %r14,%rsi
call   1050 <putc@plt>
mov    %rbx,%rdi
call   1070 <getc@plt>
cmp    (%r15),%eax
jne    11b0 <main+0x60>
jmp    11e3 <main+0x93>
lea    0xe34(%rip),%rdi
call   1030 <puts@plt>
jmp    11f3 <main+0xa3>
lea    0xe49(%rip),%rdi
call   1030 <puts@plt>
mov    %rbx,%rdi
call   1040 <fclose@plt>
mov    %r14,%rdi
call   1040 <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
@.str.2 = [23 x i8] c"Erro ao abrir arquivo\0A\00"
@.str.3 = [36 x i8] c"Utilizacao copy <origem> <destino>\0A\00"
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 i32, i32* %4
%10 = icmp sge i32 %9, 3
br i1 %10, label %11, label %43
11: ; preds = %2
%12 = load i8**, i8*** %5
%13 = getelementptr inbounds i8*, i8** %12, i64 1
%14 = load i8*, i8** %13
%15 = call i32* @fopen(i8* %14, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %15, i32** %6
%16 = load i8**, i8*** %5
%17 = getelementptr inbounds i8*, i8** %16, i64 2
%18 = load i8*, i8** %17
%19 = call i32* @fopen(i8* %18, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %19, i32** %7
%20 = load i32*, i32** %6
%21 = icmp ne i32* %20, null
br i1 %21, label %22, label %36
22: ; preds = %11
%23 = load i32*, i32** %7
%24 = icmp ne i32* %23, null
br i1 %24, label %25, label %36
25: ; preds = %22
br label %26
26: ; preds = %31, %25
%27 = load i32*, i32** %6
%28 = call i32 @getc(i32* %27)
store i32 %28, i32* %8
%29 = load i32, i32* @EOF
%30 = icmp ne i32 %28, %29
br i1 %30, label %31, label %35
31: ; preds = %26
%32 = load i32, i32* %8
%33 = load i32*, i32** %7
%34 = call i32 @putc(i32 %32, i32* %33)
br label %26
35: ; preds = %26
br label %38
36: ; preds = %22, %11
%37 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0))
br label %38
38: ; preds = %36, %35
%39 = load i32*, i32** %6
%40 = call i32 @fclose(i32* %39)
%41 = load i32*, i32** %7
%42 = call i32 @fclose(i32* %41)
br label %45
43: ; preds = %2
%44 = call i32 @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.3, i64 0, i64 0))
br label %45
45: ; preds = %43, %38
ret i32 0
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
@.str.1 = [2 x i8] c"w\00"
@EOF = global i32 0
@str = [35 x i8] c"Utilizacao copy <origem> <destino>\00"
@str.4 = [22 x i8] c"Erro ao abrir arquivo\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp sgt i32 %0, 2
br i1 %3, label %4, label %29
4: ; preds = %2
%5 = getelementptr inbounds i8*, i8** %1, i64 1
%6 = load i8*, i8** %5
%7 = tail call i32* @fopen(i8* %6, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%8 = getelementptr inbounds i8*, i8** %1, i64 2
%9 = load i8*, i8** %8
%10 = tail call i32* @fopen(i8* %9, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%11 = icmp ne i32* %7, null
%12 = icmp ne i32* %10, null
%13 = and i1 %11, %12
br i1 %13, label %14, label %24
14: ; preds = %4
%15 = tail call i32 @getc(i32* %7)
%16 = load i32, i32* @EOF
%17 = icmp eq i32 %15, %16
br i1 %17, label %26, label %18
18: ; preds = %14, %18
%19 = phi i32 [ %21, %18 ], [ %15, %14 ]
%20 = tail call i32 @putc(i32 %19, i32* %10)
%21 = tail call i32 @getc(i32* %7)
%22 = load i32, i32* @EOF
%23 = icmp eq i32 %21, %22
br i1 %23, label %26, label %18
24: ; preds = %4
%25 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str.4, i64 0, i64 0))
br label %26
26: ; preds = %18, %14, %24
%27 = tail call i32 @fclose(i32* %7)
%28 = tail call i32 @fclose(i32* %10)
br label %31
29: ; preds = %2
%30 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @str, i64 0, i64 0))
br label %31
31: ; preds = %29, %26
ret i32 0
}