#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 */
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
double pow(int, int);
int read_arcinfo_grid(char *, double **, double **, int *, int *, double *,
                      double *, double *, int *, double **);
scalar_t__ rint(double);
int /*<<< orphan*/ stderr;
int write_arcinfo_grid(char *, double *, double *, double *, int, int, double,
                       double, double, int, int);
main(int argc, char *argv[]) {
  char lowresmask[512];
  char infile[512];
  char outfile[512];
  double store_values[4];
  double *hr_values, *hr_lat, *hr_lng;
  double *lr_values, *lr_lat, *lr_lng;
  double hr_ll_lat, hr_ll_lng, hr_cellsize;
  double lr_ll_lat, lr_ll_lng, lr_cellsize;
  int hr_ncols, hr_nrows;
  int lr_ncols, lr_nrows;
  int NODATA, storecnt;
  int Ncells_lr, Ncells_hr;
  int i, j;
  if (argc != 4) {
    fprintf(stderr,
            "Usage: %s <high res grid> <low res mask> <low res output gird>\n",
            argv[0]);
    fprintf(stderr,
            "\t<high res grid> is the high resolution ARC/INFO grid.\n");
    fprintf(stderr, "\t<low res mask> is an ARC/INFO grid mask file at the "
                    "lower resolution.\n");
    fprintf(stderr,
            "\tThis program aggregates the high resolution ARCINFO file to the "
            "resolution of the low resolution mask file (only aggregates by a "
            "factor of 2, e.g. 1/8 to 1/4, 1/4 to 1/2) and outputs a new "
            "ARCINFO grid file to <low res output grid>.\n");
    exit(0);
  }
  Ncells_lr = read_arcinfo_grid(argv[2], &lr_lat, &lr_lng, &lr_ncols, &lr_nrows,
                                &lr_ll_lat, &lr_ll_lng, &lr_cellsize, &NODATA,
                                &lr_values);
  Ncells_hr = read_arcinfo_grid(argv[1], &hr_lat, &hr_lng, &hr_ncols, &hr_nrows,
                                &hr_ll_lat, &hr_ll_lng, &hr_cellsize, &NODATA,
                                &hr_values);
  for (i = 0; i < Ncells_lr; i++) {
    j = 0;
    storecnt = 0;
    while (j < Ncells_hr && storecnt < 4) {
      if (rint(hr_lat[j] * pow(10, (double)4)) ==
              rint((lr_lat[i] + hr_cellsize / 2) * pow(10, 4)) &&
          rint(hr_lng[j] * pow(10, (double)4)) ==
              rint((lr_lng[i] + hr_cellsize / 2) * pow(10, 4))) {
        if (hr_values[j] != NODATA) {
          store_values[storecnt] = hr_values[j];
          storecnt++;
        }
      }
      if (rint(hr_lat[j] * pow(10, (double)4)) ==
              rint((lr_lat[i] - hr_cellsize / 2) * pow(10, 4)) &&
          rint(hr_lng[j] * pow(10, (double)4)) ==
              rint((lr_lng[i] + hr_cellsize / 2) * pow(10, 4))) {
        if (hr_values[j] != NODATA) {
          store_values[storecnt] = hr_values[j];
          storecnt++;
        }
      }
      if (rint(hr_lat[j] * pow(10, (double)4)) ==
              rint((lr_lat[i] + hr_cellsize / 2) * pow(10, 4)) &&
          rint(hr_lng[j] * pow(10, (double)4)) ==
              rint((lr_lng[i] - hr_cellsize / 2) * pow(10, 4))) {
        if (hr_values[j] != NODATA) {
          store_values[storecnt] = hr_values[j];
          storecnt++;
        }
      }
      if (rint(hr_lat[j] * pow(10, (double)4)) ==
              rint((lr_lat[i] - hr_cellsize / 2) * pow(10, 4)) &&
          rint(hr_lng[j] * pow(10, (double)4)) ==
              rint((lr_lng[i] - hr_cellsize / 2) * pow(10, 4))) {
        if (hr_values[j] != NODATA) {
          store_values[storecnt] = hr_values[j];
          storecnt++;
        }
      }
      j++;
    }
    if (storecnt > 0) {
      lr_values[i] = 0;
      for (j = 0; j < storecnt; j++)
        lr_values[i] += store_values[j];
      lr_values[i] /= (double)storecnt;
    } else
      lr_values[i] = NODATA;
  }
  Ncells_hr =
      write_arcinfo_grid(argv[3], lr_values, lr_lat, lr_lng, lr_ncols, lr_nrows,
                         lr_ll_lat, lr_ll_lng, lr_cellsize, NODATA, Ncells_lr);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
push   %rbx
sub    $0x7a8,%rsp
movl   $0x0,-0xc(%rbp)
mov    %edi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
cmpl   $0x4,-0x10(%rbp)
je     11ee <main+0x8e>
mov    0x2e55(%rip),%rax
mov    (%rax),%edi
mov    -0x18(%rbp),%rax
mov    (%rax),%rdx
lea    0xe6d(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    0x2e37(%rip),%rax
mov    (%rax),%edi
lea    0xe96(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    0x2e20(%rip),%rax
mov    (%rax),%edi
lea    0xeb7(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    0x2e09(%rip),%rax
mov    (%rax),%edi
lea    0xee8(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
xor    %edi,%edi
call   1080 <exit@plt>
mov    -0x18(%rbp),%rax
mov    0x10(%rax),%rdi
lea    -0x668(%rbp),%rsi
lea    -0x670(%rbp),%rdx
lea    -0x6ac(%rbp),%rcx
lea    -0x6b0(%rbp),%r8
lea    -0x690(%rbp),%r9
lea    -0x698(%rbp),%rbx
lea    -0x6a0(%rbp),%r11
lea    -0x6b4(%rbp),%r10
lea    -0x660(%rbp),%rax
mov    %rbx,(%rsp)
mov    %r11,0x8(%rsp)
mov    %r10,0x10(%rsp)
mov    %rax,0x18(%rsp)
call   1060 <read_arcinfo_grid@plt>
mov    %eax,-0x6bc(%rbp)
mov    -0x18(%rbp),%rax
mov    0x8(%rax),%rdi
lea    -0x650(%rbp),%rsi
lea    -0x658(%rbp),%rdx
lea    -0x6a4(%rbp),%rcx
lea    -0x6a8(%rbp),%r8
lea    -0x678(%rbp),%r9
lea    -0x680(%rbp),%rbx
lea    -0x688(%rbp),%r11
lea    -0x6b4(%rbp),%r10
lea    -0x648(%rbp),%rax
mov    %rbx,(%rsp)
mov    %r11,0x8(%rsp)
mov    %r10,0x10(%rsp)
mov    %rax,0x18(%rsp)
call   1060 <read_arcinfo_grid@plt>
mov    %eax,-0x6c0(%rbp)
movl   $0x0,-0x6c4(%rbp)
mov    -0x6c4(%rbp),%eax
cmp    -0x6bc(%rbp),%eax
jge    1b1d <main+0x9bd>
movl   $0x0,-0x6c8(%rbp)
movl   $0x0,-0x6b8(%rbp)
mov    -0x6c8(%rbp),%ecx
xor    %eax,%eax
cmp    -0x6c0(%rbp),%ecx
mov    %al,-0x6c9(%rbp)
jge    1312 <main+0x1b2>
cmpl   $0x4,-0x6b8(%rbp)
setl   %al
mov    %al,-0x6c9(%rbp)
mov    -0x6c9(%rbp),%al
test   $0x1,%al
jne    1325 <main+0x1c5>
jmp    1a45 <main+0x8e5>
mov    -0x650(%rbp),%rax
movslq -0x6c8(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x6e8(%rbp)
ff
mov    $0xa,%edi
mov    $0x4,%esi
call   1070 <pow@plt>
movaps %xmm0,%xmm1
movsd  -0x6e8(%rbp),%xmm0
ff
mulsd  %xmm1,%xmm0
call   1050 <rint@plt>
mov    %rax,-0x6d8(%rbp)
mov    -0x668(%rbp),%rax
movslq -0x6c4(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  -0x688(%rbp),%xmm1
ff
movsd  0xc73(%rip),%xmm2
divsd  %xmm2,%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x6e0(%rbp)
ff
mov    $0xa,%edi
mov    $0x4,%esi
call   1070 <pow@plt>
movaps %xmm0,%xmm1
movsd  -0x6e0(%rbp),%xmm0
ff
mulsd  %xmm1,%xmm0
call   1050 <rint@plt>
mov    %rax,%rcx
mov    -0x6d8(%rbp),%rax
cmp    %rcx,%rax
jne    14e8 <main+0x388>
mov    -0x658(%rbp),%rax
movslq -0x6c8(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x700(%rbp)
ff
mov    $0xa,%edi
mov    $0x4,%esi
call   1070 <pow@plt>
movaps %xmm0,%xmm1
movsd  -0x700(%rbp),%xmm0
ff
mulsd  %xmm1,%xmm0
call   1050 <rint@plt>
mov    %rax,-0x6f0(%rbp)
mov    -0x670(%rbp),%rax
movslq -0x6c4(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  -0x688(%rbp),%xmm1
ff
movsd  0xbc5(%rip),%xmm2
divsd  %xmm2,%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x6f8(%rbp)
ff
mov    $0xa,%edi
mov    $0x4,%esi
call   1070 <pow@plt>
movaps %xmm0,%xmm1
movsd  -0x6f8(%rbp),%xmm0
ff
mulsd  %xmm1,%xmm0
call   1050 <rint@plt>
mov    %rax,%rcx
mov    -0x6f0(%rbp),%rax
cmp    %rcx,%rax
jne    14e8 <main+0x388>
mov    -0x648(%rbp),%rax
movslq -0x6c8(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
cvtsi2sdl -0x6b4(%rbp),%xmm1
ff
ucomisd %xmm1,%xmm0
jne    14b1 <main+0x351>
jp     14b1 <main+0x351>
jmp    14e3 <main+0x383>
mov    -0x648(%rbp),%rax
movslq -0x6c8(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movslq -0x6b8(%rbp),%rax
movsd  %xmm0,-0x640(%rbp,%rax,8)
ff ff
mov    -0x6b8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x6b8(%rbp)
jmp    14e8 <main+0x388>
mov    -0x650(%rbp),%rax
movslq -0x6c8(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x718(%rbp)
ff
mov    $0xa,%edi
mov    $0x4,%esi
call   1070 <pow@plt>
movaps %xmm0,%xmm1
movsd  -0x718(%rbp),%xmm0
ff
mulsd  %xmm1,%xmm0
call   1050 <rint@plt>
mov    %rax,-0x708(%rbp)
mov    -0x668(%rbp),%rax
movslq -0x6c4(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  -0x688(%rbp),%xmm1
ff
movsd  0xab0(%rip),%xmm2
divsd  %xmm2,%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x710(%rbp)
ff
mov    $0xa,%edi
mov    $0x4,%esi
call   1070 <pow@plt>
movaps %xmm0,%xmm1
movsd  -0x710(%rbp),%xmm0
ff
mulsd  %xmm1,%xmm0
call   1050 <rint@plt>
mov    %rax,%rcx
mov    -0x708(%rbp),%rax
cmp    %rcx,%rax
jne    16ab <main+0x54b>
mov    -0x658(%rbp),%rax
movslq -0x6c8(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x730(%rbp)
ff
mov    $0xa,%edi
mov    $0x4,%esi
call   1070 <pow@plt>
movaps %xmm0,%xmm1
movsd  -0x730(%rbp),%xmm0
ff
mulsd  %xmm1,%xmm0
call   1050 <rint@plt>
mov    %rax,-0x720(%rbp)
mov    -0x670(%rbp),%rax
movslq -0x6c4(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  -0x688(%rbp),%xmm1
ff
movsd  0xa02(%rip),%xmm2
divsd  %xmm2,%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x728(%rbp)
ff
mov    $0xa,%edi
mov    $0x4,%esi
call   1070 <pow@plt>
movaps %xmm0,%xmm1
movsd  -0x728(%rbp),%xmm0
ff
mulsd  %xmm1,%xmm0
call   1050 <rint@plt>
mov    %rax,%rcx
mov    -0x720(%rbp),%rax
cmp    %rcx,%rax
jne    16ab <main+0x54b>
mov    -0x648(%rbp),%rax
movslq -0x6c8(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
cvtsi2sdl -0x6b4(%rbp),%xmm1
ff
ucomisd %xmm1,%xmm0
jne    1674 <main+0x514>
jp     1674 <main+0x514>
jmp    16a6 <main+0x546>
mov    -0x648(%rbp),%rax
movslq -0x6c8(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movslq -0x6b8(%rbp),%rax
movsd  %xmm0,-0x640(%rbp,%rax,8)
ff ff
mov    -0x6b8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x6b8(%rbp)
jmp    16ab <main+0x54b>
mov    -0x650(%rbp),%rax
movslq -0x6c8(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x748(%rbp)
ff
mov    $0xa,%edi
mov    $0x4,%esi
call   1070 <pow@plt>
movaps %xmm0,%xmm1
movsd  -0x748(%rbp),%xmm0
ff
mulsd  %xmm1,%xmm0
call   1050 <rint@plt>
mov    %rax,-0x738(%rbp)
mov    -0x668(%rbp),%rax
movslq -0x6c4(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  -0x688(%rbp),%xmm1
ff
movsd  0x8ed(%rip),%xmm2
divsd  %xmm2,%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x740(%rbp)
ff
mov    $0xa,%edi
mov    $0x4,%esi
call   1070 <pow@plt>
movaps %xmm0,%xmm1
movsd  -0x740(%rbp),%xmm0
ff
mulsd  %xmm1,%xmm0
call   1050 <rint@plt>
mov    %rax,%rcx
mov    -0x738(%rbp),%rax
cmp    %rcx,%rax
jne    186e <main+0x70e>
mov    -0x658(%rbp),%rax
movslq -0x6c8(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x760(%rbp)
ff
mov    $0xa,%edi
mov    $0x4,%esi
call   1070 <pow@plt>
movaps %xmm0,%xmm1
movsd  -0x760(%rbp),%xmm0
ff
mulsd  %xmm1,%xmm0
call   1050 <rint@plt>
mov    %rax,-0x750(%rbp)
mov    -0x670(%rbp),%rax
movslq -0x6c4(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  -0x688(%rbp),%xmm1
ff
movsd  0x83f(%rip),%xmm2
divsd  %xmm2,%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x758(%rbp)
ff
mov    $0xa,%edi
mov    $0x4,%esi
call   1070 <pow@plt>
movaps %xmm0,%xmm1
movsd  -0x758(%rbp),%xmm0
ff
mulsd  %xmm1,%xmm0
call   1050 <rint@plt>
mov    %rax,%rcx
mov    -0x750(%rbp),%rax
cmp    %rcx,%rax
jne    186e <main+0x70e>
mov    -0x648(%rbp),%rax
movslq -0x6c8(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
cvtsi2sdl -0x6b4(%rbp),%xmm1
ff
ucomisd %xmm1,%xmm0
jne    1837 <main+0x6d7>
jp     1837 <main+0x6d7>
jmp    1869 <main+0x709>
mov    -0x648(%rbp),%rax
movslq -0x6c8(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movslq -0x6b8(%rbp),%rax
movsd  %xmm0,-0x640(%rbp,%rax,8)
ff ff
mov    -0x6b8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x6b8(%rbp)
jmp    186e <main+0x70e>
mov    -0x650(%rbp),%rax
movslq -0x6c8(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x778(%rbp)
ff
mov    $0xa,%edi
mov    $0x4,%esi
call   1070 <pow@plt>
movaps %xmm0,%xmm1
movsd  -0x778(%rbp),%xmm0
ff
mulsd  %xmm1,%xmm0
call   1050 <rint@plt>
mov    %rax,-0x768(%rbp)
mov    -0x668(%rbp),%rax
movslq -0x6c4(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  -0x688(%rbp),%xmm1
ff
movsd  0x72a(%rip),%xmm2
divsd  %xmm2,%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x770(%rbp)
ff
mov    $0xa,%edi
mov    $0x4,%esi
call   1070 <pow@plt>
movaps %xmm0,%xmm1
movsd  -0x770(%rbp),%xmm0
ff
mulsd  %xmm1,%xmm0
call   1050 <rint@plt>
mov    %rax,%rcx
mov    -0x768(%rbp),%rax
cmp    %rcx,%rax
jne    1a31 <main+0x8d1>
mov    -0x658(%rbp),%rax
movslq -0x6c8(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x790(%rbp)
ff
mov    $0xa,%edi
mov    $0x4,%esi
call   1070 <pow@plt>
movaps %xmm0,%xmm1
movsd  -0x790(%rbp),%xmm0
ff
mulsd  %xmm1,%xmm0
call   1050 <rint@plt>
mov    %rax,-0x780(%rbp)
mov    -0x670(%rbp),%rax
movslq -0x6c4(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  -0x688(%rbp),%xmm1
ff
movsd  0x67c(%rip),%xmm2
divsd  %xmm2,%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x788(%rbp)
ff
mov    $0xa,%edi
mov    $0x4,%esi
call   1070 <pow@plt>
movaps %xmm0,%xmm1
movsd  -0x788(%rbp),%xmm0
ff
mulsd  %xmm1,%xmm0
call   1050 <rint@plt>
mov    %rax,%rcx
mov    -0x780(%rbp),%rax
cmp    %rcx,%rax
jne    1a31 <main+0x8d1>
mov    -0x648(%rbp),%rax
movslq -0x6c8(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
cvtsi2sdl -0x6b4(%rbp),%xmm1
ff
ucomisd %xmm1,%xmm0
jne    19fa <main+0x89a>
jp     19fa <main+0x89a>
jmp    1a2c <main+0x8cc>
mov    -0x648(%rbp),%rax
movslq -0x6c8(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movslq -0x6b8(%rbp),%rax
movsd  %xmm0,-0x640(%rbp,%rax,8)
ff ff
mov    -0x6b8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x6b8(%rbp)
jmp    1a31 <main+0x8d1>
mov    -0x6c8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x6c8(%rbp)
jmp    12e8 <main+0x188>
cmpl   $0x0,-0x6b8(%rbp)
jle    1ae9 <main+0x989>
mov    -0x660(%rbp),%rax
movslq -0x6c4(%rbp),%rcx
xorps  %xmm0,%xmm0
movsd  %xmm0,(%rax,%rcx,8)
movl   $0x0,-0x6c8(%rbp)
mov    -0x6c8(%rbp),%eax
cmp    -0x6b8(%rbp),%eax
jge    1ac0 <main+0x960>
movslq -0x6c8(%rbp),%rax
movsd  -0x640(%rbp,%rax,8),%xmm0
ff ff
mov    -0x660(%rbp),%rax
movslq -0x6c4(%rbp),%rcx
addsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x6c8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x6c8(%rbp)
jmp    1a72 <main+0x912>
cvtsi2sdl -0x6b8(%rbp),%xmm1
ff
mov    -0x660(%rbp),%rax
movslq -0x6c4(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,(%rax,%rcx,8)
jmp    1b04 <main+0x9a4>
cvtsi2sdl -0x6b4(%rbp),%xmm0
ff
mov    -0x660(%rbp),%rax
movslq -0x6c4(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
jmp    1b09 <main+0x9a9>
mov    -0x6c4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x6c4(%rbp)
jmp    12c2 <main+0x162>
mov    -0x18(%rbp),%rax
mov    0x18(%rax),%rdi
mov    -0x660(%rbp),%rsi
mov    -0x668(%rbp),%rdx
mov    -0x670(%rbp),%rcx
mov    -0x6ac(%rbp),%r8d
mov    -0x6b0(%rbp),%r9d
movsd  -0x690(%rbp),%xmm0
ff
movsd  -0x698(%rbp),%xmm1
ff
movsd  -0x6a0(%rbp),%xmm2
ff
mov    -0x6b4(%rbp),%r10d
mov    -0x6bc(%rbp),%eax
mov    %r10d,(%rsp)
mov    %eax,0x8(%rsp)
call   1030 <write_arcinfo_grid@plt>
mov    %eax,-0x6c0(%rbp)
mov    -0xc(%rbp),%eax
add    $0x7a8,%rsp
pop    %rbx
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0xb8,%rsp
mov    %rsi,%rbx
cmp    $0x4,%edi
jne    17d7 <main+0x677>
mov    0x10(%rbx),%rdi
lea    0x40(%rsp),%rax
lea    0xc(%rsp),%r14
lea    0x88(%rsp),%rbp
lea    0x90(%rsp),%r10
lea    0x20(%rsp),%rsi
lea    0x18(%rsp),%rdx
lea    0x4c(%rsp),%rcx
lea    0x48(%rsp),%r8
lea    0x98(%rsp),%r9
push   %rax
push   %r14
push   %rbp
push   %r10
call   1060 <read_arcinfo_grid@plt>
add    $0x20,%rsp
mov    %eax,%r15d
mov    %rbx,0x78(%rsp)
mov    0x8(%rbx),%rdi
lea    0x38(%rsp),%rax
lea    0x10(%rsp),%rbp
lea    0xa8(%rsp),%rbx
lea    0x30(%rsp),%rsi
lea    0x28(%rsp),%rdx
lea    0xa4(%rsp),%rcx
lea    0xa0(%rsp),%r8
lea    0xb0(%rsp),%r9
push   %rax
push   %r14
push   %rbp
push   %rbx
call   1060 <read_arcinfo_grid@plt>
add    $0x20,%rsp
test   %r15d,%r15d
mov    %r15,0x70(%rsp)
jle    1774 <main+0x614>
mov    %eax,%r12d
movslq %eax,%rbp
mov    %r15d,%eax
mov    %rax,0x80(%rsp)
xor    %r14d,%r14d
jmp    1266 <main+0x106>
nopl   0x0(%rax,%rax,1)
xorps  %xmm0,%xmm0
cvtsi2sdl 0xc(%rsp),%xmm0
mov    0x40(%rsp),%rsi
movsd  %xmm0,(%rsi,%r14,8)
add    $0x1,%r14
cmp    0x80(%rsp),%r14
je     1779 <main+0x619>
test   %r12d,%r12d
jle    1240 <main+0xe0>
xor    %r15d,%r15d
mov    $0x1,%r13d
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    0x30(%rsp),%rax
movsd  -0x8(%rax,%r13,8),%xmm0
movsd  %xmm0,(%rsp)
mov    $0xa,%edi
mov    $0x4,%esi
call   1070 <pow@plt>
mulsd  (%rsp),%xmm0
call   1050 <rint@plt>
mov    %rax,%rbx
mov    0x20(%rsp),%rax
movsd  0x10(%rsp),%xmm1
movsd  0xd40(%rip),%xmm0
mulsd  %xmm0,%xmm1
addsd  (%rax,%r14,8),%xmm1
movsd  %xmm1,(%rsp)
mov    $0xa,%edi
mov    $0x4,%esi
call   1070 <pow@plt>
mulsd  (%rsp),%xmm0
call   1050 <rint@plt>
cmp    %rax,%rbx
jne    1390 <main+0x230>
mov    0x28(%rsp),%rax
movsd  -0x8(%rax,%r13,8),%xmm0
movsd  %xmm0,(%rsp)
mov    $0xa,%edi
mov    $0x4,%esi
call   1070 <pow@plt>
mulsd  (%rsp),%xmm0
call   1050 <rint@plt>
mov    %rax,%rbx
mov    0x18(%rsp),%rax
movsd  0x10(%rsp),%xmm0
mulsd  0xccf(%rip),%xmm0
addsd  (%rax,%r14,8),%xmm0
movsd  %xmm0,(%rsp)
mov    $0xa,%edi
mov    $0x4,%esi
call   1070 <pow@plt>
mulsd  (%rsp),%xmm0
call   1050 <rint@plt>
cmp    %rax,%rbx
jne    1390 <main+0x230>
mov    0x38(%rsp),%rax
movsd  -0x8(%rax,%r13,8),%xmm0
xorps  %xmm1,%xmm1
cvtsi2sdl 0xc(%rsp),%xmm1
ucomisd %xmm1,%xmm0
jne    1377 <main+0x217>
jnp    1390 <main+0x230>
movslq %r15d,%r15
movsd  %xmm0,0x50(%rsp,%r15,8)
add    $0x1,%r15d
cs nopw 0x0(%rax,%rax,1)
nop
mov    0x30(%rsp),%rax
movsd  -0x8(%rax,%r13,8),%xmm0
movsd  %xmm0,(%rsp)
mov    $0xa,%edi
mov    $0x4,%esi
call   1070 <pow@plt>
mulsd  (%rsp),%xmm0
call   1050 <rint@plt>
mov    %rax,%rbx
mov    0x20(%rsp),%rax
movsd  0x10(%rsp),%xmm0
mulsd  0xc38(%rip),%xmm0
addsd  (%rax,%r14,8),%xmm0
movsd  %xmm0,(%rsp)
mov    $0xa,%edi
mov    $0x4,%esi
call   1070 <pow@plt>
mulsd  (%rsp),%xmm0
call   1050 <rint@plt>
cmp    %rax,%rbx
jne    14a0 <main+0x340>
mov    0x28(%rsp),%rax
movsd  -0x8(%rax,%r13,8),%xmm0
movsd  %xmm0,(%rsp)
mov    $0xa,%edi
mov    $0x4,%esi
call   1070 <pow@plt>
mulsd  (%rsp),%xmm0
call   1050 <rint@plt>
mov    %rax,%rbx
mov    0x18(%rsp),%rax
movsd  0x10(%rsp),%xmm0
mulsd  0xbc3(%rip),%xmm0
addsd  (%rax,%r14,8),%xmm0
movsd  %xmm0,(%rsp)
mov    $0xa,%edi
mov    $0x4,%esi
call   1070 <pow@plt>
mulsd  (%rsp),%xmm0
call   1050 <rint@plt>
cmp    %rax,%rbx
jne    14a0 <main+0x340>
mov    0x38(%rsp),%rax
movsd  -0x8(%rax,%r13,8),%xmm0
xorps  %xmm1,%xmm1
cvtsi2sdl 0xc(%rsp),%xmm1
ucomisd %xmm1,%xmm0
jne    1483 <main+0x323>
jnp    14a0 <main+0x340>
movslq %r15d,%r15
movsd  %xmm0,0x50(%rsp,%r15,8)
add    $0x1,%r15d
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    0x30(%rsp),%rax
movsd  -0x8(%rax,%r13,8),%xmm0
movsd  %xmm0,(%rsp)
mov    $0xa,%edi
mov    $0x4,%esi
call   1070 <pow@plt>
mulsd  (%rsp),%xmm0
call   1050 <rint@plt>
mov    %rax,%rbx
mov    0x20(%rsp),%rax
movsd  0x10(%rsp),%xmm0
mulsd  0xb20(%rip),%xmm0
addsd  (%rax,%r14,8),%xmm0
movsd  %xmm0,(%rsp)
mov    $0xa,%edi
mov    $0x4,%esi
call   1070 <pow@plt>
mulsd  (%rsp),%xmm0
call   1050 <rint@plt>
cmp    %rax,%rbx
jne    15b0 <main+0x450>
mov    0x28(%rsp),%rax
movsd  -0x8(%rax,%r13,8),%xmm0
movsd  %xmm0,(%rsp)
mov    $0xa,%edi
mov    $0x4,%esi
call   1070 <pow@plt>
mulsd  (%rsp),%xmm0
call   1050 <rint@plt>
mov    %rax,%rbx
mov    0x18(%rsp),%rax
movsd  0x10(%rsp),%xmm0
mulsd  0xabb(%rip),%xmm0
addsd  (%rax,%r14,8),%xmm0
movsd  %xmm0,(%rsp)
mov    $0xa,%edi
mov    $0x4,%esi
call   1070 <pow@plt>
mulsd  (%rsp),%xmm0
call   1050 <rint@plt>
cmp    %rax,%rbx
jne    15b0 <main+0x450>
mov    0x38(%rsp),%rax
movsd  -0x8(%rax,%r13,8),%xmm0
xorps  %xmm1,%xmm1
cvtsi2sdl 0xc(%rsp),%xmm1
ucomisd %xmm1,%xmm0
jne    1593 <main+0x433>
jnp    15b0 <main+0x450>
movslq %r15d,%r15
movsd  %xmm0,0x50(%rsp,%r15,8)
add    $0x1,%r15d
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    0x30(%rsp),%rax
movsd  -0x8(%rax,%r13,8),%xmm0
movsd  %xmm0,(%rsp)
mov    $0xa,%edi
mov    $0x4,%esi
call   1070 <pow@plt>
mulsd  (%rsp),%xmm0
call   1050 <rint@plt>
mov    %rax,%rbx
mov    0x20(%rsp),%rax
movsd  0x10(%rsp),%xmm1
movsd  0xa18(%rip),%xmm0
mulsd  %xmm0,%xmm1
addsd  (%rax,%r14,8),%xmm1
movsd  %xmm1,(%rsp)
mov    $0xa,%edi
mov    $0x4,%esi
call   1070 <pow@plt>
mulsd  (%rsp),%xmm0
call   1050 <rint@plt>
cmp    %rax,%rbx
jne    16c0 <main+0x560>
mov    0x28(%rsp),%rax
movsd  -0x8(%rax,%r13,8),%xmm0
movsd  %xmm0,(%rsp)
mov    $0xa,%edi
mov    $0x4,%esi
call   1070 <pow@plt>
mulsd  (%rsp),%xmm0
call   1050 <rint@plt>
mov    %rax,%rbx
mov    0x18(%rsp),%rax
movsd  0x10(%rsp),%xmm0
mulsd  0x9a7(%rip),%xmm0
addsd  (%rax,%r14,8),%xmm0
movsd  %xmm0,(%rsp)
mov    $0xa,%edi
mov    $0x4,%esi
call   1070 <pow@plt>
mulsd  (%rsp),%xmm0
call   1050 <rint@plt>
cmp    %rax,%rbx
jne    16c0 <main+0x560>
mov    0x38(%rsp),%rax
movsd  -0x8(%rax,%r13,8),%xmm0
xorps  %xmm1,%xmm1
cvtsi2sdl 0xc(%rsp),%xmm1
ucomisd %xmm1,%xmm0
jne    16a7 <main+0x547>
jnp    16c0 <main+0x560>
movslq %r15d,%r15
movsd  %xmm0,0x50(%rsp,%r15,8)
add    $0x1,%r15d
cs nopw 0x0(%rax,%rax,1)
nop
cmp    %rbp,%r13
jge    16d3 <main+0x573>
add    $0x1,%r13
cmp    $0x4,%r15d
jl     1280 <main+0x120>
test   %r15d,%r15d
jle    1240 <main+0xe0>
mov    %r15d,%ecx
lea    -0x1(%rcx),%rdx
mov    %ecx,%eax
and    $0x7,%eax
cmp    $0x7,%rdx
jae    16f6 <main+0x596>
xorpd  %xmm0,%xmm0
xor    %edx,%edx
jmp    173f <main+0x5df>
and    $0xfffffff8,%ecx
xorpd  %xmm0,%xmm0
xor    %edx,%edx
nop
addsd  0x50(%rsp,%rdx,8),%xmm0
addsd  0x58(%rsp,%rdx,8),%xmm0
addsd  0x60(%rsp,%rdx,8),%xmm0
addsd  0x68(%rsp,%rdx,8),%xmm0
addsd  0x70(%rsp,%rdx,8),%xmm0
addsd  0x78(%rsp,%rdx,8),%xmm0
addsd  0x80(%rsp,%rdx,8),%xmm0
addsd  0x88(%rsp,%rdx,8),%xmm0
add    $0x8,%rdx
cmp    %rdx,%rcx
jne    1700 <main+0x5a0>
test   %rax,%rax
je     175e <main+0x5fe>
lea    (%rsp,%rdx,8),%rcx
add    $0x50,%rcx
xor    %edx,%edx
xchg   %ax,%ax
addsd  (%rcx,%rdx,8),%xmm0
add    $0x1,%rdx
cmp    %rdx,%rax
jne    1750 <main+0x5f0>
mov    0x40(%rsp),%rsi
xorps  %xmm1,%xmm1
cvtsi2sd %r15d,%xmm1
divsd  %xmm1,%xmm0
jmp    124e <main+0xee>
mov    0x40(%rsp),%rsi
mov    0x78(%rsp),%rax
mov    0x18(%rax),%rdi
mov    0x20(%rsp),%rdx
mov    0x18(%rsp),%rcx
mov    0x4c(%rsp),%r8d
mov    0x48(%rsp),%r9d
movsd  0x98(%rsp),%xmm0
movsd  0x90(%rsp),%xmm1
movsd  0x88(%rsp),%xmm2
mov    0xc(%rsp),%eax
push   0x70(%rsp)
push   %rax
call   1030 <write_arcinfo_grid@plt>
add    $0x10,%rsp
xor    %eax,%eax
add    $0xb8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2802(%rip),%rbp
mov    0x0(%rbp),%edi
mov    (%rbx),%rdx
lea    0x825(%rip),%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    0x0(%rbp),%edi
lea    0x854(%rip),%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    0x0(%rbp),%edi
lea    0x87b(%rip),%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    0x0(%rbp),%edi
lea    0x8b2(%rip),%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
xor    %edi,%edi
call   1080 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [64 x i8] c"Usage: %s <high res grid> <low res mask> <low res output gird>\0A\00"
@.str.1 = [56 x i8] c"\09<high res grid> is the high resolution ARC/INFO grid.\0A\00"
@.str.2 = [72 x i8] c"\09<low res mask> is an ARC/INFO grid mask file at the lower resolution.\0A\00"
@.str.3 = [235 x i8] c"\09This program aggregates the high resolution ARCINFO file to the resolution of the low resolution mask file (only aggregates by a factor of 2, e.g. 1/8 to 1/4, 1/4 to 1/2) and outputs a new ARCINFO grid file to <low res output grid>.\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [512 x i8]
%7 = alloca [512 x i8]
%8 = alloca [512 x i8]
%9 = alloca [4 x double]
%10 = alloca double*
%11 = alloca double*
%12 = alloca double*
%13 = alloca double*
%14 = alloca double*
%15 = alloca double*
%16 = alloca double
%17 = alloca double
%18 = alloca double
%19 = alloca double
%20 = alloca double
%21 = alloca double
%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 i32
%31 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%32 = load i32, i32* %4
%33 = icmp ne i32 %32, 4
br i1 %33, label %34, label %47
34: ; preds = %2
%35 = load i32, i32* @stderr
%36 = load i8**, i8*** %5
%37 = getelementptr inbounds i8*, i8** %36, i64 0
%38 = load i8*, i8** %37
%39 = call i32 (i32, i8*, ...) @fprintf(i32 %35, i8* getelementptr inbounds ([64 x i8], [64 x i8]* @.str, i64 0, i64 0), i8* %38)
%40 = load i32, i32* @stderr
%41 = call i32 (i32, i8*, ...) @fprintf(i32 %40, i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str.1, i64 0, i64 0))
%42 = load i32, i32* @stderr
%43 = call i32 (i32, i8*, ...) @fprintf(i32 %42, i8* getelementptr inbounds ([72 x i8], [72 x i8]* @.str.2, i64 0, i64 0))
%44 = load i32, i32* @stderr
%45 = call i32 (i32, i8*, ...) @fprintf(i32 %44, i8* getelementptr inbounds ([235 x i8], [235 x i8]* @.str.3, i64 0, i64 0))
%46 = call i32 @exit(i32 0)
unreachable
47: ; preds = %2
%48 = load i8**, i8*** %5
%49 = getelementptr inbounds i8*, i8** %48, i64 2
%50 = load i8*, i8** %49
%51 = call i32 @read_arcinfo_grid(i8* %50, double** %14, double** %15, i32* %24, i32* %25, double* %19, double* %20, double* %21, i32* %26, double** %13)
store i32 %51, i32* %28
%52 = load i8**, i8*** %5
%53 = getelementptr inbounds i8*, i8** %52, i64 1
%54 = load i8*, i8** %53
%55 = call i32 @read_arcinfo_grid(i8* %54, double** %11, double** %12, i32* %22, i32* %23, double* %16, double* %17, double* %18, i32* %26, double** %10)
store i32 %55, i32* %29
store i32 0, i32* %30
br label %56
56: ; preds = %368, %47
%57 = load i32, i32* %30
%58 = load i32, i32* %28
%59 = icmp slt i32 %57, %58
br i1 %59, label %60, label %371
60: ; preds = %56
store i32 0, i32* %31
store i32 0, i32* %27
br label %61
61: ; preds = %322, %60
%62 = load i32, i32* %31
%63 = load i32, i32* %29
%64 = icmp slt i32 %62, %63
br i1 %64, label %65, label %68
65: ; preds = %61
%66 = load i32, i32* %27
%67 = icmp slt i32 %66, 4
br label %68
68: ; preds = %65, %61
%69 = phi i1 [ false, %61 ], [ %67, %65 ]
br i1 %69, label %70, label %325
70: ; preds = %68
%71 = load double*, double** %11
%72 = load i32, i32* %31
%73 = sext i32 %72 to i64
%74 = getelementptr inbounds double, double* %71, i64 %73
%75 = load double, double* %74
%76 = call double @pow(i32 10, i32 4)
%77 = fmul double %75, %76
%78 = call i64 @rint(double %77)
%79 = load double*, double** %14
%80 = load i32, i32* %30
%81 = sext i32 %80 to i64
%82 = getelementptr inbounds double, double* %79, i64 %81
%83 = load double, double* %82
%84 = load double, double* %18
%85 = fdiv double %84, 2.000000e+00
%86 = fadd double %83, %85
%87 = call double @pow(i32 10, i32 4)
%88 = fmul double %86, %87
%89 = call i64 @rint(double %88)
%90 = icmp eq i64 %78, %89
br i1 %90, label %91, label %133
91: ; preds = %70
%92 = load double*, double** %12
%93 = load i32, i32* %31
%94 = sext i32 %93 to i64
%95 = getelementptr inbounds double, double* %92, i64 %94
%96 = load double, double* %95
%97 = call double @pow(i32 10, i32 4)
%98 = fmul double %96, %97
%99 = call i64 @rint(double %98)
%100 = load double*, double** %15
%101 = load i32, i32* %30
%102 = sext i32 %101 to i64
%103 = getelementptr inbounds double, double* %100, i64 %102
%104 = load double, double* %103
%105 = load double, double* %18
%106 = fdiv double %105, 2.000000e+00
%107 = fadd double %104, %106
%108 = call double @pow(i32 10, i32 4)
%109 = fmul double %107, %108
%110 = call i64 @rint(double %109)
%111 = icmp eq i64 %99, %110
br i1 %111, label %112, label %133
112: ; preds = %91
%113 = load double*, double** %10
%114 = load i32, i32* %31
%115 = sext i32 %114 to i64
%116 = getelementptr inbounds double, double* %113, i64 %115
%117 = load double, double* %116
%118 = load i32, i32* %26
%119 = sitofp i32 %118 to double
%120 = fcmp une double %117, %119
br i1 %120, label %121, label %132
121: ; preds = %112
%122 = load double*, double** %10
%123 = load i32, i32* %31
%124 = sext i32 %123 to i64
%125 = getelementptr inbounds double, double* %122, i64 %124
%126 = load double, double* %125
%127 = load i32, i32* %27
%128 = sext i32 %127 to i64
%129 = getelementptr inbounds [4 x double], [4 x double]* %9, i64 0, i64 %128
store double %126, double* %129
%130 = load i32, i32* %27
%131 = add nsw i32 %130, 1
store i32 %131, i32* %27
br label %132
132: ; preds = %121, %112
br label %133
133: ; preds = %132, %91, %70
%134 = load double*, double** %11
%135 = load i32, i32* %31
%136 = sext i32 %135 to i64
%137 = getelementptr inbounds double, double* %134, i64 %136
%138 = load double, double* %137
%139 = call double @pow(i32 10, i32 4)
%140 = fmul double %138, %139
%141 = call i64 @rint(double %140)
%142 = load double*, double** %14
%143 = load i32, i32* %30
%144 = sext i32 %143 to i64
%145 = getelementptr inbounds double, double* %142, i64 %144
%146 = load double, double* %145
%147 = load double, double* %18
%148 = fdiv double %147, 2.000000e+00
%149 = fsub double %146, %148
%150 = call double @pow(i32 10, i32 4)
%151 = fmul double %149, %150
%152 = call i64 @rint(double %151)
%153 = icmp eq i64 %141, %152
br i1 %153, label %154, label %196
154: ; preds = %133
%155 = load double*, double** %12
%156 = load i32, i32* %31
%157 = sext i32 %156 to i64
%158 = getelementptr inbounds double, double* %155, i64 %157
%159 = load double, double* %158
%160 = call double @pow(i32 10, i32 4)
%161 = fmul double %159, %160
%162 = call i64 @rint(double %161)
%163 = load double*, double** %15
%164 = load i32, i32* %30
%165 = sext i32 %164 to i64
%166 = getelementptr inbounds double, double* %163, i64 %165
%167 = load double, double* %166
%168 = load double, double* %18
%169 = fdiv double %168, 2.000000e+00
%170 = fadd double %167, %169
%171 = call double @pow(i32 10, i32 4)
%172 = fmul double %170, %171
%173 = call i64 @rint(double %172)
%174 = icmp eq i64 %162, %173
br i1 %174, label %175, label %196
175: ; preds = %154
%176 = load double*, double** %10
%177 = load i32, i32* %31
%178 = sext i32 %177 to i64
%179 = getelementptr inbounds double, double* %176, i64 %178
%180 = load double, double* %179
%181 = load i32, i32* %26
%182 = sitofp i32 %181 to double
%183 = fcmp une double %180, %182
br i1 %183, label %184, label %195
184: ; preds = %175
%185 = load double*, double** %10
%186 = load i32, i32* %31
%187 = sext i32 %186 to i64
%188 = getelementptr inbounds double, double* %185, i64 %187
%189 = load double, double* %188
%190 = load i32, i32* %27
%191 = sext i32 %190 to i64
%192 = getelementptr inbounds [4 x double], [4 x double]* %9, i64 0, i64 %191
store double %189, double* %192
%193 = load i32, i32* %27
%194 = add nsw i32 %193, 1
store i32 %194, i32* %27
br label %195
195: ; preds = %184, %175
br label %196
196: ; preds = %195, %154, %133
%197 = load double*, double** %11
%198 = load i32, i32* %31
%199 = sext i32 %198 to i64
%200 = getelementptr inbounds double, double* %197, i64 %199
%201 = load double, double* %200
%202 = call double @pow(i32 10, i32 4)
%203 = fmul double %201, %202
%204 = call i64 @rint(double %203)
%205 = load double*, double** %14
%206 = load i32, i32* %30
%207 = sext i32 %206 to i64
%208 = getelementptr inbounds double, double* %205, i64 %207
%209 = load double, double* %208
%210 = load double, double* %18
%211 = fdiv double %210, 2.000000e+00
%212 = fadd double %209, %211
%213 = call double @pow(i32 10, i32 4)
%214 = fmul double %212, %213
%215 = call i64 @rint(double %214)
%216 = icmp eq i64 %204, %215
br i1 %216, label %217, label %259
217: ; preds = %196
%218 = load double*, double** %12
%219 = load i32, i32* %31
%220 = sext i32 %219 to i64
%221 = getelementptr inbounds double, double* %218, i64 %220
%222 = load double, double* %221
%223 = call double @pow(i32 10, i32 4)
%224 = fmul double %222, %223
%225 = call i64 @rint(double %224)
%226 = load double*, double** %15
%227 = load i32, i32* %30
%228 = sext i32 %227 to i64
%229 = getelementptr inbounds double, double* %226, i64 %228
%230 = load double, double* %229
%231 = load double, double* %18
%232 = fdiv double %231, 2.000000e+00
%233 = fsub double %230, %232
%234 = call double @pow(i32 10, i32 4)
%235 = fmul double %233, %234
%236 = call i64 @rint(double %235)
%237 = icmp eq i64 %225, %236
br i1 %237, label %238, label %259
238: ; preds = %217
%239 = load double*, double** %10
%240 = load i32, i32* %31
%241 = sext i32 %240 to i64
%242 = getelementptr inbounds double, double* %239, i64 %241
%243 = load double, double* %242
%244 = load i32, i32* %26
%245 = sitofp i32 %244 to double
%246 = fcmp une double %243, %245
br i1 %246, label %247, label %258
247: ; preds = %238
%248 = load double*, double** %10
%249 = load i32, i32* %31
%250 = sext i32 %249 to i64
%251 = getelementptr inbounds double, double* %248, i64 %250
%252 = load double, double* %251
%253 = load i32, i32* %27
%254 = sext i32 %253 to i64
%255 = getelementptr inbounds [4 x double], [4 x double]* %9, i64 0, i64 %254
store double %252, double* %255
%256 = load i32, i32* %27
%257 = add nsw i32 %256, 1
store i32 %257, i32* %27
br label %258
258: ; preds = %247, %238
br label %259
259: ; preds = %258, %217, %196
%260 = load double*, double** %11
%261 = load i32, i32* %31
%262 = sext i32 %261 to i64
%263 = getelementptr inbounds double, double* %260, i64 %262
%264 = load double, double* %263
%265 = call double @pow(i32 10, i32 4)
%266 = fmul double %264, %265
%267 = call i64 @rint(double %266)
%268 = load double*, double** %14
%269 = load i32, i32* %30
%270 = sext i32 %269 to i64
%271 = getelementptr inbounds double, double* %268, i64 %270
%272 = load double, double* %271
%273 = load double, double* %18
%274 = fdiv double %273, 2.000000e+00
%275 = fsub double %272, %274
%276 = call double @pow(i32 10, i32 4)
%277 = fmul double %275, %276
%278 = call i64 @rint(double %277)
%279 = icmp eq i64 %267, %278
br i1 %279, label %280, label %322
280: ; preds = %259
%281 = load double*, double** %12
%282 = load i32, i32* %31
%283 = sext i32 %282 to i64
%284 = getelementptr inbounds double, double* %281, i64 %283
%285 = load double, double* %284
%286 = call double @pow(i32 10, i32 4)
%287 = fmul double %285, %286
%288 = call i64 @rint(double %287)
%289 = load double*, double** %15
%290 = load i32, i32* %30
%291 = sext i32 %290 to i64
%292 = getelementptr inbounds double, double* %289, i64 %291
%293 = load double, double* %292
%294 = load double, double* %18
%295 = fdiv double %294, 2.000000e+00
%296 = fsub double %293, %295
%297 = call double @pow(i32 10, i32 4)
%298 = fmul double %296, %297
%299 = call i64 @rint(double %298)
%300 = icmp eq i64 %288, %299
br i1 %300, label %301, label %322
301: ; preds = %280
%302 = load double*, double** %10
%303 = load i32, i32* %31
%304 = sext i32 %303 to i64
%305 = getelementptr inbounds double, double* %302, i64 %304
%306 = load double, double* %305
%307 = load i32, i32* %26
%308 = sitofp i32 %307 to double
%309 = fcmp une double %306, %308
br i1 %309, label %310, label %321
310: ; preds = %301
%311 = load double*, double** %10
%312 = load i32, i32* %31
%313 = sext i32 %312 to i64
%314 = getelementptr inbounds double, double* %311, i64 %313
%315 = load double, double* %314
%316 = load i32, i32* %27
%317 = sext i32 %316 to i64
%318 = getelementptr inbounds [4 x double], [4 x double]* %9, i64 0, i64 %317
store double %315, double* %318
%319 = load i32, i32* %27
%320 = add nsw i32 %319, 1
store i32 %320, i32* %27
br label %321
321: ; preds = %310, %301
br label %322
322: ; preds = %321, %280, %259
%323 = load i32, i32* %31
%324 = add nsw i32 %323, 1
store i32 %324, i32* %31
br label %61
325: ; preds = %68
%326 = load i32, i32* %27
%327 = icmp sgt i32 %326, 0
br i1 %327, label %328, label %360
328: ; preds = %325
%329 = load double*, double** %13
%330 = load i32, i32* %30
%331 = sext i32 %330 to i64
%332 = getelementptr inbounds double, double* %329, i64 %331
store double 0.000000e+00, double* %332
store i32 0, i32* %31
br label %333
333: ; preds = %348, %328
%334 = load i32, i32* %31
%335 = load i32, i32* %27
%336 = icmp slt i32 %334, %335
br i1 %336, label %337, label %351
337: ; preds = %333
%338 = load i32, i32* %31
%339 = sext i32 %338 to i64
%340 = getelementptr inbounds [4 x double], [4 x double]* %9, i64 0, i64 %339
%341 = load double, double* %340
%342 = load double*, double** %13
%343 = load i32, i32* %30
%344 = sext i32 %343 to i64
%345 = getelementptr inbounds double, double* %342, i64 %344
%346 = load double, double* %345
%347 = fadd double %346, %341
store double %347, double* %345
br label %348
348: ; preds = %337
%349 = load i32, i32* %31
%350 = add nsw i32 %349, 1
store i32 %350, i32* %31
br label %333
351: ; preds = %333
%352 = load i32, i32* %27
%353 = sitofp i32 %352 to double
%354 = load double*, double** %13
%355 = load i32, i32* %30
%356 = sext i32 %355 to i64
%357 = getelementptr inbounds double, double* %354, i64 %356
%358 = load double, double* %357
%359 = fdiv double %358, %353
store double %359, double* %357
br label %367
360: ; preds = %325
%361 = load i32, i32* %26
%362 = sitofp i32 %361 to double
%363 = load double*, double** %13
%364 = load i32, i32* %30
%365 = sext i32 %364 to i64
%366 = getelementptr inbounds double, double* %363, i64 %365
store double %362, double* %366
br label %367
367: ; preds = %360, %351
br label %368
368: ; preds = %367
%369 = load i32, i32* %30
%370 = add nsw i32 %369, 1
store i32 %370, i32* %30
br label %56
371: ; preds = %56
%372 = load i8**, i8*** %5
%373 = getelementptr inbounds i8*, i8** %372, i64 3
%374 = load i8*, i8** %373
%375 = load double*, double** %13
%376 = load double*, double** %14
%377 = load double*, double** %15
%378 = load i32, i32* %24
%379 = load i32, i32* %25
%380 = load double, double* %19
%381 = load double, double* %20
%382 = load double, double* %21
%383 = load i32, i32* %26
%384 = load i32, i32* %28
%385 = call i32 @write_arcinfo_grid(i8* %374, double* %375, double* %376, double* %377, i32 %378, i32 %379, double %380, double %381, double %382, i32 %383, i32 %384)
store i32 %385, i32* %29
%386 = load i32, i32* %3
ret i32 %386
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [64 x i8] c"Usage: %s <high res grid> <low res mask> <low res output gird>\0A\00"
@.str.1 = [56 x i8] c"\09<high res grid> is the high resolution ARC/INFO grid.\0A\00"
@.str.2 = [72 x i8] c"\09<low res mask> is an ARC/INFO grid mask file at the lower resolution.\0A\00"
@.str.3 = [235 x i8] c"\09This program aggregates the high resolution ARCINFO file to the resolution of the low resolution mask file (only aggregates by a factor of 2, e.g. 1/8 to 1/4, 1/4 to 1/2) and outputs a new ARCINFO grid file to <low res output grid>.\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [4 x double]
%4 = alloca double*
%5 = alloca double*
%6 = alloca double*
%7 = alloca double*
%8 = alloca double*
%9 = alloca double*
%10 = alloca double
%11 = alloca double
%12 = alloca double
%13 = alloca double
%14 = alloca double
%15 = alloca double
%16 = alloca i32
%17 = alloca i32
%18 = alloca i32
%19 = alloca i32
%20 = alloca i32
%21 = bitcast [4 x double]* %3 to i8*
%22 = bitcast double** %4 to i8*
%23 = bitcast double** %5 to i8*
%24 = bitcast double** %6 to i8*
%25 = bitcast double** %7 to i8*
%26 = bitcast double** %8 to i8*
%27 = bitcast double** %9 to i8*
%28 = bitcast double* %10 to i8*
%29 = bitcast double* %11 to i8*
%30 = bitcast double* %12 to i8*
%31 = bitcast double* %13 to i8*
%32 = bitcast double* %14 to i8*
%33 = bitcast double* %15 to i8*
%34 = bitcast i32* %16 to i8*
%35 = bitcast i32* %17 to i8*
%36 = bitcast i32* %18 to i8*
%37 = bitcast i32* %19 to i8*
%38 = bitcast i32* %20 to i8*
%39 = icmp eq i32 %0, 4
br i1 %39, label %51, label %40
40: ; preds = %2
%41 = load i32, i32* @stderr
%42 = load i8*, i8** %1
%43 = tail call i32 (i32, i8*, ...) @fprintf(i32 %41, i8* getelementptr inbounds ([64 x i8], [64 x i8]* @.str, i64 0, i64 0), i8* %42)
%44 = load i32, i32* @stderr
%45 = tail call i32 (i32, i8*, ...) @fprintf(i32 %44, i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str.1, i64 0, i64 0))
%46 = load i32, i32* @stderr
%47 = tail call i32 (i32, i8*, ...) @fprintf(i32 %46, i8* getelementptr inbounds ([72 x i8], [72 x i8]* @.str.2, i64 0, i64 0))
%48 = load i32, i32* @stderr
%49 = tail call i32 (i32, i8*, ...) @fprintf(i32 %48, i8* getelementptr inbounds ([235 x i8], [235 x i8]* @.str.3, i64 0, i64 0))
%50 = tail call i32 @exit(i32 0)
unreachable
51: ; preds = %2
%52 = getelementptr inbounds i8*, i8** %1, i64 2
%53 = load i8*, i8** %52
%54 = call i32 @read_arcinfo_grid(i8* %53, double** %8, double** %9, i32* %18, i32* %19, double* %13, double* %14, double* %15, i32* %20, double** %7)
%55 = getelementptr inbounds i8*, i8** %1, i64 1
%56 = load i8*, i8** %55
%57 = call i32 @read_arcinfo_grid(i8* %56, double** %5, double** %6, i32* %16, i32* %17, double* %10, double* %11, double* %12, i32* %20, double** %4)
%58 = icmp sgt i32 %54, 0
br i1 %58, label %61, label %59
59: ; preds = %51
%60 = load double*, double** %7
br label %335
61: ; preds = %51
%62 = icmp sgt i32 %57, 0
%63 = sext i32 %57 to i64
%64 = zext i32 %54 to i64
br label %65
65: ; preds = %61, %331
%66 = phi i64 [ 0, %61 ], [ %333, %331 ]
br i1 %62, label %67, label %326
67: ; preds = %65, %252
%68 = phi i64 [ %254, %252 ], [ 0, %65 ]
%69 = phi i32 [ %253, %252 ], [ 0, %65 ]
%70 = load double*, double** %5
%71 = getelementptr inbounds double, double* %70, i64 %68
%72 = load double, double* %71
%73 = call double @pow(i32 10, i32 4)
%74 = fmul double %72, %73
%75 = call i64 @rint(double %74)
%76 = load double*, double** %8
%77 = getelementptr inbounds double, double* %76, i64 %66
%78 = load double, double* %77
%79 = load double, double* %12
%80 = fmul double %79, 5.000000e-01
%81 = fadd double %78, %80
%82 = call double @pow(i32 10, i32 4)
%83 = fmul double %82, %81
%84 = call i64 @rint(double %83)
%85 = icmp eq i64 %75, %84
br i1 %85, label %86, label %114
86: ; preds = %67
%87 = load double*, double** %6
%88 = getelementptr inbounds double, double* %87, i64 %68
%89 = load double, double* %88
%90 = call double @pow(i32 10, i32 4)
%91 = fmul double %89, %90
%92 = call i64 @rint(double %91)
%93 = load double*, double** %9
%94 = getelementptr inbounds double, double* %93, i64 %66
%95 = load double, double* %94
%96 = load double, double* %12
%97 = fmul double %96, 5.000000e-01
%98 = fadd double %95, %97
%99 = call double @pow(i32 10, i32 4)
%100 = fmul double %99, %98
%101 = call i64 @rint(double %100)
%102 = icmp eq i64 %92, %101
br i1 %102, label %103, label %114
103: ; preds = %86
%104 = load double*, double** %4
%105 = getelementptr inbounds double, double* %104, i64 %68
%106 = load double, double* %105
%107 = load i32, i32* %20
%108 = sitofp i32 %107 to double
%109 = fcmp une double %106, %108
br i1 %109, label %110, label %114
110: ; preds = %103
%111 = sext i32 %69 to i64
%112 = getelementptr inbounds [4 x double], [4 x double]* %3, i64 0, i64 %111
store double %106, double* %112
%113 = add nsw i32 %69, 1
br label %114
114: ; preds = %103, %110, %86, %67
%115 = phi i32 [ %113, %110 ], [ %69, %103 ], [ %69, %86 ], [ %69, %67 ]
%116 = load double*, double** %5
%117 = getelementptr inbounds double, double* %116, i64 %68
%118 = load double, double* %117
%119 = call double @pow(i32 10, i32 4)
%120 = fmul double %118, %119
%121 = call i64 @rint(double %120)
%122 = load double*, double** %8
%123 = getelementptr inbounds double, double* %122, i64 %66
%124 = load double, double* %123
%125 = load double, double* %12
%126 = fmul double %125, 5.000000e-01
%127 = fsub double %124, %126
%128 = call double @pow(i32 10, i32 4)
%129 = fmul double %128, %127
%130 = call i64 @rint(double %129)
%131 = icmp eq i64 %121, %130
br i1 %131, label %132, label %160
132: ; preds = %114
%133 = load double*, double** %6
%134 = getelementptr inbounds double, double* %133, i64 %68
%135 = load double, double* %134
%136 = call double @pow(i32 10, i32 4)
%137 = fmul double %135, %136
%138 = call i64 @rint(double %137)
%139 = load double*, double** %9
%140 = getelementptr inbounds double, double* %139, i64 %66
%141 = load double, double* %140
%142 = load double, double* %12
%143 = fmul double %142, 5.000000e-01
%144 = fadd double %141, %143
%145 = call double @pow(i32 10, i32 4)
%146 = fmul double %145, %144
%147 = call i64 @rint(double %146)
%148 = icmp eq i64 %138, %147
br i1 %148, label %149, label %160
149: ; preds = %132
%150 = load double*, double** %4
%151 = getelementptr inbounds double, double* %150, i64 %68
%152 = load double, double* %151
%153 = load i32, i32* %20
%154 = sitofp i32 %153 to double
%155 = fcmp une double %152, %154
br i1 %155, label %156, label %160
156: ; preds = %149
%157 = sext i32 %115 to i64
%158 = getelementptr inbounds [4 x double], [4 x double]* %3, i64 0, i64 %157
store double %152, double* %158
%159 = add nsw i32 %115, 1
br label %160
160: ; preds = %149, %156, %132, %114
%161 = phi i32 [ %159, %156 ], [ %115, %149 ], [ %115, %132 ], [ %115, %114 ]
%162 = load double*, double** %5
%163 = getelementptr inbounds double, double* %162, i64 %68
%164 = load double, double* %163
%165 = call double @pow(i32 10, i32 4)
%166 = fmul double %164, %165
%167 = call i64 @rint(double %166)
%168 = load double*, double** %8
%169 = getelementptr inbounds double, double* %168, i64 %66
%170 = load double, double* %169
%171 = load double, double* %12
%172 = fmul double %171, 5.000000e-01
%173 = fadd double %170, %172
%174 = call double @pow(i32 10, i32 4)
%175 = fmul double %174, %173
%176 = call i64 @rint(double %175)
%177 = icmp eq i64 %167, %176
br i1 %177, label %178, label %206
178: ; preds = %160
%179 = load double*, double** %6
%180 = getelementptr inbounds double, double* %179, i64 %68
%181 = load double, double* %180
%182 = call double @pow(i32 10, i32 4)
%183 = fmul double %181, %182
%184 = call i64 @rint(double %183)
%185 = load double*, double** %9
%186 = getelementptr inbounds double, double* %185, i64 %66
%187 = load double, double* %186
%188 = load double, double* %12
%189 = fmul double %188, 5.000000e-01
%190 = fsub double %187, %189
%191 = call double @pow(i32 10, i32 4)
%192 = fmul double %191, %190
%193 = call i64 @rint(double %192)
%194 = icmp eq i64 %184, %193
br i1 %194, label %195, label %206
195: ; preds = %178
%196 = load double*, double** %4
%197 = getelementptr inbounds double, double* %196, i64 %68
%198 = load double, double* %197
%199 = load i32, i32* %20
%200 = sitofp i32 %199 to double
%201 = fcmp une double %198, %200
br i1 %201, label %202, label %206
202: ; preds = %195
%203 = sext i32 %161 to i64
%204 = getelementptr inbounds [4 x double], [4 x double]* %3, i64 0, i64 %203
store double %198, double* %204
%205 = add nsw i32 %161, 1
br label %206
206: ; preds = %195, %202, %178, %160
%207 = phi i32 [ %205, %202 ], [ %161, %195 ], [ %161, %178 ], [ %161, %160 ]
%208 = load double*, double** %5
%209 = getelementptr inbounds double, double* %208, i64 %68
%210 = load double, double* %209
%211 = call double @pow(i32 10, i32 4)
%212 = fmul double %210, %211
%213 = call i64 @rint(double %212)
%214 = load double*, double** %8
%215 = getelementptr inbounds double, double* %214, i64 %66
%216 = load double, double* %215
%217 = load double, double* %12
%218 = fmul double %217, 5.000000e-01
%219 = fsub double %216, %218
%220 = call double @pow(i32 10, i32 4)
%221 = fmul double %220, %219
%222 = call i64 @rint(double %221)
%223 = icmp eq i64 %213, %222
br i1 %223, label %224, label %252
224: ; preds = %206
%225 = load double*, double** %6
%226 = getelementptr inbounds double, double* %225, i64 %68
%227 = load double, double* %226
%228 = call double @pow(i32 10, i32 4)
%229 = fmul double %227, %228
%230 = call i64 @rint(double %229)
%231 = load double*, double** %9
%232 = getelementptr inbounds double, double* %231, i64 %66
%233 = load double, double* %232
%234 = load double, double* %12
%235 = fmul double %234, 5.000000e-01
%236 = fsub double %233, %235
%237 = call double @pow(i32 10, i32 4)
%238 = fmul double %237, %236
%239 = call i64 @rint(double %238)
%240 = icmp eq i64 %230, %239
br i1 %240, label %241, label %252
241: ; preds = %224
%242 = load double*, double** %4
%243 = getelementptr inbounds double, double* %242, i64 %68
%244 = load double, double* %243
%245 = load i32, i32* %20
%246 = sitofp i32 %245 to double
%247 = fcmp une double %244, %246
br i1 %247, label %248, label %252
248: ; preds = %241
%249 = sext i32 %207 to i64
%250 = getelementptr inbounds [4 x double], [4 x double]* %3, i64 0, i64 %249
store double %244, double* %250
%251 = add nsw i32 %207, 1
br label %252
252: ; preds = %241, %248, %224, %206
%253 = phi i32 [ %251, %248 ], [ %207, %241 ], [ %207, %224 ], [ %207, %206 ]
%254 = add nuw nsw i64 %68, 1
%255 = icmp slt i64 %254, %63
%256 = icmp slt i32 %253, 4
%257 = select i1 %255, i1 %256, i1 false
br i1 %257, label %67, label %258
258: ; preds = %252
%259 = icmp sgt i32 %253, 0
br i1 %259, label %260, label %326
260: ; preds = %258
%261 = load double*, double** %7
%262 = getelementptr inbounds double, double* %261, i64 %66
%263 = zext i32 %253 to i64
%264 = add nsw i64 %263, -1
%265 = and i64 %263, 7
%266 = icmp ult i64 %264, 7
br i1 %266, label %307, label %267
267: ; preds = %260
%268 = and i64 %263, 4294967288
br label %269
269: ; preds = %269, %267
%270 = phi i64 [ 0, %267 ], [ %304, %269 ]
%271 = phi double [ 0.000000e+00, %267 ], [ %303, %269 ]
%272 = phi i64 [ 0, %267 ], [ %305, %269 ]
%273 = getelementptr inbounds [4 x double], [4 x double]* %3, i64 0, i64 %270
%274 = load double, double* %273
%275 = fadd double %274, %271
%276 = or i64 %270, 1
%277 = getelementptr inbounds [4 x double], [4 x double]* %3, i64 0, i64 %276
%278 = load double, double* %277
%279 = fadd double %278, %275
%280 = or i64 %270, 2
%281 = getelementptr inbounds [4 x double], [4 x double]* %3, i64 0, i64 %280
%282 = load double, double* %281
%283 = fadd double %282, %279
%284 = or i64 %270, 3
%285 = getelementptr inbounds [4 x double], [4 x double]* %3, i64 0, i64 %284
%286 = load double, double* %285
%287 = fadd double %286, %283
%288 = or i64 %270, 4
%289 = getelementptr inbounds [4 x double], [4 x double]* %3, i64 0, i64 %288
%290 = load double, double* %289
%291 = fadd double %290, %287
%292 = or i64 %270, 5
%293 = getelementptr inbounds [4 x double], [4 x double]* %3, i64 0, i64 %292
%294 = load double, double* %293
%295 = fadd double %294, %291
%296 = or i64 %270, 6
%297 = getelementptr inbounds [4 x double], [4 x double]* %3, i64 0, i64 %296
%298 = load double, double* %297
%299 = fadd double %298, %295
%300 = or i64 %270, 7
%301 = getelementptr inbounds [4 x double], [4 x double]* %3, i64 0, i64 %300
%302 = load double, double* %301
%303 = fadd double %302, %299
%304 = add nuw nsw i64 %270, 8
%305 = add i64 %272, 8
%306 = icmp eq i64 %305, %268
br i1 %306, label %307, label %269
307: ; preds = %269, %260
%308 = phi double [ undef, %260 ], [ %303, %269 ]
%309 = phi i64 [ 0, %260 ], [ %304, %269 ]
%310 = phi double [ 0.000000e+00, %260 ], [ %303, %269 ]
%311 = icmp eq i64 %265, 0
br i1 %311, label %322, label %312
312: ; preds = %307, %312
%313 = phi i64 [ %319, %312 ], [ %309, %307 ]
%314 = phi double [ %318, %312 ], [ %310, %307 ]
%315 = phi i64 [ %320, %312 ], [ 0, %307 ]
%316 = getelementptr inbounds [4 x double], [4 x double]* %3, i64 0, i64 %313
%317 = load double, double* %316
%318 = fadd double %317, %314
%319 = add nuw nsw i64 %313, 1
%320 = add i64 %315, 1
%321 = icmp eq i64 %320, %265
br i1 %321, label %322, label %312
322: ; preds = %312, %307
%323 = phi double [ %308, %307 ], [ %318, %312 ]
%324 = sitofp i32 %253 to double
%325 = fdiv double %323, %324
store double %325, double* %262
br label %331
326: ; preds = %65, %258
%327 = load i32, i32* %20
%328 = sitofp i32 %327 to double
%329 = load double*, double** %7
%330 = getelementptr inbounds double, double* %329, i64 %66
store double %328, double* %330
br label %331
331: ; preds = %322, %326
%332 = phi double* [ %261, %322 ], [ %329, %326 ]
%333 = add nuw nsw i64 %66, 1
%334 = icmp eq i64 %333, %64
br i1 %334, label %335, label %65
335: ; preds = %331, %59
%336 = phi double* [ %60, %59 ], [ %332, %331 ]
%337 = getelementptr inbounds i8*, i8** %1, i64 3
%338 = load i8*, i8** %337
%339 = load double*, double** %8
%340 = load double*, double** %9
%341 = load i32, i32* %18
%342 = load i32, i32* %19
%343 = load double, double* %13
%344 = load double, double* %14
%345 = load double, double* %15
%346 = load i32, i32* %20
%347 = call i32 @write_arcinfo_grid(i8* %338, double* %336, double* %339, double* %340, i32 %341, i32 %342, double %343, double %344, double %345, i32 %346, i32 %54)
ret i32 0
}