#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*/ SEEK_SET;
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ free(unsigned char *);
int /*<<< orphan*/ fseek(int /*<<< orphan*/ *, int, int /*<<< orphan*/);
int /*<<< orphan*/ fwrite(unsigned char *, int, int, int /*<<< orphan*/ *);
unsigned char getc(int /*<<< orphan*/ *);
scalar_t__ malloc(unsigned int);
int /*<<< orphan*/ print_usage();
int main(int argc, char *argv[]) {
  FILE *image_file;
  FILE *boot_sector;
  unsigned int i;
  unsigned char *buffer;
  if (!(argc == 3)) {
    print_usage();
    return -1;
  }
  i = 0;
  boot_sector = fopen(argv[2], "rb");
  image_file = fopen(argv[1], "rb");
  buffer = (char *)malloc((unsigned int)1474560);
  for (i = 0; i < 1474560; i++)
    buffer[i] = '\0';
  i = 0;
  while (i < 3) {
    buffer[i] = getc(boot_sector);
    i++;
  }
  fseek(image_file, 3, SEEK_SET);
  while (i < 62) {
    buffer[i] = getc(image_file);
    i++;
  }
  fseek(boot_sector, 62, SEEK_SET);
  fseek(image_file, 62, SEEK_SET);
  while (i < 512) {
    buffer[i] = getc(boot_sector);
    i++;
  }
  fseek(image_file, 512, SEEK_SET);
  while (i < 1474560) {
    buffer[i] = getc(image_file);
    i++;
  }
  fclose(image_file);
  fclose(boot_sector);
  image_file = fopen(argv[1], "wb");
  fwrite(buffer, 1474560, 1, image_file);
  fclose(image_file);
  free(buffer);
  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     11b3 <main+0x33>
mov    $0x0,%al
call   1090 <print_usage@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    139c <main+0x21c>
movl   $0x0,-0x24(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xe37(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe1f(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x18(%rbp)
mov    $0x168000,%edi
call   1050 <malloc@plt>
mov    %rax,-0x30(%rbp)
movl   $0x0,-0x24(%rbp)
cmpl   $0x168000,-0x24(%rbp)
jae    1225 <main+0xa5>
mov    -0x30(%rbp),%rax
mov    -0x24(%rbp),%ecx
movb   $0x0,(%rax,%rcx,1)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    11ff <main+0x7f>
movl   $0x0,-0x24(%rbp)
cmpl   $0x3,-0x24(%rbp)
jae    1259 <main+0xd9>
mov    -0x20(%rbp),%rdi
call   10a0 <getc@plt>
mov    %al,%dl
mov    -0x30(%rbp),%rax
mov    -0x24(%rbp),%ecx
mov    %dl,(%rax,%rcx,1)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    122c <main+0xac>
mov    -0x18(%rbp),%rdi
mov    0x2d7c(%rip),%rax
mov    (%rax),%edx
mov    $0x3,%esi
call   1060 <fseek@plt>
cmpl   $0x3e,-0x24(%rbp)
jae    129d <main+0x11d>
mov    -0x18(%rbp),%rdi
call   10a0 <getc@plt>
mov    %al,%dl
mov    -0x30(%rbp),%rax
mov    -0x24(%rbp),%ecx
mov    %dl,(%rax,%rcx,1)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1270 <main+0xf0>
mov    -0x20(%rbp),%rdi
mov    0x2d38(%rip),%rax
mov    (%rax),%edx
mov    $0x3e,%esi
call   1060 <fseek@plt>
mov    -0x18(%rbp),%rdi
mov    0x2d21(%rip),%rax
mov    (%rax),%edx
mov    $0x3e,%esi
call   1060 <fseek@plt>
cmpl   $0x200,-0x24(%rbp)
jae    12fb <main+0x17b>
mov    -0x20(%rbp),%rdi
call   10a0 <getc@plt>
mov    %al,%dl
mov    -0x30(%rbp),%rax
mov    -0x24(%rbp),%ecx
mov    %dl,(%rax,%rcx,1)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    12cb <main+0x14b>
mov    -0x18(%rbp),%rdi
mov    0x2cda(%rip),%rax
mov    (%rax),%edx
mov    $0x200,%esi
call   1060 <fseek@plt>
cmpl   $0x168000,-0x24(%rbp)
jae    1342 <main+0x1c2>
mov    -0x18(%rbp),%rdi
call   10a0 <getc@plt>
mov    %al,%dl
mov    -0x30(%rbp),%rax
mov    -0x24(%rbp),%ecx
mov    %dl,(%rax,%rcx,1)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1312 <main+0x192>
mov    -0x18(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x20(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xca0(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x18(%rbp)
mov    -0x30(%rbp),%rdi
mov    -0x18(%rbp),%rcx
mov    $0x168000,%esi
mov    $0x1,%edx
call   1080 <fwrite@plt>
mov    -0x18(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x30(%rbp),%rdi
call   1030 <free@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
cmp    $0x3,%edi
jne    1304 <main+0x174>
mov    %rsi,%r14
mov    0x10(%rsi),%rdi
lea    0xe4e(%rip),%rbx
mov    %rbx,%rsi
call   1080 <fopen@plt>
mov    %rax,%r15
mov    0x8(%r14),%rdi
mov    %rbx,%rsi
call   1080 <fopen@plt>
mov    %rax,%r12
mov    $0x168000,%edi
call   1060 <malloc@plt>
mov    %rax,%rbx
mov    $0x168000,%edx
mov    %rax,%rdi
xor    %esi,%esi
call   1050 <memset@plt>
mov    %r15,%rdi
call   10b0 <getc@plt>
mov    %al,(%rbx)
mov    %r15,%rdi
call   10b0 <getc@plt>
mov    %al,0x1(%rbx)
mov    %r15,%rdi
call   10b0 <getc@plt>
mov    %al,0x2(%rbx)
mov    0x2dd1(%rip),%r13
mov    0x0(%r13),%edx
mov    %r12,%rdi
mov    $0x3,%esi
call   1070 <fseek@plt>
mov    $0x3,%ebp
cs nopw 0x0(%rax,%rax,1)
nop
mov    %r12,%rdi
call   10b0 <getc@plt>
mov    %al,(%rbx,%rbp,1)
add    $0x1,%rbp
cmp    $0x3e,%rbp
jne    1230 <main+0xa0>
mov    0x0(%r13),%edx
mov    %r15,%rdi
mov    $0x3e,%esi
call   1070 <fseek@plt>
mov    0x0(%r13),%edx
mov    %r12,%rdi
mov    $0x3e,%esi
call   1070 <fseek@plt>
mov    $0x3e,%ebp
nopl   0x0(%rax)
mov    %r15,%rdi
call   10b0 <getc@plt>
mov    %al,(%rbx,%rbp,1)
add    $0x1,%rbp
cmp    $0x200,%rbp
jne    1270 <main+0xe0>
mov    0x0(%r13),%edx
mov    %r12,%rdi
mov    $0x200,%esi
call   1070 <fseek@plt>
mov    $0x200,%ebp
xchg   %ax,%ax
mov    %r12,%rdi
call   10b0 <getc@plt>
mov    %al,(%rbx,%rbp,1)
add    $0x1,%rbp
cmp    $0x168000,%rbp
jne    12a0 <main+0x110>
mov    %r12,%rdi
call   1040 <fclose@plt>
mov    %r15,%rdi
call   1040 <fclose@plt>
mov    0x8(%r14),%rdi
lea    0xd30(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,%r14
mov    %rbx,%rdi
mov    $0x168000,%esi
mov    $0x1,%edx
mov    %rax,%rcx
call   1090 <fwrite@plt>
mov    %r14,%rdi
call   1040 <fclose@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
xor    %eax,%eax
jmp    1310 <main+0x180>
xor    %eax,%eax
call   10a0 <print_usage@plt>
mov    $0xffffffff,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"rb\00"
@SEEK_SET = global i32 0
@.str.1 = [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
%9 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%10 = load i32, i32* %4
%11 = icmp eq i32 %10, 3
br i1 %11, label %14, label %12
12: ; preds = %2
%13 = call i32 (...) @print_usage()
store i32 -1, i32* %3
br label %116
14: ; preds = %2
store i32 0, i32* %8
%15 = load i8**, i8*** %5
%16 = getelementptr inbounds i8*, i8** %15, i64 2
%17 = load i8*, i8** %16
%18 = call i32* @fopen(i8* %17, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
store i32* %18, i32** %7
%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, i64 0, i64 0))
store i32* %22, i32** %6
%23 = call i64 @malloc(i32 1474560)
%24 = inttoptr i64 %23 to i8*
store i8* %24, i8** %9
store i32 0, i32* %8
br label %25
25: ; preds = %33, %14
%26 = load i32, i32* %8
%27 = icmp ult i32 %26, 1474560
br i1 %27, label %28, label %36
28: ; preds = %25
%29 = load i8*, i8** %9
%30 = load i32, i32* %8
%31 = zext i32 %30 to i64
%32 = getelementptr inbounds i8, i8* %29, i64 %31
store i8 0, i8* %32
br label %33
33: ; preds = %28
%34 = load i32, i32* %8
%35 = add i32 %34, 1
store i32 %35, i32* %8
br label %25
36: ; preds = %25
store i32 0, i32* %8
br label %37
37: ; preds = %40, %36
%38 = load i32, i32* %8
%39 = icmp ult i32 %38, 3
br i1 %39, label %40, label %49
40: ; preds = %37
%41 = load i32*, i32** %7
%42 = call zeroext i8 @getc(i32* %41)
%43 = load i8*, i8** %9
%44 = load i32, i32* %8
%45 = zext i32 %44 to i64
%46 = getelementptr inbounds i8, i8* %43, i64 %45
store i8 %42, i8* %46
%47 = load i32, i32* %8
%48 = add i32 %47, 1
store i32 %48, i32* %8
br label %37
49: ; preds = %37
%50 = load i32*, i32** %6
%51 = load i32, i32* @SEEK_SET
%52 = call i32 @fseek(i32* %50, i32 3, i32 %51)
br label %53
53: ; preds = %56, %49
%54 = load i32, i32* %8
%55 = icmp ult i32 %54, 62
br i1 %55, label %56, label %65
56: ; preds = %53
%57 = load i32*, i32** %6
%58 = call zeroext i8 @getc(i32* %57)
%59 = load i8*, i8** %9
%60 = load i32, i32* %8
%61 = zext i32 %60 to i64
%62 = getelementptr inbounds i8, i8* %59, i64 %61
store i8 %58, i8* %62
%63 = load i32, i32* %8
%64 = add i32 %63, 1
store i32 %64, i32* %8
br label %53
65: ; preds = %53
%66 = load i32*, i32** %7
%67 = load i32, i32* @SEEK_SET
%68 = call i32 @fseek(i32* %66, i32 62, i32 %67)
%69 = load i32*, i32** %6
%70 = load i32, i32* @SEEK_SET
%71 = call i32 @fseek(i32* %69, i32 62, i32 %70)
br label %72
72: ; preds = %75, %65
%73 = load i32, i32* %8
%74 = icmp ult i32 %73, 512
br i1 %74, label %75, label %84
75: ; preds = %72
%76 = load i32*, i32** %7
%77 = call zeroext i8 @getc(i32* %76)
%78 = load i8*, i8** %9
%79 = load i32, i32* %8
%80 = zext i32 %79 to i64
%81 = getelementptr inbounds i8, i8* %78, i64 %80
store i8 %77, i8* %81
%82 = load i32, i32* %8
%83 = add i32 %82, 1
store i32 %83, i32* %8
br label %72
84: ; preds = %72
%85 = load i32*, i32** %6
%86 = load i32, i32* @SEEK_SET
%87 = call i32 @fseek(i32* %85, i32 512, i32 %86)
br label %88
88: ; preds = %91, %84
%89 = load i32, i32* %8
%90 = icmp ult i32 %89, 1474560
br i1 %90, label %91, label %100
91: ; preds = %88
%92 = load i32*, i32** %6
%93 = call zeroext i8 @getc(i32* %92)
%94 = load i8*, i8** %9
%95 = load i32, i32* %8
%96 = zext i32 %95 to i64
%97 = getelementptr inbounds i8, i8* %94, i64 %96
store i8 %93, i8* %97
%98 = load i32, i32* %8
%99 = add i32 %98, 1
store i32 %99, i32* %8
br label %88
100: ; preds = %88
%101 = load i32*, i32** %6
%102 = call i32 @fclose(i32* %101)
%103 = load i32*, i32** %7
%104 = call i32 @fclose(i32* %103)
%105 = load i8**, i8*** %5
%106 = getelementptr inbounds i8*, i8** %105, i64 1
%107 = load i8*, i8** %106
%108 = call i32* @fopen(i8* %107, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
store i32* %108, i32** %6
%109 = load i8*, i8** %9
%110 = load i32*, i32** %6
%111 = call i32 @fwrite(i8* %109, i32 1474560, i32 1, i32* %110)
%112 = load i32*, i32** %6
%113 = call i32 @fclose(i32* %112)
%114 = load i8*, i8** %9
%115 = call i32 @free(i8* %114)
store i32 0, i32* %3
br label %116
116: ; preds = %100, %12
%117 = load i32, i32* %3
ret i32 %117
}

LLVM IR (-O2):
@.str = [3 x i8] c"rb\00"
@SEEK_SET = global i32 0
@.str.1 = [3 x i8] c"wb\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 3
br i1 %3, label %6, label %4
4: ; preds = %2
%5 = tail call i32 (...) @print_usage()
br label %56
6: ; preds = %2
%7 = getelementptr inbounds i8*, i8** %1, i64 2
%8 = load i8*, i8** %7
%9 = tail call i32* @fopen(i8* %8, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%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, i64 0, i64 0))
%13 = tail call i64 @malloc(i32 1474560)
%14 = inttoptr i64 %13 to i8*
%15 = tail call zeroext i8 @getc(i32* %9)
store i8 %15, i8* %14
%16 = tail call zeroext i8 @getc(i32* %9)
%17 = getelementptr inbounds i8, i8* %14, i64 1
store i8 %16, i8* %17
%18 = tail call zeroext i8 @getc(i32* %9)
%19 = getelementptr inbounds i8, i8* %14, i64 2
store i8 %18, i8* %19
%20 = load i32, i32* @SEEK_SET
%21 = tail call i32 @fseek(i32* %12, i32 3, i32 %20)
br label %22
22: ; preds = %6, %22
%23 = phi i64 [ 3, %6 ], [ %26, %22 ]
%24 = tail call zeroext i8 @getc(i32* %12)
%25 = getelementptr inbounds i8, i8* %14, i64 %23
store i8 %24, i8* %25
%26 = add nuw nsw i64 %23, 1
%27 = icmp eq i64 %26, 62
br i1 %27, label %28, label %22
28: ; preds = %22
%29 = load i32, i32* @SEEK_SET
%30 = tail call i32 @fseek(i32* %9, i32 62, i32 %29)
%31 = load i32, i32* @SEEK_SET
%32 = tail call i32 @fseek(i32* %12, i32 62, i32 %31)
br label %33
33: ; preds = %28, %33
%34 = phi i64 [ 62, %28 ], [ %37, %33 ]
%35 = tail call zeroext i8 @getc(i32* %9)
%36 = getelementptr inbounds i8, i8* %14, i64 %34
store i8 %35, i8* %36
%37 = add nuw nsw i64 %34, 1
%38 = icmp eq i64 %37, 512
br i1 %38, label %39, label %33
39: ; preds = %33
%40 = load i32, i32* @SEEK_SET
%41 = tail call i32 @fseek(i32* %12, i32 512, i32 %40)
br label %42
42: ; preds = %39, %42
%43 = phi i64 [ 512, %39 ], [ %46, %42 ]
%44 = tail call zeroext i8 @getc(i32* %12)
%45 = getelementptr inbounds i8, i8* %14, i64 %43
store i8 %44, i8* %45
%46 = add nuw nsw i64 %43, 1
%47 = icmp eq i64 %46, 1474560
br i1 %47, label %48, label %42
48: ; preds = %42
%49 = tail call i32 @fclose(i32* %12)
%50 = tail call i32 @fclose(i32* %9)
%51 = load i8*, i8** %10
%52 = tail call i32* @fopen(i8* %51, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%53 = tail call i32 @fwrite(i8* %14, i32 1474560, i32 1, i32* %52)
%54 = tail call i32 @fclose(i32* %52)
%55 = tail call i32 @free(i8* %14)
br label %56
56: ; preds = %48, %4
%57 = phi i32 [ 0, %48 ], [ -1, %4 ]
ret i32 %57
}