#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 /*<<< orphan*/ do_it(int /*<<< orphan*/ *, int /*<<< orphan*/ *,
                         int /*<<< orphan*/ *);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ stderr;
main(int argc, char **argv) {
  FILE *src, *trg, *out;
  if (argc != 4) {
    fprintf(stderr, "Usage: %s source target ulit\n", argv[0]);
    exit(0);
  } else if (!(src = fopen(argv[1], "rb")))
    fprintf(stderr, "%s: Could not open.\n", argv[1]);
  else if (!(trg = fopen(argv[2], "rb")))
    fprintf(stderr, "%s: Could not open.\n", argv[2]);
  else if (!(out = fopen(argv[3], "wb")))
    fprintf(stderr, "%s: Could not open.\n", argv[3]);
  else
    do_it(src, trg, out);
  fclose(src);
  fclose(trg);
  fclose(out);
}


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   $0x4,-0x8(%rbp)
je     1193 <main+0x43>
mov    0x2e69(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe79(%rip),%rsi
call   1040 <fprintf@plt>
xor    %edi,%edi
call   1070 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe7c(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
jne    11d7 <main+0x87>
mov    0x2e24(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdx
lea    0xe54(%rip),%rsi
call   1040 <fprintf@plt>
jmp    127a <main+0x12a>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xe38(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
jne    121b <main+0xcb>
mov    0x2de0(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdx
lea    0xe10(%rip),%rsi
call   1040 <fprintf@plt>
jmp    1275 <main+0x125>
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
lea    0xe0c(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x28(%rbp)
cmp    $0x0,%rax
jne    125f <main+0x10f>
mov    0x2d9c(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdx
lea    0xdcc(%rip),%rsi
call   1040 <fprintf@plt>
jmp    1270 <main+0x120>
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    -0x28(%rbp),%rdx
call   1050 <do_it@plt>
jmp    1275 <main+0x125>
jmp    127a <main+0x12a>
jmp    127f <main+0x12f>
mov    -0x18(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x20(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x28(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rsi,%rbx
cmp    $0x4,%edi
jne    1237 <main+0xe7>
mov    0x8(%rbx),%rdi
lea    0xeaf(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,%r14
test   %rax,%rax
je     11bc <main+0x6c>
mov    0x10(%rbx),%rdi
lea    0xe97(%rip),%rsi
call   1060 <fopen@plt>
test   %rax,%rax
je     11d7 <main+0x87>
mov    %rax,%r15
mov    0x18(%rbx),%rdi
lea    0xe97(%rip),%rsi
call   1060 <fopen@plt>
test   %rax,%rax
je     11f5 <main+0xa5>
mov    %rax,%r12
mov    %r14,%rdi
mov    %r15,%rsi
mov    %rax,%rdx
call   1050 <do_it@plt>
jmp    1211 <main+0xc1>
mov    0x2e1d(%rip),%rax
mov    (%rax),%edi
mov    0x8(%rbx),%rdx
lea    0xe51(%rip),%rsi
call   1040 <fprintf@plt>
jmp    1211 <main+0xc1>
mov    0x2e02(%rip),%rax
mov    (%rax),%edi
mov    0x10(%rbx),%rdx
lea    0xe36(%rip),%rsi
call   1040 <fprintf@plt>
xor    %r15d,%r15d
jmp    1211 <main+0xc1>
mov    0x2de4(%rip),%rax
mov    (%rax),%edi
mov    0x18(%rbx),%rdx
lea    0xe18(%rip),%rsi
call   1040 <fprintf@plt>
xor    %r12d,%r12d
mov    %r14,%rdi
call   1030 <fclose@plt>
mov    %r15,%rdi
call   1030 <fclose@plt>
mov    %r12,%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret
mov    0x2da2(%rip),%rax
mov    (%rax),%edi
mov    (%rbx),%rdx
lea    0xdb6(%rip),%rsi
call   1040 <fprintf@plt>
xor    %edi,%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [30 x i8] c"Usage: %s source target ulit\0A\00"
@.str.1 = [3 x i8] c"rb\00"
@.str.2 = [21 x i8] c"%s: Could not open.\0A\00"
@.str.3 = [3 x i8] c"wb\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 ne i32 %9, 4
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 @fprintf(i32 %12, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), i8* %15)
%17 = call i32 @exit(i32 0)
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 ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
store i32* %22, i32** %6
%23 = icmp ne i32* %22, null
br i1 %23, label %30, label %24
24: ; preds = %18
%25 = load i32, i32* @stderr
%26 = load i8**, i8*** %5
%27 = getelementptr inbounds i8*, i8** %26, i64 1
%28 = load i8*, i8** %27
%29 = call i32 @fprintf(i32 %25, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0), i8* %28)
br label %61
30: ; preds = %18
%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 ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
store i32* %34, i32** %7
%35 = icmp ne i32* %34, null
br i1 %35, label %42, label %36
36: ; preds = %30
%37 = load i32, i32* @stderr
%38 = load i8**, i8*** %5
%39 = getelementptr inbounds i8*, i8** %38, i64 2
%40 = load i8*, i8** %39
%41 = call i32 @fprintf(i32 %37, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0), i8* %40)
br label %60
42: ; preds = %30
%43 = load i8**, i8*** %5
%44 = getelementptr inbounds i8*, i8** %43, i64 3
%45 = load i8*, i8** %44
%46 = call i32* @fopen(i8* %45, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
store i32* %46, i32** %8
%47 = icmp ne i32* %46, null
br i1 %47, label %54, label %48
48: ; preds = %42
%49 = load i32, i32* @stderr
%50 = load i8**, i8*** %5
%51 = getelementptr inbounds i8*, i8** %50, i64 3
%52 = load i8*, i8** %51
%53 = call i32 @fprintf(i32 %49, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0), i8* %52)
br label %59
54: ; preds = %42
%55 = load i32*, i32** %6
%56 = load i32*, i32** %7
%57 = load i32*, i32** %8
%58 = call i32 @do_it(i32* %55, i32* %56, i32* %57)
br label %59
59: ; preds = %54, %48
br label %60
60: ; preds = %59, %36
br label %61
61: ; preds = %60, %24
br label %62
62: ; preds = %61
%63 = load i32*, i32** %6
%64 = call i32 @fclose(i32* %63)
%65 = load i32*, i32** %7
%66 = call i32 @fclose(i32* %65)
%67 = load i32*, i32** %8
%68 = call i32 @fclose(i32* %67)
%69 = load i32, i32* %3
ret i32 %69
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [30 x i8] c"Usage: %s source target ulit\0A\00"
@.str.1 = [3 x i8] c"rb\00"
@.str.2 = [21 x i8] c"%s: Could not open.\0A\00"
@.str.3 = [3 x i8] c"wb\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 4
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 ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), i8* %6)
%8 = tail call i32 @exit(i32 0)
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 ([3 x i8], [3 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 i32, i32* @stderr
%16 = load i8*, i8** %10
%17 = tail call i32 @fprintf(i32 %15, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0), i8* %16)
br label %38
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 ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%22 = icmp eq i32* %21, null
br i1 %22, label %23, label %27
23: ; preds = %18
%24 = load i32, i32* @stderr
%25 = load i8*, i8** %19
%26 = tail call i32 @fprintf(i32 %24, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0), i8* %25)
br label %38
27: ; preds = %18
%28 = getelementptr inbounds i8*, i8** %1, i64 3
%29 = load i8*, i8** %28
%30 = tail call i32* @fopen(i8* %29, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%31 = icmp eq i32* %30, null
br i1 %31, label %32, label %36
32: ; preds = %27
%33 = load i32, i32* @stderr
%34 = load i8*, i8** %28
%35 = tail call i32 @fprintf(i32 %33, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0), i8* %34)
br label %38
36: ; preds = %27
%37 = tail call i32 @do_it(i32* %12, i32* %21, i32* %30)
br label %38
38: ; preds = %14, %32, %36, %23
%39 = phi i32* [ %21, %36 ], [ %21, %32 ], [ null, %23 ], [ undef, %14 ]
%40 = phi i32* [ %30, %36 ], [ null, %32 ], [ undef, %23 ], [ undef, %14 ]
%41 = tail call i32 @fclose(i32* %12)
%42 = tail call i32 @fclose(i32* %39)
%43 = tail call i32 @fclose(i32* %40)
ret i32 0
}