#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 check_dimensions(int *, int, int /*<<< orphan*/ *, int /*<<< orphan*/ *);
int check_luminance(int /*<<< orphan*/ *, int /*<<< orphan*/ *);
int check_magic(int /*<<< orphan*/ *, int /*<<< orphan*/ *);
int conversion(int /*<<< orphan*/ *, int /*<<< orphan*/ *, int, char);
int /*<<< orphan*/ fcloseall();
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ stderr;
scalar_t__ strcmp(char *, char *);
int main(int argc, char *argv[]) {
  int i;
  int code = 0;
  char method;
  FILE *input_file = NULL;
  FILE *output_file = NULL;
  if (argc <= 2 || argc > 4) {
    fprintf(stderr, "Not enough arguments in command line. Error code 1.\n");
    return 1;
  }
  if (argc == 3) {
    method = 'a';
    input_file = fopen(argv[1], "r");
    if (input_file == NULL) {
      fprintf(stderr, "Failed to open file '%s' for reading. Error code 2.\n",
              argv[1]);
      return 2;
    }
    output_file = fopen(argv[2], "w");
    if (output_file == NULL) {
      fprintf(stderr, "Failed to open file '%s' for writing. Error code 3.\n",
              argv[2]);
      return 3;
    }
  }
  if (argc == 4) {
    if (strcmp(argv[1], "-a") == 0 || strcmp(argv[1], "-l") == 0) {
      char *p;
      p = "-a";
      i = strcmp(argv[1], p);
      if (i == 0)
        method = 'a';
      p = "-l";
      i = strcmp(argv[1], p);
      if (i == 0)
        method = 'l';
      input_file = fopen(argv[2], "r");
      if (input_file == NULL) {
        fprintf(stderr, "Failed to open file '%s' for reading. Error code 2.\n",
                argv[2]);
        return 2;
      }
      output_file = fopen(argv[3], "w");
      if (output_file == NULL) {
        fprintf(stderr, "Failed to open file '%s' for writing. Error code 3.\n",
                argv[3]);
        return 3;
      }
    } else if (strcmp(argv[2], "-a") == 0 || strcmp(argv[2], "-l") == 0) {
      char *p;
      p = "-a";
      i = strcmp(argv[2], p);
      if (i == 0)
        method = 'a';
      p = "-l";
      i = strcmp(argv[2], p);
      if (i == 0)
        method = 'l';
      input_file = fopen(argv[1], "r");
      if (input_file == NULL) {
        fprintf(stderr, "Failed to open file '%s' for reading. Error code 2.\n",
                argv[1]);
        return 2;
      }
      output_file = fopen(argv[3], "w");
      if (output_file == NULL) {
        fprintf(stderr, "Failed to open file '%s' for writing. Error code 3.\n",
                argv[3]);
        return 3;
      }
    }
    if (strcmp(argv[3], "-a") == 0 || strcmp(argv[3], "-l") == 0) {
      char *p;
      p = "-a";
      i = strcmp(argv[3], p);
      if (i == 0)
        method = 'a';
      p = "-l";
      i = strcmp(argv[3], p);
      if (i == 0)
        method = 'l';
      input_file = fopen(argv[1], "r");
      if (input_file == NULL) {
        fprintf(stderr, "Failed to open file '%s' for reading. Error code 2.\n",
                argv[1]);
        return 2;
      }
      output_file = fopen(argv[2], "w");
      if (output_file == NULL) {
        fprintf(stderr, "Failed to open file '%s' for writing. Error code 3.\n",
                argv[2]);
        return 3;
      }
    }
  }
  code = check_magic(input_file, output_file);
  if (code != 0) {
    fcloseall();
    fprintf(stderr,
            "Header problem, please check magic number line in '%s'. Error "
            "code 4.\n",
            argv[1]);
    return code;
  }
  int dimensions_array[] = {0, 0};
  code = check_dimensions(dimensions_array, 2, input_file, output_file);
  if (code != 0) {
    fcloseall();
    fprintf(
        stderr,
        "Header problem, please check dimensions line in '%s'. Error code 4.\n",
        argv[1]);
    return code;
  }
  code = check_luminance(input_file, output_file);
  if (code != 0) {
    fcloseall();
    fprintf(
        stderr,
        "Header problem, please check luminance line in '%s'. Error code 4.\n",
        argv[1]);
    return code;
  }
  i = dimensions_array[0] * dimensions_array[1] * 3;
  code = conversion(input_file, output_file, i, method);
  if (code != 0) {
    fcloseall();
    fprintf(stderr, "Error reading image data from '%s'. Error code 2.\n",
            argv[1]);
    return code;
  }
  fcloseall();
  return code;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x18(%rbp)
movq   $0x0,-0x28(%rbp)
movq   $0x0,-0x30(%rbp)
cmpl   $0x2,-0x8(%rbp)
jle    11d1 <main+0x41>
cmpl   $0x4,-0x8(%rbp)
jle    11f4 <main+0x64>
mov    0x2e08(%rip),%rax
mov    (%rax),%edi
lea    0xe1f(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    17c2 <main+0x632>
cmpl   $0x3,-0x8(%rbp)
jne    12a3 <main+0x113>
movb   $0x61,-0x19(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe24(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    1250 <main+0xc0>
mov    0x2db4(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdx
lea    0xdfa(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
movl   $0x2,-0x4(%rbp)
jmp    17c2 <main+0x632>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xe0d(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
jne    129e <main+0x10e>
mov    0x2d66(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdx
lea    0xde3(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
movl   $0x3,-0x4(%rbp)
jmp    17c2 <main+0x632>
jmp    12a3 <main+0x113>
cmpl   $0x4,-0x8(%rbp)
jne    165c <main+0x4cc>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xde7(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
je     12e9 <main+0x159>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xdcc(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
jne    13e4 <main+0x254>
lea    0xdb3(%rip),%rax
mov    %rax,-0x38(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    -0x38(%rbp),%rsi
call   1060 <strcmp@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jne    1316 <main+0x186>
movb   $0x61,-0x19(%rbp)
lea    0xd89(%rip),%rax
mov    %rax,-0x38(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    -0x38(%rbp),%rsi
call   1060 <strcmp@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jne    1343 <main+0x1b3>
movb   $0x6c,-0x19(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xce3(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    1391 <main+0x201>
mov    0x2c73(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdx
lea    0xcb9(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
movl   $0x2,-0x4(%rbp)
jmp    17c2 <main+0x632>
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
lea    0xccc(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
jne    13df <main+0x24f>
mov    0x2c25(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdx
lea    0xca2(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
movl   $0x3,-0x4(%rbp)
jmp    17c2 <main+0x632>
jmp    1520 <main+0x390>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xcb0(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
je     1420 <main+0x290>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xc95(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
jne    151b <main+0x38b>
lea    0xc7c(%rip),%rax
mov    %rax,-0x40(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
mov    -0x40(%rbp),%rsi
call   1060 <strcmp@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jne    144d <main+0x2bd>
movb   $0x61,-0x19(%rbp)
lea    0xc52(%rip),%rax
mov    %rax,-0x40(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
mov    -0x40(%rbp),%rsi
call   1060 <strcmp@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jne    147a <main+0x2ea>
movb   $0x6c,-0x19(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xbac(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    14c8 <main+0x338>
mov    0x2b3c(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdx
lea    0xb82(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
movl   $0x2,-0x4(%rbp)
jmp    17c2 <main+0x632>
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
lea    0xb95(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
jne    1516 <main+0x386>
mov    0x2aee(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdx
lea    0xb6b(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
movl   $0x3,-0x4(%rbp)
jmp    17c2 <main+0x632>
jmp    151b <main+0x38b>
jmp    1520 <main+0x390>
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
lea    0xb74(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
je     155c <main+0x3cc>
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
lea    0xb59(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
jne    1657 <main+0x4c7>
lea    0xb40(%rip),%rax
mov    %rax,-0x48(%rbp)
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
mov    -0x48(%rbp),%rsi
call   1060 <strcmp@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jne    1589 <main+0x3f9>
movb   $0x61,-0x19(%rbp)
lea    0xb16(%rip),%rax
mov    %rax,-0x48(%rbp)
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
mov    -0x48(%rbp),%rsi
call   1060 <strcmp@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jne    15b6 <main+0x426>
movb   $0x6c,-0x19(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xa70(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    1604 <main+0x474>
mov    0x2a00(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdx
lea    0xa46(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
movl   $0x2,-0x4(%rbp)
jmp    17c2 <main+0x632>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xa59(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
jne    1652 <main+0x4c2>
mov    0x29b2(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdx
lea    0xa2f(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
movl   $0x3,-0x4(%rbp)
jmp    17c2 <main+0x632>
jmp    1657 <main+0x4c7>
jmp    165c <main+0x4cc>
mov    -0x28(%rbp),%rdi
mov    -0x30(%rbp),%rsi
call   10b0 <check_magic@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
je     16a7 <main+0x517>
mov    $0x0,%al
call   10a0 <fcloseall@plt>
mov    0x295c(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdx
lea    0xa14(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    -0x18(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    17c2 <main+0x632>
lea    -0x50(%rbp),%rdi
xor    %esi,%esi
mov    $0x8,%edx
call   1050 <memset@plt>
lea    -0x50(%rbp),%rdi
mov    -0x28(%rbp),%rdx
mov    -0x30(%rbp),%rcx
mov    $0x2,%esi
call   1030 <check_dimensions@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
je     170b <main+0x57b>
mov    $0x0,%al
call   10a0 <fcloseall@plt>
mov    0x28f8(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdx
lea    0x9f7(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    -0x18(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    17c2 <main+0x632>
mov    -0x28(%rbp),%rdi
mov    -0x30(%rbp),%rsi
call   1040 <check_luminance@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
je     1756 <main+0x5c6>
mov    $0x0,%al
call   10a0 <fcloseall@plt>
mov    0x28ad(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdx
lea    0x9f1(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    -0x18(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    17c2 <main+0x632>
mov    -0x50(%rbp),%eax
imul   -0x4c(%rbp),%eax
imul   $0x3,%eax,%eax
mov    %eax,-0x14(%rbp)
mov    -0x28(%rbp),%rdi
mov    -0x30(%rbp),%rsi
mov    -0x14(%rbp),%edx
movsbl -0x19(%rbp),%ecx
call   1080 <conversion@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
je     17b5 <main+0x625>
mov    $0x0,%al
call   10a0 <fcloseall@plt>
mov    0x284e(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdx
lea    0x9d6(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    -0x18(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    17c2 <main+0x632>
mov    $0x0,%al
call   10a0 <fcloseall@plt>
mov    -0x18(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
mov    %edi,%eax
lea    -0x5(%rax),%ecx
cmp    $0xfffffffd,%ecx
ja     11b7 <main+0x37>
mov    0x2e43(%rip),%rax
mov    (%rax),%edi
lea    0xe5a(%rip),%rsi
xor    %eax,%eax
call   1060 <fprintf@plt>
mov    $0x1,%ebp
jmp    1498 <main+0x318>
mov    %rsi,%rbx
mov    0x8(%rsi),%rdi
cmp    $0x3,%eax
jne    11ff <main+0x7f>
lea    0xe6b(%rip),%rsi
call   1080 <fopen@plt>
test   %rax,%rax
je     13df <main+0x25f>
mov    %rax,%r14
mov    0x10(%rbx),%rdi
lea    0xe86(%rip),%rsi
call   1080 <fopen@plt>
test   %rax,%rax
je     1404 <main+0x284>
mov    %rax,%r15
mov    $0x61,%r12b
jmp    13ae <main+0x22e>
lea    0xe9d(%rip),%rsi
call   1050 <strcmp@plt>
test   %rax,%rax
je     125d <main+0xdd>
mov    0x8(%rbx),%rdi
lea    0xe8b(%rip),%rsi
call   1050 <strcmp@plt>
test   %rax,%rax
je     125d <main+0xdd>
mov    0x10(%rbx),%rdi
lea    0xe73(%rip),%rsi
call   1050 <strcmp@plt>
test   %rax,%rax
je     12a7 <main+0x127>
mov    0x10(%rbx),%rdi
lea    0xe61(%rip),%rsi
call   1050 <strcmp@plt>
test   %rax,%rax
je     12a7 <main+0x127>
mov    $0x61,%r12b
xor    %r14d,%r14d
xor    %r15d,%r15d
jmp    1313 <main+0x193>
mov    0x8(%rbx),%rdi
lea    0xe3b(%rip),%rsi
call   1050 <strcmp@plt>
mov    0x8(%rbx),%rdi
lea    0xe2e(%rip),%rsi
call   1050 <strcmp@plt>
mov    %rax,%rbp
mov    0x10(%rbx),%rdi
lea    0xdaa(%rip),%rsi
call   1080 <fopen@plt>
test   %rax,%rax
jne    12e3 <main+0x163>
mov    0x2d44(%rip),%rax
mov    (%rax),%edi
mov    0x10(%rbx),%rdx
jmp    13ec <main+0x26c>
mov    0x10(%rbx),%rdi
lea    0xdf1(%rip),%rsi
call   1050 <strcmp@plt>
mov    0x10(%rbx),%rdi
lea    0xde4(%rip),%rsi
call   1050 <strcmp@plt>
mov    %rax,%rbp
mov    0x8(%rbx),%rdi
lea    0xd60(%rip),%rsi
call   1080 <fopen@plt>
test   %rax,%rax
je     13df <main+0x25f>
mov    %rax,%r14
test   %ebp,%ebp
mov    $0x6c,%eax
mov    $0x61,%r12d
cmove  %eax,%r12d
mov    0x18(%rbx),%rdi
lea    0xd6a(%rip),%rsi
call   1080 <fopen@plt>
test   %rax,%rax
je     1440 <main+0x2c0>
mov    %rax,%r15
mov    0x18(%rbx),%rdi
lea    0xd85(%rip),%rsi
call   1050 <strcmp@plt>
test   %rax,%rax
je     133d <main+0x1bd>
mov    0x18(%rbx),%rdi
lea    0xd73(%rip),%rsi
call   1050 <strcmp@plt>
test   %rax,%rax
jne    13ae <main+0x22e>
mov    0x18(%rbx),%rdi
lea    0xd5b(%rip),%rsi
call   1050 <strcmp@plt>
mov    %rax,%r15
mov    0x18(%rbx),%rdi
lea    0xd4b(%rip),%rsi
call   1050 <strcmp@plt>
mov    %rax,%rbp
mov    0x8(%rbx),%rdi
lea    0xcc7(%rip),%rsi
call   1080 <fopen@plt>
test   %rax,%rax
je     13df <main+0x25f>
mov    %rax,%r14
test   %r15d,%r15d
movzbl %r12b,%eax
mov    $0x61,%ecx
cmovne %eax,%ecx
test   %ebp,%ebp
mov    $0x6c,%r12d
cmovne %ecx,%r12d
mov    0x10(%rbx),%rdi
lea    0xccb(%rip),%rsi
call   1080 <fopen@plt>
test   %rax,%rax
je     1404 <main+0x284>
mov    %rax,%r15
mov    %r14,%rdi
mov    %r15,%rsi
call   10a0 <check_magic@plt>
test   %eax,%eax
je     1413 <main+0x293>
mov    %eax,%ebp
xor    %eax,%eax
call   1090 <fcloseall@plt>
mov    0x2c13(%rip),%rax
mov    (%rax),%edi
mov    0x8(%rbx),%rdx
lea    0xccf(%rip),%rsi
jmp    1491 <main+0x311>
mov    0x2bfa(%rip),%rax
mov    (%rax),%edi
mov    0x8(%rbx),%rdx
lea    0xc44(%rip),%rsi
xor    %eax,%eax
call   1060 <fprintf@plt>
mov    $0x2,%ebp
jmp    1498 <main+0x318>
mov    0x2bd5(%rip),%rax
mov    (%rax),%edi
mov    0x10(%rbx),%rdx
jmp    144d <main+0x2cd>
movq   $0x0,0x8(%rsp)
lea    0x8(%rsp),%rdi
mov    $0x2,%esi
mov    %r14,%rdx
mov    %r15,%rcx
call   1030 <check_dimensions@plt>
test   %eax,%eax
je     1462 <main+0x2e2>
mov    %eax,%ebp
lea    0xcb2(%rip),%r14
jmp    147a <main+0x2fa>
mov    0x2b99(%rip),%rax
mov    (%rax),%edi
mov    0x18(%rbx),%rdx
lea    0xc1a(%rip),%rsi
xor    %eax,%eax
call   1060 <fprintf@plt>
mov    $0x3,%ebp
jmp    1498 <main+0x318>
mov    %r14,%rdi
mov    %r15,%rsi
call   1040 <check_luminance@plt>
test   %eax,%eax
je     14a7 <main+0x327>
mov    %eax,%ebp
lea    0xcbb(%rip),%r14
xor    %eax,%eax
call   1090 <fcloseall@plt>
mov    0x2b58(%rip),%rax
mov    (%rax),%edi
mov    0x8(%rbx),%rdx
mov    %r14,%rsi
xor    %eax,%eax
call   1060 <fprintf@plt>
mov    %ebp,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x8(%rsp),%eax
imul   0xc(%rsp),%eax
lea    (%rax,%rax,2),%edx
movzbl %r12b,%ecx
mov    %r14,%rdi
mov    %r15,%rsi
call   1070 <conversion@plt>
mov    %eax,%r15d
xor    %ebp,%ebp
xor    %eax,%eax
call   1090 <fcloseall@plt>
test   %r15d,%r15d
je     1498 <main+0x318>
lea    0xc9f(%rip),%r14
mov    %r15d,%ebp
jmp    1481 <main+0x301>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [53 x i8] c"Not enough arguments in command line. Error code 1.\0A\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [53 x i8] c"Failed to open file '%s' for reading. Error code 2.\0A\00"
@.str.3 = [2 x i8] c"w\00"
@.str.4 = [53 x i8] c"Failed to open file '%s' for writing. Error code 3.\0A\00"
@.str.5 = [3 x i8] c"-a\00"
@.str.6 = [3 x i8] c"-l\00"
@.str.7 = [71 x i8] c"Header problem, please check magic number line in '%s'. Error code 4.\0A\00"
@.str.8 = [69 x i8] c"Header problem, please check dimensions line in '%s'. Error code 4.\0A\00"
@.str.9 = [68 x i8] c"Header problem, please check luminance line in '%s'. Error code 4.\0A\00"
@.str.10 = [51 x i8] c"Error reading image data from '%s'. Error code 2.\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 i8
%9 = alloca i32*
%10 = alloca i32*
%11 = alloca i8*
%12 = alloca i8*
%13 = alloca i8*
%14 = alloca [2 x i32]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %7
store i32* null, i32** %9
store i32* null, i32** %10
%15 = load i32, i32* %4
%16 = icmp sle i32 %15, 2
br i1 %16, label %20, label %17
17: ; preds = %2
%18 = load i32, i32* %4
%19 = icmp sgt i32 %18, 4
br i1 %19, label %20, label %23
20: ; preds = %17, %2
%21 = load i32, i32* @stderr
%22 = call i32 (i32, i8*, ...) @fprintf(i32 %21, i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %3
br label %304
23: ; preds = %17
%24 = load i32, i32* %4
%25 = icmp eq i32 %24, 3
br i1 %25, label %26, label %53
26: ; preds = %23
store i8 97, i8* %8
%27 = load i8**, i8*** %5
%28 = getelementptr inbounds i8*, i8** %27, i64 1
%29 = load i8*, i8** %28
%30 = call i32* @fopen(i8* %29, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %30, i32** %9
%31 = load i32*, i32** %9
%32 = icmp eq i32* %31, null
br i1 %32, label %33, label %39
33: ; preds = %26
%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 ([53 x i8], [53 x i8]* @.str.2, i64 0, i64 0), i8* %37)
store i32 2, i32* %3
br label %304
39: ; preds = %26
%40 = load i8**, i8*** %5
%41 = getelementptr inbounds i8*, i8** %40, i64 2
%42 = load i8*, i8** %41
%43 = call i32* @fopen(i8* %42, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
store i32* %43, i32** %10
%44 = load i32*, i32** %10
%45 = icmp eq i32* %44, null
br i1 %45, label %46, label %52
46: ; preds = %39
%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 ([53 x i8], [53 x i8]* @.str.4, i64 0, i64 0), i8* %50)
store i32 3, i32* %3
br label %304
52: ; preds = %39
br label %53
53: ; preds = %52, %23
%54 = load i32, i32* %4
%55 = icmp eq i32 %54, 4
br i1 %55, label %56, label %235
56: ; preds = %53
%57 = load i8**, i8*** %5
%58 = getelementptr inbounds i8*, i8** %57, i64 1
%59 = load i8*, i8** %58
%60 = call i64 @strcmp(i8* %59, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0))
%61 = icmp eq i64 %60, 0
br i1 %61, label %68, label %62
62: ; preds = %56
%63 = load i8**, i8*** %5
%64 = getelementptr inbounds i8*, i8** %63, i64 1
%65 = load i8*, i8** %64
%66 = call i64 @strcmp(i8* %65, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0))
%67 = icmp eq i64 %66, 0
br i1 %67, label %68, label %115
68: ; preds = %62, %56
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i8** %11
%69 = load i8**, i8*** %5
%70 = getelementptr inbounds i8*, i8** %69, i64 1
%71 = load i8*, i8** %70
%72 = load i8*, i8** %11
%73 = call i64 @strcmp(i8* %71, i8* %72)
%74 = trunc i64 %73 to i32
store i32 %74, i32* %6
%75 = load i32, i32* %6
%76 = icmp eq i32 %75, 0
br i1 %76, label %77, label %78
77: ; preds = %68
store i8 97, i8* %8
br label %78
78: ; preds = %77, %68
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i8** %11
%79 = load i8**, i8*** %5
%80 = getelementptr inbounds i8*, i8** %79, i64 1
%81 = load i8*, i8** %80
%82 = load i8*, i8** %11
%83 = call i64 @strcmp(i8* %81, i8* %82)
%84 = trunc i64 %83 to i32
store i32 %84, i32* %6
%85 = load i32, i32* %6
%86 = icmp eq i32 %85, 0
br i1 %86, label %87, label %88
87: ; preds = %78
store i8 108, i8* %8
br label %88
88: ; preds = %87, %78
%89 = load i8**, i8*** %5
%90 = getelementptr inbounds i8*, i8** %89, i64 2
%91 = load i8*, i8** %90
%92 = call i32* @fopen(i8* %91, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %92, i32** %9
%93 = load i32*, i32** %9
%94 = icmp eq i32* %93, null
br i1 %94, label %95, label %101
95: ; preds = %88
%96 = load i32, i32* @stderr
%97 = load i8**, i8*** %5
%98 = getelementptr inbounds i8*, i8** %97, i64 2
%99 = load i8*, i8** %98
%100 = call i32 (i32, i8*, ...) @fprintf(i32 %96, i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.2, i64 0, i64 0), i8* %99)
store i32 2, i32* %3
br label %304
101: ; preds = %88
%102 = load i8**, i8*** %5
%103 = getelementptr inbounds i8*, i8** %102, i64 3
%104 = load i8*, i8** %103
%105 = call i32* @fopen(i8* %104, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
store i32* %105, i32** %10
%106 = load i32*, i32** %10
%107 = icmp eq i32* %106, null
br i1 %107, label %108, label %114
108: ; preds = %101
%109 = load i32, i32* @stderr
%110 = load i8**, i8*** %5
%111 = getelementptr inbounds i8*, i8** %110, i64 3
%112 = load i8*, i8** %111
%113 = call i32 (i32, i8*, ...) @fprintf(i32 %109, i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.4, i64 0, i64 0), i8* %112)
store i32 3, i32* %3
br label %304
114: ; preds = %101
br label %175
115: ; preds = %62
%116 = load i8**, i8*** %5
%117 = getelementptr inbounds i8*, i8** %116, i64 2
%118 = load i8*, i8** %117
%119 = call i64 @strcmp(i8* %118, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0))
%120 = icmp eq i64 %119, 0
br i1 %120, label %127, label %121
121: ; preds = %115
%122 = load i8**, i8*** %5
%123 = getelementptr inbounds i8*, i8** %122, i64 2
%124 = load i8*, i8** %123
%125 = call i64 @strcmp(i8* %124, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0))
%126 = icmp eq i64 %125, 0
br i1 %126, label %127, label %174
127: ; preds = %121, %115
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i8** %12
%128 = load i8**, i8*** %5
%129 = getelementptr inbounds i8*, i8** %128, i64 2
%130 = load i8*, i8** %129
%131 = load i8*, i8** %12
%132 = call i64 @strcmp(i8* %130, i8* %131)
%133 = trunc i64 %132 to i32
store i32 %133, i32* %6
%134 = load i32, i32* %6
%135 = icmp eq i32 %134, 0
br i1 %135, label %136, label %137
136: ; preds = %127
store i8 97, i8* %8
br label %137
137: ; preds = %136, %127
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i8** %12
%138 = load i8**, i8*** %5
%139 = getelementptr inbounds i8*, i8** %138, i64 2
%140 = load i8*, i8** %139
%141 = load i8*, i8** %12
%142 = call i64 @strcmp(i8* %140, i8* %141)
%143 = trunc i64 %142 to i32
store i32 %143, i32* %6
%144 = load i32, i32* %6
%145 = icmp eq i32 %144, 0
br i1 %145, label %146, label %147
146: ; preds = %137
store i8 108, i8* %8
br label %147
147: ; preds = %146, %137
%148 = load i8**, i8*** %5
%149 = getelementptr inbounds i8*, i8** %148, i64 1
%150 = load i8*, i8** %149
%151 = call i32* @fopen(i8* %150, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %151, i32** %9
%152 = load i32*, i32** %9
%153 = icmp eq i32* %152, null
br i1 %153, label %154, label %160
154: ; preds = %147
%155 = load i32, i32* @stderr
%156 = load i8**, i8*** %5
%157 = getelementptr inbounds i8*, i8** %156, i64 1
%158 = load i8*, i8** %157
%159 = call i32 (i32, i8*, ...) @fprintf(i32 %155, i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.2, i64 0, i64 0), i8* %158)
store i32 2, i32* %3
br label %304
160: ; preds = %147
%161 = load i8**, i8*** %5
%162 = getelementptr inbounds i8*, i8** %161, i64 3
%163 = load i8*, i8** %162
%164 = call i32* @fopen(i8* %163, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
store i32* %164, i32** %10
%165 = load i32*, i32** %10
%166 = icmp eq i32* %165, null
br i1 %166, label %167, label %173
167: ; preds = %160
%168 = load i32, i32* @stderr
%169 = load i8**, i8*** %5
%170 = getelementptr inbounds i8*, i8** %169, i64 3
%171 = load i8*, i8** %170
%172 = call i32 (i32, i8*, ...) @fprintf(i32 %168, i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.4, i64 0, i64 0), i8* %171)
store i32 3, i32* %3
br label %304
173: ; preds = %160
br label %174
174: ; preds = %173, %121
br label %175
175: ; preds = %174, %114
%176 = load i8**, i8*** %5
%177 = getelementptr inbounds i8*, i8** %176, i64 3
%178 = load i8*, i8** %177
%179 = call i64 @strcmp(i8* %178, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0))
%180 = icmp eq i64 %179, 0
br i1 %180, label %187, label %181
181: ; preds = %175
%182 = load i8**, i8*** %5
%183 = getelementptr inbounds i8*, i8** %182, i64 3
%184 = load i8*, i8** %183
%185 = call i64 @strcmp(i8* %184, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0))
%186 = icmp eq i64 %185, 0
br i1 %186, label %187, label %234
187: ; preds = %181, %175
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i8** %13
%188 = load i8**, i8*** %5
%189 = getelementptr inbounds i8*, i8** %188, i64 3
%190 = load i8*, i8** %189
%191 = load i8*, i8** %13
%192 = call i64 @strcmp(i8* %190, i8* %191)
%193 = trunc i64 %192 to i32
store i32 %193, i32* %6
%194 = load i32, i32* %6
%195 = icmp eq i32 %194, 0
br i1 %195, label %196, label %197
196: ; preds = %187
store i8 97, i8* %8
br label %197
197: ; preds = %196, %187
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i8** %13
%198 = load i8**, i8*** %5
%199 = getelementptr inbounds i8*, i8** %198, i64 3
%200 = load i8*, i8** %199
%201 = load i8*, i8** %13
%202 = call i64 @strcmp(i8* %200, i8* %201)
%203 = trunc i64 %202 to i32
store i32 %203, i32* %6
%204 = load i32, i32* %6
%205 = icmp eq i32 %204, 0
br i1 %205, label %206, label %207
206: ; preds = %197
store i8 108, i8* %8
br label %207
207: ; preds = %206, %197
%208 = load i8**, i8*** %5
%209 = getelementptr inbounds i8*, i8** %208, i64 1
%210 = load i8*, i8** %209
%211 = call i32* @fopen(i8* %210, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %211, i32** %9
%212 = load i32*, i32** %9
%213 = icmp eq i32* %212, null
br i1 %213, label %214, label %220
214: ; preds = %207
%215 = load i32, i32* @stderr
%216 = load i8**, i8*** %5
%217 = getelementptr inbounds i8*, i8** %216, i64 1
%218 = load i8*, i8** %217
%219 = call i32 (i32, i8*, ...) @fprintf(i32 %215, i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.2, i64 0, i64 0), i8* %218)
store i32 2, i32* %3
br label %304
220: ; preds = %207
%221 = load i8**, i8*** %5
%222 = getelementptr inbounds i8*, i8** %221, i64 2
%223 = load i8*, i8** %222
%224 = call i32* @fopen(i8* %223, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
store i32* %224, i32** %10
%225 = load i32*, i32** %10
%226 = icmp eq i32* %225, null
br i1 %226, label %227, label %233
227: ; preds = %220
%228 = load i32, i32* @stderr
%229 = load i8**, i8*** %5
%230 = getelementptr inbounds i8*, i8** %229, i64 2
%231 = load i8*, i8** %230
%232 = call i32 (i32, i8*, ...) @fprintf(i32 %228, i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.4, i64 0, i64 0), i8* %231)
store i32 3, i32* %3
br label %304
233: ; preds = %220
br label %234
234: ; preds = %233, %181
br label %235
235: ; preds = %234, %53
%236 = load i32*, i32** %9
%237 = load i32*, i32** %10
%238 = call i32 @check_magic(i32* %236, i32* %237)
store i32 %238, i32* %7
%239 = load i32, i32* %7
%240 = icmp ne i32 %239, 0
br i1 %240, label %241, label %249
241: ; preds = %235
%242 = call i32 (...) @fcloseall()
%243 = load i32, i32* @stderr
%244 = load i8**, i8*** %5
%245 = getelementptr inbounds i8*, i8** %244, i64 1
%246 = load i8*, i8** %245
%247 = call i32 (i32, i8*, ...) @fprintf(i32 %243, i8* getelementptr inbounds ([71 x i8], [71 x i8]* @.str.7, i64 0, i64 0), i8* %246)
%248 = load i32, i32* %7
store i32 %248, i32* %3
br label %304
249: ; preds = %235
%250 = bitcast [2 x i32]* %14 to i8*
%251 = getelementptr inbounds [2 x i32], [2 x i32]* %14, i64 0, i64 0
%252 = load i32*, i32** %9
%253 = load i32*, i32** %10
%254 = call i32 @check_dimensions(i32* %251, i32 2, i32* %252, i32* %253)
store i32 %254, i32* %7
%255 = load i32, i32* %7
%256 = icmp ne i32 %255, 0
br i1 %256, label %257, label %265
257: ; preds = %249
%258 = call i32 (...) @fcloseall()
%259 = load i32, i32* @stderr
%260 = load i8**, i8*** %5
%261 = getelementptr inbounds i8*, i8** %260, i64 1
%262 = load i8*, i8** %261
%263 = call i32 (i32, i8*, ...) @fprintf(i32 %259, i8* getelementptr inbounds ([69 x i8], [69 x i8]* @.str.8, i64 0, i64 0), i8* %262)
%264 = load i32, i32* %7
store i32 %264, i32* %3
br label %304
265: ; preds = %249
%266 = load i32*, i32** %9
%267 = load i32*, i32** %10
%268 = call i32 @check_luminance(i32* %266, i32* %267)
store i32 %268, i32* %7
%269 = load i32, i32* %7
%270 = icmp ne i32 %269, 0
br i1 %270, label %271, label %279
271: ; preds = %265
%272 = call i32 (...) @fcloseall()
%273 = load i32, i32* @stderr
%274 = load i8**, i8*** %5
%275 = getelementptr inbounds i8*, i8** %274, i64 1
%276 = load i8*, i8** %275
%277 = call i32 (i32, i8*, ...) @fprintf(i32 %273, i8* getelementptr inbounds ([68 x i8], [68 x i8]* @.str.9, i64 0, i64 0), i8* %276)
%278 = load i32, i32* %7
store i32 %278, i32* %3
br label %304
279: ; preds = %265
%280 = getelementptr inbounds [2 x i32], [2 x i32]* %14, i64 0, i64 0
%281 = load i32, i32* %280
%282 = getelementptr inbounds [2 x i32], [2 x i32]* %14, i64 0, i64 1
%283 = load i32, i32* %282
%284 = mul nsw i32 %281, %283
%285 = mul nsw i32 %284, 3
store i32 %285, i32* %6
%286 = load i32*, i32** %9
%287 = load i32*, i32** %10
%288 = load i32, i32* %6
%289 = load i8, i8* %8
%290 = call i32 @conversion(i32* %286, i32* %287, i32 %288, i8 signext %289)
store i32 %290, i32* %7
%291 = load i32, i32* %7
%292 = icmp ne i32 %291, 0
br i1 %292, label %293, label %301
293: ; preds = %279
%294 = call i32 (...) @fcloseall()
%295 = load i32, i32* @stderr
%296 = load i8**, i8*** %5
%297 = getelementptr inbounds i8*, i8** %296, i64 1
%298 = load i8*, i8** %297
%299 = call i32 (i32, i8*, ...) @fprintf(i32 %295, i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.10, i64 0, i64 0), i8* %298)
%300 = load i32, i32* %7
store i32 %300, i32* %3
br label %304
301: ; preds = %279
%302 = call i32 (...) @fcloseall()
%303 = load i32, i32* %7
store i32 %303, i32* %3
br label %304
304: ; preds = %301, %293, %271, %257, %241, %227, %214, %167, %154, %108, %95, %46, %33, %20
%305 = load i32, i32* %3
ret i32 %305
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [53 x i8] c"Not enough arguments in command line. Error code 1.\0A\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [53 x i8] c"Failed to open file '%s' for reading. Error code 2.\0A\00"
@.str.3 = [2 x i8] c"w\00"
@.str.4 = [53 x i8] c"Failed to open file '%s' for writing. Error code 3.\0A\00"
@.str.5 = [3 x i8] c"-a\00"
@.str.6 = [3 x i8] c"-l\00"
@.str.7 = [71 x i8] c"Header problem, please check magic number line in '%s'. Error code 4.\0A\00"
@.str.8 = [69 x i8] c"Header problem, please check dimensions line in '%s'. Error code 4.\0A\00"
@.str.9 = [68 x i8] c"Header problem, please check luminance line in '%s'. Error code 4.\0A\00"
@.str.10 = [51 x i8] c"Error reading image data from '%s'. Error code 2.\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i64
%4 = bitcast i64* %3 to [2 x i32]*
%5 = add i32 %0, -5
%6 = icmp ult i32 %5, -2
br i1 %6, label %7, label %10
7: ; preds = %2
%8 = load i32, i32* @stderr
%9 = tail call i32 (i32, i8*, ...) @fprintf(i32 %8, i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str, i64 0, i64 0))
br label %176
10: ; preds = %2
%11 = icmp eq i32 %0, 3
%12 = getelementptr inbounds i8*, i8** %1, i64 1
%13 = load i8*, i8** %12
br i1 %11, label %14, label %30
14: ; preds = %10
%15 = tail call i32* @fopen(i8* %13, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%16 = icmp eq i32* %15, null
br i1 %16, label %17, label %21
17: ; preds = %14
%18 = load i32, i32* @stderr
%19 = load i8*, i8** %12
%20 = tail call i32 (i32, i8*, ...) @fprintf(i32 %18, i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.2, i64 0, i64 0), i8* %19)
br label %176
21: ; preds = %14
%22 = getelementptr inbounds i8*, i8** %1, i64 2
%23 = load i8*, i8** %22
%24 = tail call i32* @fopen(i8* %23, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%25 = icmp eq i32* %24, null
br i1 %25, label %26, label %134
26: ; preds = %21
%27 = load i32, i32* @stderr
%28 = load i8*, i8** %22
%29 = tail call i32 (i32, i8*, ...) @fprintf(i32 %27, i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.4, i64 0, i64 0), i8* %28)
br label %176
30: ; preds = %10
%31 = tail call i64 @strcmp(i8* %13, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0))
%32 = icmp eq i64 %31, 0
br i1 %32, label %37, label %33
33: ; preds = %30
%34 = load i8*, i8** %12
%35 = tail call i64 @strcmp(i8* %34, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0))
%36 = icmp eq i64 %35, 0
br i1 %36, label %37, label %62
37: ; preds = %33, %30
%38 = load i8*, i8** %12
%39 = tail call i64 @strcmp(i8* %38, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0))
%40 = load i8*, i8** %12
%41 = tail call i64 @strcmp(i8* %40, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0))
%42 = getelementptr inbounds i8*, i8** %1, i64 2
%43 = load i8*, i8** %42
%44 = tail call i32* @fopen(i8* %43, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%45 = icmp eq i32* %44, null
br i1 %45, label %46, label %50
46: ; preds = %37
%47 = load i32, i32* @stderr
%48 = load i8*, i8** %42
%49 = tail call i32 (i32, i8*, ...) @fprintf(i32 %47, i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.2, i64 0, i64 0), i8* %48)
br label %176
50: ; preds = %37
%51 = trunc i64 %41 to i32
%52 = icmp eq i32 %51, 0
%53 = select i1 %52, i8 108, i8 97
%54 = getelementptr inbounds i8*, i8** %1, i64 3
%55 = load i8*, i8** %54
%56 = tail call i32* @fopen(i8* %55, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%57 = icmp eq i32* %56, null
br i1 %57, label %58, label %95
58: ; preds = %50
%59 = load i32, i32* @stderr
%60 = load i8*, i8** %54
%61 = tail call i32 (i32, i8*, ...) @fprintf(i32 %59, i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.4, i64 0, i64 0), i8* %60)
br label %176
62: ; preds = %33
%63 = getelementptr inbounds i8*, i8** %1, i64 2
%64 = load i8*, i8** %63
%65 = tail call i64 @strcmp(i8* %64, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0))
%66 = icmp eq i64 %65, 0
br i1 %66, label %71, label %67
67: ; preds = %62
%68 = load i8*, i8** %63
%69 = tail call i64 @strcmp(i8* %68, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0))
%70 = icmp eq i64 %69, 0
br i1 %70, label %71, label %95
71: ; preds = %67, %62
%72 = load i8*, i8** %63
%73 = tail call i64 @strcmp(i8* %72, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0))
%74 = load i8*, i8** %63
%75 = tail call i64 @strcmp(i8* %74, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0))
%76 = load i8*, i8** %12
%77 = tail call i32* @fopen(i8* %76, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%78 = icmp eq i32* %77, null
br i1 %78, label %79, label %83
79: ; preds = %71
%80 = load i32, i32* @stderr
%81 = load i8*, i8** %12
%82 = tail call i32 (i32, i8*, ...) @fprintf(i32 %80, i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.2, i64 0, i64 0), i8* %81)
br label %176
83: ; preds = %71
%84 = trunc i64 %75 to i32
%85 = icmp eq i32 %84, 0
%86 = select i1 %85, i8 108, i8 97
%87 = getelementptr inbounds i8*, i8** %1, i64 3
%88 = load i8*, i8** %87
%89 = tail call i32* @fopen(i8* %88, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%90 = icmp eq i32* %89, null
br i1 %90, label %91, label %95
91: ; preds = %83
%92 = load i32, i32* @stderr
%93 = load i8*, i8** %87
%94 = tail call i32 (i32, i8*, ...) @fprintf(i32 %92, i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.4, i64 0, i64 0), i8* %93)
br label %176
95: ; preds = %83, %50, %67
%96 = phi i8 [ 97, %67 ], [ %53, %50 ], [ %86, %83 ]
%97 = phi i32* [ null, %67 ], [ %44, %50 ], [ %77, %83 ]
%98 = phi i32* [ null, %67 ], [ %56, %50 ], [ %89, %83 ]
%99 = getelementptr inbounds i8*, i8** %1, i64 3
%100 = load i8*, i8** %99
%101 = tail call i64 @strcmp(i8* %100, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0))
%102 = icmp eq i64 %101, 0
br i1 %102, label %107, label %103
103: ; preds = %95
%104 = load i8*, i8** %99
%105 = tail call i64 @strcmp(i8* %104, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0))
%106 = icmp eq i64 %105, 0
br i1 %106, label %107, label %134
107: ; preds = %103, %95
%108 = load i8*, i8** %99
%109 = tail call i64 @strcmp(i8* %108, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0))
%110 = load i8*, i8** %99
%111 = tail call i64 @strcmp(i8* %110, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0))
%112 = load i8*, i8** %12
%113 = tail call i32* @fopen(i8* %112, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%114 = icmp eq i32* %113, null
br i1 %114, label %115, label %119
115: ; preds = %107
%116 = load i32, i32* @stderr
%117 = load i8*, i8** %12
%118 = tail call i32 (i32, i8*, ...) @fprintf(i32 %116, i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.2, i64 0, i64 0), i8* %117)
br label %176
119: ; preds = %107
%120 = trunc i64 %111 to i32
%121 = icmp eq i32 %120, 0
%122 = trunc i64 %109 to i32
%123 = icmp eq i32 %122, 0
%124 = select i1 %123, i8 97, i8 %96
%125 = select i1 %121, i8 108, i8 %124
%126 = getelementptr inbounds i8*, i8** %1, i64 2
%127 = load i8*, i8** %126
%128 = tail call i32* @fopen(i8* %127, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%129 = icmp eq i32* %128, null
br i1 %129, label %130, label %134
130: ; preds = %119
%131 = load i32, i32* @stderr
%132 = load i8*, i8** %126
%133 = tail call i32 (i32, i8*, ...) @fprintf(i32 %131, i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.4, i64 0, i64 0), i8* %132)
br label %176
134: ; preds = %119, %21, %103
%135 = phi i8 [ %96, %103 ], [ 97, %21 ], [ %125, %119 ]
%136 = phi i32* [ %97, %103 ], [ %15, %21 ], [ %113, %119 ]
%137 = phi i32* [ %98, %103 ], [ %24, %21 ], [ %128, %119 ]
%138 = tail call i32 @check_magic(i32* %136, i32* %137)
%139 = icmp eq i32 %138, 0
br i1 %139, label %146, label %140
140: ; preds = %134
%141 = tail call i32 (...) @fcloseall()
%142 = load i32, i32* @stderr
%143 = getelementptr inbounds i8*, i8** %1, i64 1
%144 = load i8*, i8** %143
%145 = tail call i32 (i32, i8*, ...) @fprintf(i32 %142, i8* getelementptr inbounds ([71 x i8], [71 x i8]* @.str.7, i64 0, i64 0), i8* %144)
br label %176
146: ; preds = %134
%147 = bitcast i64* %3 to i8*
store i64 0, i64* %3
%148 = bitcast i64* %3 to i32*
%149 = call i32 @check_dimensions(i32* %148, i32 2, i32* %136, i32* %137)
%150 = icmp eq i32 %149, 0
br i1 %150, label %151, label %163
151: ; preds = %146
%152 = call i32 @check_luminance(i32* %136, i32* %137)
%153 = icmp eq i32 %152, 0
br i1 %153, label %154, label %163
154: ; preds = %151
%155 = load i32, i32* %148
%156 = getelementptr inbounds [2 x i32], [2 x i32]* %4, i64 0, i64 1
%157 = load i32, i32* %156
%158 = mul i32 %155, 3
%159 = mul i32 %158, %157
%160 = call i32 @conversion(i32* %136, i32* %137, i32 %159, i8 signext %135)
%161 = icmp eq i32 %160, 0
%162 = call i32 (...) @fcloseall()
br i1 %161, label %174, label %167
163: ; preds = %151, %146
%164 = phi i8* [ getelementptr inbounds ([69 x i8], [69 x i8]* @.str.8, i64 0, i64 0), %146 ], [ getelementptr inbounds ([68 x i8], [68 x i8]* @.str.9, i64 0, i64 0), %151 ]
%165 = phi i32 [ %149, %146 ], [ %152, %151 ]
%166 = call i32 (...) @fcloseall()
br label %167
167: ; preds = %163, %154
%168 = phi i8* [ getelementptr inbounds ([51 x i8], [51 x i8]* @.str.10, i64 0, i64 0), %154 ], [ %164, %163 ]
%169 = phi i32 [ %160, %154 ], [ %165, %163 ]
%170 = load i32, i32* @stderr
%171 = getelementptr inbounds i8*, i8** %1, i64 1
%172 = load i8*, i8** %171
%173 = call i32 (i32, i8*, ...) @fprintf(i32 %170, i8* %168, i8* %172)
br label %174
174: ; preds = %167, %154
%175 = phi i32 [ 0, %154 ], [ %169, %167 ]
br label %176
176: ; preds = %130, %115, %91, %79, %58, %46, %174, %140, %26, %17, %7
%177 = phi i32 [ 1, %7 ], [ 2, %17 ], [ 3, %26 ], [ %138, %140 ], [ %175, %174 ], [ 3, %58 ], [ 2, %46 ], [ 3, %91 ], [ 2, %79 ], [ 3, %130 ], [ 2, %115 ]
ret i32 %177
}