#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 u_short;

/* Variables and functions */
int /*<<< orphan*/ O_RDONLY;
int /*<<< orphan*/ STDOUT_FILENO;
int /*<<< orphan*/ Usage();
int atoi(char *);
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
unsigned char *malloc(int);
int /*<<< orphan*/ memcpy(int *, unsigned char *, int);
int /*<<< orphan*/ memset(unsigned char *, int, int);
int ntohs(int);
int open(char *, int /*<<< orphan*/);
int read(int, unsigned char *, int);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ write(int /*<<< orphan*/, unsigned char *, int);
int main(int argc, char *argv[]) {
  unsigned int i;
  u_short pid;
  int input_read;
  int buffer_size;
  int fd_ts;
  unsigned char *packet_buffer;
  unsigned char *current_packet;
  unsigned char adaptation_field;
  int pid_table[8192];
  char *pid_table_filename[8192];
  unsigned char pid_cc_table[8192];
  unsigned char previous_cc_table[8192];
  int byte_read;
  for (i = 0; i < 8192; i++) {
    pid_table[i] = -1;
    pid_table_filename[i] = 0;
  }
  memset(pid_cc_table, 0x10, 8192);
  memset(previous_cc_table, 0x10, 8192);
  if (argc <= 2) {
    Usage();
    return 2;
  }
  fd_ts = open(argv[1], O_RDONLY);
  if (fd_ts < 0) {
    fprintf(stderr, "Can't find file %s\n", argv[1]);
    return 2;
  }
  buffer_size = 0;
  i = 2;
  while (i < argc) {
    if (argv[i][0] == 'b' && argv[i][1] == ':') {
      buffer_size = atoi(&(argv[i][2]));
      i++;
    } else {
      pid = atoi(&(argv[i][1]));
      if (pid < 8192) {
        fprintf(stderr, "Modify pid %d with %s\n", pid, argv[i + 1]);
        pid_table[pid] = open(argv[i + 1], O_RDONLY);
        pid_table_filename[pid] = argv[i + 1];
        if (pid_table[pid] < 0) {
          fprintf(stderr, "Can't find file %s\n", argv[i + 1]);
          return 2;
        }
      }
      i += 2;
    }
  }
  if (buffer_size <= 0)
    buffer_size = 1;
  buffer_size *= 188;
  packet_buffer = malloc(buffer_size);
  if (packet_buffer == NULL) {
    fprintf(stderr, "Out of memory!\n");
    return 2;
  }
  input_read = 1;
  while (input_read) {
    input_read = read(fd_ts, packet_buffer, buffer_size);
    for (i = 0; i < buffer_size && input_read; i += 188) {
      current_packet = packet_buffer + i;
      memcpy(&pid, current_packet + 1, 2);
      pid = ntohs(pid);
      pid = pid & 0x1fff;
      if (pid < 8192 && pid_table[pid] != -1) {
        byte_read = read(pid_table[pid], current_packet, 188);
        if (byte_read <= 0) {
          close(pid_table[pid]);
          pid_table[pid] = open(pid_table_filename[pid], O_RDONLY);
          byte_read = read(pid_table[pid], current_packet, 188);
        }
        if (pid_cc_table[pid] == 0x10) {
          pid_cc_table[pid] = current_packet[3] & 0x0f;
          previous_cc_table[pid] = current_packet[3] & 0x0f;
        } else {
          adaptation_field = (current_packet[3] & 0x30) >> 4;
          if (adaptation_field == 0x0 || adaptation_field == 0x2) {
            current_packet[3] =
                (pid_cc_table[pid] | (current_packet[3] & 0xf0));
          } else if ((adaptation_field == 0x1) &&
                     ((current_packet[3] & 0x0f) == previous_cc_table[pid])) {
            current_packet[3] =
                (pid_cc_table[pid] | (current_packet[3] & 0xf0));
            previous_cc_table[pid] = 0x10;
          } else if ((adaptation_field == 0x3) &&
                     ((current_packet[3] & 0x0f) == previous_cc_table[pid])) {
            current_packet[3] =
                (pid_cc_table[pid] | (current_packet[3] & 0xf0));
            previous_cc_table[pid] = 0x10;
          } else {
            previous_cc_table[pid] = current_packet[3] & 0x0f;
            pid_cc_table[pid] = (pid_cc_table[pid] + 1) % 0x10;
            current_packet[3] =
                (pid_cc_table[pid] | (current_packet[3] & 0xf0));
          }
        }
      }
    }
    if (input_read) {
      write(STDOUT_FILENO, packet_buffer, buffer_size);
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1c050,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0x2000,-0x14(%rbp)
jae    1208 <main+0x58>
mov    -0x14(%rbp),%eax
movl   $0xffffffff,-0x8040(%rbp,%rax,4)
ff ff ff ff
mov    -0x14(%rbp),%eax
movq   $0x0,-0x18040(%rbp,%rax,8)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11d0 <main+0x20>
lea    -0x1a040(%rbp),%rdi
mov    $0x10,%esi
mov    $0x2000,%edx
call   1040 <memset@plt>
lea    -0x1c040(%rbp),%rdi
mov    $0x10,%esi
mov    $0x2000,%edx
call   1040 <memset@plt>
cmpl   $0x2,-0x8(%rbp)
jg     1251 <main+0xa1>
mov    $0x0,%al
call   1070 <Usage@plt>
movl   $0x2,-0x4(%rbp)
jmp    17a0 <main+0x5f0>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    0x2d80(%rip),%rax
mov    (%rax),%esi
call   10c0 <open@plt>
mov    %eax,-0x24(%rbp)
cmpl   $0x0,-0x24(%rbp)
jge    129f <main+0xef>
mov    0x2d55(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdx
lea    0xd74(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
movl   $0x2,-0x4(%rbp)
jmp    17a0 <main+0x5f0>
movl   $0x0,-0x20(%rbp)
movl   $0x2,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x8(%rbp),%eax
jae    13fa <main+0x24a>
mov    -0x10(%rbp),%rax
mov    -0x14(%rbp),%ecx
mov    (%rax,%rcx,8),%rax
movsbl (%rax),%eax
cmp    $0x62,%eax
jne    130d <main+0x15d>
mov    -0x10(%rbp),%rax
mov    -0x14(%rbp),%ecx
mov    (%rax,%rcx,8),%rax
movsbl 0x1(%rax),%eax
cmp    $0x3a,%eax
jne    130d <main+0x15d>
mov    -0x10(%rbp),%rax
mov    -0x14(%rbp),%ecx
mov    (%rax,%rcx,8),%rdi
add    $0x2,%rdi
call   10d0 <atoi@plt>
mov    %eax,-0x20(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    13f5 <main+0x245>
mov    -0x10(%rbp),%rax
mov    -0x14(%rbp),%ecx
mov    (%rax,%rcx,8),%rdi
add    $0x1,%rdi
call   10d0 <atoi@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x2000,-0x18(%rbp)
jge    13ec <main+0x23c>
mov    0x2c98(%rip),%rax
mov    (%rax),%edi
mov    -0x18(%rbp),%edx
mov    -0x10(%rbp),%rax
mov    -0x14(%rbp),%ecx
add    $0x1,%ecx
mov    %ecx,%ecx
mov    (%rax,%rcx,8),%rcx
lea    0xcc0(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    -0x10(%rbp),%rax
mov    -0x14(%rbp),%ecx
add    $0x1,%ecx
mov    %ecx,%ecx
mov    (%rax,%rcx,8),%rdi
mov    0x2c6e(%rip),%rax
mov    (%rax),%esi
call   10c0 <open@plt>
mov    %eax,%ecx
movslq -0x18(%rbp),%rax
mov    %ecx,-0x8040(%rbp,%rax,4)
mov    -0x10(%rbp),%rax
mov    -0x14(%rbp),%ecx
add    $0x1,%ecx
mov    %ecx,%ecx
mov    (%rax,%rcx,8),%rcx
movslq -0x18(%rbp),%rax
mov    %rcx,-0x18040(%rbp,%rax,8)
ff
movslq -0x18(%rbp),%rax
cmpl   $0x0,-0x8040(%rbp,%rax,4)
jge    13e7 <main+0x237>
mov    0x2c15(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    -0x14(%rbp),%ecx
add    $0x1,%ecx
mov    %ecx,%ecx
mov    (%rax,%rcx,8),%rdx
lea    0xc2c(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
movl   $0x2,-0x4(%rbp)
jmp    17a0 <main+0x5f0>
jmp    13ec <main+0x23c>
mov    -0x14(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0x14(%rbp)
jmp    12ad <main+0xfd>
cmpl   $0x0,-0x20(%rbp)
jg     140b <main+0x25b>
movl   $0x1,-0x20(%rbp)
imul   $0xbc,-0x20(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0x20(%rbp),%edi
call   10a0 <malloc@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
jne    144f <main+0x29f>
mov    0x2b9d(%rip),%rax
mov    (%rax),%edi
lea    0xbef(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
movl   $0x2,-0x4(%rbp)
jmp    17a0 <main+0x5f0>
movl   $0x1,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
je     1799 <main+0x5e9>
mov    -0x24(%rbp),%edi
mov    -0x30(%rbp),%rsi
mov    -0x20(%rbp),%edx
call   1060 <read@plt>
mov    %eax,-0x1c(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%ecx
xor    %eax,%eax
cmp    -0x20(%rbp),%ecx
mov    %al,-0x1c045(%rbp)
jae    149a <main+0x2ea>
cmpl   $0x0,-0x1c(%rbp)
setne  %al
mov    %al,-0x1c045(%rbp)
mov    -0x1c045(%rbp),%al
test   $0x1,%al
jne    14ad <main+0x2fd>
jmp    1775 <main+0x5c5>
mov    -0x30(%rbp),%rax
mov    -0x14(%rbp),%ecx
add    %rcx,%rax
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rsi
add    $0x1,%rsi
lea    -0x18(%rbp),%rdi
mov    $0x2,%edx
call   1090 <memcpy@plt>
mov    -0x18(%rbp),%edi
call   10b0 <ntohs@plt>
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%eax
and    $0x1fff,%eax
mov    %eax,-0x18(%rbp)
cmpl   $0x2000,-0x18(%rbp)
jge    1760 <main+0x5b0>
movslq -0x18(%rbp),%rax
cmpl   $0xffffffff,-0x8040(%rbp,%rax,4)
ff
je     1760 <main+0x5b0>
movslq -0x18(%rbp),%rax
mov    -0x8040(%rbp,%rax,4),%edi
mov    -0x38(%rbp),%rsi
mov    $0xbc,%edx
call   1060 <read@plt>
mov    %eax,-0x1c044(%rbp)
cmpl   $0x0,-0x1c044(%rbp)
jg     1588 <main+0x3d8>
movslq -0x18(%rbp),%rax
mov    -0x8040(%rbp,%rax,4),%edi
call   1050 <close@plt>
movslq -0x18(%rbp),%rax
mov    -0x18040(%rbp,%rax,8),%rdi
ff
mov    0x2a8b(%rip),%rax
mov    (%rax),%esi
call   10c0 <open@plt>
mov    %eax,%ecx
movslq -0x18(%rbp),%rax
mov    %ecx,-0x8040(%rbp,%rax,4)
movslq -0x18(%rbp),%rax
mov    -0x8040(%rbp,%rax,4),%edi
mov    -0x38(%rbp),%rsi
mov    $0xbc,%edx
call   1060 <read@plt>
mov    %eax,-0x1c044(%rbp)
movslq -0x18(%rbp),%rax
movzbl -0x1a040(%rbp,%rax,1),%eax
ff
cmp    $0x10,%eax
jne    15d2 <main+0x422>
mov    -0x38(%rbp),%rax
movzbl 0x3(%rax),%eax
and    $0xf,%eax
mov    %al,%cl
movslq -0x18(%rbp),%rax
mov    %cl,-0x1a040(%rbp,%rax,1)
mov    -0x38(%rbp),%rax
movzbl 0x3(%rax),%eax
and    $0xf,%eax
mov    %al,%cl
movslq -0x18(%rbp),%rax
mov    %cl,-0x1c040(%rbp,%rax,1)
jmp    175b <main+0x5ab>
mov    -0x38(%rbp),%rax
movzbl 0x3(%rax),%eax
and    $0x30,%eax
sar    $0x4,%eax
mov    %al,-0x39(%rbp)
movzbl -0x39(%rbp),%eax
cmp    $0x0,%eax
je     15fd <main+0x44d>
movzbl -0x39(%rbp),%eax
cmp    $0x2,%eax
jne    1627 <main+0x477>
movslq -0x18(%rbp),%rax
movzbl -0x1a040(%rbp,%rax,1),%eax
ff
mov    -0x38(%rbp),%rcx
movzbl 0x3(%rcx),%ecx
and    $0xf0,%ecx
or     %ecx,%eax
mov    %al,%cl
mov    -0x38(%rbp),%rax
mov    %cl,0x3(%rax)
jmp    1756 <main+0x5a6>
movzbl -0x39(%rbp),%eax
cmp    $0x1,%eax
jne    1689 <main+0x4d9>
mov    -0x38(%rbp),%rax
movzbl 0x3(%rax),%eax
and    $0xf,%eax
movslq -0x18(%rbp),%rcx
movzbl -0x1c040(%rbp,%rcx,1),%ecx
ff
cmp    %ecx,%eax
jne    1689 <main+0x4d9>
movslq -0x18(%rbp),%rax
movzbl -0x1a040(%rbp,%rax,1),%eax
ff
mov    -0x38(%rbp),%rcx
movzbl 0x3(%rcx),%ecx
and    $0xf0,%ecx
or     %ecx,%eax
mov    %al,%cl
mov    -0x38(%rbp),%rax
mov    %cl,0x3(%rax)
movslq -0x18(%rbp),%rax
movb   $0x10,-0x1c040(%rbp,%rax,1)
10
jmp    1751 <main+0x5a1>
movzbl -0x39(%rbp),%eax
cmp    $0x3,%eax
jne    16eb <main+0x53b>
mov    -0x38(%rbp),%rax
movzbl 0x3(%rax),%eax
and    $0xf,%eax
movslq -0x18(%rbp),%rcx
movzbl -0x1c040(%rbp,%rcx,1),%ecx
ff
cmp    %ecx,%eax
jne    16eb <main+0x53b>
movslq -0x18(%rbp),%rax
movzbl -0x1a040(%rbp,%rax,1),%eax
ff
mov    -0x38(%rbp),%rcx
movzbl 0x3(%rcx),%ecx
and    $0xf0,%ecx
or     %ecx,%eax
mov    %al,%cl
mov    -0x38(%rbp),%rax
mov    %cl,0x3(%rax)
movslq -0x18(%rbp),%rax
movb   $0x10,-0x1c040(%rbp,%rax,1)
10
jmp    174c <main+0x59c>
mov    -0x38(%rbp),%rax
movzbl 0x3(%rax),%eax
and    $0xf,%eax
mov    %al,%cl
movslq -0x18(%rbp),%rax
mov    %cl,-0x1c040(%rbp,%rax,1)
movslq -0x18(%rbp),%rax
movzbl -0x1a040(%rbp,%rax,1),%eax
ff
add    $0x1,%eax
mov    $0x10,%ecx
cltd
idiv   %ecx
mov    %dl,%cl
movslq -0x18(%rbp),%rax
mov    %cl,-0x1a040(%rbp,%rax,1)
movslq -0x18(%rbp),%rax
movzbl -0x1a040(%rbp,%rax,1),%eax
ff
mov    -0x38(%rbp),%rcx
movzbl 0x3(%rcx),%ecx
and    $0xf0,%ecx
or     %ecx,%eax
mov    %al,%cl
mov    -0x38(%rbp),%rax
mov    %cl,0x3(%rax)
jmp    1751 <main+0x5a1>
jmp    1756 <main+0x5a6>
jmp    175b <main+0x5ab>
jmp    1760 <main+0x5b0>
jmp    1765 <main+0x5b5>
mov    -0x14(%rbp),%eax
add    $0xbc,%eax
mov    %eax,-0x14(%rbp)
jmp    1479 <main+0x2c9>
cmpl   $0x0,-0x1c(%rbp)
je     1794 <main+0x5e4>
mov    0x286a(%rip),%rax
mov    (%rax),%edi
mov    -0x30(%rbp),%rsi
mov    -0x20(%rbp),%edx
call   1030 <write@plt>
jmp    1456 <main+0x2a6>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x1c050,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x1c018,%rsp
mov    %rsi,%rbx
mov    %edi,%r13d
lea    0x4010(%rsp),%rdi
mov    $0x8000,%edx
mov    $0xff,%esi
call   1040 <memset@plt>
lea    0xc010(%rsp),%rdi
mov    $0x10000,%edx
xor    %esi,%esi
call   1040 <memset@plt>
lea    0x2010(%rsp),%rdi
mov    $0x10,%esi
mov    $0x2000,%edx
call   1040 <memset@plt>
lea    0x10(%rsp),%rdi
mov    $0x10,%esi
mov    $0x2000,%edx
call   1040 <memset@plt>
cmp    $0x2,%r13d
jg     1234 <main+0x84>
xor    %eax,%eax
call   1070 <Usage@plt>
mov    $0x2,%ebp
jmp    151b <main+0x36b>
mov    0x8(%rbx),%rdi
mov    0x2da1(%rip),%rax
mov    (%rax),%esi
call   10c0 <open@plt>
mov    %eax,0xc(%rsp)
test   %eax,%eax
js     14d9 <main+0x329>
mov    $0x2,%r14d
movl   $0x0,0x8(%rsp)
jmp    128f <main+0xdf>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
add    $0x2,%rdi
call   10d0 <atoi@plt>
mov    %eax,0x8(%rsp)
mov    $0x1,%r15d
add    %r15d,%r14d
cmp    %r13d,%r14d
jae    131b <main+0x16b>
mov    %r14d,%r12d
mov    (%rbx,%r12,8),%rdi
cmpb   $0x62,(%rdi)
jne    12a1 <main+0xf1>
cmpb   $0x3a,0x1(%rdi)
je     1270 <main+0xc0>
add    $0x1,%rdi
call   10d0 <atoi@plt>
mov    %eax,0x4(%rsp)
mov    $0x2,%r15d
cmp    $0x1fff,%eax
jg     1283 <main+0xd3>
mov    %eax,%ebp
mov    0x2d0c(%rip),%rax
mov    (%rax),%edi
mov    0x8(%rbx,%r12,8),%rcx
lea    0xd42(%rip),%rsi
mov    %ebp,%edx
xor    %eax,%eax
call   1080 <fprintf@plt>
mov    0x8(%rbx,%r12,8),%rdi
mov    0x2cf9(%rip),%rax
mov    (%rax),%esi
call   10c0 <open@plt>
movslq %ebp,%rcx
mov    %eax,0x4010(%rsp,%rcx,4)
mov    0x8(%rbx,%r12,8),%rdx
mov    %rdx,0xc010(%rsp,%rcx,8)
test   %eax,%eax
jns    1283 <main+0xd3>
mov    0x2cbc(%rip),%rax
mov    (%rax),%edi
jmp    14e6 <main+0x336>
mov    0x8(%rsp),%ecx
test   %ecx,%ecx
mov    $0x1,%eax
cmovg  %ecx,%eax
imul   $0xbc,%eax,%r12d
mov    %r12d,%edi
call   10a0 <malloc@plt>
test   %rax,%rax
je     14fb <main+0x34b>
mov    %rax,%r13
mov    0xc(%rsp),%edi
mov    %rax,%rsi
mov    %r12d,%edx
call   1060 <read@plt>
test   %eax,%eax
sete   %al
je     1519 <main+0x369>
lea    0x4(%rsp),%r15
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %al,0x8(%rsp)
xor    %r14d,%r14d
jmp    139d <main+0x1ed>
nopl   0x0(%rax)
and    $0xf,%al
mov    %al,0x2010(%rsp,%rcx,1)
mov    %al,0x10(%rsp,%rcx,1)
add    $0xbc,%r14d
cmp    %r12d,%r14d
jae    14a0 <main+0x2f0>
mov    %r14d,%ebp
lea    0x1(,%rbp,1),%rsi
add    %r13,%rsi
mov    %r15,%rdi
mov    $0x2,%edx
call   1090 <memcpy@plt>
mov    0x4(%rsp),%edi
call   10b0 <ntohs@plt>
and    $0x1fff,%eax
mov    %eax,0x4(%rsp)
mov    0x4010(%rsp,%rax,4),%edi
cmp    $0xffffffff,%edi
je     138d <main+0x1dd>
add    %r13,%rbp
mov    %rbp,%rsi
mov    $0xbc,%edx
call   1060 <read@plt>
test   %eax,%eax
jg     1431 <main+0x281>
movslq 0x4(%rsp),%rax
mov    0x4010(%rsp,%rax,4),%edi
call   1050 <close@plt>
movslq 0x4(%rsp),%rax
mov    0xc010(%rsp,%rax,8),%rdi
mov    0x2bd1(%rip),%rax
mov    (%rax),%esi
call   10c0 <open@plt>
movslq 0x4(%rsp),%rcx
mov    %eax,0x4010(%rsp,%rcx,4)
mov    %eax,%edi
mov    %rbp,%rsi
mov    $0xbc,%edx
call   1060 <read@plt>
movslq 0x4(%rsp),%rcx
movzbl 0x2010(%rsp,%rcx,1),%edx
movzbl 0x3(%rbp),%eax
cmp    $0x10,%dl
je     1380 <main+0x1d0>
test   $0x10,%al
je     1493 <main+0x2e3>
mov    %eax,%ebx
shr    $0x4,%bl
and    $0x3,%bl
cmp    $0x1,%bl
je     1461 <main+0x2b1>
cmp    $0x3,%bl
jne    147d <main+0x2cd>
mov    %eax,%ebx
and    $0xf,%bl
cmp    0x10(%rsp,%rcx,1),%bl
jne    1482 <main+0x2d2>
and    $0xf0,%al
or     %dl,%al
mov    %al,0x3(%rbp)
movb   $0x10,0x10(%rsp,%rcx,1)
jmp    138d <main+0x1dd>
mov    %eax,%ebx
and    $0xf,%bl
mov    %bl,0x10(%rsp,%rcx,1)
add    $0x1,%dl
and    $0xf,%dl
mov    %dl,0x2010(%rsp,%rcx,1)
and    $0xf0,%al
or     %dl,%al
mov    %al,0x3(%rbp)
jmp    138d <main+0x1dd>
nop
xor    %ebp,%ebp
testb  $0x1,0x8(%rsp)
jne    151b <main+0x36b>
mov    0x2b40(%rip),%rax
mov    (%rax),%edi
mov    %r13,%rsi
mov    %r12d,%edx
call   1030 <write@plt>
mov    0xc(%rsp),%edi
mov    %r13,%rsi
mov    %r12d,%edx
call   1060 <read@plt>
test   %eax,%eax
sete   %al
jne    1370 <main+0x1c0>
jmp    151b <main+0x36b>
mov    0x2af0(%rip),%rax
mov    (%rax),%edi
mov    0x8(%rbx),%rdx
lea    0xb13(%rip),%rsi
xor    %eax,%eax
call   1080 <fprintf@plt>
mov    $0x2,%ebp
jmp    151b <main+0x36b>
mov    0x2ace(%rip),%rax
mov    (%rax),%edi
lea    0xb20(%rip),%rsi
xor    %eax,%eax
call   1080 <fprintf@plt>
mov    $0x2,%ebp
jmp    151b <main+0x36b>
xor    %ebp,%ebp
mov    %ebp,%eax
add    $0x1c018,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@O_RDONLY = global i32 0
@stderr = global i32 0
@.str = [20 x i8] c"Can't find file %s\0A\00"
@.str.1 = [23 x i8] c"Modify pid %d with %s\0A\00"
@.str.2 = [16 x i8] c"Out of memory!\0A\00"
@STDOUT_FILENO = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i8*
%12 = alloca i8*
%13 = alloca i8
%14 = alloca [8192 x i32]
%15 = alloca [8192 x i8*]
%16 = alloca [8192 x i8]
%17 = alloca [8192 x i8]
%18 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %6
br label %19
19: ; preds = %29, %2
%20 = load i32, i32* %6
%21 = icmp ult i32 %20, 8192
br i1 %21, label %22, label %32
22: ; preds = %19
%23 = load i32, i32* %6
%24 = zext i32 %23 to i64
%25 = getelementptr inbounds [8192 x i32], [8192 x i32]* %14, i64 0, i64 %24
store i32 -1, i32* %25
%26 = load i32, i32* %6
%27 = zext i32 %26 to i64
%28 = getelementptr inbounds [8192 x i8*], [8192 x i8*]* %15, i64 0, i64 %27
store i8* null, i8** %28
br label %29
29: ; preds = %22
%30 = load i32, i32* %6
%31 = add i32 %30, 1
store i32 %31, i32* %6
br label %19
32: ; preds = %19
%33 = getelementptr inbounds [8192 x i8], [8192 x i8]* %16, i64 0, i64 0
%34 = call i32 @memset(i8* %33, i32 16, i32 8192)
%35 = getelementptr inbounds [8192 x i8], [8192 x i8]* %17, i64 0, i64 0
%36 = call i32 @memset(i8* %35, i32 16, i32 8192)
%37 = load i32, i32* %4
%38 = icmp sle i32 %37, 2
br i1 %38, label %39, label %41
39: ; preds = %32
%40 = call i32 (...) @Usage()
store i32 2, i32* %3
br label %408
41: ; preds = %32
%42 = load i8**, i8*** %5
%43 = getelementptr inbounds i8*, i8** %42, i64 1
%44 = load i8*, i8** %43
%45 = load i32, i32* @O_RDONLY
%46 = call i32 @open(i8* %44, i32 %45)
store i32 %46, i32* %10
%47 = load i32, i32* %10
%48 = icmp slt i32 %47, 0
br i1 %48, label %49, label %55
49: ; preds = %41
%50 = load i32, i32* @stderr
%51 = load i8**, i8*** %5
%52 = getelementptr inbounds i8*, i8** %51, i64 1
%53 = load i8*, i8** %52
%54 = call i32 (i32, i8*, ...) @fprintf(i32 %50, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i8* %53)
store i32 2, i32* %3
br label %408
55: ; preds = %41
store i32 0, i32* %9
store i32 2, i32* %6
br label %56
56: ; preds = %148, %55
%57 = load i32, i32* %6
%58 = load i32, i32* %4
%59 = icmp ult i32 %57, %58
br i1 %59, label %60, label %149
60: ; preds = %56
%61 = load i8**, i8*** %5
%62 = load i32, i32* %6
%63 = zext i32 %62 to i64
%64 = getelementptr inbounds i8*, i8** %61, i64 %63
%65 = load i8*, i8** %64
%66 = getelementptr inbounds i8, i8* %65, i64 0
%67 = load i8, i8* %66
%68 = sext i8 %67 to i32
%69 = icmp eq i32 %68, 98
br i1 %69, label %70, label %90
70: ; preds = %60
%71 = load i8**, i8*** %5
%72 = load i32, i32* %6
%73 = zext i32 %72 to i64
%74 = getelementptr inbounds i8*, i8** %71, i64 %73
%75 = load i8*, i8** %74
%76 = getelementptr inbounds i8, i8* %75, i64 1
%77 = load i8, i8* %76
%78 = sext i8 %77 to i32
%79 = icmp eq i32 %78, 58
br i1 %79, label %80, label %90
80: ; preds = %70
%81 = load i8**, i8*** %5
%82 = load i32, i32* %6
%83 = zext i32 %82 to i64
%84 = getelementptr inbounds i8*, i8** %81, i64 %83
%85 = load i8*, i8** %84
%86 = getelementptr inbounds i8, i8* %85, i64 2
%87 = call i32 @atoi(i8* %86)
store i32 %87, i32* %9
%88 = load i32, i32* %6
%89 = add i32 %88, 1
store i32 %89, i32* %6
br label %148
90: ; preds = %70, %60
%91 = load i8**, i8*** %5
%92 = load i32, i32* %6
%93 = zext i32 %92 to i64
%94 = getelementptr inbounds i8*, i8** %91, i64 %93
%95 = load i8*, i8** %94
%96 = getelementptr inbounds i8, i8* %95, i64 1
%97 = call i32 @atoi(i8* %96)
store i32 %97, i32* %7
%98 = load i32, i32* %7
%99 = icmp slt i32 %98, 8192
br i1 %99, label %100, label %145
100: ; preds = %90
%101 = load i32, i32* @stderr
%102 = load i32, i32* %7
%103 = load i8**, i8*** %5
%104 = load i32, i32* %6
%105 = add i32 %104, 1
%106 = zext i32 %105 to i64
%107 = getelementptr inbounds i8*, i8** %103, i64 %106
%108 = load i8*, i8** %107
%109 = call i32 (i32, i8*, ...) @fprintf(i32 %101, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i32 %102, i8* %108)
%110 = load i8**, i8*** %5
%111 = load i32, i32* %6
%112 = add i32 %111, 1
%113 = zext i32 %112 to i64
%114 = getelementptr inbounds i8*, i8** %110, i64 %113
%115 = load i8*, i8** %114
%116 = load i32, i32* @O_RDONLY
%117 = call i32 @open(i8* %115, i32 %116)
%118 = load i32, i32* %7
%119 = sext i32 %118 to i64
%120 = getelementptr inbounds [8192 x i32], [8192 x i32]* %14, i64 0, i64 %119
store i32 %117, i32* %120
%121 = load i8**, i8*** %5
%122 = load i32, i32* %6
%123 = add i32 %122, 1
%124 = zext i32 %123 to i64
%125 = getelementptr inbounds i8*, i8** %121, i64 %124
%126 = load i8*, i8** %125
%127 = load i32, i32* %7
%128 = sext i32 %127 to i64
%129 = getelementptr inbounds [8192 x i8*], [8192 x i8*]* %15, i64 0, i64 %128
store i8* %126, i8** %129
%130 = load i32, i32* %7
%131 = sext i32 %130 to i64
%132 = getelementptr inbounds [8192 x i32], [8192 x i32]* %14, i64 0, i64 %131
%133 = load i32, i32* %132
%134 = icmp slt i32 %133, 0
br i1 %134, label %135, label %144
135: ; preds = %100
%136 = load i32, i32* @stderr
%137 = load i8**, i8*** %5
%138 = load i32, i32* %6
%139 = add i32 %138, 1
%140 = zext i32 %139 to i64
%141 = getelementptr inbounds i8*, i8** %137, i64 %140
%142 = load i8*, i8** %141
%143 = call i32 (i32, i8*, ...) @fprintf(i32 %136, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i8* %142)
store i32 2, i32* %3
br label %408
144: ; preds = %100
br label %145
145: ; preds = %144, %90
%146 = load i32, i32* %6
%147 = add i32 %146, 2
store i32 %147, i32* %6
br label %148
148: ; preds = %145, %80
br label %56
149: ; preds = %56
%150 = load i32, i32* %9
%151 = icmp sle i32 %150, 0
br i1 %151, label %152, label %153
152: ; preds = %149
store i32 1, i32* %9
br label %153
153: ; preds = %152, %149
%154 = load i32, i32* %9
%155 = mul nsw i32 %154, 188
store i32 %155, i32* %9
%156 = load i32, i32* %9
%157 = call i8* @malloc(i32 %156)
store i8* %157, i8** %11
%158 = load i8*, i8** %11
%159 = icmp eq i8* %158, null
br i1 %159, label %160, label %163
160: ; preds = %153
%161 = load i32, i32* @stderr
%162 = call i32 (i32, i8*, ...) @fprintf(i32 %161, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0))
store i32 2, i32* %3
br label %408
163: ; preds = %153
store i32 1, i32* %8
br label %164
164: ; preds = %406, %163
%165 = load i32, i32* %8
%166 = icmp ne i32 %165, 0
br i1 %166, label %167, label %407
167: ; preds = %164
%168 = load i32, i32* %10
%169 = load i8*, i8** %11
%170 = load i32, i32* %9
%171 = call i32 @read(i32 %168, i8* %169, i32 %170)
store i32 %171, i32* %8
store i32 0, i32* %6
br label %172
172: ; preds = %395, %167
%173 = load i32, i32* %6
%174 = load i32, i32* %9
%175 = icmp ult i32 %173, %174
br i1 %175, label %176, label %179
176: ; preds = %172
%177 = load i32, i32* %8
%178 = icmp ne i32 %177, 0
br label %179
179: ; preds = %176, %172
%180 = phi i1 [ false, %172 ], [ %178, %176 ]
br i1 %180, label %181, label %398
181: ; preds = %179
%182 = load i8*, i8** %11
%183 = load i32, i32* %6
%184 = zext i32 %183 to i64
%185 = getelementptr inbounds i8, i8* %182, i64 %184
store i8* %185, i8** %12
%186 = load i8*, i8** %12
%187 = getelementptr inbounds i8, i8* %186, i64 1
%188 = call i32 @memcpy(i32* %7, i8* %187, i32 2)
%189 = load i32, i32* %7
%190 = call i32 @ntohs(i32 %189)
store i32 %190, i32* %7
%191 = load i32, i32* %7
%192 = and i32 %191, 8191
store i32 %192, i32* %7
%193 = load i32, i32* %7
%194 = icmp slt i32 %193, 8192
br i1 %194, label %195, label %394
195: ; preds = %181
%196 = load i32, i32* %7
%197 = sext i32 %196 to i64
%198 = getelementptr inbounds [8192 x i32], [8192 x i32]* %14, i64 0, i64 %197
%199 = load i32, i32* %198
%200 = icmp ne i32 %199, -1
br i1 %200, label %201, label %394
201: ; preds = %195
%202 = load i32, i32* %7
%203 = sext i32 %202 to i64
%204 = getelementptr inbounds [8192 x i32], [8192 x i32]* %14, i64 0, i64 %203
%205 = load i32, i32* %204
%206 = load i8*, i8** %12
%207 = call i32 @read(i32 %205, i8* %206, i32 188)
store i32 %207, i32* %18
%208 = load i32, i32* %18
%209 = icmp sle i32 %208, 0
br i1 %209, label %210, label %231
210: ; preds = %201
%211 = load i32, i32* %7
%212 = sext i32 %211 to i64
%213 = getelementptr inbounds [8192 x i32], [8192 x i32]* %14, i64 0, i64 %212
%214 = load i32, i32* %213
%215 = call i32 @close(i32 %214)
%216 = load i32, i32* %7
%217 = sext i32 %216 to i64
%218 = getelementptr inbounds [8192 x i8*], [8192 x i8*]* %15, i64 0, i64 %217
%219 = load i8*, i8** %218
%220 = load i32, i32* @O_RDONLY
%221 = call i32 @open(i8* %219, i32 %220)
%222 = load i32, i32* %7
%223 = sext i32 %222 to i64
%224 = getelementptr inbounds [8192 x i32], [8192 x i32]* %14, i64 0, i64 %223
store i32 %221, i32* %224
%225 = load i32, i32* %7
%226 = sext i32 %225 to i64
%227 = getelementptr inbounds [8192 x i32], [8192 x i32]* %14, i64 0, i64 %226
%228 = load i32, i32* %227
%229 = load i8*, i8** %12
%230 = call i32 @read(i32 %228, i8* %229, i32 188)
store i32 %230, i32* %18
br label %231
231: ; preds = %210, %201
%232 = load i32, i32* %7
%233 = sext i32 %232 to i64
%234 = getelementptr inbounds [8192 x i8], [8192 x i8]* %16, i64 0, i64 %233
%235 = load i8, i8* %234
%236 = zext i8 %235 to i32
%237 = icmp eq i32 %236, 16
br i1 %237, label %238, label %257
238: ; preds = %231
%239 = load i8*, i8** %12
%240 = getelementptr inbounds i8, i8* %239, i64 3
%241 = load i8, i8* %240
%242 = zext i8 %241 to i32
%243 = and i32 %242, 15
%244 = trunc i32 %243 to i8
%245 = load i32, i32* %7
%246 = sext i32 %245 to i64
%247 = getelementptr inbounds [8192 x i8], [8192 x i8]* %16, i64 0, i64 %246
store i8 %244, i8* %247
%248 = load i8*, i8** %12
%249 = getelementptr inbounds i8, i8* %248, i64 3
%250 = load i8, i8* %249
%251 = zext i8 %250 to i32
%252 = and i32 %251, 15
%253 = trunc i32 %252 to i8
%254 = load i32, i32* %7
%255 = sext i32 %254 to i64
%256 = getelementptr inbounds [8192 x i8], [8192 x i8]* %17, i64 0, i64 %255
store i8 %253, i8* %256
br label %393
257: ; preds = %231
%258 = load i8*, i8** %12
%259 = getelementptr inbounds i8, i8* %258, i64 3
%260 = load i8, i8* %259
%261 = zext i8 %260 to i32
%262 = and i32 %261, 48
%263 = ashr i32 %262, 4
%264 = trunc i32 %263 to i8
store i8 %264, i8* %13
%265 = load i8, i8* %13
%266 = zext i8 %265 to i32
%267 = icmp eq i32 %266, 0
br i1 %267, label %272, label %268
268: ; preds = %257
%269 = load i8, i8* %13
%270 = zext i8 %269 to i32
%271 = icmp eq i32 %270, 2
br i1 %271, label %272, label %287
272: ; preds = %268, %257
%273 = load i32, i32* %7
%274 = sext i32 %273 to i64
%275 = getelementptr inbounds [8192 x i8], [8192 x i8]* %16, i64 0, i64 %274
%276 = load i8, i8* %275
%277 = zext i8 %276 to i32
%278 = load i8*, i8** %12
%279 = getelementptr inbounds i8, i8* %278, i64 3
%280 = load i8, i8* %279
%281 = zext i8 %280 to i32
%282 = and i32 %281, 240
%283 = or i32 %277, %282
%284 = trunc i32 %283 to i8
%285 = load i8*, i8** %12
%286 = getelementptr inbounds i8, i8* %285, i64 3
store i8 %284, i8* %286
br label %392
287: ; preds = %268
%288 = load i8, i8* %13
%289 = zext i8 %288 to i32
%290 = icmp eq i32 %289, 1
br i1 %290, label %291, label %321
291: ; preds = %287
%292 = load i8*, i8** %12
%293 = getelementptr inbounds i8, i8* %292, i64 3
%294 = load i8, i8* %293
%295 = zext i8 %294 to i32
%296 = and i32 %295, 15
%297 = load i32, i32* %7
%298 = sext i32 %297 to i64
%299 = getelementptr inbounds [8192 x i8], [8192 x i8]* %17, i64 0, i64 %298
%300 = load i8, i8* %299
%301 = zext i8 %300 to i32
%302 = icmp eq i32 %296, %301
br i1 %302, label %303, label %321
303: ; preds = %291
%304 = load i32, i32* %7
%305 = sext i32 %304 to i64
%306 = getelementptr inbounds [8192 x i8], [8192 x i8]* %16, i64 0, i64 %305
%307 = load i8, i8* %306
%308 = zext i8 %307 to i32
%309 = load i8*, i8** %12
%310 = getelementptr inbounds i8, i8* %309, i64 3
%311 = load i8, i8* %310
%312 = zext i8 %311 to i32
%313 = and i32 %312, 240
%314 = or i32 %308, %313
%315 = trunc i32 %314 to i8
%316 = load i8*, i8** %12
%317 = getelementptr inbounds i8, i8* %316, i64 3
store i8 %315, i8* %317
%318 = load i32, i32* %7
%319 = sext i32 %318 to i64
%320 = getelementptr inbounds [8192 x i8], [8192 x i8]* %17, i64 0, i64 %319
store i8 16, i8* %320
br label %391
321: ; preds = %291, %287
%322 = load i8, i8* %13
%323 = zext i8 %322 to i32
%324 = icmp eq i32 %323, 3
br i1 %324, label %325, label %355
325: ; preds = %321
%326 = load i8*, i8** %12
%327 = getelementptr inbounds i8, i8* %326, i64 3
%328 = load i8, i8* %327
%329 = zext i8 %328 to i32
%330 = and i32 %329, 15
%331 = load i32, i32* %7
%332 = sext i32 %331 to i64
%333 = getelementptr inbounds [8192 x i8], [8192 x i8]* %17, i64 0, i64 %332
%334 = load i8, i8* %333
%335 = zext i8 %334 to i32
%336 = icmp eq i32 %330, %335
br i1 %336, label %337, label %355
337: ; preds = %325
%338 = load i32, i32* %7
%339 = sext i32 %338 to i64
%340 = getelementptr inbounds [8192 x i8], [8192 x i8]* %16, i64 0, i64 %339
%341 = load i8, i8* %340
%342 = zext i8 %341 to i32
%343 = load i8*, i8** %12
%344 = getelementptr inbounds i8, i8* %343, i64 3
%345 = load i8, i8* %344
%346 = zext i8 %345 to i32
%347 = and i32 %346, 240
%348 = or i32 %342, %347
%349 = trunc i32 %348 to i8
%350 = load i8*, i8** %12
%351 = getelementptr inbounds i8, i8* %350, i64 3
store i8 %349, i8* %351
%352 = load i32, i32* %7
%353 = sext i32 %352 to i64
%354 = getelementptr inbounds [8192 x i8], [8192 x i8]* %17, i64 0, i64 %353
store i8 16, i8* %354
br label %390
355: ; preds = %325, %321
%356 = load i8*, i8** %12
%357 = getelementptr inbounds i8, i8* %356, i64 3
%358 = load i8, i8* %357
%359 = zext i8 %358 to i32
%360 = and i32 %359, 15
%361 = trunc i32 %360 to i8
%362 = load i32, i32* %7
%363 = sext i32 %362 to i64
%364 = getelementptr inbounds [8192 x i8], [8192 x i8]* %17, i64 0, i64 %363
store i8 %361, i8* %364
%365 = load i32, i32* %7
%366 = sext i32 %365 to i64
%367 = getelementptr inbounds [8192 x i8], [8192 x i8]* %16, i64 0, i64 %366
%368 = load i8, i8* %367
%369 = zext i8 %368 to i32
%370 = add nsw i32 %369, 1
%371 = srem i32 %370, 16
%372 = trunc i32 %371 to i8
%373 = load i32, i32* %7
%374 = sext i32 %373 to i64
%375 = getelementptr inbounds [8192 x i8], [8192 x i8]* %16, i64 0, i64 %374
store i8 %372, i8* %375
%376 = load i32, i32* %7
%377 = sext i32 %376 to i64
%378 = getelementptr inbounds [8192 x i8], [8192 x i8]* %16, i64 0, i64 %377
%379 = load i8, i8* %378
%380 = zext i8 %379 to i32
%381 = load i8*, i8** %12
%382 = getelementptr inbounds i8, i8* %381, i64 3
%383 = load i8, i8* %382
%384 = zext i8 %383 to i32
%385 = and i32 %384, 240
%386 = or i32 %380, %385
%387 = trunc i32 %386 to i8
%388 = load i8*, i8** %12
%389 = getelementptr inbounds i8, i8* %388, i64 3
store i8 %387, i8* %389
br label %390
390: ; preds = %355, %337
br label %391
391: ; preds = %390, %303
br label %392
392: ; preds = %391, %272
br label %393
393: ; preds = %392, %238
br label %394
394: ; preds = %393, %195, %181
br label %395
395: ; preds = %394
%396 = load i32, i32* %6
%397 = add i32 %396, 188
store i32 %397, i32* %6
br label %172
398: ; preds = %179
%399 = load i32, i32* %8
%400 = icmp ne i32 %399, 0
br i1 %400, label %401, label %406
401: ; preds = %398
%402 = load i32, i32* @STDOUT_FILENO
%403 = load i8*, i8** %11
%404 = load i32, i32* %9
%405 = call i32 @write(i32 %402, i8* %403, i32 %404)
br label %406
406: ; preds = %401, %398
br label %164
407: ; preds = %164
store i32 0, i32* %3
br label %408
408: ; preds = %407, %160, %135, %49, %39
%409 = load i32, i32* %3
ret i32 %409
}

LLVM IR (-O2):
@O_RDONLY = global i32 0
@stderr = global i32 0
@.str = [20 x i8] c"Can't find file %s\0A\00"
@.str.1 = [23 x i8] c"Modify pid %d with %s\0A\00"
@.str.2 = [16 x i8] c"Out of memory!\0A\00"
@STDOUT_FILENO = global i32 0
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i32
%4 = alloca [8192 x i32]
%5 = bitcast [8192 x i32]* %4 to i8*
%6 = alloca [8192 x i8*]
%7 = bitcast [8192 x i8*]* %6 to i8*
%8 = alloca [8192 x i8]
%9 = alloca [8192 x i8]
%10 = bitcast i32* %3 to i8*
%11 = getelementptr inbounds [8192 x i8], [8192 x i8]* %8, i64 0, i64 0
%12 = getelementptr inbounds [8192 x i8], [8192 x i8]* %9, i64 0, i64 0
%13 = call i32 @memset(i8* %11, i32 16, i32 8192)
%14 = call i32 @memset(i8* %12, i32 16, i32 8192)
%15 = icmp slt i32 %0, 3
br i1 %15, label %16, label %18
16: ; preds = %2
%17 = call i32 (...) @Usage()
br label %170
18: ; preds = %2
%19 = getelementptr inbounds i8*, i8** %1, i64 1
%20 = load i8*, i8** %19
%21 = load i32, i32* @O_RDONLY
%22 = call i32 @open(i8* %20, i32 %21)
%23 = icmp slt i32 %22, 0
br i1 %23, label %24, label %28
24: ; preds = %18
%25 = load i32, i32* @stderr
%26 = load i8*, i8** %19
%27 = call i32 (i32, i8*, ...) @fprintf(i32 %25, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i8* %26)
br label %170
28: ; preds = %18, %65
%29 = phi i32 [ %68, %65 ], [ 2, %18 ]
%30 = phi i32 [ %67, %65 ], [ 0, %18 ]
%31 = zext i32 %29 to i64
%32 = getelementptr inbounds i8*, i8** %1, i64 %31
%33 = load i8*, i8** %32
%34 = load i8, i8* %33
%35 = icmp eq i8 %34, 98
br i1 %35, label %36, label %43
36: ; preds = %28
%37 = getelementptr inbounds i8, i8* %33, i64 1
%38 = load i8, i8* %37
%39 = icmp eq i8 %38, 58
br i1 %39, label %40, label %43
40: ; preds = %36
%41 = getelementptr inbounds i8, i8* %33, i64 2
%42 = call i32 @atoi(i8* %41)
br label %65
43: ; preds = %36, %28
%44 = getelementptr inbounds i8, i8* %33, i64 1
%45 = call i32 @atoi(i8* %44)
store i32 %45, i32* %3
%46 = icmp slt i32 %45, 8192
br i1 %46, label %47, label %65
47: ; preds = %43
%48 = load i32, i32* @stderr
%49 = add nuw i32 %29, 1
%50 = zext i32 %49 to i64
%51 = getelementptr inbounds i8*, i8** %1, i64 %50
%52 = load i8*, i8** %51
%53 = call i32 (i32, i8*, ...) @fprintf(i32 %48, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i32 %45, i8* %52)
%54 = load i8*, i8** %51
%55 = load i32, i32* @O_RDONLY
%56 = call i32 @open(i8* %54, i32 %55)
%57 = sext i32 %45 to i64
%58 = getelementptr inbounds [8192 x i32], [8192 x i32]* %4, i64 0, i64 %57
store i32 %56, i32* %58
%59 = load i8*, i8** %51
%60 = getelementptr inbounds [8192 x i8*], [8192 x i8*]* %6, i64 0, i64 %57
store i8* %59, i8** %60
%61 = icmp slt i32 %56, 0
br i1 %61, label %62, label %65
62: ; preds = %47
%63 = load i32, i32* @stderr
%64 = call i32 (i32, i8*, ...) @fprintf(i32 %63, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i8* %59)
br label %170
65: ; preds = %43, %47, %40
%66 = phi i32 [ 1, %40 ], [ 2, %47 ], [ 2, %43 ]
%67 = phi i32 [ %42, %40 ], [ %30, %47 ], [ %30, %43 ]
%68 = add i32 %29, %66
%69 = icmp ult i32 %68, %0
br i1 %69, label %28, label %70
70: ; preds = %65
%71 = icmp sgt i32 %67, 1
%72 = select i1 %71, i32 %67, i32 1
%73 = mul nsw i32 %72, 188
%74 = call i8* @malloc(i32 %73)
%75 = icmp eq i8* %74, null
br i1 %75, label %79, label %76
76: ; preds = %70
%77 = call i32 @read(i32 %22, i8* %74, i32 %73)
%78 = icmp eq i32 %77, 0
br i1 %78, label %170, label %82
79: ; preds = %70
%80 = load i32, i32* @stderr
%81 = call i32 (i32, i8*, ...) @fprintf(i32 %80, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0))
br label %170
82: ; preds = %76, %165
%83 = phi i1 [ %169, %165 ], [ %78, %76 ]
br label %84
84: ; preds = %82, %161
%85 = phi i32 [ %162, %161 ], [ 0, %82 ]
%86 = zext i32 %85 to i64
%87 = getelementptr inbounds i8, i8* %74, i64 %86
%88 = getelementptr inbounds i8, i8* %87, i64 1
%89 = call i32 @memcpy(i32* %3, i8* %88, i32 2)
%90 = load i32, i32* %3
%91 = call i32 @ntohs(i32 %90)
%92 = and i32 %91, 8191
store i32 %92, i32* %3
%93 = zext i32 %92 to i64
%94 = getelementptr inbounds [8192 x i32], [8192 x i32]* %4, i64 0, i64 %93
%95 = load i32, i32* %94
%96 = icmp eq i32 %95, -1
br i1 %96, label %161, label %97
97: ; preds = %84
%98 = call i32 @read(i32 %95, i8* %87, i32 188)
%99 = icmp slt i32 %98, 1
br i1 %99, label %100, label %116
100: ; preds = %97
%101 = load i32, i32* %3
%102 = sext i32 %101 to i64
%103 = getelementptr inbounds [8192 x i32], [8192 x i32]* %4, i64 0, i64 %102
%104 = load i32, i32* %103
%105 = call i32 @close(i32 %104)
%106 = load i32, i32* %3
%107 = sext i32 %106 to i64
%108 = getelementptr inbounds [8192 x i8*], [8192 x i8*]* %6, i64 0, i64 %107
%109 = load i8*, i8** %108
%110 = load i32, i32* @O_RDONLY
%111 = call i32 @open(i8* %109, i32 %110)
%112 = load i32, i32* %3
%113 = sext i32 %112 to i64
%114 = getelementptr inbounds [8192 x i32], [8192 x i32]* %4, i64 0, i64 %113
store i32 %111, i32* %114
%115 = call i32 @read(i32 %111, i8* %87, i32 188)
br label %116
116: ; preds = %100, %97
%117 = load i32, i32* %3
%118 = sext i32 %117 to i64
%119 = getelementptr inbounds [8192 x i8], [8192 x i8]* %8, i64 0, i64 %118
%120 = load i8, i8* %119
%121 = icmp eq i8 %120, 16
%122 = getelementptr inbounds i8, i8* %87, i64 3
%123 = load i8, i8* %122
br i1 %121, label %124, label %127
124: ; preds = %116
%125 = and i8 %123, 15
store i8 %125, i8* %119
%126 = getelementptr inbounds [8192 x i8], [8192 x i8]* %9, i64 0, i64 %118
store i8 %125, i8* %126
br label %161
127: ; preds = %116
%128 = and i8 %123, 16
%129 = icmp eq i8 %128, 0
br i1 %129, label %130, label %133
130: ; preds = %127
%131 = and i8 %123, -16
%132 = or i8 %131, %120
store i8 %132, i8* %122
br label %161
133: ; preds = %127
%134 = lshr i8 %123, 4
%135 = and i8 %134, 3
switch i8 %135, label %136 [
i8 1, label %138
i8 3, label %146
]
136: ; preds = %133
%137 = and i8 %123, 15
br label %154
138: ; preds = %133
%139 = and i8 %123, 15
%140 = getelementptr inbounds [8192 x i8], [8192 x i8]* %9, i64 0, i64 %118
%141 = load i8, i8* %140
%142 = icmp eq i8 %139, %141
br i1 %142, label %143, label %154
143: ; preds = %138
%144 = and i8 %123, -16
%145 = or i8 %144, %120
store i8 %145, i8* %122
store i8 16, i8* %140
br label %161
146: ; preds = %133
%147 = and i8 %123, 15
%148 = getelementptr inbounds [8192 x i8], [8192 x i8]* %9, i64 0, i64 %118
%149 = load i8, i8* %148
%150 = icmp eq i8 %147, %149
br i1 %150, label %151, label %154
151: ; preds = %146
%152 = and i8 %123, -16
%153 = or i8 %152, %120
store i8 %153, i8* %122
store i8 16, i8* %148
br label %161
154: ; preds = %136, %138, %146
%155 = phi i8 [ %137, %136 ], [ %139, %138 ], [ %147, %146 ]
%156 = getelementptr inbounds [8192 x i8], [8192 x i8]* %9, i64 0, i64 %118
store i8 %155, i8* %156
%157 = add i8 %120, 1
%158 = and i8 %157, 15
store i8 %158, i8* %119
%159 = and i8 %123, -16
%160 = or i8 %159, %158
store i8 %160, i8* %122
br label %161
161: ; preds = %84, %130, %151, %154, %143, %124
%162 = add i32 %85, 188
%163 = icmp ult i32 %162, %73
br i1 %163, label %84, label %164
164: ; preds = %161
br i1 %83, label %170, label %165
165: ; preds = %164
%166 = load i32, i32* @STDOUT_FILENO
%167 = call i32 @write(i32 %166, i8* %74, i32 %73)
%168 = call i32 @read(i32 %22, i8* %74, i32 %73)
%169 = icmp eq i32 %168, 0
br i1 %169, label %170, label %82
170: ; preds = %164, %165, %76, %79, %62, %24, %16
%171 = phi i32 [ 2, %16 ], [ 2, %24 ], [ 2, %62 ], [ 2, %79 ], [ 0, %76 ], [ 0, %165 ], [ 0, %164 ]
ret i32 %171
}