#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 */
typedef struct TYPE_5__ TYPE_1__;

/* Type definitions */
struct TYPE_5__ {
  int *e_ident;
  int e_ehsize;
  int e_phoff;
  int e_phnum;
  int e_phentsize;
  int p_offset;
  int p_filesz;
  int e_shoff;
  int e_shnum;
  int e_shentsize;
  scalar_t__ sh_type;
  int sh_offset;
  int sh_size;
};
typedef int Elf32_Word;
typedef TYPE_1__ Elf32_Shdr;
typedef TYPE_1__ Elf32_Phdr;
typedef TYPE_1__ Elf32_Ehdr;

/* Variables and functions */
size_t EI_MAG0;
size_t EI_MAG1;
size_t EI_MAG2;
size_t EI_MAG3;
scalar_t__ SHT_NOBITS;
void *memcpy(TYPE_1__ *, unsigned char *, int);
int /*<<< orphan*/ printf(char *, ...);
int find_unused_bytes(unsigned char *elf_file, size_t len) {
  Elf32_Word elf_sz = 0;
  Elf32_Ehdr elf_hdr;
  Elf32_Shdr shdr;
  Elf32_Phdr phdr;
  void *ptr = NULL;
  size_t highest = 0;
  int i = 0;
  int j = 0;
  int unused_count = 0;
  int debug = 0;
  unsigned char is_used[len];
  for (i = 0; i < len; i++)
    is_used[i] = 0;
  ptr = memcpy(&elf_hdr, elf_file, sizeof(Elf32_Ehdr));
  if (ptr == NULL) {
    if (debug)
      printf("[-] memcpy failed\n");
    return -1;
  }
  if (elf_hdr.e_ident[EI_MAG0] != 0x7f || elf_hdr.e_ident[EI_MAG1] != 0x45 ||
      elf_hdr.e_ident[EI_MAG2] != 0x4c || elf_hdr.e_ident[EI_MAG3] != 0x46) {
    if (debug)
      printf("[-] input file does not appear to be a ELF file\n");
    return -1;
  }
  elf_sz += elf_hdr.e_ehsize;
  for (j = 0; j < elf_hdr.e_ehsize; j++)
    is_used[j] = 1;
  if (highest < elf_hdr.e_ehsize)
    highest = elf_hdr.e_ehsize;
  if (debug)
    printf("[+] ELF header size: 0x%08x\n", elf_hdr.e_ehsize);
  if (elf_hdr.e_phoff != 0) {
    if (debug)
      printf("[+] found program header table: 0x%08x - 0x%08x\n",
             elf_hdr.e_phoff,
             elf_hdr.e_phoff + ((elf_hdr.e_phnum) * (elf_hdr.e_phentsize)));
    for (j = elf_hdr.e_phoff;
         j < elf_hdr.e_phoff + (elf_hdr.e_phnum) * (elf_hdr.e_phentsize); j++)
      is_used[j] = 2;
    if (highest < elf_hdr.e_phoff + ((elf_hdr.e_phnum) * (elf_hdr.e_phentsize)))
      highest = elf_hdr.e_phoff + ((elf_hdr.e_phnum) * (elf_hdr.e_phentsize));
    elf_sz += ((elf_hdr.e_phnum) * (elf_hdr.e_phentsize));
    if (debug)
      printf("PHT size: 0x%08x\n", (elf_hdr.e_phnum) * (elf_hdr.e_phentsize));
    for (i = 0; i < elf_hdr.e_phnum; i++) {
      ptr =
          memcpy(&phdr, elf_file + elf_hdr.e_phoff + (elf_hdr.e_phentsize) * i,
                 sizeof(Elf32_Phdr));
      if (debug)
        printf("\tsegment[%d] @ 0x%08x: size 0x%08x\n", i, phdr.p_offset,
               phdr.p_filesz);
    }
  }
  if (elf_hdr.e_shoff != 0) {
    if (debug)
      printf("[+] found section header table @ 0x%08x (%d sections)\n",
             elf_hdr.e_shoff, elf_hdr.e_shnum);
    for (j = elf_hdr.e_shoff;
         j < elf_hdr.e_shoff + (elf_hdr.e_shnum) * (elf_hdr.e_shentsize); j++)
      is_used[j] = 3;
    if (highest < elf_hdr.e_shoff + ((elf_hdr.e_shnum) * (elf_hdr.e_shentsize)))
      highest = elf_hdr.e_shoff + ((elf_hdr.e_shnum) * (elf_hdr.e_shentsize));
    elf_sz += ((elf_hdr.e_shnum) * (elf_hdr.e_shentsize));
    if (debug)
      printf("[+] SHT size: 0x%08x\n",
             (elf_hdr.e_shnum) * (elf_hdr.e_shentsize));
    for (i = 0; i < elf_hdr.e_shnum; i++) {
      ptr =
          memcpy(&shdr, elf_file + elf_hdr.e_shoff + (elf_hdr.e_shentsize) * i,
                 sizeof(Elf32_Shdr));
      if (shdr.sh_type == SHT_NOBITS) {
        if (debug)
          printf("\tsection[%d] @ 0x%08x: size 0x%08x (NOBITS)\n", i,
                 shdr.sh_offset, shdr.sh_size);
      } else {
        if (debug)
          printf("\tsection[%d] @ 0x%08x: size 0x%08x\n", i, shdr.sh_offset,
                 shdr.sh_size);
        if (highest < shdr.sh_offset + shdr.sh_size)
          highest = shdr.sh_offset + shdr.sh_size;
        elf_sz += shdr.sh_size;
        for (j = shdr.sh_offset; j < shdr.sh_offset + shdr.sh_size; j++)
          is_used[j] = 4;
      }
    }
  }
  if (debug)
    printf("[+] final size is %d\n", elf_sz);
  if (debug)
    printf("[+] highest byte referenced: %d\n", highest);
  for (i = 0; i < len; i++) {
    if (is_used[i] == 0) {
      printf(".");
      unused_count++;
    } else if (is_used[i] == 1)
      printf("H");
    else if (is_used[i] == 2)
      printf("P");
    else if (is_used[i] == 3)
      printf("S");
    else if (is_used[i] == 4)
      printf("s");
    else
      printf("X");
  }
  return unused_count;
}


x86 assembly (clang, -O0):
<find_unused_bytes>:
push   %rbp
mov    %rsp,%rbp
sub    $0x120,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
movq   $0x0,-0xe8(%rbp)
movq   $0x0,-0xf0(%rbp)
movl   $0x0,-0xf4(%rbp)
movl   $0x0,-0xf8(%rbp)
movl   $0x0,-0xfc(%rbp)
movl   $0x0,-0x100(%rbp)
mov    -0x18(%rbp),%rax
mov    %rsp,%rcx
mov    %rcx,-0x108(%rbp)
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x120(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x110(%rbp)
movl   $0x0,-0xf4(%rbp)
movslq -0xf4(%rbp),%rax
cmp    -0x18(%rbp),%rax
jae    11e9 <find_unused_bytes+0xc9>
mov    -0x120(%rbp),%rax
movslq -0xf4(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0xf4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xf4(%rbp)
jmp    11b2 <find_unused_bytes+0x92>
mov    -0x10(%rbp),%rsi
lea    -0x60(%rbp),%rdi
mov    $0x40,%edx
call   1040 <memcpy@plt>
mov    %rax,-0xe8(%rbp)
cmpq   $0x0,-0xe8(%rbp)
jne    1241 <find_unused_bytes+0x121>
cmpl   $0x0,-0x100(%rbp)
je     122b <find_unused_bytes+0x10b>
lea    0xddc(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
movl   $0x1,-0x114(%rbp)
jmp    188b <find_unused_bytes+0x76b>
mov    -0x60(%rbp),%rax
mov    0x2d9c(%rip),%rcx
mov    (%rcx),%rcx
cmpl   $0x7f,(%rax,%rcx,4)
jne    12a1 <find_unused_bytes+0x181>
mov    -0x60(%rbp),%rax
mov    0x2d64(%rip),%rcx
mov    (%rcx),%rcx
cmpl   $0x45,(%rax,%rcx,4)
jne    12a1 <find_unused_bytes+0x181>
mov    -0x60(%rbp),%rax
mov    0x2d64(%rip),%rcx
mov    (%rcx),%rcx
cmpl   $0x4c,(%rax,%rcx,4)
jne    12a1 <find_unused_bytes+0x181>
mov    -0x60(%rbp),%rax
mov    0x2d3c(%rip),%rcx
mov    (%rcx),%rcx
cmpl   $0x46,(%rax,%rcx,4)
je     12d2 <find_unused_bytes+0x1b2>
cmpl   $0x0,-0x100(%rbp)
je     12bc <find_unused_bytes+0x19c>
lea    0xd5e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
movl   $0x1,-0x114(%rbp)
jmp    188b <find_unused_bytes+0x76b>
mov    -0x58(%rbp),%eax
add    -0x1c(%rbp),%eax
mov    %eax,-0x1c(%rbp)
movl   $0x0,-0xf8(%rbp)
mov    -0xf8(%rbp),%eax
cmp    -0x58(%rbp),%eax
jge    131a <find_unused_bytes+0x1fa>
mov    -0x120(%rbp),%rax
movslq -0xf8(%rbp),%rcx
movb   $0x1,(%rax,%rcx,1)
mov    -0xf8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xf8(%rbp)
jmp    12e5 <find_unused_bytes+0x1c5>
mov    -0xf0(%rbp),%rax
movslq -0x58(%rbp),%rcx
cmp    %rcx,%rax
jae    1339 <find_unused_bytes+0x219>
movslq -0x58(%rbp),%rax
mov    %rax,-0xf0(%rbp)
cmpl   $0x0,-0x100(%rbp)
je     1357 <find_unused_bytes+0x237>
mov    -0x58(%rbp),%esi
lea    0xcf4(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cmpl   $0x0,-0x54(%rbp)
je     14cd <find_unused_bytes+0x3ad>
cmpl   $0x0,-0x100(%rbp)
je     138b <find_unused_bytes+0x26b>
mov    -0x54(%rbp),%esi
mov    -0x54(%rbp),%edx
mov    -0x50(%rbp),%eax
imul   -0x4c(%rbp),%eax
add    %eax,%edx
lea    0xcdd(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x54(%rbp),%eax
mov    %eax,-0xf8(%rbp)
mov    -0xf8(%rbp),%eax
mov    -0x54(%rbp),%ecx
mov    -0x50(%rbp),%edx
imul   -0x4c(%rbp),%edx
add    %edx,%ecx
cmp    %ecx,%eax
jge    13d4 <find_unused_bytes+0x2b4>
mov    -0x120(%rbp),%rax
movslq -0xf8(%rbp),%rcx
movb   $0x2,(%rax,%rcx,1)
mov    -0xf8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xf8(%rbp)
jmp    1394 <find_unused_bytes+0x274>
mov    -0xf0(%rbp),%rax
mov    -0x54(%rbp),%ecx
mov    -0x50(%rbp),%edx
imul   -0x4c(%rbp),%edx
add    %edx,%ecx
movslq %ecx,%rcx
cmp    %rcx,%rax
jae    1408 <find_unused_bytes+0x2e8>
mov    -0x54(%rbp),%eax
mov    -0x50(%rbp),%ecx
imul   -0x4c(%rbp),%ecx
add    %ecx,%eax
cltq
mov    %rax,-0xf0(%rbp)
mov    -0x50(%rbp),%eax
imul   -0x4c(%rbp),%eax
add    -0x1c(%rbp),%eax
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x100(%rbp)
je     1437 <find_unused_bytes+0x317>
mov    -0x50(%rbp),%esi
imul   -0x4c(%rbp),%esi
lea    0xc62(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0xf4(%rbp)
mov    -0xf4(%rbp),%eax
cmp    -0x50(%rbp),%eax
jge    14c8 <find_unused_bytes+0x3a8>
mov    -0x10(%rbp),%rsi
movslq -0x54(%rbp),%rax
add    %rax,%rsi
mov    -0x4c(%rbp),%eax
imul   -0xf4(%rbp),%eax
cltq
add    %rax,%rsi
lea    -0xe0(%rbp),%rdi
mov    $0x40,%edx
call   1040 <memcpy@plt>
mov    %rax,-0xe8(%rbp)
cmpl   $0x0,-0x100(%rbp)
je     14af <find_unused_bytes+0x38f>
mov    -0xf4(%rbp),%esi
mov    -0xc8(%rbp),%edx
mov    -0xc4(%rbp),%ecx
lea    0xbfc(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    14b4 <find_unused_bytes+0x394>
mov    -0xf4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xf4(%rbp)
jmp    1441 <find_unused_bytes+0x321>
jmp    14cd <find_unused_bytes+0x3ad>
cmpl   $0x0,-0x40(%rbp)
je     16ed <find_unused_bytes+0x5cd>
cmpl   $0x0,-0x100(%rbp)
je     14f8 <find_unused_bytes+0x3d8>
mov    -0x40(%rbp),%esi
mov    -0x3c(%rbp),%edx
lea    0xbd7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x40(%rbp),%eax
mov    %eax,-0xf8(%rbp)
mov    -0xf8(%rbp),%eax
mov    -0x40(%rbp),%ecx
mov    -0x3c(%rbp),%edx
imul   -0x38(%rbp),%edx
add    %edx,%ecx
cmp    %ecx,%eax
jge    1541 <find_unused_bytes+0x421>
mov    -0x120(%rbp),%rax
movslq -0xf8(%rbp),%rcx
movb   $0x3,(%rax,%rcx,1)
mov    -0xf8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xf8(%rbp)
jmp    1501 <find_unused_bytes+0x3e1>
mov    -0xf0(%rbp),%rax
mov    -0x40(%rbp),%ecx
mov    -0x3c(%rbp),%edx
imul   -0x38(%rbp),%edx
add    %edx,%ecx
movslq %ecx,%rcx
cmp    %rcx,%rax
jae    1575 <find_unused_bytes+0x455>
mov    -0x40(%rbp),%eax
mov    -0x3c(%rbp),%ecx
imul   -0x38(%rbp),%ecx
add    %ecx,%eax
cltq
mov    %rax,-0xf0(%rbp)
mov    -0x3c(%rbp),%eax
imul   -0x38(%rbp),%eax
add    -0x1c(%rbp),%eax
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x100(%rbp)
je     15a4 <find_unused_bytes+0x484>
mov    -0x3c(%rbp),%esi
imul   -0x38(%rbp),%esi
lea    0xb62(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0xf4(%rbp)
mov    -0xf4(%rbp),%eax
cmp    -0x3c(%rbp),%eax
jge    16e8 <find_unused_bytes+0x5c8>
mov    -0x10(%rbp),%rsi
movslq -0x40(%rbp),%rax
add    %rax,%rsi
mov    -0x38(%rbp),%eax
imul   -0xf4(%rbp),%eax
cltq
add    %rax,%rsi
lea    -0xa0(%rbp),%rdi
mov    $0x40,%edx
call   1040 <memcpy@plt>
mov    %rax,-0xe8(%rbp)
mov    -0x70(%rbp),%rax
mov    0x29c6(%rip),%rcx
cmp    (%rcx),%rax
jne    162f <find_unused_bytes+0x50f>
cmpl   $0x0,-0x100(%rbp)
je     162a <find_unused_bytes+0x50a>
mov    -0xf4(%rbp),%esi
mov    -0x68(%rbp),%edx
mov    -0x64(%rbp),%ecx
lea    0xaf2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    16cf <find_unused_bytes+0x5af>
cmpl   $0x0,-0x100(%rbp)
je     1656 <find_unused_bytes+0x536>
mov    -0xf4(%rbp),%esi
mov    -0x68(%rbp),%edx
mov    -0x64(%rbp),%ecx
lea    0xaf3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xf0(%rbp),%rax
mov    -0x68(%rbp),%ecx
add    -0x64(%rbp),%ecx
movslq %ecx,%rcx
cmp    %rcx,%rax
jae    167e <find_unused_bytes+0x55e>
mov    -0x68(%rbp),%eax
add    -0x64(%rbp),%eax
cltq
mov    %rax,-0xf0(%rbp)
mov    -0x64(%rbp),%eax
add    -0x1c(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x68(%rbp),%eax
mov    %eax,-0xf8(%rbp)
mov    -0xf8(%rbp),%eax
mov    -0x68(%rbp),%ecx
add    -0x64(%rbp),%ecx
cmp    %ecx,%eax
jge    16ca <find_unused_bytes+0x5aa>
mov    -0x120(%rbp),%rax
movslq -0xf8(%rbp),%rcx
movb   $0x4,(%rax,%rcx,1)
mov    -0xf8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xf8(%rbp)
jmp    1690 <find_unused_bytes+0x570>
jmp    16cf <find_unused_bytes+0x5af>
jmp    16d4 <find_unused_bytes+0x5b4>
mov    -0xf4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xf4(%rbp)
jmp    15ae <find_unused_bytes+0x48e>
jmp    16ed <find_unused_bytes+0x5cd>
cmpl   $0x0,-0x100(%rbp)
je     170b <find_unused_bytes+0x5eb>
mov    -0x1c(%rbp),%esi
lea    0xa62(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cmpl   $0x0,-0x100(%rbp)
je     172d <find_unused_bytes+0x60d>
mov    -0xf0(%rbp),%rsi
lea    0xa56(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0xf4(%rbp)
movslq -0xf4(%rbp),%rax
cmp    -0x18(%rbp),%rax
jae    1878 <find_unused_bytes+0x758>
mov    -0x120(%rbp),%rax
movslq -0xf4(%rbp),%rcx
movzbl (%rax,%rcx,1),%eax
cmp    $0x0,%eax
jne    1785 <find_unused_bytes+0x665>
lea    0xa33(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xfc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xfc(%rbp)
jmp    185f <find_unused_bytes+0x73f>
mov    -0x120(%rbp),%rax
movslq -0xf4(%rbp),%rcx
movzbl (%rax,%rcx,1),%eax
cmp    $0x1,%eax
jne    17b3 <find_unused_bytes+0x693>
lea    0x9f8(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    185a <find_unused_bytes+0x73a>
mov    -0x120(%rbp),%rax
movslq -0xf4(%rbp),%rcx
movzbl (%rax,%rcx,1),%eax
cmp    $0x2,%eax
jne    17e1 <find_unused_bytes+0x6c1>
lea    0x9cc(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1855 <find_unused_bytes+0x735>
mov    -0x120(%rbp),%rax
movslq -0xf4(%rbp),%rcx
movzbl (%rax,%rcx,1),%eax
cmp    $0x3,%eax
jne    180f <find_unused_bytes+0x6ef>
lea    0x9a0(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1850 <find_unused_bytes+0x730>
mov    -0x120(%rbp),%rax
movslq -0xf4(%rbp),%rcx
movzbl (%rax,%rcx,1),%eax
cmp    $0x4,%eax
jne    183d <find_unused_bytes+0x71d>
lea    0x974(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    184b <find_unused_bytes+0x72b>
lea    0x963(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1850 <find_unused_bytes+0x730>
jmp    1855 <find_unused_bytes+0x735>
jmp    185a <find_unused_bytes+0x73a>
jmp    185f <find_unused_bytes+0x73f>
jmp    1864 <find_unused_bytes+0x744>
mov    -0xf4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xf4(%rbp)
jmp    1737 <find_unused_bytes+0x617>
mov    -0xfc(%rbp),%eax
mov    %eax,-0x4(%rbp)
movl   $0x1,-0x114(%rbp)
mov    -0x108(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<find_unused_bytes>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0xd8,%rsp
mov    %rsi,%r14
mov    %rdi,%rbx
mov    %rsp,-0x38(%rbp)
mov    %rsp,%r12
lea    0xf(%rsi),%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r12
mov    %r12,%rsp
test   %rsi,%rsi
je     1171 <find_unused_bytes+0x41>
mov    %r12,%rdi
xor    %esi,%esi
mov    %r14,%rdx
call   1040 <memset@plt>
lea    -0x78(%rbp),%rdi
mov    %rbx,%rsi
mov    $0x40,%edx
call   1050 <memcpy@plt>
mov    $0xffffffff,%r13d
test   %rax,%rax
je     13d1 <find_unused_bytes+0x2a1>
mov    -0x78(%rbp),%rax
mov    0x2e4c(%rip),%rcx
mov    (%rcx),%rcx
cmpl   $0x7f,(%rax,%rcx,4)
jne    13d1 <find_unused_bytes+0x2a1>
mov    0x2e18(%rip),%rcx
mov    (%rcx),%rcx
cmpl   $0x45,(%rax,%rcx,4)
jne    13d1 <find_unused_bytes+0x2a1>
mov    0x2e1c(%rip),%rcx
mov    (%rcx),%rcx
cmpl   $0x4c,(%rax,%rcx,4)
jne    13d1 <find_unused_bytes+0x2a1>
mov    0x2df8(%rip),%rcx
mov    (%rcx),%rcx
cmpl   $0x46,(%rax,%rcx,4)
jne    13d1 <find_unused_bytes+0x2a1>
mov    %rbx,-0x30(%rbp)
mov    -0x70(%rbp),%edx
test   %edx,%edx
jle    11fd <find_unused_bytes+0xcd>
mov    %r12,%rdi
mov    $0x1,%esi
call   1040 <memset@plt>
movslq -0x6c(%rbp),%rbx
test   %rbx,%rbx
je     129a <find_unused_bytes+0x16a>
mov    -0x68(%rbp),%r15d
mov    -0x64(%rbp),%eax
imul   %r15d,%eax
test   %eax,%eax
jle    123b <find_unused_bytes+0x10b>
add    %ebx,%eax
lea    0x1(%rbx),%ecx
cmp    %ecx,%eax
cmovle %ecx,%eax
lea    (%r12,%rbx,1),%rdi
mov    %ebx,%edx
not    %edx
add    %eax,%edx
add    $0x1,%rdx
mov    $0x2,%esi
call   1040 <memset@plt>
test   %r15d,%r15d
mov    -0x30(%rbp),%r13
jle    129a <find_unused_bytes+0x16a>
add    %r13,%rbx
lea    -0xf8(%rbp),%rdi
mov    %rbx,%rsi
mov    $0x40,%edx
call   1050 <memcpy@plt>
cmpl   $0x2,-0x68(%rbp)
jl     129a <find_unused_bytes+0x16a>
mov    $0x1,%ebx
lea    -0xf8(%rbp),%r15
nopl   (%rax)
movslq -0x6c(%rbp),%rax
movslq -0x64(%rbp),%rsi
add    %r13,%rax
movslq %ebx,%rbx
imul   %rbx,%rsi
add    %rax,%rsi
mov    %r15,%rdi
mov    $0x40,%edx
call   1050 <memcpy@plt>
add    $0x1,%ebx
cmp    -0x68(%rbp),%ebx
jl     1270 <find_unused_bytes+0x140>
movslq -0x58(%rbp),%r13
test   %r13,%r13
je     1367 <find_unused_bytes+0x237>
mov    -0x54(%rbp),%ebx
mov    -0x50(%rbp),%r15d
mov    %r15d,%eax
imul   %ebx,%eax
test   %eax,%eax
jle    12df <find_unused_bytes+0x1af>
add    %r13d,%eax
mov    %r13,%rdi
add    %r12,%rdi
lea    0x1(%r13),%ecx
cmp    %ecx,%eax
cmovle %ecx,%eax
mov    %r13d,%edx
not    %edx
add    %eax,%edx
add    $0x1,%rdx
mov    $0x3,%esi
call   1040 <memset@plt>
test   %ebx,%ebx
jle    1367 <find_unused_bytes+0x237>
mov    $0x1,%ebx
nopl   0x0(%rax)
lea    -0x1(%rbx),%eax
imul   %r15d,%eax
movslq %r13d,%rcx
add    -0x30(%rbp),%rcx
movslq %eax,%rsi
add    %rcx,%rsi
lea    -0xb8(%rbp),%rdi
mov    $0x40,%edx
call   1050 <memcpy@plt>
mov    -0x88(%rbp),%rax
mov    0x2c9d(%rip),%rcx
cmp    (%rcx),%rax
je     1355 <find_unused_bytes+0x225>
mov    -0x7c(%rbp),%eax
test   %eax,%eax
jle    1355 <find_unused_bytes+0x225>
movslq -0x80(%rbp),%rdx
add    %edx,%eax
mov    %rdx,%rdi
add    %r12,%rdi
lea    0x1(%rdx),%ecx
cmp    %ecx,%eax
cmovle %ecx,%eax
not    %edx
add    %eax,%edx
add    $0x1,%rdx
mov    $0x4,%esi
call   1040 <memset@plt>
cmp    -0x54(%rbp),%ebx
jge    1367 <find_unused_bytes+0x237>
mov    -0x58(%rbp),%r13d
mov    -0x50(%rbp),%r15d
add    $0x1,%ebx
jmp    12f0 <find_unused_bytes+0x1c0>
test   %r14,%r14
je     13ce <find_unused_bytes+0x29e>
xor    %ebx,%ebx
lea    0xc8b(%rip),%r15
xor    %r13d,%r13d
jmp    138e <find_unused_bytes+0x25e>
mov    $0x58,%edi
nop
call   1030 <putchar@plt>
add    $0x1,%rbx
cmp    %rbx,%r14
je     13d1 <find_unused_bytes+0x2a1>
movzbl (%r12,%rbx,1),%eax
cmp    $0x4,%rax
ja     137a <find_unused_bytes+0x24a>
movslq (%r15,%rax,4),%rax
add    %r15,%rax
jmp    *%rax
mov    $0x2e,%edi
call   1030 <putchar@plt>
add    $0x1,%r13d
jmp    1385 <find_unused_bytes+0x255>
mov    $0x48,%edi
jmp    1380 <find_unused_bytes+0x250>
mov    $0x50,%edi
jmp    1380 <find_unused_bytes+0x250>
mov    $0x53,%edi
jmp    1380 <find_unused_bytes+0x250>
mov    $0x73,%edi
jmp    1380 <find_unused_bytes+0x250>
xor    %r13d,%r13d
mov    -0x38(%rbp),%rsp
mov    %r13d,%eax
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.TYPE_5__ = type { i32*, i32, i32, i32, i32, i32, i32, i32, i32, i32, i64, i32, i32 }
@.str = [19 x i8] c"[-] memcpy failed\0A\00"
@EI_MAG0 = global i64 0
@EI_MAG1 = global i64 0
@EI_MAG2 = global i64 0
@EI_MAG3 = global i64 0
@.str.1 = [49 x i8] c"[-] input file does not appear to be a ELF file\0A\00"
@.str.2 = [29 x i8] c"[+] ELF header size: 0x%08x\0A\00"
@.str.3 = [49 x i8] c"[+] found program header table: 0x%08x - 0x%08x\0A\00"
@.str.4 = [18 x i8] c"PHT size: 0x%08x\0A\00"
@.str.5 = [36 x i8] c"\09segment[%d] @ 0x%08x: size 0x%08x\0A\00"
@.str.6 = [55 x i8] c"[+] found section header table @ 0x%08x (%d sections)\0A\00"
@.str.7 = [22 x i8] c"[+] SHT size: 0x%08x\0A\00"
@SHT_NOBITS = global i64 0
@.str.8 = [45 x i8] c"\09section[%d] @ 0x%08x: size 0x%08x (NOBITS)\0A\00"
@.str.9 = [36 x i8] c"\09section[%d] @ 0x%08x: size 0x%08x\0A\00"
@.str.10 = [22 x i8] c"[+] final size is %d\0A\00"
@.str.11 = [33 x i8] c"[+] highest byte referenced: %d\0A\00"
@.str.12 = [2 x i8] c".\00"
@.str.13 = [2 x i8] c"H\00"
@.str.14 = [2 x i8] c"P\00"
@.str.15 = [2 x i8] c"S\00"
@.str.16 = [2 x i8] c"s\00"
@.str.17 = [2 x i8] c"X\00"
define i32 @find_unused_bytes(i8* %0, i64 %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i64
%6 = alloca i32
%7 = alloca %struct.TYPE_5__
%8 = alloca %struct.TYPE_5__
%9 = alloca %struct.TYPE_5__
%10 = alloca i8*
%11 = alloca i64
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
%16 = alloca i8*
%17 = alloca i64
%18 = alloca i32
store i8* %0, i8** %4
store i64 %1, i64* %5
store i32 0, i32* %6
store i8* null, i8** %10
store i64 0, i64* %11
store i32 0, i32* %12
store i32 0, i32* %13
store i32 0, i32* %14
store i32 0, i32* %15
%19 = load i64, i64* %5
%20 = call i8* @llvm.stacksave()
store i8* %20, i8** %16
%21 = alloca i8, i64 %19
store i64 %19, i64* %17
store i32 0, i32* %12
br label %22
22: ; preds = %31, %2
%23 = load i32, i32* %12
%24 = sext i32 %23 to i64
%25 = load i64, i64* %5
%26 = icmp ult i64 %24, %25
br i1 %26, label %27, label %34
27: ; preds = %22
%28 = load i32, i32* %12
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds i8, i8* %21, i64 %29
store i8 0, i8* %30
br label %31
31: ; preds = %27
%32 = load i32, i32* %12
%33 = add nsw i32 %32, 1
store i32 %33, i32* %12
br label %22
34: ; preds = %22
%35 = load i8*, i8** %4
%36 = call i8* @memcpy(%struct.TYPE_5__* %7, i8* %35, i32 64)
store i8* %36, i8** %10
%37 = load i8*, i8** %10
%38 = icmp eq i8* %37, null
br i1 %38, label %39, label %45
39: ; preds = %34
%40 = load i32, i32* %15
%41 = icmp ne i32 %40, 0
br i1 %41, label %42, label %44
42: ; preds = %39
%43 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
br label %44
44: ; preds = %42, %39
store i32 -1, i32* %3
store i32 1, i32* %18
br label %463
45: ; preds = %34
%46 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %7, i32 0, i32 0
%47 = load i32*, i32** %46
%48 = load i64, i64* @EI_MAG0
%49 = getelementptr inbounds i32, i32* %47, i64 %48
%50 = load i32, i32* %49
%51 = icmp ne i32 %50, 127
br i1 %51, label %73, label %52
52: ; preds = %45
%53 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %7, i32 0, i32 0
%54 = load i32*, i32** %53
%55 = load i64, i64* @EI_MAG1
%56 = getelementptr inbounds i32, i32* %54, i64 %55
%57 = load i32, i32* %56
%58 = icmp ne i32 %57, 69
br i1 %58, label %73, label %59
59: ; preds = %52
%60 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %7, i32 0, i32 0
%61 = load i32*, i32** %60
%62 = load i64, i64* @EI_MAG2
%63 = getelementptr inbounds i32, i32* %61, i64 %62
%64 = load i32, i32* %63
%65 = icmp ne i32 %64, 76
br i1 %65, label %73, label %66
66: ; preds = %59
%67 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %7, i32 0, i32 0
%68 = load i32*, i32** %67
%69 = load i64, i64* @EI_MAG3
%70 = getelementptr inbounds i32, i32* %68, i64 %69
%71 = load i32, i32* %70
%72 = icmp ne i32 %71, 70
br i1 %72, label %73, label %79
73: ; preds = %66, %59, %52, %45
%74 = load i32, i32* %15
%75 = icmp ne i32 %74, 0
br i1 %75, label %76, label %78
76: ; preds = %73
%77 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.1, i64 0, i64 0))
br label %78
78: ; preds = %76, %73
store i32 -1, i32* %3
store i32 1, i32* %18
br label %463
79: ; preds = %66
%80 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %7, i32 0, i32 1
%81 = load i32, i32* %80
%82 = load i32, i32* %6
%83 = add nsw i32 %82, %81
store i32 %83, i32* %6
store i32 0, i32* %13
br label %84
84: ; preds = %93, %79
%85 = load i32, i32* %13
%86 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %7, i32 0, i32 1
%87 = load i32, i32* %86
%88 = icmp slt i32 %85, %87
br i1 %88, label %89, label %96
89: ; preds = %84
%90 = load i32, i32* %13
%91 = sext i32 %90 to i64
%92 = getelementptr inbounds i8, i8* %21, i64 %91
store i8 1, i8* %92
br label %93
93: ; preds = %89
%94 = load i32, i32* %13
%95 = add nsw i32 %94, 1
store i32 %95, i32* %13
br label %84
96: ; preds = %84
%97 = load i64, i64* %11
%98 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %7, i32 0, i32 1
%99 = load i32, i32* %98
%100 = sext i32 %99 to i64
%101 = icmp ult i64 %97, %100
br i1 %101, label %102, label %106
102: ; preds = %96
%103 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %7, i32 0, i32 1
%104 = load i32, i32* %103
%105 = sext i32 %104 to i64
store i64 %105, i64* %11
br label %106
106: ; preds = %102, %96
%107 = load i32, i32* %15
%108 = icmp ne i32 %107, 0
br i1 %108, label %109, label %113
109: ; preds = %106
%110 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %7, i32 0, i32 1
%111 = load i32, i32* %110
%112 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0), i32 %111)
br label %113
113: ; preds = %109, %106
%114 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %7, i32 0, i32 2
%115 = load i32, i32* %114
%116 = icmp ne i32 %115, 0
br i1 %116, label %117, label %225
117: ; preds = %113
%118 = load i32, i32* %15
%119 = icmp ne i32 %118, 0
br i1 %119, label %120, label %132
120: ; preds = %117
%121 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %7, i32 0, i32 2
%122 = load i32, i32* %121
%123 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %7, i32 0, i32 2
%124 = load i32, i32* %123
%125 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %7, i32 0, i32 3
%126 = load i32, i32* %125
%127 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %7, i32 0, i32 4
%128 = load i32, i32* %127
%129 = mul nsw i32 %126, %128
%130 = add nsw i32 %124, %129
%131 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.3, i64 0, i64 0), i32 %122, i32 %130)
br label %132
132: ; preds = %120, %117
%133 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %7, i32 0, i32 2
%134 = load i32, i32* %133
store i32 %134, i32* %13
br label %135
135: ; preds = %150, %132
%136 = load i32, i32* %13
%137 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %7, i32 0, i32 2
%138 = load i32, i32* %137
%139 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %7, i32 0, i32 3
%140 = load i32, i32* %139
%141 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %7, i32 0, i32 4
%142 = load i32, i32* %141
%143 = mul nsw i32 %140, %142
%144 = add nsw i32 %138, %143
%145 = icmp slt i32 %136, %144
br i1 %145, label %146, label %153
146: ; preds = %135
%147 = load i32, i32* %13
%148 = sext i32 %147 to i64
%149 = getelementptr inbounds i8, i8* %21, i64 %148
store i8 2, i8* %149
br label %150
150: ; preds = %146
%151 = load i32, i32* %13
%152 = add nsw i32 %151, 1
store i32 %152, i32* %13
br label %135
153: ; preds = %135
%154 = load i64, i64* %11
%155 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %7, i32 0, i32 2
%156 = load i32, i32* %155
%157 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %7, i32 0, i32 3
%158 = load i32, i32* %157
%159 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %7, i32 0, i32 4
%160 = load i32, i32* %159
%161 = mul nsw i32 %158, %160
%162 = add nsw i32 %156, %161
%163 = sext i32 %162 to i64
%164 = icmp ult i64 %154, %163
br i1 %164, label %165, label %175
165: ; preds = %153
%166 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %7, i32 0, i32 2
%167 = load i32, i32* %166
%168 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %7, i32 0, i32 3
%169 = load i32, i32* %168
%170 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %7, i32 0, i32 4
%171 = load i32, i32* %170
%172 = mul nsw i32 %169, %171
%173 = add nsw i32 %167, %172
%174 = sext i32 %173 to i64
store i64 %174, i64* %11
br label %175
175: ; preds = %165, %153
%176 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %7, i32 0, i32 3
%177 = load i32, i32* %176
%178 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %7, i32 0, i32 4
%179 = load i32, i32* %178
%180 = mul nsw i32 %177, %179
%181 = load i32, i32* %6
%182 = add nsw i32 %181, %180
store i32 %182, i32* %6
%183 = load i32, i32* %15
%184 = icmp ne i32 %183, 0
br i1 %184, label %185, label %192
185: ; preds = %175
%186 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %7, i32 0, i32 3
%187 = load i32, i32* %186
%188 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %7, i32 0, i32 4
%189 = load i32, i32* %188
%190 = mul nsw i32 %187, %189
%191 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.4, i64 0, i64 0), i32 %190)
br label %192
192: ; preds = %185, %175
store i32 0, i32* %12
br label %193
193: ; preds = %221, %192
%194 = load i32, i32* %12
%195 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %7, i32 0, i32 3
%196 = load i32, i32* %195
%197 = icmp slt i32 %194, %196
br i1 %197, label %198, label %224
198: ; preds = %193
%199 = load i8*, i8** %4
%200 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %7, i32 0, i32 2
%201 = load i32, i32* %200
%202 = sext i32 %201 to i64
%203 = getelementptr inbounds i8, i8* %199, i64 %202
%204 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %7, i32 0, i32 4
%205 = load i32, i32* %204
%206 = load i32, i32* %12
%207 = mul nsw i32 %205, %206
%208 = sext i32 %207 to i64
%209 = getelementptr inbounds i8, i8* %203, i64 %208
%210 = call i8* @memcpy(%struct.TYPE_5__* %9, i8* %209, i32 64)
store i8* %210, i8** %10
%211 = load i32, i32* %15
%212 = icmp ne i32 %211, 0
br i1 %212, label %213, label %220
213: ; preds = %198
%214 = load i32, i32* %12
%215 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %9, i32 0, i32 5
%216 = load i32, i32* %215
%217 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %9, i32 0, i32 6
%218 = load i32, i32* %217
%219 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.5, i64 0, i64 0), i32 %214, i32 %216, i32 %218)
br label %220
220: ; preds = %213, %198
br label %221
221: ; preds = %220
%222 = load i32, i32* %12
%223 = add nsw i32 %222, 1
store i32 %223, i32* %12
br label %193
224: ; preds = %193
br label %225
225: ; preds = %224, %113
%226 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %7, i32 0, i32 7
%227 = load i32, i32* %226
%228 = icmp ne i32 %227, 0
br i1 %228, label %229, label %386
229: ; preds = %225
%230 = load i32, i32* %15
%231 = icmp ne i32 %230, 0
br i1 %231, label %232, label %238
232: ; preds = %229
%233 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %7, i32 0, i32 7
%234 = load i32, i32* %233
%235 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %7, i32 0, i32 8
%236 = load i32, i32* %235
%237 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str.6, i64 0, i64 0), i32 %234, i32 %236)
br label %238
238: ; preds = %232, %229
%239 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %7, i32 0, i32 7
%240 = load i32, i32* %239
store i32 %240, i32* %13
br label %241
241: ; preds = %256, %238
%242 = load i32, i32* %13
%243 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %7, i32 0, i32 7
%244 = load i32, i32* %243
%245 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %7, i32 0, i32 8
%246 = load i32, i32* %245
%247 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %7, i32 0, i32 9
%248 = load i32, i32* %247
%249 = mul nsw i32 %246, %248
%250 = add nsw i32 %244, %249
%251 = icmp slt i32 %242, %250
br i1 %251, label %252, label %259
252: ; preds = %241
%253 = load i32, i32* %13
%254 = sext i32 %253 to i64
%255 = getelementptr inbounds i8, i8* %21, i64 %254
store i8 3, i8* %255
br label %256
256: ; preds = %252
%257 = load i32, i32* %13
%258 = add nsw i32 %257, 1
store i32 %258, i32* %13
br label %241
259: ; preds = %241
%260 = load i64, i64* %11
%261 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %7, i32 0, i32 7
%262 = load i32, i32* %261
%263 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %7, i32 0, i32 8
%264 = load i32, i32* %263
%265 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %7, i32 0, i32 9
%266 = load i32, i32* %265
%267 = mul nsw i32 %264, %266
%268 = add nsw i32 %262, %267
%269 = sext i32 %268 to i64
%270 = icmp ult i64 %260, %269
br i1 %270, label %271, label %281
271: ; preds = %259
%272 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %7, i32 0, i32 7
%273 = load i32, i32* %272
%274 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %7, i32 0, i32 8
%275 = load i32, i32* %274
%276 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %7, i32 0, i32 9
%277 = load i32, i32* %276
%278 = mul nsw i32 %275, %277
%279 = add nsw i32 %273, %278
%280 = sext i32 %279 to i64
store i64 %280, i64* %11
br label %281
281: ; preds = %271, %259
%282 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %7, i32 0, i32 8
%283 = load i32, i32* %282
%284 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %7, i32 0, i32 9
%285 = load i32, i32* %284
%286 = mul nsw i32 %283, %285
%287 = load i32, i32* %6
%288 = add nsw i32 %287, %286
store i32 %288, i32* %6
%289 = load i32, i32* %15
%290 = icmp ne i32 %289, 0
br i1 %290, label %291, label %298
291: ; preds = %281
%292 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %7, i32 0, i32 8
%293 = load i32, i32* %292
%294 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %7, i32 0, i32 9
%295 = load i32, i32* %294
%296 = mul nsw i32 %293, %295
%297 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.7, i64 0, i64 0), i32 %296)
br label %298
298: ; preds = %291, %281
store i32 0, i32* %12
br label %299
299: ; preds = %382, %298
%300 = load i32, i32* %12
%301 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %7, i32 0, i32 8
%302 = load i32, i32* %301
%303 = icmp slt i32 %300, %302
br i1 %303, label %304, label %385
304: ; preds = %299
%305 = load i8*, i8** %4
%306 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %7, i32 0, i32 7
%307 = load i32, i32* %306
%308 = sext i32 %307 to i64
%309 = getelementptr inbounds i8, i8* %305, i64 %308
%310 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %7, i32 0, i32 9
%311 = load i32, i32* %310
%312 = load i32, i32* %12
%313 = mul nsw i32 %311, %312
%314 = sext i32 %313 to i64
%315 = getelementptr inbounds i8, i8* %309, i64 %314
%316 = call i8* @memcpy(%struct.TYPE_5__* %8, i8* %315, i32 64)
store i8* %316, i8** %10
%317 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %8, i32 0, i32 10
%318 = load i64, i64* %317
%319 = load i64, i64* @SHT_NOBITS
%320 = icmp eq i64 %318, %319
br i1 %320, label %321, label %332
321: ; preds = %304
%322 = load i32, i32* %15
%323 = icmp ne i32 %322, 0
br i1 %323, label %324, label %331
324: ; preds = %321
%325 = load i32, i32* %12
%326 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %8, i32 0, i32 11
%327 = load i32, i32* %326
%328 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %8, i32 0, i32 12
%329 = load i32, i32* %328
%330 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.8, i64 0, i64 0), i32 %325, i32 %327, i32 %329)
br label %331
331: ; preds = %324, %321
br label %381
332: ; preds = %304
%333 = load i32, i32* %15
%334 = icmp ne i32 %333, 0
br i1 %334, label %335, label %342
335: ; preds = %332
%336 = load i32, i32* %12
%337 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %8, i32 0, i32 11
%338 = load i32, i32* %337
%339 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %8, i32 0, i32 12
%340 = load i32, i32* %339
%341 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.9, i64 0, i64 0), i32 %336, i32 %338, i32 %340)
br label %342
342: ; preds = %335, %332
%343 = load i64, i64* %11
%344 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %8, i32 0, i32 11
%345 = load i32, i32* %344
%346 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %8, i32 0, i32 12
%347 = load i32, i32* %346
%348 = add nsw i32 %345, %347
%349 = sext i32 %348 to i64
%350 = icmp ult i64 %343, %349
br i1 %350, label %351, label %358
351: ; preds = %342
%352 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %8, i32 0, i32 11
%353 = load i32, i32* %352
%354 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %8, i32 0, i32 12
%355 = load i32, i32* %354
%356 = add nsw i32 %353, %355
%357 = sext i32 %356 to i64
store i64 %357, i64* %11
br label %358
358: ; preds = %351, %342
%359 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %8, i32 0, i32 12
%360 = load i32, i32* %359
%361 = load i32, i32* %6
%362 = add nsw i32 %361, %360
store i32 %362, i32* %6
%363 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %8, i32 0, i32 11
%364 = load i32, i32* %363
store i32 %364, i32* %13
br label %365
365: ; preds = %377, %358
%366 = load i32, i32* %13
%367 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %8, i32 0, i32 11
%368 = load i32, i32* %367
%369 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %8, i32 0, i32 12
%370 = load i32, i32* %369
%371 = add nsw i32 %368, %370
%372 = icmp slt i32 %366, %371
br i1 %372, label %373, label %380
373: ; preds = %365
%374 = load i32, i32* %13
%375 = sext i32 %374 to i64
%376 = getelementptr inbounds i8, i8* %21, i64 %375
store i8 4, i8* %376
br label %377
377: ; preds = %373
%378 = load i32, i32* %13
%379 = add nsw i32 %378, 1
store i32 %379, i32* %13
br label %365
380: ; preds = %365
br label %381
381: ; preds = %380, %331
br label %382
382: ; preds = %381
%383 = load i32, i32* %12
%384 = add nsw i32 %383, 1
store i32 %384, i32* %12
br label %299
385: ; preds = %299
br label %386
386: ; preds = %385, %225
%387 = load i32, i32* %15
%388 = icmp ne i32 %387, 0
br i1 %388, label %389, label %392
389: ; preds = %386
%390 = load i32, i32* %6
%391 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.10, i64 0, i64 0), i32 %390)
br label %392
392: ; preds = %389, %386
%393 = load i32, i32* %15
%394 = icmp ne i32 %393, 0
br i1 %394, label %395, label %398
395: ; preds = %392
%396 = load i64, i64* %11
%397 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.11, i64 0, i64 0), i64 %396)
br label %398
398: ; preds = %395, %392
store i32 0, i32* %12
br label %399
399: ; preds = %458, %398
%400 = load i32, i32* %12
%401 = sext i32 %400 to i64
%402 = load i64, i64* %5
%403 = icmp ult i64 %401, %402
br i1 %403, label %404, label %461
404: ; preds = %399
%405 = load i32, i32* %12
%406 = sext i32 %405 to i64
%407 = getelementptr inbounds i8, i8* %21, i64 %406
%408 = load i8, i8* %407
%409 = zext i8 %408 to i32
%410 = icmp eq i32 %409, 0
br i1 %410, label %411, label %415
411: ; preds = %404
%412 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.12, i64 0, i64 0))
%413 = load i32, i32* %14
%414 = add nsw i32 %413, 1
store i32 %414, i32* %14
br label %457
415: ; preds = %404
%416 = load i32, i32* %12
%417 = sext i32 %416 to i64
%418 = getelementptr inbounds i8, i8* %21, i64 %417
%419 = load i8, i8* %418
%420 = zext i8 %419 to i32
%421 = icmp eq i32 %420, 1
br i1 %421, label %422, label %424
422: ; preds = %415
%423 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.13, i64 0, i64 0))
br label %456
424: ; preds = %415
%425 = load i32, i32* %12
%426 = sext i32 %425 to i64
%427 = getelementptr inbounds i8, i8* %21, i64 %426
%428 = load i8, i8* %427
%429 = zext i8 %428 to i32
%430 = icmp eq i32 %429, 2
br i1 %430, label %431, label %433
431: ; preds = %424
%432 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.14, i64 0, i64 0))
br label %455
433: ; preds = %424
%434 = load i32, i32* %12
%435 = sext i32 %434 to i64
%436 = getelementptr inbounds i8, i8* %21, i64 %435
%437 = load i8, i8* %436
%438 = zext i8 %437 to i32
%439 = icmp eq i32 %438, 3
br i1 %439, label %440, label %442
440: ; preds = %433
%441 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.15, i64 0, i64 0))
br label %454
442: ; preds = %433
%443 = load i32, i32* %12
%444 = sext i32 %443 to i64
%445 = getelementptr inbounds i8, i8* %21, i64 %444
%446 = load i8, i8* %445
%447 = zext i8 %446 to i32
%448 = icmp eq i32 %447, 4
br i1 %448, label %449, label %451
449: ; preds = %442
%450 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.16, i64 0, i64 0))
br label %453
451: ; preds = %442
%452 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.17, i64 0, i64 0))
br label %453
453: ; preds = %451, %449
br label %454
454: ; preds = %453, %440
br label %455
455: ; preds = %454, %431
br label %456
456: ; preds = %455, %422
br label %457
457: ; preds = %456, %411
br label %458
458: ; preds = %457
%459 = load i32, i32* %12
%460 = add nsw i32 %459, 1
store i32 %460, i32* %12
br label %399
461: ; preds = %399
%462 = load i32, i32* %14
store i32 %462, i32* %3
store i32 1, i32* %18
br label %463
463: ; preds = %461, %78, %44
%464 = load i8*, i8** %16
%465 = load i32, i32* %3
ret i32 %465
}

LLVM IR (-O2):
%struct.TYPE_5__ = type { i32*, i32, i32, i32, i32, i32, i32, i32, i32, i32, i64, i32, i32 }
@EI_MAG0 = global i64 0
@EI_MAG1 = global i64 0
@EI_MAG2 = global i64 0
@EI_MAG3 = global i64 0
@SHT_NOBITS = global i64 0
define i32 @find_unused_bytes(i8* %0, i64 %1) {
%3 = alloca %struct.TYPE_5__
%4 = alloca %struct.TYPE_5__
%5 = alloca %struct.TYPE_5__
%6 = bitcast %struct.TYPE_5__* %3 to i8*
%7 = bitcast %struct.TYPE_5__* %4 to i8*
%8 = bitcast %struct.TYPE_5__* %5 to i8*
%9 = tail call i8* @llvm.stacksave()
%10 = alloca i8, i64 %1
%11 = icmp eq i64 %1, 0
br i1 %11, label %13, label %12
12: ; preds = %2
br label %13
13: ; preds = %12, %2
%14 = call i8* @memcpy(%struct.TYPE_5__* %3, i8* %0, i32 64)
%15 = icmp eq i8* %14, null
br i1 %15, label %170, label %16
16: ; preds = %13
%17 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %3, i64 0, i32 0
%18 = load i32*, i32** %17
%19 = load i64, i64* @EI_MAG0
%20 = getelementptr inbounds i32, i32* %18, i64 %19
%21 = load i32, i32* %20
%22 = icmp eq i32 %21, 127
br i1 %22, label %23, label %170
23: ; preds = %16
%24 = load i64, i64* @EI_MAG1
%25 = getelementptr inbounds i32, i32* %18, i64 %24
%26 = load i32, i32* %25
%27 = icmp eq i32 %26, 69
br i1 %27, label %28, label %170
28: ; preds = %23
%29 = load i64, i64* @EI_MAG2
%30 = getelementptr inbounds i32, i32* %18, i64 %29
%31 = load i32, i32* %30
%32 = icmp eq i32 %31, 76
br i1 %32, label %33, label %170
33: ; preds = %28
%34 = load i64, i64* @EI_MAG3
%35 = getelementptr inbounds i32, i32* %18, i64 %34
%36 = load i32, i32* %35
%37 = icmp eq i32 %36, 70
br i1 %37, label %38, label %170
38: ; preds = %33
%39 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %3, i64 0, i32 1
%40 = load i32, i32* %39
%41 = icmp sgt i32 %40, 0
br i1 %41, label %42, label %44
42: ; preds = %38
%43 = zext i32 %40 to i64
br label %44
44: ; preds = %42, %38
%45 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %3, i64 0, i32 2
%46 = load i32, i32* %45
%47 = icmp eq i32 %46, 0
br i1 %47, label %86, label %48
48: ; preds = %44
%49 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %3, i64 0, i32 3
%50 = load i32, i32* %49
%51 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %3, i64 0, i32 4
%52 = load i32, i32* %51
%53 = mul nsw i32 %52, %50
%54 = icmp sgt i32 %53, 0
br i1 %54, label %55, label %65
55: ; preds = %48
%56 = add i32 %53, %46
%57 = sext i32 %46 to i64
%58 = getelementptr i8, i8* %10, i64 %57
%59 = add i32 %46, 1
%60 = call i32 @llvm.smax.i32(i32 %56, i32 %59)
%61 = xor i32 %46, -1
%62 = add i32 %60, %61
%63 = zext i32 %62 to i64
%64 = add nuw nsw i64 %63, 1
br label %65
65: ; preds = %55, %48
%66 = icmp sgt i32 %50, 0
br i1 %66, label %67, label %86
67: ; preds = %65
%68 = sext i32 %46 to i64
%69 = getelementptr inbounds i8, i8* %0, i64 %68
%70 = call i8* @memcpy(%struct.TYPE_5__* %5, i8* %69, i32 64)
%71 = load i32, i32* %49
%72 = icmp sgt i32 %71, 1
br i1 %72, label %73, label %86
73: ; preds = %67, %73
%74 = phi i32 [ %83, %73 ], [ 1, %67 ]
%75 = load i32, i32* %45
%76 = load i32, i32* %51
%77 = sext i32 %75 to i64
%78 = getelementptr inbounds i8, i8* %0, i64 %77
%79 = mul nsw i32 %76, %74
%80 = sext i32 %79 to i64
%81 = getelementptr inbounds i8, i8* %78, i64 %80
%82 = call i8* @memcpy(%struct.TYPE_5__* %5, i8* %81, i32 64)
%83 = add nuw nsw i32 %74, 1
%84 = load i32, i32* %49
%85 = icmp slt i32 %83, %84
br i1 %85, label %73, label %86
86: ; preds = %73, %67, %65, %44
%87 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %3, i64 0, i32 7
%88 = load i32, i32* %87
%89 = icmp eq i32 %88, 0
br i1 %89, label %147, label %90
90: ; preds = %86
%91 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %3, i64 0, i32 8
%92 = load i32, i32* %91
%93 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %3, i64 0, i32 9
%94 = load i32, i32* %93
%95 = mul nsw i32 %94, %92
%96 = icmp sgt i32 %95, 0
br i1 %96, label %97, label %107
97: ; preds = %90
%98 = add i32 %95, %88
%99 = sext i32 %88 to i64
%100 = getelementptr i8, i8* %10, i64 %99
%101 = add i32 %88, 1
%102 = call i32 @llvm.smax.i32(i32 %98, i32 %101)
%103 = xor i32 %88, -1
%104 = add i32 %102, %103
%105 = zext i32 %104 to i64
%106 = add nuw nsw i64 %105, 1
br label %107
107: ; preds = %97, %90
%108 = icmp sgt i32 %92, 0
br i1 %108, label %109, label %147
109: ; preds = %107
%110 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %4, i64 0, i32 10
%111 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %4, i64 0, i32 11
%112 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %4, i64 0, i32 12
br label %113
113: ; preds = %144, %109
%114 = phi i32 [ %94, %109 ], [ %146, %144 ]
%115 = phi i32 [ %88, %109 ], [ %145, %144 ]
%116 = phi i32 [ 0, %109 ], [ %141, %144 ]
%117 = sext i32 %115 to i64
%118 = getelementptr inbounds i8, i8* %0, i64 %117
%119 = mul nsw i32 %114, %116
%120 = sext i32 %119 to i64
%121 = getelementptr inbounds i8, i8* %118, i64 %120
%122 = call i8* @memcpy(%struct.TYPE_5__* %4, i8* %121, i32 64)
%123 = load i64, i64* %110
%124 = load i64, i64* @SHT_NOBITS
%125 = icmp eq i64 %123, %124
br i1 %125, label %140, label %126
126: ; preds = %113
%127 = load i32, i32* %111
%128 = load i32, i32* %112
%129 = icmp sgt i32 %128, 0
br i1 %129, label %130, label %140
130: ; preds = %126
%131 = add i32 %128, %127
%132 = sext i32 %127 to i64
%133 = getelementptr i8, i8* %10, i64 %132
%134 = add i32 %127, 1
%135 = call i32 @llvm.smax.i32(i32 %131, i32 %134)
%136 = xor i32 %127, -1
%137 = add i32 %135, %136
%138 = zext i32 %137 to i64
%139 = add nuw nsw i64 %138, 1
br label %140
140: ; preds = %130, %126, %113
%141 = add nuw nsw i32 %116, 1
%142 = load i32, i32* %91
%143 = icmp slt i32 %141, %142
br i1 %143, label %144, label %147
144: ; preds = %140
%145 = load i32, i32* %87
%146 = load i32, i32* %93
br label %113
147: ; preds = %140, %107, %86
br i1 %11, label %170, label %148
148: ; preds = %147, %166
%149 = phi i64 [ %168, %166 ], [ 0, %147 ]
%150 = phi i32 [ %167, %166 ], [ 0, %147 ]
%151 = getelementptr inbounds i8, i8* %10, i64 %149
%152 = load i8, i8* %151
switch i8 %152, label %164 [
i8 0, label %153
i8 1, label %156
i8 2, label %158
i8 3, label %160
i8 4, label %162
]
153: ; preds = %148
%154 = call i32 @putchar(i32 46)
%155 = add nsw i32 %150, 1
br label %166
156: ; preds = %148
%157 = call i32 @putchar(i32 72)
br label %166
158: ; preds = %148
%159 = call i32 @putchar(i32 80)
br label %166
160: ; preds = %148
%161 = call i32 @putchar(i32 83)
br label %166
162: ; preds = %148
%163 = call i32 @putchar(i32 115)
br label %166
164: ; preds = %148
%165 = call i32 @putchar(i32 88)
br label %166
166: ; preds = %153, %158, %162, %164, %160, %156
%167 = phi i32 [ %155, %153 ], [ %150, %156 ], [ %150, %158 ], [ %150, %160 ], [ %150, %162 ], [ %150, %164 ]
%168 = add nuw i64 %149, 1
%169 = icmp eq i64 %168, %1
br i1 %169, label %170, label %148
170: ; preds = %166, %147, %33, %28, %23, %16, %13
%171 = phi i32 [ -1, %13 ], [ -1, %16 ], [ -1, %23 ], [ -1, %28 ], [ -1, %33 ], [ 0, %147 ], [ %167, %166 ]
ret i32 %171
}