#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ SEEK_END;
int /*<<< orphan*/ SEEK_SET;
int S_IRGRP;
int S_IROTH;
int S_IRUSR;
int S_IWUSR;
int S_IXGRP;
int S_IXOTH;
int S_IXUSR;
int /*<<< orphan*/ chmod(char *, int);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
scalar_t__ fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ fseek(int /*<<< orphan*/ *, int, int /*<<< orphan*/);
unsigned long ftell(int /*<<< orphan*/ *);
int /*<<< orphan*/ get4k(int /*<<< orphan*/ *, char *);
int /*<<< orphan*/ memset(char *, int /*<<< orphan*/, int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ put4k(int /*<<< orphan*/ *, char *);
int /*<<< orphan*/ stderr;
char *strstr(char *, char *);
scalar_t__ strtol(char *, int /*<<< orphan*/ *, int);
int main(int argc, char **argv) {
  char inbuf[4096];
  FILE *sysmap = NULL;
  char *ptr_end = NULL;
  FILE *inputVmlinux = NULL;
  FILE *outputVmlinux = NULL;
  long i = 0;
  unsigned long sysmapFileLen = 0;
  unsigned long sysmapLen = 0;
  unsigned long roundR = 0;
  unsigned long kernelLen = 0;
  unsigned long actualKernelLen = 0;
  unsigned long round = 0;
  unsigned long roundedKernelLen = 0;
  unsigned long sysmapStartOffs = 0;
  unsigned long sysmapPages = 0;
  unsigned long roundedKernelPages = 0;
  long padPages = 0;
  if (argc < 2) {
    fprintf(stderr, "Name of System Map file missing.\n");
    exit(1);
  }
  if (argc < 3) {
    fprintf(stderr, "Name of vmlinux file missing.\n");
    exit(1);
  }
  if (argc < 4) {
    fprintf(stderr, "Name of vmlinux output file missing.\n");
    exit(1);
  }
  sysmap = fopen(argv[1], "r");
  if (!sysmap) {
    fprintf(stderr, "System Map file \"%s\" failed to open.\n", argv[1]);
    exit(1);
  }
  inputVmlinux = fopen(argv[2], "r");
  if (!inputVmlinux) {
    fprintf(stderr, "vmlinux file \"%s\" failed to open.\n", argv[2]);
    exit(1);
  }
  outputVmlinux = fopen(argv[3], "w");
  if (!outputVmlinux) {
    fprintf(stderr, "output vmlinux file \"%s\" failed to open.\n", argv[3]);
    exit(1);
  }
  fseek(inputVmlinux, 0, SEEK_END);
  kernelLen = ftell(inputVmlinux);
  fseek(inputVmlinux, 0, SEEK_SET);
  printf("kernel file size = %ld\n", kernelLen);
  if (kernelLen == 0) {
    fprintf(stderr, "You must have a linux kernel specified as argv[2]\n");
    exit(1);
  }
  actualKernelLen = kernelLen - (64 * 1024);
  printf("actual kernel length (minus ELF header) = %ld/%lxx \n",
         actualKernelLen, actualKernelLen);
  round = actualKernelLen % 4096;
  roundedKernelLen = actualKernelLen;
  if (round)
    roundedKernelLen += (4096 - round);
  printf("Kernel length rounded up to a 4k multiple = %ld/%lxx \n",
         roundedKernelLen, roundedKernelLen);
  roundedKernelPages = roundedKernelLen / 4096;
  printf("Kernel pages to copy = %ld/%lxx\n", roundedKernelPages,
         roundedKernelPages);
  fseek(sysmap, 0, SEEK_END);
  sysmapFileLen = ftell(sysmap);
  fseek(sysmap, 0, SEEK_SET);
  printf("%s file size = %ld\n", argv[1], sysmapFileLen);
  sysmapLen = sysmapFileLen;
  roundR = 4096 - (sysmapLen % 4096);
  if (roundR) {
    printf("Rounding System Map file up to a multiple of 4096, adding %ld\n",
           roundR);
    sysmapLen += roundR;
  }
  printf("Rounded System Map size is %ld\n", sysmapLen);
  sysmapPages = sysmapLen / 4096;
  printf("System map pages to copy = %ld\n", sysmapPages);
  while (fgets(inbuf, 4096, sysmap))
    ;
  ptr_end = strstr(inbuf, " _end");
  if (!ptr_end) {
    fprintf(stderr, "Unable to find _end in the sysmap file \n");
    fprintf(stderr, "inbuf: \n");
    fprintf(stderr, "%s \n", inbuf);
    exit(1);
  }
  printf("Found _end in the last page of the sysmap - backing up 10 characters "
         "it looks like %s",
         ptr_end - 10);
  sysmapStartOffs = (unsigned int)strtol(ptr_end - 10, NULL, 16);
  padPages = sysmapStartOffs / 4096 - roundedKernelPages;
  if (padPages < 0) {
    sysmapStartOffs = roundedKernelLen;
    printf("vmlinux is larger than _end indicates it needs to be - "
           "sysmapStartOffs = %lx \n",
           sysmapStartOffs);
    padPages = 0;
    printf("will insert %lx pages between the vmlinux and the start of the "
           "sysmap \n",
           padPages);
  } else {
    printf("vmlinux is smaller than _end indicates is needed - sysmapStartOffs "
           "= %lx \n",
           sysmapStartOffs);
    printf("will insert %lx pages between the vmlinux and the start of the "
           "sysmap \n",
           padPages);
  }
  for (i = 0; i < (((64 * 1024) / 4096)); ++i) {
    get4k(inputVmlinux, inbuf);
    put4k(outputVmlinux, inbuf);
  }
  fseek(inputVmlinux, (64 * 1024), SEEK_SET);
  for (i = 0; i < roundedKernelPages; ++i) {
    get4k(inputVmlinux, inbuf);
    if (i == 0) {
      unsigned long *p;
      printf("Storing embedded_sysmap_start at 0x3c\n");
      p = (unsigned long *)(inbuf + 0x3c);
      *p = sysmapStartOffs;
      printf("Storing embedded_sysmap_end at 0x44\n");
      p = (unsigned long *)(inbuf + 0x44);
      *p = sysmapStartOffs + sysmapFileLen;
    }
    put4k(outputVmlinux, inbuf);
  }
  for (i = 0; i < padPages; ++i) {
    memset(inbuf, 0, 4096);
    put4k(outputVmlinux, inbuf);
  }
  fseek(sysmap, 0, SEEK_SET);
  for (i = 0; i < sysmapPages; ++i) {
    get4k(sysmap, inbuf);
    put4k(outputVmlinux, inbuf);
  }
  fclose(sysmap);
  fclose(inputVmlinux);
  fclose(outputVmlinux);
  chmod(argv[3],
        S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10a0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x1018(%rbp)
movq   $0x0,-0x1020(%rbp)
movq   $0x0,-0x1028(%rbp)
movq   $0x0,-0x1030(%rbp)
movq   $0x0,-0x1038(%rbp)
movq   $0x0,-0x1040(%rbp)
movq   $0x0,-0x1048(%rbp)
movq   $0x0,-0x1050(%rbp)
movq   $0x0,-0x1058(%rbp)
movq   $0x0,-0x1060(%rbp)
movq   $0x0,-0x1068(%rbp)
movq   $0x0,-0x1070(%rbp)
movq   $0x0,-0x1078(%rbp)
movq   $0x0,-0x1080(%rbp)
movq   $0x0,-0x1088(%rbp)
movq   $0x0,-0x1090(%rbp)
cmpl   $0x2,-0x8(%rbp)
jge    12d4 <main+0xf4>
mov    0x2cfe(%rip),%rax
mov    (%rax),%edi
lea    0xd3d(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    $0x1,%edi
call   10e0 <exit@plt>
cmpl   $0x3,-0x8(%rbp)
jge    12ff <main+0x11f>
mov    0x2cd3(%rip),%rax
mov    (%rax),%edi
lea    0xd34(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    $0x1,%edi
call   10e0 <exit@plt>
cmpl   $0x4,-0x8(%rbp)
jge    132a <main+0x14a>
mov    0x2ca8(%rip),%rax
mov    (%rax),%edi
lea    0xd28(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    $0x1,%edi
call   10e0 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xd2e(%rip),%rsi
call   10d0 <fopen@plt>
mov    %rax,-0x1018(%rbp)
cmpq   $0x0,-0x1018(%rbp)
jne    137c <main+0x19c>
mov    0x2c5e(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdx
lea    0xcfe(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    $0x1,%edi
call   10e0 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xcdc(%rip),%rsi
call   10d0 <fopen@plt>
mov    %rax,-0x1028(%rbp)
cmpq   $0x0,-0x1028(%rbp)
jne    13ce <main+0x1ee>
mov    0x2c0c(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdx
lea    0xcdb(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    $0x1,%edi
call   10e0 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
lea    0xcb2(%rip),%rsi
call   10d0 <fopen@plt>
mov    %rax,-0x1030(%rbp)
cmpq   $0x0,-0x1030(%rbp)
jne    1420 <main+0x240>
mov    0x2bba(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdx
lea    0xc82(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    $0x1,%edi
call   10e0 <exit@plt>
mov    -0x1028(%rbp),%rdi
mov    0x2bb2(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   10b0 <fseek@plt>
mov    -0x1028(%rbp),%rdi
call   1080 <ftell@plt>
mov    %rax,-0x1058(%rbp)
mov    -0x1028(%rbp),%rdi
mov    0x2b58(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   10b0 <fseek@plt>
mov    -0x1058(%rbp),%rsi
lea    0xc4c(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
cmpq   $0x0,-0x1058(%rbp)
jne    14a5 <main+0x2c5>
mov    0x2b2d(%rip),%rax
mov    (%rax),%edi
lea    0xc3f(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    $0x1,%edi
call   10e0 <exit@plt>
mov    -0x1058(%rbp),%rax
sub    $0x10000,%rax
mov    %rax,-0x1060(%rbp)
mov    -0x1060(%rbp),%rsi
mov    -0x1060(%rbp),%rdx
lea    0xc38(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x1060(%rbp),%rax
and    $0xfff,%rax
mov    %rax,-0x1068(%rbp)
mov    -0x1060(%rbp),%rax
mov    %rax,-0x1070(%rbp)
cmpq   $0x0,-0x1068(%rbp)
je     151f <main+0x33f>
mov    $0x1000,%eax
sub    -0x1068(%rbp),%rax
add    -0x1070(%rbp),%rax
mov    %rax,-0x1070(%rbp)
mov    -0x1070(%rbp),%rsi
mov    -0x1070(%rbp),%rdx
lea    0xc07(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x1070(%rbp),%rax
shr    $0xc,%rax
mov    %rax,-0x1088(%rbp)
mov    -0x1088(%rbp),%rsi
mov    -0x1088(%rbp),%rdx
lea    0xc10(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x1018(%rbp),%rdi
mov    0x2a69(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   10b0 <fseek@plt>
mov    -0x1018(%rbp),%rdi
call   1080 <ftell@plt>
mov    %rax,-0x1040(%rbp)
mov    -0x1018(%rbp),%rdi
mov    0x2a0f(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   10b0 <fseek@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
mov    -0x1040(%rbp),%rdx
lea    0xbd3(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x1040(%rbp),%rax
mov    %rax,-0x1048(%rbp)
mov    -0x1048(%rbp),%rcx
and    $0xfff,%rcx
mov    $0x1000,%eax
sub    %rcx,%rax
mov    %rax,-0x1050(%rbp)
cmpq   $0x0,-0x1050(%rbp)
je     162a <main+0x44a>
mov    -0x1050(%rbp),%rsi
lea    0xb99(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x1050(%rbp),%rax
add    -0x1048(%rbp),%rax
mov    %rax,-0x1048(%rbp)
mov    -0x1048(%rbp),%rsi
lea    0xbae(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x1048(%rbp),%rax
shr    $0xc,%rax
mov    %rax,-0x1080(%rbp)
mov    -0x1080(%rbp),%rsi
lea    0xba7(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x1010(%rbp),%rdi
mov    -0x1018(%rbp),%rdx
mov    $0x1000,%esi
call   1060 <fgets@plt>
cmp    $0x0,%rax
je     168d <main+0x4ad>
jmp    1666 <main+0x486>
lea    -0x1010(%rbp),%rdi
lea    0xb8b(%rip),%rsi
call   10f0 <strstr@plt>
mov    %rax,-0x1020(%rbp)
cmpq   $0x0,-0x1020(%rbp)
jne    170b <main+0x52b>
mov    0x28fc(%rip),%rax
mov    (%rax),%edi
lea    0xb67(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    0x28e5(%rip),%rax
mov    (%rax),%edi
lea    0xb79(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    0x28ce(%rip),%rax
mov    (%rax),%edi
lea    -0x1010(%rbp),%rdx
lea    0xb64(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    $0x1,%edi
call   10e0 <exit@plt>
mov    -0x1020(%rbp),%rsi
add    $0xfffffffffffffff6,%rsi
lea    0xb46(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x1020(%rbp),%rdi
add    $0xfffffffffffffff6,%rdi
xor    %eax,%eax
mov    %eax,%esi
mov    $0x10,%edx
call   1090 <strtol@plt>
mov    %eax,%eax
mov    %rax,-0x1078(%rbp)
mov    -0x1078(%rbp),%rax
shr    $0xc,%rax
sub    -0x1088(%rbp),%rax
mov    %rax,-0x1090(%rbp)
cmpq   $0x0,-0x1090(%rbp)
jge    17b5 <main+0x5d5>
mov    -0x1070(%rbp),%rax
mov    %rax,-0x1078(%rbp)
mov    -0x1078(%rbp),%rsi
lea    0xb30(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movq   $0x0,-0x1090(%rbp)
mov    -0x1090(%rbp),%rsi
lea    0xb5f(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    17df <main+0x5ff>
mov    -0x1078(%rbp),%rsi
lea    0xb8d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x1090(%rbp),%rsi
lea    0xb30(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movq   $0x0,-0x1038(%rbp)
cmpq   $0x10,-0x1038(%rbp)
10
jge    1835 <main+0x655>
mov    -0x1028(%rbp),%rdi
lea    -0x1010(%rbp),%rsi
call   10a0 <get4k@plt>
mov    -0x1030(%rbp),%rdi
lea    -0x1010(%rbp),%rsi
call   1100 <put4k@plt>
mov    -0x1038(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x1038(%rbp)
jmp    17ea <main+0x60a>
mov    -0x1028(%rbp),%rdi
mov    0x276d(%rip),%rax
mov    (%rax),%edx
mov    $0x10000,%esi
call   10b0 <fseek@plt>
movq   $0x0,-0x1038(%rbp)
mov    -0x1038(%rbp),%rax
cmp    -0x1088(%rbp),%rax
jae    1922 <main+0x742>
mov    -0x1028(%rbp),%rdi
lea    -0x1010(%rbp),%rsi
call   10a0 <get4k@plt>
cmpq   $0x0,-0x1038(%rbp)
jne    18f8 <main+0x718>
lea    0xb05(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x1010(%rbp),%rax
add    $0x3c,%rax
mov    %rax,-0x1098(%rbp)
mov    -0x1078(%rbp),%rcx
mov    -0x1098(%rbp),%rax
mov    %rcx,(%rax)
lea    0xafb(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x1010(%rbp),%rax
add    $0x44,%rax
mov    %rax,-0x1098(%rbp)
mov    -0x1078(%rbp),%rcx
add    -0x1040(%rbp),%rcx
mov    -0x1098(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x1030(%rbp),%rdi
lea    -0x1010(%rbp),%rsi
call   1100 <put4k@plt>
mov    -0x1038(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x1038(%rbp)
jmp    185a <main+0x67a>
movq   $0x0,-0x1038(%rbp)
mov    -0x1038(%rbp),%rax
cmp    -0x1090(%rbp),%rax
jge    197e <main+0x79e>
lea    -0x1010(%rbp),%rdi
xor    %esi,%esi
mov    $0x1000,%edx
call   1050 <memset@plt>
mov    -0x1030(%rbp),%rdi
lea    -0x1010(%rbp),%rsi
call   1100 <put4k@plt>
mov    -0x1038(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x1038(%rbp)
jmp    192d <main+0x74d>
mov    -0x1018(%rbp),%rdi
mov    0x2624(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   10b0 <fseek@plt>
movq   $0x0,-0x1038(%rbp)
mov    -0x1038(%rbp),%rax
cmp    -0x1080(%rbp),%rax
jae    19f1 <main+0x811>
mov    -0x1018(%rbp),%rdi
lea    -0x1010(%rbp),%rsi
call   10a0 <get4k@plt>
mov    -0x1030(%rbp),%rdi
lea    -0x1010(%rbp),%rsi
call   1100 <put4k@plt>
mov    -0x1038(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x1038(%rbp)
jmp    19a0 <main+0x7c0>
mov    -0x1018(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x1028(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x1030(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
mov    0x2574(%rip),%rax
mov    (%rax),%esi
mov    0x25a3(%rip),%rax
or     (%rax),%esi
mov    0x25a2(%rip),%rax
or     (%rax),%esi
mov    0x2569(%rip),%rax
or     (%rax),%esi
mov    0x2580(%rip),%rax
or     (%rax),%esi
mov    0x254f(%rip),%rax
or     (%rax),%esi
mov    0x258e(%rip),%rax
or     (%rax),%esi
call   10c0 <chmod@plt>
xor    %eax,%eax
add    $0x10a0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x1048,%rsp
cmp    $0x1,%edi
jle    17b5 <main+0x5c5>
cmp    $0x2,%edi
je     17c7 <main+0x5d7>
cmp    $0x3,%edi
jbe    17d9 <main+0x5e9>
mov    %rsi,%r13
mov    0x8(%rsi),%rdi
lea    0xe3d(%rip),%rsi
call   10e0 <fopen@plt>
test   %rax,%rax
je     17eb <main+0x5fb>
mov    %rax,%r12
mov    0x10(%r13),%rdi
lea    0xe21(%rip),%rsi
call   10e0 <fopen@plt>
test   %rax,%rax
je     1804 <main+0x614>
mov    %rax,0x18(%rsp)
mov    0x18(%r13),%rdi
lea    0xe2b(%rip),%rsi
call   10e0 <fopen@plt>
test   %rax,%rax
je     181a <main+0x62a>
mov    %rax,%r15
mov    0x2d64(%rip),%rax
mov    (%rax),%edx
mov    0x18(%rsp),%rbp
mov    %rbp,%rdi
xor    %esi,%esi
call   10c0 <fseek@plt>
mov    %rbp,%rdi
call   1090 <ftell@plt>
mov    %rax,%rbx
mov    0x2d11(%rip),%rax
mov    (%rax),%edx
mov    %rbp,%rdi
xor    %esi,%esi
call   10c0 <fseek@plt>
lea    0xe09(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
test   %rbx,%rbx
je     1830 <main+0x640>
lea    -0x10000(%rbx),%rbp
lea    0xe33(%rip),%rdi
mov    %rbp,%rsi
mov    %rbp,%rdx
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbx,%r14
add    $0xffffffffffff1000,%r14
and    $0xfffffffffffff000,%r14
test   $0xfff,%ebx
cmove  %rbp,%r14
lea    0xe39(%rip),%rdi
mov    %r14,%rsi
mov    %r14,%rdx
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r14,0x8(%rsp)
shr    $0xc,%r14
lea    0xe53(%rip),%rdi
mov    %r14,%rsi
mov    %r14,0x10(%rsp)
mov    %r14,%rdx
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x2ca8(%rip),%rax
mov    (%rax),%edx
mov    %r12,%rdi
xor    %esi,%esi
call   10c0 <fseek@plt>
mov    %r12,%rdi
call   1090 <ftell@plt>
mov    %rax,%rbp
mov    0x2c5a(%rip),%rax
mov    (%rax),%edx
mov    %r12,%rdi
xor    %esi,%esi
call   10c0 <fseek@plt>
mov    0x8(%r13),%rsi
lea    0xe26(%rip),%rdi
mov    %rbp,%rdx
xor    %eax,%eax
call   1050 <printf@plt>
mov    %ebp,%eax
and    $0xfff,%eax
mov    $0x1000,%ebx
sub    %rax,%rbx
lea    0xe1a(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbp,0x20(%rsp)
add    %rbp,%rbx
lea    0xe40(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbx,%rsi
shr    $0xc,%rsi
lea    0xe48(%rip),%rdi
mov    %rsi,0x28(%rsp)
xor    %eax,%eax
call   1050 <printf@plt>
lea    0x40(%rsp),%rbp
nop
mov    %rbp,%rdi
mov    $0x1000,%esi
mov    %r12,%rdx
call   1070 <fgets@plt>
test   %rax,%rax
jne    13d0 <main+0x1e0>
lea    0xe3a(%rip),%rsi
lea    0x40(%rsp),%rdi
call   1100 <strstr@plt>
test   %rax,%rax
je     1851 <main+0x661>
mov    %rax,%rbp
add    $0xfffffffffffffff6,%rbp
lea    0xe56(%rip),%rdi
mov    %rbp,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbp,%rdi
xor    %esi,%esi
mov    $0x10,%edx
call   10a0 <strtol@plt>
mov    %eax,%eax
mov    %rax,%r14
shr    $0xc,%r14
sub    0x10(%rsp),%r14
mov    %rbx,0x30(%rsp)
js     1457 <main+0x267>
lea    0xf0e(%rip),%rdi
mov    %rax,(%rsp)
mov    %rax,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x8(%rsp),%rbp
jmp    1474 <main+0x284>
lea    0xe5b(%rip),%rdi
xor    %r14d,%r14d
mov    0x8(%rsp),%rbp
mov    %rbp,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbp,(%rsp)
mov    %r13,0x38(%rsp)
lea    0xe88(%rip),%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0x40(%rsp),%r13
mov    0x18(%rsp),%rbx
mov    %rbx,%rdi
mov    %r13,%rsi
call   10b0 <get4k@plt>
mov    %r15,%rdi
mov    %r13,%rsi
call   1110 <put4k@plt>
mov    %rbx,%rdi
mov    %r13,%rsi
call   10b0 <get4k@plt>
mov    %r15,%rdi
mov    %r13,%rsi
call   1110 <put4k@plt>
mov    %rbx,%rdi
mov    %r13,%rsi
call   10b0 <get4k@plt>
mov    %r15,%rdi
mov    %r13,%rsi
call   1110 <put4k@plt>
mov    %rbx,%rdi
mov    %r13,%rsi
call   10b0 <get4k@plt>
mov    %r15,%rdi
mov    %r13,%rsi
call   1110 <put4k@plt>
mov    %rbx,%rdi
mov    %r13,%rsi
call   10b0 <get4k@plt>
mov    %r15,%rdi
mov    %r13,%rsi
call   1110 <put4k@plt>
mov    %rbx,%rdi
mov    %r13,%rsi
call   10b0 <get4k@plt>
mov    %r15,%rdi
mov    %r13,%rsi
call   1110 <put4k@plt>
mov    %rbx,%rdi
mov    %r13,%rsi
call   10b0 <get4k@plt>
mov    %r15,%rdi
mov    %r13,%rsi
call   1110 <put4k@plt>
mov    %rbx,%rdi
mov    %r13,%rsi
call   10b0 <get4k@plt>
mov    %r15,%rdi
mov    %r13,%rsi
call   1110 <put4k@plt>
mov    %rbx,%rdi
mov    %r13,%rsi
call   10b0 <get4k@plt>
mov    %r15,%rdi
mov    %r13,%rsi
call   1110 <put4k@plt>
mov    %rbx,%rdi
mov    %r13,%rsi
call   10b0 <get4k@plt>
mov    %r15,%rdi
mov    %r13,%rsi
call   1110 <put4k@plt>
mov    %rbx,%rdi
mov    %r13,%rsi
call   10b0 <get4k@plt>
mov    %r15,%rdi
mov    %r13,%rsi
call   1110 <put4k@plt>
mov    %rbx,%rdi
mov    %r13,%rsi
call   10b0 <get4k@plt>
mov    %r15,%rdi
mov    %r13,%rsi
call   1110 <put4k@plt>
mov    %rbx,%rdi
mov    %r13,%rsi
call   10b0 <get4k@plt>
mov    %r15,%rdi
mov    %r13,%rsi
call   1110 <put4k@plt>
mov    %rbx,%rdi
mov    %r13,%rsi
call   10b0 <get4k@plt>
mov    %r15,%rdi
mov    %r13,%rsi
call   1110 <put4k@plt>
mov    %rbx,%rdi
mov    %r13,%rsi
call   10b0 <get4k@plt>
mov    %r15,%rdi
mov    %r13,%rsi
call   1110 <put4k@plt>
mov    %rbx,%rdi
mov    %r13,%rsi
call   10b0 <get4k@plt>
mov    %r15,%rdi
mov    %r13,%rsi
mov    %rbx,%r13
call   1110 <put4k@plt>
mov    0x29b2(%rip),%rax
mov    (%rax),%edx
mov    %rbx,%rdi
mov    $0x10000,%esi
call   10c0 <fseek@plt>
cmp    $0x1000,%rbp
jb     16ac <main+0x4bc>
mov    0x10(%rsp),%rax
cmp    $0x2,%rax
mov    $0x1,%ebx
cmovae %rax,%rbx
lea    0x40(%rsp),%rsi
mov    %r13,%rdi
call   10b0 <get4k@plt>
mov    0x20(%rsp),%rbp
add    (%rsp),%rbp
lea    0xd52(%rip),%rdi
call   1030 <puts@plt>
mov    (%rsp),%rax
mov    %rax,0x7c(%rsp)
lea    0xd63(%rip),%rdi
call   1030 <puts@plt>
mov    %rbp,0x84(%rsp)
mov    %r15,%rdi
lea    0x40(%rsp),%rsi
call   1110 <put4k@plt>
cmpq   $0x2000,0x8(%rsp)
jb     16ac <main+0x4bc>
add    $0xffffffffffffffff,%rbx
lea    0x40(%rsp),%rbp
nopl   0x0(%rax)
mov    %r13,%rdi
mov    %rbp,%rsi
call   10b0 <get4k@plt>
mov    %r15,%rdi
mov    %rbp,%rsi
call   1110 <put4k@plt>
add    $0xffffffffffffffff,%rbx
jne    1690 <main+0x4a0>
test   %r14,%r14
jle    16e0 <main+0x4f0>
lea    0x40(%rsp),%rbp
cs nopw 0x0(%rax,%rax,1)
mov    %rbp,%rdi
xor    %esi,%esi
mov    $0x1000,%edx
call   1060 <memset@plt>
mov    %r15,%rdi
mov    %rbp,%rsi
call   1110 <put4k@plt>
add    $0xffffffffffffffff,%r14
jne    16c0 <main+0x4d0>
mov    0x28c9(%rip),%rax
mov    (%rax),%edx
mov    %r12,%rdi
xor    %esi,%esi
call   10c0 <fseek@plt>
cmpq   $0x1000,0x30(%rsp)
jb     173c <main+0x54c>
mov    0x28(%rsp),%rax
cmp    $0x2,%rax
mov    $0x1,%ebx
cmovae %rax,%rbx
lea    0x40(%rsp),%rbp
cs nopw 0x0(%rax,%rax,1)
nop
mov    %r12,%rdi
mov    %rbp,%rsi
call   10b0 <get4k@plt>
mov    %r15,%rdi
mov    %rbp,%rsi
call   1110 <put4k@plt>
add    $0xffffffffffffffff,%rbx
jne    1720 <main+0x530>
mov    %r12,%rdi
call   1040 <fclose@plt>
mov    %r13,%rdi
call   1040 <fclose@plt>
mov    %r15,%rdi
call   1040 <fclose@plt>
mov    0x283d(%rip),%rax
mov    0x286e(%rip),%rcx
mov    (%rcx),%esi
or     (%rax),%esi
mov    0x286b(%rip),%rax
or     (%rax),%esi
mov    0x2832(%rip),%rax
or     (%rax),%esi
mov    0x2849(%rip),%rax
or     (%rax),%esi
mov    0x2818(%rip),%rax
or     (%rax),%esi
mov    0x38(%rsp),%rax
mov    0x18(%rax),%rdi
mov    0x284e(%rip),%rax
or     (%rax),%esi
call   10d0 <chmod@plt>
xor    %eax,%eax
add    $0x1048,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x27fc(%rip),%rax
mov    (%rax),%edi
lea    0x83b(%rip),%rsi
jmp    1840 <main+0x650>
mov    0x27ea(%rip),%rax
mov    (%rax),%edi
lea    0x84b(%rip),%rsi
jmp    1840 <main+0x650>
mov    0x27d8(%rip),%rax
mov    (%rax),%edi
lea    0x858(%rip),%rsi
jmp    1840 <main+0x650>
mov    0x27c6(%rip),%rax
mov    (%rax),%edi
mov    0x8(%r13),%rdx
lea    0x86a(%rip),%rsi
jmp    1886 <main+0x696>
mov    0x27ad(%rip),%rax
mov    (%rax),%edi
mov    0x10(%r13),%rdx
lea    0x880(%rip),%rsi
jmp    1886 <main+0x696>
mov    0x2797(%rip),%rax
mov    (%rax),%edi
mov    0x18(%r13),%rdx
lea    0x863(%rip),%rsi
jmp    1886 <main+0x696>
mov    0x2781(%rip),%rax
mov    (%rax),%edi
lea    0x893(%rip),%rsi
xor    %eax,%eax
call   1080 <fprintf@plt>
mov    $0x1,%edi
call   10f0 <exit@plt>
mov    0x2760(%rip),%rbx
mov    (%rbx),%edi
lea    0x9cb(%rip),%rsi
xor    %eax,%eax
call   1080 <fprintf@plt>
mov    (%rbx),%edi
lea    0x9e4(%rip),%rsi
xor    %eax,%eax
call   1080 <fprintf@plt>
mov    (%rbx),%edi
lea    0x9dd(%rip),%rsi
lea    0x40(%rsp),%rdx
xor    %eax,%eax
call   1080 <fprintf@plt>
mov    $0x1,%edi
call   10f0 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [34 x i8] c"Name of System Map file missing.\0A\00"
@.str.1 = [31 x i8] c"Name of vmlinux file missing.\0A\00"
@.str.2 = [38 x i8] c"Name of vmlinux output file missing.\0A\00"
@.str.3 = [2 x i8] c"r\00"
@.str.4 = [38 x i8] c"System Map file \22%s\22 failed to open.\0A\00"
@.str.5 = [35 x i8] c"vmlinux file \22%s\22 failed to open.\0A\00"
@.str.6 = [2 x i8] c"w\00"
@.str.7 = [42 x i8] c"output vmlinux file \22%s\22 failed to open.\0A\00"
@SEEK_END = global i32 0
@SEEK_SET = global i32 0
@.str.8 = [24 x i8] c"kernel file size = %ld\0A\00"
@.str.9 = [51 x i8] c"You must have a linux kernel specified as argv[2]\0A\00"
@.str.10 = [53 x i8] c"actual kernel length (minus ELF header) = %ld/%lxx \0A\00"
@.str.11 = [55 x i8] c"Kernel length rounded up to a 4k multiple = %ld/%lxx \0A\00"
@.str.12 = [33 x i8] c"Kernel pages to copy = %ld/%lxx\0A\00"
@.str.13 = [20 x i8] c"%s file size = %ld\0A\00"
@.str.14 = [63 x i8] c"Rounding System Map file up to a multiple of 4096, adding %ld\0A\00"
@.str.15 = [32 x i8] c"Rounded System Map size is %ld\0A\00"
@.str.16 = [32 x i8] c"System map pages to copy = %ld\0A\00"
@.str.17 = [6 x i8] c" _end\00"
@.str.18 = [41 x i8] c"Unable to find _end in the sysmap file \0A\00"
@.str.19 = [9 x i8] c"inbuf: \0A\00"
@.str.20 = [5 x i8] c"%s \0A\00"
@.str.21 = [86 x i8] c"Found _end in the last page of the sysmap - backing up 10 characters it looks like %s\00"
@.str.22 = [79 x i8] c"vmlinux is larger than _end indicates it needs to be - sysmapStartOffs = %lx \0A\00"
@.str.23 = [72 x i8] c"will insert %lx pages between the vmlinux and the start of the sysmap \0A\00"
@.str.24 = [75 x i8] c"vmlinux is smaller than _end indicates is needed - sysmapStartOffs = %lx \0A\00"
@.str.25 = [39 x i8] c"Storing embedded_sysmap_start at 0x3c\0A\00"
@.str.26 = [37 x i8] c"Storing embedded_sysmap_end at 0x44\0A\00"
@S_IRUSR = global i32 0
@S_IWUSR = global i32 0
@S_IXUSR = global i32 0
@S_IRGRP = global i32 0
@S_IXGRP = global i32 0
@S_IROTH = global i32 0
@S_IXOTH = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [4096 x i8]
%7 = alloca i32*
%8 = alloca i8*
%9 = alloca i32*
%10 = alloca i32*
%11 = alloca i64
%12 = alloca i64
%13 = alloca i64
%14 = alloca i64
%15 = alloca i64
%16 = alloca i64
%17 = alloca i64
%18 = alloca i64
%19 = alloca i64
%20 = alloca i64
%21 = alloca i64
%22 = alloca i64
%23 = alloca i64*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32* null, i32** %7
store i8* null, i8** %8
store i32* null, i32** %9
store i32* null, i32** %10
store i64 0, i64* %11
store i64 0, i64* %12
store i64 0, i64* %13
store i64 0, i64* %14
store i64 0, i64* %15
store i64 0, i64* %16
store i64 0, i64* %17
store i64 0, i64* %18
store i64 0, i64* %19
store i64 0, i64* %20
store i64 0, i64* %21
store i64 0, i64* %22
%24 = load i32, i32* %4
%25 = icmp slt i32 %24, 2
br i1 %25, label %26, label %30
26: ; preds = %2
%27 = load i32, i32* @stderr
%28 = call i32 (i32, i8*, ...) @fprintf(i32 %27, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0))
%29 = call i32 @exit(i32 1)
unreachable
30: ; preds = %2
%31 = load i32, i32* %4
%32 = icmp slt i32 %31, 3
br i1 %32, label %33, label %37
33: ; preds = %30
%34 = load i32, i32* @stderr
%35 = call i32 (i32, i8*, ...) @fprintf(i32 %34, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0))
%36 = call i32 @exit(i32 1)
unreachable
37: ; preds = %30
%38 = load i32, i32* %4
%39 = icmp slt i32 %38, 4
br i1 %39, label %40, label %44
40: ; preds = %37
%41 = load i32, i32* @stderr
%42 = call i32 (i32, i8*, ...) @fprintf(i32 %41, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.2, i64 0, i64 0))
%43 = call i32 @exit(i32 1)
unreachable
44: ; preds = %37
%45 = load i8**, i8*** %5
%46 = getelementptr inbounds i8*, i8** %45, i64 1
%47 = load i8*, i8** %46
%48 = call i32* @fopen(i8* %47, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
store i32* %48, i32** %7
%49 = load i32*, i32** %7
%50 = icmp ne i32* %49, null
br i1 %50, label %58, label %51
51: ; preds = %44
%52 = load i32, i32* @stderr
%53 = load i8**, i8*** %5
%54 = getelementptr inbounds i8*, i8** %53, i64 1
%55 = load i8*, i8** %54
%56 = call i32 (i32, i8*, ...) @fprintf(i32 %52, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.4, i64 0, i64 0), i8* %55)
%57 = call i32 @exit(i32 1)
unreachable
58: ; preds = %44
%59 = load i8**, i8*** %5
%60 = getelementptr inbounds i8*, i8** %59, i64 2
%61 = load i8*, i8** %60
%62 = call i32* @fopen(i8* %61, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
store i32* %62, i32** %9
%63 = load i32*, i32** %9
%64 = icmp ne i32* %63, null
br i1 %64, label %72, label %65
65: ; preds = %58
%66 = load i32, i32* @stderr
%67 = load i8**, i8*** %5
%68 = getelementptr inbounds i8*, i8** %67, i64 2
%69 = load i8*, i8** %68
%70 = call i32 (i32, i8*, ...) @fprintf(i32 %66, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.5, i64 0, i64 0), i8* %69)
%71 = call i32 @exit(i32 1)
unreachable
72: ; preds = %58
%73 = load i8**, i8*** %5
%74 = getelementptr inbounds i8*, i8** %73, i64 3
%75 = load i8*, i8** %74
%76 = call i32* @fopen(i8* %75, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0))
store i32* %76, i32** %10
%77 = load i32*, i32** %10
%78 = icmp ne i32* %77, null
br i1 %78, label %86, label %79
79: ; preds = %72
%80 = load i32, i32* @stderr
%81 = load i8**, i8*** %5
%82 = getelementptr inbounds i8*, i8** %81, i64 3
%83 = load i8*, i8** %82
%84 = call i32 (i32, i8*, ...) @fprintf(i32 %80, i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.7, i64 0, i64 0), i8* %83)
%85 = call i32 @exit(i32 1)
unreachable
86: ; preds = %72
%87 = load i32*, i32** %9
%88 = load i32, i32* @SEEK_END
%89 = call i32 @fseek(i32* %87, i32 0, i32 %88)
%90 = load i32*, i32** %9
%91 = call i64 @ftell(i32* %90)
store i64 %91, i64* %15
%92 = load i32*, i32** %9
%93 = load i32, i32* @SEEK_SET
%94 = call i32 @fseek(i32* %92, i32 0, i32 %93)
%95 = load i64, i64* %15
%96 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.8, i64 0, i64 0), i64 %95)
%97 = load i64, i64* %15
%98 = icmp eq i64 %97, 0
br i1 %98, label %99, label %103
99: ; preds = %86
%100 = load i32, i32* @stderr
%101 = call i32 (i32, i8*, ...) @fprintf(i32 %100, i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.9, i64 0, i64 0))
%102 = call i32 @exit(i32 1)
unreachable
103: ; preds = %86
%104 = load i64, i64* %15
%105 = sub i64 %104, 65536
store i64 %105, i64* %16
%106 = load i64, i64* %16
%107 = load i64, i64* %16
%108 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.10, i64 0, i64 0), i64 %106, i64 %107)
%109 = load i64, i64* %16
%110 = urem i64 %109, 4096
store i64 %110, i64* %17
%111 = load i64, i64* %16
store i64 %111, i64* %18
%112 = load i64, i64* %17
%113 = icmp ne i64 %112, 0
br i1 %113, label %114, label %119
114: ; preds = %103
%115 = load i64, i64* %17
%116 = sub i64 4096, %115
%117 = load i64, i64* %18
%118 = add i64 %117, %116
store i64 %118, i64* %18
br label %119
119: ; preds = %114, %103
%120 = load i64, i64* %18
%121 = load i64, i64* %18
%122 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str.11, i64 0, i64 0), i64 %120, i64 %121)
%123 = load i64, i64* %18
%124 = udiv i64 %123, 4096
store i64 %124, i64* %21
%125 = load i64, i64* %21
%126 = load i64, i64* %21
%127 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.12, i64 0, i64 0), i64 %125, i64 %126)
%128 = load i32*, i32** %7
%129 = load i32, i32* @SEEK_END
%130 = call i32 @fseek(i32* %128, i32 0, i32 %129)
%131 = load i32*, i32** %7
%132 = call i64 @ftell(i32* %131)
store i64 %132, i64* %12
%133 = load i32*, i32** %7
%134 = load i32, i32* @SEEK_SET
%135 = call i32 @fseek(i32* %133, i32 0, i32 %134)
%136 = load i8**, i8*** %5
%137 = getelementptr inbounds i8*, i8** %136, i64 1
%138 = load i8*, i8** %137
%139 = load i64, i64* %12
%140 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.13, i64 0, i64 0), i8* %138, i64 %139)
%141 = load i64, i64* %12
store i64 %141, i64* %13
%142 = load i64, i64* %13
%143 = urem i64 %142, 4096
%144 = sub i64 4096, %143
store i64 %144, i64* %14
%145 = load i64, i64* %14
%146 = icmp ne i64 %145, 0
br i1 %146, label %147, label %153
147: ; preds = %119
%148 = load i64, i64* %14
%149 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([63 x i8], [63 x i8]* @.str.14, i64 0, i64 0), i64 %148)
%150 = load i64, i64* %14
%151 = load i64, i64* %13
%152 = add i64 %151, %150
store i64 %152, i64* %13
br label %153
153: ; preds = %147, %119
%154 = load i64, i64* %13
%155 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.15, i64 0, i64 0), i64 %154)
%156 = load i64, i64* %13
%157 = udiv i64 %156, 4096
store i64 %157, i64* %20
%158 = load i64, i64* %20
%159 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.16, i64 0, i64 0), i64 %158)
br label %160
160: ; preds = %165, %153
%161 = getelementptr inbounds [4096 x i8], [4096 x i8]* %6, i64 0, i64 0
%162 = load i32*, i32** %7
%163 = call i64 @fgets(i8* %161, i32 4096, i32* %162)
%164 = icmp ne i64 %163, 0
br i1 %164, label %165, label %166
165: ; preds = %160
br label %160
166: ; preds = %160
%167 = getelementptr inbounds [4096 x i8], [4096 x i8]* %6, i64 0, i64 0
%168 = call i8* @strstr(i8* %167, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.17, i64 0, i64 0))
store i8* %168, i8** %8
%169 = load i8*, i8** %8
%170 = icmp ne i8* %169, null
br i1 %170, label %180, label %171
171: ; preds = %166
%172 = load i32, i32* @stderr
%173 = call i32 (i32, i8*, ...) @fprintf(i32 %172, i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.18, i64 0, i64 0))
%174 = load i32, i32* @stderr
%175 = call i32 (i32, i8*, ...) @fprintf(i32 %174, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.19, i64 0, i64 0))
%176 = load i32, i32* @stderr
%177 = getelementptr inbounds [4096 x i8], [4096 x i8]* %6, i64 0, i64 0
%178 = call i32 (i32, i8*, ...) @fprintf(i32 %176, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.20, i64 0, i64 0), i8* %177)
%179 = call i32 @exit(i32 1)
unreachable
180: ; preds = %166
%181 = load i8*, i8** %8
%182 = getelementptr inbounds i8, i8* %181, i64 -10
%183 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([86 x i8], [86 x i8]* @.str.21, i64 0, i64 0), i8* %182)
%184 = load i8*, i8** %8
%185 = getelementptr inbounds i8, i8* %184, i64 -10
%186 = call i64 @strtol(i8* %185, i32* null, i32 16)
%187 = trunc i64 %186 to i32
%188 = zext i32 %187 to i64
store i64 %188, i64* %19
%189 = load i64, i64* %19
%190 = udiv i64 %189, 4096
%191 = load i64, i64* %21
%192 = sub i64 %190, %191
store i64 %192, i64* %22
%193 = load i64, i64* %22
%194 = icmp slt i64 %193, 0
br i1 %194, label %195, label %201
195: ; preds = %180
%196 = load i64, i64* %18
store i64 %196, i64* %19
%197 = load i64, i64* %19
%198 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([79 x i8], [79 x i8]* @.str.22, i64 0, i64 0), i64 %197)
store i64 0, i64* %22
%199 = load i64, i64* %22
%200 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([72 x i8], [72 x i8]* @.str.23, i64 0, i64 0), i64 %199)
br label %206
201: ; preds = %180
%202 = load i64, i64* %19
%203 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([75 x i8], [75 x i8]* @.str.24, i64 0, i64 0), i64 %202)
%204 = load i64, i64* %22
%205 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([72 x i8], [72 x i8]* @.str.23, i64 0, i64 0), i64 %204)
br label %206
206: ; preds = %201, %195
store i64 0, i64* %11
br label %207
207: ; preds = %217, %206
%208 = load i64, i64* %11
%209 = icmp slt i64 %208, 16
br i1 %209, label %210, label %220
210: ; preds = %207
%211 = load i32*, i32** %9
%212 = getelementptr inbounds [4096 x i8], [4096 x i8]* %6, i64 0, i64 0
%213 = call i32 @get4k(i32* %211, i8* %212)
%214 = load i32*, i32** %10
%215 = getelementptr inbounds [4096 x i8], [4096 x i8]* %6, i64 0, i64 0
%216 = call i32 @put4k(i32* %214, i8* %215)
br label %217
217: ; preds = %210
%218 = load i64, i64* %11
%219 = add nsw i64 %218, 1
store i64 %219, i64* %11
br label %207
220: ; preds = %207
%221 = load i32*, i32** %9
%222 = load i32, i32* @SEEK_SET
%223 = call i32 @fseek(i32* %221, i32 65536, i32 %222)
store i64 0, i64* %11
br label %224
224: ; preds = %253, %220
%225 = load i64, i64* %11
%226 = load i64, i64* %21
%227 = icmp ult i64 %225, %226
br i1 %227, label %228, label %256
228: ; preds = %224
%229 = load i32*, i32** %9
%230 = getelementptr inbounds [4096 x i8], [4096 x i8]* %6, i64 0, i64 0
%231 = call i32 @get4k(i32* %229, i8* %230)
%232 = load i64, i64* %11
%233 = icmp eq i64 %232, 0
br i1 %233, label %234, label %249
234: ; preds = %228
%235 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.25, i64 0, i64 0))
%236 = getelementptr inbounds [4096 x i8], [4096 x i8]* %6, i64 0, i64 0
%237 = getelementptr inbounds i8, i8* %236, i64 60
%238 = bitcast i8* %237 to i64*
store i64* %238, i64** %23
%239 = load i64, i64* %19
%240 = load i64*, i64** %23
store i64 %239, i64* %240
%241 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.26, i64 0, i64 0))
%242 = getelementptr inbounds [4096 x i8], [4096 x i8]* %6, i64 0, i64 0
%243 = getelementptr inbounds i8, i8* %242, i64 68
%244 = bitcast i8* %243 to i64*
store i64* %244, i64** %23
%245 = load i64, i64* %19
%246 = load i64, i64* %12
%247 = add i64 %245, %246
%248 = load i64*, i64** %23
store i64 %247, i64* %248
br label %249
249: ; preds = %234, %228
%250 = load i32*, i32** %10
%251 = getelementptr inbounds [4096 x i8], [4096 x i8]* %6, i64 0, i64 0
%252 = call i32 @put4k(i32* %250, i8* %251)
br label %253
253: ; preds = %249
%254 = load i64, i64* %11
%255 = add nsw i64 %254, 1
store i64 %255, i64* %11
br label %224
256: ; preds = %224
store i64 0, i64* %11
br label %257
257: ; preds = %267, %256
%258 = load i64, i64* %11
%259 = load i64, i64* %22
%260 = icmp slt i64 %258, %259
br i1 %260, label %261, label %270
261: ; preds = %257
%262 = getelementptr inbounds [4096 x i8], [4096 x i8]* %6, i64 0, i64 0
%263 = call i32 @memset(i8* %262, i32 0, i32 4096)
%264 = load i32*, i32** %10
%265 = getelementptr inbounds [4096 x i8], [4096 x i8]* %6, i64 0, i64 0
%266 = call i32 @put4k(i32* %264, i8* %265)
br label %267
267: ; preds = %261
%268 = load i64, i64* %11
%269 = add nsw i64 %268, 1
store i64 %269, i64* %11
br label %257
270: ; preds = %257
%271 = load i32*, i32** %7
%272 = load i32, i32* @SEEK_SET
%273 = call i32 @fseek(i32* %271, i32 0, i32 %272)
store i64 0, i64* %11
br label %274
274: ; preds = %285, %270
%275 = load i64, i64* %11
%276 = load i64, i64* %20
%277 = icmp ult i64 %275, %276
br i1 %277, label %278, label %288
278: ; preds = %274
%279 = load i32*, i32** %7
%280 = getelementptr inbounds [4096 x i8], [4096 x i8]* %6, i64 0, i64 0
%281 = call i32 @get4k(i32* %279, i8* %280)
%282 = load i32*, i32** %10
%283 = getelementptr inbounds [4096 x i8], [4096 x i8]* %6, i64 0, i64 0
%284 = call i32 @put4k(i32* %282, i8* %283)
br label %285
285: ; preds = %278
%286 = load i64, i64* %11
%287 = add nsw i64 %286, 1
store i64 %287, i64* %11
br label %274
288: ; preds = %274
%289 = load i32*, i32** %7
%290 = call i32 @fclose(i32* %289)
%291 = load i32*, i32** %9
%292 = call i32 @fclose(i32* %291)
%293 = load i32*, i32** %10
%294 = call i32 @fclose(i32* %293)
%295 = load i8**, i8*** %5
%296 = getelementptr inbounds i8*, i8** %295, i64 3
%297 = load i8*, i8** %296
%298 = load i32, i32* @S_IRUSR
%299 = load i32, i32* @S_IWUSR
%300 = or i32 %298, %299
%301 = load i32, i32* @S_IXUSR
%302 = or i32 %300, %301
%303 = load i32, i32* @S_IRGRP
%304 = or i32 %302, %303
%305 = load i32, i32* @S_IXGRP
%306 = or i32 %304, %305
%307 = load i32, i32* @S_IROTH
%308 = or i32 %306, %307
%309 = load i32, i32* @S_IXOTH
%310 = or i32 %308, %309
%311 = call i32 @chmod(i8* %297, i32 %310)
ret i32 0
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [34 x i8] c"Name of System Map file missing.\0A\00"
@.str.1 = [31 x i8] c"Name of vmlinux file missing.\0A\00"
@.str.2 = [38 x i8] c"Name of vmlinux output file missing.\0A\00"
@.str.3 = [2 x i8] c"r\00"
@.str.4 = [38 x i8] c"System Map file \22%s\22 failed to open.\0A\00"
@.str.5 = [35 x i8] c"vmlinux file \22%s\22 failed to open.\0A\00"
@.str.6 = [2 x i8] c"w\00"
@.str.7 = [42 x i8] c"output vmlinux file \22%s\22 failed to open.\0A\00"
@SEEK_END = global i32 0
@SEEK_SET = global i32 0
@.str.8 = [24 x i8] c"kernel file size = %ld\0A\00"
@.str.9 = [51 x i8] c"You must have a linux kernel specified as argv[2]\0A\00"
@.str.10 = [53 x i8] c"actual kernel length (minus ELF header) = %ld/%lxx \0A\00"
@.str.11 = [55 x i8] c"Kernel length rounded up to a 4k multiple = %ld/%lxx \0A\00"
@.str.12 = [33 x i8] c"Kernel pages to copy = %ld/%lxx\0A\00"
@.str.13 = [20 x i8] c"%s file size = %ld\0A\00"
@.str.14 = [63 x i8] c"Rounding System Map file up to a multiple of 4096, adding %ld\0A\00"
@.str.15 = [32 x i8] c"Rounded System Map size is %ld\0A\00"
@.str.16 = [32 x i8] c"System map pages to copy = %ld\0A\00"
@.str.17 = [6 x i8] c" _end\00"
@.str.18 = [41 x i8] c"Unable to find _end in the sysmap file \0A\00"
@.str.19 = [9 x i8] c"inbuf: \0A\00"
@.str.20 = [5 x i8] c"%s \0A\00"
@.str.21 = [86 x i8] c"Found _end in the last page of the sysmap - backing up 10 characters it looks like %s\00"
@.str.22 = [79 x i8] c"vmlinux is larger than _end indicates it needs to be - sysmapStartOffs = %lx \0A\00"
@.str.23 = [72 x i8] c"will insert %lx pages between the vmlinux and the start of the sysmap \0A\00"
@.str.24 = [75 x i8] c"vmlinux is smaller than _end indicates is needed - sysmapStartOffs = %lx \0A\00"
@S_IRUSR = global i32 0
@S_IWUSR = global i32 0
@S_IXUSR = global i32 0
@S_IRGRP = global i32 0
@S_IXGRP = global i32 0
@S_IROTH = global i32 0
@S_IXOTH = global i32 0
@str = [38 x i8] c"Storing embedded_sysmap_start at 0x3c\00"
@str.27 = [36 x i8] c"Storing embedded_sysmap_end at 0x44\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [4096 x i8]
%4 = getelementptr inbounds [4096 x i8], [4096 x i8]* %3, i64 0, i64 0
%5 = icmp slt i32 %0, 2
br i1 %5, label %6, label %10
6: ; preds = %2
%7 = load i32, i32* @stderr
%8 = tail call i32 (i32, i8*, ...) @fprintf(i32 %7, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0))
%9 = tail call i32 @exit(i32 1)
unreachable
10: ; preds = %2
%11 = icmp eq i32 %0, 2
br i1 %11, label %12, label %16
12: ; preds = %10
%13 = load i32, i32* @stderr
%14 = tail call i32 (i32, i8*, ...) @fprintf(i32 %13, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0))
%15 = tail call i32 @exit(i32 1)
unreachable
16: ; preds = %10
%17 = icmp ult i32 %0, 4
br i1 %17, label %18, label %22
18: ; preds = %16
%19 = load i32, i32* @stderr
%20 = tail call i32 (i32, i8*, ...) @fprintf(i32 %19, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.2, i64 0, i64 0))
%21 = tail call i32 @exit(i32 1)
unreachable
22: ; preds = %16
%23 = getelementptr inbounds i8*, i8** %1, i64 1
%24 = load i8*, i8** %23
%25 = tail call i32* @fopen(i8* %24, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%26 = icmp eq i32* %25, null
br i1 %26, label %27, label %32
27: ; preds = %22
%28 = load i32, i32* @stderr
%29 = load i8*, i8** %23
%30 = tail call i32 (i32, i8*, ...) @fprintf(i32 %28, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.4, i64 0, i64 0), i8* %29)
%31 = tail call i32 @exit(i32 1)
unreachable
32: ; preds = %22
%33 = getelementptr inbounds i8*, i8** %1, i64 2
%34 = load i8*, i8** %33
%35 = tail call i32* @fopen(i8* %34, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%36 = icmp eq i32* %35, null
br i1 %36, label %37, label %42
37: ; preds = %32
%38 = load i32, i32* @stderr
%39 = load i8*, i8** %33
%40 = tail call i32 (i32, i8*, ...) @fprintf(i32 %38, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.5, i64 0, i64 0), i8* %39)
%41 = tail call i32 @exit(i32 1)
unreachable
42: ; preds = %32
%43 = getelementptr inbounds i8*, i8** %1, i64 3
%44 = load i8*, i8** %43
%45 = tail call i32* @fopen(i8* %44, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0))
%46 = icmp eq i32* %45, null
br i1 %46, label %47, label %52
47: ; preds = %42
%48 = load i32, i32* @stderr
%49 = load i8*, i8** %43
%50 = tail call i32 (i32, i8*, ...) @fprintf(i32 %48, i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.7, i64 0, i64 0), i8* %49)
%51 = tail call i32 @exit(i32 1)
unreachable
52: ; preds = %42
%53 = load i32, i32* @SEEK_END
%54 = tail call i32 @fseek(i32* %35, i32 0, i32 %53)
%55 = tail call i64 @ftell(i32* %35)
%56 = load i32, i32* @SEEK_SET
%57 = tail call i32 @fseek(i32* %35, i32 0, i32 %56)
%58 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.8, i64 0, i64 0), i64 %55)
%59 = icmp eq i64 %55, 0
br i1 %59, label %60, label %64
60: ; preds = %52
%61 = load i32, i32* @stderr
%62 = tail call i32 (i32, i8*, ...) @fprintf(i32 %61, i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.9, i64 0, i64 0))
%63 = tail call i32 @exit(i32 1)
unreachable
64: ; preds = %52
%65 = add i64 %55, -65536
%66 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([53 x i8], [53 x i8]* @.str.10, i64 0, i64 0), i64 %65, i64 %65)
%67 = and i64 %55, 4095
%68 = icmp eq i64 %67, 0
%69 = add i64 %55, -61440
%70 = and i64 %69, -4096
%71 = select i1 %68, i64 %65, i64 %70
%72 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([55 x i8], [55 x i8]* @.str.11, i64 0, i64 0), i64 %71, i64 %71)
%73 = lshr i64 %71, 12
%74 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str.12, i64 0, i64 0), i64 %73, i64 %73)
%75 = load i32, i32* @SEEK_END
%76 = tail call i32 @fseek(i32* %25, i32 0, i32 %75)
%77 = tail call i64 @ftell(i32* %25)
%78 = load i32, i32* @SEEK_SET
%79 = tail call i32 @fseek(i32* %25, i32 0, i32 %78)
%80 = load i8*, i8** %23
%81 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.13, i64 0, i64 0), i8* %80, i64 %77)
%82 = and i64 %77, 4095
%83 = sub nuw nsw i64 4096, %82
%84 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([63 x i8], [63 x i8]* @.str.14, i64 0, i64 0), i64 %83)
%85 = add i64 %83, %77
%86 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str.15, i64 0, i64 0), i64 %85)
%87 = lshr i64 %85, 12
%88 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str.16, i64 0, i64 0), i64 %87)
br label %89
89: ; preds = %89, %64
%90 = call i64 @fgets(i8* %4, i32 4096, i32* %25)
%91 = icmp eq i64 %90, 0
br i1 %91, label %92, label %89
92: ; preds = %89
%93 = call i8* @strstr(i8* %4, i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.17, i64 0, i64 0))
%94 = icmp eq i8* %93, null
br i1 %94, label %95, label %103
95: ; preds = %92
%96 = load i32, i32* @stderr
%97 = call i32 (i32, i8*, ...) @fprintf(i32 %96, i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.18, i64 0, i64 0))
%98 = load i32, i32* @stderr
%99 = call i32 (i32, i8*, ...) @fprintf(i32 %98, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.19, i64 0, i64 0))
%100 = load i32, i32* @stderr
%101 = call i32 (i32, i8*, ...) @fprintf(i32 %100, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.20, i64 0, i64 0), i8* %4)
%102 = call i32 @exit(i32 1)
unreachable
103: ; preds = %92
%104 = getelementptr inbounds i8, i8* %93, i64 -10
%105 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([86 x i8], [86 x i8]* @.str.21, i64 0, i64 0), i8* %104)
%106 = call i64 @strtol(i8* nocapture %104, i32* null, i32 16)
%107 = and i64 %106, 4294967295
%108 = lshr i64 %107, 12
%109 = sub nsw i64 %108, %73
%110 = icmp slt i64 %109, 0
br i1 %110, label %111, label %113
111: ; preds = %103
%112 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([79 x i8], [79 x i8]* @.str.22, i64 0, i64 0), i64 %71)
br label %115
113: ; preds = %103
%114 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([75 x i8], [75 x i8]* @.str.24, i64 0, i64 0), i64 %107)
br label %115
115: ; preds = %113, %111
%116 = phi i64 [ %109, %113 ], [ 0, %111 ]
%117 = phi i64 [ %107, %113 ], [ %71, %111 ]
%118 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([72 x i8], [72 x i8]* @.str.23, i64 0, i64 0), i64 %116)
%119 = call i32 @get4k(i32* %35, i8* %4)
%120 = call i32 @put4k(i32* %45, i8* %4)
%121 = call i32 @get4k(i32* %35, i8* %4)
%122 = call i32 @put4k(i32* %45, i8* %4)
%123 = call i32 @get4k(i32* %35, i8* %4)
%124 = call i32 @put4k(i32* %45, i8* %4)
%125 = call i32 @get4k(i32* %35, i8* %4)
%126 = call i32 @put4k(i32* %45, i8* %4)
%127 = call i32 @get4k(i32* %35, i8* %4)
%128 = call i32 @put4k(i32* %45, i8* %4)
%129 = call i32 @get4k(i32* %35, i8* %4)
%130 = call i32 @put4k(i32* %45, i8* %4)
%131 = call i32 @get4k(i32* %35, i8* %4)
%132 = call i32 @put4k(i32* %45, i8* %4)
%133 = call i32 @get4k(i32* %35, i8* %4)
%134 = call i32 @put4k(i32* %45, i8* %4)
%135 = call i32 @get4k(i32* %35, i8* %4)
%136 = call i32 @put4k(i32* %45, i8* %4)
%137 = call i32 @get4k(i32* %35, i8* %4)
%138 = call i32 @put4k(i32* %45, i8* %4)
%139 = call i32 @get4k(i32* %35, i8* %4)
%140 = call i32 @put4k(i32* %45, i8* %4)
%141 = call i32 @get4k(i32* %35, i8* %4)
%142 = call i32 @put4k(i32* %45, i8* %4)
%143 = call i32 @get4k(i32* %35, i8* %4)
%144 = call i32 @put4k(i32* %45, i8* %4)
%145 = call i32 @get4k(i32* %35, i8* %4)
%146 = call i32 @put4k(i32* %45, i8* %4)
%147 = call i32 @get4k(i32* %35, i8* %4)
%148 = call i32 @put4k(i32* %45, i8* %4)
%149 = call i32 @get4k(i32* %35, i8* %4)
%150 = call i32 @put4k(i32* %45, i8* %4)
%151 = load i32, i32* @SEEK_SET
%152 = call i32 @fseek(i32* %35, i32 65536, i32 %151)
%153 = icmp ult i64 %71, 4096
br i1 %153, label %166, label %154
154: ; preds = %115
%155 = call i64 @llvm.umax.i64(i64 %73, i64 1)
%156 = call i32 @get4k(i32* %35, i8* %4)
%157 = add i64 %117, %77
%158 = getelementptr inbounds [4096 x i8], [4096 x i8]* %3, i64 0, i64 68
%159 = bitcast i8* %158 to i64*
%160 = getelementptr inbounds [4096 x i8], [4096 x i8]* %3, i64 0, i64 60
%161 = bitcast i8* %160 to i64*
%162 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @str, i64 0, i64 0))
store i64 %117, i64* %161
%163 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @str.27, i64 0, i64 0))
store i64 %157, i64* %159
%164 = call i32 @put4k(i32* %45, i8* %4)
%165 = icmp ult i64 %71, 8192
br i1 %165, label %166, label %168
166: ; preds = %168, %154, %115
%167 = icmp sgt i64 %116, 0
br i1 %167, label %174, label %180
168: ; preds = %154, %168
%169 = phi i64 [ %172, %168 ], [ 1, %154 ]
%170 = call i32 @get4k(i32* %35, i8* %4)
%171 = call i32 @put4k(i32* %45, i8* %4)
%172 = add nuw nsw i64 %169, 1
%173 = icmp eq i64 %172, %155
br i1 %173, label %166, label %168
174: ; preds = %166, %174
%175 = phi i64 [ %178, %174 ], [ 0, %166 ]
%176 = call i32 @memset(i8* %4, i32 0, i32 4096)
%177 = call i32 @put4k(i32* %45, i8* %4)
%178 = add nuw nsw i64 %175, 1
%179 = icmp eq i64 %178, %116
br i1 %179, label %180, label %174
180: ; preds = %174, %166
%181 = load i32, i32* @SEEK_SET
%182 = call i32 @fseek(i32* %25, i32 0, i32 %181)
%183 = icmp ult i64 %85, 4096
br i1 %183, label %192, label %184
184: ; preds = %180
%185 = call i64 @llvm.umax.i64(i64 %87, i64 1)
br label %186
186: ; preds = %184, %186
%187 = phi i64 [ %190, %186 ], [ 0, %184 ]
%188 = call i32 @get4k(i32* %25, i8* %4)
%189 = call i32 @put4k(i32* %45, i8* %4)
%190 = add nuw nsw i64 %187, 1
%191 = icmp eq i64 %190, %185
br i1 %191, label %192, label %186
192: ; preds = %186, %180
%193 = call i32 @fclose(i32* %25)
%194 = call i32 @fclose(i32* %35)
%195 = call i32 @fclose(i32* %45)
%196 = load i8*, i8** %43
%197 = load i32, i32* @S_IRUSR
%198 = load i32, i32* @S_IWUSR
%199 = or i32 %198, %197
%200 = load i32, i32* @S_IXUSR
%201 = or i32 %199, %200
%202 = load i32, i32* @S_IRGRP
%203 = or i32 %201, %202
%204 = load i32, i32* @S_IXGRP
%205 = or i32 %203, %204
%206 = load i32, i32* @S_IROTH
%207 = or i32 %205, %206
%208 = load i32, i32* @S_IXOTH
%209 = or i32 %207, %208
%210 = call i32 @chmod(i8* %196, i32 %209)
ret i32 0
}