#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 */
unsigned long bswap_ul(unsigned long);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ fopen_s(int /*<<< orphan*/ **, char *, char *);
int /*<<< orphan*/ free(unsigned char *);
int /*<<< orphan*/ fwrite(unsigned char *, int, unsigned long,
                          int /*<<< orphan*/ *);
int /*<<< orphan*/ loader_read(char *, unsigned char **, unsigned long *);
int /*<<< orphan*/ memcpy(void *, void *, unsigned long);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ splash_read(char *, unsigned char **, unsigned long *);
int /*<<< orphan*/ strcmp(char *, char *);
int /*<<< orphan*/ zero_bin_read(char *, unsigned char **, unsigned long *);
int main(int argc, char *argv[]) {
  int ret = 1;
  char *file_loader;
  char *file_splash;
  char *file_zero;
  char *file_out;
  unsigned char *buff_out = NULL;
  unsigned char *buff_zero = NULL;
  unsigned char *buff_splash = NULL;
  unsigned long len_out = 0;
  unsigned long len_zero = 0;
  unsigned long len_splash = 0;
  unsigned long *ptr;
  unsigned long ofs, len;
  FILE *fp = NULL;
  printf("--- mksplash v0.1 by cafe-alpha. ---\n");
  if (argc <= 1) {
    printf(" Type %s -h for help.\n", argv[0]);
    return 0;
  }
  if (argc >= 2) {
    if ((!strcmp(argv[1], "-h")) || (!strcmp(argv[1], "-help")) ||
        (!strcmp(argv[1], "-?"))) {
      printf(
          " Note: uses LibLZF: http://oldhome.schmorp.de/marc/liblzf.html\n");
      printf(" Usage : <loader.bin> <splash.bmp> <0.bin> <out.bin>\n");
      printf(
          "         -> Pack loader.bin, splash.bmp, 0.bin in out.bin file.\n");
      printf("            After startup, splash.bmp is displayed\n");
      printf("            and 0.bin is loaded after a key is pressed.\n");
      return 0;
    }
  }
  if (argc != 5)
    return 1;
  file_loader = argv[1];
  file_splash = argv[2];
  file_zero = argv[3];
  file_out = argv[4];
  loader_read(file_loader, &buff_out, &len_out);
  if ((buff_out == NULL) || (len_out == 0))
    goto end;
  splash_read(file_splash, &buff_splash, &len_splash);
  if ((buff_splash == NULL) || (len_splash == 0))
    goto end;
  zero_bin_read(file_zero, &buff_zero, &len_zero);
  if ((buff_zero == NULL) || (len_zero == 0))
    goto end;
  len_out = (8 * 1024) + (16) + len_zero + len_splash;
  if (len_out > (1024 * 1024 - 0x4000)) {
    printf("Error : total size too big (required %d bytes, max %d bytes) !\n",
           len_out, (1024 * 1024 - 0x4000));
    goto end;
  }
  ofs = (8 * 1024) + (16);
  len = len_zero;
  ptr = (unsigned long *)(buff_out + ((8 * 1024) + 0));
  *ptr = bswap_ul(0x06004000 + ofs);
  ptr = (unsigned long *)(buff_out + ((8 * 1024) + 4));
  *ptr = bswap_ul(len);
  memcpy((void *)(buff_out + ofs), (void *)buff_zero, len);
  ofs = (8 * 1024) + (16) + len_zero;
  len = len_splash;
  ptr = (unsigned long *)(buff_out + ((8 * 1024) + 8));
  *ptr = bswap_ul(0x06004000 + ofs);
  ptr = (unsigned long *)(buff_out + ((8 * 1024) + 12));
  *ptr = bswap_ul(len);
  memcpy((void *)(buff_out + ofs), (void *)buff_splash, len);
  fopen_s(&fp, file_out, "wb");
  if (fp) {
    fwrite(buff_out, 1, len_out, fp);
    fclose(fp);
    fp = NULL;
    printf("Wrote %d bytes (%d KB) to disk.\n", len_out, len_out >> 10);
  } else {
    printf("Error : could not write to file (%s) !\n", file_out);
    goto end;
  }
  ret = 0;
end:
  if (buff_splash) {
    free(buff_splash);
    buff_splash = NULL;
  }
  if (buff_zero) {
    free(buff_zero);
    buff_zero = NULL;
  }
  if (buff_out) {
    free(buff_out);
    buff_out = NULL;
  }
  return ret;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x1,-0x14(%rbp)
movq   $0x0,-0x40(%rbp)
movq   $0x0,-0x48(%rbp)
movq   $0x0,-0x50(%rbp)
movq   $0x0,-0x58(%rbp)
movq   $0x0,-0x60(%rbp)
movq   $0x0,-0x68(%rbp)
movq   $0x0,-0x88(%rbp)
lea    0xdee(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
cmpl   $0x1,-0x8(%rbp)
jg     1244 <main+0x94>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xdf5(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    15d0 <main+0x420>
cmpl   $0x2,-0x8(%rbp)
jl     12fc <main+0x14c>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xde0(%rip),%rsi
call   1080 <strcmp@plt>
cmp    $0x0,%eax
je     12a5 <main+0xf5>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xdc6(%rip),%rsi
call   1080 <strcmp@plt>
cmp    $0x0,%eax
je     12a5 <main+0xf5>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xdaf(%rip),%rsi
call   1080 <strcmp@plt>
cmp    $0x0,%eax
jne    12f7 <main+0x147>
lea    0xd9d(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    0xdcf(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    0xdf7(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    0xe2a(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    0xe50(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    15d0 <main+0x420>
jmp    12fc <main+0x14c>
cmpl   $0x5,-0x8(%rbp)
je     1312 <main+0x162>
movl   $0x1,-0x4(%rbp)
jmp    15d0 <main+0x420>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rax
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rax
mov    %rax,-0x30(%rbp)
mov    -0x10(%rbp),%rax
mov    0x20(%rax),%rax
mov    %rax,-0x38(%rbp)
mov    -0x20(%rbp),%rdi
lea    -0x40(%rbp),%rsi
lea    -0x58(%rbp),%rdx
call   10a0 <loader_read@plt>
cmpq   $0x0,-0x40(%rbp)
je     1369 <main+0x1b9>
cmpq   $0x0,-0x58(%rbp)
jne    136e <main+0x1be>
jmp    1576 <main+0x3c6>
mov    -0x28(%rbp),%rdi
lea    -0x50(%rbp),%rsi
lea    -0x68(%rbp),%rdx
call   10b0 <splash_read@plt>
cmpq   $0x0,-0x50(%rbp)
je     1395 <main+0x1e5>
cmpq   $0x0,-0x68(%rbp)
jne    139a <main+0x1ea>
jmp    1576 <main+0x3c6>
mov    -0x30(%rbp),%rdi
lea    -0x48(%rbp),%rsi
lea    -0x60(%rbp),%rdx
call   1070 <zero_bin_read@plt>
cmpq   $0x0,-0x48(%rbp)
je     13c1 <main+0x211>
cmpq   $0x0,-0x60(%rbp)
jne    13c6 <main+0x216>
jmp    1576 <main+0x3c6>
mov    -0x60(%rbp),%rax
add    $0x2010,%rax
add    -0x68(%rbp),%rax
mov    %rax,-0x58(%rbp)
cmpq   $0xfc000,-0x58(%rbp)
jbe    1402 <main+0x252>
mov    -0x58(%rbp),%rsi
lea    0xd7c(%rip),%rdi
mov    $0xfc000,%edx
mov    $0x0,%al
call   1060 <printf@plt>
jmp    1576 <main+0x3c6>
movq   $0x2010,-0x78(%rbp)
mov    -0x60(%rbp),%rax
mov    %rax,-0x80(%rbp)
mov    -0x40(%rbp),%rax
add    $0x2000,%rax
mov    %rax,-0x70(%rbp)
mov    -0x78(%rbp),%rdi
add    $0x6004000,%rdi
call   10d0 <bswap_ul@plt>
mov    %rax,%rcx
mov    -0x70(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x40(%rbp),%rax
add    $0x2004,%rax
mov    %rax,-0x70(%rbp)
mov    -0x80(%rbp),%rdi
call   10d0 <bswap_ul@plt>
mov    %rax,%rcx
mov    -0x70(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x40(%rbp),%rdi
add    -0x78(%rbp),%rdi
mov    -0x48(%rbp),%rsi
mov    -0x80(%rbp),%rdx
call   1090 <memcpy@plt>
mov    -0x60(%rbp),%rax
add    $0x2010,%rax
mov    %rax,-0x78(%rbp)
mov    -0x68(%rbp),%rax
mov    %rax,-0x80(%rbp)
mov    -0x40(%rbp),%rax
add    $0x2008,%rax
mov    %rax,-0x70(%rbp)
mov    -0x78(%rbp),%rdi
add    $0x6004000,%rdi
call   10d0 <bswap_ul@plt>
mov    %rax,%rcx
mov    -0x70(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x40(%rbp),%rax
add    $0x200c,%rax
mov    %rax,-0x70(%rbp)
mov    -0x80(%rbp),%rdi
call   10d0 <bswap_ul@plt>
mov    %rax,%rcx
mov    -0x70(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x40(%rbp),%rdi
add    -0x78(%rbp),%rdi
mov    -0x50(%rbp),%rsi
mov    -0x80(%rbp),%rdx
call   1090 <memcpy@plt>
mov    -0x38(%rbp),%rsi
lea    -0x88(%rbp),%rdi
lea    0xcb7(%rip),%rdx
call   1040 <fopen_s@plt>
cmpq   $0x0,-0x88(%rbp)
je     1558 <main+0x3a8>
mov    -0x40(%rbp),%rdi
mov    -0x58(%rbp),%rdx
mov    -0x88(%rbp),%rcx
mov    $0x1,%esi
call   10c0 <fwrite@plt>
mov    -0x88(%rbp),%rdi
call   1050 <fclose@plt>
movq   $0x0,-0x88(%rbp)
mov    -0x58(%rbp),%rsi
mov    -0x58(%rbp),%rdx
shr    $0xa,%rdx
lea    0xc64(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    156f <main+0x3bf>
mov    -0x38(%rbp),%rsi
lea    0xc6e(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    1576 <main+0x3c6>
movl   $0x0,-0x14(%rbp)
cmpq   $0x0,-0x50(%rbp)
je     1592 <main+0x3e2>
mov    -0x50(%rbp),%rdi
call   1030 <free@plt>
movq   $0x0,-0x50(%rbp)
cmpq   $0x0,-0x48(%rbp)
je     15ae <main+0x3fe>
mov    -0x48(%rbp),%rdi
call   1030 <free@plt>
movq   $0x0,-0x48(%rbp)
cmpq   $0x0,-0x40(%rbp)
je     15ca <main+0x41a>
mov    -0x40(%rbp),%rdi
call   1030 <free@plt>
movq   $0x0,-0x40(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
mov    %rsi,%rbx
mov    %edi,%ebp
movq   $0x0,(%rsp)
movq   $0x0,0x18(%rsp)
movq   $0x0,0x10(%rsp)
movq   $0x0,0x8(%rsp)
movq   $0x0,0x30(%rsp)
movq   $0x0,0x28(%rsp)
movq   $0x0,0x20(%rsp)
lea    0xe97(%rip),%rdi
call   1050 <puts@plt>
cmp    $0x1,%ebp
jg     123b <main+0x7b>
mov    (%rbx),%rsi
lea    0xdd4(%rip),%rdi
xor    %r15d,%r15d
xor    %eax,%eax
call   1070 <printf@plt>
jmp    13a5 <main+0x1e5>
mov    0x8(%rbx),%r12
lea    0xdd1(%rip),%rsi
mov    %r12,%rdi
call   1090 <strcmp@plt>
test   %eax,%eax
je     1366 <main+0x1a6>
lea    0xdbd(%rip),%rsi
mov    %r12,%rdi
call   1090 <strcmp@plt>
test   %eax,%eax
je     1366 <main+0x1a6>
lea    0xdac(%rip),%rsi
mov    %r12,%rdi
call   1090 <strcmp@plt>
test   %eax,%eax
je     1366 <main+0x1a6>
mov    $0x1,%r15d
cmp    $0x5,%ebp
jne    13a5 <main+0x1e5>
mov    0x10(%rbx),%rbp
mov    0x18(%rbx),%r13
mov    0x20(%rbx),%r14
mov    %rsp,%rsi
lea    0x8(%rsp),%rdx
mov    %r12,%rdi
call   10b0 <loader_read@plt>
cmpq   $0x0,(%rsp)
mov    $0x1,%r15d
je     14ba <main+0x2fa>
cmpq   $0x0,0x8(%rsp)
je     14ba <main+0x2fa>
lea    0x10(%rsp),%rsi
lea    0x28(%rsp),%rdx
mov    %rbp,%rdi
call   10c0 <splash_read@plt>
mov    0x10(%rsp),%rdi
mov    $0x1,%r15d
test   %rdi,%rdi
je     14bf <main+0x2ff>
cmpq   $0x0,0x28(%rsp)
je     14bf <main+0x2ff>
lea    0x18(%rsp),%rsi
lea    0x30(%rsp),%rdx
mov    %r13,%rdi
call   1080 <zero_bin_read@plt>
cmpq   $0x0,0x18(%rsp)
mov    $0x1,%r15d
je     14ba <main+0x2fa>
mov    0x30(%rsp),%rbx
test   %rbx,%rbx
je     14ba <main+0x2fa>
mov    0x28(%rsp),%rax
lea    (%rbx,%rax,1),%rsi
add    $0x2010,%rsi
mov    %rsi,0x8(%rsp)
cmp    $0xfc001,%rsi
jb     13b7 <main+0x1f7>
lea    0xcce(%rip),%rdi
mov    $0xfc000,%edx
xor    %eax,%eax
call   1070 <printf@plt>
jmp    14ba <main+0x2fa>
lea    0xd67(%rip),%rdi
call   1050 <puts@plt>
lea    0xd9a(%rip),%rdi
call   1050 <puts@plt>
lea    0xdc3(%rip),%rdi
call   1050 <puts@plt>
lea    0xdf7(%rip),%rdi
call   1050 <puts@plt>
lea    0xe1e(%rip),%rdi
call   1050 <puts@plt>
xor    %r15d,%r15d
mov    %r15d,%eax
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    (%rsp),%rbp
mov    $0x6006010,%edi
call   10e0 <bswap_ul@plt>
mov    %rax,0x2000(%rbp)
mov    (%rsp),%rbp
mov    %rbx,%rdi
call   10e0 <bswap_ul@plt>
mov    %rax,0x2004(%rbp)
mov    $0x2010,%edi
add    (%rsp),%rdi
mov    0x18(%rsp),%rsi
mov    %rbx,%rdx
call   10a0 <memcpy@plt>
mov    0x30(%rsp),%rbp
mov    0x28(%rsp),%r13
mov    (%rsp),%r12
lea    0x6006010(%rbp),%rdi
call   10e0 <bswap_ul@plt>
mov    %rax,0x2008(%r12)
mov    (%rsp),%rbx
mov    %r13,%rdi
call   10e0 <bswap_ul@plt>
mov    %rax,0x200c(%rbx)
mov    (%rsp),%rax
lea    (%rax,%rbp,1),%rdi
add    $0x2010,%rdi
mov    0x10(%rsp),%rsi
mov    %r13,%rdx
call   10a0 <memcpy@plt>
lea    0xc16(%rip),%rdx
lea    0x20(%rsp),%rdi
mov    %r14,%rsi
call   1040 <fopen_s@plt>
mov    0x20(%rsp),%rcx
test   %rcx,%rcx
je     14a9 <main+0x2e9>
mov    (%rsp),%rdi
mov    0x8(%rsp),%rdx
mov    $0x1,%esi
call   10d0 <fwrite@plt>
mov    0x20(%rsp),%rdi
call   1060 <fclose@plt>
movq   $0x0,0x20(%rsp)
mov    0x8(%rsp),%rsi
mov    %rsi,%rdx
shr    $0xa,%rdx
lea    0xbc9(%rip),%rdi
xor    %r15d,%r15d
xor    %eax,%eax
call   1070 <printf@plt>
jmp    14ba <main+0x2fa>
lea    0xbd7(%rip),%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1070 <printf@plt>
mov    0x10(%rsp),%rdi
test   %rdi,%rdi
je     14d2 <main+0x312>
call   1030 <free@plt>
movq   $0x0,0x10(%rsp)
mov    0x18(%rsp),%rdi
test   %rdi,%rdi
je     14ea <main+0x32a>
call   1030 <free@plt>
movq   $0x0,0x18(%rsp)
mov    (%rsp),%rdi
test   %rdi,%rdi
je     13a5 <main+0x1e5>
call   1030 <free@plt>
movq   $0x0,(%rsp)
jmp    13a5 <main+0x1e5>

LLVM IR (-O0):
@.str = [38 x i8] c"--- mksplash v0.1 by cafe-alpha. ---\0A\00"
@.str.1 = [23 x i8] c" Type %s -h for help.\0A\00"
@.str.2 = [3 x i8] c"-h\00"
@.str.3 = [6 x i8] c"-help\00"
@.str.4 = [3 x i8] c"-?\00"
@.str.5 = [64 x i8] c" Note: uses LibLZF: http://oldhome.schmorp.de/marc/liblzf.html\0A\00"
@.str.6 = [54 x i8] c" Usage : <loader.bin> <splash.bmp> <0.bin> <out.bin>\0A\00"
@.str.7 = [65 x i8] c" -> Pack loader.bin, splash.bmp, 0.bin in out.bin file.\0A\00"
@.str.8 = [52 x i8] c" After startup, splash.bmp is displayed\0A\00"
@.str.9 = [57 x i8] c" and 0.bin is loaded after a key is pressed.\0A\00"
@.str.10 = [64 x i8] c"Error : total size too big (required %d bytes, max %d bytes) !\0A\00"
@.str.11 = [3 x i8] c"wb\00"
@.str.12 = [33 x i8] c"Wrote %d bytes (%d KB) to disk.\0A\00"
@.str.13 = [40 x i8] c"Error : could not write to file (%s) !\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i8*
%11 = alloca i8*
%12 = alloca i8*
%13 = alloca i8*
%14 = alloca i64
%15 = alloca i64
%16 = alloca i64
%17 = alloca i64*
%18 = alloca i64
%19 = alloca i64
%20 = alloca i32*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 1, i32* %6
store i8* null, i8** %11
store i8* null, i8** %12
store i8* null, i8** %13
store i64 0, i64* %14
store i64 0, i64* %15
store i64 0, i64* %16
store i32* null, i32** %20
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0))
%22 = load i32, i32* %4
%23 = icmp sle i32 %22, 1
br i1 %23, label %24, label %29
24: ; preds = %2
%25 = load i8**, i8*** %5
%26 = getelementptr inbounds i8*, i8** %25, i64 0
%27 = load i8*, i8** %26
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i8* %27)
store i32 0, i32* %3
br label %192
29: ; preds = %2
%30 = load i32, i32* %4
%31 = icmp sge i32 %30, 2
br i1 %31, label %32, label %57
32: ; preds = %29
%33 = load i8**, i8*** %5
%34 = getelementptr inbounds i8*, i8** %33, i64 1
%35 = load i8*, i8** %34
%36 = call i32 @strcmp(i8* %35, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%37 = icmp ne i32 %36, 0
br i1 %37, label %38, label %50
38: ; preds = %32
%39 = load i8**, i8*** %5
%40 = getelementptr inbounds i8*, i8** %39, i64 1
%41 = load i8*, i8** %40
%42 = call i32 @strcmp(i8* %41, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
%43 = icmp ne i32 %42, 0
br i1 %43, label %44, label %50
44: ; preds = %38
%45 = load i8**, i8*** %5
%46 = getelementptr inbounds i8*, i8** %45, i64 1
%47 = load i8*, i8** %46
%48 = call i32 @strcmp(i8* %47, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
%49 = icmp ne i32 %48, 0
br i1 %49, label %56, label %50
50: ; preds = %44, %38, %32
%51 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([64 x i8], [64 x i8]* @.str.5, i64 0, i64 0))
%52 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.6, i64 0, i64 0))
%53 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([65 x i8], [65 x i8]* @.str.7, i64 0, i64 0))
%54 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.8, i64 0, i64 0))
%55 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str.9, i64 0, i64 0))
store i32 0, i32* %3
br label %192
56: ; preds = %44
br label %57
57: ; preds = %56, %29
%58 = load i32, i32* %4
%59 = icmp ne i32 %58, 5
br i1 %59, label %60, label %61
60: ; preds = %57
store i32 1, i32* %3
br label %192
61: ; preds = %57
%62 = load i8**, i8*** %5
%63 = getelementptr inbounds i8*, i8** %62, i64 1
%64 = load i8*, i8** %63
store i8* %64, i8** %7
%65 = load i8**, i8*** %5
%66 = getelementptr inbounds i8*, i8** %65, i64 2
%67 = load i8*, i8** %66
store i8* %67, i8** %8
%68 = load i8**, i8*** %5
%69 = getelementptr inbounds i8*, i8** %68, i64 3
%70 = load i8*, i8** %69
store i8* %70, i8** %9
%71 = load i8**, i8*** %5
%72 = getelementptr inbounds i8*, i8** %71, i64 4
%73 = load i8*, i8** %72
store i8* %73, i8** %10
%74 = load i8*, i8** %7
%75 = call i32 @loader_read(i8* %74, i8** %11, i64* %14)
%76 = load i8*, i8** %11
%77 = icmp eq i8* %76, null
br i1 %77, label %81, label %78
78: ; preds = %61
%79 = load i64, i64* %14
%80 = icmp eq i64 %79, 0
br i1 %80, label %81, label %82
81: ; preds = %78, %61
br label %172
82: ; preds = %78
%83 = load i8*, i8** %8
%84 = call i32 @splash_read(i8* %83, i8** %13, i64* %16)
%85 = load i8*, i8** %13
%86 = icmp eq i8* %85, null
br i1 %86, label %90, label %87
87: ; preds = %82
%88 = load i64, i64* %16
%89 = icmp eq i64 %88, 0
br i1 %89, label %90, label %91
90: ; preds = %87, %82
br label %172
91: ; preds = %87
%92 = load i8*, i8** %9
%93 = call i32 @zero_bin_read(i8* %92, i8** %12, i64* %15)
%94 = load i8*, i8** %12
%95 = icmp eq i8* %94, null
br i1 %95, label %99, label %96
96: ; preds = %91
%97 = load i64, i64* %15
%98 = icmp eq i64 %97, 0
br i1 %98, label %99, label %100
99: ; preds = %96, %91
br label %172
100: ; preds = %96
%101 = load i64, i64* %15
%102 = add i64 8208, %101
%103 = load i64, i64* %16
%104 = add i64 %102, %103
store i64 %104, i64* %14
%105 = load i64, i64* %14
%106 = icmp ugt i64 %105, 1032192
br i1 %106, label %107, label %110
107: ; preds = %100
%108 = load i64, i64* %14
%109 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([64 x i8], [64 x i8]* @.str.10, i64 0, i64 0), i64 %108, i32 1032192)
br label %172
110: ; preds = %100
store i64 8208, i64* %18
%111 = load i64, i64* %15
store i64 %111, i64* %19
%112 = load i8*, i8** %11
%113 = getelementptr inbounds i8, i8* %112, i64 8192
%114 = bitcast i8* %113 to i64*
store i64* %114, i64** %17
%115 = load i64, i64* %18
%116 = add i64 100679680, %115
%117 = call i64 @bswap_ul(i64 %116)
%118 = load i64*, i64** %17
store i64 %117, i64* %118
%119 = load i8*, i8** %11
%120 = getelementptr inbounds i8, i8* %119, i64 8196
%121 = bitcast i8* %120 to i64*
store i64* %121, i64** %17
%122 = load i64, i64* %19
%123 = call i64 @bswap_ul(i64 %122)
%124 = load i64*, i64** %17
store i64 %123, i64* %124
%125 = load i8*, i8** %11
%126 = load i64, i64* %18
%127 = getelementptr inbounds i8, i8* %125, i64 %126
%128 = load i8*, i8** %12
%129 = load i64, i64* %19
%130 = call i32 @memcpy(i8* %127, i8* %128, i64 %129)
%131 = load i64, i64* %15
%132 = add i64 8208, %131
store i64 %132, i64* %18
%133 = load i64, i64* %16
store i64 %133, i64* %19
%134 = load i8*, i8** %11
%135 = getelementptr inbounds i8, i8* %134, i64 8200
%136 = bitcast i8* %135 to i64*
store i64* %136, i64** %17
%137 = load i64, i64* %18
%138 = add i64 100679680, %137
%139 = call i64 @bswap_ul(i64 %138)
%140 = load i64*, i64** %17
store i64 %139, i64* %140
%141 = load i8*, i8** %11
%142 = getelementptr inbounds i8, i8* %141, i64 8204
%143 = bitcast i8* %142 to i64*
store i64* %143, i64** %17
%144 = load i64, i64* %19
%145 = call i64 @bswap_ul(i64 %144)
%146 = load i64*, i64** %17
store i64 %145, i64* %146
%147 = load i8*, i8** %11
%148 = load i64, i64* %18
%149 = getelementptr inbounds i8, i8* %147, i64 %148
%150 = load i8*, i8** %13
%151 = load i64, i64* %19
%152 = call i32 @memcpy(i8* %149, i8* %150, i64 %151)
%153 = load i8*, i8** %10
%154 = call i32 @fopen_s(i32** %20, i8* %153, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.11, i64 0, i64 0))
%155 = load i32*, i32** %20
%156 = icmp ne i32* %155, null
br i1 %156, label %157, label %168
157: ; preds = %110
%158 = load i8*, i8** %11
%159 = load i64, i64* %14
%160 = load i32*, i32** %20
%161 = call i32 @fwrite(i8* %158, i32 1, i64 %159, i32* %160)
%162 = load i32*, i32** %20
%163 = call i32 @fclose(i32* %162)
store i32* null, i32** %20
%164 = load i64, i64* %14
%165 = load i64, i64* %14
%166 = lshr i64 %165, 10
%167 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.12, i64 0, i64 0), i64 %164, i64 %166)
br label %171
168: ; preds = %110
%169 = load i8*, i8** %10
%170 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.13, i64 0, i64 0), i8* %169)
br label %172
171: ; preds = %157
store i32 0, i32* %6
br label %172
172: ; preds = %171, %168, %107, %99, %90, %81
%173 = load i8*, i8** %13
%174 = icmp ne i8* %173, null
br i1 %174, label %175, label %178
175: ; preds = %172
%176 = load i8*, i8** %13
%177 = call i32 @free(i8* %176)
store i8* null, i8** %13
br label %178
178: ; preds = %175, %172
%179 = load i8*, i8** %12
%180 = icmp ne i8* %179, null
br i1 %180, label %181, label %184
181: ; preds = %178
%182 = load i8*, i8** %12
%183 = call i32 @free(i8* %182)
store i8* null, i8** %12
br label %184
184: ; preds = %181, %178
%185 = load i8*, i8** %11
%186 = icmp ne i8* %185, null
br i1 %186, label %187, label %190
187: ; preds = %184
%188 = load i8*, i8** %11
%189 = call i32 @free(i8* %188)
store i8* null, i8** %11
br label %190
190: ; preds = %187, %184
%191 = load i32, i32* %6
store i32 %191, i32* %3
br label %192
192: ; preds = %190, %60, %50, %24
%193 = load i32, i32* %3
ret i32 %193
}

LLVM IR (-O2):
@.str.1 = [23 x i8] c" Type %s -h for help.\0A\00"
@.str.2 = [3 x i8] c"-h\00"
@.str.3 = [6 x i8] c"-help\00"
@.str.4 = [3 x i8] c"-?\00"
@.str.10 = [64 x i8] c"Error : total size too big (required %d bytes, max %d bytes) !\0A\00"
@.str.11 = [3 x i8] c"wb\00"
@.str.12 = [33 x i8] c"Wrote %d bytes (%d KB) to disk.\0A\00"
@.str.13 = [40 x i8] c"Error : could not write to file (%s) !\0A\00"
@str = [37 x i8] c"--- mksplash v0.1 by cafe-alpha. ---\00"
@str.14 = [63 x i8] c" Note: uses LibLZF: http://oldhome.schmorp.de/marc/liblzf.html\00"
@str.15 = [53 x i8] c" Usage : <loader.bin> <splash.bmp> <0.bin> <out.bin>\00"
@str.16 = [64 x i8] c" -> Pack loader.bin, splash.bmp, 0.bin in out.bin file.\00"
@str.17 = [51 x i8] c" After startup, splash.bmp is displayed\00"
@str.18 = [56 x i8] c" and 0.bin is loaded after a key is pressed.\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i64
%7 = alloca i64
%8 = alloca i64
%9 = alloca i32*
%10 = bitcast i8** %3 to i8*
store i8* null, i8** %3
%11 = bitcast i8** %4 to i8*
store i8* null, i8** %4
%12 = bitcast i8** %5 to i8*
store i8* null, i8** %5
%13 = bitcast i64* %6 to i8*
store i64 0, i64* %6
%14 = bitcast i64* %7 to i8*
store i64 0, i64* %7
%15 = bitcast i64* %8 to i8*
store i64 0, i64* %8
%16 = bitcast i32** %9 to i8*
store i32* null, i32** %9
%17 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @str, i64 0, i64 0))
%18 = icmp slt i32 %0, 2
br i1 %18, label %19, label %22
19: ; preds = %2
%20 = load i8*, i8** %1
%21 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i8* %20)
br label %137
22: ; preds = %2
%23 = getelementptr inbounds i8*, i8** %1, i64 1
%24 = load i8*, i8** %23
%25 = tail call i32 @strcmp(i8* dereferenceable(1) %24, i8* dereferenceable(3) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%26 = icmp eq i32 %25, 0
br i1 %26, label %33, label %27
27: ; preds = %22
%28 = tail call i32 @strcmp(i8* dereferenceable(1) %24, i8* dereferenceable(6) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
%29 = icmp eq i32 %28, 0
br i1 %29, label %33, label %30
30: ; preds = %27
%31 = tail call i32 @strcmp(i8* dereferenceable(1) %24, i8* dereferenceable(3) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
%32 = icmp eq i32 %31, 0
br i1 %32, label %33, label %39
33: ; preds = %30, %27, %22
%34 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([63 x i8], [63 x i8]* @str.14, i64 0, i64 0))
%35 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([53 x i8], [53 x i8]* @str.15, i64 0, i64 0))
%36 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([64 x i8], [64 x i8]* @str.16, i64 0, i64 0))
%37 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([51 x i8], [51 x i8]* @str.17, i64 0, i64 0))
%38 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([56 x i8], [56 x i8]* @str.18, i64 0, i64 0))
br label %137
39: ; preds = %30
%40 = icmp eq i32 %0, 5
br i1 %40, label %41, label %137
41: ; preds = %39
%42 = getelementptr inbounds i8*, i8** %1, i64 2
%43 = load i8*, i8** %42
%44 = getelementptr inbounds i8*, i8** %1, i64 3
%45 = load i8*, i8** %44
%46 = getelementptr inbounds i8*, i8** %1, i64 4
%47 = load i8*, i8** %46
%48 = call i32 @loader_read(i8* %24, i8** %3, i64* %6)
%49 = load i8*, i8** %3
%50 = icmp eq i8* %49, null
%51 = load i64, i64* %6
%52 = icmp eq i64 %51, 0
%53 = select i1 %50, i1 true, i1 %52
br i1 %53, label %118, label %54
54: ; preds = %41
%55 = call i32 @splash_read(i8* %43, i8** %5, i64* %8)
%56 = load i8*, i8** %5
%57 = icmp eq i8* %56, null
%58 = load i64, i64* %8
%59 = icmp eq i64 %58, 0
%60 = select i1 %57, i1 true, i1 %59
br i1 %60, label %121, label %61
61: ; preds = %54
%62 = call i32 @zero_bin_read(i8* %45, i8** %4, i64* %7)
%63 = load i8*, i8** %4
%64 = icmp eq i8* %63, null
%65 = load i64, i64* %7
%66 = icmp eq i64 %65, 0
%67 = select i1 %64, i1 true, i1 %66
br i1 %67, label %118, label %68
68: ; preds = %61
%69 = add i64 %65, 8208
%70 = load i64, i64* %8
%71 = add i64 %69, %70
store i64 %71, i64* %6
%72 = icmp ugt i64 %71, 1032192
br i1 %72, label %73, label %75
73: ; preds = %68
%74 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([64 x i8], [64 x i8]* @.str.10, i64 0, i64 0), i64 %71, i32 1032192)
br label %118
75: ; preds = %68
%76 = load i8*, i8** %3
%77 = getelementptr inbounds i8, i8* %76, i64 8192
%78 = bitcast i8* %77 to i64*
%79 = call i64 @bswap_ul(i64 100687888)
store i64 %79, i64* %78
%80 = load i8*, i8** %3
%81 = getelementptr inbounds i8, i8* %80, i64 8196
%82 = bitcast i8* %81 to i64*
%83 = call i64 @bswap_ul(i64 %65)
store i64 %83, i64* %82
%84 = load i8*, i8** %3
%85 = getelementptr inbounds i8, i8* %84, i64 8208
%86 = load i8*, i8** %4
%87 = call i32 @memcpy(i8* %85, i8* %86, i64 %65)
%88 = load i64, i64* %7
%89 = add i64 %88, 8208
%90 = load i64, i64* %8
%91 = load i8*, i8** %3
%92 = getelementptr inbounds i8, i8* %91, i64 8200
%93 = bitcast i8* %92 to i64*
%94 = add i64 %88, 100687888
%95 = call i64 @bswap_ul(i64 %94)
store i64 %95, i64* %93
%96 = load i8*, i8** %3
%97 = getelementptr inbounds i8, i8* %96, i64 8204
%98 = bitcast i8* %97 to i64*
%99 = call i64 @bswap_ul(i64 %90)
store i64 %99, i64* %98
%100 = load i8*, i8** %3
%101 = getelementptr inbounds i8, i8* %100, i64 %89
%102 = load i8*, i8** %5
%103 = call i32 @memcpy(i8* %101, i8* %102, i64 %90)
%104 = call i32 @fopen_s(i32** %9, i8* %47, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.11, i64 0, i64 0))
%105 = load i32*, i32** %9
%106 = icmp eq i32* %105, null
br i1 %106, label %116, label %107
107: ; preds = %75
%108 = load i8*, i8** %3
%109 = load i64, i64* %6
%110 = call i32 @fwrite(i8* %108, i32 1, i64 %109, i32* %105)
%111 = load i32*, i32** %9
%112 = call i32 @fclose(i32* %111)
store i32* null, i32** %9
%113 = load i64, i64* %6
%114 = lshr i64 %113, 10
%115 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str.12, i64 0, i64 0), i64 %113, i64 %114)
br label %118
116: ; preds = %75
%117 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @.str.13, i64 0, i64 0), i8* %47)
br label %118
118: ; preds = %73, %116, %107, %41, %61
%119 = phi i32 [ 1, %116 ], [ 0, %107 ], [ 1, %73 ], [ 1, %61 ], [ 1, %41 ]
%120 = load i8*, i8** %5
br label %121
121: ; preds = %118, %54
%122 = phi i8* [ %120, %118 ], [ %56, %54 ]
%123 = phi i32 [ %119, %118 ], [ 1, %54 ]
%124 = icmp eq i8* %122, null
br i1 %124, label %127, label %125
125: ; preds = %121
%126 = call i32 @free(i8* %122)
store i8* null, i8** %5
br label %127
127: ; preds = %125, %121
%128 = load i8*, i8** %4
%129 = icmp eq i8* %128, null
br i1 %129, label %132, label %130
130: ; preds = %127
%131 = call i32 @free(i8* %128)
store i8* null, i8** %4
br label %132
132: ; preds = %130, %127
%133 = load i8*, i8** %3
%134 = icmp eq i8* %133, null
br i1 %134, label %137, label %135
135: ; preds = %132
%136 = call i32 @free(i8* %133)
store i8* null, i8** %3
br label %137
137: ; preds = %132, %135, %39, %33, %19
%138 = phi i32 [ 0, %19 ], [ 0, %33 ], [ 1, %39 ], [ %123, %135 ], [ %123, %132 ]
ret i32 %138
}