#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(int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int getc(int /*<<< orphan*/ *);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ putc(int, int /*<<< orphan*/ *);
int /*<<< orphan*/ stderr;
int main(int argc, char *argv[]) {
  int c;
  FILE *from, *to;
  if (argc != 3) {
    fprintf(stderr, "Usage: %s from-file to-file\n", *argv);
    exit(1);
  }
  from = fopen(argv[1], "r");
  if (from == NULL) {
    perror(argv[1]);
    exit(1);
  }
  to = fopen(argv[2], "a");
  if (to == NULL) {
    perror(argv[2]);
    exit(1);
  }
  while ((c = getc(from)) != EOF) {
    putc(c, to);
  }
  fclose(from);
  fclose(to);
  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)
je     11b6 <main+0x46>
mov    0x2e41(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe59(%rip),%rsi
call   1050 <fprintf@plt>
mov    $0x1,%edi
call   1080 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe58(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    11f0 <main+0x80>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1070 <perror@plt>
mov    $0x1,%edi
call   1080 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xe20(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    122a <main+0xba>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1070 <perror@plt>
mov    $0x1,%edi
call   1080 <exit@plt>
jmp    122f <main+0xbf>
mov    -0x20(%rbp),%rdi
call   1090 <getc@plt>
mov    %eax,-0x14(%rbp)
mov    0x2da6(%rip),%rcx
cmp    (%rcx),%eax
je     125b <main+0xeb>
mov    -0x14(%rbp),%edi
mov    -0x28(%rbp),%rsi
call   1040 <putc@plt>
jmp    122f <main+0xbf>
mov    -0x20(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x28(%rbp),%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%r15
cmp    $0x3,%edi
jne    11ff <main+0x8f>
mov    0x8(%r15),%rdi
lea    0xe91(%rip),%rsi
call   1060 <fopen@plt>
test   %rax,%rax
je     1221 <main+0xb1>
mov    %rax,%r14
mov    0x10(%r15),%rdi
lea    0xe77(%rip),%rsi
call   1060 <fopen@plt>
test   %rax,%rax
je     1227 <main+0xb7>
mov    %rax,%rbx
mov    %r14,%rdi
call   1090 <getc@plt>
mov    0x2e24(%rip),%r15
cmp    (%r15),%eax
je     11e7 <main+0x77>
nopl   0x0(%rax)
mov    %eax,%edi
mov    %rbx,%rsi
call   1040 <putc@plt>
mov    %r14,%rdi
call   1090 <getc@plt>
cmp    (%r15),%eax
jne    11d0 <main+0x60>
mov    %r14,%rdi
call   1030 <fclose@plt>
mov    %rbx,%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %r15
ret
mov    0x2dd2(%rip),%rax
mov    (%rax),%edi
mov    (%r15),%rdx
lea    0xdee(%rip),%rsi
call   1050 <fprintf@plt>
mov    $0x1,%edi
call   1080 <exit@plt>
mov    0x8(%r15),%rdi
jmp    122b <main+0xbb>
mov    0x10(%r15),%rdi
call   1070 <perror@plt>
mov    $0x1,%edi
call   1080 <exit@plt>

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

LLVM IR (-O2):
@stderr = global i32 0
@.str = [29 x i8] c"Usage: %s from-file to-file\0A\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [2 x i8] c"a\00"
@EOF = global i32 0
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 3
br i1 %3, label %9, label %4
4: ; preds = %2
%5 = load i32, i32* @stderr
%6 = load i8*, i8** %1
%7 = tail call i32 @fprintf(i32 %5, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0), i8* %6)
%8 = tail call i32 @exit(i32 1)
unreachable
9: ; preds = %2
%10 = getelementptr inbounds i8*, i8** %1, i64 1
%11 = load i8*, i8** %10
%12 = tail call i32* @fopen(i8* %11, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%13 = icmp eq i32* %12, null
br i1 %13, label %14, label %18
14: ; preds = %9
%15 = load i8*, i8** %10
%16 = tail call i32 @perror(i8* %15)
%17 = tail call i32 @exit(i32 1)
unreachable
18: ; preds = %9
%19 = getelementptr inbounds i8*, i8** %1, i64 2
%20 = load i8*, i8** %19
%21 = tail call i32* @fopen(i8* %20, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%22 = icmp eq i32* %21, null
br i1 %22, label %27, label %23
23: ; preds = %18
%24 = tail call i32 @getc(i32* %12)
%25 = load i32, i32* @EOF
%26 = icmp eq i32 %24, %25
br i1 %26, label %37, label %31
27: ; preds = %18
%28 = load i8*, i8** %19
%29 = tail call i32 @perror(i8* %28)
%30 = tail call i32 @exit(i32 1)
unreachable
31: ; preds = %23, %31
%32 = phi i32 [ %34, %31 ], [ %24, %23 ]
%33 = tail call i32 @putc(i32 %32, i32* %21)
%34 = tail call i32 @getc(i32* %12)
%35 = load i32, i32* @EOF
%36 = icmp eq i32 %34, %35
br i1 %36, label %37, label %31
37: ; preds = %31, %23
%38 = tail call i32 @fclose(i32* %12)
%39 = tail call i32 @fclose(i32* %21)
ret i32 0
}