#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*/ filename_from;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ SEEK_END;
char *changefileext(char *, char *);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, unsigned int,
                           unsigned int);
size_t fread(unsigned char *, int, unsigned long, int /*<<< orphan*/ *);
int /*<<< orphan*/ free(unsigned char *);
int /*<<< orphan*/ fseek(int /*<<< orphan*/ *, int /*<<< orphan*/,
                         int /*<<< orphan*/);
unsigned long ftell(int /*<<< orphan*/ *);
int /*<<< orphan*/ fwrite(unsigned char *, int, int, int /*<<< orphan*/ *);
unsigned char *malloc(int);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ rewind(int /*<<< orphan*/ *);
int /*<<< orphan*/ sprintf(char *, char *, unsigned int);
scalar_t__ strncmp(char *, char *, int);
char *strrchr(char *, char);
int main(int argc, char *argv[]) {
  char *filename_from, *filename_to;
  int mode;
  unsigned long size;
  unsigned char *buf;
  size_t res;
  if (argc == 1) {
    printf("ERACHA data converter\n");
    printf("-------------------------------\n");
    printf("usage: edc file1.ext1 [file2.ext2]\n\n");
    printf("modes supported:\n");
    printf(" - BCK => PCX\n");
    printf(" - SAN => PPM\n");
    exit(0);
  } else if (argc == 3) {
    filename_from = argv[1];
    filename_to = argv[2];
  } else if (argc == 2) {
    filename_from = argv[1];
    filename_to = (char *)malloc(sizeof(filename_from) + 1);
    if (filename_to == NULL) {
      perror("malloc");
      exit(1);
    }
  } else {
    printf("Too many arguments!\n");
    exit(1);
  }
  char *ext = strrchr(filename_from, '.');
  if (!ext) {
    printf("filename '%s' has no extension!\n", filename_from);
    exit(1);
  } else if (strncmp(ext, ".bck", 4) == 0 || strncmp(ext, ".BCK", 4) == 0) {
    mode = 1;
    printf("Converting bck to pcx\n");
  } else if (strncmp(ext, ".san", 4) == 0 || strncmp(ext, ".SAN", 4) == 0) {
    mode = 3;
    printf("Converting san to ppm\n");
  } else {
    printf("extension is '%s', do not know what to do...(yet!)\n", ext + 1);
    exit(1);
  }
  FILE *fp = fopen(filename_from, "rb");
  if (fp == NULL) {
    perror("fopen");
    exit(1);
  }
  fseek(fp, 0, SEEK_END);
  size = ftell(fp);
  rewind(fp);
  buf = (unsigned char *)malloc(sizeof(char) * size);
  if (buf == NULL) {
    perror("malloc");
    exit(1);
  }
  res = fread(buf, 1, size, fp);
  if (res != size) {
    perror("fread");
    exit(1);
  }
  if (mode == 1) {
    if (buf[11] == 'P' && buf[12] == 'C' && buf[13] == 'X') {
      if (filename_to[0] == '\0') {
        filename_to = changefileext(filename_from, ".pcx");
      }
      printf("'%s' has size of %li bytes, setting resolution to %dx%d.\n",
             filename_from, size - 19, 320, 200);
      printf("Writing %li bytes to %s\n", size - 19 + 128, filename_to);
      FILE *des = fopen(filename_to, "wb");
      if (!des) {
        perror("create file");
        exit(1);
      }
      unsigned char *pcxheader = malloc(128);
      if (pcxheader == NULL) {
        perror("malloc");
        exit(1);
      }
      pcxheader[0] = 10;
      pcxheader[1] = 5;
      pcxheader[2] = 1;
      pcxheader[3] = 8;
      pcxheader[8] = (320 - 1) & 0xFF;
      pcxheader[9] = (320 - 1) >> 8;
      pcxheader[10] = (200 - 1) & 0xFF;
      pcxheader[11] = (200 - 1) >> 8;
      pcxheader[65] = 1;
      pcxheader[66] = 320 & 0xFF;
      pcxheader[67] = 320 >> 8;
      fwrite(pcxheader, 128, 1, des);
      fwrite(&buf[19], size - 19, 1, des);
      free(pcxheader);
      fclose(des);
    } else {
      printf("'%s' is no valid BCK file!\n", filename_from);
    }
  } else if (mode == 3) {
    if (buf[0] == '[' && buf[1] == 'S' && buf[5] == 'S' && buf[9] == ']') {
      unsigned int count;
      if (filename_to[0] == '\0') {
        filename_to = changefileext(filename_from, ".ppm");
      }
      count = buf[10];
      printf("'%s' has %d images, file size is %li.\n", filename_from, count,
             size - 12);
      unsigned int id, offset, width, height, bytes, i, j, ignore_flag, padding,
          pix_count;
      offset = 12;
      for (id = 0; id < count; id++) {
        char id_ext[5];
        sprintf(id_ext, ".%02d_ppm", id);
        filename_to = changefileext(filename_from, id_ext);
        FILE *des = fopen(filename_to, "wb");
        if (!des) {
          perror("create file");
          exit(1);
        }
        width = buf[offset];
        height = buf[offset + 2];
        bytes = buf[offset + 4] | (buf[offset + 5] << 8);
        printf("image %d, %dx%d, size is %d.\n", id + 1, width, height, bytes);
        unsigned char pixel[3];
        fprintf(des, "P6\n%d %d\n255\n", width, height);
        pix_count = 0;
        for (i = 0; i < bytes; i++) {
          if (ignore_flag) {
            ignore_flag = 0;
            continue;
          }
          if (buf[offset + 6 + i] == '\0') {
            ignore_flag = 1;
            padding = buf[offset + 6 + i + 1];
            for (j = 0; j < padding; j++) {
              pixel[0] = 0;
              pixel[1] = 255;
              pixel[2] = 0;
              fwrite(pixel, 1, 3, des);
              pix_count++;
            }
          } else {
            pixel[0] = buf[offset + 6 + i];
            pixel[1] = buf[offset + 6 + i];
            pixel[2] = buf[offset + 6 + i];
            fwrite(pixel, 1, 3, des);
            pix_count++;
          }
        }
        for (j = pix_count - 1; j < width * height; j++) {
          pixel[0] = 0;
          pixel[1] = 255;
          pixel[2] = 0;
          fwrite(pixel, 1, 3, des);
        }
        offset += bytes + 8;
        fclose(des);
      }
    } else {
      printf("'%s' is no valid SAN file!\n", filename_from);
    }
  } else {
    printf("-UNKNOWN MODE-\n");
  }
  fclose(fp);
  free(buf);
  exit(0);
}


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)
cmpl   $0x1,-0x8(%rbp)
jne    128e <main+0x7e>
lea    0xdc6(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
lea    0xdcf(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
lea    0xde2(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
lea    0xdf9(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
lea    0xdfd(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
lea    0xdfe(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
xor    %edi,%edi
call   1120 <exit@plt>
cmpl   $0x3,-0x8(%rbp)
jne    12b5 <main+0xa5>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rax
mov    %rax,-0x20(%rbp)
jmp    131c <main+0x10c>
cmpl   $0x2,-0x8(%rbp)
jne    12ff <main+0xef>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x18(%rbp)
mov    $0x9,%edi
call   10c0 <malloc@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    12fa <main+0xea>
lea    0xda2(%rip),%rdi
call   10f0 <perror@plt>
mov    $0x1,%edi
call   1120 <exit@plt>
jmp    1317 <main+0x107>
lea    0xd8e(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    $0x1,%edi
call   1120 <exit@plt>
jmp    131c <main+0x10c>
jmp    1321 <main+0x111>
mov    -0x18(%rbp),%rdi
mov    $0x2e,%esi
call   1090 <strrchr@plt>
mov    %rax,-0x48(%rbp)
cmpq   $0x0,-0x48(%rbp)
jne    135a <main+0x14a>
mov    -0x18(%rbp),%rsi
lea    0xd60(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    $0x1,%edi
call   1120 <exit@plt>
mov    -0x48(%rbp),%rdi
lea    0xd65(%rip),%rsi
mov    $0x4,%edx
call   1040 <strncmp@plt>
cmp    $0x0,%rax
je     1398 <main+0x188>
mov    -0x48(%rbp),%rdi
lea    0xd4b(%rip),%rsi
mov    $0x4,%edx
call   1040 <strncmp@plt>
cmp    $0x0,%rax
jne    13b2 <main+0x1a2>
movl   $0x1,-0x24(%rbp)
lea    0xd2e(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
jmp    142f <main+0x21f>
mov    -0x48(%rbp),%rdi
lea    0xd2e(%rip),%rsi
mov    $0x4,%edx
call   1040 <strncmp@plt>
cmp    $0x0,%rax
je     13f0 <main+0x1e0>
mov    -0x48(%rbp),%rdi
lea    0xd14(%rip),%rsi
mov    $0x4,%edx
call   1040 <strncmp@plt>
cmp    $0x0,%rax
jne    140a <main+0x1fa>
movl   $0x3,-0x24(%rbp)
lea    0xcf7(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
jmp    142a <main+0x21a>
mov    -0x48(%rbp),%rsi
add    $0x1,%rsi
lea    0xcf3(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    $0x1,%edi
call   1120 <exit@plt>
jmp    142f <main+0x21f>
jmp    1434 <main+0x224>
mov    -0x18(%rbp),%rdi
lea    0xd01(%rip),%rsi
call   10e0 <fopen@plt>
mov    %rax,-0x50(%rbp)
cmpq   $0x0,-0x50(%rbp)
jne    1469 <main+0x259>
lea    0xce9(%rip),%rdi
call   10f0 <perror@plt>
mov    $0x1,%edi
call   1120 <exit@plt>
mov    -0x50(%rbp),%rdi
mov    0x2b74(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   10d0 <fseek@plt>
mov    -0x50(%rbp),%rdi
call   10b0 <ftell@plt>
mov    %rax,-0x30(%rbp)
mov    -0x50(%rbp),%rdi
call   1080 <rewind@plt>
mov    -0x30(%rbp),%rax
shl    $0x0,%rax
mov    %eax,%edi
call   10c0 <malloc@plt>
mov    %rax,-0x38(%rbp)
cmpq   $0x0,-0x38(%rbp)
jne    14c7 <main+0x2b7>
lea    0xbd5(%rip),%rdi
call   10f0 <perror@plt>
mov    $0x1,%edi
call   1120 <exit@plt>
mov    -0x38(%rbp),%rdi
mov    -0x30(%rbp),%rdx
mov    -0x50(%rbp),%rcx
mov    $0x1,%esi
call   1050 <fread@plt>
mov    %rax,-0x40(%rbp)
mov    -0x40(%rbp),%rax
cmp    -0x30(%rbp),%rax
je     1505 <main+0x2f5>
lea    0xc53(%rip),%rdi
call   10f0 <perror@plt>
mov    $0x1,%edi
call   1120 <exit@plt>
cmpl   $0x1,-0x24(%rbp)
jne    16cc <main+0x4bc>
mov    -0x38(%rbp),%rax
movzbl 0xb(%rax),%eax
cmp    $0x50,%eax
jne    16b5 <main+0x4a5>
mov    -0x38(%rbp),%rax
movzbl 0xc(%rax),%eax
cmp    $0x43,%eax
jne    16b5 <main+0x4a5>
mov    -0x38(%rbp),%rax
movzbl 0xd(%rax),%eax
cmp    $0x58,%eax
jne    16b5 <main+0x4a5>
mov    -0x20(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
jne    1566 <main+0x356>
mov    -0x18(%rbp),%rdi
lea    0xbf2(%rip),%rsi
call   1100 <changefileext@plt>
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rsi
mov    -0x30(%rbp),%rdx
sub    $0x13,%rdx
lea    0xbdb(%rip),%rdi
mov    $0x140,%ecx
mov    $0xc8,%r8d
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0x30(%rbp),%rsi
sub    $0x13,%rsi
add    $0x80,%rsi
mov    -0x20(%rbp),%rdx
lea    0xbe9(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0x20(%rbp),%rdi
lea    0xbf0(%rip),%rsi
call   10e0 <fopen@plt>
mov    %rax,-0x58(%rbp)
cmpq   $0x0,-0x58(%rbp)
jne    15e1 <main+0x3d1>
lea    0xbd8(%rip),%rdi
call   10f0 <perror@plt>
mov    $0x1,%edi
call   1120 <exit@plt>
mov    $0x80,%edi
call   10c0 <malloc@plt>
mov    %rax,-0x60(%rbp)
cmpq   $0x0,-0x60(%rbp)
jne    1610 <main+0x400>
lea    0xa8c(%rip),%rdi
call   10f0 <perror@plt>
mov    $0x1,%edi
call   1120 <exit@plt>
mov    -0x60(%rbp),%rax
movb   $0xa,(%rax)
mov    -0x60(%rbp),%rax
movb   $0x5,0x1(%rax)
mov    -0x60(%rbp),%rax
movb   $0x1,0x2(%rax)
mov    -0x60(%rbp),%rax
movb   $0x8,0x3(%rax)
mov    -0x60(%rbp),%rax
movb   $0x3f,0x8(%rax)
mov    -0x60(%rbp),%rax
movb   $0x1,0x9(%rax)
mov    -0x60(%rbp),%rax
movb   $0xc7,0xa(%rax)
mov    -0x60(%rbp),%rax
movb   $0x0,0xb(%rax)
mov    -0x60(%rbp),%rax
movb   $0x1,0x41(%rax)
mov    -0x60(%rbp),%rax
movb   $0x40,0x42(%rax)
mov    -0x60(%rbp),%rax
movb   $0x1,0x43(%rax)
mov    -0x60(%rbp),%rdi
mov    -0x58(%rbp),%rcx
mov    $0x80,%esi
mov    $0x1,%edx
call   1130 <fwrite@plt>
mov    -0x38(%rbp),%rdi
add    $0x13,%rdi
mov    -0x30(%rbp),%rax
sub    $0x13,%rax
mov    %eax,%esi
mov    -0x58(%rbp),%rcx
mov    $0x1,%edx
call   1130 <fwrite@plt>
mov    -0x60(%rbp),%rdi
call   1030 <free@plt>
mov    -0x58(%rbp),%rdi
call   1060 <fclose@plt>
jmp    16c7 <main+0x4b7>
mov    -0x18(%rbp),%rsi
lea    0xaf6(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
jmp    1a83 <main+0x873>
cmpl   $0x3,-0x24(%rbp)
jne    1a70 <main+0x860>
mov    -0x38(%rbp),%rax
movzbl (%rax),%eax
cmp    $0x5b,%eax
jne    1a59 <main+0x849>
mov    -0x38(%rbp),%rax
movzbl 0x1(%rax),%eax
cmp    $0x53,%eax
jne    1a59 <main+0x849>
mov    -0x38(%rbp),%rax
movzbl 0x5(%rax),%eax
cmp    $0x53,%eax
jne    1a59 <main+0x849>
mov    -0x38(%rbp),%rax
movzbl 0x9(%rax),%eax
cmp    $0x5d,%eax
jne    1a59 <main+0x849>
mov    -0x20(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
jne    173d <main+0x52d>
mov    -0x18(%rbp),%rdi
lea    0xa9e(%rip),%rsi
call   1100 <changefileext@plt>
mov    %rax,-0x20(%rbp)
mov    -0x38(%rbp),%rax
movzbl 0xa(%rax),%eax
mov    %eax,-0x64(%rbp)
mov    -0x18(%rbp),%rsi
mov    -0x64(%rbp),%edx
mov    -0x30(%rbp),%rcx
sub    $0xc,%rcx
lea    0xa79(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
movl   $0xc,-0x6c(%rbp)
movl   $0x0,-0x68(%rbp)
mov    -0x68(%rbp),%eax
cmp    -0x64(%rbp),%eax
jae    1a54 <main+0x844>
lea    -0x91(%rbp),%rdi
mov    -0x68(%rbp),%edx
lea    0xa6e(%rip),%rsi
call   1110 <sprintf@plt>
mov    -0x18(%rbp),%rdi
lea    -0x91(%rbp),%rsi
call   1100 <changefileext@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
lea    0x9f3(%rip),%rsi
call   10e0 <fopen@plt>
mov    %rax,-0xa0(%rbp)
cmpq   $0x0,-0xa0(%rbp)
jne    17e4 <main+0x5d4>
lea    0x9d5(%rip),%rdi
call   10f0 <perror@plt>
mov    $0x1,%edi
call   1120 <exit@plt>
mov    -0x38(%rbp),%rax
mov    -0x6c(%rbp),%ecx
movzbl (%rax,%rcx,1),%eax
mov    %eax,-0x70(%rbp)
mov    -0x38(%rbp),%rax
mov    -0x6c(%rbp),%ecx
add    $0x2,%ecx
mov    %ecx,%ecx
movzbl (%rax,%rcx,1),%eax
mov    %eax,-0x74(%rbp)
mov    -0x38(%rbp),%rax
mov    -0x6c(%rbp),%ecx
add    $0x4,%ecx
mov    %ecx,%ecx
movzbl (%rax,%rcx,1),%eax
mov    -0x38(%rbp),%rcx
mov    -0x6c(%rbp),%edx
add    $0x5,%edx
mov    %edx,%edx
movzbl (%rcx,%rdx,1),%ecx
shl    $0x8,%ecx
or     %ecx,%eax
mov    %eax,-0x78(%rbp)
mov    -0x68(%rbp),%esi
add    $0x1,%esi
mov    -0x70(%rbp),%edx
mov    -0x74(%rbp),%ecx
mov    -0x78(%rbp),%r8d
lea    0x9c4(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0xa0(%rbp),%rdi
mov    -0x70(%rbp),%edx
mov    -0x74(%rbp),%ecx
lea    0x9c7(%rip),%rsi
call   10a0 <fprintf@plt>
movl   $0x0,-0x8c(%rbp)
movl   $0x0,-0x7c(%rbp)
mov    -0x7c(%rbp),%eax
cmp    -0x78(%rbp),%eax
jae    19d0 <main+0x7c0>
cmpl   $0x0,-0x84(%rbp)
je     189d <main+0x68d>
movl   $0x0,-0x84(%rbp)
jmp    19c2 <main+0x7b2>
mov    -0x38(%rbp),%rax
mov    -0x6c(%rbp),%ecx
add    $0x6,%ecx
add    -0x7c(%rbp),%ecx
mov    %ecx,%ecx
movzbl (%rax,%rcx,1),%eax
cmp    $0x0,%eax
jne    1949 <main+0x739>
movl   $0x1,-0x84(%rbp)
mov    -0x38(%rbp),%rax
mov    -0x6c(%rbp),%ecx
add    $0x6,%ecx
add    -0x7c(%rbp),%ecx
add    $0x1,%ecx
mov    %ecx,%ecx
movzbl (%rax,%rcx,1),%eax
mov    %eax,-0x88(%rbp)
movl   $0x0,-0x80(%rbp)
mov    -0x80(%rbp),%eax
cmp    -0x88(%rbp),%eax
jae    1944 <main+0x734>
movb   $0x0,-0xa3(%rbp)
movb   $0xff,-0xa2(%rbp)
movb   $0x0,-0xa1(%rbp)
lea    -0xa3(%rbp),%rdi
mov    -0xa0(%rbp),%rcx
mov    $0x1,%esi
mov    $0x3,%edx
call   1130 <fwrite@plt>
mov    -0x8c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8c(%rbp)
mov    -0x80(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x80(%rbp)
jmp    18e6 <main+0x6d6>
jmp    19bd <main+0x7ad>
mov    -0x38(%rbp),%rax
mov    -0x6c(%rbp),%ecx
add    $0x6,%ecx
add    -0x7c(%rbp),%ecx
mov    %ecx,%ecx
mov    (%rax,%rcx,1),%al
mov    %al,-0xa3(%rbp)
mov    -0x38(%rbp),%rax
mov    -0x6c(%rbp),%ecx
add    $0x6,%ecx
add    -0x7c(%rbp),%ecx
mov    %ecx,%ecx
mov    (%rax,%rcx,1),%al
mov    %al,-0xa2(%rbp)
mov    -0x38(%rbp),%rax
mov    -0x6c(%rbp),%ecx
add    $0x6,%ecx
add    -0x7c(%rbp),%ecx
mov    %ecx,%ecx
mov    (%rax,%rcx,1),%al
mov    %al,-0xa1(%rbp)
lea    -0xa3(%rbp),%rdi
mov    -0xa0(%rbp),%rcx
mov    $0x1,%esi
mov    $0x3,%edx
call   1130 <fwrite@plt>
mov    -0x8c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8c(%rbp)
jmp    19c2 <main+0x7b2>
mov    -0x7c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x7c(%rbp)
jmp    1875 <main+0x665>
mov    -0x8c(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x80(%rbp)
mov    -0x80(%rbp),%eax
mov    -0x70(%rbp),%ecx
imul   -0x74(%rbp),%ecx
cmp    %ecx,%eax
jae    1a2e <main+0x81e>
movb   $0x0,-0xa3(%rbp)
movb   $0xff,-0xa2(%rbp)
movb   $0x0,-0xa1(%rbp)
lea    -0xa3(%rbp),%rdi
mov    -0xa0(%rbp),%rcx
mov    $0x1,%esi
mov    $0x3,%edx
call   1130 <fwrite@plt>
mov    -0x80(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x80(%rbp)
jmp    19dc <main+0x7cc>
mov    -0x78(%rbp),%eax
add    $0x8,%eax
add    -0x6c(%rbp),%eax
mov    %eax,-0x6c(%rbp)
mov    -0xa0(%rbp),%rdi
call   1060 <fclose@plt>
mov    -0x68(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x68(%rbp)
jmp    1773 <main+0x563>
jmp    1a6b <main+0x85b>
mov    -0x18(%rbp),%rsi
lea    0x7d0(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
jmp    1a7e <main+0x86e>
lea    0x7d9(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
jmp    1a83 <main+0x873>
mov    -0x50(%rbp),%rdi
call   1060 <fclose@plt>
mov    -0x38(%rbp),%rdi
call   1030 <free@plt>
xor    %edi,%edi
call   1120 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x58,%rsp
mov    %rsi,%rbx
cmp    $0x3,%edi
je     1293 <main+0x73>
cmp    $0x2,%edi
je     1299 <main+0x79>
cmp    $0x1,%edi
jne    12e0 <main+0xc0>
lea    0xf84(%rip),%rdi
call   1050 <puts@plt>
lea    0xf8e(%rip),%rdi
call   1050 <puts@plt>
lea    0xfa2(%rip),%rdi
call   1050 <puts@plt>
lea    0xfba(%rip),%rdi
call   1050 <puts@plt>
lea    0xfbf(%rip),%rdi
call   1050 <puts@plt>
lea    0xfc1(%rip),%rdi
call   1050 <puts@plt>
xor    %edi,%edi
call   1130 <exit@plt>
mov    0x10(%rbx),%r12
jmp    12af <main+0x8f>
mov    $0x9,%edi
call   10d0 <malloc@plt>
mov    %rax,%r12
test   %rax,%rax
je     13e2 <main+0x1c2>
mov    0x8(%rbx),%rbp
mov    %rbp,%rdi
mov    $0x2e,%esi
call   10a0 <strrchr@plt>
test   %rax,%rax
jne    12f6 <main+0xd6>
lea    0xd3b(%rip),%rdi
mov    %rbp,%rsi
xor    %eax,%eax
call   1080 <printf@plt>
mov    $0x1,%edi
call   1130 <exit@plt>
lea    0xe99(%rip),%rdi
call   1050 <puts@plt>
mov    $0x1,%edi
call   1130 <exit@plt>
mov    %rax,%rbx
mov    %rbp,0x30(%rsp)
lea    0xd23(%rip),%rsi
mov    %rax,%rdi
mov    $0x4,%edx
call   1040 <strncmp@plt>
mov    $0x1,%r15b
lea    0xe9d(%rip),%rbp
test   %rax,%rax
je     133a <main+0x11a>
lea    0xd05(%rip),%rsi
mov    %rbx,%rdi
mov    $0x4,%edx
call   1040 <strncmp@plt>
test   %rax,%rax
jne    133f <main+0x11f>
xor    %r13d,%r13d
jmp    1382 <main+0x162>
lea    0xcec(%rip),%rsi
mov    %rbx,%rdi
mov    $0x4,%edx
call   1040 <strncmp@plt>
mov    $0x1,%r13b
lea    0xe37(%rip),%rbp
test   %rax,%rax
je     137f <main+0x15f>
lea    0xcce(%rip),%rsi
mov    %rbx,%rdi
mov    $0x4,%edx
call   1040 <strncmp@plt>
test   %rax,%rax
jne    14ce <main+0x2ae>
xor    %r15d,%r15d
mov    %rbp,%rdi
call   1050 <puts@plt>
lea    0xcdf(%rip),%rsi
mov    0x30(%rsp),%rbx
mov    %rbx,%rdi
call   10f0 <fopen@plt>
test   %rax,%rax
jne    13ac <main+0x18c>
lea    0xcc9(%rip),%rdi
jmp    13e9 <main+0x1c9>
mov    %rax,%rbp
mov    0x2c32(%rip),%rax
mov    (%rax),%edx
mov    %rbp,%rdi
xor    %esi,%esi
call   10e0 <fseek@plt>
mov    %rbp,%rdi
call   10c0 <ftell@plt>
mov    %rax,%r14
mov    %rbp,%rdi
call   1090 <rewind@plt>
mov    %r14d,%edi
call   10d0 <malloc@plt>
test   %rax,%rax
jne    13f8 <main+0x1d8>
lea    0xc17(%rip),%rdi
call   1100 <perror@plt>
mov    $0x1,%edi
call   1130 <exit@plt>
mov    %rax,0x8(%rsp)
mov    %rax,%rdi
mov    $0x1,%esi
mov    %r14,%rdx
mov    %rbp,%rcx
call   1060 <fread@plt>
cmp    %r14,%rax
jne    14c2 <main+0x2a2>
test   %r15b,%r15b
mov    %rbp,0x40(%rsp)
je     14e1 <main+0x2c1>
mov    0x8(%rsp),%rbp
cmpb   $0x50,0xb(%rbp)
jne    178c <main+0x56c>
cmpb   $0x43,0xc(%rbp)
jne    178c <main+0x56c>
cmpb   $0x58,0xd(%rbp)
jne    178c <main+0x56c>
cmpb   $0x0,(%r12)
jne    1463 <main+0x243>
lea    0xc27(%rip),%rsi
mov    %rbx,%rdi
call   1110 <changefileext@plt>
mov    %rax,%r12
lea    -0x13(%r14),%r15
lea    0xc16(%rip),%rdi
mov    %rbx,%rsi
mov    %r15,%rdx
mov    $0x140,%ecx
mov    $0xc8,%r8d
xor    %eax,%eax
call   1080 <printf@plt>
add    $0x6d,%r14
lea    0xc2d(%rip),%rdi
mov    %r14,%rsi
mov    %r12,%rdx
xor    %eax,%eax
call   1080 <printf@plt>
lea    0xc32(%rip),%rsi
mov    %r12,%rdi
call   10f0 <fopen@plt>
test   %rax,%rax
jne    17d5 <main+0x5b5>
lea    0xc1d(%rip),%rdi
jmp    13e9 <main+0x1c9>
lea    0xbb0(%rip),%rdi
jmp    13e9 <main+0x1c9>
add    $0x1,%rbx
lea    0xb63(%rip),%rdi
mov    %rbx,%rsi
jmp    12cf <main+0xaf>
test   %r13b,%r13b
je     1795 <main+0x575>
mov    0x8(%rsp),%rbp
cmpb   $0x5b,0x0(%rbp)
jne    17a8 <main+0x588>
cmpb   $0x53,0x1(%rbp)
jne    17a8 <main+0x588>
cmpb   $0x53,0x5(%rbp)
jne    17a8 <main+0x588>
cmpb   $0x5d,0x9(%rbp)
jne    17a8 <main+0x588>
cmpb   $0x0,(%r12)
jne    152d <main+0x30d>
lea    0xbdd(%rip),%rsi
mov    %rbx,%rdi
call   1110 <changefileext@plt>
mov    0x8(%rsp),%rax
movzbl 0xa(%rax),%r15d
add    $0xfffffffffffffff4,%r14
lea    0xbc5(%rip),%rdi
xor    %ebp,%ebp
mov    %rbx,%rsi
mov    %r15d,%edx
mov    %r14,%rcx
mov    %rax,%r14
xor    %eax,%eax
call   1080 <printf@plt>
mov    %r15d,0x24(%rsp)
test   %r15d,%r15d
je     17bc <main+0x59c>
mov    $0xc,%eax
mov    %rax,0x10(%rsp)
jmp    15aa <main+0x38a>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    0x10(%rsp),%rax
mov    0x38(%rsp),%rcx
add    %ecx,%eax
add    $0x8,%eax
mov    %rax,0x10(%rsp)
mov    %r15,%rdi
call   1070 <fclose@plt>
mov    0x2c(%rsp),%ebp
cmp    0x24(%rsp),%ebp
je     17bc <main+0x59c>
lea    0x53(%rsp),%r15
mov    %r15,%rdi
lea    0xb75(%rip),%rsi
mov    %ebp,%edx
call   1120 <sprintf@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
call   1110 <changefileext@plt>
mov    %rax,%rdi
lea    0xb02(%rip),%rsi
call   10f0 <fopen@plt>
test   %rax,%rax
je     14b6 <main+0x296>
mov    %ebp,%esi
mov    %rax,%r15
mov    0x10(%rsp),%rbp
mov    %ebp,%eax
mov    %r14,%rdx
movzbl (%r14,%rax,1),%r14d
lea    0x2(%rbp),%eax
movzbl (%rdx,%rax,1),%r12d
lea    0x4(%rbp),%eax
movzbl (%rdx,%rax,1),%eax
lea    0x5(%rbp),%ecx
movzbl (%rdx,%rcx,1),%ebx
shl    $0x8,%rbx
or     %rax,%rbx
add    $0x1,%esi
lea    0xb1a(%rip),%rdi
mov    %esi,0x2c(%rsp)
mov    %r14d,%edx
mov    %r12d,%ecx
mov    %ebx,%r8d
xor    %eax,%eax
call   1080 <printf@plt>
mov    %r15,%rdi
lea    0xb1a(%rip),%rsi
mov    %r14d,0x28(%rsp)
mov    %r14d,%edx
mov    %r12d,%ecx
call   10b0 <fprintf@plt>
test   %rbx,%rbx
mov    %rbx,%rax
mov    %rbx,0x38(%rsp)
je     1730 <main+0x510>
lea    0x6(%rbp),%eax
mov    %rax,0x48(%rsp)
xor    %ebp,%ebp
xor    %ecx,%ecx
mov    0x8(%rsp),%r14
jmp    16ab <main+0x48b>
mov    %cl,0x5(%rsp)
mov    %cl,0x6(%rsp)
mov    %cl,0x7(%rsp)
lea    0x5(%rsp),%rdi
mov    $0x1,%esi
mov    $0x3,%edx
mov    %r15,%rcx
call   1140 <fwrite@plt>
mov    0x18(%rsp),%rcx
add    $0x1,%ecx
xor    %r13d,%r13d
add    $0x1,%rbp
cmp    %rbx,%rbp
je     1737 <main+0x517>
test   %r13d,%r13d
jne    169b <main+0x47b>
mov    %rcx,0x18(%rsp)
mov    0x48(%rsp),%rax
add    %ebp,%eax
mov    (%r14,%rax,1),%cl
test   %cl,%cl
jne    1670 <main+0x450>
add    $0x1,%eax
movzbl (%r14,%rax,1),%eax
mov    $0x1,%r13d
test   %eax,%eax
je     1723 <main+0x503>
mov    %eax,%ebx
mov    %eax,%r14d
lea    0x5(%rsp),%r13
movw   $0xff00,0x5(%rsp)
movb   $0x0,0x7(%rsp)
mov    %r13,%rdi
mov    $0x1,%esi
mov    $0x3,%edx
mov    %r15,%rcx
call   1140 <fwrite@plt>
add    $0xffffffff,%r14d
jne    16e0 <main+0x4c0>
mov    0x18(%rsp),%rcx
add    %ebx,%ecx
mov    0x8(%rsp),%r14
mov    0x38(%rsp),%rbx
mov    $0x1,%r13d
jmp    169e <main+0x47e>
mov    0x18(%rsp),%rcx
jmp    169e <main+0x47e>
nopl   (%rax)
mov    0x8(%rsp),%r14
xor    %ecx,%ecx
lea    -0x1(%rcx),%eax
imul   0x28(%rsp),%r12d
cmp    %r12d,%eax
mov    0x30(%rsp),%rbx
lea    0x5(%rsp),%rbp
jae    1580 <main+0x360>
sub    %ecx,%r12d
add    $0x1,%r12d
nopw   0x0(%rax,%rax,1)
movw   $0xff00,0x5(%rsp)
movb   $0x0,0x7(%rsp)
mov    %rbp,%rdi
mov    $0x1,%esi
mov    $0x3,%edx
mov    %r15,%rcx
call   1140 <fwrite@plt>
add    $0xffffffff,%r12d
jne    1760 <main+0x540>
jmp    1580 <main+0x360>
lea    0x953(%rip),%rdi
jmp    17af <main+0x58f>
lea    0xa0e(%rip),%rdi
call   1050 <puts@plt>
mov    0x8(%rsp),%r14
jmp    17bc <main+0x59c>
lea    0x9b5(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1080 <printf@plt>
mov    %rbp,%r14
mov    0x40(%rsp),%rdi
call   1070 <fclose@plt>
mov    %r14,%rdi
call   1030 <free@plt>
xor    %edi,%edi
call   1130 <exit@plt>
mov    %rax,%r14
mov    $0x80,%edi
call   10d0 <malloc@plt>
test   %rax,%rax
je     13e2 <main+0x1c2>
mov    %rax,%rbp
movl   $0x801050a,(%rax)
movl   $0xc7013f,0x8(%rax)
movw   $0x4001,0x41(%rax)
movb   $0x1,0x43(%rax)
mov    %rax,%rdi
mov    $0x80,%esi
mov    $0x1,%edx
mov    %r14,%rcx
call   1140 <fwrite@plt>
mov    0x8(%rsp),%rbx
mov    %rbx,%rdi
add    $0x13,%rdi
mov    %r15d,%esi
mov    $0x1,%edx
mov    %r14,%rcx
call   1140 <fwrite@plt>
mov    %rbp,%rdi
call   1030 <free@plt>
mov    %r14,%rdi
mov    %rbx,%r14
call   1070 <fclose@plt>
jmp    17bc <main+0x59c>

LLVM IR (-O0):
@.str = [23 x i8] c"ERACHA data converter\0A\00"
@.str.1 = [33 x i8] c"-------------------------------\0A\00"
@.str.2 = [37 x i8] c"usage: edc file1.ext1 [file2.ext2]\0A\0A\00"
@.str.3 = [18 x i8] c"modes supported:\0A\00"
@.str.4 = [15 x i8] c" - BCK => PCX\0A\00"
@.str.5 = [15 x i8] c" - SAN => PPM\0A\00"
@.str.6 = [7 x i8] c"malloc\00"
@.str.7 = [21 x i8] c"Too many arguments!\0A\00"
@.str.8 = [33 x i8] c"filename '%s' has no extension!\0A\00"
@.str.9 = [5 x i8] c".bck\00"
@.str.10 = [5 x i8] c".BCK\00"
@.str.11 = [23 x i8] c"Converting bck to pcx\0A\00"
@.str.12 = [5 x i8] c".san\00"
@.str.13 = [5 x i8] c".SAN\00"
@.str.14 = [23 x i8] c"Converting san to ppm\0A\00"
@.str.15 = [52 x i8] c"extension is '%s', do not know what to do...(yet!)\0A\00"
@.str.16 = [3 x i8] c"rb\00"
@.str.17 = [6 x i8] c"fopen\00"
@SEEK_END = global i32 0
@.str.18 = [6 x i8] c"fread\00"
@.str.19 = [5 x i8] c".pcx\00"
@.str.20 = [58 x i8] c"'%s' has size of %li bytes, setting resolution to %dx%d.\0A\00"
@.str.21 = [25 x i8] c"Writing %li bytes to %s\0A\00"
@.str.22 = [3 x i8] c"wb\00"
@.str.23 = [12 x i8] c"create file\00"
@.str.24 = [28 x i8] c"'%s' is no valid BCK file!\0A\00"
@.str.25 = [5 x i8] c".ppm\00"
@.str.26 = [39 x i8] c"'%s' has %d images, file size is %li.\0A\00"
@.str.27 = [10 x i8] c".%02d_ppm\00"
@.str.28 = [30 x i8] c"image %d, %dx%d, size is %d.\0A\00"
@.str.29 = [14 x i8] c"P6\0A%d %d\0A255\0A\00"
@.str.30 = [28 x i8] c"'%s' is no valid SAN file!\0A\00"
@.str.31 = [16 x i8] c"-UNKNOWN MODE-\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i32
%9 = alloca i64
%10 = alloca i8*
%11 = alloca i64
%12 = alloca i8*
%13 = alloca i32*
%14 = alloca i32*
%15 = alloca i8*
%16 = alloca i32
%17 = alloca i32
%18 = alloca i32
%19 = alloca i32
%20 = alloca i32
%21 = alloca i32
%22 = alloca i32
%23 = alloca i32
%24 = alloca i32
%25 = alloca i32
%26 = alloca i32
%27 = alloca [5 x i8]
%28 = alloca i32*
%29 = alloca [3 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%30 = load i32, i32* %4
%31 = icmp eq i32 %30, 1
br i1 %31, label %32, label %40
32: ; preds = %2
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.1, i64 0, i64 0))
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.2, i64 0, i64 0))
%36 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0))
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0))
%38 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.5, i64 0, i64 0))
%39 = call i32 @exit(i32 0)
unreachable
40: ; preds = %2
%41 = load i32, i32* %4
%42 = icmp eq i32 %41, 3
br i1 %42, label %43, label %50
43: ; preds = %40
%44 = load i8**, i8*** %5
%45 = getelementptr inbounds i8*, i8** %44, i64 1
%46 = load i8*, i8** %45
store i8* %46, i8** %6
%47 = load i8**, i8*** %5
%48 = getelementptr inbounds i8*, i8** %47, i64 2
%49 = load i8*, i8** %48
store i8* %49, i8** %7
br label %68
50: ; preds = %40
%51 = load i32, i32* %4
%52 = icmp eq i32 %51, 2
br i1 %52, label %53, label %64
53: ; preds = %50
%54 = load i8**, i8*** %5
%55 = getelementptr inbounds i8*, i8** %54, i64 1
%56 = load i8*, i8** %55
store i8* %56, i8** %6
%57 = call i8* @malloc(i32 9)
store i8* %57, i8** %7
%58 = load i8*, i8** %7
%59 = icmp eq i8* %58, null
br i1 %59, label %60, label %63
60: ; preds = %53
%61 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0))
%62 = call i32 @exit(i32 1)
unreachable
63: ; preds = %53
br label %67
64: ; preds = %50
%65 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.7, i64 0, i64 0))
%66 = call i32 @exit(i32 1)
unreachable
67: ; preds = %63
br label %68
68: ; preds = %67, %43
br label %69
69: ; preds = %68
%70 = load i8*, i8** %6
%71 = call i8* @strrchr(i8* %70, i8 signext 46)
store i8* %71, i8** %12
%72 = load i8*, i8** %12
%73 = icmp ne i8* %72, null
br i1 %73, label %78, label %74
74: ; preds = %69
%75 = load i8*, i8** %6
%76 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.8, i64 0, i64 0), i8* %75)
%77 = call i32 @exit(i32 1)
unreachable
78: ; preds = %69
%79 = load i8*, i8** %12
%80 = call i64 @strncmp(i8* %79, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.9, i64 0, i64 0), i32 4)
%81 = icmp eq i64 %80, 0
br i1 %81, label %86, label %82
82: ; preds = %78
%83 = load i8*, i8** %12
%84 = call i64 @strncmp(i8* %83, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.10, i64 0, i64 0), i32 4)
%85 = icmp eq i64 %84, 0
br i1 %85, label %86, label %88
86: ; preds = %82, %78
store i32 1, i32* %8
%87 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.11, i64 0, i64 0))
br label %104
88: ; preds = %82
%89 = load i8*, i8** %12
%90 = call i64 @strncmp(i8* %89, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.12, i64 0, i64 0), i32 4)
%91 = icmp eq i64 %90, 0
br i1 %91, label %96, label %92
92: ; preds = %88
%93 = load i8*, i8** %12
%94 = call i64 @strncmp(i8* %93, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.13, i64 0, i64 0), i32 4)
%95 = icmp eq i64 %94, 0
br i1 %95, label %96, label %98
96: ; preds = %92, %88
store i32 3, i32* %8
%97 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.14, i64 0, i64 0))
br label %103
98: ; preds = %92
%99 = load i8*, i8** %12
%100 = getelementptr inbounds i8, i8* %99, i64 1
%101 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.15, i64 0, i64 0), i8* %100)
%102 = call i32 @exit(i32 1)
unreachable
103: ; preds = %96
br label %104
104: ; preds = %103, %86
br label %105
105: ; preds = %104
%106 = load i8*, i8** %6
%107 = call i32* @fopen(i8* %106, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.16, i64 0, i64 0))
store i32* %107, i32** %13
%108 = load i32*, i32** %13
%109 = icmp eq i32* %108, null
br i1 %109, label %110, label %113
110: ; preds = %105
%111 = call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.17, i64 0, i64 0))
%112 = call i32 @exit(i32 1)
unreachable
113: ; preds = %105
%114 = load i32*, i32** %13
%115 = load i32, i32* @SEEK_END
%116 = call i32 @fseek(i32* %114, i32 0, i32 %115)
%117 = load i32*, i32** %13
%118 = call i64 @ftell(i32* %117)
store i64 %118, i64* %9
%119 = load i32*, i32** %13
%120 = call i32 @rewind(i32* %119)
%121 = load i64, i64* %9
%122 = mul i64 1, %121
%123 = trunc i64 %122 to i32
%124 = call i8* @malloc(i32 %123)
store i8* %124, i8** %10
%125 = load i8*, i8** %10
%126 = icmp eq i8* %125, null
br i1 %126, label %127, label %130
127: ; preds = %113
%128 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0))
%129 = call i32 @exit(i32 1)
unreachable
130: ; preds = %113
%131 = load i8*, i8** %10
%132 = load i64, i64* %9
%133 = load i32*, i32** %13
%134 = call i64 @fread(i8* %131, i32 1, i64 %132, i32* %133)
store i64 %134, i64* %11
%135 = load i64, i64* %11
%136 = load i64, i64* %9
%137 = icmp ne i64 %135, %136
br i1 %137, label %138, label %141
138: ; preds = %130
%139 = call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.18, i64 0, i64 0))
%140 = call i32 @exit(i32 1)
unreachable
141: ; preds = %130
%142 = load i32, i32* %8
%143 = icmp eq i32 %142, 1
br i1 %143, label %144, label %236
144: ; preds = %141
%145 = load i8*, i8** %10
%146 = getelementptr inbounds i8, i8* %145, i64 11
%147 = load i8, i8* %146
%148 = zext i8 %147 to i32
%149 = icmp eq i32 %148, 80
br i1 %149, label %150, label %232
150: ; preds = %144
%151 = load i8*, i8** %10
%152 = getelementptr inbounds i8, i8* %151, i64 12
%153 = load i8, i8* %152
%154 = zext i8 %153 to i32
%155 = icmp eq i32 %154, 67
br i1 %155, label %156, label %232
156: ; preds = %150
%157 = load i8*, i8** %10
%158 = getelementptr inbounds i8, i8* %157, i64 13
%159 = load i8, i8* %158
%160 = zext i8 %159 to i32
%161 = icmp eq i32 %160, 88
br i1 %161, label %162, label %232
162: ; preds = %156
%163 = load i8*, i8** %7
%164 = getelementptr inbounds i8, i8* %163, i64 0
%165 = load i8, i8* %164
%166 = sext i8 %165 to i32
%167 = icmp eq i32 %166, 0
br i1 %167, label %168, label %171
168: ; preds = %162
%169 = load i8*, i8** %6
%170 = call i8* @changefileext(i8* %169, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.19, i64 0, i64 0))
store i8* %170, i8** %7
br label %171
171: ; preds = %168, %162
%172 = load i8*, i8** %6
%173 = load i64, i64* %9
%174 = sub i64 %173, 19
%175 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str.20, i64 0, i64 0), i8* %172, i64 %174, i32 320, i32 200)
%176 = load i64, i64* %9
%177 = sub i64 %176, 19
%178 = add i64 %177, 128
%179 = load i8*, i8** %7
%180 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.21, i64 0, i64 0), i64 %178, i8* %179)
%181 = load i8*, i8** %7
%182 = call i32* @fopen(i8* %181, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.22, i64 0, i64 0))
store i32* %182, i32** %14
%183 = load i32*, i32** %14
%184 = icmp ne i32* %183, null
br i1 %184, label %188, label %185
185: ; preds = %171
%186 = call i32 @perror(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.23, i64 0, i64 0))
%187 = call i32 @exit(i32 1)
unreachable
188: ; preds = %171
%189 = call i8* @malloc(i32 128)
store i8* %189, i8** %15
%190 = load i8*, i8** %15
%191 = icmp eq i8* %190, null
br i1 %191, label %192, label %195
192: ; preds = %188
%193 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0))
%194 = call i32 @exit(i32 1)
unreachable
195: ; preds = %188
%196 = load i8*, i8** %15
%197 = getelementptr inbounds i8, i8* %196, i64 0
store i8 10, i8* %197
%198 = load i8*, i8** %15
%199 = getelementptr inbounds i8, i8* %198, i64 1
store i8 5, i8* %199
%200 = load i8*, i8** %15
%201 = getelementptr inbounds i8, i8* %200, i64 2
store i8 1, i8* %201
%202 = load i8*, i8** %15
%203 = getelementptr inbounds i8, i8* %202, i64 3
store i8 8, i8* %203
%204 = load i8*, i8** %15
%205 = getelementptr inbounds i8, i8* %204, i64 8
store i8 63, i8* %205
%206 = load i8*, i8** %15
%207 = getelementptr inbounds i8, i8* %206, i64 9
store i8 1, i8* %207
%208 = load i8*, i8** %15
%209 = getelementptr inbounds i8, i8* %208, i64 10
store i8 -57, i8* %209
%210 = load i8*, i8** %15
%211 = getelementptr inbounds i8, i8* %210, i64 11
store i8 0, i8* %211
%212 = load i8*, i8** %15
%213 = getelementptr inbounds i8, i8* %212, i64 65
store i8 1, i8* %213
%214 = load i8*, i8** %15
%215 = getelementptr inbounds i8, i8* %214, i64 66
store i8 64, i8* %215
%216 = load i8*, i8** %15
%217 = getelementptr inbounds i8, i8* %216, i64 67
store i8 1, i8* %217
%218 = load i8*, i8** %15
%219 = load i32*, i32** %14
%220 = call i32 @fwrite(i8* %218, i32 128, i32 1, i32* %219)
%221 = load i8*, i8** %10
%222 = getelementptr inbounds i8, i8* %221, i64 19
%223 = load i64, i64* %9
%224 = sub i64 %223, 19
%225 = trunc i64 %224 to i32
%226 = load i32*, i32** %14
%227 = call i32 @fwrite(i8* %222, i32 %225, i32 1, i32* %226)
%228 = load i8*, i8** %15
%229 = call i32 @free(i8* %228)
%230 = load i32*, i32** %14
%231 = call i32 @fclose(i32* %230)
br label %235
232: ; preds = %156, %150, %144
%233 = load i8*, i8** %6
%234 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.24, i64 0, i64 0), i8* %233)
br label %235
235: ; preds = %232, %195
br label %461
236: ; preds = %141
%237 = load i32, i32* %8
%238 = icmp eq i32 %237, 3
br i1 %238, label %239, label %458
239: ; preds = %236
%240 = load i8*, i8** %10
%241 = getelementptr inbounds i8, i8* %240, i64 0
%242 = load i8, i8* %241
%243 = zext i8 %242 to i32
%244 = icmp eq i32 %243, 91
br i1 %244, label %245, label %454
245: ; preds = %239
%246 = load i8*, i8** %10
%247 = getelementptr inbounds i8, i8* %246, i64 1
%248 = load i8, i8* %247
%249 = zext i8 %248 to i32
%250 = icmp eq i32 %249, 83
br i1 %250, label %251, label %454
251: ; preds = %245
%252 = load i8*, i8** %10
%253 = getelementptr inbounds i8, i8* %252, i64 5
%254 = load i8, i8* %253
%255 = zext i8 %254 to i32
%256 = icmp eq i32 %255, 83
br i1 %256, label %257, label %454
257: ; preds = %251
%258 = load i8*, i8** %10
%259 = getelementptr inbounds i8, i8* %258, i64 9
%260 = load i8, i8* %259
%261 = zext i8 %260 to i32
%262 = icmp eq i32 %261, 93
br i1 %262, label %263, label %454
263: ; preds = %257
%264 = load i8*, i8** %7
%265 = getelementptr inbounds i8, i8* %264, i64 0
%266 = load i8, i8* %265
%267 = sext i8 %266 to i32
%268 = icmp eq i32 %267, 0
br i1 %268, label %269, label %272
269: ; preds = %263
%270 = load i8*, i8** %6
%271 = call i8* @changefileext(i8* %270, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.25, i64 0, i64 0))
store i8* %271, i8** %7
br label %272
272: ; preds = %269, %263
%273 = load i8*, i8** %10
%274 = getelementptr inbounds i8, i8* %273, i64 10
%275 = load i8, i8* %274
%276 = zext i8 %275 to i32
store i32 %276, i32* %16
%277 = load i8*, i8** %6
%278 = load i32, i32* %16
%279 = load i64, i64* %9
%280 = sub i64 %279, 12
%281 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.26, i64 0, i64 0), i8* %277, i32 %278, i64 %280)
store i32 12, i32* %18
store i32 0, i32* %17
br label %282
282: ; preds = %450, %272
%283 = load i32, i32* %17
%284 = load i32, i32* %16
%285 = icmp ult i32 %283, %284
br i1 %285, label %286, label %453
286: ; preds = %282
%287 = getelementptr inbounds [5 x i8], [5 x i8]* %27, i64 0, i64 0
%288 = load i32, i32* %17
%289 = call i32 @sprintf(i8* %287, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.27, i64 0, i64 0), i32 %288)
%290 = load i8*, i8** %6
%291 = getelementptr inbounds [5 x i8], [5 x i8]* %27, i64 0, i64 0
%292 = call i8* @changefileext(i8* %290, i8* %291)
store i8* %292, i8** %7
%293 = load i8*, i8** %7
%294 = call i32* @fopen(i8* %293, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.22, i64 0, i64 0))
store i32* %294, i32** %28
%295 = load i32*, i32** %28
%296 = icmp ne i32* %295, null
br i1 %296, label %300, label %297
297: ; preds = %286
%298 = call i32 @perror(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.23, i64 0, i64 0))
%299 = call i32 @exit(i32 1)
unreachable
300: ; preds = %286
%301 = load i8*, i8** %10
%302 = load i32, i32* %18
%303 = zext i32 %302 to i64
%304 = getelementptr inbounds i8, i8* %301, i64 %303
%305 = load i8, i8* %304
%306 = zext i8 %305 to i32
store i32 %306, i32* %19
%307 = load i8*, i8** %10
%308 = load i32, i32* %18
%309 = add i32 %308, 2
%310 = zext i32 %309 to i64
%311 = getelementptr inbounds i8, i8* %307, i64 %310
%312 = load i8, i8* %311
%313 = zext i8 %312 to i32
store i32 %313, i32* %20
%314 = load i8*, i8** %10
%315 = load i32, i32* %18
%316 = add i32 %315, 4
%317 = zext i32 %316 to i64
%318 = getelementptr inbounds i8, i8* %314, i64 %317
%319 = load i8, i8* %318
%320 = zext i8 %319 to i32
%321 = load i8*, i8** %10
%322 = load i32, i32* %18
%323 = add i32 %322, 5
%324 = zext i32 %323 to i64
%325 = getelementptr inbounds i8, i8* %321, i64 %324
%326 = load i8, i8* %325
%327 = zext i8 %326 to i32
%328 = shl i32 %327, 8
%329 = or i32 %320, %328
store i32 %329, i32* %21
%330 = load i32, i32* %17
%331 = add i32 %330, 1
%332 = load i32, i32* %19
%333 = load i32, i32* %20
%334 = load i32, i32* %21
%335 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.28, i64 0, i64 0), i32 %331, i32 %332, i32 %333, i32 %334)
%336 = load i32*, i32** %28
%337 = load i32, i32* %19
%338 = load i32, i32* %20
%339 = call i32 @fprintf(i32* %336, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.29, i64 0, i64 0), i32 %337, i32 %338)
store i32 0, i32* %26
store i32 0, i32* %22
br label %340
340: ; preds = %421, %300
%341 = load i32, i32* %22
%342 = load i32, i32* %21
%343 = icmp ult i32 %341, %342
br i1 %343, label %344, label %424
344: ; preds = %340
%345 = load i32, i32* %24
%346 = icmp ne i32 %345, 0
br i1 %346, label %347, label %348
347: ; preds = %344
store i32 0, i32* %24
br label %421
348: ; preds = %344
%349 = load i8*, i8** %10
%350 = load i32, i32* %18
%351 = add i32 %350, 6
%352 = load i32, i32* %22
%353 = add i32 %351, %352
%354 = zext i32 %353 to i64
%355 = getelementptr inbounds i8, i8* %349, i64 %354
%356 = load i8, i8* %355
%357 = zext i8 %356 to i32
%358 = icmp eq i32 %357, 0
br i1 %358, label %359, label %387
359: ; preds = %348
store i32 1, i32* %24
%360 = load i8*, i8** %10
%361 = load i32, i32* %18
%362 = add i32 %361, 6
%363 = load i32, i32* %22
%364 = add i32 %362, %363
%365 = add i32 %364, 1
%366 = zext i32 %365 to i64
%367 = getelementptr inbounds i8, i8* %360, i64 %366
%368 = load i8, i8* %367
%369 = zext i8 %368 to i32
store i32 %369, i32* %25
store i32 0, i32* %23
br label %370
370: ; preds = %383, %359
%371 = load i32, i32* %23
%372 = load i32, i32* %25
%373 = icmp ult i32 %371, %372
br i1 %373, label %374, label %386
374: ; preds = %370
%375 = getelementptr inbounds [3 x i8], [3 x i8]* %29, i64 0, i64 0
store i8 0, i8* %375
%376 = getelementptr inbounds [3 x i8], [3 x i8]* %29, i64 0, i64 1
store i8 -1, i8* %376
%377 = getelementptr inbounds [3 x i8], [3 x i8]* %29, i64 0, i64 2
store i8 0, i8* %377
%378 = getelementptr inbounds [3 x i8], [3 x i8]* %29, i64 0, i64 0
%379 = load i32*, i32** %28
%380 = call i32 @fwrite(i8* %378, i32 1, i32 3, i32* %379)
%381 = load i32, i32* %26
%382 = add i32 %381, 1
store i32 %382, i32* %26
br label %383
383: ; preds = %374
%384 = load i32, i32* %23
%385 = add i32 %384, 1
store i32 %385, i32* %23
br label %370
386: ; preds = %370
br label %420
387: ; preds = %348
%388 = load i8*, i8** %10
%389 = load i32, i32* %18
%390 = add i32 %389, 6
%391 = load i32, i32* %22
%392 = add i32 %390, %391
%393 = zext i32 %392 to i64
%394 = getelementptr inbounds i8, i8* %388, i64 %393
%395 = load i8, i8* %394
%396 = getelementptr inbounds [3 x i8], [3 x i8]* %29, i64 0, i64 0
store i8 %395, i8* %396
%397 = load i8*, i8** %10
%398 = load i32, i32* %18
%399 = add i32 %398, 6
%400 = load i32, i32* %22
%401 = add i32 %399, %400
%402 = zext i32 %401 to i64
%403 = getelementptr inbounds i8, i8* %397, i64 %402
%404 = load i8, i8* %403
%405 = getelementptr inbounds [3 x i8], [3 x i8]* %29, i64 0, i64 1
store i8 %404, i8* %405
%406 = load i8*, i8** %10
%407 = load i32, i32* %18
%408 = add i32 %407, 6
%409 = load i32, i32* %22
%410 = add i32 %408, %409
%411 = zext i32 %410 to i64
%412 = getelementptr inbounds i8, i8* %406, i64 %411
%413 = load i8, i8* %412
%414 = getelementptr inbounds [3 x i8], [3 x i8]* %29, i64 0, i64 2
store i8 %413, i8* %414
%415 = getelementptr inbounds [3 x i8], [3 x i8]* %29, i64 0, i64 0
%416 = load i32*, i32** %28
%417 = call i32 @fwrite(i8* %415, i32 1, i32 3, i32* %416)
%418 = load i32, i32* %26
%419 = add i32 %418, 1
store i32 %419, i32* %26
br label %420
420: ; preds = %387, %386
br label %421
421: ; preds = %420, %347
%422 = load i32, i32* %22
%423 = add i32 %422, 1
store i32 %423, i32* %22
br label %340
424: ; preds = %340
%425 = load i32, i32* %26
%426 = sub i32 %425, 1
store i32 %426, i32* %23
br label %427
427: ; preds = %440, %424
%428 = load i32, i32* %23
%429 = load i32, i32* %19
%430 = load i32, i32* %20
%431 = mul i32 %429, %430
%432 = icmp ult i32 %428, %431
br i1 %432, label %433, label %443
433: ; preds = %427
%434 = getelementptr inbounds [3 x i8], [3 x i8]* %29, i64 0, i64 0
store i8 0, i8* %434
%435 = getelementptr inbounds [3 x i8], [3 x i8]* %29, i64 0, i64 1
store i8 -1, i8* %435
%436 = getelementptr inbounds [3 x i8], [3 x i8]* %29, i64 0, i64 2
store i8 0, i8* %436
%437 = getelementptr inbounds [3 x i8], [3 x i8]* %29, i64 0, i64 0
%438 = load i32*, i32** %28
%439 = call i32 @fwrite(i8* %437, i32 1, i32 3, i32* %438)
br label %440
440: ; preds = %433
%441 = load i32, i32* %23
%442 = add i32 %441, 1
store i32 %442, i32* %23
br label %427
443: ; preds = %427
%444 = load i32, i32* %21
%445 = add i32 %444, 8
%446 = load i32, i32* %18
%447 = add i32 %446, %445
store i32 %447, i32* %18
%448 = load i32*, i32** %28
%449 = call i32 @fclose(i32* %448)
br label %450
450: ; preds = %443
%451 = load i32, i32* %17
%452 = add i32 %451, 1
store i32 %452, i32* %17
br label %282
453: ; preds = %282
br label %457
454: ; preds = %257, %251, %245, %239
%455 = load i8*, i8** %6
%456 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.30, i64 0, i64 0), i8* %455)
br label %457
457: ; preds = %454, %453
br label %460
458: ; preds = %236
%459 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.31, i64 0, i64 0))
br label %460
460: ; preds = %458, %457
br label %461
461: ; preds = %460, %235
%462 = load i32*, i32** %13
%463 = call i32 @fclose(i32* %462)
%464 = load i8*, i8** %10
%465 = call i32 @free(i8* %464)
%466 = call i32 @exit(i32 0)
unreachable
}

LLVM IR (-O2):
@.str.6 = [7 x i8] c"malloc\00"
@.str.8 = [33 x i8] c"filename '%s' has no extension!\0A\00"
@.str.9 = [5 x i8] c".bck\00"
@.str.10 = [5 x i8] c".BCK\00"
@.str.12 = [5 x i8] c".san\00"
@.str.13 = [5 x i8] c".SAN\00"
@.str.15 = [52 x i8] c"extension is '%s', do not know what to do...(yet!)\0A\00"
@.str.16 = [3 x i8] c"rb\00"
@.str.17 = [6 x i8] c"fopen\00"
@SEEK_END = global i32 0
@.str.18 = [6 x i8] c"fread\00"
@.str.19 = [5 x i8] c".pcx\00"
@.str.20 = [58 x i8] c"'%s' has size of %li bytes, setting resolution to %dx%d.\0A\00"
@.str.21 = [25 x i8] c"Writing %li bytes to %s\0A\00"
@.str.22 = [3 x i8] c"wb\00"
@.str.23 = [12 x i8] c"create file\00"
@.str.24 = [28 x i8] c"'%s' is no valid BCK file!\0A\00"
@.str.25 = [5 x i8] c".ppm\00"
@.str.26 = [39 x i8] c"'%s' has %d images, file size is %li.\0A\00"
@.str.27 = [10 x i8] c".%02d_ppm\00"
@.str.28 = [30 x i8] c"image %d, %dx%d, size is %d.\0A\00"
@.str.29 = [14 x i8] c"P6\0A%d %d\0A255\0A\00"
@.str.30 = [28 x i8] c"'%s' is no valid SAN file!\0A\00"
@str = [20 x i8] c"Too many arguments!\00"
@str.32 = [22 x i8] c"Converting san to ppm\00"
@str.33 = [15 x i8] c"-UNKNOWN MODE-\00"
@str.34 = [22 x i8] c"Converting bck to pcx\00"
@str.35 = [22 x i8] c"ERACHA data converter\00"
@str.36 = [32 x i8] c"-------------------------------\00"
@str.37 = [36 x i8] c"usage: edc file1.ext1 [file2.ext2]\0A\00"
@str.38 = [17 x i8] c"modes supported:\00"
@str.39 = [14 x i8] c" - BCK => PCX\00"
@str.40 = [14 x i8] c" - SAN => PPM\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [5 x i8]
%4 = alloca [3 x i8]
switch i32 %0, label %22 [
i32 1, label %5
i32 3, label %13
i32 2, label %16
]
5: ; preds = %2
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str.35, i64 0, i64 0))
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @str.36, i64 0, i64 0))
%8 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @str.37, i64 0, i64 0))
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @str.38, i64 0, i64 0))
%10 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @str.39, i64 0, i64 0))
%11 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @str.40, i64 0, i64 0))
%12 = tail call i32 @exit(i32 0)
unreachable
13: ; preds = %2
%14 = getelementptr inbounds i8*, i8** %1, i64 2
%15 = load i8*, i8** %14
br label %25
16: ; preds = %2
%17 = tail call dereferenceable_or_null(9) i8* @malloc(i32 9)
%18 = icmp eq i8* %17, null
br i1 %18, label %19, label %25
19: ; preds = %16
%20 = tail call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0))
%21 = tail call i32 @exit(i32 1)
unreachable
22: ; preds = %2
%23 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str, i64 0, i64 0))
%24 = tail call i32 @exit(i32 1)
unreachable
25: ; preds = %13, %16
%26 = phi i8* [ %15, %13 ], [ %17, %16 ]
%27 = getelementptr inbounds i8*, i8** %1, i64 1
%28 = load i8*, i8** %27
%29 = tail call i8* @strrchr(i8* dereferenceable(1) %28, i8 signext 46)
%30 = icmp eq i8* %29, null
br i1 %30, label %31, label %34
31: ; preds = %25
%32 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str.8, i64 0, i64 0), i8* %28)
%33 = tail call i32 @exit(i32 1)
unreachable
34: ; preds = %25
%35 = tail call i64 @strncmp(i8* %29, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.9, i64 0, i64 0), i32 4)
%36 = icmp eq i64 %35, 0
br i1 %36, label %50, label %37
37: ; preds = %34
%38 = tail call i64 @strncmp(i8* %29, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.10, i64 0, i64 0), i32 4)
%39 = icmp eq i64 %38, 0
br i1 %39, label %50, label %40
40: ; preds = %37
%41 = tail call i64 @strncmp(i8* %29, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.12, i64 0, i64 0), i32 4)
%42 = icmp eq i64 %41, 0
br i1 %42, label %50, label %43
43: ; preds = %40
%44 = tail call i64 @strncmp(i8* %29, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.13, i64 0, i64 0), i32 4)
%45 = icmp eq i64 %44, 0
br i1 %45, label %50, label %46
46: ; preds = %43
%47 = getelementptr inbounds i8, i8* %29, i64 1
%48 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([52 x i8], [52 x i8]* @.str.15, i64 0, i64 0), i8* %47)
%49 = tail call i32 @exit(i32 1)
unreachable
50: ; preds = %40, %43, %34, %37
%51 = phi i8* [ getelementptr inbounds ([22 x i8], [22 x i8]* @str.34, i64 0, i64 0), %37 ], [ getelementptr inbounds ([22 x i8], [22 x i8]* @str.34, i64 0, i64 0), %34 ], [ getelementptr inbounds ([22 x i8], [22 x i8]* @str.32, i64 0, i64 0), %43 ], [ getelementptr inbounds ([22 x i8], [22 x i8]* @str.32, i64 0, i64 0), %40 ]
%52 = phi i1 [ true, %37 ], [ true, %34 ], [ false, %43 ], [ false, %40 ]
%53 = phi i1 [ false, %37 ], [ false, %34 ], [ true, %43 ], [ true, %40 ]
%54 = tail call i32 @puts(i8* dereferenceable(1) %51)
%55 = tail call i32* @fopen(i8* %28, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.16, i64 0, i64 0))
%56 = icmp eq i32* %55, null
br i1 %56, label %57, label %60
57: ; preds = %50
%58 = tail call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.17, i64 0, i64 0))
%59 = tail call i32 @exit(i32 1)
unreachable
60: ; preds = %50
%61 = load i32, i32* @SEEK_END
%62 = tail call i32 @fseek(i32* %55, i32 0, i32 %61)
%63 = tail call i64 @ftell(i32* %55)
%64 = tail call i32 @rewind(i32* %55)
%65 = trunc i64 %63 to i32
%66 = tail call i8* @malloc(i32 %65)
%67 = icmp eq i8* %66, null
br i1 %67, label %68, label %71
68: ; preds = %60
%69 = tail call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0))
%70 = tail call i32 @exit(i32 1)
unreachable
71: ; preds = %60
%72 = tail call i64 @fread(i8* %66, i32 1, i64 %63, i32* %55)
%73 = icmp eq i64 %72, %63
br i1 %73, label %77, label %74
74: ; preds = %71
%75 = tail call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.18, i64 0, i64 0))
%76 = tail call i32 @exit(i32 1)
unreachable
77: ; preds = %71
br i1 %52, label %78, label %131
78: ; preds = %77
%79 = getelementptr inbounds i8, i8* %66, i64 11
%80 = load i8, i8* %79
%81 = icmp eq i8 %80, 80
br i1 %81, label %82, label %129
82: ; preds = %78
%83 = getelementptr inbounds i8, i8* %66, i64 12
%84 = load i8, i8* %83
%85 = icmp eq i8 %84, 67
br i1 %85, label %86, label %129
86: ; preds = %82
%87 = getelementptr inbounds i8, i8* %66, i64 13
%88 = load i8, i8* %87
%89 = icmp eq i8 %88, 88
br i1 %89, label %90, label %129
90: ; preds = %86
%91 = load i8, i8* %26
%92 = icmp eq i8 %91, 0
br i1 %92, label %93, label %95
93: ; preds = %90
%94 = tail call i8* @changefileext(i8* %28, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.19, i64 0, i64 0))
br label %95
95: ; preds = %93, %90
%96 = phi i8* [ %94, %93 ], [ %26, %90 ]
%97 = add i64 %63, -19
%98 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([58 x i8], [58 x i8]* @.str.20, i64 0, i64 0), i8* %28, i64 %97, i32 320, i32 200)
%99 = add i64 %63, 109
%100 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.21, i64 0, i64 0), i64 %99, i8* %96)
%101 = tail call i32* @fopen(i8* %96, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.22, i64 0, i64 0))
%102 = icmp eq i32* %101, null
br i1 %102, label %103, label %106
103: ; preds = %95
%104 = tail call i32 @perror(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.23, i64 0, i64 0))
%105 = tail call i32 @exit(i32 1)
unreachable
106: ; preds = %95
%107 = tail call dereferenceable_or_null(128) i8* @malloc(i32 128)
%108 = icmp eq i8* %107, null
br i1 %108, label %109, label %112
109: ; preds = %106
%110 = tail call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0))
%111 = tail call i32 @exit(i32 1)
unreachable
112: ; preds = %106
store i8 10, i8* %107
%113 = getelementptr inbounds i8, i8* %107, i64 1
store i8 5, i8* %113
%114 = getelementptr inbounds i8, i8* %107, i64 2
store i8 1, i8* %114
%115 = getelementptr inbounds i8, i8* %107, i64 3
store i8 8, i8* %115
%116 = getelementptr inbounds i8, i8* %107, i64 8
store i8 63, i8* %116
%117 = getelementptr inbounds i8, i8* %107, i64 9
store i8 1, i8* %117
%118 = getelementptr inbounds i8, i8* %107, i64 10
store i8 -57, i8* %118
%119 = getelementptr inbounds i8, i8* %107, i64 11
store i8 0, i8* %119
%120 = getelementptr inbounds i8, i8* %107, i64 65
store i8 1, i8* %120
%121 = getelementptr inbounds i8, i8* %107, i64 66
store i8 64, i8* %121
%122 = getelementptr inbounds i8, i8* %107, i64 67
store i8 1, i8* %122
%123 = tail call i32 @fwrite(i8* %107, i32 128, i32 1, i32* %101)
%124 = getelementptr inbounds i8, i8* %66, i64 19
%125 = trunc i64 %97 to i32
%126 = tail call i32 @fwrite(i8* %124, i32 %125, i32 1, i32* %101)
%127 = tail call i32 @free(i8* %107)
%128 = tail call i32 @fclose(i32* %101)
br label %258
129: ; preds = %86, %82, %78
%130 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str.24, i64 0, i64 0), i8* %28)
br label %258
131: ; preds = %77
br i1 %53, label %132, label %256
132: ; preds = %131
%133 = load i8, i8* %66
%134 = icmp eq i8 %133, 91
br i1 %134, label %135, label %254
135: ; preds = %132
%136 = getelementptr inbounds i8, i8* %66, i64 1
%137 = load i8, i8* %136
%138 = icmp eq i8 %137, 83
br i1 %138, label %139, label %254
139: ; preds = %135
%140 = getelementptr inbounds i8, i8* %66, i64 5
%141 = load i8, i8* %140
%142 = icmp eq i8 %141, 83
br i1 %142, label %143, label %254
143: ; preds = %139
%144 = getelementptr inbounds i8, i8* %66, i64 9
%145 = load i8, i8* %144
%146 = icmp eq i8 %145, 93
br i1 %146, label %147, label %254
147: ; preds = %143
%148 = load i8, i8* %26
%149 = icmp eq i8 %148, 0
br i1 %149, label %150, label %152
150: ; preds = %147
%151 = tail call i8* @changefileext(i8* %28, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.25, i64 0, i64 0))
br label %152
152: ; preds = %150, %147
%153 = getelementptr inbounds i8, i8* %66, i64 10
%154 = load i8, i8* %153
%155 = zext i8 %154 to i32
%156 = add i64 %63, -12
%157 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @.str.26, i64 0, i64 0), i8* %28, i32 %155, i64 %156)
%158 = icmp eq i8 %154, 0
br i1 %158, label %258, label %159
159: ; preds = %152
%160 = getelementptr inbounds [5 x i8], [5 x i8]* %3, i64 0, i64 0
%161 = getelementptr inbounds [3 x i8], [3 x i8]* %4, i64 0, i64 0
%162 = getelementptr inbounds [3 x i8], [3 x i8]* %4, i64 0, i64 1
%163 = getelementptr inbounds [3 x i8], [3 x i8]* %4, i64 0, i64 2
br label %164
164: ; preds = %159, %249
%165 = phi i32 [ undef, %159 ], [ %239, %249 ]
%166 = phi i32 [ 0, %159 ], [ %197, %249 ]
%167 = phi i32 [ 12, %159 ], [ %251, %249 ]
%168 = call i32 @sprintf(i8* %160, i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.27, i64 0, i64 0), i32 %166)
%169 = call i8* @changefileext(i8* %28, i8* %160)
%170 = call i32* @fopen(i8* %169, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.22, i64 0, i64 0))
%171 = icmp eq i32* %170, null
br i1 %171, label %172, label %175
172: ; preds = %164
%173 = call i32 @perror(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.23, i64 0, i64 0))
%174 = call i32 @exit(i32 1)
unreachable
175: ; preds = %164
%176 = zext i32 %167 to i64
%177 = getelementptr inbounds i8, i8* %66, i64 %176
%178 = load i8, i8* %177
%179 = zext i8 %178 to i32
%180 = add i32 %167, 2
%181 = zext i32 %180 to i64
%182 = getelementptr inbounds i8, i8* %66, i64 %181
%183 = load i8, i8* %182
%184 = zext i8 %183 to i32
%185 = add i32 %167, 4
%186 = zext i32 %185 to i64
%187 = getelementptr inbounds i8, i8* %66, i64 %186
%188 = load i8, i8* %187
%189 = zext i8 %188 to i32
%190 = add i32 %167, 5
%191 = zext i32 %190 to i64
%192 = getelementptr inbounds i8, i8* %66, i64 %191
%193 = load i8, i8* %192
%194 = zext i8 %193 to i32
%195 = shl nuw nsw i32 %194, 8
%196 = or i32 %195, %189
%197 = add nuw nsw i32 %166, 1
%198 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str.28, i64 0, i64 0), i32 %197, i32 %179, i32 %184, i32 %196)
%199 = call i32 @fprintf(i32* %170, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.29, i64 0, i64 0), i32 %179, i32 %184)
%200 = icmp eq i32 %196, 0
br i1 %200, label %238, label %201
201: ; preds = %175
%202 = add i32 %167, 6
%203 = zext i32 %196 to i64
br label %204
204: ; preds = %201, %233
%205 = phi i64 [ 0, %201 ], [ %236, %233 ]
%206 = phi i32 [ 0, %201 ], [ %235, %233 ]
%207 = phi i32 [ %165, %201 ], [ %234, %233 ]
%208 = icmp eq i32 %207, 0
br i1 %208, label %209, label %233
209: ; preds = %204
%210 = trunc i64 %205 to i32
%211 = add i32 %202, %210
%212 = zext i32 %211 to i64
%213 = getelementptr inbounds i8, i8* %66, i64 %212
%214 = load i8, i8* %213
%215 = icmp eq i8 %214, 0
br i1 %215, label %216, label %228
216: ; preds = %209
%217 = add i32 %211, 1
%218 = zext i32 %217 to i64
%219 = getelementptr inbounds i8, i8* %66, i64 %218
%220 = load i8, i8* %219
%221 = zext i8 %220 to i32
%222 = icmp eq i8 %220, 0
br i1 %222, label %233, label %223
223: ; preds = %216, %223
%224 = phi i32 [ %226, %223 ], [ 0, %216 ]
store i8 0, i8* %161
store i8 -1, i8* %162
store i8 0, i8* %163
%225 = call i32 @fwrite(i8* %161, i32 1, i32 3, i32* %170)
%226 = add nuw nsw i32 %224, 1
%227 = icmp eq i32 %226, %221
br i1 %227, label %231, label %223
228: ; preds = %209
store i8 %214, i8* %161
store i8 %214, i8* %162
store i8 %214, i8* %163
%229 = call i32 @fwrite(i8* %161, i32 1, i32 3, i32* %170)
%230 = add i32 %206, 1
br label %233
231: ; preds = %223
%232 = add i32 %206, %221
br label %233
233: ; preds = %231, %216, %204, %228
%234 = phi i32 [ 0, %228 ], [ 0, %204 ], [ 1, %216 ], [ 1, %231 ]
%235 = phi i32 [ %230, %228 ], [ %206, %204 ], [ %206, %216 ], [ %232, %231 ]
%236 = add nuw nsw i64 %205, 1
%237 = icmp eq i64 %236, %203
br i1 %237, label %238, label %204
238: ; preds = %233, %175
%239 = phi i32 [ %165, %175 ], [ %234, %233 ]
%240 = phi i32 [ 0, %175 ], [ %235, %233 ]
%241 = add i32 %240, -1
%242 = mul nuw nsw i32 %184, %179
%243 = icmp ult i32 %241, %242
br i1 %243, label %244, label %249
244: ; preds = %238, %244
%245 = phi i32 [ %247, %244 ], [ %241, %238 ]
store i8 0, i8* %161
store i8 -1, i8* %162
store i8 0, i8* %163
%246 = call i32 @fwrite(i8* %161, i32 1, i32 3, i32* %170)
%247 = add i32 %245, 1
%248 = icmp eq i32 %247, %242
br i1 %248, label %249, label %244
249: ; preds = %244, %238
%250 = add i32 %167, 8
%251 = add i32 %250, %196
%252 = call i32 @fclose(i32* %170)
%253 = icmp eq i32 %197, %155
br i1 %253, label %258, label %164
254: ; preds = %143, %139, %135, %132
%255 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str.30, i64 0, i64 0), i8* %28)
br label %258
256: ; preds = %131
%257 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @str.33, i64 0, i64 0))
br label %258
258: ; preds = %249, %152, %256, %254, %112, %129
%259 = call i32 @fclose(i32* %55)
%260 = call i32 @free(i8* %66)
%261 = call i32 @exit(i32 0)
unreachable
}