#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ SEEK_SET;
double atof(char *);
int atoi(char *);
int /*<<< orphan*/ errno;
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, ...);
int fread(unsigned short *, int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ fseek(int /*<<< orphan*/ *, int, int /*<<< orphan*/);
int /*<<< orphan*/ fwrite(unsigned short *, int, int, int /*<<< orphan*/ *);
unsigned short *malloc(int);
int /*<<< orphan*/ snprintf(char *, int, char *, char *, int);
int /*<<< orphan*/ *stderr;
char *strchr(char *, char);
char *strerror(int /*<<< orphan*/);
scalar_t__ strncmp(char *, char *, int);
int /*<<< orphan*/ usage();
int main(int argc, char **argv) {
  FILE *input_fp, *output_fp;
  int nimages = 0;
  int npixels;
  int nlines;
  int data_offset[100];
  int data_length[100];
  int image_type[100];
  int max_length = 0;
  double image_size[100];
  double ZSens_V_to_nm;
  double CurrentSens_V_to_nA;
  double ZDAtoVolt;
  double Z_scale_V[100];
  double Z_limit_V;
  char line[256];
  if (argc < 2)
    usage();
  if (strncmp(argv[1], "-h", 2) == 0)
    usage();
  char *fn;
  int fnum;
  for (fnum = 1; fnum < argc; fnum++) {
    fn = argv[fnum];
    nimages = 0;
    max_length = 0;
    input_fp = fopen(fn, "rb");
    if (input_fp == NULL) {
      fprintf(stderr, "Could not read file %s: %s\n", fn, strerror(errno));
    }
    fprintf(stderr, "%s: ", fn);
    while (1) {
      fgets(line, 256, input_fp);
      if (strncmp(line, "\\Valid data len X: ", 18) == 0) {
        npixels = atoi(&line[18]);
        continue;
      }
      if (strncmp(line, "\\Valid data len Y: ", 18) == 0) {
        nlines = atoi(&line[18]);
        continue;
      }
      if (strncmp(line, "\\@Sens. Zscan: V ", 16) == 0) {
        ZSens_V_to_nm = atof(&line[17]);
        continue;
      }
      if (strncmp(line, "\\@1:Z limit: V [Sens. Zscan] (", 30) == 0) {
        ZDAtoVolt = atof(&line[30]);
        Z_limit_V = atof(&line[49]);
        continue;
      }
      if (strncmp(line, "\\@2:Z scale: V [Sens.", 10) == 0) {
        char *p = line;
        p = strchr(p, ')');
        p += 2;
        Z_scale_V[nimages] = atof(p);
        if (strncmp(&line[22], "Zscan", 5) == 0)
          image_type[nimages] = 0;
        else
          image_type[nimages] = 1;
        fprintf(stderr, "%d=%s ", nimages - 1,
                image_type[nimages] == 0 ? "topo" : "other");
        continue;
      }
      if (strncmp(line, "\\Data offset: ", 13) == 0) {
        data_offset[nimages] = atoi(&line[13]);
        continue;
      }
      if (strncmp(line, "\\Data length: ", 13) == 0) {
        data_length[nimages] = atoi(&line[13]);
        if (data_length[nimages] > max_length)
          max_length = data_length[nimages];
        continue;
      }
      if (strncmp(line, "\\*Ciao image list", 16) == 0) {
        nimages++;
        continue;
      }
      if (strncmp(line, "\\Scan size: ", 11) == 0) {
        image_size[nimages] = atof(&line[11]);
        continue;
      }
      if (strncmp(line, "\\*File list end ", 15) == 0)
        break;
    }
    int n;
    char outname[256];
    char ibuf[2];
    char obuf[2];
    int m, i, j;
    int d1, d2;
    unsigned short *data;
    data = malloc(max_length);
    unsigned short tmp;
    double scale_bits_to_nm;
    for (n = 1; n <= nimages; n++) {
      fseek(input_fp, data_offset[n], SEEK_SET);
      m = fread(data, 1, data_length[nimages], input_fp);
      if (m != nlines * npixels * 2)
        fprintf(stderr, "Warning image %d: m %d, pix %d lin %d pix*lin %d \n",
                n, m, npixels, nlines, nlines * npixels * 2);
      for (i = 0; i < nlines * npixels; i++)
        data[i] = ((((data[i] - 32767) & 0xff) << 8) |
                   ((unsigned short)(data[i] - 32767) >> 8));
      for (i = 0; i < npixels; i++)
        for (j = 0; j < nlines / 2; j++) {
          tmp = data[(nlines - j - 1) * npixels + i];
          data[(nlines - j - 1) * npixels + i] = data[j * npixels + i];
          data[j * npixels + i] = tmp;
        }
      snprintf(outname, 256, "%s.%d.pgm", fn, n - 1);
      if ((output_fp = fopen(outname, "wb")) == NULL) {
        fprintf(stderr, "Could not write file %s: %s\n", fn, strerror(errno));
        usage();
      }
      fprintf(output_fp, "P5\n%d %d\n", npixels, nlines);
      scale_bits_to_nm = ZSens_V_to_nm * ZDAtoVolt * Z_scale_V[n] / Z_limit_V;
      if (image_type[n] == 0)
        fprintf(output_fp, "#zmin %e\n#zmax %e\n#zunit nm\n",
                -32768 * scale_bits_to_nm, 32767 * scale_bits_to_nm);
      else
        fprintf(output_fp, "#zmin -10\n#zmax 10\n#zunit Voltage (V)\n");
      fprintf(output_fp, "#xmin 0\n#xmax %e\n#ymin 0\n#ymax %e\n",
              image_size[n], image_size[n]);
      fprintf(output_fp, "#xunit Mircons\n#yunit Microns\n");
      fprintf(output_fp, "65535\n");
      fwrite(data, data_length[nimages], 1, output_fp);
      fclose(output_fp);
    }
    fprintf(stderr, "done.\n");
    fclose(input_fp);
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xde0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x24(%rbp)
movl   $0x0,-0x4e4(%rbp)
cmpl   $0x2,-0x8(%rbp)
jge    122b <main+0x3b>
mov    $0x0,%al
call   10d0 <usage@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xdd6(%rip),%rsi
mov    $0x2,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
jne    1255 <main+0x65>
mov    $0x0,%al
call   10d0 <usage@plt>
movl   $0x1,-0xc6c(%rbp)
mov    -0xc6c(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1aee <main+0x8fe>
mov    -0x10(%rbp),%rax
movslq -0xc6c(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0xc68(%rbp)
movl   $0x0,-0x24(%rbp)
movl   $0x0,-0x4e4(%rbp)
mov    -0xc68(%rbp),%rdi
lea    0xd70(%rip),%rsi
call   10e0 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    1303 <main+0x113>
mov    0x2d22(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0xdc0(%rbp)
mov    -0xc68(%rbp),%rax
mov    %rax,-0xdb8(%rbp)
mov    0x2cfb(%rip),%rax
mov    (%rax),%edi
call   1110 <strerror@plt>
mov    -0xdc0(%rbp),%rdi
mov    -0xdb8(%rbp),%rdx
mov    %rax,%rcx
lea    0xd1a(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
mov    0x2cd6(%rip),%rax
mov    (%rax),%rdi
mov    -0xc68(%rbp),%rdx
lea    0xd17(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
lea    -0xc60(%rbp),%rdi
mov    -0x18(%rbp),%rdx
mov    $0x100,%esi
call   1090 <fgets@plt>
lea    -0xc60(%rbp),%rdi
lea    0xcf2(%rip),%rsi
mov    $0x12,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
jne    1371 <main+0x181>
lea    -0xc60(%rbp),%rdi
add    $0x12,%rdi
call   10f0 <atoi@plt>
mov    %eax,-0x28(%rbp)
jmp    1322 <main+0x132>
lea    -0xc60(%rbp),%rdi
lea    0xccc(%rip),%rsi
mov    $0x12,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
jne    13ab <main+0x1bb>
lea    -0xc60(%rbp),%rdi
add    $0x12,%rdi
call   10f0 <atoi@plt>
mov    %eax,-0x2c(%rbp)
jmp    1322 <main+0x132>
lea    -0xc60(%rbp),%rdi
lea    0xca6(%rip),%rsi
mov    $0x10,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
jne    13ea <main+0x1fa>
lea    -0xc60(%rbp),%rdi
add    $0x11,%rdi
call   1050 <atof@plt>
movsd  %xmm0,-0x818(%rbp)
ff
jmp    1322 <main+0x132>
lea    -0xc60(%rbp),%rdi
lea    0xc79(%rip),%rsi
mov    $0x1e,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
jne    1441 <main+0x251>
lea    -0xc60(%rbp),%rdi
add    $0x1e,%rdi
call   1050 <atof@plt>
movsd  %xmm0,-0x828(%rbp)
ff
lea    -0xc60(%rbp),%rdi
add    $0x31,%rdi
call   1050 <atof@plt>
movsd  %xmm0,-0xb58(%rbp)
ff
jmp    1322 <main+0x132>
lea    -0xc60(%rbp),%rdi
lea    0xc41(%rip),%rsi
mov    $0xa,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
jne    1540 <main+0x350>
lea    -0xc60(%rbp),%rax
mov    %rax,-0xc78(%rbp)
mov    -0xc78(%rbp),%rdi
mov    $0x29,%esi
call   1070 <strchr@plt>
mov    %rax,-0xc78(%rbp)
mov    -0xc78(%rbp),%rax
add    $0x2,%rax
mov    %rax,-0xc78(%rbp)
mov    -0xc78(%rbp),%rdi
call   1050 <atof@plt>
movslq -0x24(%rbp),%rax
movsd  %xmm0,-0xb50(%rbp,%rax,8)
ff ff
lea    -0xc60(%rbp),%rdi
add    $0x16,%rdi
lea    0xbe0(%rip),%rsi
mov    $0x5,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
jne    14ee <main+0x2fe>
movslq -0x24(%rbp),%rax
movl   $0x0,-0x4e0(%rbp,%rax,4)
jmp    14fd <main+0x30d>
movslq -0x24(%rbp),%rax
movl   $0x1,-0x4e0(%rbp,%rax,4)
mov    0x2adc(%rip),%rax
mov    (%rax),%rdi
mov    -0x24(%rbp),%edx
sub    $0x1,%edx
movslq -0x24(%rbp),%rax
mov    -0x4e0(%rbp,%rax,4),%esi
lea    0xb99(%rip),%rcx
lea    0xb8d(%rip),%rax
cmp    $0x0,%esi
cmove  %rax,%rcx
lea    0xb78(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
jmp    1322 <main+0x132>
lea    -0xc60(%rbp),%rdi
lea    0xb70(%rip),%rsi
mov    $0xd,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
jne    1584 <main+0x394>
lea    -0xc60(%rbp),%rdi
add    $0xd,%rdi
call   10f0 <atoi@plt>
mov    %eax,%ecx
movslq -0x24(%rbp),%rax
mov    %ecx,-0x1c0(%rbp,%rax,4)
jmp    1322 <main+0x132>
lea    -0xc60(%rbp),%rdi
lea    0xb3b(%rip),%rsi
mov    $0xd,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
jne    15f0 <main+0x400>
lea    -0xc60(%rbp),%rdi
add    $0xd,%rdi
call   10f0 <atoi@plt>
mov    %eax,%ecx
movslq -0x24(%rbp),%rax
mov    %ecx,-0x350(%rbp,%rax,4)
movslq -0x24(%rbp),%rax
mov    -0x350(%rbp,%rax,4),%eax
cmp    -0x4e4(%rbp),%eax
jle    15eb <main+0x3fb>
movslq -0x24(%rbp),%rax
mov    -0x350(%rbp,%rax,4),%eax
mov    %eax,-0x4e4(%rbp)
jmp    1322 <main+0x132>
lea    -0xc60(%rbp),%rdi
lea    0xade(%rip),%rsi
mov    $0x10,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
jne    1620 <main+0x430>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1322 <main+0x132>
lea    -0xc60(%rbp),%rdi
lea    0xac0(%rip),%rsi
mov    $0xb,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
jne    1664 <main+0x474>
lea    -0xc60(%rbp),%rdi
add    $0xb,%rdi
call   1050 <atof@plt>
movslq -0x24(%rbp),%rax
movsd  %xmm0,-0x810(%rbp,%rax,8)
ff ff
jmp    1322 <main+0x132>
lea    -0xc60(%rbp),%rdi
lea    0xa89(%rip),%rsi
mov    $0xf,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
jne    168b <main+0x49b>
jmp    1690 <main+0x4a0>
jmp    1322 <main+0x132>
mov    -0x4e4(%rbp),%edi
call   10b0 <malloc@plt>
mov    %rax,-0xda0(%rbp)
movl   $0x1,-0xc7c(%rbp)
mov    -0xc7c(%rbp),%eax
cmp    -0x24(%rbp),%eax
jg     1ab9 <main+0x8c9>
mov    -0x18(%rbp),%rdi
movslq -0xc7c(%rbp),%rax
mov    -0x1c0(%rbp,%rax,4),%esi
mov    0x28fc(%rip),%rax
mov    (%rax),%edx
call   10c0 <fseek@plt>
mov    -0xda0(%rbp),%rdi
movslq -0x24(%rbp),%rax
mov    -0x350(%rbp,%rax,4),%edx
mov    -0x18(%rbp),%rcx
mov    $0x1,%esi
call   1040 <fread@plt>
mov    %eax,-0xd88(%rbp)
mov    -0xd88(%rbp),%eax
mov    -0x2c(%rbp),%ecx
imul   -0x28(%rbp),%ecx
shl    $0x1,%ecx
cmp    %ecx,%eax
je     1752 <main+0x562>
mov    0x28c0(%rip),%rax
mov    (%rax),%rdi
mov    -0xc7c(%rbp),%edx
mov    -0xd88(%rbp),%ecx
mov    -0x28(%rbp),%r8d
mov    -0x2c(%rbp),%r9d
mov    -0x2c(%rbp),%eax
imul   -0x28(%rbp),%eax
shl    $0x1,%eax
lea    0x9c4(%rip),%rsi
mov    %eax,(%rsp)
mov    $0x0,%al
call   10a0 <fprintf@plt>
movl   $0x0,-0xd8c(%rbp)
mov    -0xd8c(%rbp),%eax
mov    -0x2c(%rbp),%ecx
imul   -0x28(%rbp),%ecx
cmp    %ecx,%eax
jge    17d9 <main+0x5e9>
mov    -0xda0(%rbp),%rax
movslq -0xd8c(%rbp),%rcx
movzwl (%rax,%rcx,2),%eax
sub    $0x7fff,%eax
and    $0xff,%eax
shl    $0x8,%eax
mov    -0xda0(%rbp),%rcx
movslq -0xd8c(%rbp),%rdx
movzwl (%rcx,%rdx,2),%ecx
sub    $0x7fff,%ecx
movzwl %cx,%ecx
sar    $0x8,%ecx
or     %ecx,%eax
mov    %ax,%dx
mov    -0xda0(%rbp),%rax
movslq -0xd8c(%rbp),%rcx
mov    %dx,(%rax,%rcx,2)
mov    -0xd8c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xd8c(%rbp)
jmp    175c <main+0x56c>
movl   $0x0,-0xd8c(%rbp)
mov    -0xd8c(%rbp),%eax
cmp    -0x28(%rbp),%eax
jge    18e2 <main+0x6f2>
movl   $0x0,-0xd90(%rbp)
mov    -0xd90(%rbp),%eax
mov    %eax,-0xdc4(%rbp)
mov    -0x2c(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0xdc4(%rbp),%eax
cmp    %ecx,%eax
jge    18c9 <main+0x6d9>
mov    -0xda0(%rbp),%rax
mov    -0x2c(%rbp),%ecx
sub    -0xd90(%rbp),%ecx
sub    $0x1,%ecx
imul   -0x28(%rbp),%ecx
add    -0xd8c(%rbp),%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,2),%ax
mov    %ax,-0xda2(%rbp)
mov    -0xda0(%rbp),%rax
mov    -0xd90(%rbp),%ecx
imul   -0x28(%rbp),%ecx
add    -0xd8c(%rbp),%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,2),%dx
mov    -0xda0(%rbp),%rax
mov    -0x2c(%rbp),%ecx
sub    -0xd90(%rbp),%ecx
sub    $0x1,%ecx
imul   -0x28(%rbp),%ecx
add    -0xd8c(%rbp),%ecx
movslq %ecx,%rcx
mov    %dx,(%rax,%rcx,2)
mov    -0xda2(%rbp),%dx
mov    -0xda0(%rbp),%rax
mov    -0xd90(%rbp),%ecx
imul   -0x28(%rbp),%ecx
add    -0xd8c(%rbp),%ecx
movslq %ecx,%rcx
mov    %dx,(%rax,%rcx,2)
mov    -0xd90(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xd90(%rbp)
jmp    17fc <main+0x60c>
jmp    18ce <main+0x6de>
mov    -0xd8c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xd8c(%rbp)
jmp    17e3 <main+0x5f3>
lea    -0xd80(%rbp),%rdi
mov    -0xc68(%rbp),%rcx
mov    -0xc7c(%rbp),%r8d
sub    $0x1,%r8d
mov    $0x100,%esi
lea    0x838(%rip),%rdx
call   1080 <snprintf@plt>
lea    -0xd80(%rbp),%rdi
lea    0x82f(%rip),%rsi
call   10e0 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
jne    1980 <main+0x790>
mov    0x26ac(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0xdd8(%rbp)
mov    -0xc68(%rbp),%rax
mov    %rax,-0xdd0(%rbp)
mov    0x2685(%rip),%rax
mov    (%rax),%edi
call   1110 <strerror@plt>
mov    -0xdd8(%rbp),%rdi
mov    -0xdd0(%rbp),%rdx
mov    %rax,%rcx
lea    0x7da(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
mov    $0x0,%al
call   10d0 <usage@plt>
mov    -0x20(%rbp),%rdi
mov    -0x28(%rbp),%edx
mov    -0x2c(%rbp),%ecx
lea    0x7d8(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
movsd  -0x818(%rbp),%xmm0
ff
mulsd  -0x828(%rbp),%xmm0
ff
movslq -0xc7c(%rbp),%rax
mulsd  -0xb50(%rbp,%rax,8),%xmm0
ff ff
divsd  -0xb58(%rbp),%xmm0
ff
movsd  %xmm0,-0xdb0(%rbp)
ff
movslq -0xc7c(%rbp),%rax
cmpl   $0x0,-0x4e0(%rbp,%rax,4)
jne    1a14 <main+0x824>
mov    -0x20(%rbp),%rdi
movsd  0x61f(%rip),%xmm0
mulsd  -0xdb0(%rbp),%xmm0
ff
movsd  0x607(%rip),%xmm1
mulsd  -0xdb0(%rbp),%xmm1
lea    0x76b(%rip),%rsi
mov    $0x2,%al
call   10a0 <fprintf@plt>
jmp    1a26 <main+0x836>
mov    -0x20(%rbp),%rdi
lea    0x771(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
mov    -0x20(%rbp),%rdi
movslq -0xc7c(%rbp),%rax
movsd  -0x810(%rbp,%rax,8),%xmm0
ff ff
movslq -0xc7c(%rbp),%rax
movsd  -0x810(%rbp,%rax,8),%xmm1
ff ff
lea    0x766(%rip),%rsi
mov    $0x2,%al
call   10a0 <fprintf@plt>
mov    -0x20(%rbp),%rdi
lea    0x777(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
mov    -0x20(%rbp),%rdi
lea    0x784(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
mov    -0xda0(%rbp),%rdi
movslq -0x24(%rbp),%rax
mov    -0x350(%rbp,%rax,4),%esi
mov    -0x20(%rbp),%rcx
mov    $0x1,%edx
call   1100 <fwrite@plt>
mov    -0x20(%rbp),%rdi
call   1060 <fclose@plt>
mov    -0xc7c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc7c(%rbp)
jmp    16ac <main+0x4bc>
mov    0x2520(%rip),%rax
mov    (%rax),%rdi
lea    0x736(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
mov    -0x18(%rbp),%rdi
call   1060 <fclose@plt>
mov    -0xc6c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc6c(%rbp)
jmp    125f <main+0x6f>
mov    -0x4(%rbp),%eax
add    $0xde0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0xdb8,%rsp
mov    %rsi,%rbx
mov    %edi,%ebp
cmp    $0x1,%edi
jg     1212 <main+0x22>
xor    %eax,%eax
call   10d0 <usage@plt>
mov    0x8(%rbx),%rdi
lea    0xe03(%rip),%rsi
mov    $0x2,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
je     1236 <main+0x46>
cmp    $0x2,%ebp
jge    1246 <main+0x56>
jmp    19b1 <main+0x7c1>
xor    %eax,%eax
call   10d0 <usage@plt>
cmp    $0x2,%ebp
jl     19b1 <main+0x7c1>
lea    0xcd(%rsp),%r13
mov    %ebp,%eax
mov    %rax,0x48(%rsp)
mov    $0x1,%eax
lea    0xc0(%rsp),%r12
mov    %rcx,0x18(%rsp)
mov    %rbx,0x50(%rsp)
jmp    12bb <main+0xcb>
xchg   %ax,%ax
mov    0x2d69(%rip),%rax
mov    (%rax),%rcx
mov    $0x6,%esi
mov    $0x1,%edx
lea    0xf85(%rip),%rdi
call   1100 <fwrite@plt>
mov    0x30(%rsp),%rdi
call   1060 <fclose@plt>
mov    0x58(%rsp),%rax
add    $0x1,%rax
cmp    0x48(%rsp),%rax
mov    0x50(%rsp),%rbx
lea    0xcd(%rsp),%r13
je     19b1 <main+0x7c1>
mov    %rax,0x58(%rsp)
mov    (%rbx,%rax,8),%r15
mov    %r15,%rdi
lea    0xd55(%rip),%rsi
call   10e0 <fopen@plt>
mov    %rax,0x30(%rsp)
test   %rax,%rax
jne    130c <main+0x11c>
mov    0x2cfc(%rip),%rax
mov    (%rax),%rbx
mov    0x2cea(%rip),%rax
mov    (%rax),%edi
call   1110 <strerror@plt>
mov    %rbx,%rdi
lea    0xd27(%rip),%rsi
mov    %r15,%rdx
mov    %rax,%rcx
xor    %eax,%eax
call   10a0 <fprintf@plt>
mov    0x2ccd(%rip),%rax
mov    (%rax),%rdi
movl   $0x0,0x14(%rsp)
lea    0xd1d(%rip),%rsi
mov    %r15,0xa0(%rsp)
mov    %r15,%rdx
xor    %eax,%eax
call   10a0 <fprintf@plt>
xor    %ebp,%ebp
lea    0xd1(%rsp),%rbx
lea    0xcb(%rsp),%r15
jmp    1360 <main+0x170>
nopl   0x0(%rax,%rax,1)
lea    0xd2(%rsp),%rdi
call   10f0 <atoi@plt>
mov    %eax,%r14d
mov    %r12,%rdi
mov    $0x100,%esi
mov    0x30(%rsp),%rdx
call   1090 <fgets@plt>
mov    %r12,%rdi
lea    0xccb(%rip),%rsi
mov    $0x12,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
je     1350 <main+0x160>
mov    %r12,%rdi
lea    0xcc6(%rip),%rsi
mov    $0x12,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
je     14a0 <main+0x2b0>
mov    %r12,%rdi
lea    0xcbd(%rip),%rsi
mov    $0x10,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
je     14b7 <main+0x2c7>
mov    %r12,%rdi
lea    0xcb2(%rip),%rsi
mov    $0x1e,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
je     14cd <main+0x2dd>
mov    %r12,%rdi
lea    0xcb4(%rip),%rsi
mov    $0xa,%edx
call   1030 <strncmp@plt>
mov    %r12,%rdi
test   %rax,%rax
je     14fe <main+0x30e>
lea    0xcc5(%rip),%rsi
mov    $0xd,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
je     157f <main+0x38f>
mov    %r12,%rdi
lea    0xcb7(%rip),%rsi
mov    $0xd,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
je     1596 <main+0x3a6>
mov    %r12,%rdi
lea    0xca9(%rip),%rsi
mov    $0x10,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
je     15ba <main+0x3ca>
mov    %r12,%rdi
lea    0xc9e(%rip),%rsi
mov    $0xb,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
je     15c2 <main+0x3d2>
mov    %r12,%rdi
lea    0xc8e(%rip),%rsi
mov    $0xf,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
jne    1360 <main+0x170>
jmp    15e0 <main+0x3f0>
cs nopw 0x0(%rax,%rax,1)
nop
lea    0xd2(%rsp),%rdi
call   10f0 <atoi@plt>
mov    %rax,0x18(%rsp)
jmp    1360 <main+0x170>
mov    %rbx,%rdi
call   1050 <atof@plt>
movq   %xmm0,0xb8(%rsp)
jmp    1360 <main+0x170>
lea    0xde(%rsp),%rdi
call   1050 <atof@plt>
movq   %xmm0,0xa8(%rsp)
lea    0xf1(%rsp),%rdi
call   1050 <atof@plt>
movq   %xmm0,0xb0(%rsp)
jmp    1360 <main+0x170>
mov    $0x29,%esi
call   1070 <strchr@plt>
lea    0x2(%rax),%rdi
call   1050 <atof@plt>
movslq %ebp,%rbx
movq   %xmm0,0x770(%rsp,%rbx,8)
lea    0xd6(%rsp),%rdi
lea    0xb8a(%rip),%rsi
mov    $0x5,%edx
call   1030 <strncmp@plt>
xor    %edx,%edx
test   %rax,%rax
lea    0xb86(%rip),%rcx
lea    0xb7a(%rip),%rax
cmove  %rax,%rcx
setne  %dl
mov    %edx,0x2c0(%rsp,%rbx,4)
lea    0xd1(%rsp),%rbx
mov    0x2a7a(%rip),%rax
mov    (%rax),%rdi
lea    -0x1(%rbp),%edx
lea    0xb49(%rip),%rsi
xor    %eax,%eax
call   10a0 <fprintf@plt>
jmp    1360 <main+0x170>
mov    %r13,%rdi
call   10f0 <atoi@plt>
movslq %ebp,%rcx
mov    %eax,0x5e0(%rsp,%rcx,4)
jmp    1360 <main+0x170>
mov    %r13,%rdi
call   10f0 <atoi@plt>
movslq %ebp,%rcx
mov    %eax,0x450(%rsp,%rcx,4)
mov    0x14(%rsp),%ecx
cmp    %ecx,%eax
cmovg  %eax,%ecx
mov    %ecx,0x14(%rsp)
jmp    1360 <main+0x170>
add    $0x1,%ebp
jmp    1360 <main+0x170>
mov    %r15,%rdi
call   1050 <atof@plt>
movslq %ebp,%rax
movq   %xmm0,0xa90(%rsp,%rax,8)
jmp    1360 <main+0x170>
nopl   0x0(%rax,%rax,1)
mov    0x14(%rsp),%edi
call   10b0 <malloc@plt>
test   %ebp,%ebp
jle    1270 <main+0x80>
mov    %rax,%r15
mov    %rbp,%rax
mov    %rbp,%rcx
mov    %ecx,%eax
mov    %rax,0x90(%rsp)
mov    %r14d,%ebp
mov    0x18(%rsp),%rax
imul   %eax,%ebp
lea    0x0(%rbp,%rbp,1),%edx
mov    %edx,0x24(%rsp)
mov    %eax,%edx
shr    $0x1f,%edx
add    %eax,%edx
sar    %edx
mov    %rdx,0x80(%rsp)
movsd  0xa8(%rsp),%xmm0
mulsd  0xb8(%rsp),%xmm0
movsd  %xmm0,0x68(%rsp)
movslq %r14d,%r13
add    $0x1,%ecx
mov    %rcx,0x98(%rsp)
mov    %r13d,%ecx
mov    %rcx,0x78(%rsp)
mov    %ebp,%ecx
and    $0xfffffff0,%ecx
mov    %rcx,0x60(%rsp)
add    $0xffffffff,%eax
imul   %r14d,%eax
mov    %eax,0x14(%rsp)
add    %r13,%r13
mov    $0x1,%ebx
mov    %rbp,0x88(%rsp)
jmp    1724 <main+0x534>
mov    $0x26,%esi
mov    $0x1,%edx
lea    0xb0f(%rip),%rdi
mov    0x28(%rsp),%rbp
mov    %rbp,%rcx
call   1100 <fwrite@plt>
movq   0xa90(%rsp,%rbx,8),%xmm0
mov    %rbp,%rdi
lea    0xb16(%rip),%rsi
movdqa %xmm0,%xmm1
mov    $0x2,%al
call   10a0 <fprintf@plt>
mov    $0x1e,%esi
mov    $0x1,%edx
lea    0xb1d(%rip),%rdi
mov    %rbp,%rcx
call   1100 <fwrite@plt>
mov    $0x6,%esi
mov    $0x1,%edx
lea    0xb23(%rip),%rdi
mov    %rbp,%rcx
call   1100 <fwrite@plt>
mov    %r15,%rdi
mov    0x3c(%rsp),%esi
mov    $0x1,%edx
mov    %rbp,%rcx
call   1100 <fwrite@plt>
mov    %rbp,%rdi
call   1060 <fclose@plt>
add    $0x1,%rbx
cmp    0x98(%rsp),%rbx
mov    0x88(%rsp),%rbp
je     1270 <main+0x80>
mov    %rbx,0x40(%rsp)
mov    0x5e0(%rsp,%rbx,4),%esi
mov    0x2899(%rip),%rax
mov    (%rax),%edx
mov    0x30(%rsp),%rbx
mov    %rbx,%rdi
call   10c0 <fseek@plt>
mov    0x90(%rsp),%rax
mov    0x450(%rsp,%rax,4),%edx
mov    %r15,%rdi
mov    $0x1,%esi
mov    %edx,0x3c(%rsp)
mov    %rbx,%rcx
mov    0x40(%rsp),%rbx
call   1040 <fread@plt>
cmp    0x24(%rsp),%eax
je     179f <main+0x5af>
mov    0x2865(%rip),%rcx
mov    (%rcx),%rdi
mov    0x24(%rsp),%ecx
mov    %ecx,(%rsp)
lea    0x990(%rip),%rsi
mov    %ebx,%edx
mov    %eax,%ecx
mov    %r14d,%r8d
mov    0x18(%rsp),%r9
xor    %eax,%eax
call   10a0 <fprintf@plt>
test   %ebp,%ebp
movdqa 0x857(%rip),%xmm3
mov    0x18(%rsp),%r9
mov    0x80(%rsp),%r10
mov    0x78(%rsp),%r11
jle    184d <main+0x65d>
xor    %eax,%eax
cmp    $0x10,%ebp
jb     1830 <main+0x640>
mov    0x60(%rsp),%rcx
nopl   (%rax)
movdqu (%r15,%rax,2),%xmm0
movdqu 0x10(%r15,%rax,2),%xmm1
paddw  %xmm3,%xmm0
paddw  %xmm3,%xmm1
movdqa %xmm0,%xmm2
psrlw  $0x8,%xmm2
psllw  $0x8,%xmm0
por    %xmm2,%xmm0
movdqa %xmm1,%xmm2
psrlw  $0x8,%xmm2
psllw  $0x8,%xmm1
por    %xmm2,%xmm1
movdqu %xmm0,(%r15,%rax,2)
movdqu %xmm1,0x10(%r15,%rax,2)
add    $0x10,%rax
cmp    %rax,%rcx
jne    17d0 <main+0x5e0>
mov    %rcx,%rax
cmp    %rbp,%rcx
je     184d <main+0x65d>
nopw   0x0(%rax,%rax,1)
movzwl (%r15,%rax,2),%ecx
add    $0xffff8001,%ecx
rol    $0x8,%cx
mov    %cx,(%r15,%rax,2)
add    $0x1,%rax
cmp    %rax,%rbp
jne    1830 <main+0x640>
test   %r14d,%r14d
jle    18b0 <main+0x6c0>
mov    %r15,%r8
xor    %ecx,%ecx
jmp    186d <main+0x67d>
nopl   0x0(%rax)
add    $0x1,%rcx
add    $0x2,%r8
cmp    %r11,%rcx
je     18b0 <main+0x6c0>
cmp    $0x2,%r9d
jl     1860 <main+0x670>
mov    %r10,%rdx
mov    %r8,%rsi
mov    0x14(%rsp),%eax
mov    %eax,%edi
nop
movslq %edi,%rdi
lea    (%rcx,%rdi,1),%rbp
movzwl (%r15,%rbp,2),%eax
movzwl (%rsi),%ebx
mov    %bx,(%r15,%rbp,2)
mov    %ax,(%rsi)
sub    %r14d,%edi
add    %r13,%rsi
add    $0xffffffffffffffff,%rdx
jne    1880 <main+0x690>
jmp    1860 <main+0x670>
cs nopw 0x0(%rax,%rax,1)
nop
mov    0x40(%rsp),%rbp
lea    -0x1(%rbp),%r8d
lea    0x1c0(%rsp),%rdi
mov    $0x100,%esi
lea    0x882(%rip),%rdx
mov    0xa0(%rsp),%rbx
mov    %rbx,%rcx
call   1080 <snprintf@plt>
lea    0x1c0(%rsp),%rdi
lea    0x86d(%rip),%rsi
call   10e0 <fopen@plt>
mov    %rax,%rcx
test   %rax,%rax
mov    %rax,0x28(%rsp)
jne    1940 <main+0x750>
mov    0x26db(%rip),%rax
mov    (%rax),%rax
mov    %rax,0x70(%rsp)
mov    0x26c4(%rip),%rax
mov    (%rax),%edi
call   1110 <strerror@plt>
mov    0x70(%rsp),%rdi
lea    0x835(%rip),%rsi
mov    %rbx,%rdx
mov    %rax,%rcx
xor    %eax,%eax
call   10a0 <fprintf@plt>
xor    %eax,%eax
call   10d0 <usage@plt>
mov    0x28(%rsp),%rcx
mov    %rcx,%rdi
lea    0x82f(%rip),%rsi
mov    %r14d,%edx
mov    0x18(%rsp),%rcx
xor    %eax,%eax
call   10a0 <fprintf@plt>
cmpl   $0x0,0x2c0(%rsp,%rbp,4)
mov    %rbp,%rbx
jne    1680 <main+0x490>
movsd  0x770(%rsp,%rbx,8),%xmm1
mulsd  0x68(%rsp),%xmm1
divsd  0xb0(%rsp),%xmm1
movapd %xmm1,%xmm0
mulsd  0x682(%rip),%xmm0
mulsd  0x682(%rip),%xmm1
mov    0x28(%rsp),%rbp
mov    %rbp,%rdi
lea    0x7de(%rip),%rsi
mov    $0x2,%al
call   10a0 <fprintf@plt>
jmp    169e <main+0x4ae>
xor    %eax,%eax
add    $0xdb8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"-h\00"
@.str.1 = [3 x i8] c"rb\00"
@stderr = global i32* null
@.str.2 = [28 x i8] c"Could not read file %s: %s\0A\00"
@errno = global i32 0
@.str.3 = [5 x i8] c"%s: \00"
@.str.4 = [20 x i8] c"\\Valid data len X: \00"
@.str.5 = [20 x i8] c"\\Valid data len Y: \00"
@.str.6 = [18 x i8] c"\\@Sens. Zscan: V \00"
@.str.7 = [31 x i8] c"\\@1:Z limit: V [Sens. Zscan] (\00"
@.str.8 = [22 x i8] c"\\@2:Z scale: V [Sens.\00"
@.str.9 = [6 x i8] c"Zscan\00"
@.str.10 = [7 x i8] c"%d=%s \00"
@.str.11 = [5 x i8] c"topo\00"
@.str.12 = [6 x i8] c"other\00"
@.str.13 = [15 x i8] c"\\Data offset: \00"
@.str.14 = [15 x i8] c"\\Data length: \00"
@.str.15 = [18 x i8] c"\\*Ciao image list\00"
@.str.16 = [13 x i8] c"\\Scan size: \00"
@.str.17 = [17 x i8] c"\\*File list end \00"
@SEEK_SET = global i32 0
@.str.18 = [51 x i8] c"Warning image %d: m %d, pix %d lin %d pix*lin %d \0A\00"
@.str.19 = [10 x i8] c"%s.%d.pgm\00"
@.str.20 = [3 x i8] c"wb\00"
@.str.21 = [29 x i8] c"Could not write file %s: %s\0A\00"
@.str.22 = [10 x i8] c"P5\0A%d %d\0A\00"
@.str.23 = [29 x i8] c"#zmin %e\0A#zmax %e\0A#zunit nm\0A\00"
@.str.24 = [39 x i8] c"#zmin -10\0A#zmax 10\0A#zunit Voltage (V)\0A\00"
@.str.25 = [35 x i8] c"#xmin 0\0A#xmax %e\0A#ymin 0\0A#ymax %e\0A\00"
@.str.26 = [31 x i8] c"#xunit Mircons\0A#yunit Microns\0A\00"
@.str.27 = [7 x i8] c"65535\0A\00"
@.str.28 = [7 x i8] c"done.\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
%7 = alloca i32*
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca [100 x i32]
%12 = alloca [100 x i32]
%13 = alloca [100 x i32]
%14 = alloca i32
%15 = alloca [100 x double]
%16 = alloca double
%17 = alloca double
%18 = alloca double
%19 = alloca [100 x double]
%20 = alloca double
%21 = alloca [256 x i8]
%22 = alloca i8*
%23 = alloca i32
%24 = alloca i8*
%25 = alloca i32
%26 = alloca [256 x i8]
%27 = alloca [2 x i8]
%28 = alloca [2 x i8]
%29 = alloca i32
%30 = alloca i32
%31 = alloca i32
%32 = alloca i32
%33 = alloca i32
%34 = alloca i16*
%35 = alloca i16
%36 = alloca double
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %8
store i32 0, i32* %14
%37 = load i32, i32* %4
%38 = icmp slt i32 %37, 2
br i1 %38, label %39, label %41
39: ; preds = %2
%40 = call i32 (...) @usage()
br label %41
41: ; preds = %39, %2
%42 = load i8**, i8*** %5
%43 = getelementptr inbounds i8*, i8** %42, i64 1
%44 = load i8*, i8** %43
%45 = call i64 @strncmp(i8* %44, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 2)
%46 = icmp eq i64 %45, 0
br i1 %46, label %47, label %49
47: ; preds = %41
%48 = call i32 (...) @usage()
br label %49
49: ; preds = %47, %41
store i32 1, i32* %23
br label %50
50: ; preds = %413, %49
%51 = load i32, i32* %23
%52 = load i32, i32* %4
%53 = icmp slt i32 %51, %52
br i1 %53, label %54, label %416
54: ; preds = %50
%55 = load i8**, i8*** %5
%56 = load i32, i32* %23
%57 = sext i32 %56 to i64
%58 = getelementptr inbounds i8*, i8** %55, i64 %57
%59 = load i8*, i8** %58
store i8* %59, i8** %22
store i32 0, i32* %8
store i32 0, i32* %14
%60 = load i8*, i8** %22
%61 = call i32* @fopen(i8* %60, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
store i32* %61, i32** %6
%62 = load i32*, i32** %6
%63 = icmp eq i32* %62, null
br i1 %63, label %64, label %70
64: ; preds = %54
%65 = load i32*, i32** @stderr
%66 = load i8*, i8** %22
%67 = load i32, i32* @errno
%68 = call i8* @strerror(i32 %67)
%69 = call i32 (i32*, i8*, ...) @fprintf(i32* %65, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0), i8* %66, i8* %68)
br label %70
70: ; preds = %64, %54
%71 = load i32*, i32** @stderr
%72 = load i8*, i8** %22
%73 = call i32 (i32*, i8*, ...) @fprintf(i32* %71, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i8* %72)
br label %74
74: ; preds = %70, %81, %88, %95, %102, %133, %149, %176, %181, %188, %199
%75 = getelementptr inbounds [256 x i8], [256 x i8]* %21, i64 0, i64 0
%76 = load i32*, i32** %6
%77 = call i32 @fgets(i8* %75, i32 256, i32* %76)
%78 = getelementptr inbounds [256 x i8], [256 x i8]* %21, i64 0, i64 0
%79 = call i64 @strncmp(i8* %78, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.4, i64 0, i64 0), i32 18)
%80 = icmp eq i64 %79, 0
br i1 %80, label %81, label %84
81: ; preds = %74
%82 = getelementptr inbounds [256 x i8], [256 x i8]* %21, i64 0, i64 18
%83 = call i32 @atoi(i8* %82)
store i32 %83, i32* %9
br label %74
84: ; preds = %74
%85 = getelementptr inbounds [256 x i8], [256 x i8]* %21, i64 0, i64 0
%86 = call i64 @strncmp(i8* %85, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.5, i64 0, i64 0), i32 18)
%87 = icmp eq i64 %86, 0
br i1 %87, label %88, label %91
88: ; preds = %84
%89 = getelementptr inbounds [256 x i8], [256 x i8]* %21, i64 0, i64 18
%90 = call i32 @atoi(i8* %89)
store i32 %90, i32* %10
br label %74
91: ; preds = %84
%92 = getelementptr inbounds [256 x i8], [256 x i8]* %21, i64 0, i64 0
%93 = call i64 @strncmp(i8* %92, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.6, i64 0, i64 0), i32 16)
%94 = icmp eq i64 %93, 0
br i1 %94, label %95, label %98
95: ; preds = %91
%96 = getelementptr inbounds [256 x i8], [256 x i8]* %21, i64 0, i64 17
%97 = call double @atof(i8* %96)
store double %97, double* %16
br label %74
98: ; preds = %91
%99 = getelementptr inbounds [256 x i8], [256 x i8]* %21, i64 0, i64 0
%100 = call i64 @strncmp(i8* %99, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.7, i64 0, i64 0), i32 30)
%101 = icmp eq i64 %100, 0
br i1 %101, label %102, label %107
102: ; preds = %98
%103 = getelementptr inbounds [256 x i8], [256 x i8]* %21, i64 0, i64 30
%104 = call double @atof(i8* %103)
store double %104, double* %18
%105 = getelementptr inbounds [256 x i8], [256 x i8]* %21, i64 0, i64 49
%106 = call double @atof(i8* %105)
store double %106, double* %20
br label %74
107: ; preds = %98
%108 = getelementptr inbounds [256 x i8], [256 x i8]* %21, i64 0, i64 0
%109 = call i64 @strncmp(i8* %108, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.8, i64 0, i64 0), i32 10)
%110 = icmp eq i64 %109, 0
br i1 %110, label %111, label %145
111: ; preds = %107
%112 = getelementptr inbounds [256 x i8], [256 x i8]* %21, i64 0, i64 0
store i8* %112, i8** %24
%113 = load i8*, i8** %24
%114 = call i8* @strchr(i8* %113, i8 signext 41)
store i8* %114, i8** %24
%115 = load i8*, i8** %24
%116 = getelementptr inbounds i8, i8* %115, i64 2
store i8* %116, i8** %24
%117 = load i8*, i8** %24
%118 = call double @atof(i8* %117)
%119 = load i32, i32* %8
%120 = sext i32 %119 to i64
%121 = getelementptr inbounds [100 x double], [100 x double]* %19, i64 0, i64 %120
store double %118, double* %121
%122 = getelementptr inbounds [256 x i8], [256 x i8]* %21, i64 0, i64 22
%123 = call i64 @strncmp(i8* %122, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.9, i64 0, i64 0), i32 5)
%124 = icmp eq i64 %123, 0
br i1 %124, label %125, label %129
125: ; preds = %111
%126 = load i32, i32* %8
%127 = sext i32 %126 to i64
%128 = getelementptr inbounds [100 x i32], [100 x i32]* %13, i64 0, i64 %127
store i32 0, i32* %128
br label %133
129: ; preds = %111
%130 = load i32, i32* %8
%131 = sext i32 %130 to i64
%132 = getelementptr inbounds [100 x i32], [100 x i32]* %13, i64 0, i64 %131
store i32 1, i32* %132
br label %133
133: ; preds = %129, %125
%134 = load i32*, i32** @stderr
%135 = load i32, i32* %8
%136 = sub nsw i32 %135, 1
%137 = load i32, i32* %8
%138 = sext i32 %137 to i64
%139 = getelementptr inbounds [100 x i32], [100 x i32]* %13, i64 0, i64 %138
%140 = load i32, i32* %139
%141 = icmp eq i32 %140, 0
%142 = zext i1 %141 to i64
%143 = select i1 %141, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.11, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.12, i64 0, i64 0)
%144 = call i32 (i32*, i8*, ...) @fprintf(i32* %134, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.10, i64 0, i64 0), i32 %136, i8* %143)
br label %74
145: ; preds = %107
%146 = getelementptr inbounds [256 x i8], [256 x i8]* %21, i64 0, i64 0
%147 = call i64 @strncmp(i8* %146, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.13, i64 0, i64 0), i32 13)
%148 = icmp eq i64 %147, 0
br i1 %148, label %149, label %155
149: ; preds = %145
%150 = getelementptr inbounds [256 x i8], [256 x i8]* %21, i64 0, i64 13
%151 = call i32 @atoi(i8* %150)
%152 = load i32, i32* %8
%153 = sext i32 %152 to i64
%154 = getelementptr inbounds [100 x i32], [100 x i32]* %11, i64 0, i64 %153
store i32 %151, i32* %154
br label %74
155: ; preds = %145
%156 = getelementptr inbounds [256 x i8], [256 x i8]* %21, i64 0, i64 0
%157 = call i64 @strncmp(i8* %156, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.14, i64 0, i64 0), i32 13)
%158 = icmp eq i64 %157, 0
br i1 %158, label %159, label %177
159: ; preds = %155
%160 = getelementptr inbounds [256 x i8], [256 x i8]* %21, i64 0, i64 13
%161 = call i32 @atoi(i8* %160)
%162 = load i32, i32* %8
%163 = sext i32 %162 to i64
%164 = getelementptr inbounds [100 x i32], [100 x i32]* %12, i64 0, i64 %163
store i32 %161, i32* %164
%165 = load i32, i32* %8
%166 = sext i32 %165 to i64
%167 = getelementptr inbounds [100 x i32], [100 x i32]* %12, i64 0, i64 %166
%168 = load i32, i32* %167
%169 = load i32, i32* %14
%170 = icmp sgt i32 %168, %169
br i1 %170, label %171, label %176
171: ; preds = %159
%172 = load i32, i32* %8
%173 = sext i32 %172 to i64
%174 = getelementptr inbounds [100 x i32], [100 x i32]* %12, i64 0, i64 %173
%175 = load i32, i32* %174
store i32 %175, i32* %14
br label %176
176: ; preds = %171, %159
br label %74
177: ; preds = %155
%178 = getelementptr inbounds [256 x i8], [256 x i8]* %21, i64 0, i64 0
%179 = call i64 @strncmp(i8* %178, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.15, i64 0, i64 0), i32 16)
%180 = icmp eq i64 %179, 0
br i1 %180, label %181, label %184
181: ; preds = %177
%182 = load i32, i32* %8
%183 = add nsw i32 %182, 1
store i32 %183, i32* %8
br label %74
184: ; preds = %177
%185 = getelementptr inbounds [256 x i8], [256 x i8]* %21, i64 0, i64 0
%186 = call i64 @strncmp(i8* %185, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.16, i64 0, i64 0), i32 11)
%187 = icmp eq i64 %186, 0
br i1 %187, label %188, label %194
188: ; preds = %184
%189 = getelementptr inbounds [256 x i8], [256 x i8]* %21, i64 0, i64 11
%190 = call double @atof(i8* %189)
%191 = load i32, i32* %8
%192 = sext i32 %191 to i64
%193 = getelementptr inbounds [100 x double], [100 x double]* %15, i64 0, i64 %192
store double %190, double* %193
br label %74
194: ; preds = %184
%195 = getelementptr inbounds [256 x i8], [256 x i8]* %21, i64 0, i64 0
%196 = call i64 @strncmp(i8* %195, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.17, i64 0, i64 0), i32 15)
%197 = icmp eq i64 %196, 0
br i1 %197, label %198, label %199
198: ; preds = %194
br label %200
199: ; preds = %194
br label %74
200: ; preds = %198
%201 = load i32, i32* %14
%202 = call i16* @malloc(i32 %201)
store i16* %202, i16** %34
store i32 1, i32* %25
br label %203
203: ; preds = %405, %200
%204 = load i32, i32* %25
%205 = load i32, i32* %8
%206 = icmp sle i32 %204, %205
br i1 %206, label %207, label %408
207: ; preds = %203
%208 = load i32*, i32** %6
%209 = load i32, i32* %25
%210 = sext i32 %209 to i64
%211 = getelementptr inbounds [100 x i32], [100 x i32]* %11, i64 0, i64 %210
%212 = load i32, i32* %211
%213 = load i32, i32* @SEEK_SET
%214 = call i32 @fseek(i32* %208, i32 %212, i32 %213)
%215 = load i16*, i16** %34
%216 = load i32, i32* %8
%217 = sext i32 %216 to i64
%218 = getelementptr inbounds [100 x i32], [100 x i32]* %12, i64 0, i64 %217
%219 = load i32, i32* %218
%220 = load i32*, i32** %6
%221 = call i32 @fread(i16* %215, i32 1, i32 %219, i32* %220)
store i32 %221, i32* %29
%222 = load i32, i32* %29
%223 = load i32, i32* %10
%224 = load i32, i32* %9
%225 = mul nsw i32 %223, %224
%226 = mul nsw i32 %225, 2
%227 = icmp ne i32 %222, %226
br i1 %227, label %228, label %239
228: ; preds = %207
%229 = load i32*, i32** @stderr
%230 = load i32, i32* %25
%231 = load i32, i32* %29
%232 = load i32, i32* %9
%233 = load i32, i32* %10
%234 = load i32, i32* %10
%235 = load i32, i32* %9
%236 = mul nsw i32 %234, %235
%237 = mul nsw i32 %236, 2
%238 = call i32 (i32*, i8*, ...) @fprintf(i32* %229, i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.18, i64 0, i64 0), i32 %230, i32 %231, i32 %232, i32 %233, i32 %237)
br label %239
239: ; preds = %228, %207
store i32 0, i32* %30
br label %240
240: ; preds = %272, %239
%241 = load i32, i32* %30
%242 = load i32, i32* %10
%243 = load i32, i32* %9
%244 = mul nsw i32 %242, %243
%245 = icmp slt i32 %241, %244
br i1 %245, label %246, label %275
246: ; preds = %240
%247 = load i16*, i16** %34
%248 = load i32, i32* %30
%249 = sext i32 %248 to i64
%250 = getelementptr inbounds i16, i16* %247, i64 %249
%251 = load i16, i16* %250
%252 = zext i16 %251 to i32
%253 = sub nsw i32 %252, 32767
%254 = and i32 %253, 255
%255 = shl i32 %254, 8
%256 = load i16*, i16** %34
%257 = load i32, i32* %30
%258 = sext i32 %257 to i64
%259 = getelementptr inbounds i16, i16* %256, i64 %258
%260 = load i16, i16* %259
%261 = zext i16 %260 to i32
%262 = sub nsw i32 %261, 32767
%263 = trunc i32 %262 to i16
%264 = zext i16 %263 to i32
%265 = ashr i32 %264, 8
%266 = or i32 %255, %265
%267 = trunc i32 %266 to i16
%268 = load i16*, i16** %34
%269 = load i32, i32* %30
%270 = sext i32 %269 to i64
%271 = getelementptr inbounds i16, i16* %268, i64 %270
store i16 %267, i16* %271
br label %272
272: ; preds = %246
%273 = load i32, i32* %30
%274 = add nsw i32 %273, 1
store i32 %274, i32* %30
br label %240
275: ; preds = %240
store i32 0, i32* %30
br label %276
276: ; preds = %332, %275
%277 = load i32, i32* %30
%278 = load i32, i32* %9
%279 = icmp slt i32 %277, %278
br i1 %279, label %280, label %335
280: ; preds = %276
store i32 0, i32* %31
br label %281
281: ; preds = %328, %280
%282 = load i32, i32* %31
%283 = load i32, i32* %10
%284 = sdiv i32 %283, 2
%285 = icmp slt i32 %282, %284
br i1 %285, label %286, label %331
286: ; preds = %281
%287 = load i16*, i16** %34
%288 = load i32, i32* %10
%289 = load i32, i32* %31
%290 = sub nsw i32 %288, %289
%291 = sub nsw i32 %290, 1
%292 = load i32, i32* %9
%293 = mul nsw i32 %291, %292
%294 = load i32, i32* %30
%295 = add nsw i32 %293, %294
%296 = sext i32 %295 to i64
%297 = getelementptr inbounds i16, i16* %287, i64 %296
%298 = load i16, i16* %297
store i16 %298, i16* %35
%299 = load i16*, i16** %34
%300 = load i32, i32* %31
%301 = load i32, i32* %9
%302 = mul nsw i32 %300, %301
%303 = load i32, i32* %30
%304 = add nsw i32 %302, %303
%305 = sext i32 %304 to i64
%306 = getelementptr inbounds i16, i16* %299, i64 %305
%307 = load i16, i16* %306
%308 = load i16*, i16** %34
%309 = load i32, i32* %10
%310 = load i32, i32* %31
%311 = sub nsw i32 %309, %310
%312 = sub nsw i32 %311, 1
%313 = load i32, i32* %9
%314 = mul nsw i32 %312, %313
%315 = load i32, i32* %30
%316 = add nsw i32 %314, %315
%317 = sext i32 %316 to i64
%318 = getelementptr inbounds i16, i16* %308, i64 %317
store i16 %307, i16* %318
%319 = load i16, i16* %35
%320 = load i16*, i16** %34
%321 = load i32, i32* %31
%322 = load i32, i32* %9
%323 = mul nsw i32 %321, %322
%324 = load i32, i32* %30
%325 = add nsw i32 %323, %324
%326 = sext i32 %325 to i64
%327 = getelementptr inbounds i16, i16* %320, i64 %326
store i16 %319, i16* %327
br label %328
328: ; preds = %286
%329 = load i32, i32* %31
%330 = add nsw i32 %329, 1
store i32 %330, i32* %31
br label %281
331: ; preds = %281
br label %332
332: ; preds = %331
%333 = load i32, i32* %30
%334 = add nsw i32 %333, 1
store i32 %334, i32* %30
br label %276
335: ; preds = %276
%336 = getelementptr inbounds [256 x i8], [256 x i8]* %26, i64 0, i64 0
%337 = load i8*, i8** %22
%338 = load i32, i32* %25
%339 = sub nsw i32 %338, 1
%340 = call i32 @snprintf(i8* %336, i32 256, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.19, i64 0, i64 0), i8* %337, i32 %339)
%341 = getelementptr inbounds [256 x i8], [256 x i8]* %26, i64 0, i64 0
%342 = call i32* @fopen(i8* %341, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.20, i64 0, i64 0))
store i32* %342, i32** %7
%343 = icmp eq i32* %342, null
br i1 %343, label %344, label %351
344: ; preds = %335
%345 = load i32*, i32** @stderr
%346 = load i8*, i8** %22
%347 = load i32, i32* @errno
%348 = call i8* @strerror(i32 %347)
%349 = call i32 (i32*, i8*, ...) @fprintf(i32* %345, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.21, i64 0, i64 0), i8* %346, i8* %348)
%350 = call i32 (...) @usage()
br label %351
351: ; preds = %344, %335
%352 = load i32*, i32** %7
%353 = load i32, i32* %9
%354 = load i32, i32* %10
%355 = call i32 (i32*, i8*, ...) @fprintf(i32* %352, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.22, i64 0, i64 0), i32 %353, i32 %354)
%356 = load double, double* %16
%357 = load double, double* %18
%358 = fmul double %356, %357
%359 = load i32, i32* %25
%360 = sext i32 %359 to i64
%361 = getelementptr inbounds [100 x double], [100 x double]* %19, i64 0, i64 %360
%362 = load double, double* %361
%363 = fmul double %358, %362
%364 = load double, double* %20
%365 = fdiv double %363, %364
store double %365, double* %36
%366 = load i32, i32* %25
%367 = sext i32 %366 to i64
%368 = getelementptr inbounds [100 x i32], [100 x i32]* %13, i64 0, i64 %367
%369 = load i32, i32* %368
%370 = icmp eq i32 %369, 0
br i1 %370, label %371, label %378
371: ; preds = %351
%372 = load i32*, i32** %7
%373 = load double, double* %36
%374 = fmul double -3.276800e+04, %373
%375 = load double, double* %36
%376 = fmul double 3.276700e+04, %375
%377 = call i32 (i32*, i8*, ...) @fprintf(i32* %372, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.23, i64 0, i64 0), double %374, double %376)
br label %381
378: ; preds = %351
%379 = load i32*, i32** %7
%380 = call i32 (i32*, i8*, ...) @fprintf(i32* %379, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.24, i64 0, i64 0))
br label %381
381: ; preds = %378, %371
%382 = load i32*, i32** %7
%383 = load i32, i32* %25
%384 = sext i32 %383 to i64
%385 = getelementptr inbounds [100 x double], [100 x double]* %15, i64 0, i64 %384
%386 = load double, double* %385
%387 = load i32, i32* %25
%388 = sext i32 %387 to i64
%389 = getelementptr inbounds [100 x double], [100 x double]* %15, i64 0, i64 %388
%390 = load double, double* %389
%391 = call i32 (i32*, i8*, ...) @fprintf(i32* %382, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.25, i64 0, i64 0), double %386, double %390)
%392 = load i32*, i32** %7
%393 = call i32 (i32*, i8*, ...) @fprintf(i32* %392, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.26, i64 0, i64 0))
%394 = load i32*, i32** %7
%395 = call i32 (i32*, i8*, ...) @fprintf(i32* %394, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.27, i64 0, i64 0))
%396 = load i16*, i16** %34
%397 = load i32, i32* %8
%398 = sext i32 %397 to i64
%399 = getelementptr inbounds [100 x i32], [100 x i32]* %12, i64 0, i64 %398
%400 = load i32, i32* %399
%401 = load i32*, i32** %7
%402 = call i32 @fwrite(i16* %396, i32 %400, i32 1, i32* %401)
%403 = load i32*, i32** %7
%404 = call i32 @fclose(i32* %403)
br label %405
405: ; preds = %381
%406 = load i32, i32* %25
%407 = add nsw i32 %406, 1
store i32 %407, i32* %25
br label %203
408: ; preds = %203
%409 = load i32*, i32** @stderr
%410 = call i32 (i32*, i8*, ...) @fprintf(i32* %409, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.28, i64 0, i64 0))
%411 = load i32*, i32** %6
%412 = call i32 @fclose(i32* %411)
br label %413
413: ; preds = %408
%414 = load i32, i32* %23
%415 = add nsw i32 %414, 1
store i32 %415, i32* %23
br label %50
416: ; preds = %50
%417 = load i32, i32* %3
ret i32 %417
}

LLVM IR (-O2):
@.str = [3 x i8] c"-h\00"
@.str.1 = [3 x i8] c"rb\00"
@stderr = global i32* null
@.str.2 = [28 x i8] c"Could not read file %s: %s\0A\00"
@errno = global i32 0
@.str.3 = [5 x i8] c"%s: \00"
@.str.4 = [20 x i8] c"\\Valid data len X: \00"
@.str.5 = [20 x i8] c"\\Valid data len Y: \00"
@.str.6 = [18 x i8] c"\\@Sens. Zscan: V \00"
@.str.7 = [31 x i8] c"\\@1:Z limit: V [Sens. Zscan] (\00"
@.str.8 = [22 x i8] c"\\@2:Z scale: V [Sens.\00"
@.str.9 = [6 x i8] c"Zscan\00"
@.str.10 = [7 x i8] c"%d=%s \00"
@.str.11 = [5 x i8] c"topo\00"
@.str.12 = [6 x i8] c"other\00"
@.str.13 = [15 x i8] c"\\Data offset: \00"
@.str.14 = [15 x i8] c"\\Data length: \00"
@.str.15 = [18 x i8] c"\\*Ciao image list\00"
@.str.16 = [13 x i8] c"\\Scan size: \00"
@.str.17 = [17 x i8] c"\\*File list end \00"
@SEEK_SET = global i32 0
@.str.18 = [51 x i8] c"Warning image %d: m %d, pix %d lin %d pix*lin %d \0A\00"
@.str.19 = [10 x i8] c"%s.%d.pgm\00"
@.str.20 = [3 x i8] c"wb\00"
@.str.21 = [29 x i8] c"Could not write file %s: %s\0A\00"
@.str.22 = [10 x i8] c"P5\0A%d %d\0A\00"
@.str.23 = [29 x i8] c"#zmin %e\0A#zmax %e\0A#zunit nm\0A\00"
@.str.24 = [39 x i8] c"#zmin -10\0A#zmax 10\0A#zunit Voltage (V)\0A\00"
@.str.25 = [35 x i8] c"#xmin 0\0A#xmax %e\0A#ymin 0\0A#ymax %e\0A\00"
@.str.26 = [31 x i8] c"#xunit Mircons\0A#yunit Microns\0A\00"
@.str.27 = [7 x i8] c"65535\0A\00"
@.str.28 = [7 x i8] c"done.\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [100 x i32]
%4 = alloca [100 x i32]
%5 = alloca [100 x i32]
%6 = alloca [100 x double]
%7 = alloca [100 x double]
%8 = alloca [256 x i8]
%9 = alloca [256 x i8]
%10 = bitcast [100 x i32]* %3 to i8*
%11 = bitcast [100 x i32]* %4 to i8*
%12 = bitcast [100 x i32]* %5 to i8*
%13 = bitcast [100 x double]* %6 to i8*
%14 = bitcast [100 x double]* %7 to i8*
%15 = getelementptr inbounds [256 x i8], [256 x i8]* %8, i64 0, i64 0
%16 = icmp slt i32 %0, 2
br i1 %16, label %17, label %19
17: ; preds = %2
%18 = tail call i32 (...) @usage()
br label %19
19: ; preds = %17, %2
%20 = getelementptr inbounds i8*, i8** %1, i64 1
%21 = load i8*, i8** %20
%22 = tail call i64 @strncmp(i8* %21, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 2)
%23 = icmp eq i64 %22, 0
br i1 %23, label %24, label %26
24: ; preds = %19
%25 = tail call i32 (...) @usage()
br label %26
26: ; preds = %24, %19
%27 = icmp sgt i32 %0, 1
br i1 %27, label %28, label %272
28: ; preds = %26
%29 = getelementptr inbounds [256 x i8], [256 x i8]* %8, i64 0, i64 11
%30 = getelementptr inbounds [256 x i8], [256 x i8]* %8, i64 0, i64 13
%31 = getelementptr inbounds [256 x i8], [256 x i8]* %8, i64 0, i64 22
%32 = getelementptr inbounds [256 x i8], [256 x i8]* %8, i64 0, i64 30
%33 = getelementptr inbounds [256 x i8], [256 x i8]* %8, i64 0, i64 49
%34 = getelementptr inbounds [256 x i8], [256 x i8]* %8, i64 0, i64 17
%35 = getelementptr inbounds [256 x i8], [256 x i8]* %8, i64 0, i64 18
%36 = getelementptr inbounds [256 x i8], [256 x i8]* %9, i64 0, i64 0
%37 = zext i32 %0 to i64
br label %38
38: ; preds = %28, %266
%39 = phi i64 [ 1, %28 ], [ %270, %266 ]
%40 = phi i32 [ undef, %28 ], [ %63, %266 ]
%41 = phi i32 [ undef, %28 ], [ %62, %266 ]
%42 = phi double [ undef, %28 ], [ %60, %266 ]
%43 = phi double [ undef, %28 ], [ %59, %266 ]
%44 = phi double [ undef, %28 ], [ %58, %266 ]
%45 = getelementptr inbounds i8*, i8** %1, i64 %39
%46 = load i8*, i8** %45
%47 = call i32* @fopen(i8* %46, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%48 = icmp eq i32* %47, null
br i1 %48, label %49, label %54
49: ; preds = %38
%50 = load i32*, i32** @stderr
%51 = load i32, i32* @errno
%52 = call i8* @strerror(i32 %51)
%53 = call i32 (i32*, i8*, ...) @fprintf(i32* %50, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0), i8* %46, i8* %52)
br label %54
54: ; preds = %49, %38
%55 = load i32*, i32** @stderr
%56 = call i32 (i32*, i8*, ...) @fprintf(i32* %55, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i8* %46)
br label %57
57: ; preds = %70, %54
%58 = phi double [ %44, %54 ], [ %71, %70 ]
%59 = phi double [ %43, %54 ], [ %72, %70 ]
%60 = phi double [ %42, %54 ], [ %73, %70 ]
%61 = phi i32 [ 0, %54 ], [ %74, %70 ]
%62 = phi i32 [ %41, %54 ], [ %75, %70 ]
%63 = phi i32 [ %40, %54 ], [ %76, %70 ]
%64 = phi i32 [ 0, %54 ], [ %77, %70 ]
%65 = call i32 @fgets(i8* %15, i32 256, i32* %47)
%66 = call i64 @strncmp(i8* %15, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.4, i64 0, i64 0), i32 18)
%67 = icmp eq i64 %66, 0
br i1 %67, label %68, label %78
68: ; preds = %57
%69 = call i32 @atoi(i8* %35)
br label %70
70: ; preds = %68, %81, %86, %91, %97, %115, %122, %131, %136, %140
%71 = phi double [ %58, %68 ], [ %58, %81 ], [ %58, %86 ], [ %93, %91 ], [ %58, %97 ], [ %58, %115 ], [ %58, %122 ], [ %58, %131 ], [ %58, %136 ], [ %58, %140 ]
%72 = phi double [ %59, %68 ], [ %59, %81 ], [ %59, %86 ], [ %92, %91 ], [ %59, %97 ], [ %59, %115 ], [ %59, %122 ], [ %59, %131 ], [ %59, %136 ], [ %59, %140 ]
%73 = phi double [ %60, %68 ], [ %60, %81 ], [ %87, %86 ], [ %60, %91 ], [ %60, %97 ], [ %60, %115 ], [ %60, %122 ], [ %60, %131 ], [ %60, %136 ], [ %60, %140 ]
%74 = phi i32 [ %61, %68 ], [ %61, %81 ], [ %61, %86 ], [ %61, %91 ], [ %61, %97 ], [ %61, %115 ], [ %127, %122 ], [ %61, %131 ], [ %61, %136 ], [ %61, %140 ]
%75 = phi i32 [ %62, %68 ], [ %82, %81 ], [ %62, %86 ], [ %62, %91 ], [ %62, %97 ], [ %62, %115 ], [ %62, %122 ], [ %62, %131 ], [ %62, %136 ], [ %62, %140 ]
%76 = phi i32 [ %69, %68 ], [ %63, %81 ], [ %63, %86 ], [ %63, %91 ], [ %63, %97 ], [ %63, %115 ], [ %63, %122 ], [ %63, %131 ], [ %63, %136 ], [ %63, %140 ]
%77 = phi i32 [ %64, %68 ], [ %64, %81 ], [ %64, %86 ], [ %64, %91 ], [ %64, %97 ], [ %64, %115 ], [ %64, %122 ], [ %132, %131 ], [ %64, %136 ], [ %64, %140 ]
br label %57
78: ; preds = %57
%79 = call i64 @strncmp(i8* %15, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.5, i64 0, i64 0), i32 18)
%80 = icmp eq i64 %79, 0
br i1 %80, label %81, label %83
81: ; preds = %78
%82 = call i32 @atoi(i8* %35)
br label %70
83: ; preds = %78
%84 = call i64 @strncmp(i8* %15, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.6, i64 0, i64 0), i32 16)
%85 = icmp eq i64 %84, 0
br i1 %85, label %86, label %88
86: ; preds = %83
%87 = call double @atof(i8* %34)
br label %70
88: ; preds = %83
%89 = call i64 @strncmp(i8* %15, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.7, i64 0, i64 0), i32 30)
%90 = icmp eq i64 %89, 0
br i1 %90, label %91, label %94
91: ; preds = %88
%92 = call double @atof(i8* %32)
%93 = call double @atof(i8* %33)
br label %70
94: ; preds = %88
%95 = call i64 @strncmp(i8* %15, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.8, i64 0, i64 0), i32 10)
%96 = icmp eq i64 %95, 0
br i1 %96, label %97, label %112
97: ; preds = %94
%98 = call i8* @strchr(i8* %15, i8 signext 41)
%99 = getelementptr inbounds i8, i8* %98, i64 2
%100 = call double @atof(i8* %99)
%101 = sext i32 %64 to i64
%102 = getelementptr inbounds [100 x double], [100 x double]* %7, i64 0, i64 %101
store double %100, double* %102
%103 = call i64 @strncmp(i8* %31, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.9, i64 0, i64 0), i32 5)
%104 = icmp eq i64 %103, 0
%105 = select i1 %104, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.11, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.12, i64 0, i64 0)
%106 = xor i1 %104, true
%107 = zext i1 %106 to i32
%108 = getelementptr inbounds [100 x i32], [100 x i32]* %5, i64 0, i64 %101
store i32 %107, i32* %108
%109 = load i32*, i32** @stderr
%110 = add nsw i32 %64, -1
%111 = call i32 (i32*, i8*, ...) @fprintf(i32* %109, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.10, i64 0, i64 0), i32 %110, i8* %105)
br label %70
112: ; preds = %94
%113 = call i64 @strncmp(i8* %15, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.13, i64 0, i64 0), i32 13)
%114 = icmp eq i64 %113, 0
br i1 %114, label %115, label %119
115: ; preds = %112
%116 = call i32 @atoi(i8* %30)
%117 = sext i32 %64 to i64
%118 = getelementptr inbounds [100 x i32], [100 x i32]* %3, i64 0, i64 %117
store i32 %116, i32* %118
br label %70
119: ; preds = %112
%120 = call i64 @strncmp(i8* %15, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.14, i64 0, i64 0), i32 13)
%121 = icmp eq i64 %120, 0
br i1 %121, label %122, label %128
122: ; preds = %119
%123 = call i32 @atoi(i8* %30)
%124 = sext i32 %64 to i64
%125 = getelementptr inbounds [100 x i32], [100 x i32]* %4, i64 0, i64 %124
store i32 %123, i32* %125
%126 = icmp sgt i32 %123, %61
%127 = select i1 %126, i32 %123, i32 %61
br label %70
128: ; preds = %119
%129 = call i64 @strncmp(i8* %15, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.15, i64 0, i64 0), i32 16)
%130 = icmp eq i64 %129, 0
br i1 %130, label %131, label %133
131: ; preds = %128
%132 = add nsw i32 %64, 1
br label %70
133: ; preds = %128
%134 = call i64 @strncmp(i8* %15, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.16, i64 0, i64 0), i32 11)
%135 = icmp eq i64 %134, 0
br i1 %135, label %136, label %140
136: ; preds = %133
%137 = call double @atof(i8* %29)
%138 = sext i32 %64 to i64
%139 = getelementptr inbounds [100 x double], [100 x double]* %6, i64 0, i64 %138
store double %137, double* %139
br label %70
140: ; preds = %133
%141 = call i64 @strncmp(i8* %15, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.17, i64 0, i64 0), i32 15)
%142 = icmp eq i64 %141, 0
br i1 %142, label %143, label %70
143: ; preds = %140
%144 = call i16* @malloc(i32 %61)
%145 = icmp slt i32 %64, 1
br i1 %145, label %266, label %146
146: ; preds = %143
%147 = zext i32 %64 to i64
%148 = getelementptr inbounds [100 x i32], [100 x i32]* %4, i64 0, i64 %147
%149 = mul i32 %63, %62
%150 = shl nsw i32 %149, 1
%151 = icmp sgt i32 %149, 0
%152 = icmp sgt i32 %63, 0
%153 = sdiv i32 %62, 2
%154 = icmp sgt i32 %62, 1
%155 = fmul double %59, %60
%156 = sext i32 %63 to i64
%157 = add nuw i32 %64, 1
%158 = zext i32 %157 to i64
%159 = zext i32 %149 to i64
%160 = zext i32 %63 to i64
%161 = zext i32 %153 to i64
%162 = icmp ult i32 %149, 16
%163 = and i64 %159, 4294967280
%164 = icmp eq i64 %163, %159
br label %165
165: ; preds = %146, %256
%166 = phi i64 [ 1, %146 ], [ %264, %256 ]
%167 = getelementptr inbounds [100 x i32], [100 x i32]* %3, i64 0, i64 %166
%168 = load i32, i32* %167
%169 = load i32, i32* @SEEK_SET
%170 = call i32 @fseek(i32* %47, i32 %168, i32 %169)
%171 = load i32, i32* %148
%172 = call i32 @fread(i16* %144, i32 1, i32 %171, i32* %47)
%173 = icmp eq i32 %172, %150
br i1 %173, label %178, label %174
174: ; preds = %165
%175 = load i32*, i32** @stderr
%176 = trunc i64 %166 to i32
%177 = call i32 (i32*, i8*, ...) @fprintf(i32* %175, i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.18, i64 0, i64 0), i32 %176, i32 %172, i32 %63, i32 %62, i32 %150)
br label %178
178: ; preds = %174, %165
br i1 %151, label %179, label %199
179: ; preds = %178
br i1 %162, label %197, label %180
180: ; preds = %179, %180
%181 = phi i64 [ %194, %180 ], [ 0, %179 ]
%182 = getelementptr inbounds i16, i16* %144, i64 %181
%183 = bitcast i16* %182 to <8 x i16>*
%184 = load <8 x i16>, <8 x i16>* %183
%185 = getelementptr inbounds i16, i16* %182, i64 8
%186 = bitcast i16* %185 to <8 x i16>*
%187 = load <8 x i16>, <8 x i16>* %186
%188 = add <8 x i16> %184, <i16 -32767, i16 -32767, i16 -32767, i16 -32767, i16 -32767, i16 -32767, i16 -32767, i16 -32767>
%189 = add <8 x i16> %187, <i16 -32767, i16 -32767, i16 -32767, i16 -32767, i16 -32767, i16 -32767, i16 -32767, i16 -32767>
%190 = call <8 x i16> @llvm.bswap.v8i16(<8 x i16> %188)
%191 = call <8 x i16> @llvm.bswap.v8i16(<8 x i16> %189)
%192 = bitcast i16* %182 to <8 x i16>*
store <8 x i16> %190, <8 x i16>* %192
%193 = bitcast i16* %185 to <8 x i16>*
store <8 x i16> %191, <8 x i16>* %193
%194 = add nuw i64 %181, 16
%195 = icmp eq i64 %194, %163
br i1 %195, label %196, label %180
196: ; preds = %180
br i1 %164, label %199, label %197
197: ; preds = %179, %196
%198 = phi i64 [ 0, %179 ], [ %163, %196 ]
br label %200
199: ; preds = %200, %196, %178
br i1 %152, label %208, label %229
200: ; preds = %197, %200
%201 = phi i64 [ %206, %200 ], [ %198, %197 ]
%202 = getelementptr inbounds i16, i16* %144, i64 %201
%203 = load i16, i16* %202
%204 = add i16 %203, -32767
%205 = call i16 @llvm.bswap.i16(i16 %204)
store i16 %205, i16* %202
%206 = add nuw nsw i64 %201, 1
%207 = icmp eq i64 %206, %159
br i1 %207, label %199, label %200
208: ; preds = %199, %226
%209 = phi i64 [ %227, %226 ], [ 0, %199 ]
br i1 %154, label %210, label %226
210: ; preds = %208, %210
%211 = phi i64 [ %224, %210 ], [ 0, %208 ]
%212 = trunc i64 %211 to i32
%213 = xor i32 %212, -1
%214 = add i32 %62, %213
%215 = mul nsw i32 %214, %63
%216 = sext i32 %215 to i64
%217 = add nsw i64 %209, %216
%218 = getelementptr inbounds i16, i16* %144, i64 %217
%219 = load i16, i16* %218
%220 = mul nsw i64 %211, %156
%221 = add nsw i64 %220, %209
%222 = getelementptr inbounds i16, i16* %144, i64 %221
%223 = load i16, i16* %222
store i16 %223, i16* %218
store i16 %219, i16* %222
%224 = add nuw nsw i64 %211, 1
%225 = icmp eq i64 %224, %161
br i1 %225, label %226, label %210
226: ; preds = %210, %208
%227 = add nuw nsw i64 %209, 1
%228 = icmp eq i64 %227, %160
br i1 %228, label %229, label %208
229: ; preds = %226, %199
%230 = trunc i64 %166 to i32
%231 = add i32 %230, -1
%232 = call i32 @snprintf(i8* %36, i32 256, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.19, i64 0, i64 0), i8* %46, i32 %231)
%233 = call i32* @fopen(i8* %36, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.20, i64 0, i64 0))
%234 = icmp eq i32* %233, null
br i1 %234, label %235, label %241
235: ; preds = %229
%236 = load i32*, i32** @stderr
%237 = load i32, i32* @errno
%238 = call i8* @strerror(i32 %237)
%239 = call i32 (i32*, i8*, ...) @fprintf(i32* %236, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.21, i64 0, i64 0), i8* %46, i8* %238)
%240 = call i32 (...) @usage()
br label %241
241: ; preds = %235, %229
%242 = call i32 (i32*, i8*, ...) @fprintf(i32* %233, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.22, i64 0, i64 0), i32 %63, i32 %62)
%243 = getelementptr inbounds [100 x double], [100 x double]* %7, i64 0, i64 %166
%244 = load double, double* %243
%245 = fmul double %155, %244
%246 = fdiv double %245, %58
%247 = getelementptr inbounds [100 x i32], [100 x i32]* %5, i64 0, i64 %166
%248 = load i32, i32* %247
%249 = icmp eq i32 %248, 0
br i1 %249, label %250, label %254
250: ; preds = %241
%251 = fmul double %246, -3.276800e+04
%252 = fmul double %246, 3.276700e+04
%253 = call i32 (i32*, i8*, ...) @fprintf(i32* %233, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.23, i64 0, i64 0), double %251, double %252)
br label %256
254: ; preds = %241
%255 = call i64 bitcast (i32 (i16*, i32, i32, i32*)* @fwrite to i64 (i8*, i64, i64, i32*)*)(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.24, i64 0, i64 0), i64 38, i64 1, i32* %233)
br label %256
256: ; preds = %254, %250
%257 = getelementptr inbounds [100 x double], [100 x double]* %6, i64 0, i64 %166
%258 = load double, double* %257
%259 = call i32 (i32*, i8*, ...) @fprintf(i32* %233, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.25, i64 0, i64 0), double %258, double %258)
%260 = call i64 bitcast (i32 (i16*, i32, i32, i32*)* @fwrite to i64 (i8*, i64, i64, i32*)*)(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.26, i64 0, i64 0), i64 30, i64 1, i32* %233)
%261 = call i64 bitcast (i32 (i16*, i32, i32, i32*)* @fwrite to i64 (i8*, i64, i64, i32*)*)(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.27, i64 0, i64 0), i64 6, i64 1, i32* %233)
%262 = call i32 @fwrite(i16* %144, i32 %171, i32 1, i32* %233)
%263 = call i32 @fclose(i32* %233)
%264 = add nuw nsw i64 %166, 1
%265 = icmp eq i64 %264, %158
br i1 %265, label %266, label %165
266: ; preds = %256, %143
%267 = load i32*, i32** @stderr
%268 = call i64 bitcast (i32 (i16*, i32, i32, i32*)* @fwrite to i64 (i8*, i64, i64, i32*)*)(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.28, i64 0, i64 0), i64 6, i64 1, i32* %267)
%269 = call i32 @fclose(i32* %47)
%270 = add nuw nsw i64 %39, 1
%271 = icmp eq i64 %270, %37
br i1 %271, label %272, label %38
272: ; preds = %266, %26
ret i32 0
}