#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 uint8_t;
typedef int uint32_t;
typedef int uint16_t;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int fread(char *, int, int, int /*<<< orphan*/ *);
int ftell(int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *, ...);
int read_hexuint8_t(int /*<<< orphan*/ *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ write_record(int, int, int, int /*<<< orphan*/ *, int *);
int read_hex_file(FILE *fp, uint8_t *buffer, uint32_t offset, uint32_t size,
                  int records, FILE *fpo) {
  uint16_t bytes_read;
  char buf[8];
  uint8_t chk;
  uint16_t d;
  uint8_t data[64], i, b, r;
  uint32_t addr = 0;
  uint32_t addr2 = 0;
  uint32_t last_addr = 0xBAD;
  uint32_t high = 0;
  uint8_t *paddr;
  uint8_t *paddr2;
  paddr = (uint8_t *)&addr;
  paddr2 = (uint8_t *)&addr2;
  addr = 0;
  int section_open = 0;
  uint32_t section_addr = 0;
  while (1) {
    do {
      bytes_read = fread(buf, 1, 1, fp);
    } while (bytes_read && (buf[0] != ':'));
    if (!bytes_read) {
      printf("No record.\n");
      return 0;
    }
    i = 0;
    chk = 0;
    do {
      d = read_hexuint8_t(fp);
      chk += d;
      data[i++] = d;
    } while (i < (data[0] + 5));
    if (chk) {
      printf("Checksum error. Got %02X, expected 00.", chk);
      printf("... File position: %ld.\n", ftell(fp));
    }
    switch (data[3]) {
    case 0x01:
      if (section_open) {
        printf("Length of section: %08x\n", last_addr - section_addr);
        if (records) {
          write_record(section_addr, last_addr - section_addr, addr2, fpo,
                       buffer);
        }
      }
      return high;
    case 0x02:
      if (data[0] == 2) {
        addr = 0;
        paddr[1] = data[4];
        paddr[0] = data[5];
        addr <<= 4;
        printf("Segmented address %08X (continuation from: %08X)\n", addr,
               last_addr);
      } else {
        fprintf(stderr, "Segmented address with wrong length.\n");
        return 0;
      }
      break;
    case 0x04:
      if (data[0] == 2) {
        paddr[3] = data[4];
        paddr[2] = data[5];
        printf("Extended address %08X. (continuation from: %08X)\n", addr,
               last_addr);
      } else {
        fprintf(stderr, "Extended address with wrong length.\n");
        return 0;
      }
      break;
    case 0x05:
    case 0x03:
      paddr2[0] = data[7];
      paddr2[1] = data[6];
      paddr2[2] = data[5];
      paddr2[3] = data[4];
      printf("Start address: 0x%08x\n", addr2);
      break;
    case 0x00:
      paddr[0] = data[2];
      paddr[1] = data[1];
      if ((addr < last_addr) || (addr > (last_addr + 32))) {
        if (section_open) {
          printf("Length of section: %08x\n", last_addr - section_addr);
          if (records) {
            write_record(section_addr, last_addr - section_addr, addr2, fpo,
                         buffer);
          }
        }
        printf("Data at new address (new record): 0x%08x\n", addr);
        last_addr = addr;
        section_addr = addr;
        section_open = 1;
        if (records) {
          offset = addr;
        }
      }
      if (addr < offset) {
        fprintf(stderr, "Address too small (0x%X is below offset..)\n", addr);
        return 0;
      }
      if (addr - offset >= size) {
        fprintf(stderr, "Address too big (0x%X is > (size+offset)..)\n", addr);
        return 0;
      }
      for (i = 0; i < data[0]; i++) {
        b = data[4 + i];
        buffer[addr - offset] = b;
        if ((addr - offset) > high)
          high = addr - offset;
        addr++;
      }
      last_addr = addr;
      break;
    default:
      fprintf(stderr, "Unsupported record type %2x.\n", data[3]);
      return 0;
    }
  }
  return high;
}


x86 assembly (clang, -O0):
<read_hex_file>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1a0,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
mov    %ecx,-0x20(%rbp)
mov    %r8d,-0x24(%rbp)
mov    %r9,-0x30(%rbp)
movl   $0x0,-0x160(%rbp)
movl   $0x0,-0x164(%rbp)
movl   $0xbad,-0x168(%rbp)
movl   $0x0,-0x16c(%rbp)
lea    -0x160(%rbp),%rax
mov    %rax,-0x178(%rbp)
lea    -0x164(%rbp),%rax
mov    %rax,-0x180(%rbp)
movl   $0x0,-0x160(%rbp)
movl   $0x0,-0x184(%rbp)
movl   $0x0,-0x188(%rbp)
jmp    11e8 <read_hex_file+0x88>
lea    -0x3c(%rbp),%rdi
mov    -0x10(%rbp),%rcx
mov    $0x1,%edx
mov    %edx,%esi
call   1040 <fread@plt>
mov    %eax,-0x34(%rbp)
xor    %eax,%eax
cmpl   $0x0,-0x34(%rbp)
mov    %al,-0x189(%rbp)
je     1221 <read_hex_file+0xc1>
movsbl -0x3c(%rbp),%eax
cmp    $0x3a,%eax
setne  %al
mov    %al,-0x189(%rbp)
mov    -0x189(%rbp),%al
test   $0x1,%al
jne    11e8 <read_hex_file+0x88>
cmpl   $0x0,-0x34(%rbp)
jne    1253 <read_hex_file+0xf3>
lea    0xdd8(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1707 <read_hex_file+0x5a7>
movl   $0x0,-0x154(%rbp)
movl   $0x0,-0x40(%rbp)
mov    -0x10(%rbp),%rdi
call   1080 <read_hexuint8_t@plt>
mov    %eax,-0x44(%rbp)
mov    -0x44(%rbp),%eax
add    -0x40(%rbp),%eax
mov    %eax,-0x40(%rbp)
mov    -0x44(%rbp),%ecx
mov    -0x154(%rbp),%eax
mov    %eax,%edx
add    $0x1,%edx
mov    %edx,-0x154(%rbp)
cltq
mov    %ecx,-0x150(%rbp,%rax,4)
mov    -0x154(%rbp),%eax
mov    -0x150(%rbp),%ecx
add    $0x5,%ecx
cmp    %ecx,%eax
jl     1264 <read_hex_file+0x104>
cmpl   $0x0,-0x40(%rbp)
je     12e1 <read_hex_file+0x181>
mov    -0x40(%rbp),%esi
lea    0xd63(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x10(%rbp),%rdi
call   1070 <ftell@plt>
mov    %eax,%esi
lea    0xd71(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x144(%rbp),%eax
mov    %rax,-0x198(%rbp)
sub    $0x5,%rax
ja     16d9 <read_hex_file+0x579>
mov    -0x198(%rbp),%rax
lea    0xcfa(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
cmpl   $0x0,-0x184(%rbp)
je     136a <read_hex_file+0x20a>
mov    -0x168(%rbp),%esi
sub    -0x188(%rbp),%esi
lea    0xd35(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
cmpl   $0x0,-0x24(%rbp)
je     1365 <read_hex_file+0x205>
mov    -0x188(%rbp),%edi
mov    -0x168(%rbp),%esi
sub    -0x188(%rbp),%esi
mov    -0x164(%rbp),%edx
mov    -0x30(%rbp),%rcx
mov    -0x18(%rbp),%r8
call   1030 <write_record@plt>
jmp    136a <read_hex_file+0x20a>
mov    -0x16c(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1707 <read_hex_file+0x5a7>
cmpl   $0x2,-0x150(%rbp)
jne    13dc <read_hex_file+0x27c>
movl   $0x0,-0x160(%rbp)
mov    -0x140(%rbp),%ecx
mov    -0x178(%rbp),%rax
mov    %ecx,0x4(%rax)
mov    -0x13c(%rbp),%ecx
mov    -0x178(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x160(%rbp),%eax
shl    $0x4,%eax
mov    %eax,-0x160(%rbp)
mov    -0x160(%rbp),%esi
mov    -0x168(%rbp),%edx
lea    0xcad(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    13ff <read_hex_file+0x29f>
mov    0x2bfd(%rip),%rax
mov    (%rax),%edi
lea    0xcc3(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1707 <read_hex_file+0x5a7>
jmp    1702 <read_hex_file+0x5a2>
cmpl   $0x2,-0x150(%rbp)
jne    1450 <read_hex_file+0x2f0>
mov    -0x140(%rbp),%ecx
mov    -0x178(%rbp),%rax
mov    %ecx,0xc(%rax)
mov    -0x13c(%rbp),%ecx
mov    -0x178(%rbp),%rax
mov    %ecx,0x8(%rax)
mov    -0x160(%rbp),%esi
mov    -0x168(%rbp),%edx
lea    0xc91(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    1473 <read_hex_file+0x313>
mov    0x2b89(%rip),%rax
mov    (%rax),%edi
lea    0xca7(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1707 <read_hex_file+0x5a7>
jmp    1702 <read_hex_file+0x5a2>
mov    -0x134(%rbp),%ecx
mov    -0x180(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x138(%rbp),%ecx
mov    -0x180(%rbp),%rax
mov    %ecx,0x4(%rax)
mov    -0x13c(%rbp),%ecx
mov    -0x180(%rbp),%rax
mov    %ecx,0x8(%rax)
mov    -0x140(%rbp),%ecx
mov    -0x180(%rbp),%rax
mov    %ecx,0xc(%rax)
mov    -0x164(%rbp),%esi
lea    0xc68(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    1702 <read_hex_file+0x5a2>
mov    -0x148(%rbp),%ecx
mov    -0x178(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x14c(%rbp),%ecx
mov    -0x178(%rbp),%rax
mov    %ecx,0x4(%rax)
mov    -0x160(%rbp),%eax
cmp    -0x168(%rbp),%eax
jl     1518 <read_hex_file+0x3b8>
mov    -0x160(%rbp),%eax
mov    -0x168(%rbp),%ecx
add    $0x20,%ecx
cmp    %ecx,%eax
jle    15c1 <read_hex_file+0x461>
cmpl   $0x0,-0x184(%rbp)
je     1573 <read_hex_file+0x413>
mov    -0x168(%rbp),%esi
sub    -0x188(%rbp),%esi
lea    0xb2c(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
cmpl   $0x0,-0x24(%rbp)
je     156e <read_hex_file+0x40e>
mov    -0x188(%rbp),%edi
mov    -0x168(%rbp),%esi
sub    -0x188(%rbp),%esi
mov    -0x164(%rbp),%edx
mov    -0x30(%rbp),%rcx
mov    -0x18(%rbp),%r8
call   1030 <write_record@plt>
jmp    1573 <read_hex_file+0x413>
mov    -0x160(%rbp),%esi
lea    0xbc3(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x160(%rbp),%eax
mov    %eax,-0x168(%rbp)
mov    -0x160(%rbp),%eax
mov    %eax,-0x188(%rbp)
movl   $0x1,-0x184(%rbp)
cmpl   $0x0,-0x24(%rbp)
je     15bc <read_hex_file+0x45c>
mov    -0x160(%rbp),%eax
mov    %eax,-0x1c(%rbp)
jmp    15c1 <read_hex_file+0x461>
mov    -0x160(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    15f9 <read_hex_file+0x499>
mov    0x2a09(%rip),%rax
mov    (%rax),%edi
mov    -0x160(%rbp),%edx
lea    0xb87(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1707 <read_hex_file+0x5a7>
mov    -0x160(%rbp),%eax
sub    -0x1c(%rbp),%eax
cmp    -0x20(%rbp),%eax
jl     1634 <read_hex_file+0x4d4>
mov    0x29ce(%rip),%rax
mov    (%rax),%edi
mov    -0x160(%rbp),%edx
lea    0xb78(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1707 <read_hex_file+0x5a7>
movl   $0x0,-0x154(%rbp)
mov    -0x154(%rbp),%eax
cmp    -0x150(%rbp),%eax
jge    16c8 <read_hex_file+0x568>
mov    -0x154(%rbp),%eax
add    $0x4,%eax
cltq
mov    -0x150(%rbp,%rax,4),%eax
mov    %eax,-0x158(%rbp)
mov    -0x158(%rbp),%edx
mov    -0x18(%rbp),%rax
mov    -0x160(%rbp),%ecx
sub    -0x1c(%rbp),%ecx
movslq %ecx,%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x160(%rbp),%eax
sub    -0x1c(%rbp),%eax
cmp    -0x16c(%rbp),%eax
jle    16a5 <read_hex_file+0x545>
mov    -0x160(%rbp),%eax
sub    -0x1c(%rbp),%eax
mov    %eax,-0x16c(%rbp)
mov    -0x160(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x160(%rbp)
mov    -0x154(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x154(%rbp)
jmp    163e <read_hex_file+0x4de>
mov    -0x160(%rbp),%eax
mov    %eax,-0x168(%rbp)
jmp    1702 <read_hex_file+0x5a2>
mov    0x2900(%rip),%rax
mov    (%rax),%edi
mov    -0x144(%rbp),%edx
lea    0xad7(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1707 <read_hex_file+0x5a7>
jmp    11e3 <read_hex_file+0x83>
mov    -0x4(%rbp),%eax
add    $0x1a0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<read_hex_file>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x158,%rsp
mov    %r9,0x38(%rsp)
mov    %r8d,0x1c(%rsp)
mov    %ecx,0x34(%rsp)
mov    %edx,0xc(%rsp)
mov    %rsi,0x28(%rsp)
mov    %rdi,%r15
mov    $0xbad,%ebp
lea    0x48(%rsp),%r12
movl   $0x0,0x24(%rsp)
movl   $0x0,0x4(%rsp)
xor    %eax,%eax
mov    %rax,0x10(%rsp)
movl   $0x0,0x20(%rsp)
movl   $0x0,0x8(%rsp)
nopl   0x0(%rax)
mov    %r12,%rdi
mov    $0x1,%esi
mov    $0x1,%edx
mov    %r15,%rcx
call   1050 <fread@plt>
test   %eax,%eax
je     1200 <read_hex_file+0x80>
cmpb   $0x3a,0x48(%rsp)
jne    11e0 <read_hex_file+0x60>
test   %eax,%eax
je     1490 <read_hex_file+0x310>
xor    %r14d,%r14d
mov    $0xffffffffffffffff,%r13
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %r15,%rdi
call   1090 <read_hexuint8_t@plt>
add    %eax,%r14d
mov    %eax,0x54(%rsp,%r13,4)
movslq 0x50(%rsp),%rbx
lea    0x4(%rbx),%rax
add    $0x1,%r13
cmp    %rax,%r13
jl     1220 <read_hex_file+0xa0>
test   %r14d,%r14d
je     1270 <read_hex_file+0xf0>
lea    0xdca(%rip),%rdi
mov    %r14d,%esi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %r15,%rdi
call   1080 <ftell@plt>
lea    0xdd8(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %ebx,%ebx
mov    0x5c(%rsp),%edx
cmp    $0x4,%edx
jne    129d <read_hex_file+0x11d>
cmp    $0x2,%ebx
jne    14e2 <read_hex_file+0x362>
lea    0xe3e(%rip),%rdi
mov    0x4(%rsp),%esi
mov    %ebp,%edx
xor    %eax,%eax
call   1060 <printf@plt>
jmp    11e0 <read_hex_file+0x60>
cmp    $0x5,%edx
ja     14fd <read_hex_file+0x37d>
mov    %edx,%eax
lea    0xd51(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    0x6c(%rsp),%esi
lea    0xe5d(%rip),%rdi
mov    %esi,0x24(%rsp)
xor    %eax,%eax
call   1060 <printf@plt>
jmp    11e0 <read_hex_file+0x60>
mov    0x58(%rsp),%r14d
cmp    %ebp,%r14d
jl     130e <read_hex_file+0x18e>
lea    0x20(%rbp),%eax
cmp    %eax,%r14d
jg     130e <read_hex_file+0x18e>
mov    0xc(%rsp),%eax
mov    %r14d,%ebp
jmp    1377 <read_hex_file+0x1f7>
cmp    $0x2,%ebx
jne    152a <read_hex_file+0x3aa>
mov    0x64(%rsp),%esi
shl    $0x4,%esi
lea    0xd69(%rip),%rdi
mov    %esi,0x4(%rsp)
jmp    128f <read_hex_file+0x10f>
cmpl   $0x0,0x20(%rsp)
je     1349 <read_hex_file+0x1c9>
sub    0x8(%rsp),%ebp
lea    0xd38(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1060 <printf@plt>
cmpl   $0x0,0x1c(%rsp)
je     1349 <read_hex_file+0x1c9>
mov    0x8(%rsp),%edi
mov    %ebp,%esi
mov    0x24(%rsp),%edx
mov    0x38(%rsp),%rcx
mov    0x28(%rsp),%r8
call   1040 <write_record@plt>
lea    0xde7(%rip),%rdi
mov    %r14d,%ebp
mov    %r14d,%esi
xor    %eax,%eax
call   1060 <printf@plt>
cmpl   $0x0,0x1c(%rsp)
mov    0xc(%rsp),%eax
cmovne %r14d,%eax
movl   $0x1,0x20(%rsp)
mov    %r14d,0x8(%rsp)
mov    %ebp,%r14d
sub    %eax,%r14d
jl     153c <read_hex_file+0x3bc>
cmp    0x34(%rsp),%r14d
jge    154e <read_hex_file+0x3ce>
mov    %eax,0xc(%rsp)
mov    %ebp,0x4(%rsp)
test   %ebx,%ebx
jle    11e0 <read_hex_file+0x60>
movslq 0x4(%rsp),%rbp
movslq 0xc(%rsp),%rax
mov    %rbp,%rcx
mov    %rax,0x40(%rsp)
sub    %rax,%rcx
mov    0x28(%rsp),%rax
mov    %rcx,%r13
lea    (%rax,%rcx,4),%rdi
lea    0x0(,%rbx,4),%rdx
lea    0x60(%rsp),%rsi
call   10a0 <memcpy@plt>
lea    -0x1(%rbx),%rcx
mov    %ebx,%eax
and    $0x3,%eax
cmp    $0x3,%rcx
jb     1458 <read_hex_file+0x2d8>
mov    %ebx,%r8d
and    $0xfffffffc,%r8d
xor    %edx,%edx
jmp    13f9 <read_hex_file+0x279>
mov    %rcx,0x10(%rsp)
add    $0x4,%rdx
cmp    %rdx,%r8
je     1455 <read_hex_file+0x2d5>
lea    (%rdx,%r13,1),%rsi
mov    0x10(%rsp),%rcx
movslq %ecx,%rdi
cmp    %rdi,%rsi
jle    140e <read_hex_file+0x28e>
lea    (%r14,%rdx,1),%ecx
lea    (%rdx,%r13,1),%rsi
add    $0x1,%rsi
movslq %ecx,%rdi
cmp    %rdi,%rsi
jle    1425 <read_hex_file+0x2a5>
lea    (%r14,%rdx,1),%ecx
add    $0x1,%ecx
lea    (%rdx,%r13,1),%rsi
add    $0x2,%rsi
movslq %ecx,%rdi
cmp    %rdi,%rsi
jle    143c <read_hex_file+0x2bc>
lea    (%r14,%rdx,1),%ecx
add    $0x2,%ecx
lea    (%rdx,%r13,1),%rsi
add    $0x3,%rsi
movslq %ecx,%rdi
cmp    %rdi,%rsi
jle    13eb <read_hex_file+0x26b>
lea    (%r14,%rdx,1),%ecx
add    $0x3,%ecx
jmp    13eb <read_hex_file+0x26b>
add    %rdx,%rbp
test   %rax,%rax
mov    0x10(%rsp),%rcx
je     147a <read_hex_file+0x2fa>
sub    0x40(%rsp),%rbp
movslq %ecx,%rcx
cmp    %rcx,%rbp
cmovg  %ebp,%ecx
add    $0x1,%rbp
add    $0xffffffffffffffff,%rax
jne    1467 <read_hex_file+0x2e7>
mov    %rcx,0x10(%rsp)
mov    0x4(%rsp),%eax
add    %ebx,%eax
mov    %eax,0x4(%rsp)
mov    %eax,%ebp
jmp    11e0 <read_hex_file+0x60>
lea    0xd41(%rip),%rdi
call   1030 <puts@plt>
xor    %ebx,%ebx
jmp    1516 <read_hex_file+0x396>
cmpl   $0x0,0x20(%rsp)
je     14db <read_hex_file+0x35b>
mov    0x8(%rsp),%ebx
sub    %ebx,%ebp
lea    0xba4(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1060 <printf@plt>
cmpl   $0x0,0x1c(%rsp)
je     14db <read_hex_file+0x35b>
mov    %ebx,%edi
mov    %ebp,%esi
mov    0x24(%rsp),%edx
mov    0x38(%rsp),%rcx
mov    0x28(%rsp),%r8
call   1040 <write_record@plt>
mov    0x10(%rsp),%rbx
jmp    1516 <read_hex_file+0x396>
mov    0x2af7(%rip),%rax
mov    (%rax),%edi
lea    0xc09(%rip),%rsi
xor    %ebx,%ebx
xor    %eax,%eax
call   1070 <fprintf@plt>
jmp    1516 <read_hex_file+0x396>
mov    0x2adc(%rip),%rax
mov    (%rax),%edi
lea    0xcad(%rip),%rsi
xor    %ebx,%ebx
xor    %eax,%eax
call   1070 <fprintf@plt>
mov    %ebx,%eax
add    $0x158,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2aaf(%rip),%rax
mov    (%rax),%edi
lea    0xb69(%rip),%rsi
jmp    14f2 <read_hex_file+0x372>
mov    0x2a9d(%rip),%rax
mov    (%rax),%edi
lea    0xc15(%rip),%rsi
jmp    155e <read_hex_file+0x3de>
mov    0x2a8b(%rip),%rax
mov    (%rax),%edi
lea    0xc2f(%rip),%rsi
xor    %ebx,%ebx
mov    %ebp,%edx
jmp    150f <read_hex_file+0x38f>

LLVM IR (-O0):
@.str = [12 x i8] c"No record.\0A\00"
@.str.1 = [39 x i8] c"Checksum error. Got %02X, expected 00.\00"
@.str.2 = [25 x i8] c"... File position: %ld.\0A\00"
@.str.3 = [25 x i8] c"Length of section: %08x\0A\00"
@.str.4 = [50 x i8] c"Segmented address %08X (continuation from: %08X)\0A\00"
@stderr = global i32 0
@.str.5 = [38 x i8] c"Segmented address with wrong length.\0A\00"
@.str.6 = [50 x i8] c"Extended address %08X. (continuation from: %08X)\0A\00"
@.str.7 = [37 x i8] c"Extended address with wrong length.\0A\00"
@.str.8 = [23 x i8] c"Start address: 0x%08x\0A\00"
@.str.9 = [42 x i8] c"Data at new address (new record): 0x%08x\0A\00"
@.str.10 = [44 x i8] c"Address too small (0x%X is below offset..)\0A\00"
@.str.11 = [45 x i8] c"Address too big (0x%X is > (size+offset)..)\0A\00"
@.str.12 = [30 x i8] c"Unsupported record type %2x.\0A\00"
define i32 @read_hex_file(i32* %0, i32* %1, i32 %2, i32 %3, i32 %4, i32* %5) {
%7 = alloca i32
%8 = alloca i32*
%9 = alloca i32*
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32*
%14 = alloca i32
%15 = alloca [8 x i8]
%16 = alloca i32
%17 = alloca i32
%18 = alloca [64 x i32]
%19 = alloca i32
%20 = alloca i32
%21 = alloca i32
%22 = alloca i32
%23 = alloca i32
%24 = alloca i32
%25 = alloca i32
%26 = alloca i32*
%27 = alloca i32*
%28 = alloca i32
%29 = alloca i32
store i32* %0, i32** %8
store i32* %1, i32** %9
store i32 %2, i32* %10
store i32 %3, i32* %11
store i32 %4, i32* %12
store i32* %5, i32** %13
store i32 0, i32* %22
store i32 0, i32* %23
store i32 2989, i32* %24
store i32 0, i32* %25
store i32* %22, i32** %26
store i32* %23, i32** %27
store i32 0, i32* %22
store i32 0, i32* %28
store i32 0, i32* %29
br label %30
30: ; preds = %6, %269
br label %31
31: ; preds = %43, %30
%32 = getelementptr inbounds [8 x i8], [8 x i8]* %15, i64 0, i64 0
%33 = load i32*, i32** %8
%34 = call i32 @fread(i8* %32, i32 1, i32 1, i32* %33)
store i32 %34, i32* %14
br label %35
35: ; preds = %31
%36 = load i32, i32* %14
%37 = icmp ne i32 %36, 0
br i1 %37, label %38, label %43
38: ; preds = %35
%39 = getelementptr inbounds [8 x i8], [8 x i8]* %15, i64 0, i64 0
%40 = load i8, i8* %39
%41 = sext i8 %40 to i32
%42 = icmp ne i32 %41, 58
br label %43
43: ; preds = %38, %35
%44 = phi i1 [ false, %35 ], [ %42, %38 ]
br i1 %44, label %31, label %45
45: ; preds = %43
%46 = load i32, i32* %14
%47 = icmp ne i32 %46, 0
br i1 %47, label %50, label %48
48: ; preds = %45
%49 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %7
br label %270
50: ; preds = %45
store i32 0, i32* %19
store i32 0, i32* %16
br label %51
51: ; preds = %62, %50
%52 = load i32*, i32** %8
%53 = call i32 @read_hexuint8_t(i32* %52)
store i32 %53, i32* %17
%54 = load i32, i32* %17
%55 = load i32, i32* %16
%56 = add nsw i32 %55, %54
store i32 %56, i32* %16
%57 = load i32, i32* %17
%58 = load i32, i32* %19
%59 = add nsw i32 %58, 1
store i32 %59, i32* %19
%60 = sext i32 %58 to i64
%61 = getelementptr inbounds [64 x i32], [64 x i32]* %18, i64 0, i64 %60
store i32 %57, i32* %61
br label %62
62: ; preds = %51
%63 = load i32, i32* %19
%64 = getelementptr inbounds [64 x i32], [64 x i32]* %18, i64 0, i64 0
%65 = load i32, i32* %64
%66 = add nsw i32 %65, 5
%67 = icmp slt i32 %63, %66
br i1 %67, label %51, label %68
68: ; preds = %62
%69 = load i32, i32* %16
%70 = icmp ne i32 %69, 0
br i1 %70, label %71, label %77
71: ; preds = %68
%72 = load i32, i32* %16
%73 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.1, i64 0, i64 0), i32 %72)
%74 = load i32*, i32** %8
%75 = call i32 @ftell(i32* %74)
%76 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0), i32 %75)
br label %77
77: ; preds = %71, %68
%78 = getelementptr inbounds [64 x i32], [64 x i32]* %18, i64 0, i64 3
%79 = load i32, i32* %78
switch i32 %79, label %264 [
i32 1, label %80
i32 2, label %102
i32 4, label %124
i32 5, label %144
i32 3, label %144
i32 0, label %163
]
80: ; preds = %77
%81 = load i32, i32* %28
%82 = icmp ne i32 %81, 0
br i1 %82, label %83, label %100
83: ; preds = %80
%84 = load i32, i32* %24
%85 = load i32, i32* %29
%86 = sub nsw i32 %84, %85
%87 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.3, i64 0, i64 0), i32 %86)
%88 = load i32, i32* %12
%89 = icmp ne i32 %88, 0
br i1 %89, label %90, label %99
90: ; preds = %83
%91 = load i32, i32* %29
%92 = load i32, i32* %24
%93 = load i32, i32* %29
%94 = sub nsw i32 %92, %93
%95 = load i32, i32* %23
%96 = load i32*, i32** %13
%97 = load i32*, i32** %9
%98 = call i32 @write_record(i32 %91, i32 %94, i32 %95, i32* %96, i32* %97)
br label %99
99: ; preds = %90, %83
br label %100
100: ; preds = %99, %80
%101 = load i32, i32* %25
store i32 %101, i32* %7
br label %270
102: ; preds = %77
%103 = getelementptr inbounds [64 x i32], [64 x i32]* %18, i64 0, i64 0
%104 = load i32, i32* %103
%105 = icmp eq i32 %104, 2
br i1 %105, label %106, label %120
106: ; preds = %102
store i32 0, i32* %22
%107 = getelementptr inbounds [64 x i32], [64 x i32]* %18, i64 0, i64 4
%108 = load i32, i32* %107
%109 = load i32*, i32** %26
%110 = getelementptr inbounds i32, i32* %109, i64 1
store i32 %108, i32* %110
%111 = getelementptr inbounds [64 x i32], [64 x i32]* %18, i64 0, i64 5
%112 = load i32, i32* %111
%113 = load i32*, i32** %26
%114 = getelementptr inbounds i32, i32* %113, i64 0
store i32 %112, i32* %114
%115 = load i32, i32* %22
%116 = shl i32 %115, 4
store i32 %116, i32* %22
%117 = load i32, i32* %22
%118 = load i32, i32* %24
%119 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.4, i64 0, i64 0), i32 %117, i32 %118)
br label %123
120: ; preds = %102
%121 = load i32, i32* @stderr
%122 = call i32 (i32, i8*, ...) @fprintf(i32 %121, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.5, i64 0, i64 0))
store i32 0, i32* %7
br label %270
123: ; preds = %106
br label %269
124: ; preds = %77
%125 = getelementptr inbounds [64 x i32], [64 x i32]* %18, i64 0, i64 0
%126 = load i32, i32* %125
%127 = icmp eq i32 %126, 2
br i1 %127, label %128, label %140
128: ; preds = %124
%129 = getelementptr inbounds [64 x i32], [64 x i32]* %18, i64 0, i64 4
%130 = load i32, i32* %129
%131 = load i32*, i32** %26
%132 = getelementptr inbounds i32, i32* %131, i64 3
store i32 %130, i32* %132
%133 = getelementptr inbounds [64 x i32], [64 x i32]* %18, i64 0, i64 5
%134 = load i32, i32* %133
%135 = load i32*, i32** %26
%136 = getelementptr inbounds i32, i32* %135, i64 2
store i32 %134, i32* %136
%137 = load i32, i32* %22
%138 = load i32, i32* %24
%139 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.6, i64 0, i64 0), i32 %137, i32 %138)
br label %143
140: ; preds = %124
%141 = load i32, i32* @stderr
%142 = call i32 (i32, i8*, ...) @fprintf(i32 %141, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.7, i64 0, i64 0))
store i32 0, i32* %7
br label %270
143: ; preds = %128
br label %269
144: ; preds = %77, %77
%145 = getelementptr inbounds [64 x i32], [64 x i32]* %18, i64 0, i64 7
%146 = load i32, i32* %145
%147 = load i32*, i32** %27
%148 = getelementptr inbounds i32, i32* %147, i64 0
store i32 %146, i32* %148
%149 = getelementptr inbounds [64 x i32], [64 x i32]* %18, i64 0, i64 6
%150 = load i32, i32* %149
%151 = load i32*, i32** %27
%152 = getelementptr inbounds i32, i32* %151, i64 1
store i32 %150, i32* %152
%153 = getelementptr inbounds [64 x i32], [64 x i32]* %18, i64 0, i64 5
%154 = load i32, i32* %153
%155 = load i32*, i32** %27
%156 = getelementptr inbounds i32, i32* %155, i64 2
store i32 %154, i32* %156
%157 = getelementptr inbounds [64 x i32], [64 x i32]* %18, i64 0, i64 4
%158 = load i32, i32* %157
%159 = load i32*, i32** %27
%160 = getelementptr inbounds i32, i32* %159, i64 3
store i32 %158, i32* %160
%161 = load i32, i32* %23
%162 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.8, i64 0, i64 0), i32 %161)
br label %269
163: ; preds = %77
%164 = getelementptr inbounds [64 x i32], [64 x i32]* %18, i64 0, i64 2
%165 = load i32, i32* %164
%166 = load i32*, i32** %26
%167 = getelementptr inbounds i32, i32* %166, i64 0
store i32 %165, i32* %167
%168 = getelementptr inbounds [64 x i32], [64 x i32]* %18, i64 0, i64 1
%169 = load i32, i32* %168
%170 = load i32*, i32** %26
%171 = getelementptr inbounds i32, i32* %170, i64 1
store i32 %169, i32* %171
%172 = load i32, i32* %22
%173 = load i32, i32* %24
%174 = icmp slt i32 %172, %173
br i1 %174, label %180, label %175
175: ; preds = %163
%176 = load i32, i32* %22
%177 = load i32, i32* %24
%178 = add nsw i32 %177, 32
%179 = icmp sgt i32 %176, %178
br i1 %179, label %180, label %210
180: ; preds = %175, %163
%181 = load i32, i32* %28
%182 = icmp ne i32 %181, 0
br i1 %182, label %183, label %200
183: ; preds = %180
%184 = load i32, i32* %24
%185 = load i32, i32* %29
%186 = sub nsw i32 %184, %185
%187 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.3, i64 0, i64 0), i32 %186)
%188 = load i32, i32* %12
%189 = icmp ne i32 %188, 0
br i1 %189, label %190, label %199
190: ; preds = %183
%191 = load i32, i32* %29
%192 = load i32, i32* %24
%193 = load i32, i32* %29
%194 = sub nsw i32 %192, %193
%195 = load i32, i32* %23
%196 = load i32*, i32** %13
%197 = load i32*, i32** %9
%198 = call i32 @write_record(i32 %191, i32 %194, i32 %195, i32* %196, i32* %197)
br label %199
199: ; preds = %190, %183
br label %200
200: ; preds = %199, %180
%201 = load i32, i32* %22
%202 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.9, i64 0, i64 0), i32 %201)
%203 = load i32, i32* %22
store i32 %203, i32* %24
%204 = load i32, i32* %22
store i32 %204, i32* %29
store i32 1, i32* %28
%205 = load i32, i32* %12
%206 = icmp ne i32 %205, 0
br i1 %206, label %207, label %209
207: ; preds = %200
%208 = load i32, i32* %22
store i32 %208, i32* %10
br label %209
209: ; preds = %207, %200
br label %210
210: ; preds = %209, %175
%211 = load i32, i32* %22
%212 = load i32, i32* %10
%213 = icmp slt i32 %211, %212
br i1 %213, label %214, label %218
214: ; preds = %210
%215 = load i32, i32* @stderr
%216 = load i32, i32* %22
%217 = call i32 (i32, i8*, ...) @fprintf(i32 %215, i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.10, i64 0, i64 0), i32 %216)
store i32 0, i32* %7
br label %270
218: ; preds = %210
%219 = load i32, i32* %22
%220 = load i32, i32* %10
%221 = sub nsw i32 %219, %220
%222 = load i32, i32* %11
%223 = icmp sge i32 %221, %222
br i1 %223, label %224, label %228
224: ; preds = %218
%225 = load i32, i32* @stderr
%226 = load i32, i32* %22
%227 = call i32 (i32, i8*, ...) @fprintf(i32 %225, i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.11, i64 0, i64 0), i32 %226)
store i32 0, i32* %7
br label %270
228: ; preds = %218
store i32 0, i32* %19
br label %229
229: ; preds = %259, %228
%230 = load i32, i32* %19
%231 = getelementptr inbounds [64 x i32], [64 x i32]* %18, i64 0, i64 0
%232 = load i32, i32* %231
%233 = icmp slt i32 %230, %232
br i1 %233, label %234, label %262
234: ; preds = %229
%235 = load i32, i32* %19
%236 = add nsw i32 4, %235
%237 = sext i32 %236 to i64
%238 = getelementptr inbounds [64 x i32], [64 x i32]* %18, i64 0, i64 %237
%239 = load i32, i32* %238
store i32 %239, i32* %20
%240 = load i32, i32* %20
%241 = load i32*, i32** %9
%242 = load i32, i32* %22
%243 = load i32, i32* %10
%244 = sub nsw i32 %242, %243
%245 = sext i32 %244 to i64
%246 = getelementptr inbounds i32, i32* %241, i64 %245
store i32 %240, i32* %246
%247 = load i32, i32* %22
%248 = load i32, i32* %10
%249 = sub nsw i32 %247, %248
%250 = load i32, i32* %25
%251 = icmp sgt i32 %249, %250
br i1 %251, label %252, label %256
252: ; preds = %234
%253 = load i32, i32* %22
%254 = load i32, i32* %10
%255 = sub nsw i32 %253, %254
store i32 %255, i32* %25
br label %256
256: ; preds = %252, %234
%257 = load i32, i32* %22
%258 = add nsw i32 %257, 1
store i32 %258, i32* %22
br label %259
259: ; preds = %256
%260 = load i32, i32* %19
%261 = add nsw i32 %260, 1
store i32 %261, i32* %19
br label %229
262: ; preds = %229
%263 = load i32, i32* %22
store i32 %263, i32* %24
br label %269
264: ; preds = %77
%265 = load i32, i32* @stderr
%266 = getelementptr inbounds [64 x i32], [64 x i32]* %18, i64 0, i64 3
%267 = load i32, i32* %266
%268 = call i32 (i32, i8*, ...) @fprintf(i32 %265, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.12, i64 0, i64 0), i32 %267)
store i32 0, i32* %7
br label %270
269: ; preds = %262, %144, %143, %123
br label %30
270: ; preds = %264, %224, %214, %140, %120, %100, %48
%271 = load i32, i32* %7
ret i32 %271
}

LLVM IR (-O2):
@.str.1 = [39 x i8] c"Checksum error. Got %02X, expected 00.\00"
@.str.2 = [25 x i8] c"... File position: %ld.\0A\00"
@.str.3 = [25 x i8] c"Length of section: %08x\0A\00"
@.str.4 = [50 x i8] c"Segmented address %08X (continuation from: %08X)\0A\00"
@stderr = global i32 0
@.str.5 = [38 x i8] c"Segmented address with wrong length.\0A\00"
@.str.6 = [50 x i8] c"Extended address %08X. (continuation from: %08X)\0A\00"
@.str.7 = [37 x i8] c"Extended address with wrong length.\0A\00"
@.str.8 = [23 x i8] c"Start address: 0x%08x\0A\00"
@.str.9 = [42 x i8] c"Data at new address (new record): 0x%08x\0A\00"
@.str.10 = [44 x i8] c"Address too small (0x%X is below offset..)\0A\00"
@.str.11 = [45 x i8] c"Address too big (0x%X is > (size+offset)..)\0A\00"
@.str.12 = [30 x i8] c"Unsupported record type %2x.\0A\00"
@str = [11 x i8] c"No record.\00"
define i32 @read_hex_file(i32* %0, i32* %1, i32 %2, i32 %3, i32 %4, i32* %5) {
%7 = alloca [8 x i8]
%8 = alloca [64 x i32]
%9 = getelementptr inbounds [8 x i8], [8 x i8]* %7, i64 0, i64 0
%10 = bitcast [64 x i32]* %8 to i8*
%11 = getelementptr inbounds [64 x i32], [64 x i32]* %8, i64 0, i64 0
%12 = getelementptr inbounds [64 x i32], [64 x i32]* %8, i64 0, i64 3
%13 = getelementptr inbounds [64 x i32], [64 x i32]* %8, i64 0, i64 2
%14 = icmp eq i32 %4, 0
%15 = getelementptr inbounds [64 x i32], [64 x i32]* %8, i64 0, i64 7
%16 = getelementptr inbounds [64 x i32], [64 x i32]* %8, i64 0, i64 5
%17 = getelementptr inbounds [64 x i32], [64 x i32]* %8, i64 0, i64 4
%18 = bitcast i32* %17 to i8*
br label %19
19: ; preds = %94, %6
%20 = phi i32 [ %95, %94 ], [ 0, %6 ]
%21 = phi i32 [ %41, %94 ], [ 0, %6 ]
%22 = phi i32 [ %36, %94 ], [ 2989, %6 ]
%23 = phi i32 [ %30, %94 ], [ 0, %6 ]
%24 = phi i32 [ %37, %94 ], [ %2, %6 ]
%25 = phi i32 [ %38, %94 ], [ 0, %6 ]
%26 = phi i32 [ %39, %94 ], [ 0, %6 ]
br label %27
27: ; preds = %19, %192
%28 = phi i32 [ %21, %19 ], [ %194, %192 ]
%29 = phi i32 [ %22, %19 ], [ %194, %192 ]
%30 = phi i32 [ %23, %19 ], [ %193, %192 ]
%31 = phi i32 [ %24, %19 ], [ %114, %192 ]
%32 = phi i32 [ %25, %19 ], [ %115, %192 ]
%33 = phi i32 [ %26, %19 ], [ %116, %192 ]
br label %34
34: ; preds = %27, %124
%35 = phi i32 [ %98, %124 ], [ %28, %27 ]
%36 = phi i32 [ %98, %124 ], [ %29, %27 ]
%37 = phi i32 [ %114, %124 ], [ %31, %27 ]
%38 = phi i32 [ %115, %124 ], [ %32, %27 ]
%39 = phi i32 [ %116, %124 ], [ %33, %27 ]
br label %40
40: ; preds = %34, %80
%41 = phi i32 [ %82, %80 ], [ %35, %34 ]
br label %42
42: ; preds = %40, %89
br label %43
43: ; preds = %43, %42
%44 = call i32 @fread(i8* %9, i32 1, i32 1, i32* %0)
%45 = icmp ne i32 %44, 0
%46 = load i8, i8* %9
%47 = icmp ne i8 %46, 58
%48 = select i1 %45, i1 %47, i1 false
br i1 %48, label %43, label %49
49: ; preds = %43
br i1 %45, label %52, label %50
50: ; preds = %49
%51 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @str, i64 0, i64 0))
br label %195
52: ; preds = %49, %52
%53 = phi i64 [ %57, %52 ], [ 0, %49 ]
%54 = phi i32 [ %56, %52 ], [ 0, %49 ]
%55 = tail call i32 @read_hexuint8_t(i32* %0)
%56 = add nsw i32 %55, %54
%57 = add nuw nsw i64 %53, 1
%58 = getelementptr inbounds [64 x i32], [64 x i32]* %8, i64 0, i64 %53
store i32 %55, i32* %58
%59 = load i32, i32* %11
%60 = add nsw i32 %59, 4
%61 = sext i32 %60 to i64
%62 = icmp slt i64 %53, %61
br i1 %62, label %52, label %63
63: ; preds = %52
%64 = icmp eq i32 %56, 0
br i1 %64, label %69, label %65
65: ; preds = %63
%66 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @.str.1, i64 0, i64 0), i32 %56)
%67 = tail call i32 @ftell(i32* %0)
%68 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0), i32 %67)
br label %69
69: ; preds = %65, %63
%70 = load i32, i32* %12
switch i32 %70, label %172 [
i32 1, label %71
i32 2, label %78
i32 4, label %87
i32 5, label %94
i32 3, label %94
i32 0, label %97
]
71: ; preds = %69
%72 = icmp eq i32 %38, 0
br i1 %72, label %195, label %73
73: ; preds = %71
%74 = sub nsw i32 %36, %39
%75 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.3, i64 0, i64 0), i32 %74)
br i1 %14, label %195, label %76
76: ; preds = %73
%77 = tail call i32 @write_record(i32 %39, i32 %74, i32 %20, i32* %5, i32* %1)
br label %195
78: ; preds = %69
%79 = icmp eq i32 %59, 2
br i1 %79, label %80, label %84
80: ; preds = %78
%81 = load i32, i32* %16
%82 = shl i32 %81, 4
%83 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([50 x i8], [50 x i8]* @.str.4, i64 0, i64 0), i32 %82, i32 %36)
br label %40
84: ; preds = %78
%85 = load i32, i32* @stderr
%86 = tail call i32 (i32, i8*, ...) @fprintf(i32 %85, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.5, i64 0, i64 0))
br label %195
87: ; preds = %69
%88 = icmp eq i32 %59, 2
br i1 %88, label %89, label %91
89: ; preds = %87
%90 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([50 x i8], [50 x i8]* @.str.6, i64 0, i64 0), i32 %41, i32 %36)
br label %42
91: ; preds = %87
%92 = load i32, i32* @stderr
%93 = tail call i32 (i32, i8*, ...) @fprintf(i32 %92, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.7, i64 0, i64 0))
br label %195
94: ; preds = %69, %69
%95 = load i32, i32* %15
%96 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.8, i64 0, i64 0), i32 %95)
br label %19
97: ; preds = %69
%98 = load i32, i32* %13
%99 = icmp slt i32 %98, %36
%100 = add nsw i32 %36, 32
%101 = icmp sgt i32 %98, %100
%102 = select i1 %99, i1 true, i1 %101
br i1 %102, label %103, label %113
103: ; preds = %97
%104 = icmp eq i32 %38, 0
br i1 %104, label %110, label %105
105: ; preds = %103
%106 = sub nsw i32 %36, %39
%107 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.3, i64 0, i64 0), i32 %106)
br i1 %14, label %110, label %108
108: ; preds = %105
%109 = tail call i32 @write_record(i32 %39, i32 %106, i32 %20, i32* %5, i32* %1)
br label %110
110: ; preds = %105, %108, %103
%111 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([42 x i8], [42 x i8]* @.str.9, i64 0, i64 0), i32 %98)
%112 = select i1 %14, i32 %37, i32 %98
br label %113
113: ; preds = %110, %97
%114 = phi i32 [ %37, %97 ], [ %112, %110 ]
%115 = phi i32 [ %38, %97 ], [ 1, %110 ]
%116 = phi i32 [ %39, %97 ], [ %98, %110 ]
%117 = icmp slt i32 %98, %114
br i1 %117, label %118, label %121
118: ; preds = %113
%119 = load i32, i32* @stderr
%120 = tail call i32 (i32, i8*, ...) @fprintf(i32 %119, i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.10, i64 0, i64 0), i32 %98)
br label %195
121: ; preds = %113
%122 = sub nsw i32 %98, %114
%123 = icmp slt i32 %122, %3
br i1 %123, label %124, label %139
124: ; preds = %121
%125 = icmp sgt i32 %59, 0
br i1 %125, label %126, label %34
126: ; preds = %124
%127 = sext i32 %98 to i64
%128 = sext i32 %114 to i64
%129 = sub nsw i64 %127, %128
%130 = getelementptr i32, i32* %1, i64 %129
%131 = bitcast i32* %130 to i8*
%132 = zext i32 %59 to i64
%133 = shl nuw nsw i64 %132, 2
%134 = add nsw i64 %132, -1
%135 = and i64 %132, 3
%136 = icmp ult i64 %134, 3
br i1 %136, label %175, label %137
137: ; preds = %126
%138 = and i64 %132, 4294967292
br label %142
139: ; preds = %121
%140 = load i32, i32* @stderr
%141 = tail call i32 (i32, i8*, ...) @fprintf(i32 %140, i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.11, i64 0, i64 0), i32 %98)
br label %195
142: ; preds = %142, %137
%143 = phi i64 [ %127, %137 ], [ %169, %142 ]
%144 = phi i32 [ %30, %137 ], [ %168, %142 ]
%145 = phi i64 [ 0, %137 ], [ %170, %142 ]
%146 = sub nsw i64 %143, %128
%147 = sext i32 %144 to i64
%148 = icmp sgt i64 %146, %147
%149 = trunc i64 %146 to i32
%150 = select i1 %148, i32 %149, i32 %144
%151 = add nsw i64 %143, 1
%152 = sub nsw i64 %151, %128
%153 = sext i32 %150 to i64
%154 = icmp sgt i64 %152, %153
%155 = trunc i64 %152 to i32
%156 = select i1 %154, i32 %155, i32 %150
%157 = add nsw i64 %143, 2
%158 = sub nsw i64 %157, %128
%159 = sext i32 %156 to i64
%160 = icmp sgt i64 %158, %159
%161 = trunc i64 %158 to i32
%162 = select i1 %160, i32 %161, i32 %156
%163 = add nsw i64 %143, 3
%164 = sub nsw i64 %163, %128
%165 = sext i32 %162 to i64
%166 = icmp sgt i64 %164, %165
%167 = trunc i64 %164 to i32
%168 = select i1 %166, i32 %167, i32 %162
%169 = add nsw i64 %143, 4
%170 = add i64 %145, 4
%171 = icmp eq i64 %170, %138
br i1 %171, label %175, label %142
172: ; preds = %69
%173 = load i32, i32* @stderr
%174 = tail call i32 (i32, i8*, ...) @fprintf(i32 %173, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.12, i64 0, i64 0), i32 %70)
br label %195
175: ; preds = %142, %126
%176 = phi i32 [ undef, %126 ], [ %168, %142 ]
%177 = phi i64 [ %127, %126 ], [ %169, %142 ]
%178 = phi i32 [ %30, %126 ], [ %168, %142 ]
%179 = icmp eq i64 %135, 0
br i1 %179, label %192, label %180
180: ; preds = %175, %180
%181 = phi i64 [ %189, %180 ], [ %177, %175 ]
%182 = phi i32 [ %188, %180 ], [ %178, %175 ]
%183 = phi i64 [ %190, %180 ], [ 0, %175 ]
%184 = sub nsw i64 %181, %128
%185 = sext i32 %182 to i64
%186 = icmp sgt i64 %184, %185
%187 = trunc i64 %184 to i32
%188 = select i1 %186, i32 %187, i32 %182
%189 = add nsw i64 %181, 1
%190 = add i64 %183, 1
%191 = icmp eq i64 %190, %135
br i1 %191, label %192, label %180
192: ; preds = %180, %175
%193 = phi i32 [ %176, %175 ], [ %188, %180 ]
%194 = add i32 %98, %59
br label %27
195: ; preds = %71, %76, %73, %172, %139, %118, %91, %84, %50
%196 = phi i32 [ 0, %172 ], [ 0, %118 ], [ 0, %139 ], [ 0, %91 ], [ 0, %84 ], [ 0, %50 ], [ %30, %73 ], [ %30, %76 ], [ %30, %71 ]
ret i32 %196
}