#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 EXIT_FAILURE;
int EXIT_SUCCESS;
int errno;
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int fgetc(int /*<<< orphan*/ *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int fputc(int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *open_file(char *, char *);
int /*<<< orphan*/ stderr;
char *strerror(int);
int main(int argc, char *argv[]) {
  FILE *fp_in;
  FILE *fp_out;
  int c;
  if (argc != 3) {
    fprintf(stderr, "Uso: %s <input_file> <output_file>\n", argv[0]);
    exit(EXIT_FAILURE);
  }
  fp_in = open_file(argv[1], "r");
  fp_out = open_file(argv[2], "w");
  while ((c = fgetc(fp_in)) != EOF) {
    if (fputc(c, fp_out) == EOF) {
      fprintf(stderr, "Err(%d) - %s: EOF\n", errno, strerror(errno));
      exit(EOF);
    }
  }
  fclose(fp_in);
  fclose(fp_out);
  return (EXIT_SUCCESS);
}


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)
je     11bc <main+0x4c>
mov    0x2e41(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe59(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    0x2e13(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe59(%rip),%rsi
call   1040 <open_file@plt>
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xe43(%rip),%rsi
call   1040 <open_file@plt>
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
call   1050 <fgetc@plt>
mov    %eax,-0x24(%rbp)
mov    0x2de9(%rip),%rcx
cmp    (%rcx),%eax
je     1272 <main+0x102>
mov    -0x24(%rbp),%edi
mov    -0x20(%rbp),%rsi
call   1060 <fputc@plt>
mov    0x2dce(%rip),%rcx
cmp    (%rcx),%eax
jne    126d <main+0xfd>
mov    0x2daf(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x2c(%rbp)
mov    0x2d9b(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x28(%rbp)
mov    0x2d8f(%rip),%rax
mov    (%rax),%edi
call   1090 <strerror@plt>
mov    -0x2c(%rbp),%edi
mov    -0x28(%rbp),%edx
mov    %rax,%rcx
lea    0xdd0(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    0x2d82(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>
jmp    11ec <main+0x7c>
mov    -0x18(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x20(%rbp),%rdi
call   1030 <fclose@plt>
mov    0x2d35(%rip),%rax
mov    (%rax),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
mov    %rsi,%rbx
cmp    $0x3,%edi
jne    1222 <main+0xb2>
mov    0x8(%rbx),%rdi
lea    0xe99(%rip),%rsi
call   1040 <open_file@plt>
mov    %rax,%r14
mov    0x10(%rbx),%rdi
lea    0xe88(%rip),%rsi
call   1040 <open_file@plt>
mov    %rax,%rbx
mov    0x2e3b(%rip),%rbp
nopl   (%rax)
mov    %r14,%rdi
call   1050 <fgetc@plt>
cmp    0x0(%rbp),%eax
je     1204 <main+0x94>
mov    %eax,%edi
mov    %rbx,%rsi
call   1060 <fputc@plt>
cmp    0x0(%rbp),%eax
jne    11b0 <main+0x40>
mov    0x2e05(%rip),%rax
mov    (%rax),%r14d
mov    0x2df3(%rip),%rax
mov    (%rax),%ebx
mov    %ebx,%edi
call   1090 <strerror@plt>
lea    0xe3b(%rip),%rsi
mov    %r14d,%edi
mov    %ebx,%edx
mov    %rax,%rcx
xor    %eax,%eax
call   1070 <fprintf@plt>
mov    0x0(%rbp),%edi
call   1080 <exit@plt>
mov    %r14,%rdi
call   1030 <fclose@plt>
mov    %rbx,%rdi
call   1030 <fclose@plt>
mov    0x2da5(%rip),%rax
mov    (%rax),%eax
pop    %rbx
pop    %r14
pop    %rbp
ret
mov    0x2daf(%rip),%rax
mov    (%rax),%edi
mov    (%rbx),%rdx
lea    0xdcb(%rip),%rsi
xor    %eax,%eax
call   1070 <fprintf@plt>
mov    0x2d85(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [36 x i8] c"Uso: %s <input_file> <output_file>\0A\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [2 x i8] c"w\00"
@EOF = global i32 0
@.str.3 = [19 x i8] c"Err(%d) - %s: EOF\0A\00"
@errno = global i32 0
@EXIT_SUCCESS = 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 i32, i32* %4
%10 = icmp ne i32 %9, 3
br i1 %10, label %11, label %19
11: ; preds = %2
%12 = load i32, i32* @stderr
%13 = load i8**, i8*** %5
%14 = getelementptr inbounds i8*, i8** %13, i64 0
%15 = load i8*, i8** %14
%16 = call i32 (i32, i8*, ...) @fprintf(i32 %12, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0), i8* %15)
%17 = load i32, i32* @EXIT_FAILURE
%18 = call i32 @exit(i32 %17)
unreachable
19: ; preds = %2
%20 = load i8**, i8*** %5
%21 = getelementptr inbounds i8*, i8** %20, i64 1
%22 = load i8*, i8** %21
%23 = call i32* @open_file(i8* %22, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %23, i32** %6
%24 = load i8**, i8*** %5
%25 = getelementptr inbounds i8*, i8** %24, i64 2
%26 = load i8*, i8** %25
%27 = call i32* @open_file(i8* %26, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i32* %27, i32** %7
br label %28
28: ; preds = %47, %19
%29 = load i32*, i32** %6
%30 = call i32 @fgetc(i32* %29)
store i32 %30, i32* %8
%31 = load i32, i32* @EOF
%32 = icmp ne i32 %30, %31
br i1 %32, label %33, label %48
33: ; preds = %28
%34 = load i32, i32* %8
%35 = load i32*, i32** %7
%36 = call i32 @fputc(i32 %34, i32* %35)
%37 = load i32, i32* @EOF
%38 = icmp eq i32 %36, %37
br i1 %38, label %39, label %47
39: ; preds = %33
%40 = load i32, i32* @stderr
%41 = load i32, i32* @errno
%42 = load i32, i32* @errno
%43 = call i8* @strerror(i32 %42)
%44 = call i32 (i32, i8*, ...) @fprintf(i32 %40, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0), i32 %41, i8* %43)
%45 = load i32, i32* @EOF
%46 = call i32 @exit(i32 %45)
unreachable
47: ; preds = %33
br label %28
48: ; preds = %28
%49 = load i32*, i32** %6
%50 = call i32 @fclose(i32* %49)
%51 = load i32*, i32** %7
%52 = call i32 @fclose(i32* %51)
%53 = load i32, i32* @EXIT_SUCCESS
ret i32 %53
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [36 x i8] c"Uso: %s <input_file> <output_file>\0A\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [2 x i8] c"w\00"
@EOF = global i32 0
@.str.3 = [19 x i8] c"Err(%d) - %s: EOF\0A\00"
@errno = global i32 0
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 3
br i1 %3, label %10, label %4
4: ; preds = %2
%5 = load i32, i32* @stderr
%6 = load i8*, i8** %1
%7 = tail call i32 (i32, i8*, ...) @fprintf(i32 %5, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0), i8* %6)
%8 = load i32, i32* @EXIT_FAILURE
%9 = tail call i32 @exit(i32 %8)
unreachable
10: ; preds = %2
%11 = getelementptr inbounds i8*, i8** %1, i64 1
%12 = load i8*, i8** %11
%13 = tail call i32* @open_file(i8* %12, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%14 = getelementptr inbounds i8*, i8** %1, i64 2
%15 = load i8*, i8** %14
%16 = tail call i32* @open_file(i8* %15, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %17
17: ; preds = %21, %10
%18 = tail call i32 @fgetc(i32* %13)
%19 = load i32, i32* @EOF
%20 = icmp eq i32 %18, %19
br i1 %20, label %32, label %21
21: ; preds = %17
%22 = tail call i32 @fputc(i32 %18, i32* %16)
%23 = load i32, i32* @EOF
%24 = icmp eq i32 %22, %23
br i1 %24, label %25, label %17
25: ; preds = %21
%26 = load i32, i32* @stderr
%27 = load i32, i32* @errno
%28 = tail call i8* @strerror(i32 %27)
%29 = tail call i32 (i32, i8*, ...) @fprintf(i32 %26, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0), i32 %27, i8* %28)
%30 = load i32, i32* @EOF
%31 = tail call i32 @exit(i32 %30)
unreachable
32: ; preds = %17
%33 = tail call i32 @fclose(i32* %13)
%34 = tail call i32 @fclose(i32* %16)
%35 = load i32, i32* @EXIT_SUCCESS
ret i32 %35
}