#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 uint8_t;
typedef void *uint16_t;
typedef int int16_t;
typedef int /*<<< orphan*/ buf;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int EXIT_FAILURE;
int EXIT_SUCCESS;
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ fputc(int, int /*<<< orphan*/ *);
size_t fread(int *, int, int, int /*<<< orphan*/ *);
int getopt(int, char **, char *);
int /*<<< orphan*/ optarg;
int optind;
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ *stdin;
int /*<<< orphan*/ *stdout;
scalar_t__ strcmp(char *, char *);
void *strtol(int /*<<< orphan*/, int /*<<< orphan*/ *, int /*<<< orphan*/);
int /*<<< orphan*/ usage(char *);
int main(int argc, char *argv[]) {
  FILE *ifp = stdin;
  FILE *ofp = stdout;
  int opt;
  bool do_analyse = false;
  bool output_unpacked = false;
  int downsample_rate = 1;
  uint16_t threshold = 0x4000;
  struct {
    unsigned int min_unsigned;
    unsigned int max_unsigned;
    int min_signed;
    int max_signed;
  } stats = {0};
  int downsample_threshold = 1;
  int downsample_cnt = 0;
  int one_cnt = 0;
  size_t len;
  uint8_t buf[4096];
  uint16_t *vals;
  size_t i;
  uint8_t b;
  int j;
  while ((opt = getopt(argc, argv, "ad:t:uh")) != -1) {
    switch (opt) {
    case 'a':
      do_analyse = true;
      break;
    case 'd':
      downsample_rate = strtol(optarg, NULL, 0);
      if (downsample_rate <= 0) {
        downsample_rate = 1;
      }
      break;
    case 't':
      threshold = strtol(optarg, NULL, 0);
      break;
    case 'u':
      output_unpacked = true;
      break;
    case 'h':
      usage(argv[0]);
      exit(EXIT_SUCCESS);
      break;
    default:
      usage(argv[0]);
      exit(EXIT_FAILURE);
    }
  }
  if (argc - optind > 2) {
    fprintf(stderr, "Too many arguments\n");
    usage(argv[0]);
    exit(EXIT_FAILURE);
  }
  if (argc - optind > 0) {
    if (strcmp(argv[optind], "-") != 0) {
      if ((ifp = fopen(argv[optind], "rb")) == NULL) {
        perror("Failed opening input file");
        exit(EXIT_FAILURE);
      }
    }
    optind++;
  }
  if (argc - optind > 0 && !do_analyse) {
    if (strcmp(argv[optind], "-") != 0) {
      if ((ofp = fopen(argv[optind], "wb")) == NULL) {
        if (ifp != stdin)
          fclose(ifp);
        perror("Failed opening output file");
        exit(EXIT_FAILURE);
      }
    }
    optind++;
  }
  if (downsample_rate != 1) {
    downsample_threshold = downsample_rate >> 1;
  }
  b = 0;
  j = 0;
  one_cnt = 0;
  downsample_cnt = 0;
  while ((len = fread(buf, 1, sizeof(buf), ifp)) > 0) {
    vals = (uint16_t *)buf;
    for (i = 0; i < len / 2; i++) {
      if (do_analyse) {
        if (vals[i] > stats.max_unsigned)
          stats.max_unsigned = vals[i];
        if (vals[i] < stats.min_unsigned)
          stats.min_unsigned = vals[i];
        if ((int16_t)vals[i] > stats.max_signed)
          stats.max_signed = vals[i];
        if ((int16_t)vals[i] < stats.min_signed)
          stats.min_signed = vals[i];
      } else {
        if (vals[i] > threshold) {
          one_cnt++;
        }
        if (++downsample_cnt == downsample_rate) {
          b <<= 1;
          if (one_cnt >= downsample_threshold) {
            b |= 1;
          }
          if (++j == 8 || output_unpacked) {
            fputc(b, ofp);
            j = 0;
            b = 0;
          }
          one_cnt = 0;
          downsample_cnt = 0;
        }
      }
    }
  }
  if (do_analyse) {
    printf("Analysis\n");
    printf("--------\n");
    printf("Unsigned Minimal level: %u\n", stats.min_unsigned);
    printf("Unsigned Maximum level: %u\n", stats.max_unsigned);
    printf("Signed Minimal level: %u\n", stats.min_signed);
    printf("Signed Maximum level: %u\n", stats.max_signed);
  } else {
    if (j != 0) {
      b <<= (8 - j);
      fputc(b, ofp);
    }
  }
  if (ifp != stdin)
    fclose(ifp);
  if (ofp != stdout)
    fclose(ofp);
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x4080,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0x2df0(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x18(%rbp)
mov    0x2dba(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x20(%rbp)
movl   $0x0,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
movl   $0x1,-0x30(%rbp)
mov    $0x4000,%eax
mov    %rax,-0x38(%rbp)
lea    -0x48(%rbp),%rdi
xor    %esi,%esi
mov    $0x10,%edx
call   1060 <memset@plt>
movl   $0x1,-0x4c(%rbp)
movl   $0x0,-0x50(%rbp)
movl   $0x0,-0x54(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xdfe(%rip),%rdx
call   10e0 <getopt@plt>
mov    %eax,-0x24(%rbp)
cmp    $0xffffffff,%eax
je     1331 <main+0x161>
mov    -0x24(%rbp),%eax
add    $0xffffff9f,%eax
mov    %eax,%ecx
mov    %rcx,-0x4080(%rbp)
sub    $0x14,%eax
ja     1312 <main+0x142>
mov    -0x4080(%rbp),%rax
lea    0xd73(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movl   $0x1,-0x28(%rbp)
jmp    132c <main+0x15c>
mov    0x2d4f(%rip),%rax
mov    (%rax),%edi
xor    %eax,%eax
mov    %eax,%esi
xor    %edx,%edx
call   10a0 <strtol@plt>
mov    %eax,-0x30(%rbp)
cmpl   $0x0,-0x30(%rbp)
jg     12ca <main+0xfa>
movl   $0x1,-0x30(%rbp)
jmp    132c <main+0x15c>
mov    0x2d22(%rip),%rax
mov    (%rax),%edi
xor    %eax,%eax
mov    %eax,%esi
xor    %edx,%edx
call   10a0 <strtol@plt>
mov    %rax,-0x38(%rbp)
jmp    132c <main+0x15c>
movl   $0x1,-0x2c(%rbp)
jmp    132c <main+0x15c>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   10b0 <usage@plt>
mov    0x2ca5(%rip),%rax
mov    (%rax),%edi
call   10f0 <exit@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   10b0 <usage@plt>
mov    0x2c9b(%rip),%rax
mov    (%rax),%edi
call   10f0 <exit@plt>
jmp    1248 <main+0x78>
mov    -0x8(%rbp),%eax
mov    0x2c9d(%rip),%rcx
sub    (%rcx),%eax
cmp    $0x2,%eax
jle    1375 <main+0x1a5>
mov    0x2c7b(%rip),%rax
mov    (%rax),%edi
lea    0xd06(%rip),%rsi
call   1090 <fprintf@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   10b0 <usage@plt>
mov    0x2c52(%rip),%rax
mov    (%rax),%edi
call   10f0 <exit@plt>
mov    -0x8(%rbp),%eax
mov    0x2c59(%rip),%rcx
sub    (%rcx),%eax
cmp    $0x0,%eax
jle    1412 <main+0x242>
mov    -0x10(%rbp),%rax
mov    0x2c43(%rip),%rcx
movslq (%rcx),%rcx
mov    (%rax,%rcx,8),%rdi
lea    0xccd(%rip),%rsi
call   1080 <strcmp@plt>
cmp    $0x0,%rax
je     13fd <main+0x22d>
mov    -0x10(%rbp),%rax
mov    0x2c1b(%rip),%rcx
movslq (%rcx),%rcx
mov    (%rax,%rcx,8),%rdi
lea    0xca7(%rip),%rsi
call   10c0 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
jne    13f8 <main+0x228>
lea    0xc90(%rip),%rdi
call   10d0 <perror@plt>
mov    0x2bcf(%rip),%rax
mov    (%rax),%edi
call   10f0 <exit@plt>
jmp    13fd <main+0x22d>
mov    0x2bd4(%rip),%rax
mov    (%rax),%ecx
add    $0x1,%ecx
mov    0x2bc8(%rip),%rax
mov    %ecx,(%rax)
mov    -0x8(%rbp),%eax
mov    0x2bbc(%rip),%rcx
sub    (%rcx),%eax
cmp    $0x0,%eax
jle    14d6 <main+0x306>
cmpl   $0x0,-0x28(%rbp)
jne    14d6 <main+0x306>
mov    -0x10(%rbp),%rax
mov    0x2b9c(%rip),%rcx
movslq (%rcx),%rcx
mov    (%rax,%rcx,8),%rdi
lea    0xc26(%rip),%rsi
call   1080 <strcmp@plt>
cmp    $0x0,%rax
je     14c1 <main+0x2f1>
mov    -0x10(%rbp),%rax
mov    0x2b74(%rip),%rcx
movslq (%rcx),%rcx
mov    (%rax,%rcx,8),%rdi
lea    0xc1d(%rip),%rsi
call   10c0 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
jne    14bc <main+0x2ec>
mov    -0x18(%rbp),%rax
mov    0x2b50(%rip),%rcx
cmp    (%rcx),%rax
je     14a2 <main+0x2d2>
mov    -0x18(%rbp),%rdi
call   1040 <fclose@plt>
lea    0xbe9(%rip),%rdi
call   10d0 <perror@plt>
mov    0x2b0b(%rip),%rax
mov    (%rax),%edi
call   10f0 <exit@plt>
jmp    14c1 <main+0x2f1>
mov    0x2b10(%rip),%rax
mov    (%rax),%ecx
add    $0x1,%ecx
mov    0x2b04(%rip),%rax
mov    %ecx,(%rax)
cmpl   $0x1,-0x30(%rbp)
je     14e9 <main+0x319>
mov    -0x30(%rbp),%eax
sar    $0x1,%eax
mov    %eax,-0x4c(%rbp)
movl   $0x0,-0x4074(%rbp)
movl   $0x0,-0x4078(%rbp)
movl   $0x0,-0x54(%rbp)
movl   $0x0,-0x50(%rbp)
lea    -0x4060(%rbp),%rdi
mov    -0x18(%rbp),%rcx
mov    $0x1,%esi
mov    $0x4000,%edx
call   1030 <fread@plt>
mov    %rax,-0x60(%rbp)
cmp    $0x0,%rax
jbe    1713 <main+0x543>
lea    -0x4060(%rbp),%rax
mov    %rax,-0x4068(%rbp)
movq   $0x0,-0x4070(%rbp)
mov    -0x4070(%rbp),%rax
mov    -0x60(%rbp),%rcx
shr    $0x1,%rcx
cmp    %rcx,%rax
jae    170e <main+0x53e>
cmpl   $0x0,-0x28(%rbp)
je     1639 <main+0x469>
mov    -0x4068(%rbp),%rax
mov    -0x4070(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    -0x44(%rbp),%ecx
cmp    %rcx,%rax
jbe    15a1 <main+0x3d1>
mov    -0x4068(%rbp),%rax
mov    -0x4070(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    %eax,-0x44(%rbp)
mov    -0x4068(%rbp),%rax
mov    -0x4070(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    -0x48(%rbp),%ecx
cmp    %rcx,%rax
jae    15d4 <main+0x404>
mov    -0x4068(%rbp),%rax
mov    -0x4070(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    %eax,-0x48(%rbp)
mov    -0x4068(%rbp),%rax
mov    -0x4070(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
cmp    -0x3c(%rbp),%eax
jle    1604 <main+0x434>
mov    -0x4068(%rbp),%rax
mov    -0x4070(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    %eax,-0x3c(%rbp)
mov    -0x4068(%rbp),%rax
mov    -0x4070(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
cmp    -0x40(%rbp),%eax
jge    1634 <main+0x464>
mov    -0x4068(%rbp),%rax
mov    -0x4070(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    %eax,-0x40(%rbp)
jmp    16f2 <main+0x522>
mov    -0x4068(%rbp),%rax
mov    -0x4070(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
cmp    -0x38(%rbp),%rax
jbe    165e <main+0x48e>
mov    -0x54(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x54(%rbp)
mov    -0x50(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x50(%rbp)
cmp    -0x30(%rbp),%eax
jne    16ed <main+0x51d>
mov    -0x4074(%rbp),%eax
shl    $0x1,%eax
mov    %eax,-0x4074(%rbp)
mov    -0x54(%rbp),%eax
cmp    -0x4c(%rbp),%eax
jl     169a <main+0x4ca>
mov    -0x4074(%rbp),%eax
or     $0x1,%eax
mov    %eax,-0x4074(%rbp)
mov    -0x4078(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4078(%rbp)
cmp    $0x8,%eax
je     16bc <main+0x4ec>
cmpl   $0x0,-0x2c(%rbp)
je     16df <main+0x50f>
mov    -0x4074(%rbp),%edi
mov    -0x20(%rbp),%rsi
call   1070 <fputc@plt>
movl   $0x0,-0x4078(%rbp)
movl   $0x0,-0x4074(%rbp)
movl   $0x0,-0x54(%rbp)
movl   $0x0,-0x50(%rbp)
jmp    16f2 <main+0x522>
jmp    16f7 <main+0x527>
mov    -0x4070(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x4070(%rbp)
jmp    154c <main+0x37c>
jmp    150b <main+0x33b>
cmpl   $0x0,-0x28(%rbp)
je     1782 <main+0x5b2>
lea    0x989(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0x985(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x48(%rbp),%esi
lea    0x97e(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x44(%rbp),%esi
lea    0x989(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x40(%rbp),%esi
lea    0x994(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x3c(%rbp),%esi
lea    0x99d(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    17bc <main+0x5ec>
cmpl   $0x0,-0x4078(%rbp)
je     17b7 <main+0x5e7>
mov    $0x8,%ecx
sub    -0x4078(%rbp),%ecx
mov    -0x4074(%rbp),%eax
shl    %cl,%eax
mov    %eax,-0x4074(%rbp)
mov    -0x4074(%rbp),%edi
mov    -0x20(%rbp),%rsi
call   1070 <fputc@plt>
jmp    17bc <main+0x5ec>
mov    -0x18(%rbp),%rax
mov    0x2819(%rip),%rcx
cmp    (%rcx),%rax
je     17d9 <main+0x609>
mov    -0x18(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x20(%rbp),%rax
mov    0x27d4(%rip),%rcx
cmp    (%rcx),%rax
je     17f6 <main+0x626>
mov    -0x20(%rbp),%rdi
call   1040 <fclose@plt>
mov    0x27b3(%rip),%rax
mov    (%rax),%eax
add    $0x4080,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x4048,%rsp
mov    %rsi,%rbx
mov    %edi,%ebp
mov    0x2df3(%rip),%rax
mov    (%rax),%r15
mov    0x2dc1(%rip),%rax
mov    (%rax),%rax
mov    %rax,0x20(%rsp)
mov    $0x4000,%ecx
xor    %eax,%eax
mov    %rax,0x8(%rsp)
lea    0xe42(%rip),%r14
mov    0x2ddf(%rip),%r12
lea    0xde0(%rip),%r13
movl   $0x0,0x1c(%rsp)
mov    $0x1,%edx
mov    %rdx,(%rsp)
mov    %rcx,0x10(%rsp)
cs nopw 0x0(%rax,%rax,1)
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %r14,%rdx
call   10e0 <getopt@plt>
cmp    $0x74,%eax
jne    1270 <main+0xa0>
mov    (%r12),%edi
xor    %esi,%esi
xor    %edx,%edx
call   10a0 <strtol@plt>
mov    %rax,0x10(%rsp)
jmp    1240 <main+0x70>
cs nopw 0x0(%rax,%rax,1)
lea    -0x61(%rax),%ecx
cmp    $0x14,%ecx
ja     12cd <main+0xfd>
movslq 0x0(%r13,%rcx,4),%rax
add    %r13,%rax
mov    0x10(%rsp),%rcx
mov    (%rsp),%rdx
jmp    *%rax
mov    (%r12),%edi
xor    %esi,%esi
xor    %edx,%edx
call   10a0 <strtol@plt>
mov    0x10(%rsp),%rcx
test   %eax,%eax
mov    $0x1,%edx
cmovle %edx,%eax
mov    %rax,(%rsp)
jmp    1231 <main+0x61>
nopl   (%rax)
mov    $0x1,%al
mov    %rax,0x8(%rsp)
jmp    122d <main+0x5d>
nopl   0x0(%rax)
movl   $0x1,0x1c(%rsp)
jmp    122d <main+0x5d>
cmp    $0xffffffff,%eax
mov    (%rsp),%rdx
jne    1602 <main+0x432>
mov    0x2cf7(%rip),%r14
mov    (%r14),%eax
mov    %ebp,%ecx
sub    %eax,%ecx
cmp    $0x3,%ecx
jge    15ed <main+0x41d>
test   %ecx,%ecx
mov    %r15,%r12
jle    133b <main+0x16b>
cltq
mov    (%rbx,%rax,8),%rdi
lea    0xe22(%rip),%rsi
call   1080 <strcmp@plt>
test   %rax,%rax
je     132e <main+0x15e>
movslq (%r14),%rax
mov    (%rbx,%rax,8),%rdi
lea    0xd53(%rip),%rsi
call   10c0 <fopen@plt>
mov    %rax,%r12
test   %rax,%rax
je     1618 <main+0x448>
mov    (%r14),%eax
add    $0x1,%eax
mov    %eax,(%r14)
mov    (%rsp),%rdx
cmp    %ebp,%eax
setge  %cl
or     0x8(%rsp),%cl
test   $0x1,%cl
jne    1389 <main+0x1b9>
cltq
mov    (%rbx,%rax,8),%rdi
lea    0xdd1(%rip),%rsi
call   1080 <strcmp@plt>
test   %rax,%rax
je     1381 <main+0x1b1>
movslq (%r14),%rax
mov    (%rbx,%rax,8),%rdi
lea    0xd1f(%rip),%rsi
call   10c0 <fopen@plt>
mov    %rax,0x20(%rsp)
test   %rax,%rax
je     1621 <main+0x451>
addl   $0x1,(%r14)
mov    (%rsp),%rdx
mov    %edx,%eax
shr    %eax
cmp    $0x1,%edx
cmove  %edx,%eax
mov    %eax,0x2c(%rsp)
lea    0x40(%rsp),%rdi
mov    $0x1,%esi
mov    $0x4000,%edx
mov    %r12,%rcx
call   1040 <fread@plt>
test   %rax,%rax
je     1512 <main+0x342>
mov    %rax,%r13
mov    %r12,0x30(%rsp)
xor    %edi,%edi
xor    %r10d,%r10d
xor    %r14d,%r14d
xor    %r12d,%r12d
xor    %ebp,%ebp
xor    %r8d,%r8d
xor    %edx,%edx
xor    %r15d,%r15d
mov    0x8(%rsp),%rsi
jmp    1428 <main+0x258>
nopl   0x0(%rax,%rax,1)
mov    %rdi,0x38(%rsp)
mov    %edx,0x28(%rsp)
lea    0x40(%rsp),%rdi
mov    $0x1,%esi
mov    $0x4000,%edx
mov    0x30(%rsp),%rcx
mov    %r8d,%ebx
mov    %r10,%r13
call   1040 <fread@plt>
mov    0x38(%rsp),%rdi
mov    %r13,%r10
mov    0x28(%rsp),%edx
mov    %ebx,%r8d
mov    0x8(%rsp),%rsi
mov    %rax,%r13
test   %rax,%rax
je     14e2 <main+0x312>
cmp    $0x2,%r13
jb     13e0 <main+0x210>
shr    %r13
xor    %ebx,%ebx
mov    0x10(%rsp),%r9
mov    (%rsp),%r11
jmp    146b <main+0x29b>
xchg   %ax,%ax
mov    %edx,%ecx
cmp    %rcx,%rax
cmova  %eax,%edx
mov    %r15d,%ecx
cmp    %rcx,%rax
cmovb  %eax,%r15d
cmp    %eax,%ebp
cmovl  %eax,%ebp
cmp    %eax,%r8d
cmovg  %eax,%r8d
add    $0x1,%rbx
cmp    %rbx,%r13
je     13e0 <main+0x210>
mov    0x40(%rsp,%rbx,8),%rax
test   $0x1,%sil
jne    1440 <main+0x270>
cmp    %rax,%r9
adc    $0x0,%r14d
add    $0x1,%r12d
cmp    %r11d,%r12d
jne    145e <main+0x28e>
xor    %eax,%eax
cmp    0x2c(%rsp),%r14d
setge  %al
lea    (%rax,%r10,2),%r10d
add    $0x1,%edi
cmp    $0x8,%edi
je     14ab <main+0x2db>
xor    %r12d,%r12d
cmpl   $0x0,0x1c(%rsp)
jne    14ab <main+0x2db>
xor    %r14d,%r14d
jmp    145e <main+0x28e>
mov    %r10d,%edi
mov    0x20(%rsp),%rsi
mov    %r8d,%r14d
mov    %edx,%r12d
call   1070 <fputc@plt>
mov    %r12d,%edx
mov    %r14d,%r8d
mov    (%rsp),%r11
mov    0x10(%rsp),%r9
mov    0x8(%rsp),%rsi
xor    %r12d,%r12d
xor    %r14d,%r14d
xor    %r10d,%r10d
xor    %edi,%edi
jmp    145e <main+0x28e>
test   $0x1,%sil
mov    0x20(%rsp),%rbx
mov    0x30(%rsp),%r12
jne    1531 <main+0x361>
test   %edi,%edi
je     1594 <main+0x3c4>
mov    $0x8,%cl
sub    %dil,%cl
shl    %cl,%r10d
mov    %r10d,%edi
mov    %rbx,%rsi
call   1070 <fputc@plt>
jmp    1594 <main+0x3c4>
xor    %ebp,%ebp
mov    $0x0,%r8d
mov    $0x0,%edx
mov    $0x0,%r15d
testb  $0x1,0x8(%rsp)
mov    0x20(%rsp),%rbx
je     1594 <main+0x3c4>
lea    0xbdf(%rip),%rdi
mov    %ebp,%r14d
mov    %r8d,%r13d
mov    %edx,%ebp
call   1030 <puts@plt>
lea    0xbd4(%rip),%rdi
call   1030 <puts@plt>
lea    0xb53(%rip),%rdi
mov    %r15d,%esi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xb5e(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xb6a(%rip),%rdi
mov    %r13d,%esi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xb73(%rip),%rdi
mov    %r14d,%esi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x2a45(%rip),%rax
cmp    (%rax),%r12
je     15a8 <main+0x3d8>
mov    %r12,%rdi
call   1050 <fclose@plt>
mov    0x2a09(%rip),%rax
cmp    (%rax),%rbx
je     15bc <main+0x3ec>
mov    %rbx,%rdi
call   1050 <fclose@plt>
mov    0x29ed(%rip),%rax
mov    (%rax),%eax
add    $0x4048,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    (%rbx),%rdi
call   10b0 <usage@plt>
mov    0x29ca(%rip),%rax
mov    (%rax),%edi
call   10f0 <exit@plt>
mov    0x29d4(%rip),%rax
mov    (%rax),%edi
lea    0xa5f(%rip),%rsi
call   1090 <fprintf@plt>
mov    (%rbx),%rdi
call   10b0 <usage@plt>
mov    0x29af(%rip),%rax
mov    (%rax),%edi
call   10f0 <exit@plt>
lea    0xa54(%rip),%rdi
jmp    163c <main+0x46c>
mov    0x29b8(%rip),%rax
cmp    (%rax),%r12
je     1635 <main+0x465>
mov    %r12,%rdi
call   1050 <fclose@plt>
lea    0xa54(%rip),%rdi
call   10d0 <perror@plt>
jmp    160a <main+0x43a>

LLVM IR (-O0):
%struct.anon = type { i32, i32, i32, i32 }
@stdin = global i32* null
@stdout = global i32* null
@.str = [8 x i8] c"ad:t:uh\00"
@optarg = global i32 0
@EXIT_SUCCESS = global i32 0
@EXIT_FAILURE = global i32 0
@optind = global i32 0
@stderr = global i32 0
@.str.1 = [20 x i8] c"Too many arguments\0A\00"
@.str.2 = [2 x i8] c"-\00"
@.str.3 = [3 x i8] c"rb\00"
@.str.4 = [26 x i8] c"Failed opening input file\00"
@.str.5 = [3 x i8] c"wb\00"
@.str.6 = [27 x i8] c"Failed opening output file\00"
@.str.7 = [10 x i8] c"Analysis\0A\00"
@.str.8 = [10 x i8] c"--------\0A\00"
@.str.9 = [28 x i8] c"Unsigned Minimal level: %u\0A\00"
@.str.10 = [28 x i8] c"Unsigned Maximum level: %u\0A\00"
@.str.11 = [26 x i8] c"Signed Minimal level: %u\0A\00"
@.str.12 = [26 x i8] c"Signed Maximum level: %u\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 i32
%11 = alloca i32
%12 = alloca i8*
%13 = alloca %struct.anon
%14 = alloca i32
%15 = alloca i32
%16 = alloca i32
%17 = alloca i64
%18 = alloca [4096 x i32]
%19 = alloca i8**
%20 = alloca i64
%21 = alloca i32
%22 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%23 = load i32*, i32** @stdin
store i32* %23, i32** %6
%24 = load i32*, i32** @stdout
store i32* %24, i32** %7
store i32 0, i32* %9
store i32 0, i32* %10
store i32 1, i32* %11
store i8* inttoptr (i64 16384 to i8*), i8** %12
%25 = bitcast %struct.anon* %13 to i8*
store i32 1, i32* %14
store i32 0, i32* %15
store i32 0, i32* %16
br label %26
26: ; preds = %60, %2
%27 = load i32, i32* %4
%28 = load i8**, i8*** %5
%29 = call i32 @getopt(i32 %27, i8** %28, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
store i32 %29, i32* %8
%30 = icmp ne i32 %29, -1
br i1 %30, label %31, label %61
31: ; preds = %26
%32 = load i32, i32* %8
switch i32 %32, label %53 [
i32 97, label %33
i32 100, label %34
i32 116, label %42
i32 117, label %45
i32 104, label %46
]
33: ; preds = %31
store i32 1, i32* %9
br label %60
34: ; preds = %31
%35 = load i32, i32* @optarg
%36 = call i8* @strtol(i32 %35, i32* null, i32 0)
%37 = ptrtoint i8* %36 to i32
store i32 %37, i32* %11
%38 = load i32, i32* %11
%39 = icmp sle i32 %38, 0
br i1 %39, label %40, label %41
40: ; preds = %34
store i32 1, i32* %11
br label %41
41: ; preds = %40, %34
br label %60
42: ; preds = %31
%43 = load i32, i32* @optarg
%44 = call i8* @strtol(i32 %43, i32* null, i32 0)
store i8* %44, i8** %12
br label %60
45: ; preds = %31
store i32 1, i32* %10
br label %60
46: ; preds = %31
%47 = load i8**, i8*** %5
%48 = getelementptr inbounds i8*, i8** %47, i64 0
%49 = load i8*, i8** %48
%50 = call i32 @usage(i8* %49)
%51 = load i32, i32* @EXIT_SUCCESS
%52 = call i32 @exit(i32 %51)
unreachable
53: ; preds = %31
%54 = load i8**, i8*** %5
%55 = getelementptr inbounds i8*, i8** %54, i64 0
%56 = load i8*, i8** %55
%57 = call i32 @usage(i8* %56)
%58 = load i32, i32* @EXIT_FAILURE
%59 = call i32 @exit(i32 %58)
unreachable
60: ; preds = %45, %42, %41, %33
br label %26
61: ; preds = %26
%62 = load i32, i32* %4
%63 = load i32, i32* @optind
%64 = sub nsw i32 %62, %63
%65 = icmp sgt i32 %64, 2
br i1 %65, label %66, label %75
66: ; preds = %61
%67 = load i32, i32* @stderr
%68 = call i32 @fprintf(i32 %67, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0))
%69 = load i8**, i8*** %5
%70 = getelementptr inbounds i8*, i8** %69, i64 0
%71 = load i8*, i8** %70
%72 = call i32 @usage(i8* %71)
%73 = load i32, i32* @EXIT_FAILURE
%74 = call i32 @exit(i32 %73)
unreachable
75: ; preds = %61
%76 = load i32, i32* %4
%77 = load i32, i32* @optind
%78 = sub nsw i32 %76, %77
%79 = icmp sgt i32 %78, 0
br i1 %79, label %80, label %104
80: ; preds = %75
%81 = load i8**, i8*** %5
%82 = load i32, i32* @optind
%83 = sext i32 %82 to i64
%84 = getelementptr inbounds i8*, i8** %81, i64 %83
%85 = load i8*, i8** %84
%86 = call i64 @strcmp(i8* %85, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%87 = icmp ne i64 %86, 0
br i1 %87, label %88, label %101
88: ; preds = %80
%89 = load i8**, i8*** %5
%90 = load i32, i32* @optind
%91 = sext i32 %90 to i64
%92 = getelementptr inbounds i8*, i8** %89, i64 %91
%93 = load i8*, i8** %92
%94 = call i32* @fopen(i8* %93, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
store i32* %94, i32** %6
%95 = icmp eq i32* %94, null
br i1 %95, label %96, label %100
96: ; preds = %88
%97 = call i32 @perror(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.4, i64 0, i64 0))
%98 = load i32, i32* @EXIT_FAILURE
%99 = call i32 @exit(i32 %98)
unreachable
100: ; preds = %88
br label %101
101: ; preds = %100, %80
%102 = load i32, i32* @optind
%103 = add nsw i32 %102, 1
store i32 %103, i32* @optind
br label %104
104: ; preds = %101, %75
%105 = load i32, i32* %4
%106 = load i32, i32* @optind
%107 = sub nsw i32 %105, %106
%108 = icmp sgt i32 %107, 0
br i1 %108, label %109, label %143
109: ; preds = %104
%110 = load i32, i32* %9
%111 = icmp ne i32 %110, 0
br i1 %111, label %143, label %112
112: ; preds = %109
%113 = load i8**, i8*** %5
%114 = load i32, i32* @optind
%115 = sext i32 %114 to i64
%116 = getelementptr inbounds i8*, i8** %113, i64 %115
%117 = load i8*, i8** %116
%118 = call i64 @strcmp(i8* %117, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%119 = icmp ne i64 %118, 0
br i1 %119, label %120, label %140
120: ; preds = %112
%121 = load i8**, i8*** %5
%122 = load i32, i32* @optind
%123 = sext i32 %122 to i64
%124 = getelementptr inbounds i8*, i8** %121, i64 %123
%125 = load i8*, i8** %124
%126 = call i32* @fopen(i8* %125, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0))
store i32* %126, i32** %7
%127 = icmp eq i32* %126, null
br i1 %127, label %128, label %139
128: ; preds = %120
%129 = load i32*, i32** %6
%130 = load i32*, i32** @stdin
%131 = icmp ne i32* %129, %130
br i1 %131, label %132, label %135
132: ; preds = %128
%133 = load i32*, i32** %6
%134 = call i32 @fclose(i32* %133)
br label %135
135: ; preds = %132, %128
%136 = call i32 @perror(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.6, i64 0, i64 0))
%137 = load i32, i32* @EXIT_FAILURE
%138 = call i32 @exit(i32 %137)
unreachable
139: ; preds = %120
br label %140
140: ; preds = %139, %112
%141 = load i32, i32* @optind
%142 = add nsw i32 %141, 1
store i32 %142, i32* @optind
br label %143
143: ; preds = %140, %109, %104
%144 = load i32, i32* %11
%145 = icmp ne i32 %144, 1
br i1 %145, label %146, label %149
146: ; preds = %143
%147 = load i32, i32* %11
%148 = ashr i32 %147, 1
store i32 %148, i32* %14
br label %149
149: ; preds = %146, %143
store i32 0, i32* %21
store i32 0, i32* %22
store i32 0, i32* %16
store i32 0, i32* %15
br label %150
150: ; preds = %274, %149
%151 = getelementptr inbounds [4096 x i32], [4096 x i32]* %18, i64 0, i64 0
%152 = load i32*, i32** %6
%153 = call i64 @fread(i32* %151, i32 1, i32 16384, i32* %152)
store i64 %153, i64* %17
%154 = icmp ugt i64 %153, 0
br i1 %154, label %155, label %275
155: ; preds = %150
%156 = getelementptr inbounds [4096 x i32], [4096 x i32]* %18, i64 0, i64 0
%157 = bitcast i32* %156 to i8**
store i8** %157, i8*** %19
store i64 0, i64* %20
br label %158
158: ; preds = %271, %155
%159 = load i64, i64* %20
%160 = load i64, i64* %17
%161 = udiv i64 %160, 2
%162 = icmp ult i64 %159, %161
br i1 %162, label %163, label %274
163: ; preds = %158
%164 = load i32, i32* %9
%165 = icmp ne i32 %164, 0
br i1 %165, label %166, label %233
166: ; preds = %163
%167 = load i8**, i8*** %19
%168 = load i64, i64* %20
%169 = getelementptr inbounds i8*, i8** %167, i64 %168
%170 = load i8*, i8** %169
%171 = getelementptr inbounds %struct.anon, %struct.anon* %13, i32 0, i32 1
%172 = load i32, i32* %171
%173 = zext i32 %172 to i64
%174 = inttoptr i64 %173 to i8*
%175 = icmp ugt i8* %170, %174
br i1 %175, label %176, label %183
176: ; preds = %166
%177 = load i8**, i8*** %19
%178 = load i64, i64* %20
%179 = getelementptr inbounds i8*, i8** %177, i64 %178
%180 = load i8*, i8** %179
%181 = ptrtoint i8* %180 to i32
%182 = getelementptr inbounds %struct.anon, %struct.anon* %13, i32 0, i32 1
store i32 %181, i32* %182
br label %183
183: ; preds = %176, %166
%184 = load i8**, i8*** %19
%185 = load i64, i64* %20
%186 = getelementptr inbounds i8*, i8** %184, i64 %185
%187 = load i8*, i8** %186
%188 = getelementptr inbounds %struct.anon, %struct.anon* %13, i32 0, i32 0
%189 = load i32, i32* %188
%190 = zext i32 %189 to i64
%191 = inttoptr i64 %190 to i8*
%192 = icmp ult i8* %187, %191
br i1 %192, label %193, label %200
193: ; preds = %183
%194 = load i8**, i8*** %19
%195 = load i64, i64* %20
%196 = getelementptr inbounds i8*, i8** %194, i64 %195
%197 = load i8*, i8** %196
%198 = ptrtoint i8* %197 to i32
%199 = getelementptr inbounds %struct.anon, %struct.anon* %13, i32 0, i32 0
store i32 %198, i32* %199
br label %200
200: ; preds = %193, %183
%201 = load i8**, i8*** %19
%202 = load i64, i64* %20
%203 = getelementptr inbounds i8*, i8** %201, i64 %202
%204 = load i8*, i8** %203
%205 = ptrtoint i8* %204 to i32
%206 = getelementptr inbounds %struct.anon, %struct.anon* %13, i32 0, i32 3
%207 = load i32, i32* %206
%208 = icmp sgt i32 %205, %207
br i1 %208, label %209, label %216
209: ; preds = %200
%210 = load i8**, i8*** %19
%211 = load i64, i64* %20
%212 = getelementptr inbounds i8*, i8** %210, i64 %211
%213 = load i8*, i8** %212
%214 = ptrtoint i8* %213 to i32
%215 = getelementptr inbounds %struct.anon, %struct.anon* %13, i32 0, i32 3
store i32 %214, i32* %215
br label %216
216: ; preds = %209, %200
%217 = load i8**, i8*** %19
%218 = load i64, i64* %20
%219 = getelementptr inbounds i8*, i8** %217, i64 %218
%220 = load i8*, i8** %219
%221 = ptrtoint i8* %220 to i32
%222 = getelementptr inbounds %struct.anon, %struct.anon* %13, i32 0, i32 2
%223 = load i32, i32* %222
%224 = icmp slt i32 %221, %223
br i1 %224, label %225, label %232
225: ; preds = %216
%226 = load i8**, i8*** %19
%227 = load i64, i64* %20
%228 = getelementptr inbounds i8*, i8** %226, i64 %227
%229 = load i8*, i8** %228
%230 = ptrtoint i8* %229 to i32
%231 = getelementptr inbounds %struct.anon, %struct.anon* %13, i32 0, i32 2
store i32 %230, i32* %231
br label %232
232: ; preds = %225, %216
br label %270
233: ; preds = %163
%234 = load i8**, i8*** %19
%235 = load i64, i64* %20
%236 = getelementptr inbounds i8*, i8** %234, i64 %235
%237 = load i8*, i8** %236
%238 = load i8*, i8** %12
%239 = icmp ugt i8* %237, %238
br i1 %239, label %240, label %243
240: ; preds = %233
%241 = load i32, i32* %16
%242 = add nsw i32 %241, 1
store i32 %242, i32* %16
br label %243
243: ; preds = %240, %233
%244 = load i32, i32* %15
%245 = add nsw i32 %244, 1
store i32 %245, i32* %15
%246 = load i32, i32* %11
%247 = icmp eq i32 %245, %246
br i1 %247, label %248, label %269
248: ; preds = %243
%249 = load i32, i32* %21
%250 = shl i32 %249, 1
store i32 %250, i32* %21
%251 = load i32, i32* %16
%252 = load i32, i32* %14
%253 = icmp sge i32 %251, %252
br i1 %253, label %254, label %257
254: ; preds = %248
%255 = load i32, i32* %21
%256 = or i32 %255, 1
store i32 %256, i32* %21
br label %257
257: ; preds = %254, %248
%258 = load i32, i32* %22
%259 = add nsw i32 %258, 1
store i32 %259, i32* %22
%260 = icmp eq i32 %259, 8
br i1 %260, label %264, label %261
261: ; preds = %257
%262 = load i32, i32* %10
%263 = icmp ne i32 %262, 0
br i1 %263, label %264, label %268
264: ; preds = %261, %257
%265 = load i32, i32* %21
%266 = load i32*, i32** %7
%267 = call i32 @fputc(i32 %265, i32* %266)
store i32 0, i32* %22
store i32 0, i32* %21
br label %268
268: ; preds = %264, %261
store i32 0, i32* %16
store i32 0, i32* %15
br label %269
269: ; preds = %268, %243
br label %270
270: ; preds = %269, %232
br label %271
271: ; preds = %270
%272 = load i64, i64* %20
%273 = add i64 %272, 1
store i64 %273, i64* %20
br label %158
274: ; preds = %158
br label %150
275: ; preds = %150
%276 = load i32, i32* %9
%277 = icmp ne i32 %276, 0
br i1 %277, label %278, label %293
278: ; preds = %275
%279 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.7, i64 0, i64 0))
%280 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.8, i64 0, i64 0))
%281 = getelementptr inbounds %struct.anon, %struct.anon* %13, i32 0, i32 0
%282 = load i32, i32* %281
%283 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.9, i64 0, i64 0), i32 %282)
%284 = getelementptr inbounds %struct.anon, %struct.anon* %13, i32 0, i32 1
%285 = load i32, i32* %284
%286 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.10, i64 0, i64 0), i32 %285)
%287 = getelementptr inbounds %struct.anon, %struct.anon* %13, i32 0, i32 2
%288 = load i32, i32* %287
%289 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.11, i64 0, i64 0), i32 %288)
%290 = getelementptr inbounds %struct.anon, %struct.anon* %13, i32 0, i32 3
%291 = load i32, i32* %290
%292 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.12, i64 0, i64 0), i32 %291)
br label %305
293: ; preds = %275
%294 = load i32, i32* %22
%295 = icmp ne i32 %294, 0
br i1 %295, label %296, label %304
296: ; preds = %293
%297 = load i32, i32* %22
%298 = sub nsw i32 8, %297
%299 = load i32, i32* %21
%300 = shl i32 %299, %298
store i32 %300, i32* %21
%301 = load i32, i32* %21
%302 = load i32*, i32** %7
%303 = call i32 @fputc(i32 %301, i32* %302)
br label %304
304: ; preds = %296, %293
br label %305
305: ; preds = %304, %278
%306 = load i32*, i32** %6
%307 = load i32*, i32** @stdin
%308 = icmp ne i32* %306, %307
br i1 %308, label %309, label %312
309: ; preds = %305
%310 = load i32*, i32** %6
%311 = call i32 @fclose(i32* %310)
br label %312
312: ; preds = %309, %305
%313 = load i32*, i32** %7
%314 = load i32*, i32** @stdout
%315 = icmp ne i32* %313, %314
br i1 %315, label %316, label %319
316: ; preds = %312
%317 = load i32*, i32** %7
%318 = call i32 @fclose(i32* %317)
br label %319
319: ; preds = %316, %312
%320 = load i32, i32* @EXIT_SUCCESS
ret i32 %320
}

LLVM IR (-O2):
@stdin = global i32* null
@stdout = global i32* null
@.str = [8 x i8] c"ad:t:uh\00"
@optarg = global i32 0
@EXIT_SUCCESS = global i32 0
@EXIT_FAILURE = global i32 0
@optind = global i32 0
@stderr = global i32 0
@.str.1 = [20 x i8] c"Too many arguments\0A\00"
@.str.2 = [2 x i8] c"-\00"
@.str.3 = [3 x i8] c"rb\00"
@.str.4 = [26 x i8] c"Failed opening input file\00"
@.str.5 = [3 x i8] c"wb\00"
@.str.6 = [27 x i8] c"Failed opening output file\00"
@.str.9 = [28 x i8] c"Unsigned Minimal level: %u\0A\00"
@.str.10 = [28 x i8] c"Unsigned Maximum level: %u\0A\00"
@.str.11 = [26 x i8] c"Signed Minimal level: %u\0A\00"
@.str.12 = [26 x i8] c"Signed Maximum level: %u\0A\00"
@str = [9 x i8] c"Analysis\00"
@str.13 = [9 x i8] c"--------\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca [4096 x i32]
%4 = load i32*, i32** @stdin
%5 = load i32*, i32** @stdout
%6 = bitcast [4096 x i32]* %3 to i8*
br label %7
7: ; preds = %19, %2
%8 = phi i1 [ false, %2 ], [ true, %19 ]
%9 = phi i32 [ 0, %2 ], [ %13, %19 ]
%10 = phi i32 [ 1, %2 ], [ %17, %19 ]
%11 = phi i8* [ inttoptr (i64 16384 to i8*), %2 ], [ %20, %19 ]
br label %12
12: ; preds = %19, %7
%13 = phi i32 [ %9, %7 ], [ 1, %19 ]
%14 = phi i32 [ %10, %7 ], [ %17, %19 ]
%15 = phi i8* [ %11, %7 ], [ %20, %19 ]
br label %16
16: ; preds = %12, %22
%17 = phi i32 [ %14, %12 ], [ %28, %22 ]
%18 = phi i8* [ %15, %12 ], [ %20, %22 ]
br label %19
19: ; preds = %16, %29
%20 = phi i8* [ %31, %29 ], [ %18, %16 ]
%21 = tail call i32 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
switch i32 %21, label %37 [
i32 -1, label %42
i32 97, label %7
i32 100, label %22
i32 116, label %29
i32 117, label %12
i32 104, label %32
]
22: ; preds = %19
%23 = load i32, i32* @optarg
%24 = tail call i8* @strtol(i32 %23, i32* null, i32 0)
%25 = ptrtoint i8* %24 to i64
%26 = trunc i64 %25 to i32
%27 = icmp sgt i32 %26, 1
%28 = select i1 %27, i32 %26, i32 1
br label %16
29: ; preds = %19
%30 = load i32, i32* @optarg
%31 = tail call i8* @strtol(i32 %30, i32* null, i32 0)
br label %19
32: ; preds = %19
%33 = load i8*, i8** %1
%34 = tail call i32 @usage(i8* %33)
%35 = load i32, i32* @EXIT_SUCCESS
%36 = tail call i32 @exit(i32 %35)
unreachable
37: ; preds = %19
%38 = load i8*, i8** %1
%39 = tail call i32 @usage(i8* %38)
%40 = load i32, i32* @EXIT_FAILURE
%41 = tail call i32 @exit(i32 %40)
unreachable
42: ; preds = %19
%43 = load i32, i32* @optind
%44 = sub nsw i32 %0, %43
%45 = icmp sgt i32 %44, 2
br i1 %45, label %46, label %53
46: ; preds = %42
%47 = load i32, i32* @stderr
%48 = tail call i32 @fprintf(i32 %47, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0))
%49 = load i8*, i8** %1
%50 = tail call i32 @usage(i8* %49)
%51 = load i32, i32* @EXIT_FAILURE
%52 = tail call i32 @exit(i32 %51)
unreachable
53: ; preds = %42
%54 = icmp sgt i32 %44, 0
br i1 %54, label %55, label %76
55: ; preds = %53
%56 = sext i32 %43 to i64
%57 = getelementptr inbounds i8*, i8** %1, i64 %56
%58 = load i8*, i8** %57
%59 = tail call i64 @strcmp(i8* %58, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%60 = icmp eq i64 %59, 0
br i1 %60, label %72, label %61
61: ; preds = %55
%62 = load i32, i32* @optind
%63 = sext i32 %62 to i64
%64 = getelementptr inbounds i8*, i8** %1, i64 %63
%65 = load i8*, i8** %64
%66 = tail call i32* @fopen(i8* %65, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%67 = icmp eq i32* %66, null
br i1 %67, label %68, label %72
68: ; preds = %61
%69 = tail call i32 @perror(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.4, i64 0, i64 0))
%70 = load i32, i32* @EXIT_FAILURE
%71 = tail call i32 @exit(i32 %70)
unreachable
72: ; preds = %61, %55
%73 = phi i32* [ %66, %61 ], [ %4, %55 ]
%74 = load i32, i32* @optind
%75 = add nsw i32 %74, 1
store i32 %75, i32* @optind
br label %76
76: ; preds = %72, %53
%77 = phi i32 [ %75, %72 ], [ %43, %53 ]
%78 = phi i32* [ %73, %72 ], [ %4, %53 ]
%79 = icmp sge i32 %77, %0
%80 = or i1 %79, %8
br i1 %80, label %107, label %81
81: ; preds = %76
%82 = sext i32 %77 to i64
%83 = getelementptr inbounds i8*, i8** %1, i64 %82
%84 = load i8*, i8** %83
%85 = tail call i64 @strcmp(i8* %84, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%86 = icmp eq i64 %85, 0
br i1 %86, label %103, label %87
87: ; preds = %81
%88 = load i32, i32* @optind
%89 = sext i32 %88 to i64
%90 = getelementptr inbounds i8*, i8** %1, i64 %89
%91 = load i8*, i8** %90
%92 = tail call i32* @fopen(i8* %91, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0))
%93 = icmp eq i32* %92, null
br i1 %93, label %94, label %103
94: ; preds = %87
%95 = load i32*, i32** @stdin
%96 = icmp eq i32* %78, %95
br i1 %96, label %99, label %97
97: ; preds = %94
%98 = tail call i32 @fclose(i32* %78)
br label %99
99: ; preds = %97, %94
%100 = tail call i32 @perror(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.6, i64 0, i64 0))
%101 = load i32, i32* @EXIT_FAILURE
%102 = tail call i32 @exit(i32 %101)
unreachable
103: ; preds = %87, %81
%104 = phi i32* [ %92, %87 ], [ %5, %81 ]
%105 = load i32, i32* @optind
%106 = add nsw i32 %105, 1
store i32 %106, i32* @optind
br label %107
107: ; preds = %103, %76
%108 = phi i32* [ %5, %76 ], [ %104, %103 ]
%109 = icmp eq i32 %17, 1
%110 = lshr i32 %17, 1
%111 = select i1 %109, i32 1, i32 %110
%112 = getelementptr inbounds [4096 x i32], [4096 x i32]* %3, i64 0, i64 0
%113 = call i64 @fread(i32* %112, i32 1, i32 16384, i32* %78)
%114 = icmp eq i64 %113, 0
br i1 %114, label %197, label %115
115: ; preds = %107
%116 = bitcast [4096 x i32]* %3 to i8**
%117 = icmp ne i32 %13, 0
br label %129
118: ; preds = %185, %129
%119 = phi i32 [ %138, %129 ], [ %186, %185 ]
%120 = phi i32 [ %137, %129 ], [ %187, %185 ]
%121 = phi i32 [ %136, %129 ], [ %188, %185 ]
%122 = phi i32 [ %135, %129 ], [ %189, %185 ]
%123 = phi i32 [ %134, %129 ], [ %190, %185 ]
%124 = phi i32 [ %133, %129 ], [ %191, %185 ]
%125 = phi i32 [ %132, %129 ], [ %192, %185 ]
%126 = phi i32 [ %131, %129 ], [ %193, %185 ]
%127 = call i64 @fread(i32* %112, i32 1, i32 16384, i32* %78)
%128 = icmp eq i64 %127, 0
br i1 %128, label %196, label %129
129: ; preds = %115, %118
%130 = phi i64 [ %113, %115 ], [ %127, %118 ]
%131 = phi i32 [ 0, %115 ], [ %126, %118 ]
%132 = phi i32 [ 0, %115 ], [ %125, %118 ]
%133 = phi i32 [ 0, %115 ], [ %124, %118 ]
%134 = phi i32 [ 0, %115 ], [ %123, %118 ]
%135 = phi i32 [ 0, %115 ], [ %122, %118 ]
%136 = phi i32 [ 0, %115 ], [ %121, %118 ]
%137 = phi i32 [ 0, %115 ], [ %120, %118 ]
%138 = phi i32 [ 0, %115 ], [ %119, %118 ]
%139 = icmp ult i64 %130, 2
br i1 %139, label %118, label %140
140: ; preds = %129
%141 = lshr i64 %130, 1
br label %142
142: ; preds = %140, %185
%143 = phi i32 [ %193, %185 ], [ %131, %140 ]
%144 = phi i32 [ %192, %185 ], [ %132, %140 ]
%145 = phi i64 [ %194, %185 ], [ 0, %140 ]
%146 = phi i32 [ %191, %185 ], [ %133, %140 ]
%147 = phi i32 [ %190, %185 ], [ %134, %140 ]
%148 = phi i32 [ %189, %185 ], [ %135, %140 ]
%149 = phi i32 [ %188, %185 ], [ %136, %140 ]
%150 = phi i32 [ %187, %185 ], [ %137, %140 ]
%151 = phi i32 [ %186, %185 ], [ %138, %140 ]
%152 = getelementptr inbounds i8*, i8** %116, i64 %145
%153 = load i8*, i8** %152
br i1 %8, label %154, label %169
154: ; preds = %142
%155 = zext i32 %150 to i64
%156 = inttoptr i64 %155 to i8*
%157 = icmp ugt i8* %153, %156
%158 = ptrtoint i8* %153 to i64
%159 = trunc i64 %158 to i32
%160 = select i1 %157, i32 %159, i32 %150
%161 = zext i32 %151 to i64
%162 = inttoptr i64 %161 to i8*
%163 = icmp ult i8* %153, %162
%164 = select i1 %163, i32 %159, i32 %151
%165 = icmp slt i32 %148, %159
%166 = select i1 %165, i32 %159, i32 %148
%167 = icmp sgt i32 %149, %159
%168 = select i1 %167, i32 %159, i32 %149
br label %185
169: ; preds = %142
%170 = icmp ugt i8* %153, %20
%171 = zext i1 %170 to i32
%172 = add nsw i32 %146, %171
%173 = add nsw i32 %147, 1
%174 = icmp eq i32 %173, %17
br i1 %174, label %175, label %185
175: ; preds = %169
%176 = shl i32 %144, 1
%177 = icmp sge i32 %172, %111
%178 = zext i1 %177 to i32
%179 = or i32 %176, %178
%180 = add nsw i32 %143, 1
%181 = icmp eq i32 %180, 8
%182 = select i1 %181, i1 true, i1 %117
br i1 %182, label %183, label %185
183: ; preds = %175
%184 = tail call i32 @fputc(i32 %179, i32* %108)
br label %185
185: ; preds = %154, %183, %175, %169
%186 = phi i32 [ %151, %169 ], [ %151, %175 ], [ %151, %183 ], [ %164, %154 ]
%187 = phi i32 [ %150, %169 ], [ %150, %175 ], [ %150, %183 ], [ %160, %154 ]
%188 = phi i32 [ %149, %169 ], [ %149, %175 ], [ %149, %183 ], [ %168, %154 ]
%189 = phi i32 [ %148, %169 ], [ %148, %175 ], [ %148, %183 ], [ %166, %154 ]
%190 = phi i32 [ %173, %169 ], [ 0, %175 ], [ 0, %183 ], [ %147, %154 ]
%191 = phi i32 [ %172, %169 ], [ 0, %175 ], [ 0, %183 ], [ %146, %154 ]
%192 = phi i32 [ %144, %169 ], [ %179, %175 ], [ 0, %183 ], [ %144, %154 ]
%193 = phi i32 [ %143, %169 ], [ %180, %175 ], [ 0, %183 ], [ %143, %154 ]
%194 = add nuw nsw i64 %145, 1
%195 = icmp eq i64 %194, %141
br i1 %195, label %118, label %142
196: ; preds = %118
br i1 %8, label %198, label %209
197: ; preds = %107
br i1 %8, label %198, label %215
198: ; preds = %197, %196
%199 = phi i32 [ 0, %197 ], [ %122, %196 ]
%200 = phi i32 [ 0, %197 ], [ %121, %196 ]
%201 = phi i32 [ 0, %197 ], [ %120, %196 ]
%202 = phi i32 [ 0, %197 ], [ %119, %196 ]
%203 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @str, i64 0, i64 0))
%204 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @str.13, i64 0, i64 0))
%205 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str.9, i64 0, i64 0), i32 %202)
%206 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str.10, i64 0, i64 0), i32 %201)
%207 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.11, i64 0, i64 0), i32 %200)
%208 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.12, i64 0, i64 0), i32 %199)
br label %215
209: ; preds = %196
%210 = icmp eq i32 %126, 0
br i1 %210, label %215, label %211
211: ; preds = %209
%212 = sub nsw i32 8, %126
%213 = shl i32 %125, %212
%214 = tail call i32 @fputc(i32 %213, i32* %108)
br label %215
215: ; preds = %197, %209, %211, %198
%216 = load i32*, i32** @stdin
%217 = icmp eq i32* %78, %216
br i1 %217, label %220, label %218
218: ; preds = %215
%219 = tail call i32 @fclose(i32* %78)
br label %220
220: ; preds = %218, %215
%221 = load i32*, i32** @stdout
%222 = icmp eq i32* %108, %221
br i1 %222, label %225, label %223
223: ; preds = %220
%224 = tail call i32 @fclose(i32* %108)
br label %225
225: ; preds = %223, %220
%226 = load i32, i32* @EXIT_SUCCESS
ret i32 %226
}