#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*/ EXIT_FAILURE;
int EXIT_SUCCESS;
int errno;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ feof(int /*<<< orphan*/ *);
scalar_t__ ferror(int /*<<< orphan*/ *);
int fgetc(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ fputc(int, int /*<<< orphan*/);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdout;
char *strerror(int);
int main(int argc, char *argv[]) {
  FILE *fp_in;
  int c;
  if (argc != 2) {
    fprintf(stderr, "Uso: %s <input_file>\n", argv[0]);
    exit(EXIT_FAILURE);
  }
  if ((fp_in = fopen(argv[1], "r")) == NULL) {
    fprintf(stderr, "Err(%d) %s: %s\n", errno, strerror(errno), argv[1]);
    exit(EXIT_FAILURE);
  }
  while (!feof(fp_in)) {
    if ((c = fgetc(fp_in)) != EOF)
      fputc(c, stdout);
  }
  if (ferror(fp_in)) {
    fprintf(stderr, "Err(%d) %s: stream error\n", errno, strerror(errno));
    exit(EXIT_FAILURE);
  }
  fclose(fp_in);
  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   $0x2,-0x8(%rbp)
je     11dc <main+0x4c>
mov    0x2e21(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe39(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    0x2df3(%rip),%rax
mov    (%rax),%edi
call   10a0 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe2b(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
jne    1251 <main+0xc1>
mov    0x2dd3(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x24(%rbp)
mov    0x2dbf(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x20(%rbp)
mov    0x2db3(%rip),%rax
mov    (%rax),%edi
call   10b0 <strerror@plt>
mov    -0x24(%rbp),%edi
mov    -0x20(%rbp),%edx
mov    %rax,%rcx
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%r8
lea    0xddc(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    0x2d7e(%rip),%rax
mov    (%rax),%edi
call   10a0 <exit@plt>
jmp    1256 <main+0xc6>
mov    -0x18(%rbp),%rdi
call   1080 <feof@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    1274 <main+0xe4>
jmp    12a5 <main+0x115>
mov    -0x18(%rbp),%rdi
call   1050 <fgetc@plt>
mov    %eax,-0x1c(%rbp)
mov    0x2d61(%rip),%rcx
cmp    (%rcx),%eax
je     12a0 <main+0x110>
mov    -0x1c(%rbp),%edi
mov    0x2d27(%rip),%rax
mov    (%rax),%esi
call   1060 <fputc@plt>
jmp    1256 <main+0xc6>
mov    -0x18(%rbp),%rdi
call   1030 <ferror@plt>
cmp    $0x0,%rax
je     1303 <main+0x173>
mov    0x2d19(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x2c(%rbp)
mov    0x2d05(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x28(%rbp)
mov    0x2cf9(%rip),%rax
mov    (%rax),%edi
call   10b0 <strerror@plt>
mov    -0x2c(%rbp),%edi
mov    -0x28(%rbp),%edx
mov    %rax,%rcx
lea    0xd3a(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    0x2ccc(%rip),%rax
mov    (%rax),%edi
call   10a0 <exit@plt>
mov    -0x18(%rbp),%rdi
call   1040 <fclose@plt>
mov    0x2ca5(%rip),%rax
mov    (%rax),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
mov    %rsi,%r14
cmp    $0x2,%edi
jne    1225 <main+0x95>
mov    0x8(%r14),%rdi
lea    0xe6b(%rip),%rsi
call   1090 <fopen@plt>
test   %rax,%rax
je     1241 <main+0xb1>
mov    %rax,%rbx
mov    %rax,%rdi
call   1080 <feof@plt>
test   %eax,%eax
je     11ef <main+0x5f>
mov    %rbx,%rdi
call   1030 <ferror@plt>
test   %rax,%rax
jne    1275 <main+0xe5>
mov    %rbx,%rdi
call   1040 <fclose@plt>
mov    0x2dd0(%rip),%rax
mov    (%rax),%eax
pop    %rbx
pop    %r14
pop    %rbp
ret
mov    0x2df2(%rip),%rbp
mov    0x2dc3(%rip),%r14
jmp    120c <main+0x7c>
nop
mov    %rbx,%rdi
call   1080 <feof@plt>
test   %eax,%eax
jne    11c8 <main+0x38>
mov    %rbx,%rdi
call   1050 <fgetc@plt>
cmp    0x0(%rbp),%eax
je     1200 <main+0x70>
mov    (%r14),%esi
mov    %eax,%edi
call   1060 <fputc@plt>
jmp    1200 <main+0x70>
mov    0x2dac(%rip),%rax
mov    (%rax),%edi
mov    (%r14),%rdx
lea    0xdc8(%rip),%rsi
xor    %eax,%eax
call   1070 <fprintf@plt>
jmp    12a3 <main+0x113>
mov    0x2d90(%rip),%rax
mov    (%rax),%ebx
mov    0x2d7f(%rip),%rax
mov    (%rax),%ebp
mov    %ebp,%edi
call   10b0 <strerror@plt>
mov    0x8(%r14),%r8
lea    0xdb3(%rip),%rsi
mov    %ebx,%edi
mov    %ebp,%edx
mov    %rax,%rcx
xor    %eax,%eax
call   1070 <fprintf@plt>
jmp    12a3 <main+0x113>
mov    0x2d5c(%rip),%rax
mov    (%rax),%ebx
mov    0x2d4b(%rip),%rax
mov    (%rax),%ebp
mov    %ebp,%edi
call   10b0 <strerror@plt>
lea    0xd93(%rip),%rsi
mov    %ebx,%edi
mov    %ebp,%edx
mov    %rax,%rcx
xor    %eax,%eax
call   1070 <fprintf@plt>
mov    0x2d1e(%rip),%rax
mov    (%rax),%edi
call   10a0 <exit@plt>

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

LLVM IR (-O2):
@stderr = global i32 0
@.str = [22 x i8] c"Uso: %s <input_file>\0A\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [16 x i8] c"Err(%d) %s: %s\0A\00"
@errno = global i32 0
@EOF = global i32 0
@stdout = global i32 0
@.str.3 = [26 x i8] c"Err(%d) %s: stream error\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 2
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 ([22 x i8], [22 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* @fopen(i8* %12, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%14 = icmp eq i32* %13, null
br i1 %14, label %18, label %15
15: ; preds = %10
%16 = tail call i32 @feof(i32* %13)
%17 = icmp eq i32 %16, 0
br i1 %17, label %26, label %36
18: ; preds = %10
%19 = load i32, i32* @stderr
%20 = load i32, i32* @errno
%21 = tail call i8* @strerror(i32 %20)
%22 = load i8*, i8** %11
%23 = tail call i32 (i32, i8*, ...) @fprintf(i32 %19, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0), i32 %20, i8* %21, i8* %22)
%24 = load i32, i32* @EXIT_FAILURE
%25 = tail call i32 @exit(i32 %24)
unreachable
26: ; preds = %15, %33
%27 = tail call i32 @fgetc(i32* %13)
%28 = load i32, i32* @EOF
%29 = icmp eq i32 %27, %28
br i1 %29, label %33, label %30
30: ; preds = %26
%31 = load i32, i32* @stdout
%32 = tail call i32 @fputc(i32 %27, i32 %31)
br label %33
33: ; preds = %30, %26
%34 = tail call i32 @feof(i32* %13)
%35 = icmp eq i32 %34, 0
br i1 %35, label %26, label %36
36: ; preds = %33, %15
%37 = tail call i64 @ferror(i32* %13)
%38 = icmp eq i64 %37, 0
br i1 %38, label %46, label %39
39: ; preds = %36
%40 = load i32, i32* @stderr
%41 = load i32, i32* @errno
%42 = tail call i8* @strerror(i32 %41)
%43 = tail call i32 (i32, i8*, ...) @fprintf(i32 %40, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.3, i64 0, i64 0), i32 %41, i8* %42)
%44 = load i32, i32* @EXIT_FAILURE
%45 = tail call i32 @exit(i32 %44)
unreachable
46: ; preds = %36
%47 = tail call i32 @fclose(i32* %13)
%48 = load i32, i32* @EXIT_SUCCESS
ret i32 %48
}