#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*/ Convert(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char const *, char *);
int fread(char *, int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ free(char *);
scalar_t__ malloc(int);
int main(int pc, const char **ps) {
  FILE *in = fopen(ps[1], "rb");
  FILE *out = fopen(ps[2], "wb+");
  if (in && out) {
    int len = 0x10000;
    char *data = (char *)malloc(len);
    if (data) {
      len = fread(data, 1, len, in);
      Convert(data, len, out);
      free(data);
    }
    fclose(in);
    fclose(out);
  }
  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)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe7b(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xe66(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     121d <main+0xbd>
cmpq   $0x0,-0x20(%rbp)
je     121d <main+0xbd>
movl   $0x10000,-0x24(%rbp)
mov    -0x24(%rbp),%edi
call   1070 <malloc@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
je     120b <main+0xab>
mov    -0x30(%rbp),%rdi
mov    -0x24(%rbp),%edx
mov    -0x18(%rbp),%rcx
mov    $0x1,%esi
call   1040 <fread@plt>
mov    %eax,-0x24(%rbp)
mov    -0x30(%rbp),%rdi
mov    -0x24(%rbp),%esi
mov    -0x20(%rbp),%rdx
call   1050 <Convert@plt>
mov    -0x30(%rbp),%rdi
call   1030 <free@plt>
mov    -0x18(%rbp),%rdi
call   1060 <fclose@plt>
mov    -0x20(%rbp),%rdi
call   1060 <fclose@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%rbx
mov    0x8(%rsi),%rdi
lea    0xe8d(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,%r15
mov    0x10(%rbx),%rdi
lea    0xe7d(%rip),%rsi
call   1080 <fopen@plt>
test   %r15,%r15
je     11e4 <main+0x84>
mov    %rax,%r14
test   %rax,%rax
je     11e4 <main+0x84>
mov    $0x10000,%edi
call   1070 <malloc@plt>
test   %rax,%rax
je     11d4 <main+0x74>
mov    %rax,%rbx
mov    %rax,%rdi
mov    $0x1,%esi
mov    $0x10000,%edx
mov    %r15,%rcx
call   1040 <fread@plt>
mov    %rbx,%rdi
mov    %eax,%esi
mov    %r14,%rdx
call   1050 <Convert@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    %r15,%rdi
call   1060 <fclose@plt>
mov    %r14,%rdi
call   1060 <fclose@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [3 x i8] c"rb\00"
@.str.1 = [4 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
%9 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%10 = load i8**, i8*** %5
%11 = getelementptr inbounds i8*, i8** %10, i64 1
%12 = load i8*, i8** %11
%13 = call i32* @fopen(i8* %12, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
store i32* %13, i32** %6
%14 = load i8**, i8*** %5
%15 = getelementptr inbounds i8*, i8** %14, i64 2
%16 = load i8*, i8** %15
%17 = call i32* @fopen(i8* %16, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
store i32* %17, i32** %7
%18 = load i32*, i32** %6
%19 = icmp ne i32* %18, null
br i1 %19, label %20, label %45
20: ; preds = %2
%21 = load i32*, i32** %7
%22 = icmp ne i32* %21, null
br i1 %22, label %23, label %45
23: ; preds = %20
store i32 65536, i32* %8
%24 = load i32, i32* %8
%25 = call i64 @malloc(i32 %24)
%26 = inttoptr i64 %25 to i8*
store i8* %26, i8** %9
%27 = load i8*, i8** %9
%28 = icmp ne i8* %27, null
br i1 %28, label %29, label %40
29: ; preds = %23
%30 = load i8*, i8** %9
%31 = load i32, i32* %8
%32 = load i32*, i32** %6
%33 = call i32 @fread(i8* %30, i32 1, i32 %31, i32* %32)
store i32 %33, i32* %8
%34 = load i8*, i8** %9
%35 = load i32, i32* %8
%36 = load i32*, i32** %7
%37 = call i32 @Convert(i8* %34, i32 %35, i32* %36)
%38 = load i8*, i8** %9
%39 = call i32 @free(i8* %38)
br label %40
40: ; preds = %29, %23
%41 = load i32*, i32** %6
%42 = call i32 @fclose(i32* %41)
%43 = load i32*, i32** %7
%44 = call i32 @fclose(i32* %43)
br label %45
45: ; preds = %40, %20, %2
ret i32 0
}

LLVM IR (-O2):
@.str = [3 x i8] c"rb\00"
@.str.1 = [4 x i8] c"wb+\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = getelementptr inbounds i8*, i8** %1, i64 1
%4 = load i8*, i8** %3
%5 = tail call i32* @fopen(i8* %4, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%6 = getelementptr inbounds i8*, i8** %1, i64 2
%7 = load i8*, i8** %6
%8 = tail call i32* @fopen(i8* %7, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%9 = icmp ne i32* %5, null
%10 = icmp ne i32* %8, null
%11 = and i1 %9, %10
br i1 %11, label %12, label %23
12: ; preds = %2
%13 = tail call i64 @malloc(i32 65536)
%14 = inttoptr i64 %13 to i8*
%15 = icmp eq i64 %13, 0
br i1 %15, label %20, label %16
16: ; preds = %12
%17 = tail call i32 @fread(i8* %14, i32 1, i32 65536, i32* %5)
%18 = tail call i32 @Convert(i8* %14, i32 %17, i32* %8)
%19 = tail call i32 @free(i8* %14)
br label %20
20: ; preds = %16, %12
%21 = tail call i32 @fclose(i32* %5)
%22 = tail call i32 @fclose(i32* %8)
br label %23
23: ; preds = %20, %2
ret i32 0
}