#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*/ *);
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);
  for (i = 0; i < sysmapPages; ++i) {
    get4k(sysmap, inbuf);
  }
  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    12c4 <main+0xf4>
mov    0x2d0e(%rip),%rax
mov    (%rax),%edi
lea    0xd4d(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    $0x1,%edi
call   10d0 <exit@plt>
cmpl   $0x3,-0x8(%rbp)
jge    12ef <main+0x11f>
mov    0x2ce3(%rip),%rax
mov    (%rax),%edi
lea    0xd44(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    $0x1,%edi
call   10d0 <exit@plt>
cmpl   $0x4,-0x8(%rbp)
jge    131a <main+0x14a>
mov    0x2cb8(%rip),%rax
mov    (%rax),%edi
lea    0xd38(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    $0x1,%edi
call   10d0 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xd3e(%rip),%rsi
call   10c0 <fopen@plt>
mov    %rax,-0x1018(%rbp)
cmpq   $0x0,-0x1018(%rbp)
jne    136c <main+0x19c>
mov    0x2c6e(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdx
lea    0xd0e(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    $0x1,%edi
call   10d0 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xcec(%rip),%rsi
call   10c0 <fopen@plt>
mov    %rax,-0x1028(%rbp)
cmpq   $0x0,-0x1028(%rbp)
jne    13be <main+0x1ee>
mov    0x2c1c(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdx
lea    0xceb(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    $0x1,%edi
call   10d0 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
lea    0xcc2(%rip),%rsi
call   10c0 <fopen@plt>
mov    %rax,-0x1030(%rbp)
cmpq   $0x0,-0x1030(%rbp)
jne    1410 <main+0x240>
mov    0x2bca(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdx
lea    0xc92(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    $0x1,%edi
call   10d0 <exit@plt>
mov    -0x1028(%rbp),%rdi
mov    0x2bc2(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   10a0 <fseek@plt>
mov    -0x1028(%rbp),%rdi
call   1070 <ftell@plt>
mov    %rax,-0x1058(%rbp)
mov    -0x1028(%rbp),%rdi
mov    0x2b68(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   10a0 <fseek@plt>
mov    -0x1058(%rbp),%rsi
lea    0xc5c(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
cmpq   $0x0,-0x1058(%rbp)
jne    1495 <main+0x2c5>
mov    0x2b3d(%rip),%rax
mov    (%rax),%edi
lea    0xc4f(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    $0x1,%edi
call   10d0 <exit@plt>
mov    -0x1058(%rbp),%rax
sub    $0x10000,%rax
mov    %rax,-0x1060(%rbp)
mov    -0x1060(%rbp),%rsi
mov    -0x1060(%rbp),%rdx
lea    0xc48(%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     150f <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    0xc17(%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    0xc20(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x1018(%rbp),%rdi
mov    0x2a79(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   10a0 <fseek@plt>
mov    -0x1018(%rbp),%rdi
call   1070 <ftell@plt>
mov    %rax,-0x1040(%rbp)
mov    -0x1018(%rbp),%rdi
mov    0x2a1f(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   10a0 <fseek@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
mov    -0x1040(%rbp),%rdx
lea    0xbe3(%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     161a <main+0x44a>
mov    -0x1050(%rbp),%rsi
lea    0xba9(%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    0xbbe(%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    0xbb7(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movq   $0x0,-0x1038(%rbp)
mov    -0x1038(%rbp),%rax
cmp    -0x1080(%rbp),%rax
jae    169f <main+0x4cf>
mov    -0x1018(%rbp),%rdi
lea    -0x1010(%rbp),%rsi
call   1090 <get4k@plt>
mov    -0x1038(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x1038(%rbp)
jmp    1661 <main+0x491>
lea    -0x1010(%rbp),%rdi
lea    0xb79(%rip),%rsi
call   10e0 <strstr@plt>
mov    %rax,-0x1020(%rbp)
cmpq   $0x0,-0x1020(%rbp)
jne    171d <main+0x54d>
mov    0x28ea(%rip),%rax
mov    (%rax),%edi
lea    0xb55(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    0x28d3(%rip),%rax
mov    (%rax),%edi
lea    0xb67(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    0x28bc(%rip),%rax
mov    (%rax),%edi
lea    -0x1010(%rbp),%rdx
lea    0xb52(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    $0x1,%edi
call   10d0 <exit@plt>
mov    -0x1020(%rbp),%rsi
add    $0xfffffffffffffff6,%rsi
lea    0xb34(%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   1080 <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    17c7 <main+0x5f7>
mov    -0x1070(%rbp),%rax
mov    %rax,-0x1078(%rbp)
mov    -0x1078(%rbp),%rsi
lea    0xb1e(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movq   $0x0,-0x1090(%rbp)
mov    -0x1090(%rbp),%rsi
lea    0xb4d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    17f1 <main+0x621>
mov    -0x1078(%rbp),%rsi
lea    0xb7b(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x1090(%rbp),%rsi
lea    0xb1e(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movq   $0x0,-0x1038(%rbp)
cmpq   $0x10,-0x1038(%rbp)
10
jge    1847 <main+0x677>
mov    -0x1028(%rbp),%rdi
lea    -0x1010(%rbp),%rsi
call   1090 <get4k@plt>
mov    -0x1030(%rbp),%rdi
lea    -0x1010(%rbp),%rsi
call   10f0 <put4k@plt>
mov    -0x1038(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x1038(%rbp)
jmp    17fc <main+0x62c>
mov    -0x1028(%rbp),%rdi
mov    0x275b(%rip),%rax
mov    (%rax),%edx
mov    $0x10000,%esi
call   10a0 <fseek@plt>
movq   $0x0,-0x1038(%rbp)
mov    -0x1038(%rbp),%rax
cmp    -0x1088(%rbp),%rax
jae    1934 <main+0x764>
mov    -0x1028(%rbp),%rdi
lea    -0x1010(%rbp),%rsi
call   1090 <get4k@plt>
cmpq   $0x0,-0x1038(%rbp)
jne    190a <main+0x73a>
lea    0xaf3(%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    0xae9(%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   10f0 <put4k@plt>
mov    -0x1038(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x1038(%rbp)
jmp    186c <main+0x69c>
movq   $0x0,-0x1038(%rbp)
mov    -0x1038(%rbp),%rax
cmp    -0x1090(%rbp),%rax
jge    1990 <main+0x7c0>
lea    -0x1010(%rbp),%rdi
xor    %esi,%esi
mov    $0x1000,%edx
call   1050 <memset@plt>
mov    -0x1030(%rbp),%rdi
lea    -0x1010(%rbp),%rsi
call   10f0 <put4k@plt>
mov    -0x1038(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x1038(%rbp)
jmp    193f <main+0x76f>
mov    -0x1018(%rbp),%rdi
mov    0x2612(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   10a0 <fseek@plt>
movq   $0x0,-0x1038(%rbp)
mov    -0x1038(%rbp),%rax
cmp    -0x1080(%rbp),%rax
jae    1a03 <main+0x833>
mov    -0x1018(%rbp),%rdi
lea    -0x1010(%rbp),%rsi
call   1090 <get4k@plt>
mov    -0x1030(%rbp),%rdi
lea    -0x1010(%rbp),%rsi
call   10f0 <put4k@plt>
mov    -0x1038(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x1038(%rbp)
jmp    19b2 <main+0x7e2>
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    0x2562(%rip),%rax
mov    (%rax),%esi
mov    0x2591(%rip),%rax
or     (%rax),%esi
mov    0x2590(%rip),%rax
or     (%rax),%esi
mov    0x2557(%rip),%rax
or     (%rax),%esi
mov    0x256e(%rip),%rax
or     (%rax),%esi
mov    0x253d(%rip),%rax
or     (%rax),%esi
mov    0x257c(%rip),%rax
or     (%rax),%esi
call   10b0 <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    17c5 <main+0x5e5>
cmp    $0x2,%edi
je     17d7 <main+0x5f7>
cmp    $0x3,%edi
jbe    17e9 <main+0x609>
mov    %rsi,%r13
mov    0x8(%rsi),%rdi
lea    0xe4d(%rip),%rsi
call   10d0 <fopen@plt>
test   %rax,%rax
je     17fb <main+0x61b>
mov    %rax,%r12
mov    0x10(%r13),%rdi
lea    0xe31(%rip),%rsi
call   10d0 <fopen@plt>
test   %rax,%rax
je     1814 <main+0x634>
mov    %rax,0x18(%rsp)
mov    0x18(%r13),%rdi
lea    0xe3b(%rip),%rsi
call   10d0 <fopen@plt>
test   %rax,%rax
je     182a <main+0x64a>
mov    %rax,%r15
mov    0x2d74(%rip),%rax
mov    (%rax),%edx
mov    0x18(%rsp),%rbx
mov    %rbx,%rdi
xor    %esi,%esi
call   10b0 <fseek@plt>
mov    %rbx,%rdi
call   1080 <ftell@plt>
mov    %rax,%rbp
mov    0x2d21(%rip),%rax
mov    (%rax),%edx
mov    %rbx,%rdi
xor    %esi,%esi
call   10b0 <fseek@plt>
lea    0xe19(%rip),%rdi
mov    %rbp,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
test   %rbp,%rbp
je     1840 <main+0x660>
lea    -0x10000(%rbp),%r14
lea    0xe43(%rip),%rdi
mov    %r14,%rsi
mov    %r14,%rdx
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbp,%rbx
add    $0xffffffffffff1000,%rbx
and    $0xfffffffffffff000,%rbx
test   $0xfff,%ebp
cmove  %r14,%rbx
lea    0xe49(%rip),%rdi
mov    %rbx,%rsi
mov    %rbx,%rdx
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbx,0x8(%rsp)
shr    $0xc,%rbx
lea    0xe63(%rip),%rdi
mov    %rbx,%rsi
mov    %rbx,0x10(%rsp)
mov    %rbx,%rdx
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x2cb8(%rip),%rax
mov    (%rax),%edx
mov    %r12,%rdi
xor    %esi,%esi
call   10b0 <fseek@plt>
mov    %r12,%rdi
call   1080 <ftell@plt>
mov    %rax,%rbx
mov    0x2c6a(%rip),%rax
mov    (%rax),%edx
mov    %r12,%rdi
xor    %esi,%esi
call   10b0 <fseek@plt>
mov    %r13,0x38(%rsp)
mov    0x8(%r13),%rsi
lea    0xe31(%rip),%rdi
mov    %rbx,%rdx
xor    %eax,%eax
call   1050 <printf@plt>
mov    %ebx,%eax
and    $0xfff,%eax
mov    $0x1000,%r13d
sub    %rax,%r13
lea    0xe24(%rip),%rdi
mov    %r13,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbx,0x20(%rsp)
add    %rbx,%r13
lea    0xe4a(%rip),%rdi
mov    %r13,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r13,%r14
shr    $0xc,%r14
lea    0xe52(%rip),%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
cmp    $0x1000,%r13
jb     13f1 <main+0x211>
cmp    $0x2,%r14
mov    $0x1,%ebx
cmovae %r14,%rbx
lea    0x40(%rsp),%rbp
nopl   0x0(%rax)
mov    %r12,%rdi
mov    %rbp,%rsi
call   10a0 <get4k@plt>
add    $0xffffffffffffffff,%rbx
jne    13e0 <main+0x200>
mov    %r14,0x28(%rsp)
lea    0xe29(%rip),%rsi
lea    0x40(%rsp),%rdi
call   10f0 <strstr@plt>
test   %rax,%rax
je     1861 <main+0x681>
mov    %rax,%rbp
add    $0xfffffffffffffff6,%rbp
lea    0xe45(%rip),%rdi
mov    %rbp,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbp,%rdi
xor    %esi,%esi
mov    $0x10,%edx
call   1090 <strtol@plt>
mov    %eax,%eax
mov    %rax,%r14
shr    $0xc,%r14
sub    0x10(%rsp),%r14
mov    %r13,0x30(%rsp)
js     1463 <main+0x283>
lea    0xefd(%rip),%rdi
mov    %rax,(%rsp)
mov    %rax,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
jmp    1480 <main+0x2a0>
lea    0xe4f(%rip),%rdi
xor    %r14d,%r14d
mov    0x8(%rsp),%rbx
mov    %rbx,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbx,(%rsp)
mov    0x2b29(%rip),%rbp
lea    0xe7a(%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   10a0 <get4k@plt>
mov    %r15,%rdi
mov    %r13,%rsi
call   1100 <put4k@plt>
mov    %rbx,%rdi
mov    %r13,%rsi
call   10a0 <get4k@plt>
mov    %r15,%rdi
mov    %r13,%rsi
call   1100 <put4k@plt>
mov    %rbx,%rdi
mov    %r13,%rsi
call   10a0 <get4k@plt>
mov    %r15,%rdi
mov    %r13,%rsi
call   1100 <put4k@plt>
mov    %rbx,%rdi
mov    %r13,%rsi
call   10a0 <get4k@plt>
mov    %r15,%rdi
mov    %r13,%rsi
call   1100 <put4k@plt>
mov    %rbx,%rdi
mov    %r13,%rsi
call   10a0 <get4k@plt>
mov    %r15,%rdi
mov    %r13,%rsi
call   1100 <put4k@plt>
mov    %rbx,%rdi
mov    %r13,%rsi
call   10a0 <get4k@plt>
mov    %r15,%rdi
mov    %r13,%rsi
call   1100 <put4k@plt>
mov    %rbx,%rdi
mov    %r13,%rsi
call   10a0 <get4k@plt>
mov    %r15,%rdi
mov    %r13,%rsi
call   1100 <put4k@plt>
mov    %rbx,%rdi
mov    %r13,%rsi
call   10a0 <get4k@plt>
mov    %r15,%rdi
mov    %r13,%rsi
call   1100 <put4k@plt>
mov    %rbx,%rdi
mov    %r13,%rsi
call   10a0 <get4k@plt>
mov    %r15,%rdi
mov    %r13,%rsi
call   1100 <put4k@plt>
mov    %rbx,%rdi
mov    %r13,%rsi
call   10a0 <get4k@plt>
mov    %r15,%rdi
mov    %r13,%rsi
call   1100 <put4k@plt>
mov    %rbx,%rdi
mov    %r13,%rsi
call   10a0 <get4k@plt>
mov    %r15,%rdi
mov    %r13,%rsi
call   1100 <put4k@plt>
mov    %rbx,%rdi
mov    %r13,%rsi
call   10a0 <get4k@plt>
mov    %r15,%rdi
mov    %r13,%rsi
call   1100 <put4k@plt>
mov    %rbx,%rdi
mov    %r13,%rsi
call   10a0 <get4k@plt>
mov    %r15,%rdi
mov    %r13,%rsi
call   1100 <put4k@plt>
mov    %rbx,%rdi
mov    %r13,%rsi
call   10a0 <get4k@plt>
mov    %r15,%rdi
mov    %r13,%rsi
call   1100 <put4k@plt>
mov    %rbx,%rdi
mov    %r13,%rsi
call   10a0 <get4k@plt>
mov    %r15,%rdi
mov    %r13,%rsi
call   1100 <put4k@plt>
mov    %rbx,%rdi
mov    %r13,%rsi
call   10a0 <get4k@plt>
mov    %r15,%rdi
mov    %r13,%rsi
mov    %rbx,%r13
call   1100 <put4k@plt>
mov    0x0(%rbp),%edx
mov    %rbx,%rdi
mov    $0x10000,%esi
call   10b0 <fseek@plt>
mov    0x8(%rsp),%rax
cmp    $0x1000,%rax
jb     16bc <main+0x4dc>
mov    0x10(%rsp),%rcx
cmp    $0x2,%rcx
mov    $0x1,%ebx
cmovae %rcx,%rbx
lea    0x40(%rsp),%rsi
mov    %r13,%rdi
call   10a0 <get4k@plt>
mov    0x20(%rsp),%rbp
add    (%rsp),%rbp
lea    0xd46(%rip),%rdi
call   1030 <puts@plt>
mov    (%rsp),%rax
mov    %rax,0x7c(%rsp)
lea    0xd57(%rip),%rdi
call   1030 <puts@plt>
mov    %rbp,0x84(%rsp)
mov    %r15,%rdi
lea    0x40(%rsp),%rsi
call   1100 <put4k@plt>
cmpq   $0x2000,0x8(%rsp)
jb     16bc <main+0x4dc>
add    $0xffffffffffffffff,%rbx
lea    0x40(%rsp),%rbp
nopl   0x0(%rax,%rax,1)
mov    %r13,%rdi
mov    %rbp,%rsi
call   10a0 <get4k@plt>
mov    %r15,%rdi
mov    %rbp,%rsi
call   1100 <put4k@plt>
add    $0xffffffffffffffff,%rbx
jne    16a0 <main+0x4c0>
test   %r14,%r14
jle    16f0 <main+0x510>
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   1100 <put4k@plt>
add    $0xffffffffffffffff,%r14
jne    16d0 <main+0x4f0>
mov    0x28b9(%rip),%rax
mov    (%rax),%edx
mov    %r12,%rdi
xor    %esi,%esi
call   10b0 <fseek@plt>
cmpq   $0x1000,0x30(%rsp)
jb     174c <main+0x56c>
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   10a0 <get4k@plt>
mov    %r15,%rdi
mov    %rbp,%rsi
call   1100 <put4k@plt>
add    $0xffffffffffffffff,%rbx
jne    1730 <main+0x550>
mov    %r12,%rdi
call   1040 <fclose@plt>
mov    %r13,%rdi
call   1040 <fclose@plt>
mov    %r15,%rdi
call   1040 <fclose@plt>
mov    0x282d(%rip),%rax
mov    0x285e(%rip),%rcx
mov    (%rcx),%esi
or     (%rax),%esi
mov    0x285b(%rip),%rax
or     (%rax),%esi
mov    0x2822(%rip),%rax
or     (%rax),%esi
mov    0x2839(%rip),%rax
or     (%rax),%esi
mov    0x2808(%rip),%rax
or     (%rax),%esi
mov    0x38(%rsp),%rax
mov    0x18(%rax),%rdi
mov    0x283e(%rip),%rax
or     (%rax),%esi
call   10c0 <chmod@plt>
xor    %eax,%eax
add    $0x1048,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x27ec(%rip),%rax
mov    (%rax),%edi
lea    0x82b(%rip),%rsi
jmp    1850 <main+0x670>
mov    0x27da(%rip),%rax
mov    (%rax),%edi
lea    0x83b(%rip),%rsi
jmp    1850 <main+0x670>
mov    0x27c8(%rip),%rax
mov    (%rax),%edi
lea    0x848(%rip),%rsi
jmp    1850 <main+0x670>
mov    0x27b6(%rip),%rax
mov    (%rax),%edi
mov    0x8(%r13),%rdx
lea    0x85a(%rip),%rsi
jmp    1896 <main+0x6b6>
mov    0x279d(%rip),%rax
mov    (%rax),%edi
mov    0x10(%r13),%rdx
lea    0x870(%rip),%rsi
jmp    1896 <main+0x6b6>
mov    0x2787(%rip),%rax
mov    (%rax),%edi
mov    0x18(%r13),%rdx
lea    0x853(%rip),%rsi
jmp    1896 <main+0x6b6>
mov    0x2771(%rip),%rax
mov    (%rax),%edi
lea    0x883(%rip),%rsi
xor    %eax,%eax
call   1070 <fprintf@plt>
mov    $0x1,%edi
call   10e0 <exit@plt>
mov    0x2750(%rip),%rbx
mov    (%rbx),%edi
lea    0x9bb(%rip),%rsi
xor    %eax,%eax
call   1070 <fprintf@plt>
mov    (%rbx),%edi
lea    0x9d4(%rip),%rsi
xor    %eax,%eax
call   1070 <fprintf@plt>
mov    (%rbx),%edi
lea    0x9cd(%rip),%rsi
lea    0x40(%rsp),%rdx
xor    %eax,%eax
call   1070 <fprintf@plt>
mov    $0x1,%edi
call   10e0 <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)
store i64 0, i64* %11
br label %160
160: ; preds = %168, %153
%161 = load i64, i64* %11
%162 = load i64, i64* %20
%163 = icmp ult i64 %161, %162
br i1 %163, label %164, label %171
164: ; preds = %160
%165 = load i32*, i32** %7
%166 = getelementptr inbounds [4096 x i8], [4096 x i8]* %6, i64 0, i64 0
%167 = call i32 @get4k(i32* %165, i8* %166)
br label %168
168: ; preds = %164
%169 = load i64, i64* %11
%170 = add nsw i64 %169, 1
store i64 %170, i64* %11
br label %160
171: ; preds = %160
%172 = getelementptr inbounds [4096 x i8], [4096 x i8]* %6, i64 0, i64 0
%173 = call i8* @strstr(i8* %172, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.17, i64 0, i64 0))
store i8* %173, i8** %8
%174 = load i8*, i8** %8
%175 = icmp ne i8* %174, null
br i1 %175, label %185, label %176
176: ; preds = %171
%177 = load i32, i32* @stderr
%178 = call i32 (i32, i8*, ...) @fprintf(i32 %177, i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.18, i64 0, i64 0))
%179 = load i32, i32* @stderr
%180 = call i32 (i32, i8*, ...) @fprintf(i32 %179, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.19, i64 0, i64 0))
%181 = load i32, i32* @stderr
%182 = getelementptr inbounds [4096 x i8], [4096 x i8]* %6, i64 0, i64 0
%183 = call i32 (i32, i8*, ...) @fprintf(i32 %181, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.20, i64 0, i64 0), i8* %182)
%184 = call i32 @exit(i32 1)
unreachable
185: ; preds = %171
%186 = load i8*, i8** %8
%187 = getelementptr inbounds i8, i8* %186, i64 -10
%188 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([86 x i8], [86 x i8]* @.str.21, i64 0, i64 0), i8* %187)
%189 = load i8*, i8** %8
%190 = getelementptr inbounds i8, i8* %189, i64 -10
%191 = call i64 @strtol(i8* %190, i32* null, i32 16)
%192 = trunc i64 %191 to i32
%193 = zext i32 %192 to i64
store i64 %193, i64* %19
%194 = load i64, i64* %19
%195 = udiv i64 %194, 4096
%196 = load i64, i64* %21
%197 = sub i64 %195, %196
store i64 %197, i64* %22
%198 = load i64, i64* %22
%199 = icmp slt i64 %198, 0
br i1 %199, label %200, label %206
200: ; preds = %185
%201 = load i64, i64* %18
store i64 %201, i64* %19
%202 = load i64, i64* %19
%203 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([79 x i8], [79 x i8]* @.str.22, i64 0, i64 0), i64 %202)
store i64 0, i64* %22
%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 %211
206: ; preds = %185
%207 = load i64, i64* %19
%208 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([75 x i8], [75 x i8]* @.str.24, i64 0, i64 0), i64 %207)
%209 = load i64, i64* %22
%210 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([72 x i8], [72 x i8]* @.str.23, i64 0, i64 0), i64 %209)
br label %211
211: ; preds = %206, %200
store i64 0, i64* %11
br label %212
212: ; preds = %222, %211
%213 = load i64, i64* %11
%214 = icmp slt i64 %213, 16
br i1 %214, label %215, label %225
215: ; preds = %212
%216 = load i32*, i32** %9
%217 = getelementptr inbounds [4096 x i8], [4096 x i8]* %6, i64 0, i64 0
%218 = call i32 @get4k(i32* %216, i8* %217)
%219 = load i32*, i32** %10
%220 = getelementptr inbounds [4096 x i8], [4096 x i8]* %6, i64 0, i64 0
%221 = call i32 @put4k(i32* %219, i8* %220)
br label %222
222: ; preds = %215
%223 = load i64, i64* %11
%224 = add nsw i64 %223, 1
store i64 %224, i64* %11
br label %212
225: ; preds = %212
%226 = load i32*, i32** %9
%227 = load i32, i32* @SEEK_SET
%228 = call i32 @fseek(i32* %226, i32 65536, i32 %227)
store i64 0, i64* %11
br label %229
229: ; preds = %258, %225
%230 = load i64, i64* %11
%231 = load i64, i64* %21
%232 = icmp ult i64 %230, %231
br i1 %232, label %233, label %261
233: ; preds = %229
%234 = load i32*, i32** %9
%235 = getelementptr inbounds [4096 x i8], [4096 x i8]* %6, i64 0, i64 0
%236 = call i32 @get4k(i32* %234, i8* %235)
%237 = load i64, i64* %11
%238 = icmp eq i64 %237, 0
br i1 %238, label %239, label %254
239: ; preds = %233
%240 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.25, i64 0, i64 0))
%241 = getelementptr inbounds [4096 x i8], [4096 x i8]* %6, i64 0, i64 0
%242 = getelementptr inbounds i8, i8* %241, i64 60
%243 = bitcast i8* %242 to i64*
store i64* %243, i64** %23
%244 = load i64, i64* %19
%245 = load i64*, i64** %23
store i64 %244, i64* %245
%246 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.26, i64 0, i64 0))
%247 = getelementptr inbounds [4096 x i8], [4096 x i8]* %6, i64 0, i64 0
%248 = getelementptr inbounds i8, i8* %247, i64 68
%249 = bitcast i8* %248 to i64*
store i64* %249, i64** %23
%250 = load i64, i64* %19
%251 = load i64, i64* %12
%252 = add i64 %250, %251
%253 = load i64*, i64** %23
store i64 %252, i64* %253
br label %254
254: ; preds = %239, %233
%255 = load i32*, i32** %10
%256 = getelementptr inbounds [4096 x i8], [4096 x i8]* %6, i64 0, i64 0
%257 = call i32 @put4k(i32* %255, i8* %256)
br label %258
258: ; preds = %254
%259 = load i64, i64* %11
%260 = add nsw i64 %259, 1
store i64 %260, i64* %11
br label %229
261: ; preds = %229
store i64 0, i64* %11
br label %262
262: ; preds = %272, %261
%263 = load i64, i64* %11
%264 = load i64, i64* %22
%265 = icmp slt i64 %263, %264
br i1 %265, label %266, label %275
266: ; preds = %262
%267 = getelementptr inbounds [4096 x i8], [4096 x i8]* %6, i64 0, i64 0
%268 = call i32 @memset(i8* %267, i32 0, i32 4096)
%269 = load i32*, i32** %10
%270 = getelementptr inbounds [4096 x i8], [4096 x i8]* %6, i64 0, i64 0
%271 = call i32 @put4k(i32* %269, i8* %270)
br label %272
272: ; preds = %266
%273 = load i64, i64* %11
%274 = add nsw i64 %273, 1
store i64 %274, i64* %11
br label %262
275: ; preds = %262
%276 = load i32*, i32** %7
%277 = load i32, i32* @SEEK_SET
%278 = call i32 @fseek(i32* %276, i32 0, i32 %277)
store i64 0, i64* %11
br label %279
279: ; preds = %290, %275
%280 = load i64, i64* %11
%281 = load i64, i64* %20
%282 = icmp ult i64 %280, %281
br i1 %282, label %283, label %293
283: ; preds = %279
%284 = load i32*, i32** %7
%285 = getelementptr inbounds [4096 x i8], [4096 x i8]* %6, i64 0, i64 0
%286 = call i32 @get4k(i32* %284, i8* %285)
%287 = load i32*, i32** %10
%288 = getelementptr inbounds [4096 x i8], [4096 x i8]* %6, i64 0, i64 0
%289 = call i32 @put4k(i32* %287, i8* %288)
br label %290
290: ; preds = %283
%291 = load i64, i64* %11
%292 = add nsw i64 %291, 1
store i64 %292, i64* %11
br label %279
293: ; preds = %279
%294 = load i32*, i32** %7
%295 = call i32 @fclose(i32* %294)
%296 = load i32*, i32** %9
%297 = call i32 @fclose(i32* %296)
%298 = load i32*, i32** %10
%299 = call i32 @fclose(i32* %298)
%300 = load i8**, i8*** %5
%301 = getelementptr inbounds i8*, i8** %300, i64 3
%302 = load i8*, i8** %301
%303 = load i32, i32* @S_IRUSR
%304 = load i32, i32* @S_IWUSR
%305 = or i32 %303, %304
%306 = load i32, i32* @S_IXUSR
%307 = or i32 %305, %306
%308 = load i32, i32* @S_IRGRP
%309 = or i32 %307, %308
%310 = load i32, i32* @S_IXGRP
%311 = or i32 %309, %310
%312 = load i32, i32* @S_IROTH
%313 = or i32 %311, %312
%314 = load i32, i32* @S_IXOTH
%315 = or i32 %313, %314
%316 = call i32 @chmod(i8* %302, i32 %315)
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)
%89 = icmp ult i64 %85, 4096
br i1 %89, label %97, label %90
90: ; preds = %64
%91 = call i64 @llvm.umax.i64(i64 %87, i64 1)
br label %92
92: ; preds = %90, %92
%93 = phi i64 [ %95, %92 ], [ 0, %90 ]
%94 = call i32 @get4k(i32* %25, i8* %4)
%95 = add nuw nsw i64 %93, 1
%96 = icmp eq i64 %95, %91
br i1 %96, label %97, label %92
97: ; preds = %92, %64
%98 = call i8* @strstr(i8* %4, i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.17, i64 0, i64 0))
%99 = icmp eq i8* %98, null
br i1 %99, label %100, label %108
100: ; preds = %97
%101 = load i32, i32* @stderr
%102 = call i32 (i32, i8*, ...) @fprintf(i32 %101, i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.18, i64 0, i64 0))
%103 = load i32, i32* @stderr
%104 = call i32 (i32, i8*, ...) @fprintf(i32 %103, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.19, i64 0, i64 0))
%105 = load i32, i32* @stderr
%106 = call i32 (i32, i8*, ...) @fprintf(i32 %105, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.20, i64 0, i64 0), i8* %4)
%107 = call i32 @exit(i32 1)
unreachable
108: ; preds = %97
%109 = getelementptr inbounds i8, i8* %98, i64 -10
%110 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([86 x i8], [86 x i8]* @.str.21, i64 0, i64 0), i8* %109)
%111 = call i64 @strtol(i8* nocapture %109, i32* null, i32 16)
%112 = and i64 %111, 4294967295
%113 = lshr i64 %112, 12
%114 = sub nsw i64 %113, %73
%115 = icmp slt i64 %114, 0
br i1 %115, label %116, label %118
116: ; preds = %108
%117 = 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 %120
118: ; preds = %108
%119 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([75 x i8], [75 x i8]* @.str.24, i64 0, i64 0), i64 %112)
br label %120
120: ; preds = %118, %116
%121 = phi i64 [ %114, %118 ], [ 0, %116 ]
%122 = phi i64 [ %112, %118 ], [ %71, %116 ]
%123 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([72 x i8], [72 x i8]* @.str.23, i64 0, i64 0), i64 %121)
%124 = call i32 @get4k(i32* %35, i8* %4)
%125 = call i32 @put4k(i32* %45, i8* %4)
%126 = call i32 @get4k(i32* %35, i8* %4)
%127 = call i32 @put4k(i32* %45, i8* %4)
%128 = call i32 @get4k(i32* %35, i8* %4)
%129 = call i32 @put4k(i32* %45, i8* %4)
%130 = call i32 @get4k(i32* %35, i8* %4)
%131 = call i32 @put4k(i32* %45, i8* %4)
%132 = call i32 @get4k(i32* %35, i8* %4)
%133 = call i32 @put4k(i32* %45, i8* %4)
%134 = call i32 @get4k(i32* %35, i8* %4)
%135 = call i32 @put4k(i32* %45, i8* %4)
%136 = call i32 @get4k(i32* %35, i8* %4)
%137 = call i32 @put4k(i32* %45, i8* %4)
%138 = call i32 @get4k(i32* %35, i8* %4)
%139 = call i32 @put4k(i32* %45, i8* %4)
%140 = call i32 @get4k(i32* %35, i8* %4)
%141 = call i32 @put4k(i32* %45, i8* %4)
%142 = call i32 @get4k(i32* %35, i8* %4)
%143 = call i32 @put4k(i32* %45, i8* %4)
%144 = call i32 @get4k(i32* %35, i8* %4)
%145 = call i32 @put4k(i32* %45, i8* %4)
%146 = call i32 @get4k(i32* %35, i8* %4)
%147 = call i32 @put4k(i32* %45, i8* %4)
%148 = call i32 @get4k(i32* %35, i8* %4)
%149 = call i32 @put4k(i32* %45, i8* %4)
%150 = call i32 @get4k(i32* %35, i8* %4)
%151 = call i32 @put4k(i32* %45, i8* %4)
%152 = call i32 @get4k(i32* %35, i8* %4)
%153 = call i32 @put4k(i32* %45, i8* %4)
%154 = call i32 @get4k(i32* %35, i8* %4)
%155 = call i32 @put4k(i32* %45, i8* %4)
%156 = load i32, i32* @SEEK_SET
%157 = call i32 @fseek(i32* %35, i32 65536, i32 %156)
%158 = icmp ult i64 %71, 4096
br i1 %158, label %171, label %159
159: ; preds = %120
%160 = call i64 @llvm.umax.i64(i64 %73, i64 1)
%161 = call i32 @get4k(i32* %35, i8* %4)
%162 = add i64 %122, %77
%163 = getelementptr inbounds [4096 x i8], [4096 x i8]* %3, i64 0, i64 68
%164 = bitcast i8* %163 to i64*
%165 = getelementptr inbounds [4096 x i8], [4096 x i8]* %3, i64 0, i64 60
%166 = bitcast i8* %165 to i64*
%167 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @str, i64 0, i64 0))
store i64 %122, i64* %166
%168 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @str.27, i64 0, i64 0))
store i64 %162, i64* %164
%169 = call i32 @put4k(i32* %45, i8* %4)
%170 = icmp ult i64 %71, 8192
br i1 %170, label %171, label %173
171: ; preds = %173, %159, %120
%172 = icmp sgt i64 %121, 0
br i1 %172, label %179, label %185
173: ; preds = %159, %173
%174 = phi i64 [ %177, %173 ], [ 1, %159 ]
%175 = call i32 @get4k(i32* %35, i8* %4)
%176 = call i32 @put4k(i32* %45, i8* %4)
%177 = add nuw nsw i64 %174, 1
%178 = icmp eq i64 %177, %160
br i1 %178, label %171, label %173
179: ; preds = %171, %179
%180 = phi i64 [ %183, %179 ], [ 0, %171 ]
%181 = call i32 @memset(i8* %4, i32 0, i32 4096)
%182 = call i32 @put4k(i32* %45, i8* %4)
%183 = add nuw nsw i64 %180, 1
%184 = icmp eq i64 %183, %121
br i1 %184, label %185, label %179
185: ; preds = %179, %171
%186 = load i32, i32* @SEEK_SET
%187 = call i32 @fseek(i32* %25, i32 0, i32 %186)
br i1 %89, label %196, label %188
188: ; preds = %185
%189 = call i64 @llvm.umax.i64(i64 %87, i64 1)
br label %190
190: ; preds = %188, %190
%191 = phi i64 [ %194, %190 ], [ 0, %188 ]
%192 = call i32 @get4k(i32* %25, i8* %4)
%193 = call i32 @put4k(i32* %45, i8* %4)
%194 = add nuw nsw i64 %191, 1
%195 = icmp eq i64 %194, %189
br i1 %195, label %196, label %190
196: ; preds = %190, %185
%197 = call i32 @fclose(i32* %25)
%198 = call i32 @fclose(i32* %35)
%199 = call i32 @fclose(i32* %45)
%200 = load i8*, i8** %43
%201 = load i32, i32* @S_IRUSR
%202 = load i32, i32* @S_IWUSR
%203 = or i32 %202, %201
%204 = load i32, i32* @S_IXUSR
%205 = or i32 %203, %204
%206 = load i32, i32* @S_IRGRP
%207 = or i32 %205, %206
%208 = load i32, i32* @S_IXGRP
%209 = or i32 %207, %208
%210 = load i32, i32* @S_IROTH
%211 = or i32 %209, %210
%212 = load i32, i32* @S_IXOTH
%213 = or i32 %211, %212
%214 = call i32 @chmod(i8* %200, i32 %213)
ret i32 0
}