#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 */
struct stat {
  size_t st_size;
  int /*<<< orphan*/ st_mode;
};
typedef size_t fat_size;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int EXIT_FAILURE;
int /*<<< orphan*/ S_ISREG(int /*<<< orphan*/);
scalar_t__ copy_bootcode_into_image(int /*<<< orphan*/ *, int /*<<< orphan*/ *,
                                    size_t, int);
int detect_fat_size(int /*<<< orphan*/ *);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ help(char *);
size_t nop_slide_size(int);
scalar_t__ stat(char *, struct stat *);
int /*<<< orphan*/ stderr;
int main(int argc, char **argv) {
  struct stat bootloader_stats, image_stats;
  FILE *image_file, *boot_file;
  int fat_size;
  size_t bootcode_size;
  if (argc != 3) {
    help(argv[0]);
    return EXIT_FAILURE;
  }
  if (stat(argv[1], &bootloader_stats) || !S_ISREG(bootloader_stats.st_mode)) {
    help(argv[0]);
    return EXIT_FAILURE;
  }
  if (stat(argv[2], &image_stats) || !S_ISREG(image_stats.st_mode)) {
    help(argv[0]);
    return EXIT_FAILURE;
  }
  image_file = fopen(argv[2], "r+");
  if (!image_file) {
    help(argv[0]);
    return EXIT_FAILURE;
  }
  fat_size = detect_fat_size(image_file);
  if (fat_size < 0) {
    fclose(image_file);
    fprintf(stderr, "Unable to detect FAT type\n");
    help(argv[0]);
    return EXIT_FAILURE;
  }
  bootcode_size = bootloader_stats.st_size;
  if (bootcode_size > (512 - (fat_size)-2) - nop_slide_size(fat_size)) {
    fclose(image_file);
    fprintf(stderr, "Impossible to fit bootloader code into image\n");
    help(argv[0]);
    return EXIT_FAILURE;
  }
  if (image_stats.st_size < 512) {
    fclose(image_file);
    fprintf(stderr, "Impossible bootable geometry for image\n");
    help(argv[0]);
    return EXIT_FAILURE;
  }
  boot_file = fopen(argv[1], "r");
  if (!boot_file) {
    fclose(image_file);
    help(argv[0]);
    return EXIT_FAILURE;
  }
  if (copy_bootcode_into_image(boot_file, image_file, bootcode_size,
                               fat_size)) {
    fclose(image_file);
    fclose(boot_file);
    fprintf(stderr, "Error while copying. Possible corruption of image"
                    "file\n");
    return EXIT_FAILURE;
  }
  fclose(image_file);
  fclose(boot_file);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x3,-0x8(%rbp)
je     11cd <main+0x3d>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   10b0 <help@plt>
mov    0x2e15(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    146c <main+0x2dc>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    -0x20(%rbp),%rsi
call   1060 <stat@plt>
cmp    $0x0,%rax
jne    11f9 <main+0x69>
mov    -0x18(%rbp),%edi
call   1070 <S_ISREG@plt>
cmp    $0x0,%eax
jne    1216 <main+0x86>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   10b0 <help@plt>
mov    0x2dcc(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    146c <main+0x2dc>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    -0x30(%rbp),%rsi
call   1060 <stat@plt>
cmp    $0x0,%rax
jne    1242 <main+0xb2>
mov    -0x28(%rbp),%edi
call   1070 <S_ISREG@plt>
cmp    $0x0,%eax
jne    125f <main+0xcf>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   10b0 <help@plt>
mov    0x2d83(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    146c <main+0x2dc>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xd92(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,-0x38(%rbp)
cmpq   $0x0,-0x38(%rbp)
jne    129f <main+0x10f>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   10b0 <help@plt>
mov    0x2d43(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    146c <main+0x2dc>
mov    -0x38(%rbp),%rdi
call   1090 <detect_fat_size@plt>
mov    %eax,-0x44(%rbp)
cmpl   $0x0,-0x44(%rbp)
jge    12f0 <main+0x160>
mov    -0x38(%rbp),%rdi
call   1030 <fclose@plt>
mov    0x2d1b(%rip),%rax
mov    (%rax),%edi
lea    0xd35(%rip),%rsi
call   1050 <fprintf@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   10b0 <help@plt>
mov    0x2cf2(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    146c <main+0x2dc>
mov    -0x20(%rbp),%rax
mov    %rax,-0x50(%rbp)
mov    -0x50(%rbp),%rax
mov    %rax,-0x58(%rbp)
mov    $0x200,%eax
sub    -0x44(%rbp),%eax
sub    $0x2,%eax
cltq
mov    %rax,-0x60(%rbp)
mov    -0x44(%rbp),%edi
call   1040 <nop_slide_size@plt>
mov    -0x60(%rbp),%rcx
mov    %rax,%rdx
mov    -0x58(%rbp),%rax
sub    %rdx,%rcx
cmp    %rcx,%rax
jbe    136b <main+0x1db>
mov    -0x38(%rbp),%rdi
call   1030 <fclose@plt>
mov    0x2ca0(%rip),%rax
mov    (%rax),%edi
lea    0xcd5(%rip),%rsi
call   1050 <fprintf@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   10b0 <help@plt>
mov    0x2c77(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    146c <main+0x2dc>
cmpq   $0x200,-0x30(%rbp)
jae    13b4 <main+0x224>
mov    -0x38(%rbp),%rdi
call   1030 <fclose@plt>
mov    0x2c57(%rip),%rax
mov    (%rax),%edi
lea    0xcba(%rip),%rsi
call   1050 <fprintf@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   10b0 <help@plt>
mov    0x2c2e(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    146c <main+0x2dc>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xcb1(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,-0x40(%rbp)
cmpq   $0x0,-0x40(%rbp)
jne    13fd <main+0x26d>
mov    -0x38(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   10b0 <help@plt>
mov    0x2be5(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    146c <main+0x2dc>
mov    -0x40(%rbp),%rdi
mov    -0x38(%rbp),%rsi
mov    -0x50(%rbp),%rdx
mov    -0x44(%rbp),%ecx
call   1080 <copy_bootcode_into_image@plt>
cmp    $0x0,%rax
je     1453 <main+0x2c3>
mov    -0x38(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x40(%rbp),%rdi
call   1030 <fclose@plt>
mov    0x2bac(%rip),%rax
mov    (%rax),%edi
lea    0xc39(%rip),%rsi
call   1050 <fprintf@plt>
mov    0x2b8f(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    146c <main+0x2dc>
mov    -0x38(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x40(%rbp),%rdi
call   1030 <fclose@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %rsi,%rbx
cmp    $0x3,%edi
jne    11b9 <main+0x29>
mov    0x8(%rbx),%rdi
lea    0x18(%rsp),%rsi
call   1060 <stat@plt>
test   %rax,%rax
je     11d9 <main+0x49>
mov    (%rbx),%rdi
call   10b0 <help@plt>
mov    0x2e10(%rip),%rax
mov    (%rax),%eax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x20(%rsp),%edi
call   1070 <S_ISREG@plt>
test   %eax,%eax
je     11b9 <main+0x29>
mov    0x10(%rbx),%rdi
lea    0x8(%rsp),%rsi
call   1060 <stat@plt>
test   %rax,%rax
jne    11b9 <main+0x29>
mov    0x10(%rsp),%edi
call   1070 <S_ISREG@plt>
test   %eax,%eax
je     11b9 <main+0x29>
mov    0x10(%rbx),%rdi
lea    0xdef(%rip),%rsi
call   10a0 <fopen@plt>
test   %rax,%rax
je     11b9 <main+0x29>
mov    %rax,%r14
mov    %rax,%rdi
call   1090 <detect_fat_size@plt>
test   %eax,%eax
js     126f <main+0xdf>
mov    %eax,%r13d
mov    0x18(%rsp),%r15
mov    $0x1fe,%eax
sub    %r13d,%eax
movslq %eax,%rbp
mov    %r13d,%edi
call   1040 <nop_slide_size@plt>
sub    %rax,%rbp
cmp    %rbp,%r15
jbe    1291 <main+0x101>
mov    %r14,%rdi
call   1030 <fclose@plt>
mov    0x2d84(%rip),%rax
mov    (%rax),%edi
lea    0xdb9(%rip),%rsi
call   1050 <fprintf@plt>
jmp    11b9 <main+0x29>
mov    %r14,%rdi
call   1030 <fclose@plt>
mov    0x2d62(%rip),%rax
mov    (%rax),%edi
lea    0xd7c(%rip),%rsi
call   1050 <fprintf@plt>
jmp    11b9 <main+0x29>
cmpq   $0x1ff,0x8(%rsp)
ja     12be <main+0x12e>
mov    %r14,%rdi
call   1030 <fclose@plt>
mov    0x2d35(%rip),%rax
mov    (%rax),%edi
lea    0xd98(%rip),%rsi
call   1050 <fprintf@plt>
jmp    11b9 <main+0x29>
mov    0x8(%rbx),%rdi
lea    0xdab(%rip),%rsi
call   10a0 <fopen@plt>
test   %rax,%rax
je     1319 <main+0x189>
mov    %rax,%r12
mov    %rax,%rdi
mov    %r14,%rsi
mov    %r15,%rdx
mov    %r13d,%ecx
call   1080 <copy_bootcode_into_image@plt>
mov    %rax,%rbx
mov    %r14,%rdi
call   1030 <fclose@plt>
mov    %r12,%rdi
call   1030 <fclose@plt>
test   %rbx,%rbx
je     1326 <main+0x196>
mov    0x2cda(%rip),%rax
mov    (%rax),%edi
lea    0xd67(%rip),%rsi
call   1050 <fprintf@plt>
jmp    11c1 <main+0x31>
mov    %r14,%rdi
call   1030 <fclose@plt>
jmp    11b9 <main+0x29>
xor    %eax,%eax
jmp    11ca <main+0x3a>

LLVM IR (-O0):
%struct.stat = type { i64, i32 }
@EXIT_FAILURE = global i32 0
@.str = [3 x i8] c"r+\00"
@stderr = global i32 0
@.str.1 = [27 x i8] c"Unable to detect FAT type\0A\00"
@.str.2 = [46 x i8] c"Impossible to fit bootloader code into image\0A\00"
@.str.3 = [40 x i8] c"Impossible bootable geometry for image\0A\00"
@.str.4 = [2 x i8] c"r\00"
@.str.5 = [55 x i8] c"Error while copying. Possible corruption of imagefile\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca %struct.stat
%7 = alloca %struct.stat
%8 = alloca i32*
%9 = alloca i32*
%10 = alloca i32
%11 = alloca i64
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%12 = load i32, i32* %4
%13 = icmp ne i32 %12, 3
br i1 %13, label %14, label %20
14: ; preds = %2
%15 = load i8**, i8*** %5
%16 = getelementptr inbounds i8*, i8** %15, i64 0
%17 = load i8*, i8** %16
%18 = call i32 @help(i8* %17)
%19 = load i32, i32* @EXIT_FAILURE
store i32 %19, i32* %3
br label %153
20: ; preds = %2
%21 = load i8**, i8*** %5
%22 = getelementptr inbounds i8*, i8** %21, i64 1
%23 = load i8*, i8** %22
%24 = call i64 @stat(i8* %23, %struct.stat* %6)
%25 = icmp ne i64 %24, 0
br i1 %25, label %31, label %26
26: ; preds = %20
%27 = getelementptr inbounds %struct.stat, %struct.stat* %6, i32 0, i32 1
%28 = load i32, i32* %27
%29 = call i32 @S_ISREG(i32 %28)
%30 = icmp ne i32 %29, 0
br i1 %30, label %37, label %31
31: ; preds = %26, %20
%32 = load i8**, i8*** %5
%33 = getelementptr inbounds i8*, i8** %32, i64 0
%34 = load i8*, i8** %33
%35 = call i32 @help(i8* %34)
%36 = load i32, i32* @EXIT_FAILURE
store i32 %36, i32* %3
br label %153
37: ; preds = %26
%38 = load i8**, i8*** %5
%39 = getelementptr inbounds i8*, i8** %38, i64 2
%40 = load i8*, i8** %39
%41 = call i64 @stat(i8* %40, %struct.stat* %7)
%42 = icmp ne i64 %41, 0
br i1 %42, label %48, label %43
43: ; preds = %37
%44 = getelementptr inbounds %struct.stat, %struct.stat* %7, i32 0, i32 1
%45 = load i32, i32* %44
%46 = call i32 @S_ISREG(i32 %45)
%47 = icmp ne i32 %46, 0
br i1 %47, label %54, label %48
48: ; preds = %43, %37
%49 = load i8**, i8*** %5
%50 = getelementptr inbounds i8*, i8** %49, i64 0
%51 = load i8*, i8** %50
%52 = call i32 @help(i8* %51)
%53 = load i32, i32* @EXIT_FAILURE
store i32 %53, i32* %3
br label %153
54: ; preds = %43
%55 = load i8**, i8*** %5
%56 = getelementptr inbounds i8*, i8** %55, i64 2
%57 = load i8*, i8** %56
%58 = call i32* @fopen(i8* %57, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
store i32* %58, i32** %8
%59 = load i32*, i32** %8
%60 = icmp ne i32* %59, null
br i1 %60, label %67, label %61
61: ; preds = %54
%62 = load i8**, i8*** %5
%63 = getelementptr inbounds i8*, i8** %62, i64 0
%64 = load i8*, i8** %63
%65 = call i32 @help(i8* %64)
%66 = load i32, i32* @EXIT_FAILURE
store i32 %66, i32* %3
br label %153
67: ; preds = %54
%68 = load i32*, i32** %8
%69 = call i32 @detect_fat_size(i32* %68)
store i32 %69, i32* %10
%70 = load i32, i32* %10
%71 = icmp slt i32 %70, 0
br i1 %71, label %72, label %82
72: ; preds = %67
%73 = load i32*, i32** %8
%74 = call i32 @fclose(i32* %73)
%75 = load i32, i32* @stderr
%76 = call i32 @fprintf(i32 %75, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0))
%77 = load i8**, i8*** %5
%78 = getelementptr inbounds i8*, i8** %77, i64 0
%79 = load i8*, i8** %78
%80 = call i32 @help(i8* %79)
%81 = load i32, i32* @EXIT_FAILURE
store i32 %81, i32* %3
br label %153
82: ; preds = %67
%83 = getelementptr inbounds %struct.stat, %struct.stat* %6, i32 0, i32 0
%84 = load i64, i64* %83
store i64 %84, i64* %11
%85 = load i64, i64* %11
%86 = load i32, i32* %10
%87 = sub nsw i32 512, %86
%88 = sub nsw i32 %87, 2
%89 = sext i32 %88 to i64
%90 = load i32, i32* %10
%91 = call i64 @nop_slide_size(i32 %90)
%92 = sub i64 %89, %91
%93 = icmp ugt i64 %85, %92
br i1 %93, label %94, label %104
94: ; preds = %82
%95 = load i32*, i32** %8
%96 = call i32 @fclose(i32* %95)
%97 = load i32, i32* @stderr
%98 = call i32 @fprintf(i32 %97, i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.2, i64 0, i64 0))
%99 = load i8**, i8*** %5
%100 = getelementptr inbounds i8*, i8** %99, i64 0
%101 = load i8*, i8** %100
%102 = call i32 @help(i8* %101)
%103 = load i32, i32* @EXIT_FAILURE
store i32 %103, i32* %3
br label %153
104: ; preds = %82
%105 = getelementptr inbounds %struct.stat, %struct.stat* %7, i32 0, i32 0
%106 = load i64, i64* %105
%107 = icmp ult i64 %106, 512
br i1 %107, label %108, label %118
108: ; preds = %104
%109 = load i32*, i32** %8
%110 = call i32 @fclose(i32* %109)
%111 = load i32, i32* @stderr
%112 = call i32 @fprintf(i32 %111, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.3, i64 0, i64 0))
%113 = load i8**, i8*** %5
%114 = getelementptr inbounds i8*, i8** %113, i64 0
%115 = load i8*, i8** %114
%116 = call i32 @help(i8* %115)
%117 = load i32, i32* @EXIT_FAILURE
store i32 %117, i32* %3
br label %153
118: ; preds = %104
%119 = load i8**, i8*** %5
%120 = getelementptr inbounds i8*, i8** %119, i64 1
%121 = load i8*, i8** %120
%122 = call i32* @fopen(i8* %121, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
store i32* %122, i32** %9
%123 = load i32*, i32** %9
%124 = icmp ne i32* %123, null
br i1 %124, label %133, label %125
125: ; preds = %118
%126 = load i32*, i32** %8
%127 = call i32 @fclose(i32* %126)
%128 = load i8**, i8*** %5
%129 = getelementptr inbounds i8*, i8** %128, i64 0
%130 = load i8*, i8** %129
%131 = call i32 @help(i8* %130)
%132 = load i32, i32* @EXIT_FAILURE
store i32 %132, i32* %3
br label %153
133: ; preds = %118
%134 = load i32*, i32** %9
%135 = load i32*, i32** %8
%136 = load i64, i64* %11
%137 = load i32, i32* %10
%138 = call i64 @copy_bootcode_into_image(i32* %134, i32* %135, i64 %136, i32 %137)
%139 = icmp ne i64 %138, 0
br i1 %139, label %140, label %148
140: ; preds = %133
%141 = load i32*, i32** %8
%142 = call i32 @fclose(i32* %141)
%143 = load i32*, i32** %9
%144 = call i32 @fclose(i32* %143)
%145 = load i32, i32* @stderr
%146 = call i32 @fprintf(i32 %145, i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str.5, i64 0, i64 0))
%147 = load i32, i32* @EXIT_FAILURE
store i32 %147, i32* %3
br label %153
148: ; preds = %133
%149 = load i32*, i32** %8
%150 = call i32 @fclose(i32* %149)
%151 = load i32*, i32** %9
%152 = call i32 @fclose(i32* %151)
store i32 0, i32* %3
br label %153
153: ; preds = %148, %140, %125, %108, %94, %72, %61, %48, %31, %14
%154 = load i32, i32* %3
ret i32 %154
}

LLVM IR (-O2):
%struct.stat = type { i64, i32 }
@EXIT_FAILURE = global i32 0
@.str = [3 x i8] c"r+\00"
@stderr = global i32 0
@.str.1 = [27 x i8] c"Unable to detect FAT type\0A\00"
@.str.2 = [46 x i8] c"Impossible to fit bootloader code into image\0A\00"
@.str.3 = [40 x i8] c"Impossible bootable geometry for image\0A\00"
@.str.4 = [2 x i8] c"r\00"
@.str.5 = [55 x i8] c"Error while copying. Possible corruption of imagefile\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca %struct.stat
%4 = alloca %struct.stat
%5 = bitcast %struct.stat* %3 to i8*
%6 = bitcast %struct.stat* %4 to i8*
%7 = icmp eq i32 %0, 3
br i1 %7, label %12, label %8
8: ; preds = %2
%9 = load i8*, i8** %1
%10 = tail call i32 @help(i8* %9)
%11 = load i32, i32* @EXIT_FAILURE
br label %102
12: ; preds = %2
%13 = getelementptr inbounds i8*, i8** %1, i64 1
%14 = load i8*, i8** %13
%15 = call i64 @stat(i8* %14, %struct.stat* %3)
%16 = icmp eq i64 %15, 0
br i1 %16, label %17, label %22
17: ; preds = %12
%18 = getelementptr inbounds %struct.stat, %struct.stat* %3, i64 0, i32 1
%19 = load i32, i32* %18
%20 = call i32 @S_ISREG(i32 %19)
%21 = icmp eq i32 %20, 0
br i1 %21, label %22, label %26
22: ; preds = %17, %12
%23 = load i8*, i8** %1
%24 = call i32 @help(i8* %23)
%25 = load i32, i32* @EXIT_FAILURE
br label %102
26: ; preds = %17
%27 = getelementptr inbounds i8*, i8** %1, i64 2
%28 = load i8*, i8** %27
%29 = call i64 @stat(i8* %28, %struct.stat* %4)
%30 = icmp eq i64 %29, 0
br i1 %30, label %31, label %36
31: ; preds = %26
%32 = getelementptr inbounds %struct.stat, %struct.stat* %4, i64 0, i32 1
%33 = load i32, i32* %32
%34 = call i32 @S_ISREG(i32 %33)
%35 = icmp eq i32 %34, 0
br i1 %35, label %36, label %40
36: ; preds = %31, %26
%37 = load i8*, i8** %1
%38 = call i32 @help(i8* %37)
%39 = load i32, i32* @EXIT_FAILURE
br label %102
40: ; preds = %31
%41 = load i8*, i8** %27
%42 = call i32* @fopen(i8* %41, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%43 = icmp eq i32* %42, null
br i1 %43, label %44, label %48
44: ; preds = %40
%45 = load i8*, i8** %1
%46 = call i32 @help(i8* %45)
%47 = load i32, i32* @EXIT_FAILURE
br label %102
48: ; preds = %40
%49 = call i32 @detect_fat_size(i32* %42)
%50 = icmp slt i32 %49, 0
br i1 %50, label %51, label %58
51: ; preds = %48
%52 = call i32 @fclose(i32* %42)
%53 = load i32, i32* @stderr
%54 = call i32 @fprintf(i32 %53, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0))
%55 = load i8*, i8** %1
%56 = call i32 @help(i8* %55)
%57 = load i32, i32* @EXIT_FAILURE
br label %102
58: ; preds = %48
%59 = getelementptr inbounds %struct.stat, %struct.stat* %3, i64 0, i32 0
%60 = load i64, i64* %59
%61 = sub nsw i32 510, %49
%62 = sext i32 %61 to i64
%63 = call i64 @nop_slide_size(i32 %49)
%64 = sub i64 %62, %63
%65 = icmp ugt i64 %60, %64
br i1 %65, label %66, label %73
66: ; preds = %58
%67 = call i32 @fclose(i32* %42)
%68 = load i32, i32* @stderr
%69 = call i32 @fprintf(i32 %68, i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.2, i64 0, i64 0))
%70 = load i8*, i8** %1
%71 = call i32 @help(i8* %70)
%72 = load i32, i32* @EXIT_FAILURE
br label %102
73: ; preds = %58
%74 = getelementptr inbounds %struct.stat, %struct.stat* %4, i64 0, i32 0
%75 = load i64, i64* %74
%76 = icmp ult i64 %75, 512
br i1 %76, label %77, label %84
77: ; preds = %73
%78 = call i32 @fclose(i32* %42)
%79 = load i32, i32* @stderr
%80 = call i32 @fprintf(i32 %79, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.3, i64 0, i64 0))
%81 = load i8*, i8** %1
%82 = call i32 @help(i8* %81)
%83 = load i32, i32* @EXIT_FAILURE
br label %102
84: ; preds = %73
%85 = load i8*, i8** %13
%86 = call i32* @fopen(i8* %85, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%87 = icmp eq i32* %86, null
br i1 %87, label %88, label %93
88: ; preds = %84
%89 = call i32 @fclose(i32* %42)
%90 = load i8*, i8** %1
%91 = call i32 @help(i8* %90)
%92 = load i32, i32* @EXIT_FAILURE
br label %102
93: ; preds = %84
%94 = call i64 @copy_bootcode_into_image(i32* %86, i32* %42, i64 %60, i32 %49)
%95 = icmp eq i64 %94, 0
%96 = call i32 @fclose(i32* %42)
%97 = call i32 @fclose(i32* %86)
br i1 %95, label %102, label %98
98: ; preds = %93
%99 = load i32, i32* @stderr
%100 = call i32 @fprintf(i32 %99, i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str.5, i64 0, i64 0))
%101 = load i32, i32* @EXIT_FAILURE
br label %102
102: ; preds = %93, %98, %88, %77, %66, %51, %44, %36, %22, %8
%103 = phi i32 [ %11, %8 ], [ %25, %22 ], [ %39, %36 ], [ %57, %51 ], [ %72, %66 ], [ %83, %77 ], [ %101, %98 ], [ %92, %88 ], [ %47, %44 ], [ 0, %93 ]
ret i32 %103
}