#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*/ exit(int);
int /*<<< orphan*/ fflush(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int fread(unsigned char *, int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ fwrite(unsigned char *, int, int, int /*<<< orphan*/ *);
unsigned char *malloc(int);
int /*<<< orphan*/ printf(char *, int, ...);
unsigned char *realloc(unsigned char *, int);
int /*<<< orphan*/ stderr;
int uint8(unsigned char *);
int main(int argc, char **argv) {
  FILE *out, *in1, *in2, *in3;
  unsigned char *buffer1, *buffer2, *buffer3;
  int size1, size2, size3;
  int i, k, count, smallest, size[4];
  if (argc != 5) {
    fprintf(stderr, "bad arg: output in-1 in-2 in-3\n");
    exit(8);
  }
  if ((out = fopen(argv[1], "wb")) == NULL) {
    fprintf(stderr, "bad arg: output=%s\n", argv[1]);
    exit(8);
  }
  if ((in1 = fopen(argv[2], "rb")) == NULL) {
    fprintf(stderr, "bad arg: in-1=%s\n", argv[2]);
    exit(8);
  }
  if ((in2 = fopen(argv[3], "rb")) == NULL) {
    fprintf(stderr, "bad arg: in-2=%s\n", argv[3]);
    exit(8);
  }
  if ((in3 = fopen(argv[4], "rb")) == NULL) {
    fprintf(stderr, "bad arg: in-3=%s\n", argv[4]);
    exit(8);
  }
  buffer1 = malloc(4096 * 4);
  buffer2 = malloc(4096 * 4);
  buffer3 = malloc(4096 * 4);
  if (buffer1 == NULL || buffer2 == NULL || buffer3 == NULL) {
    fprintf(stderr, "not enough memory\n");
    exit(8);
  }
  size1 = size2 = size3 = 4096 * 4;
  count = 0;
  while (1 == 1) {
    i = fread(buffer1, 1, 16, in1);
    if (i != 16)
      break;
    if (buffer1[0] != 'G' || buffer1[1] != 'R' || buffer1[2] != 'I' ||
        buffer1[3] != 'B')
      exit(1);
    size[1] = uint8(&(buffer1[8]));
    if (size1 < size[1]) {
      size1 = size[1];
      buffer1 = realloc(buffer1, size1);
      if (buffer1 == NULL) {
        fprintf(stderr, "not enough memory\n");
        exit(8);
      }
    }
    k = fread(buffer1 + 16, 1, size[1] - 16, in1);
    if (k != size[1] - 16)
      exit(4);
    i = fread(buffer2, 1, 16, in2);
    if (i != 16)
      break;
    if (buffer2[0] != 'G' || buffer2[1] != 'R' || buffer2[2] != 'I' ||
        buffer2[3] != 'B')
      exit(1);
    size[2] = uint8(&(buffer2[8]));
    if (size2 < size[2]) {
      size2 = size[2];
      buffer2 = realloc(buffer2, size2);
      if (buffer2 == NULL) {
        fprintf(stderr, "not enough memory\n");
        exit(8);
      }
    }
    k = fread(buffer2 + 16, 1, size[2] - 16, in2);
    if (k != size[2] - 16)
      exit(4);
    i = fread(buffer3, 1, 16, in3);
    if (i != 16)
      break;
    if (buffer3[0] != 'G' || buffer3[1] != 'R' || buffer3[2] != 'I' ||
        buffer3[3] != 'B')
      exit(1);
    size[3] = uint8(&(buffer3[8]));
    if (size3 < size[3]) {
      size3 = size[3];
      buffer3 = realloc(buffer3, size3);
      if (buffer3 == NULL) {
        fprintf(stderr, "not enough memory\n");
        exit(8);
      }
    }
    k = fread(buffer3 + 16, 1, size[3] - 16, in3);
    if (k != size[3] - 16)
      exit(4);
    smallest = 1;
    if (size[2] < size[smallest])
      smallest = 2;
    if (size[3] < size[smallest])
      smallest = 3;
    count++;
    printf("%d: code=%d n1 %d n2 %d n3 %d\n", count, smallest, size[1], size[2],
           size[3]);
    if (smallest == 1)
      fwrite(buffer1, 1, size[1], out);
    if (smallest == 2)
      fwrite(buffer2, 1, size[2], out);
    if (smallest == 3)
      fwrite(buffer3, 1, size[3], out);
    fflush(out);
  }
  printf("records = %d\n", count);
  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     11e4 <main+0x44>
mov    0x2e16(%rip),%rax
mov    (%rax),%edi
lea    0xe2d(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    $0x8,%edi
call   10b0 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe2d(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
jne    122f <main+0x8f>
mov    0x2dd3(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdx
lea    0xe05(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    $0x8,%edi
call   10b0 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xdf9(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
jne    127a <main+0xda>
mov    0x2d88(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdx
lea    0xdd1(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    $0x8,%edi
call   10b0 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
lea    0xdae(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,-0x28(%rbp)
cmp    $0x0,%rax
jne    12c5 <main+0x125>
mov    0x2d3d(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdx
lea    0xd98(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    $0x8,%edi
call   10b0 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x20(%rax),%rdi
lea    0xd63(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,-0x30(%rbp)
cmp    $0x0,%rax
jne    1310 <main+0x170>
mov    0x2cf2(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    0x20(%rax),%rdx
lea    0xd5f(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    $0x8,%edi
call   10b0 <exit@plt>
mov    $0x4000,%edi
call   1070 <malloc@plt>
mov    %rax,-0x38(%rbp)
mov    $0x4000,%edi
call   1070 <malloc@plt>
mov    %rax,-0x40(%rbp)
mov    $0x4000,%edi
call   1070 <malloc@plt>
mov    %rax,-0x48(%rbp)
cmpq   $0x0,-0x38(%rbp)
je     135b <main+0x1bb>
cmpq   $0x0,-0x40(%rbp)
je     135b <main+0x1bb>
cmpq   $0x0,-0x48(%rbp)
jne    137c <main+0x1dc>
mov    0x2c7e(%rip),%rax
mov    (%rax),%edi
lea    0xd05(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    $0x8,%edi
call   10b0 <exit@plt>
movl   $0x4000,-0x54(%rbp)
movl   $0x4000,-0x50(%rbp)
movl   $0x4000,-0x4c(%rbp)
movl   $0x0,-0x60(%rbp)
mov    -0x38(%rbp),%rdi
mov    -0x20(%rbp),%rcx
mov    $0x1,%esi
mov    $0x10,%edx
call   1040 <fread@plt>
mov    %eax,-0x58(%rbp)
cmpl   $0x10,-0x58(%rbp)
je     13c1 <main+0x221>
jmp    179b <main+0x5fb>
mov    -0x38(%rbp),%rax
movzbl (%rax),%eax
cmp    $0x47,%eax
jne    1404 <main+0x264>
mov    -0x38(%rbp),%rax
movzbl 0x1(%rax),%eax
cmp    $0x52,%eax
jne    1404 <main+0x264>
mov    -0x38(%rbp),%rax
movzbl 0x2(%rax),%eax
cmp    $0x49,%eax
jne    1404 <main+0x264>
mov    -0x38(%rbp),%rax
movzbl 0x3(%rax),%eax
cmp    $0x42,%eax
je     140e <main+0x26e>
mov    $0x1,%edi
call   10b0 <exit@plt>
mov    -0x38(%rbp),%rdi
add    $0x8,%rdi
call   1030 <uint8@plt>
mov    %eax,-0x7c(%rbp)
mov    -0x4c(%rbp),%eax
cmp    -0x7c(%rbp),%eax
jge    1471 <main+0x2d1>
mov    -0x7c(%rbp),%eax
mov    %eax,-0x4c(%rbp)
mov    -0x38(%rbp),%rdi
mov    -0x4c(%rbp),%esi
call   1090 <realloc@plt>
mov    %rax,-0x38(%rbp)
cmpq   $0x0,-0x38(%rbp)
jne    146c <main+0x2cc>
mov    0x2b8e(%rip),%rax
mov    (%rax),%edi
lea    0xc15(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    $0x8,%edi
call   10b0 <exit@plt>
jmp    1471 <main+0x2d1>
mov    -0x38(%rbp),%rdi
add    $0x10,%rdi
mov    -0x7c(%rbp),%edx
sub    $0x10,%edx
mov    -0x20(%rbp),%rcx
mov    $0x1,%esi
call   1040 <fread@plt>
mov    %eax,-0x5c(%rbp)
mov    -0x5c(%rbp),%eax
mov    -0x7c(%rbp),%ecx
sub    $0x10,%ecx
cmp    %ecx,%eax
je     14ab <main+0x30b>
mov    $0x4,%edi
call   10b0 <exit@plt>
mov    -0x40(%rbp),%rdi
mov    -0x28(%rbp),%rcx
mov    $0x1,%esi
mov    $0x10,%edx
call   1040 <fread@plt>
mov    %eax,-0x58(%rbp)
cmpl   $0x10,-0x58(%rbp)
je     14d4 <main+0x334>
jmp    179b <main+0x5fb>
mov    -0x40(%rbp),%rax
movzbl (%rax),%eax
cmp    $0x47,%eax
jne    1517 <main+0x377>
mov    -0x40(%rbp),%rax
movzbl 0x1(%rax),%eax
cmp    $0x52,%eax
jne    1517 <main+0x377>
mov    -0x40(%rbp),%rax
movzbl 0x2(%rax),%eax
cmp    $0x49,%eax
jne    1517 <main+0x377>
mov    -0x40(%rbp),%rax
movzbl 0x3(%rax),%eax
cmp    $0x42,%eax
je     1521 <main+0x381>
mov    $0x1,%edi
call   10b0 <exit@plt>
mov    -0x40(%rbp),%rdi
add    $0x8,%rdi
call   1030 <uint8@plt>
mov    %eax,-0x78(%rbp)
mov    -0x50(%rbp),%eax
cmp    -0x78(%rbp),%eax
jge    1584 <main+0x3e4>
mov    -0x78(%rbp),%eax
mov    %eax,-0x50(%rbp)
mov    -0x40(%rbp),%rdi
mov    -0x50(%rbp),%esi
call   1090 <realloc@plt>
mov    %rax,-0x40(%rbp)
cmpq   $0x0,-0x40(%rbp)
jne    157f <main+0x3df>
mov    0x2a7b(%rip),%rax
mov    (%rax),%edi
lea    0xb02(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    $0x8,%edi
call   10b0 <exit@plt>
jmp    1584 <main+0x3e4>
mov    -0x40(%rbp),%rdi
add    $0x10,%rdi
mov    -0x78(%rbp),%edx
sub    $0x10,%edx
mov    -0x28(%rbp),%rcx
mov    $0x1,%esi
call   1040 <fread@plt>
mov    %eax,-0x5c(%rbp)
mov    -0x5c(%rbp),%eax
mov    -0x78(%rbp),%ecx
sub    $0x10,%ecx
cmp    %ecx,%eax
je     15be <main+0x41e>
mov    $0x4,%edi
call   10b0 <exit@plt>
mov    -0x48(%rbp),%rdi
mov    -0x30(%rbp),%rcx
mov    $0x1,%esi
mov    $0x10,%edx
call   1040 <fread@plt>
mov    %eax,-0x58(%rbp)
cmpl   $0x10,-0x58(%rbp)
je     15e7 <main+0x447>
jmp    179b <main+0x5fb>
mov    -0x48(%rbp),%rax
movzbl (%rax),%eax
cmp    $0x47,%eax
jne    162a <main+0x48a>
mov    -0x48(%rbp),%rax
movzbl 0x1(%rax),%eax
cmp    $0x52,%eax
jne    162a <main+0x48a>
mov    -0x48(%rbp),%rax
movzbl 0x2(%rax),%eax
cmp    $0x49,%eax
jne    162a <main+0x48a>
mov    -0x48(%rbp),%rax
movzbl 0x3(%rax),%eax
cmp    $0x42,%eax
je     1634 <main+0x494>
mov    $0x1,%edi
call   10b0 <exit@plt>
mov    -0x48(%rbp),%rdi
add    $0x8,%rdi
call   1030 <uint8@plt>
mov    %eax,-0x74(%rbp)
mov    -0x54(%rbp),%eax
cmp    -0x74(%rbp),%eax
jge    1697 <main+0x4f7>
mov    -0x74(%rbp),%eax
mov    %eax,-0x54(%rbp)
mov    -0x48(%rbp),%rdi
mov    -0x54(%rbp),%esi
call   1090 <realloc@plt>
mov    %rax,-0x48(%rbp)
cmpq   $0x0,-0x48(%rbp)
jne    1692 <main+0x4f2>
mov    0x2968(%rip),%rax
mov    (%rax),%edi
lea    0x9ef(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    $0x8,%edi
call   10b0 <exit@plt>
jmp    1697 <main+0x4f7>
mov    -0x48(%rbp),%rdi
add    $0x10,%rdi
mov    -0x74(%rbp),%edx
sub    $0x10,%edx
mov    -0x30(%rbp),%rcx
mov    $0x1,%esi
call   1040 <fread@plt>
mov    %eax,-0x5c(%rbp)
mov    -0x5c(%rbp),%eax
mov    -0x74(%rbp),%ecx
sub    $0x10,%ecx
cmp    %ecx,%eax
je     16d1 <main+0x531>
mov    $0x4,%edi
call   10b0 <exit@plt>
movl   $0x1,-0x64(%rbp)
mov    -0x78(%rbp),%eax
movslq -0x64(%rbp),%rcx
cmp    -0x80(%rbp,%rcx,4),%eax
jge    16f0 <main+0x550>
movl   $0x2,-0x64(%rbp)
mov    -0x74(%rbp),%eax
movslq -0x64(%rbp),%rcx
cmp    -0x80(%rbp,%rcx,4),%eax
jge    1708 <main+0x568>
movl   $0x3,-0x64(%rbp)
mov    -0x60(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x60(%rbp)
mov    -0x60(%rbp),%esi
mov    -0x64(%rbp),%edx
mov    -0x7c(%rbp),%ecx
mov    -0x78(%rbp),%r8d
mov    -0x74(%rbp),%r9d
lea    0x95a(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
cmpl   $0x1,-0x64(%rbp)
jne    174f <main+0x5af>
mov    -0x38(%rbp),%rdi
mov    -0x7c(%rbp),%edx
mov    -0x18(%rbp),%rcx
mov    $0x1,%esi
call   10c0 <fwrite@plt>
cmpl   $0x2,-0x64(%rbp)
jne    176e <main+0x5ce>
mov    -0x40(%rbp),%rdi
mov    -0x78(%rbp),%edx
mov    -0x18(%rbp),%rcx
mov    $0x1,%esi
call   10c0 <fwrite@plt>
cmpl   $0x3,-0x64(%rbp)
jne    178d <main+0x5ed>
mov    -0x48(%rbp),%rdi
mov    -0x74(%rbp),%edx
mov    -0x18(%rbp),%rcx
mov    $0x1,%esi
call   10c0 <fwrite@plt>
mov    -0x18(%rbp),%rdi
call   1080 <fflush@plt>
jmp    1398 <main+0x1f8>
mov    -0x60(%rbp),%esi
lea    0x8fd(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@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    $0x58,%rsp
cmp    $0x5,%edi
jne    15f7 <main+0x457>
mov    %rsi,%rbp
mov    0x8(%rsi),%rdi
lea    0xe5b(%rip),%rsi
call   10a0 <fopen@plt>
test   %rax,%rax
je     1609 <main+0x469>
mov    %rax,%r13
mov    0x10(%rbp),%rdi
lea    0xe56(%rip),%rsi
call   10a0 <fopen@plt>
test   %rax,%rax
je     161f <main+0x47f>
mov    %rax,%r15
mov    0x18(%rbp),%rdi
lea    0xe3a(%rip),%rsi
call   10a0 <fopen@plt>
test   %rax,%rax
je     1635 <main+0x495>
mov    %rax,%r14
mov    0x20(%rbp),%rdi
lea    0xe1e(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,0x20(%rsp)
test   %rax,%rax
je     164b <main+0x4ab>
mov    $0x4000,%edi
call   1070 <malloc@plt>
mov    %rax,%rbx
mov    $0x4000,%edi
call   1070 <malloc@plt>
mov    %rax,%rbp
mov    $0x4000,%edi
call   1070 <malloc@plt>
mov    %rax,0x10(%rsp)
test   %rbx,%rbx
je     15d6 <main+0x436>
test   %rbp,%rbp
je     15d6 <main+0x436>
cmpq   $0x0,0x10(%rsp)
je     15d6 <main+0x436>
mov    %rbx,%rdi
mov    $0x1,%esi
mov    $0x10,%edx
mov    %r15,%rcx
call   1040 <fread@plt>
movl   $0x0,(%rsp)
cmp    $0x10,%eax
jne    15a0 <main+0x400>
movl   $0x4000,0x4(%rsp)
movl   $0x0,(%rsp)
movl   $0x4000,0x8(%rsp)
movl   $0x4000,0xc(%rsp)
mov    %r15,0x48(%rsp)
mov    %r14,0x40(%rsp)
mov    %r13,0x50(%rsp)
jmp    1305 <main+0x165>
nopl   0x0(%rax,%rax,1)
mov    %r13,%rdi
call   1080 <fflush@plt>
mov    %rbx,%rdi
mov    $0x1,%esi
mov    $0x10,%edx
mov    0x48(%rsp),%r15
mov    %r15,%rcx
call   1040 <fread@plt>
cmp    $0x10,%eax
mov    0x40(%rsp),%r14
mov    0x28(%rsp),%rbp
jne    15a0 <main+0x400>
cmpb   $0x47,(%rbx)
jne    15c2 <main+0x422>
cmpb   $0x52,0x1(%rbx)
jne    15c2 <main+0x422>
cmpb   $0x49,0x2(%rbx)
jne    15c2 <main+0x422>
cmpb   $0x42,0x3(%rbx)
jne    15c2 <main+0x422>
lea    0x8(%rbx),%rdi
call   1030 <uint8@plt>
mov    %eax,%r12d
mov    %eax,0x34(%rsp)
cmp    %eax,0xc(%rsp)
jge    1370 <main+0x1d0>
mov    %rbp,%r13
mov    %rbx,%rdi
mov    %r12d,%esi
call   1090 <realloc@plt>
mov    %rax,%rbx
mov    %r12d,%eax
mov    %r12d,0xc(%rsp)
test   %rbx,%rbx
jne    1373 <main+0x1d3>
jmp    15d6 <main+0x436>
cs nopw 0x0(%rax,%rax,1)
nop
mov    %rbp,%r13
lea    0x10(%rbx),%rdi
lea    -0x10(%r12),%ebp
mov    $0x1,%esi
mov    %ebp,%edx
mov    %r15,%rcx
call   1040 <fread@plt>
cmp    %ebp,%eax
jne    15cc <main+0x42c>
mov    %r13,%rbp
mov    %r13,%rdi
mov    $0x1,%esi
mov    $0x10,%edx
mov    %r14,%rcx
call   1040 <fread@plt>
cmp    $0x10,%eax
jne    15a0 <main+0x400>
mov    %rbx,0x18(%rsp)
cmpb   $0x47,0x0(%rbp)
jne    15c2 <main+0x422>
cmpb   $0x52,0x1(%rbp)
jne    15c2 <main+0x422>
cmpb   $0x49,0x2(%rbp)
jne    15c2 <main+0x422>
cmpb   $0x42,0x3(%rbp)
jne    15c2 <main+0x422>
lea    0x8(%rbp),%rdi
call   1030 <uint8@plt>
mov    %eax,%r13d
mov    %eax,0x38(%rsp)
cmp    %eax,0x8(%rsp)
jge    1416 <main+0x276>
mov    %rbp,%rdi
mov    %r13d,%esi
call   1090 <realloc@plt>
mov    %rax,%rbp
mov    %r13d,%eax
mov    %r13d,0x8(%rsp)
test   %rbp,%rbp
je     15d6 <main+0x436>
mov    %rbp,0x28(%rsp)
lea    0x10(%rbp),%rdi
lea    -0x10(%r13),%ebp
mov    $0x1,%esi
mov    %ebp,%edx
mov    %r14,%rcx
call   1040 <fread@plt>
cmp    %ebp,%eax
jne    15cc <main+0x42c>
mov    0x10(%rsp),%rbp
mov    %rbp,%rdi
mov    $0x1,%esi
mov    $0x10,%edx
mov    0x20(%rsp),%rcx
call   1040 <fread@plt>
cmp    $0x10,%eax
jne    15a0 <main+0x400>
cmpb   $0x47,0x0(%rbp)
jne    15c2 <main+0x422>
cmpb   $0x52,0x1(%rbp)
jne    15c2 <main+0x422>
cmpb   $0x49,0x2(%rbp)
jne    15c2 <main+0x422>
cmpb   $0x42,0x3(%rbp)
jne    15c2 <main+0x422>
lea    0x8(%rbp),%rdi
call   1030 <uint8@plt>
mov    %eax,%r15d
mov    %eax,0x3c(%rsp)
cmp    %eax,0x4(%rsp)
jge    14bc <main+0x31c>
mov    %rbp,%rdi
mov    %r15d,%esi
call   1090 <realloc@plt>
mov    %rax,%rbp
mov    %r15d,%eax
mov    %r15d,0x4(%rsp)
test   %rbp,%rbp
je     15d6 <main+0x436>
mov    0x50(%rsp),%rbx
mov    %rbp,0x10(%rsp)
lea    0x10(%rbp),%rdi
lea    -0x10(%r15),%ebp
mov    $0x1,%esi
mov    %ebp,%edx
mov    0x20(%rsp),%rcx
call   1040 <fread@plt>
cmp    %ebp,%eax
jne    15cc <main+0x42c>
xor    %eax,%eax
cmp    %r12d,%r13d
setl   %al
add    $0x1,%eax
mov    0x30(%rsp,%rax,4),%ebp
mov    $0x3,%r14d
cmp    %ebp,%r15d
jl     1504 <main+0x364>
mov    %eax,%r14d
mov    (%rsp),%esi
add    $0x1,%esi
lea    0xb72(%rip),%rdi
mov    %esi,(%rsp)
mov    %r14d,%edx
mov    %r12d,%ecx
mov    %r13d,%r8d
mov    %r15d,%r9d
xor    %eax,%eax
call   1050 <printf@plt>
cmp    $0x2,%r14d
je     1560 <main+0x3c0>
cmp    $0x1,%r14d
mov    %rbx,%r13
mov    0x18(%rsp),%rbx
jne    154e <main+0x3ae>
mov    %rbx,%rdi
mov    $0x1,%esi
mov    %r12d,%edx
mov    %r13,%rcx
call   10c0 <fwrite@plt>
cmp    %ebp,%r15d
jge    12d0 <main+0x130>
jmp    1586 <main+0x3e6>
nopl   0x0(%rax)
mov    0x28(%rsp),%rdi
mov    $0x1,%esi
mov    %r13d,%edx
mov    %rbx,%r13
mov    %rbx,%rcx
call   10c0 <fwrite@plt>
mov    0x18(%rsp),%rbx
cmp    %ebp,%r15d
jge    12d0 <main+0x130>
mov    0x10(%rsp),%rdi
mov    $0x1,%esi
mov    %r15d,%edx
mov    %r13,%rcx
call   10c0 <fwrite@plt>
jmp    12d0 <main+0x130>
lea    0xafb(%rip),%rdi
mov    (%rsp),%esi
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x58,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    $0x1,%edi
call   10b0 <exit@plt>
mov    $0x4,%edi
call   10b0 <exit@plt>
mov    0x2a03(%rip),%rax
mov    (%rax),%edi
lea    0xa8a(%rip),%rsi
xor    %eax,%eax
call   1060 <fprintf@plt>
mov    $0x8,%edi
call   10b0 <exit@plt>
mov    0x29e2(%rip),%rax
mov    (%rax),%edi
lea    0x9f9(%rip),%rsi
jmp    15e6 <main+0x446>
mov    0x29d0(%rip),%rax
mov    (%rax),%edi
mov    0x8(%rbp),%rdx
lea    0xa06(%rip),%rsi
jmp    165f <main+0x4bf>
mov    0x29ba(%rip),%rax
mov    (%rax),%edi
mov    0x10(%rbp),%rdx
lea    0xa07(%rip),%rsi
jmp    165f <main+0x4bf>
mov    0x29a4(%rip),%rax
mov    (%rax),%edi
mov    0x18(%rbp),%rdx
lea    0xa03(%rip),%rsi
jmp    165f <main+0x4bf>
mov    0x298e(%rip),%rax
mov    (%rax),%edi
mov    0x20(%rbp),%rdx
lea    0x9ff(%rip),%rsi
xor    %eax,%eax
call   1060 <fprintf@plt>
mov    $0x8,%edi
call   10b0 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [32 x i8] c"bad arg: output in-1 in-2 in-3\0A\00"
@.str.1 = [3 x i8] c"wb\00"
@.str.2 = [20 x i8] c"bad arg: output=%s\0A\00"
@.str.3 = [3 x i8] c"rb\00"
@.str.4 = [18 x i8] c"bad arg: in-1=%s\0A\00"
@.str.5 = [18 x i8] c"bad arg: in-2=%s\0A\00"
@.str.6 = [18 x i8] c"bad arg: in-3=%s\0A\00"
@.str.7 = [19 x i8] c"not enough memory\0A\00"
@.str.8 = [31 x i8] c"%d: code=%d n1 %d n2 %d n3 %d\0A\00"
@.str.9 = [14 x i8] c"records = %d\0A\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 i32*
%9 = alloca i32*
%10 = alloca i8*
%11 = alloca i8*
%12 = alloca i8*
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
%16 = alloca i32
%17 = alloca i32
%18 = alloca i32
%19 = alloca i32
%20 = alloca [4 x 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 %27
23: ; preds = %2
%24 = load i32, i32* @stderr
%25 = call i32 (i32, i8*, ...) @fprintf(i32 %24, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0))
%26 = call i32 @exit(i32 8)
unreachable
27: ; preds = %2
%28 = load i8**, i8*** %5
%29 = getelementptr inbounds i8*, i8** %28, i64 1
%30 = load i8*, i8** %29
%31 = call i32* @fopen(i8* %30, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
store i32* %31, i32** %6
%32 = icmp eq i32* %31, null
br i1 %32, label %33, label %40
33: ; preds = %27
%34 = load i32, i32* @stderr
%35 = load i8**, i8*** %5
%36 = getelementptr inbounds i8*, i8** %35, i64 1
%37 = load i8*, i8** %36
%38 = call i32 (i32, i8*, ...) @fprintf(i32 %34, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0), i8* %37)
%39 = call i32 @exit(i32 8)
unreachable
40: ; preds = %27
%41 = load i8**, i8*** %5
%42 = getelementptr inbounds i8*, i8** %41, i64 2
%43 = load i8*, i8** %42
%44 = call i32* @fopen(i8* %43, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
store i32* %44, i32** %7
%45 = icmp eq i32* %44, null
br i1 %45, label %46, label %53
46: ; preds = %40
%47 = load i32, i32* @stderr
%48 = load i8**, i8*** %5
%49 = getelementptr inbounds i8*, i8** %48, i64 2
%50 = load i8*, i8** %49
%51 = call i32 (i32, i8*, ...) @fprintf(i32 %47, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.4, i64 0, i64 0), i8* %50)
%52 = call i32 @exit(i32 8)
unreachable
53: ; preds = %40
%54 = load i8**, i8*** %5
%55 = getelementptr inbounds i8*, i8** %54, i64 3
%56 = load i8*, i8** %55
%57 = call i32* @fopen(i8* %56, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
store i32* %57, i32** %8
%58 = icmp eq i32* %57, null
br i1 %58, label %59, label %66
59: ; preds = %53
%60 = load i32, i32* @stderr
%61 = load i8**, i8*** %5
%62 = getelementptr inbounds i8*, i8** %61, i64 3
%63 = load i8*, i8** %62
%64 = call i32 (i32, i8*, ...) @fprintf(i32 %60, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.5, i64 0, i64 0), i8* %63)
%65 = call i32 @exit(i32 8)
unreachable
66: ; preds = %53
%67 = load i8**, i8*** %5
%68 = getelementptr inbounds i8*, i8** %67, i64 4
%69 = load i8*, i8** %68
%70 = call i32* @fopen(i8* %69, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
store i32* %70, i32** %9
%71 = icmp eq i32* %70, null
br i1 %71, label %72, label %79
72: ; preds = %66
%73 = load i32, i32* @stderr
%74 = load i8**, i8*** %5
%75 = getelementptr inbounds i8*, i8** %74, i64 4
%76 = load i8*, i8** %75
%77 = call i32 (i32, i8*, ...) @fprintf(i32 %73, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.6, i64 0, i64 0), i8* %76)
%78 = call i32 @exit(i32 8)
unreachable
79: ; preds = %66
%80 = call i8* @malloc(i32 16384)
store i8* %80, i8** %10
%81 = call i8* @malloc(i32 16384)
store i8* %81, i8** %11
%82 = call i8* @malloc(i32 16384)
store i8* %82, i8** %12
%83 = load i8*, i8** %10
%84 = icmp eq i8* %83, null
br i1 %84, label %91, label %85
85: ; preds = %79
%86 = load i8*, i8** %11
%87 = icmp eq i8* %86, null
br i1 %87, label %91, label %88
88: ; preds = %85
%89 = load i8*, i8** %12
%90 = icmp eq i8* %89, null
br i1 %90, label %91, label %95
91: ; preds = %88, %85, %79
%92 = load i32, i32* @stderr
%93 = call i32 (i32, i8*, ...) @fprintf(i32 %92, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.7, i64 0, i64 0))
%94 = call i32 @exit(i32 8)
unreachable
95: ; preds = %88
store i32 16384, i32* %15
store i32 16384, i32* %14
store i32 16384, i32* %13
store i32 0, i32* %18
br label %96
96: ; preds = %95, %362
%97 = load i8*, i8** %10
%98 = load i32*, i32** %7
%99 = call i32 @fread(i8* %97, i32 1, i32 16, i32* %98)
store i32 %99, i32* %16
%100 = load i32, i32* %16
%101 = icmp ne i32 %100, 16
br i1 %101, label %102, label %103
102: ; preds = %96
br label %365
103: ; preds = %96
%104 = load i8*, i8** %10
%105 = getelementptr inbounds i8, i8* %104, i64 0
%106 = load i8, i8* %105
%107 = zext i8 %106 to i32
%108 = icmp ne i32 %107, 71
br i1 %108, label %127, label %109
109: ; preds = %103
%110 = load i8*, i8** %10
%111 = getelementptr inbounds i8, i8* %110, i64 1
%112 = load i8, i8* %111
%113 = zext i8 %112 to i32
%114 = icmp ne i32 %113, 82
br i1 %114, label %127, label %115
115: ; preds = %109
%116 = load i8*, i8** %10
%117 = getelementptr inbounds i8, i8* %116, i64 2
%118 = load i8, i8* %117
%119 = zext i8 %118 to i32
%120 = icmp ne i32 %119, 73
br i1 %120, label %127, label %121
121: ; preds = %115
%122 = load i8*, i8** %10
%123 = getelementptr inbounds i8, i8* %122, i64 3
%124 = load i8, i8* %123
%125 = zext i8 %124 to i32
%126 = icmp ne i32 %125, 66
br i1 %126, label %127, label %129
127: ; preds = %121, %115, %109, %103
%128 = call i32 @exit(i32 1)
unreachable
129: ; preds = %121
%130 = load i8*, i8** %10
%131 = getelementptr inbounds i8, i8* %130, i64 8
%132 = call i32 @uint8(i8* %131)
%133 = getelementptr inbounds [4 x i32], [4 x i32]* %20, i64 0, i64 1
store i32 %132, i32* %133
%134 = load i32, i32* %13
%135 = getelementptr inbounds [4 x i32], [4 x i32]* %20, i64 0, i64 1
%136 = load i32, i32* %135
%137 = icmp slt i32 %134, %136
br i1 %137, label %138, label %151
138: ; preds = %129
%139 = getelementptr inbounds [4 x i32], [4 x i32]* %20, i64 0, i64 1
%140 = load i32, i32* %139
store i32 %140, i32* %13
%141 = load i8*, i8** %10
%142 = load i32, i32* %13
%143 = call i8* @realloc(i8* %141, i32 %142)
store i8* %143, i8** %10
%144 = load i8*, i8** %10
%145 = icmp eq i8* %144, null
br i1 %145, label %146, label %150
146: ; preds = %138
%147 = load i32, i32* @stderr
%148 = call i32 (i32, i8*, ...) @fprintf(i32 %147, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.7, i64 0, i64 0))
%149 = call i32 @exit(i32 8)
unreachable
150: ; preds = %138
br label %151
151: ; preds = %150, %129
%152 = load i8*, i8** %10
%153 = getelementptr inbounds i8, i8* %152, i64 16
%154 = getelementptr inbounds [4 x i32], [4 x i32]* %20, i64 0, i64 1
%155 = load i32, i32* %154
%156 = sub nsw i32 %155, 16
%157 = load i32*, i32** %7
%158 = call i32 @fread(i8* %153, i32 1, i32 %156, i32* %157)
store i32 %158, i32* %17
%159 = load i32, i32* %17
%160 = getelementptr inbounds [4 x i32], [4 x i32]* %20, i64 0, i64 1
%161 = load i32, i32* %160
%162 = sub nsw i32 %161, 16
%163 = icmp ne i32 %159, %162
br i1 %163, label %164, label %166
164: ; preds = %151
%165 = call i32 @exit(i32 4)
unreachable
166: ; preds = %151
%167 = load i8*, i8** %11
%168 = load i32*, i32** %8
%169 = call i32 @fread(i8* %167, i32 1, i32 16, i32* %168)
store i32 %169, i32* %16
%170 = load i32, i32* %16
%171 = icmp ne i32 %170, 16
br i1 %171, label %172, label %173
172: ; preds = %166
br label %365
173: ; preds = %166
%174 = load i8*, i8** %11
%175 = getelementptr inbounds i8, i8* %174, i64 0
%176 = load i8, i8* %175
%177 = zext i8 %176 to i32
%178 = icmp ne i32 %177, 71
br i1 %178, label %197, label %179
179: ; preds = %173
%180 = load i8*, i8** %11
%181 = getelementptr inbounds i8, i8* %180, i64 1
%182 = load i8, i8* %181
%183 = zext i8 %182 to i32
%184 = icmp ne i32 %183, 82
br i1 %184, label %197, label %185
185: ; preds = %179
%186 = load i8*, i8** %11
%187 = getelementptr inbounds i8, i8* %186, i64 2
%188 = load i8, i8* %187
%189 = zext i8 %188 to i32
%190 = icmp ne i32 %189, 73
br i1 %190, label %197, label %191
191: ; preds = %185
%192 = load i8*, i8** %11
%193 = getelementptr inbounds i8, i8* %192, i64 3
%194 = load i8, i8* %193
%195 = zext i8 %194 to i32
%196 = icmp ne i32 %195, 66
br i1 %196, label %197, label %199
197: ; preds = %191, %185, %179, %173
%198 = call i32 @exit(i32 1)
unreachable
199: ; preds = %191
%200 = load i8*, i8** %11
%201 = getelementptr inbounds i8, i8* %200, i64 8
%202 = call i32 @uint8(i8* %201)
%203 = getelementptr inbounds [4 x i32], [4 x i32]* %20, i64 0, i64 2
store i32 %202, i32* %203
%204 = load i32, i32* %14
%205 = getelementptr inbounds [4 x i32], [4 x i32]* %20, i64 0, i64 2
%206 = load i32, i32* %205
%207 = icmp slt i32 %204, %206
br i1 %207, label %208, label %221
208: ; preds = %199
%209 = getelementptr inbounds [4 x i32], [4 x i32]* %20, i64 0, i64 2
%210 = load i32, i32* %209
store i32 %210, i32* %14
%211 = load i8*, i8** %11
%212 = load i32, i32* %14
%213 = call i8* @realloc(i8* %211, i32 %212)
store i8* %213, i8** %11
%214 = load i8*, i8** %11
%215 = icmp eq i8* %214, null
br i1 %215, label %216, label %220
216: ; preds = %208
%217 = load i32, i32* @stderr
%218 = call i32 (i32, i8*, ...) @fprintf(i32 %217, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.7, i64 0, i64 0))
%219 = call i32 @exit(i32 8)
unreachable
220: ; preds = %208
br label %221
221: ; preds = %220, %199
%222 = load i8*, i8** %11
%223 = getelementptr inbounds i8, i8* %222, i64 16
%224 = getelementptr inbounds [4 x i32], [4 x i32]* %20, i64 0, i64 2
%225 = load i32, i32* %224
%226 = sub nsw i32 %225, 16
%227 = load i32*, i32** %8
%228 = call i32 @fread(i8* %223, i32 1, i32 %226, i32* %227)
store i32 %228, i32* %17
%229 = load i32, i32* %17
%230 = getelementptr inbounds [4 x i32], [4 x i32]* %20, i64 0, i64 2
%231 = load i32, i32* %230
%232 = sub nsw i32 %231, 16
%233 = icmp ne i32 %229, %232
br i1 %233, label %234, label %236
234: ; preds = %221
%235 = call i32 @exit(i32 4)
unreachable
236: ; preds = %221
%237 = load i8*, i8** %12
%238 = load i32*, i32** %9
%239 = call i32 @fread(i8* %237, i32 1, i32 16, i32* %238)
store i32 %239, i32* %16
%240 = load i32, i32* %16
%241 = icmp ne i32 %240, 16
br i1 %241, label %242, label %243
242: ; preds = %236
br label %365
243: ; preds = %236
%244 = load i8*, i8** %12
%245 = getelementptr inbounds i8, i8* %244, i64 0
%246 = load i8, i8* %245
%247 = zext i8 %246 to i32
%248 = icmp ne i32 %247, 71
br i1 %248, label %267, label %249
249: ; preds = %243
%250 = load i8*, i8** %12
%251 = getelementptr inbounds i8, i8* %250, i64 1
%252 = load i8, i8* %251
%253 = zext i8 %252 to i32
%254 = icmp ne i32 %253, 82
br i1 %254, label %267, label %255
255: ; preds = %249
%256 = load i8*, i8** %12
%257 = getelementptr inbounds i8, i8* %256, i64 2
%258 = load i8, i8* %257
%259 = zext i8 %258 to i32
%260 = icmp ne i32 %259, 73
br i1 %260, label %267, label %261
261: ; preds = %255
%262 = load i8*, i8** %12
%263 = getelementptr inbounds i8, i8* %262, i64 3
%264 = load i8, i8* %263
%265 = zext i8 %264 to i32
%266 = icmp ne i32 %265, 66
br i1 %266, label %267, label %269
267: ; preds = %261, %255, %249, %243
%268 = call i32 @exit(i32 1)
unreachable
269: ; preds = %261
%270 = load i8*, i8** %12
%271 = getelementptr inbounds i8, i8* %270, i64 8
%272 = call i32 @uint8(i8* %271)
%273 = getelementptr inbounds [4 x i32], [4 x i32]* %20, i64 0, i64 3
store i32 %272, i32* %273
%274 = load i32, i32* %15
%275 = getelementptr inbounds [4 x i32], [4 x i32]* %20, i64 0, i64 3
%276 = load i32, i32* %275
%277 = icmp slt i32 %274, %276
br i1 %277, label %278, label %291
278: ; preds = %269
%279 = getelementptr inbounds [4 x i32], [4 x i32]* %20, i64 0, i64 3
%280 = load i32, i32* %279
store i32 %280, i32* %15
%281 = load i8*, i8** %12
%282 = load i32, i32* %15
%283 = call i8* @realloc(i8* %281, i32 %282)
store i8* %283, i8** %12
%284 = load i8*, i8** %12
%285 = icmp eq i8* %284, null
br i1 %285, label %286, label %290
286: ; preds = %278
%287 = load i32, i32* @stderr
%288 = call i32 (i32, i8*, ...) @fprintf(i32 %287, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.7, i64 0, i64 0))
%289 = call i32 @exit(i32 8)
unreachable
290: ; preds = %278
br label %291
291: ; preds = %290, %269
%292 = load i8*, i8** %12
%293 = getelementptr inbounds i8, i8* %292, i64 16
%294 = getelementptr inbounds [4 x i32], [4 x i32]* %20, i64 0, i64 3
%295 = load i32, i32* %294
%296 = sub nsw i32 %295, 16
%297 = load i32*, i32** %9
%298 = call i32 @fread(i8* %293, i32 1, i32 %296, i32* %297)
store i32 %298, i32* %17
%299 = load i32, i32* %17
%300 = getelementptr inbounds [4 x i32], [4 x i32]* %20, i64 0, i64 3
%301 = load i32, i32* %300
%302 = sub nsw i32 %301, 16
%303 = icmp ne i32 %299, %302
br i1 %303, label %304, label %306
304: ; preds = %291
%305 = call i32 @exit(i32 4)
unreachable
306: ; preds = %291
store i32 1, i32* %19
%307 = getelementptr inbounds [4 x i32], [4 x i32]* %20, i64 0, i64 2
%308 = load i32, i32* %307
%309 = load i32, i32* %19
%310 = sext i32 %309 to i64
%311 = getelementptr inbounds [4 x i32], [4 x i32]* %20, i64 0, i64 %310
%312 = load i32, i32* %311
%313 = icmp slt i32 %308, %312
br i1 %313, label %314, label %315
314: ; preds = %306
store i32 2, i32* %19
br label %315
315: ; preds = %314, %306
%316 = getelementptr inbounds [4 x i32], [4 x i32]* %20, i64 0, i64 3
%317 = load i32, i32* %316
%318 = load i32, i32* %19
%319 = sext i32 %318 to i64
%320 = getelementptr inbounds [4 x i32], [4 x i32]* %20, i64 0, i64 %319
%321 = load i32, i32* %320
%322 = icmp slt i32 %317, %321
br i1 %322, label %323, label %324
323: ; preds = %315
store i32 3, i32* %19
br label %324
324: ; preds = %323, %315
%325 = load i32, i32* %18
%326 = add nsw i32 %325, 1
store i32 %326, i32* %18
%327 = load i32, i32* %18
%328 = load i32, i32* %19
%329 = getelementptr inbounds [4 x i32], [4 x i32]* %20, i64 0, i64 1
%330 = load i32, i32* %329
%331 = getelementptr inbounds [4 x i32], [4 x i32]* %20, i64 0, i64 2
%332 = load i32, i32* %331
%333 = getelementptr inbounds [4 x i32], [4 x i32]* %20, i64 0, i64 3
%334 = load i32, i32* %333
%335 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.8, i64 0, i64 0), i32 %327, i32 %328, i32 %330, i32 %332, i32 %334)
%336 = load i32, i32* %19
%337 = icmp eq i32 %336, 1
br i1 %337, label %338, label %344
338: ; preds = %324
%339 = load i8*, i8** %10
%340 = getelementptr inbounds [4 x i32], [4 x i32]* %20, i64 0, i64 1
%341 = load i32, i32* %340
%342 = load i32*, i32** %6
%343 = call i32 @fwrite(i8* %339, i32 1, i32 %341, i32* %342)
br label %344
344: ; preds = %338, %324
%345 = load i32, i32* %19
%346 = icmp eq i32 %345, 2
br i1 %346, label %347, label %353
347: ; preds = %344
%348 = load i8*, i8** %11
%349 = getelementptr inbounds [4 x i32], [4 x i32]* %20, i64 0, i64 2
%350 = load i32, i32* %349
%351 = load i32*, i32** %6
%352 = call i32 @fwrite(i8* %348, i32 1, i32 %350, i32* %351)
br label %353
353: ; preds = %347, %344
%354 = load i32, i32* %19
%355 = icmp eq i32 %354, 3
br i1 %355, label %356, label %362
356: ; preds = %353
%357 = load i8*, i8** %12
%358 = getelementptr inbounds [4 x i32], [4 x i32]* %20, i64 0, i64 3
%359 = load i32, i32* %358
%360 = load i32*, i32** %6
%361 = call i32 @fwrite(i8* %357, i32 1, i32 %359, i32* %360)
br label %362
362: ; preds = %356, %353
%363 = load i32*, i32** %6
%364 = call i32 @fflush(i32* %363)
br label %96
365: ; preds = %242, %172, %102
%366 = load i32, i32* %18
%367 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.9, i64 0, i64 0), i32 %366)
ret i32 0
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [32 x i8] c"bad arg: output in-1 in-2 in-3\0A\00"
@.str.1 = [3 x i8] c"wb\00"
@.str.2 = [20 x i8] c"bad arg: output=%s\0A\00"
@.str.3 = [3 x i8] c"rb\00"
@.str.4 = [18 x i8] c"bad arg: in-1=%s\0A\00"
@.str.5 = [18 x i8] c"bad arg: in-2=%s\0A\00"
@.str.6 = [18 x i8] c"bad arg: in-3=%s\0A\00"
@.str.7 = [19 x i8] c"not enough memory\0A\00"
@.str.8 = [31 x i8] c"%d: code=%d n1 %d n2 %d n3 %d\0A\00"
@.str.9 = [14 x i8] c"records = %d\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [4 x i32]
%4 = bitcast [4 x i32]* %3 to i8*
%5 = icmp eq i32 %0, 5
br i1 %5, label %10, label %6
6: ; preds = %2
%7 = load i32, i32* @stderr
%8 = tail call i32 (i32, i8*, ...) @fprintf(i32 %7, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0))
%9 = tail call i32 @exit(i32 8)
unreachable
10: ; preds = %2
%11 = getelementptr inbounds i8*, i8** %1, i64 1
%12 = load i8*, i8** %11
%13 = tail call i32* @fopen(i8* %12, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%14 = icmp eq i32* %13, null
br i1 %14, label %15, label %20
15: ; preds = %10
%16 = load i32, i32* @stderr
%17 = load i8*, i8** %11
%18 = tail call i32 (i32, i8*, ...) @fprintf(i32 %16, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0), i8* %17)
%19 = tail call i32 @exit(i32 8)
unreachable
20: ; preds = %10
%21 = getelementptr inbounds i8*, i8** %1, i64 2
%22 = load i8*, i8** %21
%23 = tail call i32* @fopen(i8* %22, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%24 = icmp eq i32* %23, null
br i1 %24, label %25, label %30
25: ; preds = %20
%26 = load i32, i32* @stderr
%27 = load i8*, i8** %21
%28 = tail call i32 (i32, i8*, ...) @fprintf(i32 %26, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.4, i64 0, i64 0), i8* %27)
%29 = tail call i32 @exit(i32 8)
unreachable
30: ; preds = %20
%31 = getelementptr inbounds i8*, i8** %1, i64 3
%32 = load i8*, i8** %31
%33 = tail call i32* @fopen(i8* %32, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%34 = icmp eq i32* %33, null
br i1 %34, label %35, label %40
35: ; preds = %30
%36 = load i32, i32* @stderr
%37 = load i8*, i8** %31
%38 = tail call i32 (i32, i8*, ...) @fprintf(i32 %36, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.5, i64 0, i64 0), i8* %37)
%39 = tail call i32 @exit(i32 8)
unreachable
40: ; preds = %30
%41 = getelementptr inbounds i8*, i8** %1, i64 4
%42 = load i8*, i8** %41
%43 = tail call i32* @fopen(i8* %42, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%44 = icmp eq i32* %43, null
br i1 %44, label %45, label %50
45: ; preds = %40
%46 = load i32, i32* @stderr
%47 = load i8*, i8** %41
%48 = tail call i32 (i32, i8*, ...) @fprintf(i32 %46, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.6, i64 0, i64 0), i8* %47)
%49 = tail call i32 @exit(i32 8)
unreachable
50: ; preds = %40
%51 = tail call dereferenceable_or_null(16384) i8* @malloc(i32 16384)
%52 = tail call dereferenceable_or_null(16384) i8* @malloc(i32 16384)
%53 = tail call dereferenceable_or_null(16384) i8* @malloc(i32 16384)
%54 = icmp eq i8* %51, null
%55 = icmp eq i8* %52, null
%56 = or i1 %54, %55
%57 = icmp eq i8* %53, null
%58 = or i1 %56, %57
br i1 %58, label %66, label %59
59: ; preds = %50
%60 = tail call i32 @fread(i8* %51, i32 1, i32 16, i32* %23)
%61 = icmp eq i32 %60, 16
br i1 %61, label %62, label %215
62: ; preds = %59
%63 = getelementptr inbounds [4 x i32], [4 x i32]* %3, i64 0, i64 1
%64 = getelementptr inbounds [4 x i32], [4 x i32]* %3, i64 0, i64 2
%65 = getelementptr inbounds [4 x i32], [4 x i32]* %3, i64 0, i64 3
br label %70
66: ; preds = %50
%67 = load i32, i32* @stderr
%68 = tail call i32 (i32, i8*, ...) @fprintf(i32 %67, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.7, i64 0, i64 0))
%69 = tail call i32 @exit(i32 8)
unreachable
70: ; preds = %62, %211
%71 = phi i32 [ 0, %62 ], [ %202, %211 ]
%72 = phi i32 [ 16384, %62 ], [ %187, %211 ]
%73 = phi i32 [ 16384, %62 ], [ %147, %211 ]
%74 = phi i32 [ 16384, %62 ], [ %107, %211 ]
%75 = phi i8* [ %53, %62 ], [ %186, %211 ]
%76 = phi i8* [ %52, %62 ], [ %146, %211 ]
%77 = phi i8* [ %51, %62 ], [ %106, %211 ]
%78 = load i8, i8* %77
%79 = icmp eq i8 %78, 71
br i1 %79, label %80, label %92
80: ; preds = %70
%81 = getelementptr inbounds i8, i8* %77, i64 1
%82 = load i8, i8* %81
%83 = icmp eq i8 %82, 82
br i1 %83, label %84, label %92
84: ; preds = %80
%85 = getelementptr inbounds i8, i8* %77, i64 2
%86 = load i8, i8* %85
%87 = icmp eq i8 %86, 73
br i1 %87, label %88, label %92
88: ; preds = %84
%89 = getelementptr inbounds i8, i8* %77, i64 3
%90 = load i8, i8* %89
%91 = icmp eq i8 %90, 66
br i1 %91, label %94, label %92
92: ; preds = %88, %84, %80, %70
%93 = tail call i32 @exit(i32 1)
unreachable
94: ; preds = %88
%95 = getelementptr inbounds i8, i8* %77, i64 8
%96 = tail call i32 @uint8(i8* %95)
store i32 %96, i32* %63
%97 = icmp slt i32 %74, %96
br i1 %97, label %98, label %105
98: ; preds = %94
%99 = tail call i8* @realloc(i8* %77, i32 %96)
%100 = icmp eq i8* %99, null
br i1 %100, label %101, label %105
101: ; preds = %98
%102 = load i32, i32* @stderr
%103 = tail call i32 (i32, i8*, ...) @fprintf(i32 %102, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.7, i64 0, i64 0))
%104 = tail call i32 @exit(i32 8)
unreachable
105: ; preds = %98, %94
%106 = phi i8* [ %99, %98 ], [ %77, %94 ]
%107 = phi i32 [ %96, %98 ], [ %74, %94 ]
%108 = getelementptr inbounds i8, i8* %106, i64 16
%109 = add nsw i32 %96, -16
%110 = tail call i32 @fread(i8* %108, i32 1, i32 %109, i32* %23)
%111 = icmp eq i32 %110, %109
br i1 %111, label %114, label %112
112: ; preds = %105
%113 = tail call i32 @exit(i32 4)
unreachable
114: ; preds = %105
%115 = tail call i32 @fread(i8* %76, i32 1, i32 16, i32* %33)
%116 = icmp eq i32 %115, 16
br i1 %116, label %117, label %215
117: ; preds = %114
%118 = load i8, i8* %76
%119 = icmp eq i8 %118, 71
br i1 %119, label %120, label %132
120: ; preds = %117
%121 = getelementptr inbounds i8, i8* %76, i64 1
%122 = load i8, i8* %121
%123 = icmp eq i8 %122, 82
br i1 %123, label %124, label %132
124: ; preds = %120
%125 = getelementptr inbounds i8, i8* %76, i64 2
%126 = load i8, i8* %125
%127 = icmp eq i8 %126, 73
br i1 %127, label %128, label %132
128: ; preds = %124
%129 = getelementptr inbounds i8, i8* %76, i64 3
%130 = load i8, i8* %129
%131 = icmp eq i8 %130, 66
br i1 %131, label %134, label %132
132: ; preds = %128, %124, %120, %117
%133 = tail call i32 @exit(i32 1)
unreachable
134: ; preds = %128
%135 = getelementptr inbounds i8, i8* %76, i64 8
%136 = tail call i32 @uint8(i8* %135)
store i32 %136, i32* %64
%137 = icmp slt i32 %73, %136
br i1 %137, label %138, label %145
138: ; preds = %134
%139 = tail call i8* @realloc(i8* %76, i32 %136)
%140 = icmp eq i8* %139, null
br i1 %140, label %141, label %145
141: ; preds = %138
%142 = load i32, i32* @stderr
%143 = tail call i32 (i32, i8*, ...) @fprintf(i32 %142, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.7, i64 0, i64 0))
%144 = tail call i32 @exit(i32 8)
unreachable
145: ; preds = %138, %134
%146 = phi i8* [ %139, %138 ], [ %76, %134 ]
%147 = phi i32 [ %136, %138 ], [ %73, %134 ]
%148 = getelementptr inbounds i8, i8* %146, i64 16
%149 = add nsw i32 %136, -16
%150 = tail call i32 @fread(i8* %148, i32 1, i32 %149, i32* %33)
%151 = icmp eq i32 %150, %149
br i1 %151, label %154, label %152
152: ; preds = %145
%153 = tail call i32 @exit(i32 4)
unreachable
154: ; preds = %145
%155 = tail call i32 @fread(i8* %75, i32 1, i32 16, i32* %43)
%156 = icmp eq i32 %155, 16
br i1 %156, label %157, label %215
157: ; preds = %154
%158 = load i8, i8* %75
%159 = icmp eq i8 %158, 71
br i1 %159, label %160, label %172
160: ; preds = %157
%161 = getelementptr inbounds i8, i8* %75, i64 1
%162 = load i8, i8* %161
%163 = icmp eq i8 %162, 82
br i1 %163, label %164, label %172
164: ; preds = %160
%165 = getelementptr inbounds i8, i8* %75, i64 2
%166 = load i8, i8* %165
%167 = icmp eq i8 %166, 73
br i1 %167, label %168, label %172
168: ; preds = %164
%169 = getelementptr inbounds i8, i8* %75, i64 3
%170 = load i8, i8* %169
%171 = icmp eq i8 %170, 66
br i1 %171, label %174, label %172
172: ; preds = %168, %164, %160, %157
%173 = tail call i32 @exit(i32 1)
unreachable
174: ; preds = %168
%175 = getelementptr inbounds i8, i8* %75, i64 8
%176 = tail call i32 @uint8(i8* %175)
store i32 %176, i32* %65
%177 = icmp slt i32 %72, %176
br i1 %177, label %178, label %185
178: ; preds = %174
%179 = tail call i8* @realloc(i8* %75, i32 %176)
%180 = icmp eq i8* %179, null
br i1 %180, label %181, label %185
181: ; preds = %178
%182 = load i32, i32* @stderr
%183 = tail call i32 (i32, i8*, ...) @fprintf(i32 %182, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.7, i64 0, i64 0))
%184 = tail call i32 @exit(i32 8)
unreachable
185: ; preds = %178, %174
%186 = phi i8* [ %179, %178 ], [ %75, %174 ]
%187 = phi i32 [ %176, %178 ], [ %72, %174 ]
%188 = getelementptr inbounds i8, i8* %186, i64 16
%189 = add nsw i32 %176, -16
%190 = tail call i32 @fread(i8* %188, i32 1, i32 %189, i32* %43)
%191 = icmp eq i32 %190, %189
br i1 %191, label %194, label %192
192: ; preds = %185
%193 = tail call i32 @exit(i32 4)
unreachable
194: ; preds = %185
%195 = icmp slt i32 %136, %96
%196 = select i1 %195, i32 2, i32 1
%197 = zext i32 %196 to i64
%198 = getelementptr inbounds [4 x i32], [4 x i32]* %3, i64 0, i64 %197
%199 = load i32, i32* %198
%200 = icmp slt i32 %176, %199
%201 = select i1 %200, i32 3, i32 %196
%202 = add nuw nsw i32 %71, 1
%203 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.8, i64 0, i64 0), i32 %202, i32 %201, i32 %96, i32 %136, i32 %176)
switch i32 %201, label %208 [
i32 1, label %204
i32 2, label %206
]
204: ; preds = %194
%205 = tail call i32 @fwrite(i8* %106, i32 1, i32 %96, i32* %13)
br label %208
206: ; preds = %194
%207 = tail call i32 @fwrite(i8* %146, i32 1, i32 %136, i32* %13)
br label %208
208: ; preds = %204, %194, %206
br i1 %200, label %209, label %211
209: ; preds = %208
%210 = tail call i32 @fwrite(i8* %186, i32 1, i32 %176, i32* %13)
br label %211
211: ; preds = %209, %208
%212 = tail call i32 @fflush(i32* %13)
%213 = tail call i32 @fread(i8* %106, i32 1, i32 16, i32* %23)
%214 = icmp eq i32 %213, 16
br i1 %214, label %70, label %215
215: ; preds = %211, %114, %154, %59
%216 = phi i32 [ 0, %59 ], [ %71, %154 ], [ %71, %114 ], [ %202, %211 ]
%217 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.9, i64 0, i64 0), i32 %216)
ret i32 0
}