#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*/ fsig;
typedef int /*<<< orphan*/ bsig;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ SEEK_END;
int /*<<< orphan*/ SEEK_SET;
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char const *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
size_t fread(unsigned char *, int, size_t, int /*<<< orphan*/ *);
int /*<<< orphan*/ free(unsigned char *);
int /*<<< orphan*/ fseek(int /*<<< orphan*/ *, int /*<<< orphan*/,
                         int /*<<< orphan*/);
size_t ftell(int /*<<< orphan*/ *);
size_t fwrite(unsigned char *, int, size_t, int /*<<< orphan*/ *);
unsigned char *malloc(size_t);
scalar_t__ memcmp(unsigned char *, unsigned char const *, int);
int /*<<< orphan*/ memcpy(unsigned char *, unsigned char *, size_t);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ stderr;
int mkboot_iaudio(const char *infile, const char *bootfile, const char *outfile,
                  int model_nr) {
  size_t flength, blength;
  unsigned char *bbuf, *fbuf, *p;
  const unsigned char fsig[] = {0x4e, 0xb9, 0x00, 0x01, 0x00, 0x10};
  unsigned char bsig[2][8] = {
      {0x60, 0x06, 0x44, 0x42, 0x69, 0x61, 0x78, 0x35},
      {0x60, 0x06, 0x44, 0x42, 0x69, 0x61, 0x6d, 0x35},
  };
  FILE *ffile, *bfile, *ofile;
  unsigned char sum = 0;
  int i;
  if ((bfile = fopen(bootfile, "rb")) == NULL) {
    perror("Cannot open Rockbox bootloader file.\n");
    return 1;
  }
  fseek(bfile, 0, SEEK_END);
  blength = ftell(bfile);
  fseek(bfile, 0, SEEK_SET);
  if (blength + 0x00150000 >= 0x00170000) {
    fprintf(stderr, "Rockbox bootloader is too big.\n");
    return 1;
  }
  if ((ffile = fopen(infile, "rb")) == NULL) {
    perror("Cannot open original firmware file.");
    return 1;
  }
  fseek(ffile, 0, SEEK_END);
  flength = ftell(ffile);
  fseek(ffile, 0, SEEK_SET);
  bbuf = malloc(blength);
  fbuf = malloc(flength);
  if (!bbuf || !fbuf) {
    fprintf(stderr, "Out of memory.\n");
    return 1;
  }
  if (fread(bbuf, 1, blength, bfile) < blength ||
      fread(fbuf, 1, flength, ffile) < flength) {
    fprintf(stderr, "Read error.\n");
    return 1;
  }
  fclose(bfile);
  fclose(ffile);
  if (blength < 0x10 || memcmp(bbuf, bsig[model_nr], sizeof(bsig[0]))) {
    fprintf(stderr,
            "Rockbox bootloader format error (is it bootloader.bin?).\n");
    return 1;
  }
  if (flength < 0x1030 - 0x00010000 + 0x00170000 ||
      memcmp(fbuf + 0x1030, fsig, sizeof(fsig))) {
    fprintf(stderr, "Original firmware format error.\n");
    return 1;
  }
  for (i = 0x00150000; i < 0x00170000; i++) {
    if (fbuf[0x1030 - 0x00010000 + i] != 0xff) {
      fprintf(stderr, "Original firmware has grown too much.\n");
      return 1;
    }
  }
  p = fbuf + 0x1030 + 2;
  *p++ = (0x00150000 >> 24) & 0xff;
  *p++ = (0x00150000 >> 16) & 0xff;
  *p++ = (0x00150000 >> 8) & 0xff;
  *p++ = (0x00150000) & 0xff;
  p = fbuf + 0x1030 + 0x00150000 - 0x00010000;
  memcpy(p, bbuf, blength);
  for (i = 0x1030; (size_t)i < flength; i++)
    sum += fbuf[i];
  fbuf[0x102b] = sum;
  if ((ofile = fopen(outfile, "wb")) == NULL) {
    perror("Cannot open output file");
    return 1;
  }
  if (fwrite(fbuf, 1, flength, ofile) < flength) {
    fprintf(stderr, "Write error.\n");
    return 1;
  }
  fclose(ofile);
  free(bbuf);
  free(fbuf);
  return 0;
}


x86 assembly (clang, -O0):
<mkboot_iaudio>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %ecx,-0x24(%rbp)
mov    0xe20(%rip),%eax
mov    %eax,-0x56(%rbp)
mov    0xe1a(%rip),%ax
mov    %ax,-0x52(%rbp)
mov    0xe1b(%rip),%rax
mov    %rax,-0x70(%rbp)
mov    0xe18(%rip),%rax
mov    %rax,-0x68(%rbp)
movb   $0x0,-0x89(%rbp)
mov    -0x18(%rbp),%rdi
lea    0xe0a(%rip),%rsi
call   10c0 <fopen@plt>
mov    %rax,-0x80(%rbp)
cmp    $0x0,%rax
jne    1241 <mkboot_iaudio+0x81>
lea    0xdf3(%rip),%rdi
call   10d0 <perror@plt>
movl   $0x1,-0x4(%rbp)
jmp    167b <mkboot_iaudio+0x4bb>
mov    -0x80(%rbp),%rdi
mov    0x2d9c(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   10b0 <fseek@plt>
mov    -0x80(%rbp),%rdi
call   1080 <ftell@plt>
mov    %rax,-0x38(%rbp)
mov    -0x80(%rbp),%rdi
mov    0x2d63(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   10b0 <fseek@plt>
mov    -0x38(%rbp),%rax
add    $0x150000,%rax
cmp    $0x170000,%rax
jb     12ad <mkboot_iaudio+0xed>
mov    0x2d45(%rip),%rax
mov    (%rax),%edi
lea    0xdad(%rip),%rsi
call   1070 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    167b <mkboot_iaudio+0x4bb>
mov    -0x10(%rbp),%rdi
lea    0xd68(%rip),%rsi
call   10c0 <fopen@plt>
mov    %rax,-0x78(%rbp)
cmp    $0x0,%rax
jne    12e3 <mkboot_iaudio+0x123>
lea    0xd97(%rip),%rdi
call   10d0 <perror@plt>
movl   $0x1,-0x4(%rbp)
jmp    167b <mkboot_iaudio+0x4bb>
mov    -0x78(%rbp),%rdi
mov    0x2cfa(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   10b0 <fseek@plt>
mov    -0x78(%rbp),%rdi
call   1080 <ftell@plt>
mov    %rax,-0x30(%rbp)
mov    -0x78(%rbp),%rdi
mov    0x2cc1(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   10b0 <fseek@plt>
mov    -0x38(%rbp),%rdi
call   10a0 <malloc@plt>
mov    %rax,-0x40(%rbp)
mov    -0x30(%rbp),%rdi
call   10a0 <malloc@plt>
mov    %rax,-0x48(%rbp)
cmpq   $0x0,-0x40(%rbp)
je     1348 <mkboot_iaudio+0x188>
cmpq   $0x0,-0x48(%rbp)
jne    1369 <mkboot_iaudio+0x1a9>
mov    0x2c89(%rip),%rax
mov    (%rax),%edi
lea    0xd35(%rip),%rsi
call   1070 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    167b <mkboot_iaudio+0x4bb>
mov    -0x40(%rbp),%rdi
mov    -0x38(%rbp),%rdx
mov    -0x80(%rbp),%rcx
mov    $0x1,%esi
call   1040 <fread@plt>
cmp    -0x38(%rbp),%rax
jb     13a9 <mkboot_iaudio+0x1e9>
mov    -0x48(%rbp),%rdi
mov    -0x30(%rbp),%rdx
mov    -0x78(%rbp),%rcx
mov    $0x1,%esi
call   1040 <fread@plt>
cmp    -0x30(%rbp),%rax
jae    13ca <mkboot_iaudio+0x20a>
mov    0x2c28(%rip),%rax
mov    (%rax),%edi
lea    0xce4(%rip),%rsi
call   1070 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    167b <mkboot_iaudio+0x4bb>
mov    -0x80(%rbp),%rdi
call   1050 <fclose@plt>
mov    -0x78(%rbp),%rdi
call   1050 <fclose@plt>
cmpq   $0x10,-0x38(%rbp)
jb     140e <mkboot_iaudio+0x24e>
mov    -0x40(%rbp),%rdi
movslq -0x24(%rbp),%rax
lea    -0x70(%rbp),%rsi
shl    $0x3,%rax
add    %rax,%rsi
mov    $0x8,%edx
call   1060 <memcmp@plt>
cmp    $0x0,%rax
je     142f <mkboot_iaudio+0x26f>
mov    0x2bc3(%rip),%rax
mov    (%rax),%edi
lea    0xc8c(%rip),%rsi
call   1070 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    167b <mkboot_iaudio+0x4bb>
cmpq   $0x161030,-0x30(%rbp)
jb     1460 <mkboot_iaudio+0x2a0>
mov    -0x48(%rbp),%rdi
add    $0x1030,%rdi
lea    -0x56(%rbp),%rsi
mov    $0x6,%edx
call   1060 <memcmp@plt>
cmp    $0x0,%rax
je     1481 <mkboot_iaudio+0x2c1>
mov    0x2b71(%rip),%rax
mov    (%rax),%edi
lea    0xc74(%rip),%rsi
call   1070 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    167b <mkboot_iaudio+0x4bb>
movl   $0x150000,-0x90(%rbp)
cmpl   $0x170000,-0x90(%rbp)
jge    14f7 <mkboot_iaudio+0x337>
mov    -0x48(%rbp),%rax
mov    -0x90(%rbp),%ecx
add    $0xffff1030,%ecx
movslq %ecx,%rcx
movzbl (%rax,%rcx,1),%eax
cmp    $0xff,%eax
je     14de <mkboot_iaudio+0x31e>
mov    0x2b14(%rip),%rax
mov    (%rax),%edi
lea    0xc38(%rip),%rsi
call   1070 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    167b <mkboot_iaudio+0x4bb>
jmp    14e3 <mkboot_iaudio+0x323>
mov    -0x90(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x90(%rbp)
jmp    148b <mkboot_iaudio+0x2cb>
mov    -0x48(%rbp),%rax
add    $0x1030,%rax
add    $0x2,%rax
mov    %rax,-0x50(%rbp)
mov    -0x50(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x50(%rbp)
movb   $0x0,(%rax)
mov    -0x50(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x50(%rbp)
movb   $0x15,(%rax)
mov    -0x50(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x50(%rbp)
movb   $0x0,(%rax)
mov    -0x50(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x50(%rbp)
movb   $0x0,(%rax)
mov    -0x48(%rbp),%rax
add    $0x1030,%rax
add    $0x150000,%rax
add    $0xffffffffffff0000,%rax
mov    %rax,-0x50(%rbp)
mov    -0x50(%rbp),%rdi
mov    -0x40(%rbp),%rsi
mov    -0x38(%rbp),%rdx
call   1090 <memcpy@plt>
movl   $0x1030,-0x90(%rbp)
movslq -0x90(%rbp),%rax
cmp    -0x30(%rbp),%rax
jae    15c9 <mkboot_iaudio+0x409>
mov    -0x48(%rbp),%rax
movslq -0x90(%rbp),%rcx
movzbl (%rax,%rcx,1),%ecx
movzbl -0x89(%rbp),%eax
add    %ecx,%eax
mov    %al,-0x89(%rbp)
mov    -0x90(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x90(%rbp)
jmp    1586 <mkboot_iaudio+0x3c6>
mov    -0x89(%rbp),%cl
mov    -0x48(%rbp),%rax
mov    %cl,0x102b(%rax)
mov    -0x20(%rbp),%rdi
lea    0xb48(%rip),%rsi
call   10c0 <fopen@plt>
mov    %rax,-0x88(%rbp)
cmp    $0x0,%rax
jne    1612 <mkboot_iaudio+0x452>
lea    0xb2e(%rip),%rdi
call   10d0 <perror@plt>
movl   $0x1,-0x4(%rbp)
jmp    167b <mkboot_iaudio+0x4bb>
mov    -0x48(%rbp),%rdi
mov    -0x30(%rbp),%rdx
mov    -0x88(%rbp),%rcx
mov    $0x1,%esi
call   10e0 <fwrite@plt>
cmp    -0x30(%rbp),%rax
jae    1656 <mkboot_iaudio+0x496>
mov    0x299c(%rip),%rax
mov    (%rax),%edi
lea    0xb02(%rip),%rsi
call   1070 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    167b <mkboot_iaudio+0x4bb>
mov    -0x88(%rbp),%rdi
call   1050 <fclose@plt>
mov    -0x40(%rbp),%rdi
call   1030 <free@plt>
mov    -0x48(%rbp),%rdi
call   1030 <free@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mkboot_iaudio>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x48,%rsp
mov    %ecx,%ebp
mov    %rdx,%rbx
mov    %rsi,%rax
mov    %rdi,%r15
movw   $0x1000,0x2c(%rsp)
movl   $0x100b94e,0x28(%rsp)
01
movdqa 0xe20(%rip),%xmm0
movdqa %xmm0,0x30(%rsp)
lea    0xe23(%rip),%rsi
mov    %rax,%rdi
call   10c0 <fopen@plt>
test   %rax,%rax
je     135f <mkboot_iaudio+0x19f>
mov    %rax,%r14
mov    %ebp,0x24(%rsp)
mov    0x2dcc(%rip),%r12
mov    (%r12),%edx
mov    %rax,%rdi
xor    %esi,%esi
call   10b0 <fseek@plt>
mov    %r14,%rdi
call   1080 <ftell@plt>
mov    %rax,%rbp
mov    0x2d94(%rip),%r13
mov    0x0(%r13),%edx
mov    %r14,%rdi
xor    %esi,%esi
call   10b0 <fseek@plt>
mov    %rbp,0x18(%rsp)
lea    -0x20000(%rbp),%rax
cmp    $0xffffffffffe8ffff,%rax
ja     1273 <mkboot_iaudio+0xb3>
mov    0x2d73(%rip),%rax
mov    (%rax),%edi
lea    0xddb(%rip),%rsi
jmp    1342 <mkboot_iaudio+0x182>
mov    %rbx,0x10(%rsp)
lea    0xda1(%rip),%rsi
mov    %r15,%rdi
call   10c0 <fopen@plt>
test   %rax,%rax
je     13b1 <mkboot_iaudio+0x1f1>
mov    %rax,%r15
mov    (%r12),%edx
mov    %rax,%rdi
xor    %esi,%esi
call   10b0 <fseek@plt>
mov    %r15,%rdi
call   1080 <ftell@plt>
mov    %rax,%rbp
mov    0x0(%r13),%edx
mov    %r15,%rdi
xor    %esi,%esi
call   10b0 <fseek@plt>
mov    0x18(%rsp),%rdi
call   10a0 <malloc@plt>
mov    %rax,%rbx
mov    %rbp,%rdi
call   10a0 <malloc@plt>
test   %rbx,%rbx
je     1332 <mkboot_iaudio+0x172>
test   %rax,%rax
je     1332 <mkboot_iaudio+0x172>
mov    %rax,0x8(%rsp)
mov    $0x1,%r12d
mov    %rbx,%rdi
mov    $0x1,%esi
mov    0x18(%rsp),%r13
mov    %r13,%rdx
mov    %r14,%rcx
call   1040 <fread@plt>
cmp    %r13,%rax
jb     131b <mkboot_iaudio+0x15b>
mov    0x8(%rsp),%rdi
mov    $0x1,%esi
mov    %rbp,%rdx
mov    %r15,%rcx
call   1040 <fread@plt>
cmp    %rbp,%rax
jae    1368 <mkboot_iaudio+0x1a8>
mov    0x2cb6(%rip),%rax
mov    (%rax),%edi
lea    0xd72(%rip),%rsi
call   1070 <fprintf@plt>
jmp    134d <mkboot_iaudio+0x18d>
mov    0x2c9f(%rip),%rax
mov    (%rax),%edi
lea    0xd4b(%rip),%rsi
call   1070 <fprintf@plt>
mov    $0x1,%r12d
mov    %r12d,%eax
add    $0x48,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xcbd(%rip),%rdi
jmp    13b8 <mkboot_iaudio+0x1f8>
mov    %r14,%rdi
call   1050 <fclose@plt>
mov    %r15,%rdi
call   1050 <fclose@plt>
cmpq   $0x10,0x18(%rsp)
jb     139f <mkboot_iaudio+0x1df>
movslq 0x24(%rsp),%rax
lea    (%rsp,%rax,8),%rsi
add    $0x30,%rsi
mov    %rbx,%rdi
mov    $0x8,%edx
call   1060 <memcmp@plt>
test   %rax,%rax
je     13bf <mkboot_iaudio+0x1ff>
mov    0x2c32(%rip),%rax
mov    (%rax),%edi
lea    0xcfb(%rip),%rsi
jmp    1342 <mkboot_iaudio+0x182>
lea    0xcb1(%rip),%rdi
call   10d0 <perror@plt>
jmp    1347 <mkboot_iaudio+0x187>
cmp    $0x161030,%rbp
mov    0x8(%rsp),%r15
jb     13e8 <mkboot_iaudio+0x228>
lea    0x1030(%r15),%rdi
lea    0x28(%rsp),%rsi
mov    $0x6,%edx
call   1060 <memcmp@plt>
test   %rax,%rax
je     13fd <mkboot_iaudio+0x23d>
mov    0x2be9(%rip),%rax
mov    (%rax),%edi
lea    0xcec(%rip),%rsi
jmp    1342 <mkboot_iaudio+0x182>
mov    $0x141033,%eax
mov    0x10(%rsp),%r14
cmpb   $0xff,-0x3(%r15,%rax,1)
jne    1473 <mkboot_iaudio+0x2b3>
cmpb   $0xff,-0x2(%r15,%rax,1)
jne    1473 <mkboot_iaudio+0x2b3>
cmpb   $0xff,-0x1(%r15,%rax,1)
jne    1473 <mkboot_iaudio+0x2b3>
cmpb   $0xff,(%r15,%rax,1)
jne    1473 <mkboot_iaudio+0x2b3>
add    $0x4,%rax
cmp    $0x161033,%rax
jne    1407 <mkboot_iaudio+0x247>
movl   $0x1500,0x1032(%r15)
lea    0x141030(%r15),%rdi
mov    %rbx,%rsi
mov    0x18(%rsp),%rdx
call   1090 <memcpy@plt>
cmp    $0x1031,%rbp
jb     1488 <mkboot_iaudio+0x2c8>
lea    -0x1030(%rbp),%r8
cmp    $0x8,%r8
jae    148f <mkboot_iaudio+0x2cf>
mov    $0x1030,%esi
xor    %edx,%edx
jmp    1616 <mkboot_iaudio+0x456>
mov    0x2b5e(%rip),%rax
mov    (%rax),%edi
lea    0xc82(%rip),%rsi
jmp    1342 <mkboot_iaudio+0x182>
xor    %edx,%edx
jmp    1623 <mkboot_iaudio+0x463>
cmp    $0x20,%r8
jae    149e <mkboot_iaudio+0x2de>
xor    %edx,%edx
xor    %ecx,%ecx
jmp    15b9 <mkboot_iaudio+0x3f9>
mov    %r8,%rcx
and    $0xffffffffffffffe0,%rcx
lea    -0x20(%rcx),%rsi
mov    %rsi,%rdi
shr    $0x5,%rdi
add    $0x1,%rdi
mov    %edi,%edx
and    $0x3,%edx
cmp    $0x60,%rsi
jae    14ce <mkboot_iaudio+0x30e>
pxor   %xmm0,%xmm0
xor    %esi,%esi
pxor   %xmm1,%xmm1
jmp    1553 <mkboot_iaudio+0x393>
and    $0xfffffffffffffffc,%rdi
pxor   %xmm0,%xmm0
xor    %esi,%esi
pxor   %xmm1,%xmm1
mov    0x8(%rsp),%rax
movdqu 0x1030(%rax,%rsi,1),%xmm2
paddb  %xmm0,%xmm2
movdqu 0x1040(%rax,%rsi,1),%xmm0
paddb  %xmm1,%xmm0
movdqu 0x1050(%rax,%rsi,1),%xmm1
movdqu 0x1060(%rax,%rsi,1),%xmm3
movdqu 0x1070(%rax,%rsi,1),%xmm4
paddb  %xmm1,%xmm4
paddb  %xmm2,%xmm4
movdqu 0x1080(%rax,%rsi,1),%xmm2
paddb  %xmm3,%xmm2
paddb  %xmm0,%xmm2
movdqu 0x1090(%rax,%rsi,1),%xmm0
paddb  %xmm4,%xmm0
movdqu 0x10a0(%rax,%rsi,1),%xmm1
paddb  %xmm2,%xmm1
sub    $0xffffffffffffff80,%rsi
add    $0xfffffffffffffffc,%rdi
jne    14e1 <mkboot_iaudio+0x321>
test   %rdx,%rdx
je     1589 <mkboot_iaudio+0x3c9>
mov    0x8(%rsp),%rax
add    %rax,%rsi
add    $0x1040,%rsi
shl    $0x5,%rdx
xor    %edi,%edi
movdqu -0x10(%rsi,%rdi,1),%xmm2
paddb  %xmm2,%xmm0
movdqu (%rsi,%rdi,1),%xmm2
paddb  %xmm2,%xmm1
add    $0x20,%rdi
cmp    %rdi,%rdx
jne    156d <mkboot_iaudio+0x3ad>
paddb  %xmm1,%xmm0
pshufd $0xee,%xmm0,%xmm1
paddb  %xmm0,%xmm1
pxor   %xmm0,%xmm0
psadbw %xmm1,%xmm0
movd   %xmm0,%edx
cmp    %rcx,%r8
jne    15b3 <mkboot_iaudio+0x3f3>
mov    0x10(%rsp),%r14
mov    0x8(%rsp),%r15
jmp    1623 <mkboot_iaudio+0x463>
test   $0x18,%r8b
je     1602 <mkboot_iaudio+0x442>
mov    %r8,%rdi
and    $0xfffffffffffffff8,%rdi
lea    0x1030(%rdi),%rsi
movzbl %dl,%edx
movd   %edx,%xmm0
mov    0x8(%rsp),%r15
movq   0x1030(%r15,%rcx,1),%xmm1
paddb  %xmm1,%xmm0
add    $0x8,%rcx
cmp    %rcx,%rdi
jne    15d3 <mkboot_iaudio+0x413>
pxor   %xmm1,%xmm1
psadbw %xmm1,%xmm0
movd   %xmm0,%edx
cmp    %rdi,%r8
mov    0x10(%rsp),%r14
jne    1616 <mkboot_iaudio+0x456>
jmp    1623 <mkboot_iaudio+0x463>
add    $0x1030,%rcx
mov    %rcx,%rsi
mov    0x10(%rsp),%r14
mov    0x8(%rsp),%r15
add    (%r15,%rsi,1),%dl
add    $0x1,%rsi
cmp    %rsi,%rbp
jne    1616 <mkboot_iaudio+0x456>
mov    %dl,0x102b(%r15)
lea    0xafb(%rip),%rsi
mov    %r14,%rdi
call   10c0 <fopen@plt>
test   %rax,%rax
je     169c <mkboot_iaudio+0x4dc>
mov    %rax,%r13
mov    %r15,%r14
mov    $0x1,%r12d
mov    %r15,%rdi
mov    $0x1,%esi
mov    %rbp,%rdx
mov    %rax,%rcx
call   10e0 <fwrite@plt>
cmp    %rbp,%rax
jae    167c <mkboot_iaudio+0x4bc>
mov    0x296f(%rip),%rax
mov    (%rax),%edi
lea    0xad5(%rip),%rsi
call   1070 <fprintf@plt>
jmp    134d <mkboot_iaudio+0x18d>
mov    %r13,%rdi
call   1050 <fclose@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    %r14,%rdi
call   1030 <free@plt>
xor    %r12d,%r12d
jmp    134d <mkboot_iaudio+0x18d>
lea    0xa8c(%rip),%rdi
jmp    13b8 <mkboot_iaudio+0x1f8>

LLVM IR (-O0):
@__const.mkboot_iaudio.fsig = [6 x i8] c"N\B9\00\01\00\10"
@__const.mkboot_iaudio.bsig = [2 x [8 x i8]] [[8 x i8] c"`\06DBiax5", [8 x i8] c"`\06DBiam5"]
@.str = [3 x i8] c"rb\00"
@.str.1 = [38 x i8] c"Cannot open Rockbox bootloader file.\0A\00"
@SEEK_END = global i32 0
@SEEK_SET = global i32 0
@stderr = global i32 0
@.str.2 = [32 x i8] c"Rockbox bootloader is too big.\0A\00"
@.str.3 = [36 x i8] c"Cannot open original firmware file.\00"
@.str.4 = [16 x i8] c"Out of memory.\0A\00"
@.str.5 = [13 x i8] c"Read error.\0A\00"
@.str.6 = [58 x i8] c"Rockbox bootloader format error (is it bootloader.bin?).\0A\00"
@.str.7 = [33 x i8] c"Original firmware format error.\0A\00"
@.str.8 = [39 x i8] c"Original firmware has grown too much.\0A\00"
@.str.9 = [3 x i8] c"wb\00"
@.str.10 = [24 x i8] c"Cannot open output file\00"
@.str.11 = [14 x i8] c"Write error.\0A\00"
define i32 @mkboot_iaudio(i8* %0, i8* %1, i8* %2, i32 %3) {
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i32
%10 = alloca i64
%11 = alloca i64
%12 = alloca i8*
%13 = alloca i8*
%14 = alloca i8*
%15 = alloca [6 x i8]
%16 = alloca [2 x [8 x i8]]
%17 = alloca i32*
%18 = alloca i32*
%19 = alloca i32*
%20 = alloca i8
%21 = alloca i32
store i8* %0, i8** %6
store i8* %1, i8** %7
store i8* %2, i8** %8
store i32 %3, i32* %9
%22 = bitcast [6 x i8]* %15 to i8*
%23 = bitcast [2 x [8 x i8]]* %16 to i8*
store i8 0, i8* %20
%24 = load i8*, i8** %7
%25 = call i32* @fopen(i8* %24, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
store i32* %25, i32** %18
%26 = icmp eq i32* %25, null
br i1 %26, label %27, label %29
27: ; preds = %4
%28 = call i32 @perror(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.1, i64 0, i64 0))
store i32 1, i32* %5
br label %203
29: ; preds = %4
%30 = load i32*, i32** %18
%31 = load i32, i32* @SEEK_END
%32 = call i32 @fseek(i32* %30, i32 0, i32 %31)
%33 = load i32*, i32** %18
%34 = call i64 @ftell(i32* %33)
store i64 %34, i64* %11
%35 = load i32*, i32** %18
%36 = load i32, i32* @SEEK_SET
%37 = call i32 @fseek(i32* %35, i32 0, i32 %36)
%38 = load i64, i64* %11
%39 = add i64 %38, 1376256
%40 = icmp uge i64 %39, 1507328
br i1 %40, label %41, label %44
41: ; preds = %29
%42 = load i32, i32* @stderr
%43 = call i32 @fprintf(i32 %42, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.2, i64 0, i64 0))
store i32 1, i32* %5
br label %203
44: ; preds = %29
%45 = load i8*, i8** %6
%46 = call i32* @fopen(i8* %45, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
store i32* %46, i32** %17
%47 = icmp eq i32* %46, null
br i1 %47, label %48, label %50
48: ; preds = %44
%49 = call i32 @perror(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.3, i64 0, i64 0))
store i32 1, i32* %5
br label %203
50: ; preds = %44
%51 = load i32*, i32** %17
%52 = load i32, i32* @SEEK_END
%53 = call i32 @fseek(i32* %51, i32 0, i32 %52)
%54 = load i32*, i32** %17
%55 = call i64 @ftell(i32* %54)
store i64 %55, i64* %10
%56 = load i32*, i32** %17
%57 = load i32, i32* @SEEK_SET
%58 = call i32 @fseek(i32* %56, i32 0, i32 %57)
%59 = load i64, i64* %11
%60 = call i8* @malloc(i64 %59)
store i8* %60, i8** %12
%61 = load i64, i64* %10
%62 = call i8* @malloc(i64 %61)
store i8* %62, i8** %13
%63 = load i8*, i8** %12
%64 = icmp ne i8* %63, null
br i1 %64, label %65, label %68
65: ; preds = %50
%66 = load i8*, i8** %13
%67 = icmp ne i8* %66, null
br i1 %67, label %71, label %68
68: ; preds = %65, %50
%69 = load i32, i32* @stderr
%70 = call i32 @fprintf(i32 %69, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.4, i64 0, i64 0))
store i32 1, i32* %5
br label %203
71: ; preds = %65
%72 = load i8*, i8** %12
%73 = load i64, i64* %11
%74 = load i32*, i32** %18
%75 = call i64 @fread(i8* %72, i32 1, i64 %73, i32* %74)
%76 = load i64, i64* %11
%77 = icmp ult i64 %75, %76
br i1 %77, label %85, label %78
78: ; preds = %71
%79 = load i8*, i8** %13
%80 = load i64, i64* %10
%81 = load i32*, i32** %17
%82 = call i64 @fread(i8* %79, i32 1, i64 %80, i32* %81)
%83 = load i64, i64* %10
%84 = icmp ult i64 %82, %83
br i1 %84, label %85, label %88
85: ; preds = %78, %71
%86 = load i32, i32* @stderr
%87 = call i32 @fprintf(i32 %86, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.5, i64 0, i64 0))
store i32 1, i32* %5
br label %203
88: ; preds = %78
%89 = load i32*, i32** %18
%90 = call i32 @fclose(i32* %89)
%91 = load i32*, i32** %17
%92 = call i32 @fclose(i32* %91)
%93 = load i64, i64* %11
%94 = icmp ult i64 %93, 16
br i1 %94, label %103, label %95
95: ; preds = %88
%96 = load i8*, i8** %12
%97 = load i32, i32* %9
%98 = sext i32 %97 to i64
%99 = getelementptr inbounds [2 x [8 x i8]], [2 x [8 x i8]]* %16, i64 0, i64 %98
%100 = getelementptr inbounds [8 x i8], [8 x i8]* %99, i64 0, i64 0
%101 = call i64 @memcmp(i8* %96, i8* %100, i32 8)
%102 = icmp ne i64 %101, 0
br i1 %102, label %103, label %106
103: ; preds = %95, %88
%104 = load i32, i32* @stderr
%105 = call i32 @fprintf(i32 %104, i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str.6, i64 0, i64 0))
store i32 1, i32* %5
br label %203
106: ; preds = %95
%107 = load i64, i64* %10
%108 = icmp ult i64 %107, 1445936
br i1 %108, label %115, label %109
109: ; preds = %106
%110 = load i8*, i8** %13
%111 = getelementptr inbounds i8, i8* %110, i64 4144
%112 = getelementptr inbounds [6 x i8], [6 x i8]* %15, i64 0, i64 0
%113 = call i64 @memcmp(i8* %111, i8* %112, i32 6)
%114 = icmp ne i64 %113, 0
br i1 %114, label %115, label %118
115: ; preds = %109, %106
%116 = load i32, i32* @stderr
%117 = call i32 @fprintf(i32 %116, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.7, i64 0, i64 0))
store i32 1, i32* %5
br label %203
118: ; preds = %109
store i32 1376256, i32* %21
br label %119
119: ; preds = %135, %118
%120 = load i32, i32* %21
%121 = icmp slt i32 %120, 1507328
br i1 %121, label %122, label %138
122: ; preds = %119
%123 = load i8*, i8** %13
%124 = load i32, i32* %21
%125 = add nsw i32 -61392, %124
%126 = sext i32 %125 to i64
%127 = getelementptr inbounds i8, i8* %123, i64 %126
%128 = load i8, i8* %127
%129 = zext i8 %128 to i32
%130 = icmp ne i32 %129, 255
br i1 %130, label %131, label %134
131: ; preds = %122
%132 = load i32, i32* @stderr
%133 = call i32 @fprintf(i32 %132, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.8, i64 0, i64 0))
store i32 1, i32* %5
br label %203
134: ; preds = %122
br label %135
135: ; preds = %134
%136 = load i32, i32* %21
%137 = add nsw i32 %136, 1
store i32 %137, i32* %21
br label %119
138: ; preds = %119
%139 = load i8*, i8** %13
%140 = getelementptr inbounds i8, i8* %139, i64 4144
%141 = getelementptr inbounds i8, i8* %140, i64 2
store i8* %141, i8** %14
%142 = load i8*, i8** %14
%143 = getelementptr inbounds i8, i8* %142, i32 1
store i8* %143, i8** %14
store i8 0, i8* %142
%144 = load i8*, i8** %14
%145 = getelementptr inbounds i8, i8* %144, i32 1
store i8* %145, i8** %14
store i8 21, i8* %144
%146 = load i8*, i8** %14
%147 = getelementptr inbounds i8, i8* %146, i32 1
store i8* %147, i8** %14
store i8 0, i8* %146
%148 = load i8*, i8** %14
%149 = getelementptr inbounds i8, i8* %148, i32 1
store i8* %149, i8** %14
store i8 0, i8* %148
%150 = load i8*, i8** %13
%151 = getelementptr inbounds i8, i8* %150, i64 4144
%152 = getelementptr inbounds i8, i8* %151, i64 1376256
%153 = getelementptr inbounds i8, i8* %152, i64 -65536
store i8* %153, i8** %14
%154 = load i8*, i8** %14
%155 = load i8*, i8** %12
%156 = load i64, i64* %11
%157 = call i32 @memcpy(i8* %154, i8* %155, i64 %156)
store i32 4144, i32* %21
br label %158
158: ; preds = %174, %138
%159 = load i32, i32* %21
%160 = sext i32 %159 to i64
%161 = load i64, i64* %10
%162 = icmp ult i64 %160, %161
br i1 %162, label %163, label %177
163: ; preds = %158
%164 = load i8*, i8** %13
%165 = load i32, i32* %21
%166 = sext i32 %165 to i64
%167 = getelementptr inbounds i8, i8* %164, i64 %166
%168 = load i8, i8* %167
%169 = zext i8 %168 to i32
%170 = load i8, i8* %20
%171 = zext i8 %170 to i32
%172 = add nsw i32 %171, %169
%173 = trunc i32 %172 to i8
store i8 %173, i8* %20
br label %174
174: ; preds = %163
%175 = load i32, i32* %21
%176 = add nsw i32 %175, 1
store i32 %176, i32* %21
br label %158
177: ; preds = %158
%178 = load i8, i8* %20
%179 = load i8*, i8** %13
%180 = getelementptr inbounds i8, i8* %179, i64 4139
store i8 %178, i8* %180
%181 = load i8*, i8** %8
%182 = call i32* @fopen(i8* %181, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.9, i64 0, i64 0))
store i32* %182, i32** %19
%183 = icmp eq i32* %182, null
br i1 %183, label %184, label %186
184: ; preds = %177
%185 = call i32 @perror(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.10, i64 0, i64 0))
store i32 1, i32* %5
br label %203
186: ; preds = %177
%187 = load i8*, i8** %13
%188 = load i64, i64* %10
%189 = load i32*, i32** %19
%190 = call i64 @fwrite(i8* %187, i32 1, i64 %188, i32* %189)
%191 = load i64, i64* %10
%192 = icmp ult i64 %190, %191
br i1 %192, label %193, label %196
193: ; preds = %186
%194 = load i32, i32* @stderr
%195 = call i32 @fprintf(i32 %194, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.11, i64 0, i64 0))
store i32 1, i32* %5
br label %203
196: ; preds = %186
%197 = load i32*, i32** %19
%198 = call i32 @fclose(i32* %197)
%199 = load i8*, i8** %12
%200 = call i32 @free(i8* %199)
%201 = load i8*, i8** %13
%202 = call i32 @free(i8* %201)
store i32 0, i32* %5
br label %203
203: ; preds = %196, %193, %184, %131, %115, %103, %85, %68, %48, %41, %27
%204 = load i32, i32* %5
ret i32 %204
}

LLVM IR (-O2):
@__const.mkboot_iaudio.fsig = [6 x i8] c"N\B9\00\01\00\10"
@__const.mkboot_iaudio.bsig = [2 x [8 x i8]] [[8 x i8] c"`\06DBiax5", [8 x i8] c"`\06DBiam5"]
@.str = [3 x i8] c"rb\00"
@.str.1 = [38 x i8] c"Cannot open Rockbox bootloader file.\0A\00"
@SEEK_END = global i32 0
@SEEK_SET = global i32 0
@stderr = global i32 0
@.str.2 = [32 x i8] c"Rockbox bootloader is too big.\0A\00"
@.str.3 = [36 x i8] c"Cannot open original firmware file.\00"
@.str.4 = [16 x i8] c"Out of memory.\0A\00"
@.str.5 = [13 x i8] c"Read error.\0A\00"
@.str.6 = [58 x i8] c"Rockbox bootloader format error (is it bootloader.bin?).\0A\00"
@.str.7 = [33 x i8] c"Original firmware format error.\0A\00"
@.str.8 = [39 x i8] c"Original firmware has grown too much.\0A\00"
@.str.9 = [3 x i8] c"wb\00"
@.str.10 = [24 x i8] c"Cannot open output file\00"
@.str.11 = [14 x i8] c"Write error.\0A\00"
define i32 @mkboot_iaudio(i8* nocapture %0, i8* nocapture %1, i8* nocapture %2, i32 %3) {
%5 = alloca [6 x i8]
%6 = alloca [2 x [8 x i8]]
%7 = getelementptr inbounds [6 x i8], [6 x i8]* %5, i64 0, i64 0
%8 = getelementptr inbounds [2 x [8 x i8]], [2 x [8 x i8]]* %6, i64 0, i64 0, i64 0
%9 = tail call i32* @fopen(i8* %1, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%10 = icmp eq i32* %9, null
br i1 %10, label %11, label %13
11: ; preds = %4
%12 = tail call i32 @perror(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.1, i64 0, i64 0))
br label %248
13: ; preds = %4
%14 = load i32, i32* @SEEK_END
%15 = tail call i32 @fseek(i32* %9, i32 0, i32 %14)
%16 = tail call i64 @ftell(i32* %9)
%17 = load i32, i32* @SEEK_SET
%18 = tail call i32 @fseek(i32* %9, i32 0, i32 %17)
%19 = add i64 %16, -131072
%20 = icmp ult i64 %19, -1507328
br i1 %20, label %21, label %24
21: ; preds = %13
%22 = load i32, i32* @stderr
%23 = tail call i32 @fprintf(i32 %22, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.2, i64 0, i64 0))
br label %248
24: ; preds = %13
%25 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%26 = icmp eq i32* %25, null
br i1 %26, label %27, label %29
27: ; preds = %24
%28 = tail call i32 @perror(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.3, i64 0, i64 0))
br label %248
29: ; preds = %24
%30 = load i32, i32* @SEEK_END
%31 = tail call i32 @fseek(i32* %25, i32 0, i32 %30)
%32 = tail call i64 @ftell(i32* %25)
%33 = load i32, i32* @SEEK_SET
%34 = tail call i32 @fseek(i32* %25, i32 0, i32 %33)
%35 = tail call i8* @malloc(i64 %16)
%36 = tail call i8* @malloc(i64 %32)
%37 = icmp ne i8* %35, null
%38 = icmp ne i8* %36, null
%39 = and i1 %37, %38
br i1 %39, label %43, label %40
40: ; preds = %29
%41 = load i32, i32* @stderr
%42 = tail call i32 @fprintf(i32 %41, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.4, i64 0, i64 0))
br label %248
43: ; preds = %29
%44 = tail call i64 @fread(i8* %35, i32 1, i64 %16, i32* %9)
%45 = icmp ult i64 %44, %16
br i1 %45, label %49, label %46
46: ; preds = %43
%47 = tail call i64 @fread(i8* %36, i32 1, i64 %32, i32* %25)
%48 = icmp ult i64 %47, %32
br i1 %48, label %49, label %52
49: ; preds = %46, %43
%50 = load i32, i32* @stderr
%51 = tail call i32 @fprintf(i32 %50, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.5, i64 0, i64 0))
br label %248
52: ; preds = %46
%53 = tail call i32 @fclose(i32* %9)
%54 = tail call i32 @fclose(i32* %25)
%55 = icmp ult i64 %16, 16
br i1 %55, label %61, label %56
56: ; preds = %52
%57 = sext i32 %3 to i64
%58 = getelementptr inbounds [2 x [8 x i8]], [2 x [8 x i8]]* %6, i64 0, i64 %57, i64 0
%59 = call i64 @memcmp(i8* %35, i8* %58, i32 8)
%60 = icmp eq i64 %59, 0
br i1 %60, label %64, label %61
61: ; preds = %56, %52
%62 = load i32, i32* @stderr
%63 = call i32 @fprintf(i32 %62, i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str.6, i64 0, i64 0))
br label %248
64: ; preds = %56
%65 = icmp ult i64 %32, 1445936
br i1 %65, label %70, label %66
66: ; preds = %64
%67 = getelementptr inbounds i8, i8* %36, i64 4144
%68 = call i64 @memcmp(i8* %67, i8* %7, i32 6)
%69 = icmp eq i64 %68, 0
br i1 %69, label %91, label %70
70: ; preds = %66, %64
%71 = load i32, i32* @stderr
%72 = call i32 @fprintf(i32 %71, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.7, i64 0, i64 0))
br label %248
73: ; preds = %91
%74 = add nsw i64 %92, -61391
%75 = getelementptr inbounds i8, i8* %36, i64 %74
%76 = load i8, i8* %75
%77 = icmp eq i8 %76, -1
br i1 %77, label %78, label %97
78: ; preds = %73
%79 = add nsw i64 %92, -61390
%80 = getelementptr inbounds i8, i8* %36, i64 %79
%81 = load i8, i8* %80
%82 = icmp eq i8 %81, -1
br i1 %82, label %83, label %97
83: ; preds = %78
%84 = add nsw i64 %92, -61389
%85 = getelementptr inbounds i8, i8* %36, i64 %84
%86 = load i8, i8* %85
%87 = icmp eq i8 %86, -1
br i1 %87, label %88, label %97
88: ; preds = %83
%89 = add nuw nsw i64 %92, 4
%90 = icmp eq i64 %89, 1507328
br i1 %90, label %100, label %91
91: ; preds = %66, %88
%92 = phi i64 [ %89, %88 ], [ 1376256, %66 ]
%93 = add nsw i64 %92, -61392
%94 = getelementptr inbounds i8, i8* %36, i64 %93
%95 = load i8, i8* %94
%96 = icmp eq i8 %95, -1
br i1 %96, label %73, label %97
97: ; preds = %83, %78, %73, %91
%98 = load i32, i32* @stderr
%99 = call i32 @fprintf(i32 %98, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.8, i64 0, i64 0))
br label %248
100: ; preds = %88
%101 = getelementptr inbounds i8, i8* %36, i64 4146
%102 = getelementptr inbounds i8, i8* %36, i64 4147
store i8 0, i8* %101
%103 = getelementptr inbounds i8, i8* %36, i64 4148
store i8 21, i8* %102
%104 = getelementptr inbounds i8, i8* %36, i64 4149
store i8 0, i8* %103
store i8 0, i8* %104
%105 = getelementptr inbounds i8, i8* %36, i64 1314864
%106 = call i32 @memcpy(i8* %105, i8* %35, i64 %16)
%107 = icmp ugt i64 %32, 4144
br i1 %107, label %108, label %231
108: ; preds = %100
%109 = add i64 %32, -4144
%110 = icmp ult i64 %109, 8
br i1 %110, label %220, label %111
111: ; preds = %108
%112 = icmp ult i64 %109, 32
br i1 %112, label %200, label %113
113: ; preds = %111
%114 = and i64 %109, -32
%115 = add i64 %114, -32
%116 = lshr exact i64 %115, 5
%117 = add nuw nsw i64 %116, 1
%118 = and i64 %117, 3
%119 = icmp ult i64 %115, 96
br i1 %119, label %166, label %120
120: ; preds = %113
%121 = and i64 %117, 1152921504606846972
br label %122
122: ; preds = %122, %120
%123 = phi i64 [ 0, %120 ], [ %163, %122 ]
%124 = phi <16 x i8> [ zeroinitializer, %120 ], [ %161, %122 ]
%125 = phi <16 x i8> [ zeroinitializer, %120 ], [ %162, %122 ]
%126 = phi i64 [ 0, %120 ], [ %164, %122 ]
%127 = add nuw i64 %123, 4144
%128 = getelementptr inbounds i8, i8* %36, i64 %127
%129 = bitcast i8* %128 to <16 x i8>*
%130 = load <16 x i8>, <16 x i8>* %129
%131 = getelementptr inbounds i8, i8* %128, i64 16
%132 = bitcast i8* %131 to <16 x i8>*
%133 = load <16 x i8>, <16 x i8>* %132
%134 = add <16 x i8> %130, %124
%135 = add <16 x i8> %133, %125
%136 = add nuw i64 %123, 4176
%137 = getelementptr inbounds i8, i8* %36, i64 %136
%138 = bitcast i8* %137 to <16 x i8>*
%139 = load <16 x i8>, <16 x i8>* %138
%140 = getelementptr inbounds i8, i8* %137, i64 16
%141 = bitcast i8* %140 to <16 x i8>*
%142 = load <16 x i8>, <16 x i8>* %141
%143 = add <16 x i8> %139, %134
%144 = add <16 x i8> %142, %135
%145 = add nuw i64 %123, 4208
%146 = getelementptr inbounds i8, i8* %36, i64 %145
%147 = bitcast i8* %146 to <16 x i8>*
%148 = load <16 x i8>, <16 x i8>* %147
%149 = getelementptr inbounds i8, i8* %146, i64 16
%150 = bitcast i8* %149 to <16 x i8>*
%151 = load <16 x i8>, <16 x i8>* %150
%152 = add <16 x i8> %148, %143
%153 = add <16 x i8> %151, %144
%154 = add nuw i64 %123, 4240
%155 = getelementptr inbounds i8, i8* %36, i64 %154
%156 = bitcast i8* %155 to <16 x i8>*
%157 = load <16 x i8>, <16 x i8>* %156
%158 = getelementptr inbounds i8, i8* %155, i64 16
%159 = bitcast i8* %158 to <16 x i8>*
%160 = load <16 x i8>, <16 x i8>* %159
%161 = add <16 x i8> %157, %152
%162 = add <16 x i8> %160, %153
%163 = add nuw i64 %123, 128
%164 = add nuw nsw i64 %126, 4
%165 = icmp eq i64 %164, %121
br i1 %165, label %166, label %122
166: ; preds = %122, %113
%167 = phi <16 x i8> [ undef, %113 ], [ %161, %122 ]
%168 = phi <16 x i8> [ undef, %113 ], [ %162, %122 ]
%169 = phi i64 [ 0, %113 ], [ %163, %122 ]
%170 = phi <16 x i8> [ zeroinitializer, %113 ], [ %161, %122 ]
%171 = phi <16 x i8> [ zeroinitializer, %113 ], [ %162, %122 ]
%172 = icmp eq i64 %118, 0
br i1 %172, label %190, label %173
173: ; preds = %166, %173
%174 = phi i64 [ %187, %173 ], [ %169, %166 ]
%175 = phi <16 x i8> [ %185, %173 ], [ %170, %166 ]
%176 = phi <16 x i8> [ %186, %173 ], [ %171, %166 ]
%177 = phi i64 [ %188, %173 ], [ 0, %166 ]
%178 = add i64 %174, 4144
%179 = getelementptr inbounds i8, i8* %36, i64 %178
%180 = bitcast i8* %179 to <16 x i8>*
%181 = load <16 x i8>, <16 x i8>* %180
%182 = getelementptr inbounds i8, i8* %179, i64 16
%183 = bitcast i8* %182 to <16 x i8>*
%184 = load <16 x i8>, <16 x i8>* %183
%185 = add <16 x i8> %181, %175
%186 = add <16 x i8> %184, %176
%187 = add nuw i64 %174, 32
%188 = add i64 %177, 1
%189 = icmp eq i64 %188, %118
br i1 %189, label %190, label %173
190: ; preds = %173, %166
%191 = phi <16 x i8> [ %167, %166 ], [ %185, %173 ]
%192 = phi <16 x i8> [ %168, %166 ], [ %186, %173 ]
%193 = add <16 x i8> %192, %191
%194 = call i8 @llvm.vector.reduce.add.v16i8(<16 x i8> %193)
%195 = icmp eq i64 %109, %114
br i1 %195, label %231, label %196
196: ; preds = %190
%197 = add i64 %114, 4144
%198 = and i64 %109, 24
%199 = icmp eq i64 %198, 0
br i1 %199, label %220, label %200
200: ; preds = %111, %196
%201 = phi i8 [ 0, %111 ], [ %194, %196 ]
%202 = phi i64 [ 0, %111 ], [ %114, %196 ]
%203 = add i64 %32, -4144
%204 = and i64 %203, -8
%205 = add i64 %204, 4144
%206 = insertelement <8 x i8> <i8 poison, i8 0, i8 0, i8 0, i8 0, i8 0, i8 0, i8 0>, i8 %201, i64 0
br label %207
207: ; preds = %207, %200
%208 = phi i64 [ %202, %200 ], [ %215, %207 ]
%209 = phi <8 x i8> [ %206, %200 ], [ %214, %207 ]
%210 = add i64 %208, 4144
%211 = getelementptr inbounds i8, i8* %36, i64 %210
%212 = bitcast i8* %211 to <8 x i8>*
%213 = load <8 x i8>, <8 x i8>* %212
%214 = add <8 x i8> %213, %209
%215 = add nuw i64 %208, 8
%216 = icmp eq i64 %215, %204
br i1 %216, label %217, label %207
217: ; preds = %207
%218 = call i8 @llvm.vector.reduce.add.v8i8(<8 x i8> %214)
%219 = icmp eq i64 %203, %204
br i1 %219, label %231, label %220
220: ; preds = %108, %196, %217
%221 = phi i64 [ 4144, %108 ], [ %197, %196 ], [ %205, %217 ]
%222 = phi i8 [ 0, %108 ], [ %194, %196 ], [ %218, %217 ]
br label %223
223: ; preds = %220, %223
%224 = phi i64 [ %229, %223 ], [ %221, %220 ]
%225 = phi i8 [ %228, %223 ], [ %222, %220 ]
%226 = getelementptr inbounds i8, i8* %36, i64 %224
%227 = load i8, i8* %226
%228 = add i8 %227, %225
%229 = add nuw nsw i64 %224, 1
%230 = icmp eq i64 %229, %32
br i1 %230, label %231, label %223
231: ; preds = %223, %190, %217, %100
%232 = phi i8 [ 0, %100 ], [ %194, %190 ], [ %218, %217 ], [ %228, %223 ]
%233 = getelementptr inbounds i8, i8* %36, i64 4139
store i8 %232, i8* %233
%234 = call i32* @fopen(i8* %2, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.9, i64 0, i64 0))
%235 = icmp eq i32* %234, null
br i1 %235, label %236, label %238
236: ; preds = %231
%237 = call i32 @perror(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.10, i64 0, i64 0))
br label %248
238: ; preds = %231
%239 = call i64 @fwrite(i8* %36, i32 1, i64 %32, i32* %234)
%240 = icmp ult i64 %239, %32
br i1 %240, label %241, label %244
241: ; preds = %238
%242 = load i32, i32* @stderr
%243 = call i32 @fprintf(i32 %242, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.11, i64 0, i64 0))
br label %248
244: ; preds = %238
%245 = call i32 @fclose(i32* %234)
%246 = call i32 @free(i8* %35)
%247 = call i32 @free(i8* %36)
br label %248
248: ; preds = %244, %241, %236, %97, %70, %61, %49, %40, %27, %21, %11
%249 = phi i32 [ 1, %11 ], [ 1, %21 ], [ 1, %27 ], [ 1, %49 ], [ 1, %61 ], [ 1, %70 ], [ 1, %97 ], [ 1, %236 ], [ 1, %241 ], [ 0, %244 ], [ 1, %40 ]
ret i32 %249
}