#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 EOF;
int /*<<< orphan*/ error(char *, ...);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int fgetc(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, int, ...);
int /*<<< orphan*/ printf(char *, ...);
scalar_t__ strcmp(char *, char *);
unsigned int strtoul(char *, char **, int);
int main(int argc, char *argv[]) {
  int type;
  unsigned int loadAddrMsk;
  char *loadAddrStr;
  char *infileStr;
  char *outfileStr;
  char *endptr;
  unsigned int loadAddr;
  unsigned int startAddr;
  FILE *infile;
  FILE *outfile;
  int numBytes, i;
  int c;
  unsigned char lineData[16];
  unsigned int chksum;
  if (argc != 5) {
    printf("Usage: %s -S1|-S2|-S3 <load addr, hex> ", argv[0]);
    printf("<input file> <output file>\n");
    exit(1);
  }
  if (strcmp(argv[1], "-S1") == 0) {
    type = 1;
    loadAddrMsk = 0x0000FFFF;
  } else if (strcmp(argv[1], "-S2") == 0) {
    type = 2;
    loadAddrMsk = 0x00FFFFFF;
  } else if (strcmp(argv[1], "-S3") == 0) {
    type = 3;
    loadAddrMsk = 0xFFFFFFFF;
  } else {
    error("exactly one of -S1, -S2, or -S3 must be specified");
  }
  loadAddrStr = argv[2];
  infileStr = argv[3];
  outfileStr = argv[4];
  loadAddr = strtoul(loadAddrStr, &endptr, 16);
  if (*endptr != '\0') {
    error("illegal load address %s", loadAddrStr);
  }
  if (loadAddr & ~loadAddrMsk) {
    error("load address too big");
  }
  startAddr = loadAddr;
  infile = fopen(infileStr, "rb");
  if (infile == NULL) {
    error("cannot open input file %s", infileStr);
  }
  outfile = fopen(outfileStr, "wt");
  if (outfile == NULL) {
    error("cannot open output file %s", outfileStr);
  }
  while (1) {
    chksum = 0;
    for (numBytes = 0; numBytes < 16; numBytes++) {
      c = fgetc(infile);
      if (c == EOF) {
        break;
      }
      lineData[numBytes] = c;
      chksum += c;
    }
    if (numBytes == 0) {
      break;
    }
    switch (type) {
    case 1:
      fprintf(outfile, "S1%02X%04X", numBytes + 3, loadAddr);
      break;
    case 2:
      fprintf(outfile, "S2%02X%06X", numBytes + 4, loadAddr);
      break;
    case 3:
      fprintf(outfile, "S3%02X%08X", numBytes + 5, loadAddr);
      break;
    }
    for (i = 0; i < numBytes; i++) {
      fprintf(outfile, "%02X", lineData[i]);
    }
    switch (type) {
    case 1:
      chksum +=
          numBytes + 3 + ((loadAddr >> 0) & 0xFF) + ((loadAddr >> 8) & 0xFF);
      break;
    case 2:
      chksum += numBytes + 4 + ((loadAddr >> 0) & 0xFF) +
                ((loadAddr >> 8) & 0xFF) + ((loadAddr >> 16) & 0xFF);
      break;
    case 3:
      chksum += numBytes + 5 + ((loadAddr >> 0) & 0xFF) +
                ((loadAddr >> 8) & 0xFF) + ((loadAddr >> 16) & 0xFF) +
                ((loadAddr >> 24) & 0xFF);
      break;
    }
    fprintf(outfile, "%02X\n", 0xFF - (chksum & 0xFF));
    loadAddr += numBytes;
    if (c == EOF) {
      break;
    }
  }
  switch (type) {
  case 1:
    fprintf(outfile, "S903%04X", startAddr);
    chksum = 3 + ((startAddr >> 0) & 0xFF) + ((startAddr >> 8) & 0xFF);
    break;
  case 2:
    fprintf(outfile, "S804%06X", startAddr);
    chksum = 4 + ((startAddr >> 0) & 0xFF) + ((startAddr >> 8) & 0xFF) +
             ((startAddr >> 16) & 0xFF);
    break;
  case 3:
    fprintf(outfile, "S705%08X", startAddr);
    chksum = 5 + ((startAddr >> 0) & 0xFF) + ((startAddr >> 8) & 0xFF) +
             ((startAddr >> 16) & 0xFF) + ((startAddr >> 24) & 0xFF);
    break;
  }
  fprintf(outfile, "%02X\n", 0xFF - (chksum & 0xFF));
  fclose(infile);
  fclose(outfile);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x5,-0x8(%rbp)
je     11e0 <main+0x50>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xe3f(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe59(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x1,%edi
call   10b0 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe55(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
jne    1211 <main+0x81>
movl   $0x1,-0x14(%rbp)
movl   $0xffff,-0x18(%rbp)
jmp    128b <main+0xfb>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe28(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
jne    1242 <main+0xb2>
movl   $0x2,-0x14(%rbp)
movl   $0xffffff,-0x18(%rbp)
jmp    1286 <main+0xf6>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xdfb(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
jne    1273 <main+0xe3>
movl   $0x3,-0x14(%rbp)
movl   $0xffffffff,-0x18(%rbp)
jmp    1281 <main+0xf1>
lea    0xdd6(%rip),%rdi
mov    $0x0,%al
call   1080 <error@plt>
jmp    1286 <main+0xf6>
jmp    128b <main+0xfb>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rax
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rax
mov    0x20(%rax),%rax
mov    %rax,-0x30(%rbp)
mov    -0x20(%rbp),%rdi
lea    -0x38(%rbp),%rsi
mov    $0x10,%edx
call   10a0 <strtoul@plt>
mov    %eax,-0x3c(%rbp)
mov    -0x38(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     12e6 <main+0x156>
mov    -0x20(%rbp),%rsi
lea    0xda3(%rip),%rdi
mov    $0x0,%al
call   1080 <error@plt>
mov    -0x3c(%rbp),%eax
mov    -0x18(%rbp),%ecx
xor    $0xffffffff,%ecx
and    %ecx,%eax
cmp    $0x0,%eax
je     1308 <main+0x178>
lea    0xd99(%rip),%rdi
mov    $0x0,%al
call   1080 <error@plt>
mov    -0x3c(%rbp),%eax
mov    %eax,-0x40(%rbp)
mov    -0x28(%rbp),%rdi
lea    0xd96(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0x48(%rbp)
cmpq   $0x0,-0x48(%rbp)
jne    133f <main+0x1af>
mov    -0x28(%rbp),%rsi
lea    0xd7a(%rip),%rdi
mov    $0x0,%al
call   1080 <error@plt>
mov    -0x30(%rbp),%rdi
lea    0xd82(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0x50(%rbp)
cmpq   $0x0,-0x50(%rbp)
jne    1370 <main+0x1e0>
mov    -0x30(%rbp),%rsi
lea    0xd66(%rip),%rdi
mov    $0x0,%al
call   1080 <error@plt>
jmp    1375 <main+0x1e5>
movl   $0x0,-0x74(%rbp)
movl   $0x0,-0x54(%rbp)
cmpl   $0x10,-0x54(%rbp)
jge    13d4 <main+0x244>
mov    -0x48(%rbp),%rdi
call   1050 <fgetc@plt>
mov    %eax,-0x5c(%rbp)
mov    -0x5c(%rbp),%eax
mov    0x2c45(%rip),%rcx
cmp    (%rcx),%eax
jne    13b0 <main+0x220>
jmp    13d4 <main+0x244>
mov    -0x5c(%rbp),%eax
mov    %al,%cl
movslq -0x54(%rbp),%rax
mov    %cl,-0x70(%rbp,%rax,1)
mov    -0x5c(%rbp),%eax
add    -0x74(%rbp),%eax
mov    %eax,-0x74(%rbp)
mov    -0x54(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x54(%rbp)
jmp    1383 <main+0x1f3>
cmpl   $0x0,-0x54(%rbp)
jne    13e3 <main+0x253>
jmp    15d8 <main+0x448>
mov    -0x14(%rbp),%eax
mov    %eax,-0x78(%rbp)
sub    $0x1,%eax
je     1419 <main+0x289>
jmp    13f7 <main+0x267>
mov    -0x78(%rbp),%eax
sub    $0x2,%eax
je     1439 <main+0x2a9>
jmp    1408 <main+0x278>
mov    -0x78(%rbp),%eax
sub    $0x3,%eax
je     1459 <main+0x2c9>
jmp    1474 <main+0x2e4>
mov    -0x50(%rbp),%rdi
mov    -0x54(%rbp),%edx
add    $0x3,%edx
mov    -0x3c(%rbp),%ecx
lea    0xcbd(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
jmp    1474 <main+0x2e4>
mov    -0x50(%rbp),%rdi
mov    -0x54(%rbp),%edx
add    $0x4,%edx
mov    -0x3c(%rbp),%ecx
lea    0xca8(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
jmp    1474 <main+0x2e4>
mov    -0x50(%rbp),%rdi
mov    -0x54(%rbp),%edx
add    $0x5,%edx
mov    -0x3c(%rbp),%ecx
lea    0xc93(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
movl   $0x0,-0x58(%rbp)
mov    -0x58(%rbp),%eax
cmp    -0x54(%rbp),%eax
jge    14b0 <main+0x320>
mov    -0x50(%rbp),%rdi
movslq -0x58(%rbp),%rax
movzbl -0x70(%rbp,%rax,1),%edx
lea    0xc70(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    -0x58(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x58(%rbp)
jmp    147b <main+0x2eb>
mov    -0x14(%rbp),%eax
mov    %eax,-0x7c(%rbp)
sub    $0x1,%eax
je     14e6 <main+0x356>
jmp    14c4 <main+0x334>
mov    -0x7c(%rbp),%eax
sub    $0x2,%eax
je     1513 <main+0x383>
jmp    14d5 <main+0x345>
mov    -0x7c(%rbp),%eax
sub    $0x3,%eax
je     154e <main+0x3be>
jmp    1592 <main+0x402>
mov    -0x54(%rbp),%eax
add    $0x3,%eax
mov    -0x3c(%rbp),%ecx
shr    $0x0,%ecx
and    $0xff,%ecx
add    %ecx,%eax
mov    -0x3c(%rbp),%ecx
shr    $0x8,%ecx
and    $0xff,%ecx
add    %ecx,%eax
add    -0x74(%rbp),%eax
mov    %eax,-0x74(%rbp)
jmp    1592 <main+0x402>
mov    -0x54(%rbp),%eax
add    $0x4,%eax
mov    -0x3c(%rbp),%ecx
shr    $0x0,%ecx
and    $0xff,%ecx
add    %ecx,%eax
mov    -0x3c(%rbp),%ecx
shr    $0x8,%ecx
and    $0xff,%ecx
add    %ecx,%eax
mov    -0x3c(%rbp),%ecx
shr    $0x10,%ecx
and    $0xff,%ecx
add    %ecx,%eax
add    -0x74(%rbp),%eax
mov    %eax,-0x74(%rbp)
jmp    1592 <main+0x402>
mov    -0x54(%rbp),%eax
add    $0x5,%eax
mov    -0x3c(%rbp),%ecx
shr    $0x0,%ecx
and    $0xff,%ecx
add    %ecx,%eax
mov    -0x3c(%rbp),%ecx
shr    $0x8,%ecx
and    $0xff,%ecx
add    %ecx,%eax
mov    -0x3c(%rbp),%ecx
shr    $0x10,%ecx
and    $0xff,%ecx
add    %ecx,%eax
mov    -0x3c(%rbp),%ecx
shr    $0x18,%ecx
and    $0xff,%ecx
add    %ecx,%eax
add    -0x74(%rbp),%eax
mov    %eax,-0x74(%rbp)
mov    -0x50(%rbp),%rdi
mov    -0x74(%rbp),%eax
and    $0xff,%eax
mov    $0xff,%edx
sub    %eax,%edx
lea    0xb64(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    -0x54(%rbp),%eax
add    -0x3c(%rbp),%eax
mov    %eax,-0x3c(%rbp)
mov    -0x5c(%rbp),%eax
mov    0x2a22(%rip),%rcx
cmp    (%rcx),%eax
jne    15d3 <main+0x443>
jmp    15d8 <main+0x448>
jmp    1375 <main+0x1e5>
mov    -0x14(%rbp),%eax
mov    %eax,-0x80(%rbp)
sub    $0x1,%eax
je     160e <main+0x47e>
jmp    15ec <main+0x45c>
mov    -0x80(%rbp),%eax
sub    $0x2,%eax
je     1647 <main+0x4b7>
jmp    15fd <main+0x46d>
mov    -0x80(%rbp),%eax
sub    $0x3,%eax
je     168e <main+0x4fe>
jmp    16de <main+0x54e>
mov    -0x50(%rbp),%rdi
mov    -0x40(%rbp),%edx
lea    0xafa(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    -0x40(%rbp),%eax
shr    $0x0,%eax
and    $0xff,%eax
add    $0x3,%eax
mov    -0x40(%rbp),%ecx
shr    $0x8,%ecx
and    $0xff,%ecx
add    %ecx,%eax
mov    %eax,-0x74(%rbp)
jmp    16de <main+0x54e>
mov    -0x50(%rbp),%rdi
mov    -0x40(%rbp),%edx
lea    0xaca(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    -0x40(%rbp),%eax
shr    $0x0,%eax
and    $0xff,%eax
add    $0x4,%eax
mov    -0x40(%rbp),%ecx
shr    $0x8,%ecx
and    $0xff,%ecx
add    %ecx,%eax
mov    -0x40(%rbp),%ecx
shr    $0x10,%ecx
and    $0xff,%ecx
add    %ecx,%eax
mov    %eax,-0x74(%rbp)
jmp    16de <main+0x54e>
mov    -0x50(%rbp),%rdi
mov    -0x40(%rbp),%edx
lea    0xa8c(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    -0x40(%rbp),%eax
shr    $0x0,%eax
and    $0xff,%eax
add    $0x5,%eax
mov    -0x40(%rbp),%ecx
shr    $0x8,%ecx
and    $0xff,%ecx
add    %ecx,%eax
mov    -0x40(%rbp),%ecx
shr    $0x10,%ecx
and    $0xff,%ecx
add    %ecx,%eax
mov    -0x40(%rbp),%ecx
shr    $0x18,%ecx
and    $0xff,%ecx
add    %ecx,%eax
mov    %eax,-0x74(%rbp)
mov    -0x50(%rbp),%rdi
mov    -0x74(%rbp),%eax
and    $0xff,%eax
mov    $0xff,%edx
sub    %eax,%edx
lea    0xa18(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    -0x48(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x50(%rbp),%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x68,%rsp
mov    %rsi,%rbx
cmp    $0x5,%edi
jne    174c <main+0x5ac>
mov    0x8(%rbx),%rdi
lea    0xe63(%rip),%rsi
call   1070 <strcmp@plt>
test   %rax,%rax
je     120e <main+0x6e>
mov    0x8(%rbx),%rdi
lea    0xe52(%rip),%rsi
call   1070 <strcmp@plt>
test   %rax,%rax
je     1220 <main+0x80>
mov    0x8(%rbx),%rdi
lea    0xe41(%rip),%rsi
call   1070 <strcmp@plt>
test   %rax,%rax
je     1232 <main+0x92>
lea    0xe34(%rip),%rdi
xor    %eax,%eax
call   1090 <error@plt>
mov    %rax,0x10(%rsp)
jmp    123f <main+0x9f>
mov    $0x1,%eax
mov    %rax,0x10(%rsp)
mov    $0xffff0000,%r14d
jmp    123f <main+0x9f>
mov    $0x2,%eax
mov    %rax,0x10(%rsp)
mov    $0xff000000,%r14d
jmp    123f <main+0x9f>
mov    $0x3,%eax
mov    %rax,0x10(%rsp)
xor    %r14d,%r14d
mov    0x10(%rbx),%rbp
mov    0x18(%rbx),%r12
mov    0x20(%rbx),%rbx
lea    0x60(%rsp),%rsi
mov    %rbp,%rdi
mov    $0x10,%edx
call   10b0 <strtoul@plt>
mov    %eax,0x1c(%rsp)
mov    0x60(%rsp),%rax
cmpb   $0x0,(%rax)
je     127c <main+0xdc>
lea    0xdf4(%rip),%rdi
mov    %rbp,%rsi
xor    %eax,%eax
call   1090 <error@plt>
test   %r14d,0x1c(%rsp)
je     1291 <main+0xf1>
lea    0xdf4(%rip),%rdi
xor    %eax,%eax
call   1090 <error@plt>
lea    0xdfb(%rip),%rsi
mov    %r12,%rdi
call   10a0 <fopen@plt>
mov    %rax,%r14
test   %rax,%rax
jne    12b9 <main+0x119>
lea    0xde7(%rip),%rdi
mov    %r12,%rsi
xor    %eax,%eax
call   1090 <error@plt>
lea    0xdf0(%rip),%rsi
mov    %rbx,%rdi
call   10a0 <fopen@plt>
mov    %rax,%r15
test   %rax,%rax
jne    12e1 <main+0x141>
lea    0xddc(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1090 <error@plt>
mov    0x10(%rsp),%rcx
lea    -0x1(%rcx),%eax
add    $0x2,%ecx
mov    %rcx,0x50(%rsp)
mov    %eax,0x44(%rsp)
cltq
shl    $0x2,%rax
mov    %rax,0x48(%rsp)
mov    0x2ce1(%rip),%rbp
lea    0xde1(%rip),%r12
mov    0x1c(%rsp),%ebx
mov    %r14,0x58(%rsp)
jmp    1384 <main+0x1e4>
nopl   0x0(%rax)
mov    0x34(%rsp),%ebx
movzbl %bl,%eax
movzbl %bh,%esi
mov    %ebx,%edx
shr    $0x10,%edx
movzbl %dl,%edx
mov    %ebx,%ecx
shr    $0x18,%ecx
mov    0x38(%rsp),%r14
add    %r14d,%r13d
add    %eax,%r13d
add    %ecx,%r13d
add    %esi,%r13d
add    %edx,%r13d
add    $0x5,%r13d
mov    0x2c92(%rip),%rbp
mov    %r13d,%eax
not    %eax
movzbl %al,%edx
mov    %r15,%rdi
lea    0xd8c(%rip),%rsi
xor    %eax,%eax
call   1080 <fprintf@plt>
add    %r14d,%ebx
mov    0xc(%rsp),%eax
cmp    0x0(%rbp),%eax
mov    0x58(%rsp),%r14
je     1671 <main+0x4d1>
mov    %ebx,0x34(%rsp)
mov    %r14,%rdi
call   1060 <fgetc@plt>
cmp    0x0(%rbp),%eax
je     166e <main+0x4ce>
mov    %eax,%r13d
mov    %r13b,0x20(%rsp)
mov    %r14,%rdi
call   1060 <fgetc@plt>
mov    %r14,%rbx
mov    $0x1,%r14d
cmp    0x0(%rbp),%eax
je     1540 <main+0x3a0>
mov    %al,0x21(%rsp)
add    %eax,%r13d
mov    %rbx,%rdi
call   1060 <fgetc@plt>
mov    $0x2,%r14d
cmp    0x0(%rbp),%eax
je     1540 <main+0x3a0>
mov    %al,0x22(%rsp)
add    %eax,%r13d
mov    %rbx,%rdi
call   1060 <fgetc@plt>
mov    $0x3,%r14d
cmp    0x0(%rbp),%eax
je     1540 <main+0x3a0>
mov    %al,0x23(%rsp)
add    %eax,%r13d
mov    %rbx,%rdi
call   1060 <fgetc@plt>
mov    $0x4,%r14d
cmp    0x0(%rbp),%eax
je     1540 <main+0x3a0>
mov    %al,0x24(%rsp)
add    %eax,%r13d
mov    %rbx,%rdi
call   1060 <fgetc@plt>
mov    $0x5,%r14d
cmp    0x0(%rbp),%eax
je     1540 <main+0x3a0>
mov    %al,0x25(%rsp)
add    %eax,%r13d
mov    %rbx,%rdi
call   1060 <fgetc@plt>
mov    $0x6,%r14d
cmp    0x0(%rbp),%eax
je     1540 <main+0x3a0>
mov    %al,0x26(%rsp)
add    %eax,%r13d
mov    %rbx,%rdi
call   1060 <fgetc@plt>
mov    $0x7,%r14d
cmp    0x0(%rbp),%eax
je     1540 <main+0x3a0>
mov    %al,0x27(%rsp)
add    %eax,%r13d
mov    %rbx,%rdi
call   1060 <fgetc@plt>
mov    $0x8,%r14d
cmp    0x0(%rbp),%eax
je     1540 <main+0x3a0>
mov    %al,0x28(%rsp)
add    %eax,%r13d
mov    %rbx,%rdi
call   1060 <fgetc@plt>
mov    $0x9,%r14d
cmp    0x0(%rbp),%eax
je     1540 <main+0x3a0>
mov    %al,0x29(%rsp)
add    %eax,%r13d
mov    %rbx,%rdi
call   1060 <fgetc@plt>
mov    $0xa,%r14d
cmp    0x0(%rbp),%eax
je     1540 <main+0x3a0>
mov    %al,0x2a(%rsp)
add    %eax,%r13d
mov    %rbx,%rdi
call   1060 <fgetc@plt>
mov    $0xb,%r14d
cmp    0x0(%rbp),%eax
je     1540 <main+0x3a0>
mov    %al,0x2b(%rsp)
add    %eax,%r13d
mov    %rbx,%rdi
call   1060 <fgetc@plt>
mov    $0xc,%r14d
cmp    0x0(%rbp),%eax
je     1540 <main+0x3a0>
mov    %al,0x2c(%rsp)
add    %eax,%r13d
mov    %rbx,%rdi
call   1060 <fgetc@plt>
mov    $0xd,%r14d
cmp    0x0(%rbp),%eax
je     1540 <main+0x3a0>
mov    %al,0x2d(%rsp)
add    %eax,%r13d
mov    %rbx,%rdi
call   1060 <fgetc@plt>
mov    $0xe,%r14d
cmp    0x0(%rbp),%eax
jne    163a <main+0x49a>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %eax,0xc(%rsp)
mov    0x10(%rsp),%rbp
mov    %r13,%rbx
cmpl   $0x2,0x44(%rsp)
ja     157d <main+0x3dd>
mov    0x48(%rsp),%rax
lea    0xbd1(%rip),%rcx
movslq (%rax,%rcx,1),%rsi
add    %rcx,%rsi
mov    0x50(%rsp),%rax
lea    (%r14,%rax,1),%edx
mov    %r15,%rdi
mov    0x34(%rsp),%ecx
xor    %eax,%eax
call   1080 <fprintf@plt>
mov    %r14,0x38(%rsp)
mov    %r14d,%r14d
xor    %r13d,%r13d
nopl   0x0(%rax,%rax,1)
movzbl 0x20(%rsp,%r13,1),%edx
mov    %r15,%rdi
mov    %r12,%rsi
xor    %eax,%eax
call   1080 <fprintf@plt>
add    $0x1,%r13
cmp    %r13,%r14
jne    1590 <main+0x3f0>
mov    %rbx,%r13
mov    %rbp,%rax
cmp    $0x3,%eax
mov    %rbp,0x10(%rsp)
je     1320 <main+0x180>
cmp    $0x2,%eax
mov    0x2a1e(%rip),%rbp
mov    0x34(%rsp),%ebx
je     1600 <main+0x460>
cmp    $0x1,%eax
jne    1630 <main+0x490>
movzbl %bl,%eax
movzbl %bh,%ecx
mov    0x38(%rsp),%r14
add    %r14d,%r13d
add    %eax,%r13d
add    %ecx,%r13d
add    $0x3,%r13d
jmp    1356 <main+0x1b6>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movzbl %bl,%eax
movzbl %bh,%ecx
mov    %ebx,%edx
shr    $0x10,%edx
movzbl %dl,%edx
mov    0x38(%rsp),%r14
add    %r14d,%r13d
add    %eax,%r13d
add    %ecx,%r13d
add    %edx,%r13d
add    $0x4,%r13d
jmp    1356 <main+0x1b6>
nopl   0x0(%rax,%rax,1)
mov    0x38(%rsp),%r14
jmp    1356 <main+0x1b6>
mov    %al,0x2e(%rsp)
add    %eax,%r13d
mov    %rbx,%rdi
call   1060 <fgetc@plt>
mov    $0xf,%r14d
cmp    0x0(%rbp),%eax
mov    %eax,0xc(%rsp)
je     1544 <main+0x3a4>
mov    %al,0x2f(%rsp)
add    %eax,%r13d
mov    $0x10,%r14d
jmp    1544 <main+0x3a4>
xor    %r13d,%r13d
mov    0x10(%rsp),%rax
cmp    $0x3,%eax
je     16b0 <main+0x510>
cmp    $0x2,%eax
je     16e6 <main+0x546>
cmp    $0x1,%eax
jne    1713 <main+0x573>
lea    0xa6a(%rip),%rsi
mov    %r15,%rdi
mov    0x1c(%rsp),%ebx
mov    %ebx,%edx
xor    %eax,%eax
call   1080 <fprintf@plt>
movzbl %bl,%eax
movzbl %bh,%ecx
lea    (%rax,%rcx,1),%r13d
add    $0x3,%r13d
jmp    1713 <main+0x573>
lea    0xa55(%rip),%rsi
mov    %r15,%rdi
mov    0x1c(%rsp),%ebx
mov    %ebx,%edx
xor    %eax,%eax
call   1080 <fprintf@plt>
movzbl %bl,%eax
mov    %ebx,%ecx
shr    $0x18,%ecx
add    %eax,%ecx
movzbl %bh,%eax
shr    $0x10,%ebx
movzbl %bl,%edx
add    %ecx,%eax
lea    (%rdx,%rax,1),%r13d
add    $0x5,%r13d
jmp    1713 <main+0x573>
lea    0xa16(%rip),%rsi
mov    %r15,%rdi
mov    0x1c(%rsp),%ebx
mov    %ebx,%edx
xor    %eax,%eax
call   1080 <fprintf@plt>
movzbl %bl,%eax
movzbl %bh,%ecx
add    %eax,%ecx
shr    $0x10,%ebx
movzbl %bl,%eax
lea    (%rax,%rcx,1),%r13d
add    $0x4,%r13d
not    %r13d
movzbl %r13b,%edx
lea    0x9d3(%rip),%rsi
mov    %r15,%rdi
xor    %eax,%eax
call   1080 <fprintf@plt>
mov    %r14,%rdi
call   1040 <fclose@plt>
mov    %r15,%rdi
call   1040 <fclose@plt>
xor    %eax,%eax
add    $0x68,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    (%rbx),%rsi
lea    0x8aa(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0x9b1(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%edi
call   10c0 <exit@plt>

LLVM IR (-O0):
@.str = [40 x i8] c"Usage: %s -S1|-S2|-S3 <load addr, hex> \00"
@.str.1 = [28 x i8] c"<input file> <output file>\0A\00"
@.str.2 = [4 x i8] c"-S1\00"
@.str.3 = [4 x i8] c"-S2\00"
@.str.4 = [4 x i8] c"-S3\00"
@.str.5 = [50 x i8] c"exactly one of -S1, -S2, or -S3 must be specified\00"
@.str.6 = [24 x i8] c"illegal load address %s\00"
@.str.7 = [21 x i8] c"load address too big\00"
@.str.8 = [3 x i8] c"rb\00"
@.str.9 = [26 x i8] c"cannot open input file %s\00"
@.str.10 = [3 x i8] c"wt\00"
@.str.11 = [27 x i8] c"cannot open output file %s\00"
@EOF = global i32 0
@.str.12 = [11 x i8] c"S1%02X%04X\00"
@.str.13 = [11 x i8] c"S2%02X%06X\00"
@.str.14 = [11 x i8] c"S3%02X%08X\00"
@.str.15 = [5 x i8] c"%02X\00"
@.str.16 = [6 x i8] c"%02X\0A\00"
@.str.17 = [9 x i8] c"S903%04X\00"
@.str.18 = [9 x i8] c"S804%06X\00"
@.str.19 = [9 x i8] c"S705%08X\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i8*
%11 = alloca i8*
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32*
%15 = alloca i32*
%16 = alloca i32
%17 = alloca i32
%18 = alloca i32
%19 = alloca [16 x i8]
%20 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%21 = load i32, i32* %4
%22 = icmp ne i32 %21, 5
br i1 %22, label %23, label %30
23: ; preds = %2
%24 = load i8**, i8*** %5
%25 = getelementptr inbounds i8*, i8** %24, i64 0
%26 = load i8*, i8** %25
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str, i64 0, i64 0), i8* %26)
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0))
%29 = call i32 @exit(i32 1)
unreachable
30: ; preds = %2
%31 = load i8**, i8*** %5
%32 = getelementptr inbounds i8*, i8** %31, i64 1
%33 = load i8*, i8** %32
%34 = call i64 @strcmp(i8* %33, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
%35 = icmp eq i64 %34, 0
br i1 %35, label %36, label %37
36: ; preds = %30
store i32 1, i32* %6
store i32 65535, i32* %7
br label %55
37: ; preds = %30
%38 = load i8**, i8*** %5
%39 = getelementptr inbounds i8*, i8** %38, i64 1
%40 = load i8*, i8** %39
%41 = call i64 @strcmp(i8* %40, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
%42 = icmp eq i64 %41, 0
br i1 %42, label %43, label %44
43: ; preds = %37
store i32 2, i32* %6
store i32 16777215, i32* %7
br label %54
44: ; preds = %37
%45 = load i8**, i8*** %5
%46 = getelementptr inbounds i8*, i8** %45, i64 1
%47 = load i8*, i8** %46
%48 = call i64 @strcmp(i8* %47, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0))
%49 = icmp eq i64 %48, 0
br i1 %49, label %50, label %51
50: ; preds = %44
store i32 3, i32* %6
store i32 -1, i32* %7
br label %53
51: ; preds = %44
%52 = call i32 (i8*, ...) @error(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.5, i64 0, i64 0))
br label %53
53: ; preds = %51, %50
br label %54
54: ; preds = %53, %43
br label %55
55: ; preds = %54, %36
%56 = load i8**, i8*** %5
%57 = getelementptr inbounds i8*, i8** %56, i64 2
%58 = load i8*, i8** %57
store i8* %58, i8** %8
%59 = load i8**, i8*** %5
%60 = getelementptr inbounds i8*, i8** %59, i64 3
%61 = load i8*, i8** %60
store i8* %61, i8** %9
%62 = load i8**, i8*** %5
%63 = getelementptr inbounds i8*, i8** %62, i64 4
%64 = load i8*, i8** %63
store i8* %64, i8** %10
%65 = load i8*, i8** %8
%66 = call i32 @strtoul(i8* %65, i8** %11, i32 16)
store i32 %66, i32* %12
%67 = load i8*, i8** %11
%68 = load i8, i8* %67
%69 = sext i8 %68 to i32
%70 = icmp ne i32 %69, 0
br i1 %70, label %71, label %74
71: ; preds = %55
%72 = load i8*, i8** %8
%73 = call i32 (i8*, ...) @error(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.6, i64 0, i64 0), i8* %72)
br label %74
74: ; preds = %71, %55
%75 = load i32, i32* %12
%76 = load i32, i32* %7
%77 = xor i32 %76, -1
%78 = and i32 %75, %77
%79 = icmp ne i32 %78, 0
br i1 %79, label %80, label %82
80: ; preds = %74
%81 = call i32 (i8*, ...) @error(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.7, i64 0, i64 0))
br label %82
82: ; preds = %80, %74
%83 = load i32, i32* %12
store i32 %83, i32* %13
%84 = load i8*, i8** %9
%85 = call i32* @fopen(i8* %84, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0))
store i32* %85, i32** %14
%86 = load i32*, i32** %14
%87 = icmp eq i32* %86, null
br i1 %87, label %88, label %91
88: ; preds = %82
%89 = load i8*, i8** %9
%90 = call i32 (i8*, ...) @error(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.9, i64 0, i64 0), i8* %89)
br label %91
91: ; preds = %88, %82
%92 = load i8*, i8** %10
%93 = call i32* @fopen(i8* %92, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.10, i64 0, i64 0))
store i32* %93, i32** %15
%94 = load i32*, i32** %15
%95 = icmp eq i32* %94, null
br i1 %95, label %96, label %99
96: ; preds = %91
%97 = load i8*, i8** %10
%98 = call i32 (i8*, ...) @error(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.11, i64 0, i64 0), i8* %97)
br label %99
99: ; preds = %96, %91
br label %100
100: ; preds = %99, %229
store i32 0, i32* %20
store i32 0, i32* %16
br label %101
101: ; preds = %120, %100
%102 = load i32, i32* %16
%103 = icmp slt i32 %102, 16
br i1 %103, label %104, label %123
104: ; preds = %101
%105 = load i32*, i32** %14
%106 = call i32 @fgetc(i32* %105)
store i32 %106, i32* %18
%107 = load i32, i32* %18
%108 = load i32, i32* @EOF
%109 = icmp eq i32 %107, %108
br i1 %109, label %110, label %111
110: ; preds = %104
br label %123
111: ; preds = %104
%112 = load i32, i32* %18
%113 = trunc i32 %112 to i8
%114 = load i32, i32* %16
%115 = sext i32 %114 to i64
%116 = getelementptr inbounds [16 x i8], [16 x i8]* %19, i64 0, i64 %115
store i8 %113, i8* %116
%117 = load i32, i32* %18
%118 = load i32, i32* %20
%119 = add i32 %118, %117
store i32 %119, i32* %20
br label %120
120: ; preds = %111
%121 = load i32, i32* %16
%122 = add nsw i32 %121, 1
store i32 %122, i32* %16
br label %101
123: ; preds = %110, %101
%124 = load i32, i32* %16
%125 = icmp eq i32 %124, 0
br i1 %125, label %126, label %127
126: ; preds = %123
br label %230
127: ; preds = %123
%128 = load i32, i32* %6
switch i32 %128, label %147 [
i32 1, label %129
i32 2, label %135
i32 3, label %141
]
129: ; preds = %127
%130 = load i32*, i32** %15
%131 = load i32, i32* %16
%132 = add nsw i32 %131, 3
%133 = load i32, i32* %12
%134 = call i32 (i32*, i8*, i32, ...) @fprintf(i32* %130, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.12, i64 0, i64 0), i32 %132, i32 %133)
br label %147
135: ; preds = %127
%136 = load i32*, i32** %15
%137 = load i32, i32* %16
%138 = add nsw i32 %137, 4
%139 = load i32, i32* %12
%140 = call i32 (i32*, i8*, i32, ...) @fprintf(i32* %136, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.13, i64 0, i64 0), i32 %138, i32 %139)
br label %147
141: ; preds = %127
%142 = load i32*, i32** %15
%143 = load i32, i32* %16
%144 = add nsw i32 %143, 5
%145 = load i32, i32* %12
%146 = call i32 (i32*, i8*, i32, ...) @fprintf(i32* %142, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.14, i64 0, i64 0), i32 %144, i32 %145)
br label %147
147: ; preds = %127, %141, %135, %129
store i32 0, i32* %17
br label %148
148: ; preds = %160, %147
%149 = load i32, i32* %17
%150 = load i32, i32* %16
%151 = icmp slt i32 %149, %150
br i1 %151, label %152, label %163
152: ; preds = %148
%153 = load i32*, i32** %15
%154 = load i32, i32* %17
%155 = sext i32 %154 to i64
%156 = getelementptr inbounds [16 x i8], [16 x i8]* %19, i64 0, i64 %155
%157 = load i8, i8* %156
%158 = zext i8 %157 to i32
%159 = call i32 (i32*, i8*, i32, ...) @fprintf(i32* %153, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.15, i64 0, i64 0), i32 %158)
br label %160
160: ; preds = %152
%161 = load i32, i32* %17
%162 = add nsw i32 %161, 1
store i32 %162, i32* %17
br label %148
163: ; preds = %148
%164 = load i32, i32* %6
switch i32 %164, label %216 [
i32 1, label %165
i32 2, label %178
i32 3, label %195
]
165: ; preds = %163
%166 = load i32, i32* %16
%167 = add nsw i32 %166, 3
%168 = load i32, i32* %12
%169 = lshr i32 %168, 0
%170 = and i32 %169, 255
%171 = add i32 %167, %170
%172 = load i32, i32* %12
%173 = lshr i32 %172, 8
%174 = and i32 %173, 255
%175 = add i32 %171, %174
%176 = load i32, i32* %20
%177 = add i32 %176, %175
store i32 %177, i32* %20
br label %216
178: ; preds = %163
%179 = load i32, i32* %16
%180 = add nsw i32 %179, 4
%181 = load i32, i32* %12
%182 = lshr i32 %181, 0
%183 = and i32 %182, 255
%184 = add i32 %180, %183
%185 = load i32, i32* %12
%186 = lshr i32 %185, 8
%187 = and i32 %186, 255
%188 = add i32 %184, %187
%189 = load i32, i32* %12
%190 = lshr i32 %189, 16
%191 = and i32 %190, 255
%192 = add i32 %188, %191
%193 = load i32, i32* %20
%194 = add i32 %193, %192
store i32 %194, i32* %20
br label %216
195: ; preds = %163
%196 = load i32, i32* %16
%197 = add nsw i32 %196, 5
%198 = load i32, i32* %12
%199 = lshr i32 %198, 0
%200 = and i32 %199, 255
%201 = add i32 %197, %200
%202 = load i32, i32* %12
%203 = lshr i32 %202, 8
%204 = and i32 %203, 255
%205 = add i32 %201, %204
%206 = load i32, i32* %12
%207 = lshr i32 %206, 16
%208 = and i32 %207, 255
%209 = add i32 %205, %208
%210 = load i32, i32* %12
%211 = lshr i32 %210, 24
%212 = and i32 %211, 255
%213 = add i32 %209, %212
%214 = load i32, i32* %20
%215 = add i32 %214, %213
store i32 %215, i32* %20
br label %216
216: ; preds = %163, %195, %178, %165
%217 = load i32*, i32** %15
%218 = load i32, i32* %20
%219 = and i32 %218, 255
%220 = sub i32 255, %219
%221 = call i32 (i32*, i8*, i32, ...) @fprintf(i32* %217, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.16, i64 0, i64 0), i32 %220)
%222 = load i32, i32* %16
%223 = load i32, i32* %12
%224 = add i32 %223, %222
store i32 %224, i32* %12
%225 = load i32, i32* %18
%226 = load i32, i32* @EOF
%227 = icmp eq i32 %225, %226
br i1 %227, label %228, label %229
228: ; preds = %216
br label %230
229: ; preds = %216
br label %100
230: ; preds = %228, %126
%231 = load i32, i32* %6
switch i32 %231, label %280 [
i32 1, label %232
i32 2, label %244
i32 3, label %260
]
232: ; preds = %230
%233 = load i32*, i32** %15
%234 = load i32, i32* %13
%235 = call i32 (i32*, i8*, i32, ...) @fprintf(i32* %233, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.17, i64 0, i64 0), i32 %234)
%236 = load i32, i32* %13
%237 = lshr i32 %236, 0
%238 = and i32 %237, 255
%239 = add i32 3, %238
%240 = load i32, i32* %13
%241 = lshr i32 %240, 8
%242 = and i32 %241, 255
%243 = add i32 %239, %242
store i32 %243, i32* %20
br label %280
244: ; preds = %230
%245 = load i32*, i32** %15
%246 = load i32, i32* %13
%247 = call i32 (i32*, i8*, i32, ...) @fprintf(i32* %245, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.18, i64 0, i64 0), i32 %246)
%248 = load i32, i32* %13
%249 = lshr i32 %248, 0
%250 = and i32 %249, 255
%251 = add i32 4, %250
%252 = load i32, i32* %13
%253 = lshr i32 %252, 8
%254 = and i32 %253, 255
%255 = add i32 %251, %254
%256 = load i32, i32* %13
%257 = lshr i32 %256, 16
%258 = and i32 %257, 255
%259 = add i32 %255, %258
store i32 %259, i32* %20
br label %280
260: ; preds = %230
%261 = load i32*, i32** %15
%262 = load i32, i32* %13
%263 = call i32 (i32*, i8*, i32, ...) @fprintf(i32* %261, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.19, i64 0, i64 0), i32 %262)
%264 = load i32, i32* %13
%265 = lshr i32 %264, 0
%266 = and i32 %265, 255
%267 = add i32 5, %266
%268 = load i32, i32* %13
%269 = lshr i32 %268, 8
%270 = and i32 %269, 255
%271 = add i32 %267, %270
%272 = load i32, i32* %13
%273 = lshr i32 %272, 16
%274 = and i32 %273, 255
%275 = add i32 %271, %274
%276 = load i32, i32* %13
%277 = lshr i32 %276, 24
%278 = and i32 %277, 255
%279 = add i32 %275, %278
store i32 %279, i32* %20
br label %280
280: ; preds = %230, %260, %244, %232
%281 = load i32*, i32** %15
%282 = load i32, i32* %20
%283 = and i32 %282, 255
%284 = sub i32 255, %283
%285 = call i32 (i32*, i8*, i32, ...) @fprintf(i32* %281, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.16, i64 0, i64 0), i32 %284)
%286 = load i32*, i32** %14
%287 = call i32 @fclose(i32* %286)
%288 = load i32*, i32** %15
%289 = call i32 @fclose(i32* %288)
ret i32 0
}

LLVM IR (-O2):
@.str = [40 x i8] c"Usage: %s -S1|-S2|-S3 <load addr, hex> \00"
@.str.2 = [4 x i8] c"-S1\00"
@.str.3 = [4 x i8] c"-S2\00"
@.str.4 = [4 x i8] c"-S3\00"
@.str.5 = [50 x i8] c"exactly one of -S1, -S2, or -S3 must be specified\00"
@.str.6 = [24 x i8] c"illegal load address %s\00"
@.str.7 = [21 x i8] c"load address too big\00"
@.str.8 = [3 x i8] c"rb\00"
@.str.9 = [26 x i8] c"cannot open input file %s\00"
@.str.10 = [3 x i8] c"wt\00"
@.str.11 = [27 x i8] c"cannot open output file %s\00"
@EOF = global i32 0
@.str.12 = [11 x i8] c"S1%02X%04X\00"
@.str.13 = [11 x i8] c"S2%02X%06X\00"
@.str.14 = [11 x i8] c"S3%02X%08X\00"
@.str.15 = [5 x i8] c"%02X\00"
@.str.16 = [6 x i8] c"%02X\0A\00"
@.str.17 = [9 x i8] c"S903%04X\00"
@.str.18 = [9 x i8] c"S804%06X\00"
@.str.19 = [9 x i8] c"S705%08X\00"
@str = [27 x i8] c"<input file> <output file>\00"
@reltable.main = [3 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([11 x i8]* @.str.12 to i64), i64 ptrtoint ([3 x i32]* @reltable.main to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([11 x i8]* @.str.13 to i64), i64 ptrtoint ([3 x i32]* @reltable.main to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([11 x i8]* @.str.14 to i64), i64 ptrtoint ([3 x i32]* @reltable.main to i64)) to i32)]
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i8*
%4 = alloca [16 x i8]
%5 = bitcast i8** %3 to i8*
%6 = getelementptr inbounds [16 x i8], [16 x i8]* %4, i64 0, i64 0
%7 = icmp eq i32 %0, 5
br i1 %7, label %13, label %8
8: ; preds = %2
%9 = load i8*, i8** %1
%10 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @.str, i64 0, i64 0), i8* %9)
%11 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @str, i64 0, i64 0))
%12 = tail call i32 @exit(i32 1)
unreachable
13: ; preds = %2
%14 = getelementptr inbounds i8*, i8** %1, i64 1
%15 = load i8*, i8** %14
%16 = tail call i64 @strcmp(i8* %15, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
%17 = icmp eq i64 %16, 0
br i1 %17, label %28, label %18
18: ; preds = %13
%19 = load i8*, i8** %14
%20 = tail call i64 @strcmp(i8* %19, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
%21 = icmp eq i64 %20, 0
br i1 %21, label %28, label %22
22: ; preds = %18
%23 = load i8*, i8** %14
%24 = tail call i64 @strcmp(i8* %23, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0))
%25 = icmp eq i64 %24, 0
br i1 %25, label %28, label %26
26: ; preds = %22
%27 = tail call i32 (i8*, ...) @error(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.5, i64 0, i64 0))
br label %28
28: ; preds = %22, %18, %13, %26
%29 = phi i32 [ undef, %26 ], [ -65536, %13 ], [ -16777216, %18 ], [ 0, %22 ]
%30 = phi i32 [ undef, %26 ], [ 1, %13 ], [ 2, %18 ], [ 3, %22 ]
%31 = getelementptr inbounds i8*, i8** %1, i64 2
%32 = load i8*, i8** %31
%33 = getelementptr inbounds i8*, i8** %1, i64 3
%34 = load i8*, i8** %33
%35 = getelementptr inbounds i8*, i8** %1, i64 4
%36 = load i8*, i8** %35
%37 = call i32 @strtoul(i8* %32, i8** %3, i32 16)
%38 = load i8*, i8** %3
%39 = load i8, i8* %38
%40 = icmp eq i8 %39, 0
br i1 %40, label %43, label %41
41: ; preds = %28
%42 = tail call i32 (i8*, ...) @error(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.6, i64 0, i64 0), i8* %32)
br label %43
43: ; preds = %41, %28
%44 = and i32 %37, %29
%45 = icmp eq i32 %44, 0
br i1 %45, label %48, label %46
46: ; preds = %43
%47 = tail call i32 (i8*, ...) @error(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.7, i64 0, i64 0))
br label %48
48: ; preds = %46, %43
%49 = tail call i32* @fopen(i8* %34, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0))
%50 = icmp eq i32* %49, null
br i1 %50, label %51, label %53
51: ; preds = %48
%52 = tail call i32 (i8*, ...) @error(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.9, i64 0, i64 0), i8* %34)
br label %53
53: ; preds = %51, %48
%54 = tail call i32* @fopen(i8* %36, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.10, i64 0, i64 0))
%55 = icmp eq i32* %54, null
br i1 %55, label %56, label %58
56: ; preds = %53
%57 = tail call i32 (i8*, ...) @error(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.11, i64 0, i64 0), i8* %36)
br label %58
58: ; preds = %56, %53
%59 = getelementptr inbounds [16 x i8], [16 x i8]* %4, i64 0, i64 1
%60 = getelementptr inbounds [16 x i8], [16 x i8]* %4, i64 0, i64 2
%61 = getelementptr inbounds [16 x i8], [16 x i8]* %4, i64 0, i64 3
%62 = getelementptr inbounds [16 x i8], [16 x i8]* %4, i64 0, i64 4
%63 = getelementptr inbounds [16 x i8], [16 x i8]* %4, i64 0, i64 5
%64 = getelementptr inbounds [16 x i8], [16 x i8]* %4, i64 0, i64 6
%65 = getelementptr inbounds [16 x i8], [16 x i8]* %4, i64 0, i64 7
%66 = getelementptr inbounds [16 x i8], [16 x i8]* %4, i64 0, i64 8
%67 = getelementptr inbounds [16 x i8], [16 x i8]* %4, i64 0, i64 9
%68 = getelementptr inbounds [16 x i8], [16 x i8]* %4, i64 0, i64 10
%69 = getelementptr inbounds [16 x i8], [16 x i8]* %4, i64 0, i64 11
%70 = getelementptr inbounds [16 x i8], [16 x i8]* %4, i64 0, i64 12
%71 = getelementptr inbounds [16 x i8], [16 x i8]* %4, i64 0, i64 13
%72 = getelementptr inbounds [16 x i8], [16 x i8]* %4, i64 0, i64 14
%73 = getelementptr inbounds [16 x i8], [16 x i8]* %4, i64 0, i64 15
%74 = add i32 %30, -1
%75 = icmp ult i32 %74, 3
%76 = add i32 %30, 2
%77 = sext i32 %74 to i64
%78 = shl i64 %77, 2
br label %79
79: ; preds = %227, %58
%80 = phi i32 [ %37, %58 ], [ %232, %227 ]
%81 = tail call i32 @fgetc(i32* %49)
%82 = load i32, i32* @EOF
%83 = icmp eq i32 %81, %82
br i1 %83, label %235, label %84
84: ; preds = %79
%85 = trunc i32 %81 to i8
store i8 %85, i8* %6
%86 = tail call i32 @fgetc(i32* %49)
%87 = load i32, i32* @EOF
%88 = icmp eq i32 %86, %87
br i1 %88, label %176, label %89
89: ; preds = %84
%90 = trunc i32 %86 to i8
store i8 %90, i8* %59
%91 = add i32 %86, %81
%92 = tail call i32 @fgetc(i32* %49)
%93 = load i32, i32* @EOF
%94 = icmp eq i32 %92, %93
br i1 %94, label %176, label %95
95: ; preds = %89
%96 = trunc i32 %92 to i8
store i8 %96, i8* %60
%97 = add i32 %92, %91
%98 = tail call i32 @fgetc(i32* %49)
%99 = load i32, i32* @EOF
%100 = icmp eq i32 %98, %99
br i1 %100, label %176, label %101
101: ; preds = %95
%102 = trunc i32 %98 to i8
store i8 %102, i8* %61
%103 = add i32 %98, %97
%104 = tail call i32 @fgetc(i32* %49)
%105 = load i32, i32* @EOF
%106 = icmp eq i32 %104, %105
br i1 %106, label %176, label %107
107: ; preds = %101
%108 = trunc i32 %104 to i8
store i8 %108, i8* %62
%109 = add i32 %104, %103
%110 = tail call i32 @fgetc(i32* %49)
%111 = load i32, i32* @EOF
%112 = icmp eq i32 %110, %111
br i1 %112, label %176, label %113
113: ; preds = %107
%114 = trunc i32 %110 to i8
store i8 %114, i8* %63
%115 = add i32 %110, %109
%116 = tail call i32 @fgetc(i32* %49)
%117 = load i32, i32* @EOF
%118 = icmp eq i32 %116, %117
br i1 %118, label %176, label %119
119: ; preds = %113
%120 = trunc i32 %116 to i8
store i8 %120, i8* %64
%121 = add i32 %116, %115
%122 = tail call i32 @fgetc(i32* %49)
%123 = load i32, i32* @EOF
%124 = icmp eq i32 %122, %123
br i1 %124, label %176, label %125
125: ; preds = %119
%126 = trunc i32 %122 to i8
store i8 %126, i8* %65
%127 = add i32 %122, %121
%128 = tail call i32 @fgetc(i32* %49)
%129 = load i32, i32* @EOF
%130 = icmp eq i32 %128, %129
br i1 %130, label %176, label %131
131: ; preds = %125
%132 = trunc i32 %128 to i8
store i8 %132, i8* %66
%133 = add i32 %128, %127
%134 = tail call i32 @fgetc(i32* %49)
%135 = load i32, i32* @EOF
%136 = icmp eq i32 %134, %135
br i1 %136, label %176, label %137
137: ; preds = %131
%138 = trunc i32 %134 to i8
store i8 %138, i8* %67
%139 = add i32 %134, %133
%140 = tail call i32 @fgetc(i32* %49)
%141 = load i32, i32* @EOF
%142 = icmp eq i32 %140, %141
br i1 %142, label %176, label %143
143: ; preds = %137
%144 = trunc i32 %140 to i8
store i8 %144, i8* %68
%145 = add i32 %140, %139
%146 = tail call i32 @fgetc(i32* %49)
%147 = load i32, i32* @EOF
%148 = icmp eq i32 %146, %147
br i1 %148, label %176, label %149
149: ; preds = %143
%150 = trunc i32 %146 to i8
store i8 %150, i8* %69
%151 = add i32 %146, %145
%152 = tail call i32 @fgetc(i32* %49)
%153 = load i32, i32* @EOF
%154 = icmp eq i32 %152, %153
br i1 %154, label %176, label %155
155: ; preds = %149
%156 = trunc i32 %152 to i8
store i8 %156, i8* %70
%157 = add i32 %152, %151
%158 = tail call i32 @fgetc(i32* %49)
%159 = load i32, i32* @EOF
%160 = icmp eq i32 %158, %159
br i1 %160, label %176, label %161
161: ; preds = %155
%162 = trunc i32 %158 to i8
store i8 %162, i8* %71
%163 = add i32 %158, %157
%164 = tail call i32 @fgetc(i32* %49)
%165 = load i32, i32* @EOF
%166 = icmp eq i32 %164, %165
br i1 %166, label %176, label %167
167: ; preds = %161
%168 = trunc i32 %164 to i8
store i8 %168, i8* %72
%169 = add i32 %164, %163
%170 = tail call i32 @fgetc(i32* %49)
%171 = load i32, i32* @EOF
%172 = icmp eq i32 %170, %171
br i1 %172, label %176, label %173
173: ; preds = %167
%174 = trunc i32 %170 to i8
store i8 %174, i8* %73
%175 = add i32 %170, %169
br label %176
176: ; preds = %167, %161, %155, %149, %143, %137, %131, %125, %119, %113, %107, %101, %95, %89, %84, %173
%177 = phi i32 [ %170, %173 ], [ %170, %167 ], [ %164, %161 ], [ %158, %155 ], [ %152, %149 ], [ %146, %143 ], [ %140, %137 ], [ %134, %131 ], [ %128, %125 ], [ %122, %119 ], [ %116, %113 ], [ %110, %107 ], [ %104, %101 ], [ %98, %95 ], [ %92, %89 ], [ %86, %84 ]
%178 = phi i32 [ 16, %173 ], [ 15, %167 ], [ 14, %161 ], [ 13, %155 ], [ 12, %149 ], [ 11, %143 ], [ 10, %137 ], [ 9, %131 ], [ 8, %125 ], [ 7, %119 ], [ 6, %113 ], [ 5, %107 ], [ 4, %101 ], [ 3, %95 ], [ 2, %89 ], [ 1, %84 ]
%179 = phi i32 [ %175, %173 ], [ %169, %167 ], [ %163, %161 ], [ %157, %155 ], [ %151, %149 ], [ %145, %143 ], [ %139, %137 ], [ %133, %131 ], [ %127, %125 ], [ %121, %119 ], [ %115, %113 ], [ %109, %107 ], [ %103, %101 ], [ %97, %95 ], [ %91, %89 ], [ %81, %84 ]
br i1 %75, label %180, label %184
180: ; preds = %176
%181 = call i8* @llvm.load.relative.i64(i8* bitcast ([3 x i32]* @reltable.main to i8*), i64 %78)
%182 = add nuw nsw i32 %178, %76
%183 = tail call i32 (i32*, i8*, i32, ...) @fprintf(i32* %54, i8* %181, i32 %182, i32 %80)
br label %184
184: ; preds = %176, %180
%185 = zext i32 %178 to i64
br label %186
186: ; preds = %184, %186
%187 = phi i64 [ 0, %184 ], [ %192, %186 ]
%188 = getelementptr inbounds [16 x i8], [16 x i8]* %4, i64 0, i64 %187
%189 = load i8, i8* %188
%190 = zext i8 %189 to i32
%191 = tail call i32 (i32*, i8*, i32, ...) @fprintf(i32* %54, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.15, i64 0, i64 0), i32 %190)
%192 = add nuw nsw i64 %187, 1
%193 = icmp eq i64 %192, %185
br i1 %193, label %194, label %186
194: ; preds = %186
switch i32 %30, label %227 [
i32 1, label %195
i32 2, label %203
i32 3, label %214
]
195: ; preds = %194
%196 = and i32 %80, 255
%197 = lshr i32 %80, 8
%198 = and i32 %197, 255
%199 = add i32 %179, %178
%200 = add i32 %199, 3
%201 = add i32 %200, %196
%202 = add i32 %201, %198
br label %227
203: ; preds = %194
%204 = and i32 %80, 255
%205 = lshr i32 %80, 8
%206 = and i32 %205, 255
%207 = lshr i32 %80, 16
%208 = and i32 %207, 255
%209 = add i32 %179, %178
%210 = add i32 %209, 4
%211 = add i32 %210, %204
%212 = add i32 %211, %206
%213 = add i32 %212, %208
br label %227
214: ; preds = %194
%215 = and i32 %80, 255
%216 = lshr i32 %80, 8
%217 = and i32 %216, 255
%218 = lshr i32 %80, 16
%219 = and i32 %218, 255
%220 = lshr i32 %80, 24
%221 = add i32 %179, %178
%222 = add i32 %221, 5
%223 = add i32 %222, %215
%224 = add i32 %223, %220
%225 = add i32 %224, %217
%226 = add i32 %225, %219
br label %227
227: ; preds = %194, %214, %203, %195
%228 = phi i32 [ %179, %194 ], [ %226, %214 ], [ %213, %203 ], [ %202, %195 ]
%229 = and i32 %228, 255
%230 = xor i32 %229, 255
%231 = tail call i32 (i32*, i8*, i32, ...) @fprintf(i32* %54, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.16, i64 0, i64 0), i32 %230)
%232 = add i32 %178, %80
%233 = load i32, i32* @EOF
%234 = icmp eq i32 %177, %233
br i1 %234, label %235, label %79
235: ; preds = %79, %227
%236 = phi i32 [ %228, %227 ], [ 0, %79 ]
switch i32 %30, label %266 [
i32 1, label %237
i32 2, label %244
i32 3, label %254
]
237: ; preds = %235
%238 = tail call i32 (i32*, i8*, i32, ...) @fprintf(i32* %54, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.17, i64 0, i64 0), i32 %37)
%239 = and i32 %37, 255
%240 = add nuw nsw i32 %239, 3
%241 = lshr i32 %37, 8
%242 = and i32 %241, 255
%243 = add nuw nsw i32 %240, %242
br label %266
244: ; preds = %235
%245 = tail call i32 (i32*, i8*, i32, ...) @fprintf(i32* %54, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.18, i64 0, i64 0), i32 %37)
%246 = and i32 %37, 255
%247 = add nuw nsw i32 %246, 4
%248 = lshr i32 %37, 8
%249 = and i32 %248, 255
%250 = add nuw nsw i32 %247, %249
%251 = lshr i32 %37, 16
%252 = and i32 %251, 255
%253 = add nuw nsw i32 %250, %252
br label %266
254: ; preds = %235
%255 = tail call i32 (i32*, i8*, i32, ...) @fprintf(i32* %54, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.19, i64 0, i64 0), i32 %37)
%256 = and i32 %37, 255
%257 = add nuw nsw i32 %256, 5
%258 = lshr i32 %37, 8
%259 = and i32 %258, 255
%260 = lshr i32 %37, 16
%261 = and i32 %260, 255
%262 = lshr i32 %37, 24
%263 = add nuw nsw i32 %257, %262
%264 = add nuw nsw i32 %263, %259
%265 = add nuw nsw i32 %264, %261
br label %266
266: ; preds = %235, %254, %244, %237
%267 = phi i32 [ %236, %235 ], [ %265, %254 ], [ %253, %244 ], [ %243, %237 ]
%268 = and i32 %267, 255
%269 = xor i32 %268, 255
%270 = tail call i32 (i32*, i8*, i32, ...) @fprintf(i32* %54, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.16, i64 0, i64 0), i32 %269)
%271 = tail call i32 @fclose(i32* %49)
%272 = tail call i32 @fclose(i32* %54)
ret i32 0
}