#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 atoi(char *);
int constrain(int /*<<< orphan*/, int, int);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char const *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, ...);
int fread(unsigned char *, int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ fwrite(unsigned char *, int, int, int /*<<< orphan*/ *);
int getopt(int, char **, char *);
scalar_t__ malloc(int);
char *optarg;
int optind;
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ *stdin;
int /*<<< orphan*/ *stdout;
scalar_t__ strcmp(char const *, char *);
int /*<<< orphan*/ usage(char *);
int main(int argc, char *argv[]) {
  FILE *input_file;
  FILE *output_file;
  int opt;
  int width = 0;
  int height = 0;
  int bytes_per_line = 0;
  int luminance_only = 0;
  int chrominance_only = 0;
  int swap_chrominance = 0;
  int image_size;
  int luminance_size;
  const char *output_filename = 0;
  const char *input_filename = 0;
  unsigned char *buffer;
  int column;
  int row;
  while ((opt = getopt(argc, argv, "w:h:b:o:lcs")) != -1) {
    switch (opt) {
    case 'w':
      width = atoi(optarg);
      break;
    case 'h':
      height = atoi(optarg);
      break;
    case 'b':
      bytes_per_line = atoi(optarg);
      break;
    case 'o':
      output_filename = optarg;
      break;
    case 'l':
      luminance_only = 1;
      break;
    case 'c':
      chrominance_only = 1;
      break;
    case 's':
      swap_chrominance = 1;
      break;
    default:
      usage(argv[0]);
      exit(-1);
    }
  }
  if (optind < argc)
    input_filename = argv[optind];
  if (width <= 0 || height <= 0) {
    fprintf(stderr, "ERROR: Must specify width and height of input image\n");
    usage(argv[0]);
    exit(-1);
  }
  if (bytes_per_line <= 0)
    bytes_per_line = width;
  if (input_filename == 0 || strcmp(input_filename, "-") == 0)
    input_file = stdin;
  else
    input_file = fopen(input_filename, "rb");
  if (input_file == 0) {
    fprintf(stderr, "Error opening %s\n", input_filename);
    exit(-1);
  }
  if (output_filename == 0 || strcmp(output_filename, "-") == 0)
    output_file = stdout;
  else
    output_file = fopen(output_filename, "wb");
  if (output_file == 0) {
    fprintf(stderr, "Error opening %s\n", output_filename);
    exit(-1);
  }
  image_size = bytes_per_line * height * 3 / 2;
  buffer = (unsigned char *)malloc(image_size);
  if (buffer == 0) {
    fprintf(stderr, "Not enough memory\n");
    exit(-1);
  }
  if (fread(buffer, 1, image_size, input_file) != image_size) {
    fprintf(stderr, "Input file not big enough\n");
    exit(-1);
  }
  fclose(input_file);
  fprintf(output_file, "P6\n%d %d\n255\n", width, height);
  luminance_size = bytes_per_line * height;
  for (row = 0; row < height; row++) {
    for (column = 0; column < width; column++) {
      unsigned char rgb[3];
      int y, cb, cr;
      int r, g, b;
      if (!chrominance_only)
        y = buffer[row * bytes_per_line + column];
      else
        y = 128;
      if (!luminance_only) {
        cb = buffer[luminance_size + (row / 2 * bytes_per_line) +
                    (column & ~1)] -
             128;
        cr =
            buffer[luminance_size + (row / 2 * bytes_per_line) + (column | 1)] -
            128;
        if (swap_chrominance) {
          int tmp = cb;
          cb = cr;
          cr = tmp;
        }
      }
      r = y + 91881 * cr / 65536;
      g = y - (22572 * cb + 46802 * cr) / 65536;
      b = y + 116130 * cb / 65536;
      r = constrain(0, r, 255);
      g = constrain(0, g, 255);
      b = constrain(0, b, 255);
      rgb[0] = (unsigned char)r;
      rgb[1] = (unsigned char)g;
      rgb[2] = (unsigned char)b;
      fwrite(rgb, 3, 1, output_file);
    }
  }
  fclose(output_file);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xb0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
movl   $0x0,-0x30(%rbp)
movl   $0x0,-0x34(%rbp)
movl   $0x0,-0x38(%rbp)
movl   $0x0,-0x3c(%rbp)
movq   $0x0,-0x50(%rbp)
movq   $0x0,-0x58(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xe37(%rip),%rdx
call   10b0 <getopt@plt>
mov    %eax,-0x24(%rbp)
cmp    $0xffffffff,%eax
je     12f8 <main+0x138>
mov    -0x24(%rbp),%eax
add    $0xffffff9e,%eax
mov    %eax,%ecx
mov    %rcx,-0x90(%rbp)
sub    $0x15,%eax
ja     12dd <main+0x11d>
mov    -0x90(%rbp),%rax
lea    0xda8(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    0x2d90(%rip),%rax
mov    (%rax),%rdi
call   10c0 <atoi@plt>
mov    %eax,-0x28(%rbp)
jmp    12f3 <main+0x133>
mov    0x2d79(%rip),%rax
mov    (%rax),%rdi
call   10c0 <atoi@plt>
mov    %eax,-0x2c(%rbp)
jmp    12f3 <main+0x133>
mov    0x2d62(%rip),%rax
mov    (%rax),%rdi
call   10c0 <atoi@plt>
mov    %eax,-0x30(%rbp)
jmp    12f3 <main+0x133>
mov    0x2d4b(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x50(%rbp)
jmp    12f3 <main+0x133>
movl   $0x1,-0x34(%rbp)
jmp    12f3 <main+0x133>
movl   $0x1,-0x38(%rbp)
jmp    12f3 <main+0x133>
movl   $0x1,-0x3c(%rbp)
jmp    12f3 <main+0x133>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1090 <usage@plt>
mov    $0xffffffff,%edi
call   10d0 <exit@plt>
jmp    1213 <main+0x53>
mov    0x2cd9(%rip),%rax
mov    (%rax),%eax
cmp    -0x8(%rbp),%eax
jge    1320 <main+0x160>
mov    -0x10(%rbp),%rax
mov    0x2cc3(%rip),%rcx
movslq (%rcx),%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x58(%rbp)
cmpl   $0x0,-0x28(%rbp)
jle    1334 <main+0x174>
cmpl   $0x0,-0x2c(%rbp)
jg     1362 <main+0x1a2>
mov    0x2c8d(%rip),%rax
movslq (%rax),%rdi
lea    0xd1f(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1090 <usage@plt>
mov    $0xffffffff,%edi
call   10d0 <exit@plt>
cmpl   $0x0,-0x30(%rbp)
jg     1372 <main+0x1b2>
mov    -0x28(%rbp),%eax
mov    %eax,-0x30(%rbp)
cmpq   $0x0,-0x58(%rbp)
je     1397 <main+0x1d7>
mov    -0x58(%rbp),%rdi
lea    0xd11(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jne    13aa <main+0x1ea>
mov    0x2c42(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x18(%rbp)
jmp    13be <main+0x1fe>
mov    -0x58(%rbp),%rdi
lea    0xce6(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    13ef <main+0x22f>
mov    0x2bf8(%rip),%rax
movslq (%rax),%rdi
mov    -0x58(%rbp),%rdx
lea    0xcc0(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    $0xffffffff,%edi
call   10d0 <exit@plt>
cmpq   $0x0,-0x50(%rbp)
je     1414 <main+0x254>
mov    -0x50(%rbp),%rdi
lea    0xc94(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jne    1427 <main+0x267>
mov    0x2ba5(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x20(%rbp)
jmp    143b <main+0x27b>
mov    -0x50(%rbp),%rdi
lea    0xc7e(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    146c <main+0x2ac>
mov    0x2b7b(%rip),%rax
movslq (%rax),%rdi
mov    -0x50(%rbp),%rdx
lea    0xc43(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    $0xffffffff,%edi
call   10d0 <exit@plt>
mov    -0x30(%rbp),%eax
imul   -0x2c(%rbp),%eax
imul   $0x3,%eax,%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,-0x40(%rbp)
mov    -0x40(%rbp),%edi
call   1070 <malloc@plt>
mov    %rax,-0x60(%rbp)
cmpq   $0x0,-0x60(%rbp)
jne    14ba <main+0x2fa>
mov    0x2b29(%rip),%rax
movslq (%rax),%rdi
lea    0xc0a(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    $0xffffffff,%edi
call   10d0 <exit@plt>
mov    -0x60(%rbp),%rdi
mov    -0x40(%rbp),%edx
mov    -0x18(%rbp),%rcx
mov    $0x1,%esi
call   1030 <fread@plt>
cmp    -0x40(%rbp),%eax
je     14fa <main+0x33a>
mov    0x2ae9(%rip),%rax
movslq (%rax),%rdi
lea    0xbdd(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    $0xffffffff,%edi
call   10d0 <exit@plt>
mov    -0x18(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x20(%rbp),%rdi
mov    -0x28(%rbp),%edx
mov    -0x2c(%rbp),%ecx
lea    0xbcd(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    -0x30(%rbp),%eax
imul   -0x2c(%rbp),%eax
mov    %eax,-0x44(%rbp)
movl   $0x0,-0x68(%rbp)
mov    -0x68(%rbp),%eax
cmp    -0x2c(%rbp),%eax
jge    172c <main+0x56c>
movl   $0x0,-0x64(%rbp)
mov    -0x64(%rbp),%eax
cmp    -0x28(%rbp),%eax
jge    1719 <main+0x559>
cmpl   $0x0,-0x38(%rbp)
jne    1572 <main+0x3b2>
mov    -0x60(%rbp),%rax
mov    -0x68(%rbp),%ecx
imul   -0x30(%rbp),%ecx
add    -0x64(%rbp),%ecx
movslq %ecx,%rcx
movzbl (%rax,%rcx,1),%eax
mov    %eax,-0x70(%rbp)
jmp    1579 <main+0x3b9>
movl   $0x80,-0x70(%rbp)
cmpl   $0x0,-0x34(%rbp)
jne    1628 <main+0x468>
mov    -0x60(%rbp),%rax
mov    %rax,-0xa0(%rbp)
mov    -0x44(%rbp),%ecx
mov    -0x68(%rbp),%eax
mov    $0x2,%esi
cltd
idiv   %esi
mov    %eax,%edx
mov    -0xa0(%rbp),%rax
imul   -0x30(%rbp),%edx
add    %edx,%ecx
mov    -0x64(%rbp),%edx
and    $0xfffffffe,%edx
add    %edx,%ecx
movslq %ecx,%rcx
movzbl (%rax,%rcx,1),%eax
sub    $0x80,%eax
mov    %eax,-0x74(%rbp)
mov    -0x60(%rbp),%rax
mov    %rax,-0x98(%rbp)
mov    -0x44(%rbp),%ecx
mov    -0x68(%rbp),%eax
mov    $0x2,%esi
cltd
idiv   %esi
mov    %eax,%edx
mov    -0x98(%rbp),%rax
imul   -0x30(%rbp),%edx
add    %edx,%ecx
mov    -0x64(%rbp),%edx
or     $0x1,%edx
add    %edx,%ecx
movslq %ecx,%rcx
movzbl (%rax,%rcx,1),%eax
sub    $0x80,%eax
mov    %eax,-0x78(%rbp)
cmpl   $0x0,-0x3c(%rbp)
je     1623 <main+0x463>
mov    -0x74(%rbp),%eax
mov    %eax,-0x88(%rbp)
mov    -0x78(%rbp),%eax
mov    %eax,-0x74(%rbp)
mov    -0x88(%rbp),%eax
mov    %eax,-0x78(%rbp)
jmp    1628 <main+0x468>
mov    -0x70(%rbp),%eax
mov    %eax,-0xac(%rbp)
imul   $0x166e9,-0x78(%rbp),%eax
mov    $0x10000,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0xac(%rbp),%eax
add    %ecx,%eax
mov    %eax,-0x7c(%rbp)
mov    -0x70(%rbp),%eax
mov    %eax,-0xa8(%rbp)
imul   $0x582c,-0x74(%rbp),%eax
imul   $0xb6d2,-0x78(%rbp),%ecx
add    %ecx,%eax
mov    $0x10000,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0xa8(%rbp),%eax
sub    %ecx,%eax
mov    %eax,-0x80(%rbp)
mov    -0x70(%rbp),%eax
mov    %eax,-0xa4(%rbp)
imul   $0x1c5a2,-0x74(%rbp),%eax
mov    $0x10000,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0xa4(%rbp),%eax
add    %ecx,%eax
mov    %eax,-0x84(%rbp)
mov    -0x7c(%rbp),%esi
xor    %edi,%edi
mov    $0xff,%edx
call   1080 <constrain@plt>
mov    %eax,-0x7c(%rbp)
mov    -0x80(%rbp),%esi
xor    %edi,%edi
mov    $0xff,%edx
call   1080 <constrain@plt>
mov    %eax,-0x80(%rbp)
mov    -0x84(%rbp),%esi
xor    %edi,%edi
mov    $0xff,%edx
call   1080 <constrain@plt>
mov    %eax,-0x84(%rbp)
mov    -0x7c(%rbp),%eax
mov    %al,-0x6b(%rbp)
mov    -0x80(%rbp),%eax
mov    %al,-0x6a(%rbp)
mov    -0x84(%rbp),%eax
mov    %al,-0x69(%rbp)
lea    -0x6b(%rbp),%rdi
mov    -0x20(%rbp),%rcx
mov    $0x3,%esi
mov    $0x1,%edx
call   10e0 <fwrite@plt>
mov    -0x64(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x64(%rbp)
jmp    153f <main+0x37f>
jmp    171e <main+0x55e>
mov    -0x68(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x68(%rbp)
jmp    152c <main+0x36c>
mov    -0x20(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x4(%rbp),%eax
add    $0xb0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x68,%rsp
mov    %rsi,%rbx
mov    %edi,%ebp
xor    %eax,%eax
mov    %rax,0x38(%rsp)
mov    $0x1,%al
mov    %eax,0x18(%rsp)
lea    0xe61(%rip),%r15
mov    0x2e0a(%rip),%r14
lea    0xe0b(%rip),%r12
movl   $0x0,0x1c(%rsp)
xor    %eax,%eax
mov    %rax,0x20(%rsp)
movl   $0x0,0x8(%rsp)
movl   $0x0,0x10(%rsp)
xor    %r13d,%r13d
jmp    122b <main+0x6b>
nopl   0x0(%rax)
mov    (%r14),%rdi
call   10c0 <atoi@plt>
mov    %eax,%r13d
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %r15,%rdx
call   10b0 <getopt@plt>
cmp    $0x77,%eax
je     1220 <main+0x60>
lea    -0x62(%rax),%ecx
cmp    $0x11,%ecx
ja     1294 <main+0xd4>
movslq (%r12,%rcx,4),%rax
add    %r12,%rax
jmp    *%rax
mov    (%r14),%rdi
call   10c0 <atoi@plt>
mov    %eax,0x8(%rsp)
jmp    122b <main+0x6b>
mov    $0x1,%eax
mov    %rax,0x38(%rsp)
jmp    122b <main+0x6b>
mov    (%r14),%rdi
call   10c0 <atoi@plt>
mov    %eax,0x10(%rsp)
jmp    122b <main+0x6b>
movl   $0x1,0x1c(%rsp)
jmp    122b <main+0x6b>
mov    (%r14),%rax
mov    %rax,0x20(%rsp)
jmp    122b <main+0x6b>
movl   $0x0,0x18(%rsp)
jmp    122b <main+0x6b>
cmp    $0xffffffff,%eax
jne    15fb <main+0x43b>
mov    0x2d34(%rip),%rax
movslq (%rax),%rax
cmp    %ebp,%eax
jge    1301 <main+0x141>
test   %r13d,%r13d
mov    0x10(%rsp),%r14d
jle    15db <main+0x41b>
test   %r14d,%r14d
jle    15db <main+0x41b>
mov    (%rbx,%rax,8),%rbx
mov    0x8(%rsp),%eax
test   %eax,%eax
cmovle %r13d,%eax
mov    %eax,0x8(%rsp)
test   %rbx,%rbx
je     1326 <main+0x166>
lea    0xda9(%rip),%rsi
mov    %rbx,%rdi
call   1050 <strcmp@plt>
test   %rax,%rax
je     1328 <main+0x168>
lea    0xd97(%rip),%rsi
mov    %rbx,%rdi
call   10a0 <fopen@plt>
mov    %rax,%rbp
jmp    1332 <main+0x172>
test   %r13d,%r13d
mov    0x10(%rsp),%r14d
jle    15db <main+0x41b>
test   %r14d,%r14d
jle    15db <main+0x41b>
mov    0x8(%rsp),%eax
test   %eax,%eax
cmovle %r13d,%eax
mov    %eax,0x8(%rsp)
xor    %ebx,%ebx
mov    0x2cb1(%rip),%rax
mov    (%rax),%rbp
test   %rbp,%rbp
je     15b6 <main+0x3f6>
mov    0x20(%rsp),%rbx
test   %rbx,%rbx
je     136d <main+0x1ad>
lea    0xd3d(%rip),%rsi
mov    %rbx,%rdi
call   1050 <strcmp@plt>
test   %rax,%rax
je     136d <main+0x1ad>
lea    0xd40(%rip),%rsi
mov    %rbx,%rdi
call   10a0 <fopen@plt>
mov    %rax,%r15
jmp    1377 <main+0x1b7>
mov    0x2c4c(%rip),%rax
mov    (%rax),%r15
test   %r15,%r15
je     15b6 <main+0x3f6>
mov    0x8(%rsp),%eax
imul   %r14d,%eax
mov    %rax,0x50(%rsp)
lea    (%rax,%rax,2),%eax
mov    %r14d,%ebx
mov    %eax,%r14d
shr    $0x1f,%r14d
add    %eax,%r14d
sar    %r14d
mov    %r14d,%edi
call   1070 <malloc@plt>
test   %rax,%rax
je     160d <main+0x44d>
mov    %rax,%r12
mov    %rax,%rdi
mov    $0x1,%esi
mov    %r14d,%edx
mov    %rbp,%rcx
call   1030 <fread@plt>
cmp    %r14d,%eax
jne    1625 <main+0x465>
mov    %rbp,%rdi
call   1040 <fclose@plt>
lea    0xcf2(%rip),%rsi
xor    %ebp,%ebp
mov    %r15,0x10(%rsp)
mov    %r15,%rdi
mov    %r13d,%edx
mov    %ebx,%ecx
xor    %eax,%eax
call   1060 <fprintf@plt>
mov    0x8(%rsp),%eax
mov    %rax,0x48(%rsp)
mov    %ebx,%eax
mov    %rax,0x40(%rsp)
mov    %r13d,%eax
mov    %rax,0x20(%rsp)
mov    %r12,0x60(%rsp)
mov    %r12,0x28(%rsp)
jmp    1443 <main+0x283>
nopl   0x0(%rax)
mov    0x58(%rsp),%rbp
add    $0x1,%rbp
mov    0x28(%rsp),%rax
add    0x48(%rsp),%rax
mov    %rax,0x28(%rsp)
cmp    0x40(%rsp),%rbp
je     159b <main+0x3db>
mov    %rbp,0x58(%rsp)
mov    %ebp,%eax
shr    %eax
imul   0x8(%rsp),%eax
add    0x50(%rsp),%eax
mov    %eax,0x34(%rsp)
xor    %r12d,%r12d
jmp    1539 <main+0x379>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    0x28(%rsp),%rax
movzbl (%rax,%r12,1),%eax
cmpl   $0x0,0x1c(%rsp)
je     1554 <main+0x394>
imul   $0x166e9,%r15d,%ecx
lea    0xffff(%rcx),%esi
test   %ecx,%ecx
cmovns %ecx,%esi
sar    $0x10,%esi
add    %eax,%esi
imul   $0x582c,%r14d,%ecx
imul   $0xb6d2,%r15d,%edx
lea    (%rdx,%rcx,1),%edi
add    $0xffff,%edi
add    %ecx,%edx
cmovns %edx,%edi
sar    $0x10,%edi
mov    %eax,%ebp
sub    %edi,%ebp
imul   $0x1c5a2,%r14d,%ecx
lea    0xffff(%rcx),%ebx
test   %ecx,%ecx
cmovns %ecx,%ebx
sar    $0x10,%ebx
add    %eax,%ebx
xor    %edi,%edi
mov    $0xff,%edx
call   1080 <constrain@plt>
mov    %eax,%r13d
xor    %edi,%edi
mov    %ebp,%esi
mov    $0xff,%edx
call   1080 <constrain@plt>
mov    %eax,%ebp
xor    %edi,%edi
mov    %ebx,%esi
mov    $0xff,%edx
call   1080 <constrain@plt>
mov    %r13b,0xd(%rsp)
mov    %bpl,0xe(%rsp)
mov    %al,0xf(%rsp)
lea    0xd(%rsp),%rdi
mov    $0x3,%esi
mov    $0x1,%edx
mov    0x10(%rsp),%rcx
call   10e0 <fwrite@plt>
add    $0x1,%r12
cmp    %r12,0x20(%rsp)
je     1420 <main+0x260>
mov    $0x80,%eax
cmpl   $0x0,0x38(%rsp)
je     1470 <main+0x2b0>
cmpl   $0x0,0x1c(%rsp)
jne    1485 <main+0x2c5>
mov    %r12d,%ecx
and    $0x7ffffffe,%ecx
mov    0x34(%rsp),%edi
add    %edi,%ecx
movslq %ecx,%rcx
mov    0x60(%rsp),%rsi
movzbl (%rsi,%rcx,1),%ecx
add    $0xffffff80,%ecx
mov    %r12d,%edx
or     $0x1,%edx
add    %edi,%edx
movslq %edx,%rdx
movzbl (%rsi,%rdx,1),%r15d
add    $0xffffff80,%r15d
testb  $0x1,0x18(%rsp)
mov    %r15d,%r14d
cmovne %ecx,%r14d
cmove  %ecx,%r15d
jmp    1485 <main+0x2c5>
mov    0x10(%rsp),%rdi
call   1040 <fclose@plt>
xor    %eax,%eax
add    $0x68,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2a0b(%rip),%rax
movslq (%rax),%rdi
lea    0xac7(%rip),%rsi
mov    %rbx,%rdx
xor    %eax,%eax
call   1060 <fprintf@plt>
mov    $0xffffffff,%edi
call   10d0 <exit@plt>
mov    0x29e6(%rip),%rax
movslq (%rax),%rcx
lea    0xa68(%rip),%rdi
mov    $0x34,%esi
mov    $0x1,%edx
call   10e0 <fwrite@plt>
mov    (%rbx),%rdi
call   1090 <usage@plt>
mov    $0xffffffff,%edi
call   10d0 <exit@plt>
mov    0x29b4(%rip),%rax
movslq (%rax),%rcx
lea    0xa85(%rip),%rdi
mov    $0x12,%esi
jmp    163b <main+0x47b>
mov    0x299c(%rip),%rax
movslq (%rax),%rcx
lea    0xa80(%rip),%rdi
mov    $0x1a,%esi
mov    $0x1,%edx
call   10e0 <fwrite@plt>
mov    $0xffffffff,%edi
call   10d0 <exit@plt>

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

LLVM IR (-O2):
@.str = [12 x i8] c"w:h:b:o:lcs\00"
@optarg = global i8* null
@optind = global i32 0
@stderr = global i32 0
@.str.1 = [53 x i8] c"ERROR: Must specify width and height of input image\0A\00"
@.str.2 = [2 x i8] c"-\00"
@stdin = global i32* null
@.str.3 = [3 x i8] c"rb\00"
@.str.4 = [18 x i8] c"Error opening %s\0A\00"
@stdout = global i32* null
@.str.5 = [3 x i8] c"wb\00"
@.str.6 = [19 x i8] c"Not enough memory\0A\00"
@.str.7 = [27 x i8] c"Input file not big enough\0A\00"
@.str.8 = [14 x i8] c"P6\0A%d %d\0A255\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca [3 x i8]
br label %4
4: ; preds = %37, %2
%5 = phi i1 [ true, %2 ], [ false, %37 ]
%6 = phi i32 [ 0, %2 ], [ %13, %37 ]
%7 = phi i32 [ 0, %2 ], [ %20, %37 ]
%8 = phi i8* [ null, %2 ], [ %26, %37 ]
%9 = phi i32 [ 0, %2 ], [ %31, %37 ]
%10 = phi i32 [ 0, %2 ], [ %35, %37 ]
%11 = phi i32 [ 0, %2 ], [ %38, %37 ]
br label %12
12: ; preds = %37, %4
%13 = phi i32 [ %6, %4 ], [ 1, %37 ]
%14 = phi i32 [ %7, %4 ], [ %20, %37 ]
%15 = phi i8* [ %8, %4 ], [ %26, %37 ]
%16 = phi i32 [ %9, %4 ], [ %31, %37 ]
%17 = phi i32 [ %10, %4 ], [ %35, %37 ]
%18 = phi i32 [ %11, %4 ], [ %38, %37 ]
br label %19
19: ; preds = %37, %12
%20 = phi i32 [ %14, %12 ], [ 1, %37 ]
%21 = phi i8* [ %15, %12 ], [ %26, %37 ]
%22 = phi i32 [ %16, %12 ], [ %31, %37 ]
%23 = phi i32 [ %17, %12 ], [ %35, %37 ]
%24 = phi i32 [ %18, %12 ], [ %38, %37 ]
br label %25
25: ; preds = %19, %49
%26 = phi i8* [ %21, %19 ], [ %50, %49 ]
%27 = phi i32 [ %22, %19 ], [ %31, %49 ]
%28 = phi i32 [ %23, %19 ], [ %35, %49 ]
%29 = phi i32 [ %24, %19 ], [ %38, %49 ]
br label %30
30: ; preds = %25, %46
%31 = phi i32 [ %27, %25 ], [ %48, %46 ]
%32 = phi i32 [ %28, %25 ], [ %35, %46 ]
%33 = phi i32 [ %29, %25 ], [ %38, %46 ]
br label %34
34: ; preds = %30, %43
%35 = phi i32 [ %32, %30 ], [ %45, %43 ]
%36 = phi i32 [ %33, %30 ], [ %38, %43 ]
br label %37
37: ; preds = %34, %40
%38 = phi i32 [ %42, %40 ], [ %36, %34 ]
%39 = tail call i32 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
switch i32 %39, label %51 [
i32 -1, label %55
i32 119, label %40
i32 104, label %43
i32 98, label %46
i32 111, label %49
i32 108, label %19
i32 99, label %12
i32 115, label %4
]
40: ; preds = %37
%41 = load i8*, i8** @optarg
%42 = tail call i32 @atoi(i8* %41)
br label %37
43: ; preds = %37
%44 = load i8*, i8** @optarg
%45 = tail call i32 @atoi(i8* %44)
br label %34
46: ; preds = %37
%47 = load i8*, i8** @optarg
%48 = tail call i32 @atoi(i8* %47)
br label %30
49: ; preds = %37
%50 = load i8*, i8** @optarg
br label %25
51: ; preds = %37
%52 = load i8*, i8** %1
%53 = tail call i32 @usage(i8* %52)
%54 = tail call i32 @exit(i32 -1)
unreachable
55: ; preds = %37
%56 = load i32, i32* @optind
%57 = icmp slt i32 %56, %0
br i1 %57, label %58, label %65
58: ; preds = %55
%59 = sext i32 %56 to i64
%60 = getelementptr inbounds i8*, i8** %1, i64 %59
%61 = load i8*, i8** %60
%62 = icmp slt i32 %38, 1
%63 = icmp slt i32 %35, 1
%64 = select i1 %62, i1 true, i1 %63
br i1 %64, label %72, label %80
65: ; preds = %55
%66 = icmp slt i32 %38, 1
%67 = icmp slt i32 %35, 1
%68 = select i1 %66, i1 true, i1 %67
br i1 %68, label %72, label %69
69: ; preds = %65
%70 = icmp slt i32 %31, 1
%71 = select i1 %70, i32 %38, i32 %31
br label %87
72: ; preds = %65, %58
%73 = load i32, i32* @stderr
%74 = sext i32 %73 to i64
%75 = inttoptr i64 %74 to i32*
%76 = tail call i64 bitcast (i32 (i8*, i32, i32, i32*)* @fwrite to i64 (i8*, i64, i64, i32*)*)(i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.1, i64 0, i64 0), i64 52, i64 1, i32* %75)
%77 = load i8*, i8** %1
%78 = tail call i32 @usage(i8* %77)
%79 = tail call i32 @exit(i32 -1)
unreachable
80: ; preds = %58
%81 = icmp slt i32 %31, 1
%82 = select i1 %81, i32 %38, i32 %31
%83 = icmp eq i8* %61, null
br i1 %83, label %87, label %84
84: ; preds = %80
%85 = tail call i64 @strcmp(i8* %61, 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 %87, label %91
87: ; preds = %69, %84, %80
%88 = phi i32 [ %71, %69 ], [ %82, %84 ], [ %82, %80 ]
%89 = phi i8* [ null, %69 ], [ %61, %84 ], [ null, %80 ]
%90 = load i32*, i32** @stdin
br label %93
91: ; preds = %84
%92 = tail call i32* @fopen(i8* %61, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
br label %93
93: ; preds = %91, %87
%94 = phi i32 [ %88, %87 ], [ %82, %91 ]
%95 = phi i8* [ %89, %87 ], [ %61, %91 ]
%96 = phi i32* [ %90, %87 ], [ %92, %91 ]
%97 = icmp eq i32* %96, null
br i1 %97, label %98, label %104
98: ; preds = %93
%99 = load i32, i32* @stderr
%100 = sext i32 %99 to i64
%101 = inttoptr i64 %100 to i32*
%102 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %101, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.4, i64 0, i64 0), i8* %95)
%103 = tail call i32 @exit(i32 -1)
unreachable
104: ; preds = %93
%105 = icmp eq i8* %26, null
br i1 %105, label %109, label %106
106: ; preds = %104
%107 = tail call i64 @strcmp(i8* %26, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%108 = icmp eq i64 %107, 0
br i1 %108, label %109, label %111
109: ; preds = %106, %104
%110 = load i32*, i32** @stdout
br label %113
111: ; preds = %106
%112 = tail call i32* @fopen(i8* %26, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0))
br label %113
113: ; preds = %111, %109
%114 = phi i32* [ %110, %109 ], [ %112, %111 ]
%115 = icmp eq i32* %114, null
br i1 %115, label %116, label %122
116: ; preds = %113
%117 = load i32, i32* @stderr
%118 = sext i32 %117 to i64
%119 = inttoptr i64 %118 to i32*
%120 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %119, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.4, i64 0, i64 0), i8* %26)
%121 = tail call i32 @exit(i32 -1)
unreachable
122: ; preds = %113
%123 = mul nsw i32 %94, %35
%124 = mul nsw i32 %123, 3
%125 = sdiv i32 %124, 2
%126 = tail call i64 @malloc(i32 %125)
%127 = inttoptr i64 %126 to i8*
%128 = icmp eq i64 %126, 0
br i1 %128, label %129, label %135
129: ; preds = %122
%130 = load i32, i32* @stderr
%131 = sext i32 %130 to i64
%132 = inttoptr i64 %131 to i32*
%133 = tail call i64 bitcast (i32 (i8*, i32, i32, i32*)* @fwrite to i64 (i8*, i64, i64, i32*)*)(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.6, i64 0, i64 0), i64 18, i64 1, i32* %132)
%134 = tail call i32 @exit(i32 -1)
unreachable
135: ; preds = %122
%136 = tail call i32 @fread(i8* %127, i32 1, i32 %125, i32* %96)
%137 = icmp eq i32 %136, %125
br i1 %137, label %144, label %138
138: ; preds = %135
%139 = load i32, i32* @stderr
%140 = sext i32 %139 to i64
%141 = inttoptr i64 %140 to i32*
%142 = tail call i64 bitcast (i32 (i8*, i32, i32, i32*)* @fwrite to i64 (i8*, i64, i64, i32*)*)(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.7, i64 0, i64 0), i64 26, i64 1, i32* %141)
%143 = tail call i32 @exit(i32 -1)
unreachable
144: ; preds = %135
%145 = tail call i32 @fclose(i32* %96)
%146 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %114, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.8, i64 0, i64 0), i32 %38, i32 %35)
%147 = getelementptr inbounds [3 x i8], [3 x i8]* %3, i64 0, i64 0
%148 = icmp eq i32 %13, 0
%149 = icmp eq i32 %20, 0
%150 = getelementptr inbounds [3 x i8], [3 x i8]* %3, i64 0, i64 1
%151 = getelementptr inbounds [3 x i8], [3 x i8]* %3, i64 0, i64 2
%152 = zext i32 %94 to i64
%153 = zext i32 %35 to i64
%154 = zext i32 %38 to i64
br label %155
155: ; preds = %144, %216
%156 = phi i64 [ 0, %144 ], [ %217, %216 ]
%157 = phi i32 [ undef, %144 ], [ %195, %216 ]
%158 = phi i32 [ undef, %144 ], [ %194, %216 ]
%159 = mul nsw i64 %156, %152
%160 = trunc i64 %156 to i32
%161 = lshr i32 %160, 1
%162 = mul nsw i32 %161, %94
%163 = add nsw i32 %162, %123
br label %164
164: ; preds = %155, %193
%165 = phi i64 [ 0, %155 ], [ %214, %193 ]
%166 = phi i32 [ %157, %155 ], [ %195, %193 ]
%167 = phi i32 [ %158, %155 ], [ %194, %193 ]
br i1 %148, label %168, label %173
168: ; preds = %164
%169 = add nuw nsw i64 %165, %159
%170 = getelementptr inbounds i8, i8* %127, i64 %169
%171 = load i8, i8* %170
%172 = zext i8 %171 to i32
br label %173
173: ; preds = %164, %168
%174 = phi i32 [ %172, %168 ], [ 128, %164 ]
br i1 %149, label %175, label %193
175: ; preds = %173
%176 = trunc i64 %165 to i32
%177 = and i32 %176, 2147483646
%178 = add nsw i32 %177, %163
%179 = sext i32 %178 to i64
%180 = getelementptr inbounds i8, i8* %127, i64 %179
%181 = load i8, i8* %180
%182 = zext i8 %181 to i32
%183 = add nsw i32 %182, -128
%184 = or i32 %176, 1
%185 = add nsw i32 %184, %163
%186 = sext i32 %185 to i64
%187 = getelementptr inbounds i8, i8* %127, i64 %186
%188 = load i8, i8* %187
%189 = zext i8 %188 to i32
%190 = add nsw i32 %189, -128
%191 = select i1 %5, i32 %183, i32 %190
%192 = select i1 %5, i32 %190, i32 %183
br label %193
193: ; preds = %175, %173
%194 = phi i32 [ %167, %173 ], [ %191, %175 ]
%195 = phi i32 [ %166, %173 ], [ %192, %175 ]
%196 = mul nsw i32 %195, 91881
%197 = sdiv i32 %196, 65536
%198 = add nsw i32 %197, %174
%199 = mul nsw i32 %194, 22572
%200 = mul nsw i32 %195, 46802
%201 = add nsw i32 %200, %199
%202 = sdiv i32 %201, -65536
%203 = add nsw i32 %202, %174
%204 = mul nsw i32 %194, 116130
%205 = sdiv i32 %204, 65536
%206 = add nsw i32 %205, %174
%207 = tail call i32 @constrain(i32 0, i32 %198, i32 255)
%208 = tail call i32 @constrain(i32 0, i32 %203, i32 255)
%209 = tail call i32 @constrain(i32 0, i32 %206, i32 255)
%210 = trunc i32 %207 to i8
store i8 %210, i8* %147
%211 = trunc i32 %208 to i8
store i8 %211, i8* %150
%212 = trunc i32 %209 to i8
store i8 %212, i8* %151
%213 = call i32 @fwrite(i8* %147, i32 3, i32 1, i32* %114)
%214 = add nuw nsw i64 %165, 1
%215 = icmp eq i64 %214, %154
br i1 %215, label %216, label %164
216: ; preds = %193
%217 = add nuw nsw i64 %156, 1
%218 = icmp eq i64 %217, %153
br i1 %218, label %219, label %155
219: ; preds = %216
%220 = tail call i32 @fclose(i32* %114)
ret i32 0
}