#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*/ buffer;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ exit(int);
scalar_t__ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *, ...);
int /*<<< orphan*/ fputs(char *, int /*<<< orphan*/ *);
int /*<<< orphan*/ stderr;
int main(int argc, char *argv[]) {
  char buffer[512];
  FILE *fpin, *fpout;
  if (argc != 3) {
    fprintf(stderr, "Usage: %s sourcefile destination\n", argv[0]);
    exit(1);
  }
  fpin = fopen(argv[1], "r");
  if (fpin == NULL) {
    fprintf(stderr, "%s: can't open %s for input\n", argv[0], argv[1]);
    exit(1);
  }
  fpout = fopen(argv[2], "w");
  if (fpout == NULL) {
    fprintf(stderr, "%s: can't open %s for input\n", argv[0], argv[1]);
    exit(1);
  }
  while (fgets(buffer, sizeof(buffer), fpin) != NULL)
    fputs(buffer, fpout);
  if (fclose(fpin) != 0) {
    fprintf(stderr, "%s: unable to close %s\n", argv[0], argv[1]);
    exit(1);
  }
  if (fclose(fpout)) {
    fprintf(stderr, "%s: unable to close %s\n", argv[0], argv[1]);
    exit(1);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x220,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x3,-0x8(%rbp)
je     11ab <main+0x4b>
mov    0x2e56(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe66(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    $0x1,%edi
call   1080 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe68(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x218(%rbp)
cmpq   $0x0,-0x218(%rbp)
jne    1204 <main+0xa4>
mov    0x2e05(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rcx
lea    0xe31(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    $0x1,%edi
call   1080 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xe2e(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x220(%rbp)
cmpq   $0x0,-0x220(%rbp)
jne    125d <main+0xfd>
mov    0x2dac(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rcx
lea    0xdd8(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    $0x1,%edi
call   1080 <exit@plt>
jmp    1262 <main+0x102>
lea    -0x210(%rbp),%rdi
mov    -0x218(%rbp),%rdx
mov    $0x200,%esi
call   1050 <fgets@plt>
cmp    $0x0,%rax
je     129c <main+0x13c>
lea    -0x210(%rbp),%rdi
mov    -0x220(%rbp),%rsi
call   1040 <fputs@plt>
jmp    1262 <main+0x102>
mov    -0x218(%rbp),%rdi
call   1030 <fclose@plt>
cmp    $0x0,%rax
je     12e2 <main+0x182>
mov    0x2d27(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rcx
lea    0xd72(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    $0x1,%edi
call   1080 <exit@plt>
mov    -0x220(%rbp),%rdi
call   1030 <fclose@plt>
cmp    $0x0,%rax
je     1328 <main+0x1c8>
mov    0x2ce1(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rcx
lea    0xd2c(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    $0x1,%edi
call   1080 <exit@plt>
xor    %eax,%eax
add    $0x220,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x208,%rsp
mov    %rsi,%r14
cmp    $0x3,%edi
jne    125c <main+0xfc>
mov    0x8(%r14),%rdi
lea    0xe9d(%rip),%rsi
call   1070 <fopen@plt>
test   %rax,%rax
je     121b <main+0xbb>
mov    %rax,%r12
mov    0x10(%r14),%rdi
lea    0xea0(%rip),%rsi
call   1070 <fopen@plt>
test   %rax,%rax
je     121b <main+0xbb>
mov    %rax,%r15
mov    %rsp,%rdi
mov    $0x200,%esi
mov    %r12,%rdx
call   1050 <fgets@plt>
test   %rax,%rax
je     11f0 <main+0x90>
mov    %rsp,%rbx
cs nopw 0x0(%rax,%rax,1)
mov    %rbx,%rdi
mov    %r15,%rsi
call   1040 <fputs@plt>
mov    %rbx,%rdi
mov    $0x200,%esi
mov    %r12,%rdx
call   1050 <fgets@plt>
test   %rax,%rax
jne    11d0 <main+0x70>
mov    %r12,%rdi
call   1030 <fclose@plt>
test   %rax,%rax
jne    1234 <main+0xd4>
mov    %r15,%rdi
call   1030 <fclose@plt>
test   %rax,%rax
jne    1234 <main+0xd4>
xor    %eax,%eax
add    $0x208,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret
mov    0x2dbe(%rip),%rax
mov    (%rax),%edi
mov    (%r14),%rdx
mov    0x8(%r14),%rcx
lea    0xdf2(%rip),%rsi
jmp    124b <main+0xeb>
mov    0x2da5(%rip),%rax
mov    (%rax),%edi
mov    (%r14),%rdx
mov    0x8(%r14),%rcx
lea    0xdf8(%rip),%rsi
xor    %eax,%eax
call   1060 <fprintf@plt>
mov    $0x1,%edi
call   1080 <exit@plt>
mov    0x2d7d(%rip),%rax
mov    (%rax),%edi
mov    (%r14),%rdx
lea    0xd91(%rip),%rsi
xor    %eax,%eax
call   1060 <fprintf@plt>
mov    $0x1,%edi
call   1080 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [34 x i8] c"Usage: %s sourcefile destination\0A\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [29 x i8] c"%s: can't open %s for input\0A\00"
@.str.3 = [2 x i8] c"w\00"
@.str.4 = [24 x i8] c"%s: unable to close %s\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [512 x i8]
%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 %18
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*, i8*, ...) @fprintf(i32 %12, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0), i8* %15)
%17 = call i32 @exit(i32 1)
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** %7
%23 = load i32*, i32** %7
%24 = icmp eq i32* %23, null
br i1 %24, label %25, label %35
25: ; preds = %18
%26 = load i32, i32* @stderr
%27 = load i8**, i8*** %5
%28 = getelementptr inbounds i8*, i8** %27, i64 0
%29 = load i8*, i8** %28
%30 = load i8**, i8*** %5
%31 = getelementptr inbounds i8*, i8** %30, i64 1
%32 = load i8*, i8** %31
%33 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %26, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0), i8* %29, i8* %32)
%34 = call i32 @exit(i32 1)
unreachable
35: ; preds = %18
%36 = load i8**, i8*** %5
%37 = getelementptr inbounds i8*, i8** %36, i64 2
%38 = load i8*, i8** %37
%39 = call i32* @fopen(i8* %38, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
store i32* %39, i32** %8
%40 = load i32*, i32** %8
%41 = icmp eq i32* %40, null
br i1 %41, label %42, label %52
42: ; preds = %35
%43 = load i32, i32* @stderr
%44 = load i8**, i8*** %5
%45 = getelementptr inbounds i8*, i8** %44, i64 0
%46 = load i8*, i8** %45
%47 = load i8**, i8*** %5
%48 = getelementptr inbounds i8*, i8** %47, i64 1
%49 = load i8*, i8** %48
%50 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %43, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0), i8* %46, i8* %49)
%51 = call i32 @exit(i32 1)
unreachable
52: ; preds = %35
br label %53
53: ; preds = %58, %52
%54 = getelementptr inbounds [512 x i8], [512 x i8]* %6, i64 0, i64 0
%55 = load i32*, i32** %7
%56 = call i32* @fgets(i8* %54, i32 512, i32* %55)
%57 = icmp ne i32* %56, null
br i1 %57, label %58, label %62
58: ; preds = %53
%59 = getelementptr inbounds [512 x i8], [512 x i8]* %6, i64 0, i64 0
%60 = load i32*, i32** %8
%61 = call i32 @fputs(i8* %59, i32* %60)
br label %53
62: ; preds = %53
%63 = load i32*, i32** %7
%64 = call i64 @fclose(i32* %63)
%65 = icmp ne i64 %64, 0
br i1 %65, label %66, label %76
66: ; preds = %62
%67 = load i32, i32* @stderr
%68 = load i8**, i8*** %5
%69 = getelementptr inbounds i8*, i8** %68, i64 0
%70 = load i8*, i8** %69
%71 = load i8**, i8*** %5
%72 = getelementptr inbounds i8*, i8** %71, i64 1
%73 = load i8*, i8** %72
%74 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %67, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.4, i64 0, i64 0), i8* %70, i8* %73)
%75 = call i32 @exit(i32 1)
unreachable
76: ; preds = %62
%77 = load i32*, i32** %8
%78 = call i64 @fclose(i32* %77)
%79 = icmp ne i64 %78, 0
br i1 %79, label %80, label %90
80: ; preds = %76
%81 = load i32, i32* @stderr
%82 = load i8**, i8*** %5
%83 = getelementptr inbounds i8*, i8** %82, i64 0
%84 = load i8*, i8** %83
%85 = load i8**, i8*** %5
%86 = getelementptr inbounds i8*, i8** %85, i64 1
%87 = load i8*, i8** %86
%88 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %81, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.4, i64 0, i64 0), i8* %84, i8* %87)
%89 = call i32 @exit(i32 1)
unreachable
90: ; preds = %76
ret i32 0
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [34 x i8] c"Usage: %s sourcefile destination\0A\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [29 x i8] c"%s: can't open %s for input\0A\00"
@.str.3 = [2 x i8] c"w\00"
@.str.4 = [24 x i8] c"%s: unable to close %s\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [512 x i8]
%4 = getelementptr inbounds [512 x i8], [512 x i8]* %3, i64 0, i64 0
%5 = icmp eq i32 %0, 3
br i1 %5, label %11, label %6
6: ; preds = %2
%7 = load i32, i32* @stderr
%8 = load i8*, i8** %1
%9 = tail call i32 (i32, i8*, i8*, ...) @fprintf(i32 %7, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0), i8* %8)
%10 = tail call i32 @exit(i32 1)
unreachable
11: ; preds = %2
%12 = getelementptr inbounds i8*, i8** %1, i64 1
%13 = load i8*, i8** %12
%14 = tail call i32* @fopen(i8* %13, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%15 = icmp eq i32* %14, null
br i1 %15, label %16, label %22
16: ; preds = %11
%17 = load i32, i32* @stderr
%18 = load i8*, i8** %1
%19 = load i8*, i8** %12
%20 = tail call i32 (i32, i8*, i8*, ...) @fprintf(i32 %17, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0), i8* %18, i8* %19)
%21 = tail call i32 @exit(i32 1)
unreachable
22: ; preds = %11
%23 = getelementptr inbounds i8*, i8** %1, i64 2
%24 = load i8*, i8** %23
%25 = tail call i32* @fopen(i8* %24, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%26 = icmp eq i32* %25, null
br i1 %26, label %30, label %27
27: ; preds = %22
%28 = call i32* @fgets(i8* %4, i32 512, i32* %14)
%29 = icmp eq i32* %28, null
br i1 %29, label %40, label %36
30: ; preds = %22
%31 = load i32, i32* @stderr
%32 = load i8*, i8** %1
%33 = load i8*, i8** %12
%34 = tail call i32 (i32, i8*, i8*, ...) @fprintf(i32 %31, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0), i8* %32, i8* %33)
%35 = tail call i32 @exit(i32 1)
unreachable
36: ; preds = %27, %36
%37 = call i32 @fputs(i8* %4, i32* %25)
%38 = call i32* @fgets(i8* %4, i32 512, i32* %14)
%39 = icmp eq i32* %38, null
br i1 %39, label %40, label %36
40: ; preds = %36, %27
%41 = call i64 @fclose(i32* %14)
%42 = icmp eq i64 %41, 0
br i1 %42, label %49, label %43
43: ; preds = %40
%44 = load i32, i32* @stderr
%45 = load i8*, i8** %1
%46 = load i8*, i8** %12
%47 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %44, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.4, i64 0, i64 0), i8* %45, i8* %46)
%48 = call i32 @exit(i32 1)
unreachable
49: ; preds = %40
%50 = call i64 @fclose(i32* %25)
%51 = icmp eq i64 %50, 0
br i1 %51, label %58, label %52
52: ; preds = %49
%53 = load i32, i32* @stderr
%54 = load i8*, i8** %1
%55 = load i8*, i8** %12
%56 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %53, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.4, i64 0, i64 0), i8* %54, i8* %55)
%57 = call i32 @exit(i32 1)
unreachable
58: ; preds = %49
ret i32 0
}