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

/* Forward declarations */

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

/* Variables and functions */
int /*<<< orphan*/ exit(int);
float fabs(float);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ printf(char *, int, float, float, float, float, float, float,
                          int);
long rd_grib_msg(int /*<<< orphan*/ *, long, unsigned char **, unsigned char **,
                 unsigned char **, unsigned char **);
float sqrt(float);
int /*<<< orphan*/ stderr;
int unpk_bds(float *, unsigned char *, unsigned char *, unsigned char *,
             unsigned char *, int);
int main(int argc, char **argv) {
  long int len_grib, pos1, pos2;
  unsigned char *pds, *gds, *bms, *bds;
  FILE *input1, *input2;
  int i, count, nxny1, nxny2, n, ndiff;
  float array1[100000], array2[100000], maxerr, err, rms_err;
  float minx, maxx;
  if (argc != 3) {
    fprintf(stderr, "%s [gribfile1] [gribfile2]\n", argv[0]);
    exit(8);
  }
  if ((input1 = fopen(argv[1], "rb")) == NULL) {
    fprintf(stderr, "could not open file: %s\n", argv[1]);
    exit(7);
  }
  if ((input2 = fopen(argv[2], "rb")) == NULL) {
    fprintf(stderr, "could not open file: %s\n", argv[2]);
    exit(7);
  }
  pos1 = pos2 = 0;
  for (count = 1;; count++) {
    len_grib = rd_grib_msg(input1, pos1, &pds, &gds, &bms, &bds);
    if (len_grib <= 0)
      break;
    nxny1 = unpk_bds(array1, pds, gds, bms, bds, 100000);
    pos1 += len_grib;
    if (nxny1 == -1) {
      fprintf(stderr, "array too small\n");
      exit(8);
    }
    len_grib = rd_grib_msg(input2, pos2, &pds, &gds, &bms, &bds);
    if (len_grib <= 0)
      break;
    nxny2 = unpk_bds(array2, pds, gds, bms, bds, 100000);
    pos2 += len_grib;
    if (nxny2 == -1) {
      fprintf(stderr, "array too small\n");
      exit(8);
    }
    if (nxny2 != nxny1) {
      fprintf(stderr, "nxny1 != nxny2\n");
      exit(8);
    }
    rms_err = maxerr = 0.0;
    minx = maxx = array1[0];
    ndiff = 0;
    for (n = i = 0; i < nxny1; i++) {
      if (!((array1[i]) >= 9.9989e20 && (array1[i]) <= 9.9991e20) &&
          !((array2[i]) >= 9.9989e20 && (array2[i]) <= 9.9991e20)) {
        if (n == 0) {
          minx = maxx = array1[i];
        }
        if (minx > array1[i])
          minx = array1[i];
        if (maxx < array1[i])
          maxx = array1[i];
        err = fabs(array1[i] - array2[i]);
        if (err > maxerr)
          maxerr = err;
        rms_err += err * err;
        n++;
        if (array1[i] != array2[i])
          ndiff++;
      }
    }
    if (maxerr != 0)
      printf(
          "%d: max %g rms %g scaled max %g scaled rms %g m/m %g/%g ndiff %d\n",
          count, maxerr, sqrt(rms_err / n), maxerr / (maxx - minx),
          sqrt(rms_err / n) / (maxx - minx), minx, maxx, ndiff);
  }
  fclose(input1);
  fclose(input2);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xc35a0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x3,-0x8(%rbp)
je     11db <main+0x4b>
mov    0x2e26(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe46(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    $0x8,%edi
call   10b0 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe42(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0x50(%rbp)
cmp    $0x0,%rax
jne    1226 <main+0x96>
mov    0x2ddc(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdx
lea    0xe1a(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    $0x7,%edi
call   10b0 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xdf7(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0x58(%rbp)
cmp    $0x0,%rax
jne    1271 <main+0xe1>
mov    0x2d91(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdx
lea    0xdcf(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    $0x7,%edi
call   10b0 <exit@plt>
movq   $0x0,-0x28(%rbp)
movq   $0x0,-0x20(%rbp)
movl   $0x1,-0x60(%rbp)
mov    -0x50(%rbp),%rdi
mov    -0x20(%rbp),%rsi
lea    -0x30(%rbp),%rdx
lea    -0x38(%rbp),%rcx
lea    -0x40(%rbp),%r8
lea    -0x48(%rbp),%r9
call   1080 <rd_grib_msg@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jg     12b9 <main+0x129>
jmp    16f2 <main+0x562>
lea    -0x61af0(%rbp),%rdi
mov    -0x30(%rbp),%rsi
mov    -0x38(%rbp),%rdx
mov    -0x40(%rbp),%rcx
mov    -0x48(%rbp),%r8
mov    $0x186a0,%r9d
call   1040 <unpk_bds@plt>
mov    %eax,-0x64(%rbp)
mov    -0x18(%rbp),%rax
add    -0x20(%rbp),%rax
mov    %rax,-0x20(%rbp)
cmpl   $0xffffffff,-0x64(%rbp)
jne    1315 <main+0x185>
mov    0x2ce5(%rip),%rax
mov    (%rax),%edi
lea    0xd44(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    $0x8,%edi
call   10b0 <exit@plt>
mov    -0x58(%rbp),%rdi
mov    -0x28(%rbp),%rsi
lea    -0x30(%rbp),%rdx
lea    -0x38(%rbp),%rcx
lea    -0x40(%rbp),%r8
lea    -0x48(%rbp),%r9
call   1080 <rd_grib_msg@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jg     1346 <main+0x1b6>
jmp    16f2 <main+0x562>
lea    -0xc3570(%rbp),%rdi
mov    -0x30(%rbp),%rsi
mov    -0x38(%rbp),%rdx
mov    -0x40(%rbp),%rcx
mov    -0x48(%rbp),%r8
mov    $0x186a0,%r9d
call   1040 <unpk_bds@plt>
mov    %eax,-0x68(%rbp)
mov    -0x18(%rbp),%rax
add    -0x28(%rbp),%rax
mov    %rax,-0x28(%rbp)
cmpl   $0xffffffff,-0x68(%rbp)
jne    13a2 <main+0x212>
mov    0x2c58(%rip),%rax
mov    (%rax),%edi
lea    0xcb7(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    $0x8,%edi
call   10b0 <exit@plt>
mov    -0x68(%rbp),%eax
cmp    -0x64(%rbp),%eax
je     13cf <main+0x23f>
mov    0x2c2b(%rip),%rax
mov    (%rax),%edi
lea    0xc9b(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    $0x8,%edi
call   10b0 <exit@plt>
xorps  %xmm0,%xmm0
movss  %xmm0,-0xc3574(%rbp)
ff
xorps  %xmm0,%xmm0
movss  %xmm0,-0xc357c(%rbp)
ff
movss  -0x61af0(%rbp),%xmm0
ff
movss  %xmm0,-0xc3584(%rbp)
ff
movss  %xmm0,-0xc3580(%rbp)
ff
movl   $0x0,-0x70(%rbp)
movl   $0x0,-0x5c(%rbp)
movl   $0x0,-0x6c(%rbp)
mov    -0x5c(%rbp),%eax
cmp    -0x64(%rbp),%eax
jge    15fb <main+0x46b>
movslq -0x5c(%rbp),%rax
movss  -0x61af0(%rbp,%rax,4),%xmm0
f9 ff
cvtss2sd %xmm0,%xmm0
movsd  0xbc9(%rip),%xmm1
ucomisd %xmm1,%xmm0
jb     1464 <main+0x2d4>
movslq -0x5c(%rbp),%rax
movss  -0x61af0(%rbp,%rax,4),%xmm0
f9 ff
cvtss2sd %xmm0,%xmm1
movsd  0xbae(%rip),%xmm0
ucomisd %xmm1,%xmm0
jae    15e8 <main+0x458>
movslq -0x5c(%rbp),%rax
movss  -0xc3570(%rbp,%rax,4),%xmm0
f3 ff
cvtss2sd %xmm0,%xmm0
movsd  0xb83(%rip),%xmm1
ucomisd %xmm1,%xmm0
jb     14aa <main+0x31a>
movslq -0x5c(%rbp),%rax
movss  -0xc3570(%rbp,%rax,4),%xmm0
f3 ff
cvtss2sd %xmm0,%xmm1
movsd  0xb68(%rip),%xmm0
ucomisd %xmm1,%xmm0
jae    15e8 <main+0x458>
cmpl   $0x0,-0x6c(%rbp)
jne    14d1 <main+0x341>
movslq -0x5c(%rbp),%rax
movss  -0x61af0(%rbp,%rax,4),%xmm0
f9 ff
movss  %xmm0,-0xc3584(%rbp)
ff
movss  %xmm0,-0xc3580(%rbp)
ff
movss  -0xc3580(%rbp),%xmm0
ff
movslq -0x5c(%rbp),%rax
ucomiss -0x61af0(%rbp,%rax,4),%xmm0
ff
jbe    1500 <main+0x370>
movslq -0x5c(%rbp),%rax
movss  -0x61af0(%rbp,%rax,4),%xmm0
f9 ff
movss  %xmm0,-0xc3580(%rbp)
ff
movss  -0xc3584(%rbp),%xmm1
ff
movslq -0x5c(%rbp),%rax
movss  -0x61af0(%rbp,%rax,4),%xmm0
f9 ff
ucomiss %xmm1,%xmm0
jbe    1533 <main+0x3a3>
movslq -0x5c(%rbp),%rax
movss  -0x61af0(%rbp,%rax,4),%xmm0
f9 ff
movss  %xmm0,-0xc3584(%rbp)
ff
movslq -0x5c(%rbp),%rax
movss  -0x61af0(%rbp,%rax,4),%xmm0
f9 ff
movslq -0x5c(%rbp),%rax
subss  -0xc3570(%rbp,%rax,4),%xmm0
f3 ff
call   1060 <fabs@plt>
movss  %xmm0,-0xc3578(%rbp)
ff
movss  -0xc3578(%rbp),%xmm0
ff
ucomiss -0xc3574(%rbp),%xmm0
jbe    157f <main+0x3ef>
movss  -0xc3578(%rbp),%xmm0
ff
movss  %xmm0,-0xc3574(%rbp)
ff
movss  -0xc3578(%rbp),%xmm0
ff
movss  -0xc3578(%rbp),%xmm2
ff
movss  -0xc357c(%rbp),%xmm1
ff
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
movss  %xmm0,-0xc357c(%rbp)
ff
mov    -0x6c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x6c(%rbp)
movslq -0x5c(%rbp),%rax
movss  -0x61af0(%rbp,%rax,4),%xmm0
f9 ff
movslq -0x5c(%rbp),%rax
ucomiss -0xc3570(%rbp,%rax,4),%xmm0
ff
jne    15da <main+0x44a>
jp     15da <main+0x44a>
jmp    15e3 <main+0x453>
mov    -0x70(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x70(%rbp)
jmp    15e8 <main+0x458>
jmp    15ed <main+0x45d>
mov    -0x5c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x5c(%rbp)
jmp    1412 <main+0x282>
movss  -0xc3574(%rbp),%xmm0
ff
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
jne    161a <main+0x48a>
jp     161a <main+0x48a>
jmp    16df <main+0x54f>
mov    -0x60(%rbp),%eax
mov    %eax,-0xc3594(%rbp)
movss  -0xc3574(%rbp),%xmm0
ff
movss  %xmm0,-0xc3588(%rbp)
ff
movss  -0xc357c(%rbp),%xmm0
ff
cvtsi2ssl -0x6c(%rbp),%xmm1
divss  %xmm1,%xmm0
call   10a0 <sqrt@plt>
movss  %xmm0,-0xc3590(%rbp)
ff
movss  -0xc3574(%rbp),%xmm0
ff
movss  -0xc3584(%rbp),%xmm1
ff
subss  -0xc3580(%rbp),%xmm1
ff
divss  %xmm1,%xmm0
movss  %xmm0,-0xc358c(%rbp)
ff
movss  -0xc357c(%rbp),%xmm0
ff
cvtsi2ssl -0x6c(%rbp),%xmm1
divss  %xmm1,%xmm0
call   10a0 <sqrt@plt>
mov    -0xc3594(%rbp),%esi
movss  -0xc3590(%rbp),%xmm1
ff
movss  -0xc358c(%rbp),%xmm2
ff
movaps %xmm0,%xmm3
movss  -0xc3588(%rbp),%xmm0
ff
movss  -0xc3584(%rbp),%xmm4
ff
subss  -0xc3580(%rbp),%xmm4
ff
divss  %xmm4,%xmm3
movss  -0xc3580(%rbp),%xmm4
ff
movss  -0xc3584(%rbp),%xmm5
ff
mov    -0x70(%rbp),%edx
lea    0x98f(%rip),%rdi
call   1050 <printf@plt>
jmp    16e4 <main+0x554>
mov    -0x60(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x60(%rbp)
jmp    1288 <main+0xf8>
mov    -0x50(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x58(%rbp),%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
add    $0xc35a0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0xc3568,%rsp
mov    %rsi,%rbx
cmp    $0x3,%edi
jne    14d5 <main+0x355>
mov    0x8(%rbx),%rdi
lea    0xe98(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,0x20(%rsp)
test   %rax,%rax
je     14f9 <main+0x379>
mov    0x10(%rbx),%rdi
lea    0xe7a(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,0x38(%rsp)
test   %rax,%rax
je     1508 <main+0x388>
lea    0x18(%rsp),%rdx
lea    0x10(%rsp),%rcx
lea    0x8(%rsp),%r8
mov    %rsp,%r9
mov    0x20(%rsp),%rdi
xor    %esi,%esi
call   1070 <rd_grib_msg@plt>
test   %rax,%rax
jle    147a <main+0x2fa>
mov    %rax,%r14
mov    $0x1,%r15d
xor    %ebx,%ebx
xor    %r13d,%r13d
jmp    1277 <main+0xf7>
movss  0x34(%rsp),%xmm5
movaps %xmm5,%xmm6
movss  0x30(%rsp),%xmm4
subss  %xmm4,%xmm6
movaps 0x50(%rsp),%xmm0
movaps %xmm0,%xmm2
divss  %xmm6,%xmm2
divss  %xmm6,%xmm3
lea    0xe43(%rip),%rdi
mov    %r15d,%esi
mov    %r14d,%edx
call   1050 <printf@plt>
add    %r12,%r13
add    $0x1,%r15d
mov    0x20(%rsp),%rdi
mov    %rbx,%rsi
lea    0x18(%rsp),%rdx
lea    0x10(%rsp),%rcx
lea    0x8(%rsp),%r8
mov    %rsp,%r9
call   1070 <rd_grib_msg@plt>
mov    %rax,%r14
test   %rax,%rax
jle    147a <main+0x2fa>
mov    0x18(%rsp),%rsi
mov    0x10(%rsp),%rdx
mov    0x8(%rsp),%rcx
mov    (%rsp),%r8
lea    0x60(%rsp),%rdi
mov    $0x186a0,%r9d
call   1040 <unpk_bds@plt>
cmp    $0xffffffff,%eax
je     14a2 <main+0x322>
mov    %eax,%ebp
mov    0x38(%rsp),%rdi
mov    %r13,%rsi
lea    0x18(%rsp),%rdx
lea    0x10(%rsp),%rcx
lea    0x8(%rsp),%r8
mov    %rsp,%r9
call   1070 <rd_grib_msg@plt>
test   %rax,%rax
jle    147a <main+0x2fa>
mov    %rax,%r12
mov    0x18(%rsp),%rsi
mov    0x10(%rsp),%rdx
mov    0x8(%rsp),%rcx
mov    (%rsp),%r8
lea    0x61ae0(%rsp),%rdi
mov    $0x186a0,%r9d
call   1040 <unpk_bds@plt>
cmp    $0xffffffff,%eax
je     14a2 <main+0x322>
cmp    %ebp,%eax
jne    14b4 <main+0x334>
add    %r14,%rbx
test   %ebp,%ebp
jle    1245 <main+0xc5>
movss  0x60(%rsp),%xmm0
mov    %ebp,%eax
add    $0xffffffffffffffff,%rax
xor    %ecx,%ecx
xorps  %xmm1,%xmm1
movaps %xmm0,%xmm9
movaps %xmm0,%xmm10
xorps  %xmm2,%xmm2
xor    %r14d,%r14d
xor    %edx,%edx
movsd  0xcc5(%rip),%xmm6
movaps 0xccd(%rip),%xmm8
movsd  0xcbd(%rip),%xmm7
nopl   0x0(%rax,%rax,1)
xorps  %xmm3,%xmm3
cvtss2sd %xmm0,%xmm3
ucomisd %xmm6,%xmm3
jb     1363 <main+0x1e3>
ucomisd %xmm3,%xmm7
jae    137f <main+0x1ff>
movss  0x61ae0(%rsp,%rcx,4),%xmm3
xorps  %xmm4,%xmm4
cvtss2sd %xmm3,%xmm4
ucomisd %xmm6,%xmm4
jb     13a0 <main+0x220>
ucomisd %xmm4,%xmm7
jb     13a0 <main+0x220>
movaps %xmm2,%xmm4
movaps %xmm1,%xmm5
cmp    %rcx,%rax
je     13f0 <main+0x270>
movss  0x64(%rsp,%rcx,4),%xmm0
add    $0x1,%rcx
movaps %xmm5,%xmm1
movaps %xmm4,%xmm2
jmp    1350 <main+0x1d0>
nopl   0x0(%rax)
movaps %xmm0,%xmm4
movaps %xmm0,%xmm5
test   %edx,%edx
je     13b2 <main+0x232>
movaps %xmm10,%xmm4
movaps %xmm9,%xmm5
movaps %xmm0,%xmm10
minss  %xmm4,%xmm10
movaps %xmm0,%xmm9
maxss  %xmm5,%xmm9
movaps %xmm0,%xmm5
subss  %xmm3,%xmm5
movaps %xmm5,%xmm4
andps  %xmm8,%xmm4
maxss  %xmm2,%xmm4
mulss  %xmm5,%xmm5
addss  %xmm1,%xmm5
add    $0x1,%edx
ucomiss %xmm3,%xmm0
jne    13e8 <main+0x268>
jnp    1385 <main+0x205>
add    $0x1,%r14d
jmp    1385 <main+0x205>
xchg   %ax,%ax
ucomiss 0xc29(%rip),%xmm4
jne    13ff <main+0x27f>
jnp    1245 <main+0xc5>
movaps %xmm4,0x50(%rsp)
movss  %xmm10,0x30(%rsp)
movss  %xmm9,0x34(%rsp)
xorps  %xmm0,%xmm0
cvtsi2ss %edx,%xmm0
divss  %xmm0,%xmm5
xorps  %xmm3,%xmm3
sqrtss %xmm5,%xmm3
ucomiss 0xbf5(%rip),%xmm5
movaps %xmm3,%xmm1
jae    1451 <main+0x2d1>
movaps %xmm5,%xmm0
movaps %xmm5,0x40(%rsp)
movss  %xmm3,0x2c(%rsp)
call   1090 <sqrt@plt>
movss  0x2c(%rsp),%xmm3
movaps 0x40(%rsp),%xmm5
movaps %xmm0,%xmm1
ucomiss 0xbc8(%rip),%xmm5
jae    1210 <main+0x90>
movaps %xmm5,%xmm0
movss  %xmm1,0x40(%rsp)
call   1090 <sqrt@plt>
movss  0x40(%rsp),%xmm1
movaps %xmm0,%xmm3
jmp    1210 <main+0x90>
mov    0x20(%rsp),%rdi
call   1030 <fclose@plt>
mov    0x38(%rsp),%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
add    $0xc3568,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2b37(%rip),%rax
mov    (%rax),%edi
lea    0xbaa(%rip),%rsi
jmp    14c4 <main+0x344>
mov    0x2b25(%rip),%rax
mov    (%rax),%edi
lea    0xba9(%rip),%rsi
xor    %eax,%eax
call   1060 <fprintf@plt>
mov    $0x8,%edi
call   10a0 <exit@plt>
mov    0x2b04(%rip),%rax
mov    (%rax),%edi
mov    (%rbx),%rdx
lea    0xb3c(%rip),%rsi
xor    %eax,%eax
call   1060 <fprintf@plt>
mov    $0x8,%edi
call   10a0 <exit@plt>
mov    0x2ae0(%rip),%rax
mov    (%rax),%edi
mov    0x8(%rbx),%rdx
jmp    1515 <main+0x395>
mov    0x2ad1(%rip),%rax
mov    (%rax),%edi
mov    0x10(%rbx),%rdx
lea    0xb27(%rip),%rsi
xor    %eax,%eax
call   1060 <fprintf@plt>
mov    $0x7,%edi
call   10a0 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [28 x i8] c"%s [gribfile1] [gribfile2]\0A\00"
@.str.1 = [3 x i8] c"rb\00"
@.str.2 = [25 x i8] c"could not open file: %s\0A\00"
@.str.3 = [17 x i8] c"array too small\0A\00"
@.str.4 = [16 x i8] c"nxny1 != nxny2\0A\00"
@.str.5 = [66 x i8] c"%d: max %g rms %g scaled max %g scaled rms %g m/m %g/%g ndiff %d\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i64
%7 = alloca i64
%8 = alloca i64
%9 = alloca i8*
%10 = alloca i8*
%11 = alloca i8*
%12 = alloca i8*
%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 [100000 x float]
%22 = alloca [100000 x float]
%23 = alloca float
%24 = alloca float
%25 = alloca float
%26 = alloca float
%27 = alloca float
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%28 = load i32, i32* %4
%29 = icmp ne i32 %28, 3
br i1 %29, label %30, label %37
30: ; preds = %2
%31 = load i32, i32* @stderr
%32 = load i8**, i8*** %5
%33 = getelementptr inbounds i8*, i8** %32, i64 0
%34 = load i8*, i8** %33
%35 = call i32 (i32, i8*, ...) @fprintf(i32 %31, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0), i8* %34)
%36 = call i32 @exit(i32 8)
unreachable
37: ; preds = %2
%38 = load i8**, i8*** %5
%39 = getelementptr inbounds i8*, i8** %38, i64 1
%40 = load i8*, i8** %39
%41 = call i32* @fopen(i8* %40, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
store i32* %41, i32** %13
%42 = icmp eq i32* %41, null
br i1 %42, label %43, label %50
43: ; preds = %37
%44 = load i32, i32* @stderr
%45 = load i8**, i8*** %5
%46 = getelementptr inbounds i8*, i8** %45, i64 1
%47 = load i8*, i8** %46
%48 = call i32 (i32, i8*, ...) @fprintf(i32 %44, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0), i8* %47)
%49 = call i32 @exit(i32 7)
unreachable
50: ; preds = %37
%51 = load i8**, i8*** %5
%52 = getelementptr inbounds i8*, i8** %51, i64 2
%53 = load i8*, i8** %52
%54 = call i32* @fopen(i8* %53, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
store i32* %54, i32** %14
%55 = icmp eq i32* %54, null
br i1 %55, label %56, label %63
56: ; preds = %50
%57 = load i32, i32* @stderr
%58 = load i8**, i8*** %5
%59 = getelementptr inbounds i8*, i8** %58, i64 2
%60 = load i8*, i8** %59
%61 = call i32 (i32, i8*, ...) @fprintf(i32 %57, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0), i8* %60)
%62 = call i32 @exit(i32 7)
unreachable
63: ; preds = %50
store i64 0, i64* %8
store i64 0, i64* %7
store i32 1, i32* %16
br label %64
64: ; preds = %255, %63
%65 = load i32*, i32** %13
%66 = load i64, i64* %7
%67 = call i64 @rd_grib_msg(i32* %65, i64 %66, i8** %9, i8** %10, i8** %11, i8** %12)
store i64 %67, i64* %6
%68 = load i64, i64* %6
%69 = icmp sle i64 %68, 0
br i1 %69, label %70, label %71
70: ; preds = %64
br label %258
71: ; preds = %64
%72 = getelementptr inbounds [100000 x float], [100000 x float]* %21, i64 0, i64 0
%73 = load i8*, i8** %9
%74 = load i8*, i8** %10
%75 = load i8*, i8** %11
%76 = load i8*, i8** %12
%77 = call i32 @unpk_bds(float* %72, i8* %73, i8* %74, i8* %75, i8* %76, i32 100000)
store i32 %77, i32* %17
%78 = load i64, i64* %6
%79 = load i64, i64* %7
%80 = add nsw i64 %79, %78
store i64 %80, i64* %7
%81 = load i32, i32* %17
%82 = icmp eq i32 %81, -1
br i1 %82, label %83, label %87
83: ; preds = %71
%84 = load i32, i32* @stderr
%85 = call i32 (i32, i8*, ...) @fprintf(i32 %84, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0))
%86 = call i32 @exit(i32 8)
unreachable
87: ; preds = %71
%88 = load i32*, i32** %14
%89 = load i64, i64* %8
%90 = call i64 @rd_grib_msg(i32* %88, i64 %89, i8** %9, i8** %10, i8** %11, i8** %12)
store i64 %90, i64* %6
%91 = load i64, i64* %6
%92 = icmp sle i64 %91, 0
br i1 %92, label %93, label %94
93: ; preds = %87
br label %258
94: ; preds = %87
%95 = getelementptr inbounds [100000 x float], [100000 x float]* %22, i64 0, i64 0
%96 = load i8*, i8** %9
%97 = load i8*, i8** %10
%98 = load i8*, i8** %11
%99 = load i8*, i8** %12
%100 = call i32 @unpk_bds(float* %95, i8* %96, i8* %97, i8* %98, i8* %99, i32 100000)
store i32 %100, i32* %18
%101 = load i64, i64* %6
%102 = load i64, i64* %8
%103 = add nsw i64 %102, %101
store i64 %103, i64* %8
%104 = load i32, i32* %18
%105 = icmp eq i32 %104, -1
br i1 %105, label %106, label %110
106: ; preds = %94
%107 = load i32, i32* @stderr
%108 = call i32 (i32, i8*, ...) @fprintf(i32 %107, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0))
%109 = call i32 @exit(i32 8)
unreachable
110: ; preds = %94
%111 = load i32, i32* %18
%112 = load i32, i32* %17
%113 = icmp ne i32 %111, %112
br i1 %113, label %114, label %118
114: ; preds = %110
%115 = load i32, i32* @stderr
%116 = call i32 (i32, i8*, ...) @fprintf(i32 %115, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.4, i64 0, i64 0))
%117 = call i32 @exit(i32 8)
unreachable
118: ; preds = %110
store float 0.000000e+00, float* %23
store float 0.000000e+00, float* %25
%119 = getelementptr inbounds [100000 x float], [100000 x float]* %21, i64 0, i64 0
%120 = load float, float* %119
store float %120, float* %27
store float %120, float* %26
store i32 0, i32* %20
store i32 0, i32* %15
store i32 0, i32* %19
br label %121
121: ; preds = %222, %118
%122 = load i32, i32* %15
%123 = load i32, i32* %17
%124 = icmp slt i32 %122, %123
br i1 %124, label %125, label %225
125: ; preds = %121
%126 = load i32, i32* %15
%127 = sext i32 %126 to i64
%128 = getelementptr inbounds [100000 x float], [100000 x float]* %21, i64 0, i64 %127
%129 = load float, float* %128
%130 = fpext float %129 to double
%131 = fcmp oge double %130, 0x444B1A2170AD88AA
br i1 %131, label %132, label %139
132: ; preds = %125
%133 = load i32, i32* %15
%134 = sext i32 %133 to i64
%135 = getelementptr inbounds [100000 x float], [100000 x float]* %21, i64 0, i64 %134
%136 = load float, float* %135
%137 = fpext float %136 to double
%138 = fcmp ole double %137, 9.999100e+20
br i1 %138, label %221, label %139
139: ; preds = %132, %125
%140 = load i32, i32* %15
%141 = sext i32 %140 to i64
%142 = getelementptr inbounds [100000 x float], [100000 x float]* %22, i64 0, i64 %141
%143 = load float, float* %142
%144 = fpext float %143 to double
%145 = fcmp oge double %144, 0x444B1A2170AD88AA
br i1 %145, label %146, label %153
146: ; preds = %139
%147 = load i32, i32* %15
%148 = sext i32 %147 to i64
%149 = getelementptr inbounds [100000 x float], [100000 x float]* %22, i64 0, i64 %148
%150 = load float, float* %149
%151 = fpext float %150 to double
%152 = fcmp ole double %151, 9.999100e+20
br i1 %152, label %221, label %153
153: ; preds = %146, %139
%154 = load i32, i32* %19
%155 = icmp eq i32 %154, 0
br i1 %155, label %156, label %161
156: ; preds = %153
%157 = load i32, i32* %15
%158 = sext i32 %157 to i64
%159 = getelementptr inbounds [100000 x float], [100000 x float]* %21, i64 0, i64 %158
%160 = load float, float* %159
store float %160, float* %27
store float %160, float* %26
br label %161
161: ; preds = %156, %153
%162 = load float, float* %26
%163 = load i32, i32* %15
%164 = sext i32 %163 to i64
%165 = getelementptr inbounds [100000 x float], [100000 x float]* %21, i64 0, i64 %164
%166 = load float, float* %165
%167 = fcmp ogt float %162, %166
br i1 %167, label %168, label %173
168: ; preds = %161
%169 = load i32, i32* %15
%170 = sext i32 %169 to i64
%171 = getelementptr inbounds [100000 x float], [100000 x float]* %21, i64 0, i64 %170
%172 = load float, float* %171
store float %172, float* %26
br label %173
173: ; preds = %168, %161
%174 = load float, float* %27
%175 = load i32, i32* %15
%176 = sext i32 %175 to i64
%177 = getelementptr inbounds [100000 x float], [100000 x float]* %21, i64 0, i64 %176
%178 = load float, float* %177
%179 = fcmp olt float %174, %178
br i1 %179, label %180, label %185
180: ; preds = %173
%181 = load i32, i32* %15
%182 = sext i32 %181 to i64
%183 = getelementptr inbounds [100000 x float], [100000 x float]* %21, i64 0, i64 %182
%184 = load float, float* %183
store float %184, float* %27
br label %185
185: ; preds = %180, %173
%186 = load i32, i32* %15
%187 = sext i32 %186 to i64
%188 = getelementptr inbounds [100000 x float], [100000 x float]* %21, i64 0, i64 %187
%189 = load float, float* %188
%190 = load i32, i32* %15
%191 = sext i32 %190 to i64
%192 = getelementptr inbounds [100000 x float], [100000 x float]* %22, i64 0, i64 %191
%193 = load float, float* %192
%194 = fsub float %189, %193
%195 = call float @fabs(float %194)
store float %195, float* %24
%196 = load float, float* %24
%197 = load float, float* %23
%198 = fcmp ogt float %196, %197
br i1 %198, label %199, label %201
199: ; preds = %185
%200 = load float, float* %24
store float %200, float* %23
br label %201
201: ; preds = %199, %185
%202 = load float, float* %24
%203 = load float, float* %24
%204 = load float, float* %25
%205 = call float @llvm.fmuladd.f32(float %202, float %203, float %204)
store float %205, float* %25
%206 = load i32, i32* %19
%207 = add nsw i32 %206, 1
store i32 %207, i32* %19
%208 = load i32, i32* %15
%209 = sext i32 %208 to i64
%210 = getelementptr inbounds [100000 x float], [100000 x float]* %21, i64 0, i64 %209
%211 = load float, float* %210
%212 = load i32, i32* %15
%213 = sext i32 %212 to i64
%214 = getelementptr inbounds [100000 x float], [100000 x float]* %22, i64 0, i64 %213
%215 = load float, float* %214
%216 = fcmp une float %211, %215
br i1 %216, label %217, label %220
217: ; preds = %201
%218 = load i32, i32* %20
%219 = add nsw i32 %218, 1
store i32 %219, i32* %20
br label %220
220: ; preds = %217, %201
br label %221
221: ; preds = %220, %146, %132
br label %222
222: ; preds = %221
%223 = load i32, i32* %15
%224 = add nsw i32 %223, 1
store i32 %224, i32* %15
br label %121
225: ; preds = %121
%226 = load float, float* %23
%227 = fcmp une float %226, 0.000000e+00
br i1 %227, label %228, label %254
228: ; preds = %225
%229 = load i32, i32* %16
%230 = load float, float* %23
%231 = load float, float* %25
%232 = load i32, i32* %19
%233 = sitofp i32 %232 to float
%234 = fdiv float %231, %233
%235 = call float @sqrt(float %234)
%236 = load float, float* %23
%237 = load float, float* %27
%238 = load float, float* %26
%239 = fsub float %237, %238
%240 = fdiv float %236, %239
%241 = load float, float* %25
%242 = load i32, i32* %19
%243 = sitofp i32 %242 to float
%244 = fdiv float %241, %243
%245 = call float @sqrt(float %244)
%246 = load float, float* %27
%247 = load float, float* %26
%248 = fsub float %246, %247
%249 = fdiv float %245, %248
%250 = load float, float* %26
%251 = load float, float* %27
%252 = load i32, i32* %20
%253 = call i32 @printf(i8* getelementptr inbounds ([66 x i8], [66 x i8]* @.str.5, i64 0, i64 0), i32 %229, float %230, float %235, float %240, float %249, float %250, float %251, i32 %252)
br label %254
254: ; preds = %228, %225
br label %255
255: ; preds = %254
%256 = load i32, i32* %16
%257 = add nsw i32 %256, 1
store i32 %257, i32* %16
br label %64
258: ; preds = %93, %70
%259 = load i32*, i32** %13
%260 = call i32 @fclose(i32* %259)
%261 = load i32*, i32** %14
%262 = call i32 @fclose(i32* %261)
ret i32 0
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [28 x i8] c"%s [gribfile1] [gribfile2]\0A\00"
@.str.1 = [3 x i8] c"rb\00"
@.str.2 = [25 x i8] c"could not open file: %s\0A\00"
@.str.3 = [17 x i8] c"array too small\0A\00"
@.str.4 = [16 x i8] c"nxny1 != nxny2\0A\00"
@.str.5 = [66 x i8] c"%d: max %g rms %g scaled max %g scaled rms %g m/m %g/%g ndiff %d\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca [100000 x float]
%8 = alloca [100000 x float]
%9 = bitcast i8** %3 to i8*
%10 = bitcast i8** %4 to i8*
%11 = bitcast i8** %5 to i8*
%12 = bitcast i8** %6 to i8*
%13 = bitcast [100000 x float]* %7 to i8*
%14 = bitcast [100000 x float]* %8 to i8*
%15 = icmp eq i32 %0, 3
br i1 %15, label %21, label %16
16: ; preds = %2
%17 = load i32, i32* @stderr
%18 = load i8*, i8** %1
%19 = tail call i32 (i32, i8*, ...) @fprintf(i32 %17, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0), i8* %18)
%20 = tail call i32 @exit(i32 8)
unreachable
21: ; preds = %2
%22 = getelementptr inbounds i8*, i8** %1, i64 1
%23 = load i8*, i8** %22
%24 = tail call i32* @fopen(i8* %23, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%25 = icmp eq i32* %24, null
br i1 %25, label %26, label %31
26: ; preds = %21
%27 = load i32, i32* @stderr
%28 = load i8*, i8** %22
%29 = tail call i32 (i32, i8*, ...) @fprintf(i32 %27, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0), i8* %28)
%30 = tail call i32 @exit(i32 7)
unreachable
31: ; preds = %21
%32 = getelementptr inbounds i8*, i8** %1, i64 2
%33 = load i8*, i8** %32
%34 = tail call i32* @fopen(i8* %33, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%35 = icmp eq i32* %34, null
br i1 %35, label %42, label %36
36: ; preds = %31
%37 = call i64 @rd_grib_msg(i32* %24, i64 0, i8** %3, i8** %4, i8** %5, i8** %6)
%38 = icmp slt i64 %37, 1
br i1 %38, label %153, label %39
39: ; preds = %36
%40 = getelementptr inbounds [100000 x float], [100000 x float]* %7, i64 0, i64 0
%41 = getelementptr inbounds [100000 x float], [100000 x float]* %8, i64 0, i64 0
br label %47
42: ; preds = %31
%43 = load i32, i32* @stderr
%44 = load i8*, i8** %32
%45 = tail call i32 (i32, i8*, ...) @fprintf(i32 %43, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0), i8* %44)
%46 = tail call i32 @exit(i32 7)
unreachable
47: ; preds = %39, %149
%48 = phi i64 [ %37, %39 ], [ %151, %149 ]
%49 = phi i64 [ 0, %39 ], [ %57, %149 ]
%50 = phi i64 [ 0, %39 ], [ %72, %149 ]
%51 = phi i32 [ 1, %39 ], [ %150, %149 ]
%52 = load i8*, i8** %3
%53 = load i8*, i8** %4
%54 = load i8*, i8** %5
%55 = load i8*, i8** %6
%56 = call i32 @unpk_bds(float* %40, i8* %52, i8* %53, i8* %54, i8* %55, i32 100000)
%57 = add nsw i64 %48, %49
%58 = icmp eq i32 %56, -1
br i1 %58, label %59, label %63
59: ; preds = %47
%60 = load i32, i32* @stderr
%61 = call i32 (i32, i8*, ...) @fprintf(i32 %60, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0))
%62 = call i32 @exit(i32 8)
unreachable
63: ; preds = %47
%64 = call i64 @rd_grib_msg(i32* %34, i64 %50, i8** %3, i8** %4, i8** %5, i8** %6)
%65 = icmp slt i64 %64, 1
br i1 %65, label %153, label %66
66: ; preds = %63
%67 = load i8*, i8** %3
%68 = load i8*, i8** %4
%69 = load i8*, i8** %5
%70 = load i8*, i8** %6
%71 = call i32 @unpk_bds(float* %41, i8* %67, i8* %68, i8* %69, i8* %70, i32 100000)
%72 = add nsw i64 %64, %50
%73 = icmp eq i32 %71, -1
br i1 %73, label %74, label %78
74: ; preds = %66
%75 = load i32, i32* @stderr
%76 = call i32 (i32, i8*, ...) @fprintf(i32 %75, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0))
%77 = call i32 @exit(i32 8)
unreachable
78: ; preds = %66
%79 = icmp eq i32 %71, %56
br i1 %79, label %84, label %80
80: ; preds = %78
%81 = load i32, i32* @stderr
%82 = call i32 (i32, i8*, ...) @fprintf(i32 %81, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.4, i64 0, i64 0))
%83 = call i32 @exit(i32 8)
unreachable
84: ; preds = %78
%85 = load float, float* %40
%86 = icmp sgt i32 %56, 0
br i1 %86, label %87, label %149
87: ; preds = %84
%88 = zext i32 %56 to i64
br label %89
89: ; preds = %135, %87
%90 = phi float [ %85, %87 ], [ %137, %135 ]
%91 = phi i64 [ 0, %87 ], [ %133, %135 ]
%92 = phi float [ %85, %87 ], [ %132, %135 ]
%93 = phi float [ %85, %87 ], [ %131, %135 ]
%94 = phi float [ 0.000000e+00, %87 ], [ %130, %135 ]
%95 = phi float [ 0.000000e+00, %87 ], [ %129, %135 ]
%96 = phi i32 [ 0, %87 ], [ %128, %135 ]
%97 = phi i32 [ 0, %87 ], [ %127, %135 ]
%98 = fpext float %90 to double
%99 = fcmp ult double %98, 0x444B1A2170AD88AA
%100 = fcmp ugt double %98, 9.999100e+20
%101 = or i1 %99, %100
br i1 %101, label %102, label %126
102: ; preds = %89
%103 = getelementptr inbounds [100000 x float], [100000 x float]* %8, i64 0, i64 %91
%104 = load float, float* %103
%105 = fpext float %104 to double
%106 = fcmp ult double %105, 0x444B1A2170AD88AA
%107 = fcmp ugt double %105, 9.999100e+20
%108 = or i1 %106, %107
br i1 %108, label %109, label %126
109: ; preds = %102
%110 = icmp eq i32 %97, 0
%111 = select i1 %110, float %90, float %93
%112 = select i1 %110, float %90, float %92
%113 = fcmp ogt float %111, %90
%114 = select i1 %113, float %90, float %111
%115 = fcmp olt float %112, %90
%116 = select i1 %115, float %90, float %112
%117 = fsub float %90, %104
%118 = call float @llvm.fabs.f32(float %117)
%119 = fcmp ogt float %118, %95
%120 = select i1 %119, float %118, float %95
%121 = call float @llvm.fmuladd.f32(float %117, float %117, float %94)
%122 = add nsw i32 %97, 1
%123 = fcmp une float %90, %104
br i1 %123, label %124, label %126
124: ; preds = %109
%125 = add nsw i32 %96, 1
br label %126
126: ; preds = %102, %89, %124, %109
%127 = phi i32 [ %122, %124 ], [ %122, %109 ], [ %97, %89 ], [ %97, %102 ]
%128 = phi i32 [ %125, %124 ], [ %96, %109 ], [ %96, %89 ], [ %96, %102 ]
%129 = phi float [ %120, %124 ], [ %120, %109 ], [ %95, %89 ], [ %95, %102 ]
%130 = phi float [ %121, %124 ], [ %121, %109 ], [ %94, %89 ], [ %94, %102 ]
%131 = phi float [ %114, %124 ], [ %114, %109 ], [ %93, %89 ], [ %93, %102 ]
%132 = phi float [ %116, %124 ], [ %116, %109 ], [ %92, %89 ], [ %92, %102 ]
%133 = add nuw nsw i64 %91, 1
%134 = icmp eq i64 %133, %88
br i1 %134, label %138, label %135
135: ; preds = %126
%136 = getelementptr inbounds [100000 x float], [100000 x float]* %7, i64 0, i64 %133
%137 = load float, float* %136
br label %89
138: ; preds = %126
%139 = fcmp une float %129, 0.000000e+00
br i1 %139, label %140, label %149
140: ; preds = %138
%141 = sitofp i32 %127 to float
%142 = fdiv float %130, %141
%143 = call float @sqrt(float %142)
%144 = fsub float %132, %131
%145 = fdiv float %129, %144
%146 = call float @sqrt(float %142)
%147 = fdiv float %146, %144
%148 = call i32 @printf(i8* getelementptr inbounds ([66 x i8], [66 x i8]* @.str.5, i64 0, i64 0), i32 %51, float %129, float %143, float %145, float %147, float %131, float %132, i32 %128)
br label %149
149: ; preds = %84, %138, %140
%150 = add nuw nsw i32 %51, 1
%151 = call i64 @rd_grib_msg(i32* %24, i64 %57, i8** %3, i8** %4, i8** %5, i8** %6)
%152 = icmp slt i64 %151, 1
br i1 %152, label %153, label %47
153: ; preds = %149, %63, %36
%154 = call i32 @fclose(i32* %24)
%155 = call i32 @fclose(i32* %34)
ret i32 0
}