#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 */

/* Variables and functions */
void *atoi(char *);
int /*<<< orphan*/ exit(int);
scalar_t__ floorl(float);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ fwrite(unsigned short *, int, int, int /*<<< orphan*/);
scalar_t__ malloc(int);
int /*<<< orphan*/ read_raw_image_from_stdin(unsigned short *, int);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdout;
int main(int argc, char *argv[]) {
  int i;
  short unsigned int *base_image;
  short unsigned int *align_image;
  short unsigned int *IP, *IP2;
  short unsigned int yrows, xcols;
  int curr_y_offset, curr_x_offset;
  int curr_pixel;
  int FOCUS_N, CUTOFF, MIN_MAX, MAX_OFF, FRAME_N;
  int INDEX;
  int count, total_focus_pix, count3, curr_focus_pix, count5, count6, count7,
      max_total_offset;
  int FOCUS_PIXEL_X[20000];
  int FOCUS_PIXEL_Y[20000];
  int SCORE, BEST_X, BEST_Y, BEST_SCORE;
  int PRE_MULT[20000];
  int TOT_SIZE;
  unsigned short int ROW_SIZE, COL_SIZE;
  int n;
  if (argc < 7) {
    fprintf(stderr, "\n");
    fprintf(stderr, "To use this program, execute as follows:\n");
    fprintf(stderr,
            " cat base_raw_image align_raw_image | ./register-raw-translate "
            "xcols yrows focus_n threshold bead_color max_offset\n");
    fprintf(stderr, "  WHERE:\n");
    fprintf(stderr, "        xcols = number of columns (in pixels) in image; "
                    "1000 with our camera\n");
    fprintf(stderr, "        yrows = number of rows (in pixels) in image; 1000 "
                    "with our camera\n");
    fprintf(stderr, "        focus_n = number of sample pixels for use in "
                    "alignment algorithm\n");
    fprintf(stderr,
            "        threshold = brightfield threshold used for find_object\n");
    fprintf(stderr,
            "        bead_color = 1 or -1 (as specified for find_object\n");
    fprintf(stderr, "        max_offset = maximum offset (in pixels) to "
                    "translate image by to put it in register with the\n");
    fprintf(stderr, "                     base image; the larger this value, "
                    "the longer it will take; we use 40\n");
    fprintf(stderr, "\n");
    fprintf(stderr, "Output is the align_raw_image translated by the offsets, "
                    "with out-of-frame pixels\n");
    fprintf(stderr, "replaced with white (65535).\n");
    exit(0);
  }
  yrows = atoi(argv[1]);
  xcols = atoi(argv[2]);
  FOCUS_N = atoi(argv[3]);
  if (FOCUS_N > 20000) {
    fprintf(stderr,
            "Number of focus pixels is greater than maximum allowed (%i)\n",
            20000);
    exit(1);
  }
  CUTOFF = atoi(argv[4]);
  MIN_MAX = atoi(argv[5]);
  MAX_OFF = atoi(argv[6]);
  ROW_SIZE = yrows;
  COL_SIZE = xcols;
  TOT_SIZE = ROW_SIZE * COL_SIZE;
  if (MIN_MAX >= 0) {
    MIN_MAX = 1;
  } else {
    MIN_MAX = -1;
  }
  max_total_offset = (MAX_OFF * 2) - 1;
  if ((base_image = (short unsigned int *)malloc(
           TOT_SIZE * sizeof(short unsigned int))) == NULL) {
    fprintf(stderr, "Could not allocate enough memory for the image.\n");
    exit(42);
  }
  if ((align_image = (short unsigned int *)malloc(
           TOT_SIZE * sizeof(short unsigned int))) == NULL) {
    fprintf(stderr, "Could not allocate enough memory for the image.\n");
    exit(42);
  }
  read_raw_image_from_stdin(base_image, TOT_SIZE);
  read_raw_image_from_stdin(align_image, TOT_SIZE);
  total_focus_pix = 0;
  for (curr_pixel = 0; curr_pixel < TOT_SIZE; curr_pixel++) {
    if ((MIN_MAX * base_image[curr_pixel]) > (MIN_MAX * CUTOFF)) {
      total_focus_pix++;
    }
  }
  count3 = (int)floorl(((float)total_focus_pix) / ((float)FOCUS_N));
  if (count3 == 0) {
    fprintf(
        stderr,
        "count3 (floorl(total_focus_pix / FOCUS_N))==0; setting count3=1\n");
    count3 = 1;
  }
  total_focus_pix = 0;
  curr_focus_pix = 0;
  for (curr_pixel = 0; curr_pixel < TOT_SIZE; curr_pixel++) {
    if ((MIN_MAX * base_image[curr_pixel]) > (MIN_MAX * CUTOFF)) {
      total_focus_pix++;
      if ((total_focus_pix % count3) == 0 && curr_focus_pix < FOCUS_N) {
        FOCUS_PIXEL_X[curr_focus_pix] = ((int)curr_pixel % COL_SIZE) - MAX_OFF;
        FOCUS_PIXEL_Y[curr_focus_pix] =
            ((int)floorl(((float)curr_pixel) / ((float)COL_SIZE))) - MAX_OFF;
        curr_focus_pix++;
      }
    }
  }
  BEST_SCORE = 0;
  for (curr_y_offset = 0; curr_y_offset < max_total_offset; curr_y_offset++) {
    for (curr_x_offset = 0; curr_x_offset < max_total_offset; curr_x_offset++) {
      count5 = 0;
      count6 = 0;
      for (curr_focus_pix = 0; curr_focus_pix < FOCUS_N; curr_focus_pix++) {
        count7 = FOCUS_PIXEL_Y[curr_focus_pix] + curr_y_offset;
        if (count7 > 0) {
          INDEX = (COL_SIZE * count7) + FOCUS_PIXEL_X[curr_focus_pix] +
                  curr_x_offset;
          if (INDEX >= 0 && INDEX < TOT_SIZE) {
            count6 += align_image[INDEX];
            count5++;
          }
        }
      }
      SCORE = (int)count6 / count5;
      if (SCORE > BEST_SCORE) {
        BEST_Y = curr_y_offset - MAX_OFF;
        BEST_X = curr_x_offset - MAX_OFF;
        BEST_SCORE = SCORE;
      }
    }
  }
  fprintf(stderr, "%d\t%d\t%d\n", BEST_X, BEST_Y, BEST_SCORE);
  short unsigned int *output_image;
  short unsigned int output_pixel;
  int pix, x, y, x_result, y_result;
  if ((output_image = (short unsigned int *)malloc(
           TOT_SIZE * sizeof(short unsigned int))) == NULL) {
    fprintf(stderr, "Could not allocate enough memory for the image.\n");
    exit(42);
  }
  for (curr_pixel = 0; curr_pixel < TOT_SIZE; curr_pixel++) {
    x = curr_pixel % ROW_SIZE;
    y = curr_pixel / COL_SIZE;
    x_result = x + BEST_X;
    y_result = y + BEST_Y;
    if (x_result < 0 || y_result < 0 || x_result > ROW_SIZE ||
        y_result > COL_SIZE) {
      output_image[curr_pixel] = (short unsigned int)65535;
    } else {
      output_image[curr_pixel] = align_image[(y_result * ROW_SIZE) + x_result];
    }
  }
  fwrite(output_image, sizeof(short unsigned int) * TOT_SIZE, 1, stdout);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x3aa40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x7,-0x8(%rbp)
jge    12dc <main+0x16c>
mov    0x2e46(%rip),%rax
mov    (%rax),%edi
lea    0x11d2(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    0x2e2f(%rip),%rax
mov    (%rax),%edi
lea    0xe46(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    0x2e18(%rip),%rax
mov    (%rax),%edi
lea    0xe59(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    0x2e01(%rip),%rax
mov    (%rax),%edi
lea    0xeb6(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    0x2dea(%rip),%rax
mov    (%rax),%edi
lea    0xea9(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    0x2dd3(%rip),%rax
mov    (%rax),%edi
lea    0xee0(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    0x2dbc(%rip),%rax
mov    (%rax),%edi
lea    0xf14(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    0x2da5(%rip),%rax
mov    (%rax),%edi
lea    0xf47(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    0x2d8e(%rip),%rax
mov    (%rax),%edi
lea    0xf70(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    0x2d77(%rip),%rax
mov    (%rax),%edi
lea    0xf95(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    0x2d60(%rip),%rax
mov    (%rax),%edi
lea    0xfe4(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    0x2d49(%rip),%rax
mov    (%rax),%edi
lea    0x10d5(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    0x2d32(%rip),%rax
mov    (%rax),%edi
lea    0x1012(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    0x2d1b(%rip),%rax
mov    (%rax),%edi
lea    0x104e(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
xor    %edi,%edi
call   1070 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1060 <atoi@plt>
mov    %ax,-0x3a(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1060 <atoi@plt>
mov    %ax,-0x3c(%rbp)
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
call   1060 <atoi@plt>
mov    %eax,-0x4c(%rbp)
cmpl   $0x4e20,-0x4c(%rbp)
jle    1341 <main+0x1d1>
mov    0x2cbe(%rip),%rax
mov    (%rax),%edi
lea    0x100f(%rip),%rsi
mov    $0x4e20,%edx
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x20(%rax),%rdi
call   1060 <atoi@plt>
mov    %eax,-0x50(%rbp)
mov    -0x10(%rbp),%rax
mov    0x28(%rax),%rdi
call   1060 <atoi@plt>
mov    %eax,-0x54(%rbp)
mov    -0x10(%rbp),%rax
mov    0x30(%rax),%rdi
call   1060 <atoi@plt>
mov    %eax,-0x58(%rbp)
mov    -0x3a(%rbp),%ax
mov    %ax,-0x3aa16(%rbp)
mov    -0x3c(%rbp),%ax
mov    %ax,-0x3aa18(%rbp)
movzwl -0x3aa16(%rbp),%eax
movzwl -0x3aa18(%rbp),%ecx
imul   %ecx,%eax
mov    %eax,-0x3aa14(%rbp)
cmpl   $0x0,-0x54(%rbp)
jl     13b4 <main+0x244>
movl   $0x1,-0x54(%rbp)
jmp    13bb <main+0x24b>
movl   $0xffffffff,-0x54(%rbp)
mov    -0x58(%rbp),%eax
shl    $0x1,%eax
sub    $0x1,%eax
mov    %eax,-0x80(%rbp)
movslq -0x3aa14(%rbp),%rax
shl    $0x1,%rax
mov    %eax,%edi
call   1050 <malloc@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
jne    1408 <main+0x298>
mov    0x2bf2(%rip),%rax
mov    (%rax),%edi
lea    0xf80(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    $0x2a,%edi
call   1070 <exit@plt>
movslq -0x3aa14(%rbp),%rax
shl    $0x1,%rax
mov    %eax,%edi
call   1050 <malloc@plt>
mov    %rax,-0x28(%rbp)
cmp    $0x0,%rax
jne    1449 <main+0x2d9>
mov    0x2bb1(%rip),%rax
mov    (%rax),%edi
lea    0xf3f(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    $0x2a,%edi
call   1070 <exit@plt>
mov    -0x20(%rbp),%rdi
mov    -0x3aa14(%rbp),%esi
call   1030 <read_raw_image_from_stdin@plt>
mov    -0x28(%rbp),%rdi
mov    -0x3aa14(%rbp),%esi
call   1030 <read_raw_image_from_stdin@plt>
movl   $0x0,-0x68(%rbp)
movl   $0x0,-0x48(%rbp)
mov    -0x48(%rbp),%eax
cmp    -0x3aa14(%rbp),%eax
jge    14c1 <main+0x351>
mov    -0x54(%rbp),%eax
mov    -0x20(%rbp),%rcx
movslq -0x48(%rbp),%rdx
movzwl (%rcx,%rdx,2),%ecx
imul   %ecx,%eax
mov    -0x54(%rbp),%ecx
imul   -0x50(%rbp),%ecx
cmp    %ecx,%eax
jle    14ae <main+0x33e>
mov    -0x68(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x68(%rbp)
jmp    14b3 <main+0x343>
mov    -0x48(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x48(%rbp)
jmp    1475 <main+0x305>
cvtsi2ssl -0x68(%rbp),%xmm0
cvtsi2ssl -0x4c(%rbp),%xmm1
divss  %xmm1,%xmm0
call   1090 <floorl@plt>
mov    %eax,-0x6c(%rbp)
cmpl   $0x0,-0x6c(%rbp)
jne    14ff <main+0x38f>
mov    0x2af8(%rip),%rax
mov    (%rax),%edi
lea    0xeb7(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
movl   $0x1,-0x6c(%rbp)
movl   $0x0,-0x68(%rbp)
movl   $0x0,-0x70(%rbp)
movl   $0x0,-0x48(%rbp)
mov    -0x48(%rbp),%eax
cmp    -0x3aa14(%rbp),%eax
jge    15d0 <main+0x460>
mov    -0x54(%rbp),%eax
mov    -0x20(%rbp),%rcx
movslq -0x48(%rbp),%rdx
movzwl (%rcx,%rdx,2),%ecx
imul   %ecx,%eax
mov    -0x54(%rbp),%ecx
imul   -0x50(%rbp),%ecx
cmp    %ecx,%eax
jle    15bd <main+0x44d>
mov    -0x68(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x68(%rbp)
mov    -0x68(%rbp),%eax
cltd
idivl  -0x6c(%rbp)
cmp    $0x0,%edx
jne    15b8 <main+0x448>
mov    -0x70(%rbp),%eax
cmp    -0x4c(%rbp),%eax
jge    15b8 <main+0x448>
mov    -0x48(%rbp),%eax
movzwl -0x3aa18(%rbp),%ecx
cltd
idiv   %ecx
mov    -0x58(%rbp),%eax
sub    %eax,%edx
movslq -0x70(%rbp),%rax
mov    %edx,-0x13900(%rbp,%rax,4)
cvtsi2ssl -0x48(%rbp),%xmm0
movzwl -0x3aa18(%rbp),%eax
cvtsi2ss %eax,%xmm1
divss  %xmm1,%xmm0
call   1090 <floorl@plt>
mov    %eax,%ecx
sub    -0x58(%rbp),%ecx
movslq -0x70(%rbp),%rax
mov    %ecx,-0x27180(%rbp,%rax,4)
mov    -0x70(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x70(%rbp)
jmp    15bd <main+0x44d>
jmp    15c2 <main+0x452>
mov    -0x48(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x48(%rbp)
jmp    1514 <main+0x3a4>
movl   $0x0,-0x27190(%rbp)
movl   $0x0,-0x40(%rbp)
mov    -0x40(%rbp),%eax
cmp    -0x80(%rbp),%eax
jge    170d <main+0x59d>
movl   $0x0,-0x44(%rbp)
mov    -0x44(%rbp),%eax
cmp    -0x80(%rbp),%eax
jge    16fa <main+0x58a>
movl   $0x0,-0x74(%rbp)
movl   $0x0,-0x78(%rbp)
movl   $0x0,-0x70(%rbp)
mov    -0x70(%rbp),%eax
cmp    -0x4c(%rbp),%eax
jge    16a4 <main+0x534>
movslq -0x70(%rbp),%rax
mov    -0x27180(%rbp,%rax,4),%eax
add    -0x40(%rbp),%eax
mov    %eax,-0x7c(%rbp)
cmpl   $0x0,-0x7c(%rbp)
jle    1691 <main+0x521>
movzwl -0x3aa18(%rbp),%eax
imul   -0x7c(%rbp),%eax
movslq -0x70(%rbp),%rcx
add    -0x13900(%rbp,%rcx,4),%eax
add    -0x44(%rbp),%eax
mov    %eax,-0x60(%rbp)
cmpl   $0x0,-0x60(%rbp)
jl     168c <main+0x51c>
mov    -0x60(%rbp),%eax
cmp    -0x3aa14(%rbp),%eax
jge    168c <main+0x51c>
mov    -0x28(%rbp),%rax
movslq -0x60(%rbp),%rcx
movzwl (%rax,%rcx,2),%eax
add    -0x78(%rbp),%eax
mov    %eax,-0x78(%rbp)
mov    -0x74(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x74(%rbp)
jmp    1691 <main+0x521>
jmp    1696 <main+0x526>
mov    -0x70(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x70(%rbp)
jmp    1615 <main+0x4a5>
mov    -0x78(%rbp),%eax
cltd
idivl  -0x74(%rbp)
mov    %eax,-0x27184(%rbp)
mov    -0x27184(%rbp),%eax
cmp    -0x27190(%rbp),%eax
jle    16e7 <main+0x577>
mov    -0x40(%rbp),%eax
sub    -0x58(%rbp),%eax
mov    %eax,-0x2718c(%rbp)
mov    -0x44(%rbp),%eax
sub    -0x58(%rbp),%eax
mov    %eax,-0x27188(%rbp)
mov    -0x27184(%rbp),%eax
mov    %eax,-0x27190(%rbp)
jmp    16ec <main+0x57c>
mov    -0x44(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x44(%rbp)
jmp    15f4 <main+0x484>
jmp    16ff <main+0x58f>
mov    -0x40(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x40(%rbp)
jmp    15e1 <main+0x471>
mov    0x28cc(%rip),%rax
mov    (%rax),%edi
mov    -0x27188(%rbp),%edx
mov    -0x2718c(%rbp),%ecx
mov    -0x27190(%rbp),%r8d
lea    0xcb9(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
movslq -0x3aa14(%rbp),%rax
shl    $0x1,%rax
mov    %eax,%edi
call   1050 <malloc@plt>
mov    %rax,-0x3aa28(%rbp)
cmp    $0x0,%rax
jne    177b <main+0x60b>
mov    0x287f(%rip),%rax
mov    (%rax),%edi
lea    0xc0d(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    $0x2a,%edi
call   1070 <exit@plt>
movl   $0x0,-0x48(%rbp)
mov    -0x48(%rbp),%eax
cmp    -0x3aa14(%rbp),%eax
jge    1878 <main+0x708>
mov    -0x48(%rbp),%eax
movzwl -0x3aa16(%rbp),%ecx
cltd
idiv   %ecx
mov    %edx,-0x3aa34(%rbp)
mov    -0x48(%rbp),%eax
movzwl -0x3aa18(%rbp),%ecx
cltd
idiv   %ecx
mov    %eax,-0x3aa38(%rbp)
mov    -0x3aa34(%rbp),%eax
add    -0x27188(%rbp),%eax
mov    %eax,-0x3aa3c(%rbp)
mov    -0x3aa38(%rbp),%eax
add    -0x2718c(%rbp),%eax
mov    %eax,-0x3aa40(%rbp)
cmpl   $0x0,-0x3aa3c(%rbp)
jl     181f <main+0x6af>
cmpl   $0x0,-0x3aa40(%rbp)
jl     181f <main+0x6af>
mov    -0x3aa3c(%rbp),%eax
movzwl -0x3aa16(%rbp),%ecx
cmp    %ecx,%eax
jg     181f <main+0x6af>
mov    -0x3aa40(%rbp),%eax
movzwl -0x3aa18(%rbp),%ecx
cmp    %ecx,%eax
jle    1835 <main+0x6c5>
mov    -0x3aa28(%rbp),%rax
movslq -0x48(%rbp),%rcx
movw   $0xffff,(%rax,%rcx,2)
jmp    1865 <main+0x6f5>
mov    -0x28(%rbp),%rax
mov    -0x3aa40(%rbp),%ecx
movzwl -0x3aa16(%rbp),%edx
imul   %edx,%ecx
add    -0x3aa3c(%rbp),%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,2),%dx
mov    -0x3aa28(%rbp),%rax
movslq -0x48(%rbp),%rcx
mov    %dx,(%rax,%rcx,2)
jmp    186a <main+0x6fa>
mov    -0x48(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x48(%rbp)
jmp    1782 <main+0x612>
mov    -0x3aa28(%rbp),%rdi
movslq -0x3aa14(%rbp),%rax
shl    $0x1,%rax
mov    %eax,%esi
mov    0x2745(%rip),%rax
mov    (%rax),%ecx
mov    $0x1,%edx
call   1080 <fwrite@plt>
mov    -0x4(%rbp),%eax
add    $0x3aa40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x27168,%rsp
cmp    $0x6,%edi
jle    1712 <main+0x5a2>
mov    %rsi,%rbx
mov    0x10(%rsi),%rdi
call   1060 <atoi@plt>
mov    %rax,%r15
mov    0x18(%rbx),%rdi
call   1060 <atoi@plt>
mov    %rax,0x18(%rsp)
cmp    $0x4e21,%eax
jge    180d <main+0x69d>
mov    0x8(%rbx),%rdi
call   1060 <atoi@plt>
mov    %rax,%r14
mov    0x20(%rbx),%rdi
call   1060 <atoi@plt>
mov    %rax,%r13
mov    0x28(%rbx),%rdi
call   1060 <atoi@plt>
mov    %rax,%rbp
mov    0x30(%rbx),%rdi
call   1060 <atoi@plt>
mov    %rax,0x20(%rsp)
movzwl %r14w,%ecx
mov    %r15,0x38(%rsp)
movzwl %r15w,%r15d
mov    %ecx,0x48(%rsp)
mov    %ecx,%r14d
imul   %r15d,%r14d
and    $0x80000000,%ebp
neg    %rbp
sbb    %ebp,%ebp
lea    (%r14,%r14,1),%r12d
mov    %r12d,%edi
call   1050 <malloc@plt>
mov    %rax,0x10(%rsp)
test   %rax,%rax
je     1704 <main+0x594>
mov    %r12d,%edi
call   1050 <malloc@plt>
test   %rax,%rax
je     1704 <main+0x594>
mov    %rax,%rbx
or     $0x1,%ebp
mov    0x10(%rsp),%rdi
mov    %r14d,%esi
call   1030 <read_raw_image_from_stdin@plt>
mov    %rbx,0x30(%rsp)
mov    %rbx,%rdi
mov    %r14d,%esi
call   1030 <read_raw_image_from_stdin@plt>
mov    %r14d,%ebx
test   %r14d,%r14d
mov    %rbx,0x28(%rsp)
mov    %ebp,0xc(%rsp)
je     1281 <main+0x111>
mov    %ebp,%r8d
imul   %r13d,%r8d
cmp    $0x8,%r14d
mov    0x10(%rsp),%rax
jae    1289 <main+0x119>
xor    %ecx,%ecx
xor    %edx,%edx
jmp    1440 <main+0x2d0>
xorps  %xmm0,%xmm0
jmp    1462 <main+0x2f2>
mov    %ebx,%ecx
and    $0x7ffffff8,%ecx
movd   %ebp,%xmm0
pshufd $0x0,%xmm0,%xmm5
movd   %r8d,%xmm0
pshufd $0x0,%xmm0,%xmm0
lea    -0x8(%rcx),%rsi
mov    %rsi,%rdx
shr    $0x3,%rdx
add    $0x1,%rdx
pshufd $0xf5,%xmm5,%xmm3
test   %rsi,%rsi
je     16ec <main+0x57c>
mov    %rdx,%rdi
and    $0xfffffffffffffffe,%rdi
pxor   %xmm8,%xmm8
xor    %esi,%esi
pxor   %xmm1,%xmm1
pxor   %xmm4,%xmm4
nopw   0x0(%rax,%rax,1)
movq   (%rax,%rsi,2),%xmm6
movq   0x8(%rax,%rsi,2),%xmm7
punpcklwd %xmm8,%xmm6
punpcklwd %xmm8,%xmm7
movdqa %xmm5,%xmm2
pmuludq %xmm6,%xmm2
pshufd $0xe8,%xmm2,%xmm2
pshufd $0xf5,%xmm6,%xmm6
pmuludq %xmm3,%xmm6
pshufd $0xe8,%xmm6,%xmm6
punpckldq %xmm6,%xmm2
movdqa %xmm5,%xmm6
pmuludq %xmm7,%xmm6
pshufd $0xe8,%xmm6,%xmm6
pshufd $0xf5,%xmm7,%xmm7
pmuludq %xmm3,%xmm7
pshufd $0xe8,%xmm7,%xmm7
punpckldq %xmm7,%xmm6
pcmpgtd %xmm0,%xmm2
psubd  %xmm2,%xmm1
pcmpgtd %xmm0,%xmm6
psubd  %xmm6,%xmm4
movq   0x10(%rax,%rsi,2),%xmm2
movq   0x18(%rax,%rsi,2),%xmm6
punpcklwd %xmm8,%xmm2
punpcklwd %xmm8,%xmm6
movdqa %xmm5,%xmm7
pmuludq %xmm2,%xmm7
pshufd $0xe8,%xmm7,%xmm7
pshufd $0xf5,%xmm2,%xmm2
pmuludq %xmm3,%xmm2
pshufd $0xe8,%xmm2,%xmm2
punpckldq %xmm2,%xmm7
movdqa %xmm5,%xmm2
pmuludq %xmm6,%xmm2
pshufd $0xe8,%xmm2,%xmm2
pshufd $0xf5,%xmm6,%xmm6
pmuludq %xmm3,%xmm6
pshufd $0xe8,%xmm6,%xmm6
punpckldq %xmm6,%xmm2
pcmpgtd %xmm0,%xmm7
psubd  %xmm7,%xmm1
pcmpgtd %xmm0,%xmm2
psubd  %xmm2,%xmm4
add    $0x10,%rsi
add    $0xfffffffffffffffe,%rdi
jne    12e0 <main+0x170>
test   $0x1,%dl
je     141b <main+0x2ab>
movq   (%rax,%rsi,2),%xmm2
movq   0x8(%rax,%rsi,2),%xmm6
pxor   %xmm7,%xmm7
punpcklwd %xmm7,%xmm2
punpcklwd %xmm7,%xmm6
movdqa %xmm5,%xmm7
pmuludq %xmm2,%xmm7
pshufd $0xe8,%xmm7,%xmm7
pshufd $0xf5,%xmm2,%xmm2
pmuludq %xmm3,%xmm2
pshufd $0xe8,%xmm2,%xmm2
punpckldq %xmm2,%xmm7
pmuludq %xmm6,%xmm5
pshufd $0xe8,%xmm5,%xmm2
pshufd $0xf5,%xmm6,%xmm5
pmuludq %xmm3,%xmm5
pshufd $0xe8,%xmm5,%xmm3
punpckldq %xmm3,%xmm2
pcmpgtd %xmm0,%xmm7
psubd  %xmm7,%xmm1
pcmpgtd %xmm0,%xmm2
psubd  %xmm2,%xmm4
paddd  %xmm4,%xmm1
pshufd $0xee,%xmm1,%xmm0
paddd  %xmm1,%xmm0
pshufd $0x55,%xmm0,%xmm1
paddd  %xmm0,%xmm1
movd   %xmm1,%edx
cmp    %rbx,%rcx
je     145b <main+0x2eb>
nopw   0x0(%rax,%rax,1)
movzwl (%rax,%rcx,2),%esi
imul   %ebp,%esi
xor    %edi,%edi
cmp    %r8d,%esi
setg   %dil
add    %edi,%edx
add    $0x1,%rcx
cmp    %rcx,%rbx
jne    1440 <main+0x2d0>
xorps  %xmm0,%xmm0
cvtsi2ss %edx,%xmm0
mov    %r12d,0x8(%rsp)
xorps  %xmm1,%xmm1
cvtsi2ssl 0x18(%rsp),%xmm1
divss  %xmm1,%xmm0
call   1090 <floorl@plt>
mov    %rax,%r8
test   %r8d,%r8d
jne    149e <main+0x32e>
mov    0x2b58(%rip),%rax
mov    (%rax),%edi
lea    0xf17(%rip),%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    $0x1,%r8d
mov    0x20(%rsp),%rax
add    %eax,%eax
add    $0xffffffff,%eax
mov    %eax,0x44(%rsp)
test   %r14d,%r14d
mov    0x30(%rsp),%r11
mov    0x28(%rsp),%r9
mov    0xc(%rsp),%esi
mov    0x10(%rsp),%r10
je     158e <main+0x41e>
movzwl 0x38(%rsp),%eax
xorps  %xmm0,%xmm0
cvtsi2ss %eax,%xmm0
movss  %xmm0,0x4c(%rsp)
imul   %esi,%r13d
xor    %ebx,%ebx
xor    %r12d,%r12d
xor    %edi,%edi
mov    %r13,0x58(%rsp)
mov    %r8,0x50(%rsp)
jmp    150d <main+0x39d>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
add    $0x1,%rbx
cmp    %rbx,%r9
je     158e <main+0x41e>
movzwl (%r10,%rbx,2),%eax
imul   %esi,%eax
cmp    %r13d,%eax
jle    1500 <main+0x390>
add    $0x1,%r12d
mov    %r12d,%eax
cltd
idiv   %r8d
test   %edx,%edx
jne    1500 <main+0x390>
cmp    0x18(%rsp),%edi
jge    1500 <main+0x390>
mov    %ebx,%eax
xor    %edx,%edx
div    %r15d
mov    0x20(%rsp),%r13
sub    %r13d,%edx
movslq %edi,%rbp
mov    %edx,0x138e0(%rsp,%rbp,4)
xorps  %xmm0,%xmm0
cvtsi2ss %ebx,%xmm0
divss  0x4c(%rsp),%xmm0
mov    %edi,0x38(%rsp)
call   1090 <floorl@plt>
mov    0x38(%rsp),%edi
mov    0x50(%rsp),%r8
mov    0x10(%rsp),%r10
mov    0xc(%rsp),%esi
mov    0x28(%rsp),%r9
mov    0x30(%rsp),%r11
sub    %r13d,%eax
mov    0x58(%rsp),%r13
mov    %eax,0x60(%rsp,%rbp,4)
add    $0x1,%edi
jmp    1500 <main+0x390>
mov    0x44(%rsp),%eax
cmp    $0x2,%eax
mov    $0x1,%r9d
cmovge %eax,%r9d
mov    0x18(%rsp),%esi
xor    %edi,%edi
xor    %r8d,%r8d
jmp    15b8 <main+0x448>
nopw   0x0(%rax,%rax,1)
add    $0x1,%edi
cmp    %r9d,%edi
je     1633 <main+0x4c3>
mov    %edi,%r10d
sub    0x20(%rsp),%r10d
xor    %ecx,%ecx
jmp    15f0 <main+0x480>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
cltd
idiv   %ebx
mov    %ecx,%edx
sub    0x20(%rsp),%edx
cmp    %r8d,%eax
cmovg  %eax,%r8d
cmovg  %r10d,%r13d
cmovg  %edx,%r12d
add    $0x1,%ecx
cmp    %r9d,%ecx
je     15b0 <main+0x440>
cmpl   $0x0,0x18(%rsp)
jle    15d3 <main+0x463>
xor    %edx,%edx
xor    %ebx,%ebx
xor    %eax,%eax
jmp    1609 <main+0x499>
nop
add    $0x1,%rdx
cmp    %rdx,%rsi
je     15d0 <main+0x460>
mov    0x60(%rsp,%rdx,4),%ebp
add    %edi,%ebp
jle    1600 <main+0x490>
imul   %r15d,%ebp
add    %ecx,%ebp
add    0x138e0(%rsp,%rdx,4),%ebp
js     1600 <main+0x490>
cmp    %r14d,%ebp
jge    1600 <main+0x490>
mov    %ebp,%ebp
movzwl (%r11,%rbp,2),%ebp
add    %ebp,%eax
add    $0x1,%ebx
jmp    1600 <main+0x490>
mov    0x29a6(%rip),%rbx
mov    (%rbx),%edi
lea    0xda6(%rip),%rsi
mov    %r12d,%edx
mov    %r13d,%ecx
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    0x8(%rsp),%edi
call   1050 <malloc@plt>
test   %rax,%rax
je     1833 <main+0x6c3>
mov    %rax,%rdi
test   %r14d,%r14d
mov    0x48(%rsp),%ebp
mov    0x30(%rsp),%r8
mov    0x28(%rsp),%rbx
je     16c1 <main+0x551>
xor    %ecx,%ecx
jmp    168d <main+0x51d>
nopl   0x0(%rax)
mov    %dx,(%rdi,%rcx,2)
add    $0x1,%rcx
cmp    %rcx,%rbx
je     16c1 <main+0x551>
mov    %ecx,%eax
xor    %edx,%edx
div    %ebp
mov    %edx,%esi
mov    %ecx,%eax
xor    %edx,%edx
div    %r15d
add    %r12d,%esi
mov    $0xffff,%dx
js     1680 <main+0x510>
add    %r13d,%eax
js     1680 <main+0x510>
cmp    %ebp,%esi
jg     1680 <main+0x510>
cmp    %r15d,%eax
jg     1680 <main+0x510>
imul   %ebp,%eax
add    %esi,%eax
cltq
movzwl (%r8,%rax,2),%edx
jmp    1680 <main+0x510>
mov    0x2910(%rip),%rax
mov    (%rax),%ecx
mov    0x8(%rsp),%esi
mov    $0x1,%edx
call   1080 <fwrite@plt>
xor    %eax,%eax
add    $0x27168,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
pxor   %xmm1,%xmm1
xor    %esi,%esi
pxor   %xmm4,%xmm4
test   $0x1,%dl
jne    13ba <main+0x24a>
jmp    141b <main+0x2ab>
mov    0x28d5(%rip),%rax
mov    (%rax),%edi
jmp    1835 <main+0x6c5>
mov    0x28c7(%rip),%rbp
mov    0x0(%rbp),%edi
lea    0xc52(%rip),%rbx
mov    %rbx,%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    0x0(%rbp),%edi
lea    0x8c9(%rip),%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    0x0(%rbp),%edi
lea    0x8e2(%rip),%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    0x0(%rbp),%edi
lea    0x945(%rip),%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    0x0(%rbp),%edi
lea    0x93e(%rip),%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    0x0(%rbp),%edi
lea    0x97b(%rip),%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    0x0(%rbp),%edi
lea    0x9b5(%rip),%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    0x0(%rbp),%edi
lea    0x9ee(%rip),%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    0x0(%rbp),%edi
lea    0xa1d(%rip),%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    0x0(%rbp),%edi
lea    0xa48(%rip),%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    0x0(%rbp),%edi
lea    0xa9d(%rip),%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    0x0(%rbp),%edi
mov    %rbx,%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    0x0(%rbp),%edi
lea    0xadb(%rip),%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    0x0(%rbp),%edi
lea    0xb1d(%rip),%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
xor    %edi,%edi
call   1070 <exit@plt>
mov    0x27cc(%rip),%rax
mov    (%rax),%edi
lea    0xb1d(%rip),%rsi
mov    $0x4e20,%edx
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
mov    (%rbx),%edi
lea    0xb3b(%rip),%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    $0x2a,%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [2 x i8] c"\0A\00"
@.str.1 = [42 x i8] c"To use this program, execute as follows:\0A\00"
@.str.2 = [116 x i8] c" cat base_raw_image align_raw_image | ./register-raw-translate xcols yrows focus_n threshold bead_color max_offset\0A\00"
@.str.3 = [10 x i8] c" WHERE:\0A\00"
@.str.4 = [78 x i8] c" xcols = number of columns (in pixels) in image; 1000 with our camera\0A\00"
@.str.5 = [75 x i8] c" yrows = number of rows (in pixels) in image; 1000 with our camera\0A\00"
@.str.6 = [74 x i8] c" focus_n = number of sample pixels for use in alignment algorithm\0A\00"
@.str.7 = [64 x i8] c" threshold = brightfield threshold used for find_object\0A\00"
@.str.8 = [60 x i8] c" bead_color = 1 or -1 (as specified for find_object\0A\00"
@.str.9 = [102 x i8] c" max_offset = maximum offset (in pixels) to translate image by to put it in register with the\0A\00"
@.str.10 = [92 x i8] c" base image; the larger this value, the longer it will take; we use 40\0A\00"
@.str.11 = [83 x i8] c"Output is the align_raw_image translated by the offsets, with out-of-frame pixels\0A\00"
@.str.12 = [30 x i8] c"replaced with white (65535).\0A\00"
@.str.13 = [61 x i8] c"Number of focus pixels is greater than maximum allowed (%i)\0A\00"
@.str.14 = [49 x i8] c"Could not allocate enough memory for the image.\0A\00"
@.str.15 = [65 x i8] c"count3 (floorl(total_focus_pix / FOCUS_N))==0; setting count3=1\0A\00"
@.str.16 = [10 x i8] c"%d\09%d\09%d\0A\00"
@stdout = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i16*
%8 = alloca i16*
%9 = alloca i16*
%10 = alloca i16*
%11 = alloca i16
%12 = alloca i16
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
%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 i32
%28 = alloca i32
%29 = alloca i32
%30 = alloca [20000 x i32]
%31 = alloca [20000 x i32]
%32 = alloca i32
%33 = alloca i32
%34 = alloca i32
%35 = alloca i32
%36 = alloca [20000 x i32]
%37 = alloca i32
%38 = alloca i16
%39 = alloca i16
%40 = alloca i32
%41 = alloca i16*
%42 = alloca i16
%43 = alloca i32
%44 = alloca i32
%45 = alloca i32
%46 = alloca i32
%47 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%48 = load i32, i32* %4
%49 = icmp slt i32 %48, 7
br i1 %49, label %50, label %80
50: ; preds = %2
%51 = load i32, i32* @stderr
%52 = call i32 (i32, i8*, ...) @fprintf(i32 %51, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%53 = load i32, i32* @stderr
%54 = call i32 (i32, i8*, ...) @fprintf(i32 %53, i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.1, i64 0, i64 0))
%55 = load i32, i32* @stderr
%56 = call i32 (i32, i8*, ...) @fprintf(i32 %55, i8* getelementptr inbounds ([116 x i8], [116 x i8]* @.str.2, i64 0, i64 0))
%57 = load i32, i32* @stderr
%58 = call i32 (i32, i8*, ...) @fprintf(i32 %57, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0))
%59 = load i32, i32* @stderr
%60 = call i32 (i32, i8*, ...) @fprintf(i32 %59, i8* getelementptr inbounds ([78 x i8], [78 x i8]* @.str.4, i64 0, i64 0))
%61 = load i32, i32* @stderr
%62 = call i32 (i32, i8*, ...) @fprintf(i32 %61, i8* getelementptr inbounds ([75 x i8], [75 x i8]* @.str.5, i64 0, i64 0))
%63 = load i32, i32* @stderr
%64 = call i32 (i32, i8*, ...) @fprintf(i32 %63, i8* getelementptr inbounds ([74 x i8], [74 x i8]* @.str.6, i64 0, i64 0))
%65 = load i32, i32* @stderr
%66 = call i32 (i32, i8*, ...) @fprintf(i32 %65, i8* getelementptr inbounds ([64 x i8], [64 x i8]* @.str.7, i64 0, i64 0))
%67 = load i32, i32* @stderr
%68 = call i32 (i32, i8*, ...) @fprintf(i32 %67, i8* getelementptr inbounds ([60 x i8], [60 x i8]* @.str.8, i64 0, i64 0))
%69 = load i32, i32* @stderr
%70 = call i32 (i32, i8*, ...) @fprintf(i32 %69, i8* getelementptr inbounds ([102 x i8], [102 x i8]* @.str.9, i64 0, i64 0))
%71 = load i32, i32* @stderr
%72 = call i32 (i32, i8*, ...) @fprintf(i32 %71, i8* getelementptr inbounds ([92 x i8], [92 x i8]* @.str.10, i64 0, i64 0))
%73 = load i32, i32* @stderr
%74 = call i32 (i32, i8*, ...) @fprintf(i32 %73, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%75 = load i32, i32* @stderr
%76 = call i32 (i32, i8*, ...) @fprintf(i32 %75, i8* getelementptr inbounds ([83 x i8], [83 x i8]* @.str.11, i64 0, i64 0))
%77 = load i32, i32* @stderr
%78 = call i32 (i32, i8*, ...) @fprintf(i32 %77, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.12, i64 0, i64 0))
%79 = call i32 @exit(i32 0)
unreachable
80: ; preds = %2
%81 = load i8**, i8*** %5
%82 = getelementptr inbounds i8*, i8** %81, i64 1
%83 = load i8*, i8** %82
%84 = call i8* @atoi(i8* %83)
%85 = ptrtoint i8* %84 to i16
store i16 %85, i16* %11
%86 = load i8**, i8*** %5
%87 = getelementptr inbounds i8*, i8** %86, i64 2
%88 = load i8*, i8** %87
%89 = call i8* @atoi(i8* %88)
%90 = ptrtoint i8* %89 to i16
store i16 %90, i16* %12
%91 = load i8**, i8*** %5
%92 = getelementptr inbounds i8*, i8** %91, i64 3
%93 = load i8*, i8** %92
%94 = call i8* @atoi(i8* %93)
%95 = ptrtoint i8* %94 to i32
store i32 %95, i32* %16
%96 = load i32, i32* %16
%97 = icmp sgt i32 %96, 20000
br i1 %97, label %98, label %102
98: ; preds = %80
%99 = load i32, i32* @stderr
%100 = call i32 (i32, i8*, ...) @fprintf(i32 %99, i8* getelementptr inbounds ([61 x i8], [61 x i8]* @.str.13, i64 0, i64 0), i32 20000)
%101 = call i32 @exit(i32 1)
unreachable
102: ; preds = %80
%103 = load i8**, i8*** %5
%104 = getelementptr inbounds i8*, i8** %103, i64 4
%105 = load i8*, i8** %104
%106 = call i8* @atoi(i8* %105)
%107 = ptrtoint i8* %106 to i32
store i32 %107, i32* %17
%108 = load i8**, i8*** %5
%109 = getelementptr inbounds i8*, i8** %108, i64 5
%110 = load i8*, i8** %109
%111 = call i8* @atoi(i8* %110)
%112 = ptrtoint i8* %111 to i32
store i32 %112, i32* %18
%113 = load i8**, i8*** %5
%114 = getelementptr inbounds i8*, i8** %113, i64 6
%115 = load i8*, i8** %114
%116 = call i8* @atoi(i8* %115)
%117 = ptrtoint i8* %116 to i32
store i32 %117, i32* %19
%118 = load i16, i16* %11
store i16 %118, i16* %38
%119 = load i16, i16* %12
store i16 %119, i16* %39
%120 = load i16, i16* %38
%121 = zext i16 %120 to i32
%122 = load i16, i16* %39
%123 = zext i16 %122 to i32
%124 = mul nsw i32 %121, %123
store i32 %124, i32* %37
%125 = load i32, i32* %18
%126 = icmp sge i32 %125, 0
br i1 %126, label %127, label %128
127: ; preds = %102
store i32 1, i32* %18
br label %129
128: ; preds = %102
store i32 -1, i32* %18
br label %129
129: ; preds = %128, %127
%130 = load i32, i32* %19
%131 = mul nsw i32 %130, 2
%132 = sub nsw i32 %131, 1
store i32 %132, i32* %29
%133 = load i32, i32* %37
%134 = sext i32 %133 to i64
%135 = mul i64 %134, 2
%136 = trunc i64 %135 to i32
%137 = call i64 @malloc(i32 %136)
%138 = inttoptr i64 %137 to i16*
store i16* %138, i16** %7
%139 = icmp eq i16* %138, null
br i1 %139, label %140, label %144
140: ; preds = %129
%141 = load i32, i32* @stderr
%142 = call i32 (i32, i8*, ...) @fprintf(i32 %141, i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.14, i64 0, i64 0))
%143 = call i32 @exit(i32 42)
unreachable
144: ; preds = %129
%145 = load i32, i32* %37
%146 = sext i32 %145 to i64
%147 = mul i64 %146, 2
%148 = trunc i64 %147 to i32
%149 = call i64 @malloc(i32 %148)
%150 = inttoptr i64 %149 to i16*
store i16* %150, i16** %8
%151 = icmp eq i16* %150, null
br i1 %151, label %152, label %156
152: ; preds = %144
%153 = load i32, i32* @stderr
%154 = call i32 (i32, i8*, ...) @fprintf(i32 %153, i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.14, i64 0, i64 0))
%155 = call i32 @exit(i32 42)
unreachable
156: ; preds = %144
%157 = load i16*, i16** %7
%158 = load i32, i32* %37
%159 = call i32 @read_raw_image_from_stdin(i16* %157, i32 %158)
%160 = load i16*, i16** %8
%161 = load i32, i32* %37
%162 = call i32 @read_raw_image_from_stdin(i16* %160, i32 %161)
store i32 0, i32* %23
store i32 0, i32* %15
br label %163
163: ; preds = %184, %156
%164 = load i32, i32* %15
%165 = load i32, i32* %37
%166 = icmp slt i32 %164, %165
br i1 %166, label %167, label %187
167: ; preds = %163
%168 = load i32, i32* %18
%169 = load i16*, i16** %7
%170 = load i32, i32* %15
%171 = sext i32 %170 to i64
%172 = getelementptr inbounds i16, i16* %169, i64 %171
%173 = load i16, i16* %172
%174 = zext i16 %173 to i32
%175 = mul nsw i32 %168, %174
%176 = load i32, i32* %18
%177 = load i32, i32* %17
%178 = mul nsw i32 %176, %177
%179 = icmp sgt i32 %175, %178
br i1 %179, label %180, label %183
180: ; preds = %167
%181 = load i32, i32* %23
%182 = add nsw i32 %181, 1
store i32 %182, i32* %23
br label %183
183: ; preds = %180, %167
br label %184
184: ; preds = %183
%185 = load i32, i32* %15
%186 = add nsw i32 %185, 1
store i32 %186, i32* %15
br label %163
187: ; preds = %163
%188 = load i32, i32* %23
%189 = sitofp i32 %188 to float
%190 = load i32, i32* %16
%191 = sitofp i32 %190 to float
%192 = fdiv float %189, %191
%193 = call i64 @floorl(float %192)
%194 = trunc i64 %193 to i32
store i32 %194, i32* %24
%195 = load i32, i32* %24
%196 = icmp eq i32 %195, 0
br i1 %196, label %197, label %200
197: ; preds = %187
%198 = load i32, i32* @stderr
%199 = call i32 (i32, i8*, ...) @fprintf(i32 %198, i8* getelementptr inbounds ([65 x i8], [65 x i8]* @.str.15, i64 0, i64 0))
store i32 1, i32* %24
br label %200
200: ; preds = %197, %187
store i32 0, i32* %23
store i32 0, i32* %25
store i32 0, i32* %15
br label %201
201: ; preds = %255, %200
%202 = load i32, i32* %15
%203 = load i32, i32* %37
%204 = icmp slt i32 %202, %203
br i1 %204, label %205, label %258
205: ; preds = %201
%206 = load i32, i32* %18
%207 = load i16*, i16** %7
%208 = load i32, i32* %15
%209 = sext i32 %208 to i64
%210 = getelementptr inbounds i16, i16* %207, i64 %209
%211 = load i16, i16* %210
%212 = zext i16 %211 to i32
%213 = mul nsw i32 %206, %212
%214 = load i32, i32* %18
%215 = load i32, i32* %17
%216 = mul nsw i32 %214, %215
%217 = icmp sgt i32 %213, %216
br i1 %217, label %218, label %254
218: ; preds = %205
%219 = load i32, i32* %23
%220 = add nsw i32 %219, 1
store i32 %220, i32* %23
%221 = load i32, i32* %23
%222 = load i32, i32* %24
%223 = srem i32 %221, %222
%224 = icmp eq i32 %223, 0
br i1 %224, label %225, label %253
225: ; preds = %218
%226 = load i32, i32* %25
%227 = load i32, i32* %16
%228 = icmp slt i32 %226, %227
br i1 %228, label %229, label %253
229: ; preds = %225
%230 = load i32, i32* %15
%231 = load i16, i16* %39
%232 = zext i16 %231 to i32
%233 = srem i32 %230, %232
%234 = load i32, i32* %19
%235 = sub nsw i32 %233, %234
%236 = load i32, i32* %25
%237 = sext i32 %236 to i64
%238 = getelementptr inbounds [20000 x i32], [20000 x i32]* %30, i64 0, i64 %237
store i32 %235, i32* %238
%239 = load i32, i32* %15
%240 = sitofp i32 %239 to float
%241 = load i16, i16* %39
%242 = uitofp i16 %241 to float
%243 = fdiv float %240, %242
%244 = call i64 @floorl(float %243)
%245 = trunc i64 %244 to i32
%246 = load i32, i32* %19
%247 = sub nsw i32 %245, %246
%248 = load i32, i32* %25
%249 = sext i32 %248 to i64
%250 = getelementptr inbounds [20000 x i32], [20000 x i32]* %31, i64 0, i64 %249
store i32 %247, i32* %250
%251 = load i32, i32* %25
%252 = add nsw i32 %251, 1
store i32 %252, i32* %25
br label %253
253: ; preds = %229, %225, %218
br label %254
254: ; preds = %253, %205
br label %255
255: ; preds = %254
%256 = load i32, i32* %15
%257 = add nsw i32 %256, 1
store i32 %257, i32* %15
br label %201
258: ; preds = %201
store i32 0, i32* %35
store i32 0, i32* %13
br label %259
259: ; preds = %336, %258
%260 = load i32, i32* %13
%261 = load i32, i32* %29
%262 = icmp slt i32 %260, %261
br i1 %262, label %263, label %339
263: ; preds = %259
store i32 0, i32* %14
br label %264
264: ; preds = %332, %263
%265 = load i32, i32* %14
%266 = load i32, i32* %29
%267 = icmp slt i32 %265, %266
br i1 %267, label %268, label %335
268: ; preds = %264
store i32 0, i32* %26
store i32 0, i32* %27
store i32 0, i32* %25
br label %269
269: ; preds = %313, %268
%270 = load i32, i32* %25
%271 = load i32, i32* %16
%272 = icmp slt i32 %270, %271
br i1 %272, label %273, label %316
273: ; preds = %269
%274 = load i32, i32* %25
%275 = sext i32 %274 to i64
%276 = getelementptr inbounds [20000 x i32], [20000 x i32]* %31, i64 0, i64 %275
%277 = load i32, i32* %276
%278 = load i32, i32* %13
%279 = add nsw i32 %277, %278
store i32 %279, i32* %28
%280 = load i32, i32* %28
%281 = icmp sgt i32 %280, 0
br i1 %281, label %282, label %312
282: ; preds = %273
%283 = load i16, i16* %39
%284 = zext i16 %283 to i32
%285 = load i32, i32* %28
%286 = mul nsw i32 %284, %285
%287 = load i32, i32* %25
%288 = sext i32 %287 to i64
%289 = getelementptr inbounds [20000 x i32], [20000 x i32]* %30, i64 0, i64 %288
%290 = load i32, i32* %289
%291 = add nsw i32 %286, %290
%292 = load i32, i32* %14
%293 = add nsw i32 %291, %292
store i32 %293, i32* %21
%294 = load i32, i32* %21
%295 = icmp sge i32 %294, 0
br i1 %295, label %296, label %311
296: ; preds = %282
%297 = load i32, i32* %21
%298 = load i32, i32* %37
%299 = icmp slt i32 %297, %298
br i1 %299, label %300, label %311
300: ; preds = %296
%301 = load i16*, i16** %8
%302 = load i32, i32* %21
%303 = sext i32 %302 to i64
%304 = getelementptr inbounds i16, i16* %301, i64 %303
%305 = load i16, i16* %304
%306 = zext i16 %305 to i32
%307 = load i32, i32* %27
%308 = add nsw i32 %307, %306
store i32 %308, i32* %27
%309 = load i32, i32* %26
%310 = add nsw i32 %309, 1
store i32 %310, i32* %26
br label %311
311: ; preds = %300, %296, %282
br label %312
312: ; preds = %311, %273
br label %313
313: ; preds = %312
%314 = load i32, i32* %25
%315 = add nsw i32 %314, 1
store i32 %315, i32* %25
br label %269
316: ; preds = %269
%317 = load i32, i32* %27
%318 = load i32, i32* %26
%319 = sdiv i32 %317, %318
store i32 %319, i32* %32
%320 = load i32, i32* %32
%321 = load i32, i32* %35
%322 = icmp sgt i32 %320, %321
br i1 %322, label %323, label %331
323: ; preds = %316
%324 = load i32, i32* %13
%325 = load i32, i32* %19
%326 = sub nsw i32 %324, %325
store i32 %326, i32* %34
%327 = load i32, i32* %14
%328 = load i32, i32* %19
%329 = sub nsw i32 %327, %328
store i32 %329, i32* %33
%330 = load i32, i32* %32
store i32 %330, i32* %35
br label %331
331: ; preds = %323, %316
br label %332
332: ; preds = %331
%333 = load i32, i32* %14
%334 = add nsw i32 %333, 1
store i32 %334, i32* %14
br label %264
335: ; preds = %264
br label %336
336: ; preds = %335
%337 = load i32, i32* %13
%338 = add nsw i32 %337, 1
store i32 %338, i32* %13
br label %259
339: ; preds = %259
%340 = load i32, i32* @stderr
%341 = load i32, i32* %33
%342 = load i32, i32* %34
%343 = load i32, i32* %35
%344 = call i32 (i32, i8*, ...) @fprintf(i32 %340, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.16, i64 0, i64 0), i32 %341, i32 %342, i32 %343)
%345 = load i32, i32* %37
%346 = sext i32 %345 to i64
%347 = mul i64 %346, 2
%348 = trunc i64 %347 to i32
%349 = call i64 @malloc(i32 %348)
%350 = inttoptr i64 %349 to i16*
store i16* %350, i16** %41
%351 = icmp eq i16* %350, null
br i1 %351, label %352, label %356
352: ; preds = %339
%353 = load i32, i32* @stderr
%354 = call i32 (i32, i8*, ...) @fprintf(i32 %353, i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.14, i64 0, i64 0))
%355 = call i32 @exit(i32 42)
unreachable
356: ; preds = %339
store i32 0, i32* %15
br label %357
357: ; preds = %412, %356
%358 = load i32, i32* %15
%359 = load i32, i32* %37
%360 = icmp slt i32 %358, %359
br i1 %360, label %361, label %415
361: ; preds = %357
%362 = load i32, i32* %15
%363 = load i16, i16* %38
%364 = zext i16 %363 to i32
%365 = srem i32 %362, %364
store i32 %365, i32* %44
%366 = load i32, i32* %15
%367 = load i16, i16* %39
%368 = zext i16 %367 to i32
%369 = sdiv i32 %366, %368
store i32 %369, i32* %45
%370 = load i32, i32* %44
%371 = load i32, i32* %33
%372 = add nsw i32 %370, %371
store i32 %372, i32* %46
%373 = load i32, i32* %45
%374 = load i32, i32* %34
%375 = add nsw i32 %373, %374
store i32 %375, i32* %47
%376 = load i32, i32* %46
%377 = icmp slt i32 %376, 0
br i1 %377, label %391, label %378
378: ; preds = %361
%379 = load i32, i32* %47
%380 = icmp slt i32 %379, 0
br i1 %380, label %391, label %381
381: ; preds = %378
%382 = load i32, i32* %46
%383 = load i16, i16* %38
%384 = zext i16 %383 to i32
%385 = icmp sgt i32 %382, %384
br i1 %385, label %391, label %386
386: ; preds = %381
%387 = load i32, i32* %47
%388 = load i16, i16* %39
%389 = zext i16 %388 to i32
%390 = icmp sgt i32 %387, %389
br i1 %390, label %391, label %396
391: ; preds = %386, %381, %378, %361
%392 = load i16*, i16** %41
%393 = load i32, i32* %15
%394 = sext i32 %393 to i64
%395 = getelementptr inbounds i16, i16* %392, i64 %394
store i16 -1, i16* %395
br label %411
396: ; preds = %386
%397 = load i16*, i16** %8
%398 = load i32, i32* %47
%399 = load i16, i16* %38
%400 = zext i16 %399 to i32
%401 = mul nsw i32 %398, %400
%402 = load i32, i32* %46
%403 = add nsw i32 %401, %402
%404 = sext i32 %403 to i64
%405 = getelementptr inbounds i16, i16* %397, i64 %404
%406 = load i16, i16* %405
%407 = load i16*, i16** %41
%408 = load i32, i32* %15
%409 = sext i32 %408 to i64
%410 = getelementptr inbounds i16, i16* %407, i64 %409
store i16 %406, i16* %410
br label %411
411: ; preds = %396, %391
br label %412
412: ; preds = %411
%413 = load i32, i32* %15
%414 = add nsw i32 %413, 1
store i32 %414, i32* %15
br label %357
415: ; preds = %357
%416 = load i16*, i16** %41
%417 = load i32, i32* %37
%418 = sext i32 %417 to i64
%419 = mul i64 2, %418
%420 = trunc i64 %419 to i32
%421 = load i32, i32* @stdout
%422 = call i32 @fwrite(i16* %416, i32 %420, i32 1, i32 %421)
%423 = load i32, i32* %3
ret i32 %423
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [2 x i8] c"\0A\00"
@.str.1 = [42 x i8] c"To use this program, execute as follows:\0A\00"
@.str.2 = [116 x i8] c" cat base_raw_image align_raw_image | ./register-raw-translate xcols yrows focus_n threshold bead_color max_offset\0A\00"
@.str.3 = [10 x i8] c" WHERE:\0A\00"
@.str.4 = [78 x i8] c" xcols = number of columns (in pixels) in image; 1000 with our camera\0A\00"
@.str.5 = [75 x i8] c" yrows = number of rows (in pixels) in image; 1000 with our camera\0A\00"
@.str.6 = [74 x i8] c" focus_n = number of sample pixels for use in alignment algorithm\0A\00"
@.str.7 = [64 x i8] c" threshold = brightfield threshold used for find_object\0A\00"
@.str.8 = [60 x i8] c" bead_color = 1 or -1 (as specified for find_object\0A\00"
@.str.9 = [102 x i8] c" max_offset = maximum offset (in pixels) to translate image by to put it in register with the\0A\00"
@.str.10 = [92 x i8] c" base image; the larger this value, the longer it will take; we use 40\0A\00"
@.str.11 = [83 x i8] c"Output is the align_raw_image translated by the offsets, with out-of-frame pixels\0A\00"
@.str.12 = [30 x i8] c"replaced with white (65535).\0A\00"
@.str.13 = [61 x i8] c"Number of focus pixels is greater than maximum allowed (%i)\0A\00"
@.str.14 = [49 x i8] c"Could not allocate enough memory for the image.\0A\00"
@.str.15 = [65 x i8] c"count3 (floorl(total_focus_pix / FOCUS_N))==0; setting count3=1\0A\00"
@.str.16 = [10 x i8] c"%d\09%d\09%d\0A\00"
@stdout = global i32 0
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [20000 x i32]
%4 = alloca [20000 x i32]
%5 = bitcast [20000 x i32]* %3 to i8*
%6 = bitcast [20000 x i32]* %4 to i8*
%7 = icmp slt i32 %0, 7
br i1 %7, label %8, label %38
8: ; preds = %2
%9 = load i32, i32* @stderr
%10 = tail call i32 (i32, i8*, ...) @fprintf(i32 %9, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%11 = load i32, i32* @stderr
%12 = tail call i32 (i32, i8*, ...) @fprintf(i32 %11, i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.1, i64 0, i64 0))
%13 = load i32, i32* @stderr
%14 = tail call i32 (i32, i8*, ...) @fprintf(i32 %13, i8* getelementptr inbounds ([116 x i8], [116 x i8]* @.str.2, i64 0, i64 0))
%15 = load i32, i32* @stderr
%16 = tail call i32 (i32, i8*, ...) @fprintf(i32 %15, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0))
%17 = load i32, i32* @stderr
%18 = tail call i32 (i32, i8*, ...) @fprintf(i32 %17, i8* getelementptr inbounds ([78 x i8], [78 x i8]* @.str.4, i64 0, i64 0))
%19 = load i32, i32* @stderr
%20 = tail call i32 (i32, i8*, ...) @fprintf(i32 %19, i8* getelementptr inbounds ([75 x i8], [75 x i8]* @.str.5, i64 0, i64 0))
%21 = load i32, i32* @stderr
%22 = tail call i32 (i32, i8*, ...) @fprintf(i32 %21, i8* getelementptr inbounds ([74 x i8], [74 x i8]* @.str.6, i64 0, i64 0))
%23 = load i32, i32* @stderr
%24 = tail call i32 (i32, i8*, ...) @fprintf(i32 %23, i8* getelementptr inbounds ([64 x i8], [64 x i8]* @.str.7, i64 0, i64 0))
%25 = load i32, i32* @stderr
%26 = tail call i32 (i32, i8*, ...) @fprintf(i32 %25, i8* getelementptr inbounds ([60 x i8], [60 x i8]* @.str.8, i64 0, i64 0))
%27 = load i32, i32* @stderr
%28 = tail call i32 (i32, i8*, ...) @fprintf(i32 %27, i8* getelementptr inbounds ([102 x i8], [102 x i8]* @.str.9, i64 0, i64 0))
%29 = load i32, i32* @stderr
%30 = tail call i32 (i32, i8*, ...) @fprintf(i32 %29, i8* getelementptr inbounds ([92 x i8], [92 x i8]* @.str.10, i64 0, i64 0))
%31 = load i32, i32* @stderr
%32 = tail call i32 (i32, i8*, ...) @fprintf(i32 %31, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%33 = load i32, i32* @stderr
%34 = tail call i32 (i32, i8*, ...) @fprintf(i32 %33, i8* getelementptr inbounds ([83 x i8], [83 x i8]* @.str.11, i64 0, i64 0))
%35 = load i32, i32* @stderr
%36 = tail call i32 (i32, i8*, ...) @fprintf(i32 %35, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.12, i64 0, i64 0))
%37 = tail call i32 @exit(i32 0)
unreachable
38: ; preds = %2
%39 = getelementptr inbounds i8*, i8** %1, i64 2
%40 = load i8*, i8** %39
%41 = tail call i8* @atoi(i8* %40)
%42 = ptrtoint i8* %41 to i64
%43 = trunc i64 %42 to i16
%44 = getelementptr inbounds i8*, i8** %1, i64 3
%45 = load i8*, i8** %44
%46 = tail call i8* @atoi(i8* %45)
%47 = ptrtoint i8* %46 to i64
%48 = trunc i64 %47 to i32
%49 = icmp sgt i32 %48, 20000
br i1 %49, label %50, label %54
50: ; preds = %38
%51 = load i32, i32* @stderr
%52 = tail call i32 (i32, i8*, ...) @fprintf(i32 %51, i8* getelementptr inbounds ([61 x i8], [61 x i8]* @.str.13, i64 0, i64 0), i32 20000)
%53 = tail call i32 @exit(i32 1)
unreachable
54: ; preds = %38
%55 = getelementptr inbounds i8*, i8** %1, i64 1
%56 = load i8*, i8** %55
%57 = tail call i8* @atoi(i8* %56)
%58 = ptrtoint i8* %57 to i64
%59 = trunc i64 %58 to i32
%60 = getelementptr inbounds i8*, i8** %1, i64 4
%61 = load i8*, i8** %60
%62 = tail call i8* @atoi(i8* %61)
%63 = ptrtoint i8* %62 to i64
%64 = trunc i64 %63 to i32
%65 = getelementptr inbounds i8*, i8** %1, i64 5
%66 = load i8*, i8** %65
%67 = tail call i8* @atoi(i8* %66)
%68 = ptrtoint i8* %67 to i64
%69 = getelementptr inbounds i8*, i8** %1, i64 6
%70 = load i8*, i8** %69
%71 = tail call i8* @atoi(i8* %70)
%72 = ptrtoint i8* %71 to i64
%73 = trunc i64 %72 to i32
%74 = and i32 %59, 65535
%75 = trunc i64 %42 to i32
%76 = and i32 %75, 65535
%77 = mul nuw nsw i32 %74, %76
%78 = and i64 %68, 2147483648
%79 = icmp eq i64 %78, 0
%80 = select i1 %79, i32 1, i32 -1
%81 = shl nsw i32 %73, 1
%82 = add i32 %81, -1
%83 = shl nuw i32 %77, 1
%84 = tail call i64 @malloc(i32 %83)
%85 = inttoptr i64 %84 to i16*
%86 = icmp eq i64 %84, 0
br i1 %86, label %87, label %91
87: ; preds = %54
%88 = load i32, i32* @stderr
%89 = tail call i32 (i32, i8*, ...) @fprintf(i32 %88, i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.14, i64 0, i64 0))
%90 = tail call i32 @exit(i32 42)
unreachable
91: ; preds = %54
%92 = tail call i64 @malloc(i32 %83)
%93 = inttoptr i64 %92 to i16*
%94 = icmp eq i64 %92, 0
br i1 %94, label %95, label %99
95: ; preds = %91
%96 = load i32, i32* @stderr
%97 = tail call i32 (i32, i8*, ...) @fprintf(i32 %96, i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.14, i64 0, i64 0))
%98 = tail call i32 @exit(i32 42)
unreachable
99: ; preds = %91
%100 = tail call i32 @read_raw_image_from_stdin(i16* %85, i32 %77)
%101 = tail call i32 @read_raw_image_from_stdin(i16* %93, i32 %77)
%102 = icmp eq i32 %77, 0
br i1 %102, label %213, label %103
103: ; preds = %99
%104 = mul nsw i32 %80, %64
%105 = zext i32 %77 to i64
%106 = icmp ult i32 %77, 8
br i1 %106, label %195, label %107
107: ; preds = %103
%108 = and i64 %105, 2147483640
%109 = insertelement <4 x i32> poison, i32 %80, i64 0
%110 = shufflevector <4 x i32> %109, <4 x i32> poison, <4 x i32> zeroinitializer
%111 = insertelement <4 x i32> poison, i32 %80, i64 0
%112 = shufflevector <4 x i32> %111, <4 x i32> poison, <4 x i32> zeroinitializer
%113 = insertelement <4 x i32> poison, i32 %104, i64 0
%114 = shufflevector <4 x i32> %113, <4 x i32> poison, <4 x i32> zeroinitializer
%115 = insertelement <4 x i32> poison, i32 %104, i64 0
%116 = shufflevector <4 x i32> %115, <4 x i32> poison, <4 x i32> zeroinitializer
%117 = add nsw i64 %108, -8
%118 = lshr exact i64 %117, 3
%119 = add nuw nsw i64 %118, 1
%120 = and i64 %119, 1
%121 = icmp eq i64 %117, 0
br i1 %121, label %165, label %122
122: ; preds = %107
%123 = and i64 %119, 4611686018427387902
br label %124
124: ; preds = %124, %122
%125 = phi i64 [ 0, %122 ], [ %162, %124 ]
%126 = phi <4 x i32> [ zeroinitializer, %122 ], [ %160, %124 ]
%127 = phi <4 x i32> [ zeroinitializer, %122 ], [ %161, %124 ]
%128 = phi i64 [ 0, %122 ], [ %163, %124 ]
%129 = getelementptr inbounds i16, i16* %85, i64 %125
%130 = bitcast i16* %129 to <4 x i16>*
%131 = load <4 x i16>, <4 x i16>* %130
%132 = getelementptr inbounds i16, i16* %129, i64 4
%133 = bitcast i16* %132 to <4 x i16>*
%134 = load <4 x i16>, <4 x i16>* %133
%135 = zext <4 x i16> %131 to <4 x i32>
%136 = zext <4 x i16> %134 to <4 x i32>
%137 = mul nsw <4 x i32> %110, %135
%138 = mul nsw <4 x i32> %112, %136
%139 = icmp sgt <4 x i32> %137, %114
%140 = icmp sgt <4 x i32> %138, %116
%141 = zext <4 x i1> %139 to <4 x i32>
%142 = zext <4 x i1> %140 to <4 x i32>
%143 = add <4 x i32> %126, %141
%144 = add <4 x i32> %127, %142
%145 = or i64 %125, 8
%146 = getelementptr inbounds i16, i16* %85, i64 %145
%147 = bitcast i16* %146 to <4 x i16>*
%148 = load <4 x i16>, <4 x i16>* %147
%149 = getelementptr inbounds i16, i16* %146, i64 4
%150 = bitcast i16* %149 to <4 x i16>*
%151 = load <4 x i16>, <4 x i16>* %150
%152 = zext <4 x i16> %148 to <4 x i32>
%153 = zext <4 x i16> %151 to <4 x i32>
%154 = mul nsw <4 x i32> %110, %152
%155 = mul nsw <4 x i32> %112, %153
%156 = icmp sgt <4 x i32> %154, %114
%157 = icmp sgt <4 x i32> %155, %116
%158 = zext <4 x i1> %156 to <4 x i32>
%159 = zext <4 x i1> %157 to <4 x i32>
%160 = add <4 x i32> %143, %158
%161 = add <4 x i32> %144, %159
%162 = add nuw i64 %125, 16
%163 = add i64 %128, 2
%164 = icmp eq i64 %163, %123
br i1 %164, label %165, label %124
165: ; preds = %124, %107
%166 = phi <4 x i32> [ undef, %107 ], [ %160, %124 ]
%167 = phi <4 x i32> [ undef, %107 ], [ %161, %124 ]
%168 = phi i64 [ 0, %107 ], [ %162, %124 ]
%169 = phi <4 x i32> [ zeroinitializer, %107 ], [ %160, %124 ]
%170 = phi <4 x i32> [ zeroinitializer, %107 ], [ %161, %124 ]
%171 = icmp eq i64 %120, 0
br i1 %171, label %189, label %172
172: ; preds = %165
%173 = getelementptr inbounds i16, i16* %85, i64 %168
%174 = bitcast i16* %173 to <4 x i16>*
%175 = load <4 x i16>, <4 x i16>* %174
%176 = getelementptr inbounds i16, i16* %173, i64 4
%177 = bitcast i16* %176 to <4 x i16>*
%178 = load <4 x i16>, <4 x i16>* %177
%179 = zext <4 x i16> %175 to <4 x i32>
%180 = zext <4 x i16> %178 to <4 x i32>
%181 = mul nsw <4 x i32> %110, %179
%182 = mul nsw <4 x i32> %112, %180
%183 = icmp sgt <4 x i32> %181, %114
%184 = icmp sgt <4 x i32> %182, %116
%185 = zext <4 x i1> %183 to <4 x i32>
%186 = zext <4 x i1> %184 to <4 x i32>
%187 = add <4 x i32> %169, %185
%188 = add <4 x i32> %170, %186
br label %189
189: ; preds = %165, %172
%190 = phi <4 x i32> [ %166, %165 ], [ %187, %172 ]
%191 = phi <4 x i32> [ %167, %165 ], [ %188, %172 ]
%192 = add <4 x i32> %191, %190
%193 = call i32 @llvm.vector.reduce.add.v4i32(<4 x i32> %192)
%194 = icmp eq i64 %108, %105
br i1 %194, label %210, label %195
195: ; preds = %103, %189
%196 = phi i64 [ 0, %103 ], [ %108, %189 ]
%197 = phi i32 [ 0, %103 ], [ %193, %189 ]
br label %198
198: ; preds = %195, %198
%199 = phi i64 [ %208, %198 ], [ %196, %195 ]
%200 = phi i32 [ %207, %198 ], [ %197, %195 ]
%201 = getelementptr inbounds i16, i16* %85, i64 %199
%202 = load i16, i16* %201
%203 = zext i16 %202 to i32
%204 = mul nsw i32 %80, %203
%205 = icmp sgt i32 %204, %104
%206 = zext i1 %205 to i32
%207 = add nuw nsw i32 %200, %206
%208 = add nuw nsw i64 %199, 1
%209 = icmp eq i64 %208, %105
br i1 %209, label %210, label %198
210: ; preds = %198, %189
%211 = phi i32 [ %193, %189 ], [ %207, %198 ]
%212 = sitofp i32 %211 to float
br label %213
213: ; preds = %210, %99
%214 = phi float [ 0.000000e+00, %99 ], [ %212, %210 ]
%215 = sitofp i32 %48 to float
%216 = fdiv float %214, %215
%217 = tail call i64 @floorl(float %216)
%218 = trunc i64 %217 to i32
%219 = icmp eq i32 %218, 0
br i1 %219, label %220, label %223
220: ; preds = %213
%221 = load i32, i32* @stderr
%222 = tail call i32 (i32, i8*, ...) @fprintf(i32 %221, i8* getelementptr inbounds ([65 x i8], [65 x i8]* @.str.15, i64 0, i64 0))
br label %223
223: ; preds = %220, %213
%224 = phi i32 [ 1, %220 ], [ %218, %213 ]
br i1 %102, label %229, label %225
225: ; preds = %223
%226 = mul nsw i32 %80, %64
%227 = uitofp i16 %43 to float
%228 = zext i32 %77 to i64
br label %234
229: ; preds = %262, %223
%230 = icmp sgt i32 %73, 0
%231 = icmp sgt i32 %48, 0
%232 = call i32 @llvm.smax.i32(i32 %82, i32 1)
%233 = and i64 %47, 4294967295
br label %267
234: ; preds = %225, %262
%235 = phi i64 [ 0, %225 ], [ %265, %262 ]
%236 = phi i32 [ 0, %225 ], [ %264, %262 ]
%237 = phi i32 [ 0, %225 ], [ %263, %262 ]
%238 = getelementptr inbounds i16, i16* %85, i64 %235
%239 = load i16, i16* %238
%240 = zext i16 %239 to i32
%241 = mul nsw i32 %80, %240
%242 = icmp sgt i32 %241, %226
br i1 %242, label %243, label %262
243: ; preds = %234
%244 = add nsw i32 %236, 1
%245 = srem i32 %244, %224
%246 = icmp eq i32 %245, 0
%247 = icmp slt i32 %237, %48
%248 = select i1 %246, i1 %247, i1 false
br i1 %248, label %249, label %262
249: ; preds = %243
%250 = trunc i64 %235 to i32
%251 = urem i32 %250, %76
%252 = sub nsw i32 %251, %73
%253 = sext i32 %237 to i64
%254 = getelementptr inbounds [20000 x i32], [20000 x i32]* %3, i64 0, i64 %253
store i32 %252, i32* %254
%255 = sitofp i32 %250 to float
%256 = fdiv float %255, %227
%257 = tail call i64 @floorl(float %256)
%258 = trunc i64 %257 to i32
%259 = sub nsw i32 %258, %73
%260 = getelementptr inbounds [20000 x i32], [20000 x i32]* %4, i64 0, i64 %253
store i32 %259, i32* %260
%261 = add nsw i32 %237, 1
br label %262
262: ; preds = %234, %249, %243
%263 = phi i32 [ %261, %249 ], [ %237, %243 ], [ %237, %234 ]
%264 = phi i32 [ %244, %249 ], [ %244, %243 ], [ %236, %234 ]
%265 = add nuw nsw i64 %235, 1
%266 = icmp eq i64 %265, %228
br i1 %266, label %229, label %234
267: ; preds = %318, %229
%268 = phi i32 [ 0, %229 ], [ %319, %318 ]
%269 = phi i32 [ undef, %229 ], [ %315, %318 ]
%270 = phi i32 [ undef, %229 ], [ %314, %318 ]
%271 = phi i32 [ 0, %229 ], [ %313, %318 ]
%272 = sub nsw i32 %268, %73
br label %273
273: ; preds = %267, %309
%274 = phi i32 [ 0, %267 ], [ %316, %309 ]
%275 = phi i32 [ %269, %267 ], [ %315, %309 ]
%276 = phi i32 [ %270, %267 ], [ %314, %309 ]
%277 = phi i32 [ %271, %267 ], [ %313, %309 ]
br i1 %231, label %278, label %309
278: ; preds = %273, %302
%279 = phi i64 [ %305, %302 ], [ 0, %273 ]
%280 = phi i32 [ %304, %302 ], [ 0, %273 ]
%281 = phi i32 [ %303, %302 ], [ 0, %273 ]
%282 = getelementptr inbounds [20000 x i32], [20000 x i32]* %4, i64 0, i64 %279
%283 = load i32, i32* %282
%284 = add nsw i32 %283, %268
%285 = icmp sgt i32 %284, 0
br i1 %285, label %286, label %302
286: ; preds = %278
%287 = mul nsw i32 %284, %76
%288 = getelementptr inbounds [20000 x i32], [20000 x i32]* %3, i64 0, i64 %279
%289 = load i32, i32* %288
%290 = add i32 %287, %274
%291 = add i32 %290, %289
%292 = icmp sgt i32 %291, -1
%293 = icmp slt i32 %291, %77
%294 = select i1 %292, i1 %293, i1 false
br i1 %294, label %295, label %302
295: ; preds = %286
%296 = zext i32 %291 to i64
%297 = getelementptr inbounds i16, i16* %93, i64 %296
%298 = load i16, i16* %297
%299 = zext i16 %298 to i32
%300 = add nsw i32 %281, %299
%301 = add nsw i32 %280, 1
br label %302
302: ; preds = %278, %295, %286
%303 = phi i32 [ %300, %295 ], [ %281, %286 ], [ %281, %278 ]
%304 = phi i32 [ %301, %295 ], [ %280, %286 ], [ %280, %278 ]
%305 = add nuw nsw i64 %279, 1
%306 = icmp eq i64 %305, %233
br i1 %306, label %307, label %278
307: ; preds = %302
%308 = sdiv i32 %303, %304
br label %309
309: ; preds = %307, %273
%310 = phi i32 [ %308, %307 ], [ poison, %273 ]
%311 = icmp sgt i32 %310, %277
%312 = sub nsw i32 %274, %73
%313 = select i1 %311, i32 %310, i32 %277
%314 = select i1 %311, i32 %272, i32 %276
%315 = select i1 %311, i32 %312, i32 %275
%316 = add nuw nsw i32 %274, 1
%317 = icmp eq i32 %316, %232
br i1 %317, label %318, label %273
318: ; preds = %309
%319 = add nuw nsw i32 %268, 1
%320 = icmp eq i32 %319, %232
br i1 %320, label %321, label %267
321: ; preds = %318
%322 = load i32, i32* @stderr
%323 = tail call i32 (i32, i8*, ...) @fprintf(i32 %322, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.16, i64 0, i64 0), i32 %315, i32 %314, i32 %313)
%324 = tail call i64 @malloc(i32 %83)
%325 = inttoptr i64 %324 to i16*
%326 = icmp eq i64 %324, 0
br i1 %326, label %330, label %327
327: ; preds = %321
br i1 %102, label %359, label %328
328: ; preds = %327
%329 = zext i32 %77 to i64
br label %334
330: ; preds = %321
%331 = load i32, i32* @stderr
%332 = tail call i32 (i32, i8*, ...) @fprintf(i32 %331, i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.14, i64 0, i64 0))
%333 = tail call i32 @exit(i32 42)
unreachable
334: ; preds = %328, %354
%335 = phi i64 [ 0, %328 ], [ %357, %354 ]
%336 = trunc i64 %335 to i32
%337 = urem i32 %336, %74
%338 = udiv i32 %336, %76
%339 = add nsw i32 %337, %315
%340 = add nsw i32 %338, %314
%341 = icmp slt i32 %339, 0
%342 = icmp slt i32 %340, 0
%343 = select i1 %341, i1 true, i1 %342
%344 = icmp sgt i32 %339, %74
%345 = select i1 %343, i1 true, i1 %344
%346 = icmp sgt i32 %340, %76
%347 = select i1 %345, i1 true, i1 %346
br i1 %347, label %354, label %348
348: ; preds = %334
%349 = mul nsw i32 %340, %74
%350 = add nsw i32 %349, %339
%351 = sext i32 %350 to i64
%352 = getelementptr inbounds i16, i16* %93, i64 %351
%353 = load i16, i16* %352
br label %354
354: ; preds = %334, %348
%355 = phi i16 [ %353, %348 ], [ -1, %334 ]
%356 = getelementptr inbounds i16, i16* %325, i64 %335
store i16 %355, i16* %356
%357 = add nuw nsw i64 %335, 1
%358 = icmp eq i64 %357, %329
br i1 %358, label %359, label %334
359: ; preds = %354, %327
%360 = load i32, i32* @stdout
%361 = tail call i32 @fwrite(i16* %325, i32 %83, i32 1, i32 %360)
ret i32 0
}