#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*/ con1x1(float *, float *);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ free(unsigned char *);
unsigned char *gds_grid2();
unsigned char *mk_BDS(unsigned char *, float *, int);
long rd_grib_msg(int /*<<< orphan*/ *, long, unsigned char **, unsigned char **,
                 unsigned char **, unsigned char **);
int /*<<< orphan*/ set_PDSGridType(unsigned char *, int);
int /*<<< orphan*/ stderr;
int unpk_bds(float *, unsigned char *, unsigned char *, unsigned char *,
             unsigned char *, int);
int /*<<< orphan*/ wrt_grib_msg(int /*<<< orphan*/ *, unsigned char *,
                                unsigned char *, unsigned char *,
                                unsigned char *);
int main(int argc, char **argv) {
  long int len_grib, pos = 0;
  unsigned char *pds, *gds, *bms, *bds, *gds2;
  FILE *input, *output;
  int count, cnvt, nxny;
  float array[100000];
  float array25[144 * 73];
  if (argc != 3) {
    fprintf(stderr, "%s [in gribfile] [out gribfile]\n", argv[0]);
    exit(8);
  }
  if ((input = fopen(argv[1], "rb")) == NULL) {
    fprintf(stderr, "could not open file: %s\n", argv[1]);
    exit(7);
  }
  if ((output = fopen(argv[2], "wb")) == NULL) {
    fprintf(stderr, "could not open file: %s\n", argv[2]);
    exit(7);
  }
  gds2 = gds_grid2();
  pos = count = cnvt = 0;
  for (;;) {
    len_grib = rd_grib_msg(input, pos, &pds, &gds, &bms, &bds);
    if (len_grib <= 0)
      break;
    if ((pds[6]) == 3 && ((pds[7] & 64) != 0) == 0) {
      nxny = unpk_bds(array, pds, gds, bms, bds, 100000);
      if (nxny != 360 * 181) {
        fprintf(stderr, "unexpected grid size, record %d\n", count);
        exit(8);
      }
      con1x1(array, array25);
      set_PDSGridType(pds, 2);
      bds = mk_BDS(pds, array25, 144 * 73);
      wrt_grib_msg(output, pds, gds2, bms, bds);
      cnvt++;
      free(bds);
    } else {
      wrt_grib_msg(output, pds, gds, bms, bds);
    }
    pos += len_grib;
    count++;
  }
  fclose(output);
  fclose(input);
  fprintf(stderr, "converted %d records out of %d to 144x73\n", cnvt, count);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x6bf30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x20(%rbp)
cmpl   $0x3,-0x8(%rbp)
je     1213 <main+0x53>
mov    0x2dee(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xdfe(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    $0x8,%edi
call   10d0 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xdff(%rip),%rsi
call   10b0 <fopen@plt>
mov    %rax,-0x50(%rbp)
cmp    $0x0,%rax
jne    125e <main+0x9e>
mov    0x2da4(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdx
lea    0xdd7(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    $0x7,%edi
call   10d0 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xdd0(%rip),%rsi
call   10b0 <fopen@plt>
mov    %rax,-0x58(%rbp)
cmp    $0x0,%rax
jne    12a9 <main+0xe9>
mov    0x2d59(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdx
lea    0xd8c(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    $0x7,%edi
call   10d0 <exit@plt>
mov    $0x0,%al
call   10a0 <gds_grid2@plt>
mov    %rax,-0x48(%rbp)
movl   $0x0,-0x60(%rbp)
movl   $0x0,-0x5c(%rbp)
movq   $0x0,-0x20(%rbp)
mov    -0x50(%rbp),%rdi
mov    -0x20(%rbp),%rsi
lea    -0x28(%rbp),%rdx
lea    -0x30(%rbp),%rcx
lea    -0x38(%rbp),%r8
lea    -0x40(%rbp),%r9
call   1090 <rd_grib_msg@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jg     12fb <main+0x13b>
jmp    141e <main+0x25e>
mov    -0x28(%rbp),%rax
movzbl 0x6(%rax),%eax
cmp    $0x3,%eax
jne    13eb <main+0x22b>
mov    -0x28(%rbp),%rax
movzbl 0x7(%rax),%eax
and    $0x40,%eax
cmp    $0x0,%eax
setne  %al
and    $0x1,%al
movzbl %al,%eax
cmp    $0x0,%eax
jne    13eb <main+0x22b>
lea    -0x61af0(%rbp),%rdi
mov    -0x28(%rbp),%rsi
mov    -0x30(%rbp),%rdx
mov    -0x38(%rbp),%rcx
mov    -0x40(%rbp),%r8
mov    $0x186a0,%r9d
call   1050 <unpk_bds@plt>
mov    %eax,-0x64(%rbp)
cmpl   $0xfe88,-0x64(%rbp)
je     1381 <main+0x1c1>
mov    0x2c7c(%rip),%rax
mov    (%rax),%edi
mov    -0x5c(%rbp),%edx
lea    0xcd0(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    $0x8,%edi
call   10d0 <exit@plt>
lea    -0x61af0(%rbp),%rdi
lea    -0x6bf30(%rbp),%rsi
call   10c0 <con1x1@plt>
mov    -0x28(%rbp),%rdi
mov    $0x2,%esi
call   10e0 <set_PDSGridType@plt>
mov    -0x28(%rbp),%rdi
lea    -0x6bf30(%rbp),%rsi
mov    $0x2910,%edx
call   1080 <mk_BDS@plt>
mov    %rax,-0x40(%rbp)
mov    -0x58(%rbp),%rdi
mov    -0x28(%rbp),%rsi
mov    -0x48(%rbp),%rdx
mov    -0x38(%rbp),%rcx
mov    -0x40(%rbp),%r8
call   1060 <wrt_grib_msg@plt>
mov    -0x60(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x60(%rbp)
mov    -0x40(%rbp),%rdi
call   1030 <free@plt>
jmp    1404 <main+0x244>
mov    -0x58(%rbp),%rdi
mov    -0x28(%rbp),%rsi
mov    -0x30(%rbp),%rdx
mov    -0x38(%rbp),%rcx
mov    -0x40(%rbp),%r8
call   1060 <wrt_grib_msg@plt>
mov    -0x18(%rbp),%rax
add    -0x20(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x5c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x5c(%rbp)
jmp    12ca <main+0x10a>
mov    -0x58(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x50(%rbp),%rdi
call   1040 <fclose@plt>
mov    0x2ba9(%rip),%rax
mov    (%rax),%edi
mov    -0x60(%rbp),%edx
mov    -0x5c(%rbp),%ecx
lea    0xc1b(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
xor    %eax,%eax
add    $0x6bf30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x6bef8,%rsp
mov    %rsi,%rbx
cmp    $0x3,%edi
jne    13c1 <main+0x201>
mov    0x8(%rbx),%rdi
lea    0xe39(%rip),%rsi
call   10b0 <fopen@plt>
test   %rax,%rax
je     13e5 <main+0x225>
mov    %rax,%r14
mov    0x10(%rbx),%rdi
lea    0xe39(%rip),%rsi
call   10b0 <fopen@plt>
test   %rax,%rax
je     13f4 <main+0x234>
mov    %rax,%r15
xor    %ebx,%ebx
xor    %eax,%eax
call   10a0 <gds_grid2@plt>
mov    %rax,0x28(%rsp)
lea    0x10(%rsp),%rdx
lea    0x20(%rsp),%rcx
lea    0x18(%rsp),%r8
lea    0x8(%rsp),%r9
mov    %r14,%rdi
xor    %esi,%esi
call   1090 <rd_grib_msg@plt>
movl   $0x0,0x4(%rsp)
test   %rax,%rax
jle    135d <main+0x19d>
mov    %rax,%r12
xor    %ebp,%ebp
lea    0xa470(%rsp),%r13
movl   $0x0,0x4(%rsp)
xor    %ebx,%ebx
jmp    12c0 <main+0x100>
nopl   0x0(%rax,%rax,1)
mov    0x20(%rsp),%rdx
mov    0x18(%rsp),%rcx
mov    0x8(%rsp),%r8
mov    %r15,%rdi
call   1060 <wrt_grib_msg@plt>
add    %r12,%rbp
add    $0x1,%ebx
mov    %r14,%rdi
mov    %rbp,%rsi
lea    0x10(%rsp),%rdx
lea    0x20(%rsp),%rcx
lea    0x18(%rsp),%r8
lea    0x8(%rsp),%r9
call   1090 <rd_grib_msg@plt>
mov    %rax,%r12
test   %rax,%rax
lea    0xa470(%rsp),%r13
jle    135d <main+0x19d>
mov    0x10(%rsp),%rsi
cmpb   $0x3,0x6(%rsi)
jne    1270 <main+0xb0>
testb  $0x40,0x7(%rsi)
jne    1270 <main+0xb0>
mov    0x20(%rsp),%rdx
mov    0x18(%rsp),%rcx
mov    0x8(%rsp),%r8
mov    %r13,%rdi
mov    $0x186a0,%r9d
call   1050 <unpk_bds@plt>
cmp    $0xfe88,%eax
jne    139e <main+0x1de>
mov    %r13,%rdi
lea    0x30(%rsp),%r13
mov    %r13,%rsi
call   10c0 <con1x1@plt>
mov    0x10(%rsp),%rdi
mov    $0x2,%esi
call   10e0 <set_PDSGridType@plt>
mov    0x10(%rsp),%rdi
mov    %r13,%rsi
mov    $0x2910,%edx
call   1080 <mk_BDS@plt>
mov    %rax,0x8(%rsp)
mov    0x10(%rsp),%rsi
mov    0x18(%rsp),%rcx
mov    %r15,%rdi
mov    0x28(%rsp),%rdx
mov    %rax,%r8
call   1060 <wrt_grib_msg@plt>
addl   $0x1,0x4(%rsp)
mov    0x8(%rsp),%rdi
call   1030 <free@plt>
jmp    1287 <main+0xc7>
mov    %r15,%rdi
call   1040 <fclose@plt>
mov    %r14,%rdi
call   1040 <fclose@plt>
mov    0x2c6c(%rip),%rax
mov    (%rax),%edi
lea    0xce4(%rip),%rsi
mov    0x4(%rsp),%edx
mov    %ebx,%ecx
xor    %eax,%eax
call   1070 <fprintf@plt>
xor    %eax,%eax
add    $0x6bef8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2c3b(%rip),%rax
mov    (%rax),%edi
lea    0xc92(%rip),%rsi
mov    %ebx,%edx
xor    %eax,%eax
call   1070 <fprintf@plt>
mov    $0x8,%edi
call   10d0 <exit@plt>
mov    0x2c18(%rip),%rax
mov    (%rax),%edi
mov    (%rbx),%rdx
lea    0xc2c(%rip),%rsi
xor    %eax,%eax
call   1070 <fprintf@plt>
mov    $0x8,%edi
call   10d0 <exit@plt>
mov    0x2bf4(%rip),%rax
mov    (%rax),%edi
mov    0x8(%rbx),%rdx
jmp    1401 <main+0x241>
mov    0x2be5(%rip),%rax
mov    (%rax),%edi
mov    0x10(%rbx),%rdx
lea    0xc1c(%rip),%rsi
xor    %eax,%eax
call   1070 <fprintf@plt>
mov    $0x7,%edi
call   10d0 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [33 x i8] c"%s [in gribfile] [out gribfile]\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 = [3 x i8] c"wb\00"
@.str.4 = [33 x i8] c"unexpected grid size, record %d\0A\00"
@.str.5 = [42 x i8] c"converted %d records out of %d to 144x73\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 i8*
%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 [100000 x float]
%19 = alloca [10512 x float]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i64 0, i64* %7
%20 = load i32, i32* %4
%21 = icmp ne i32 %20, 3
br i1 %21, label %22, label %29
22: ; preds = %2
%23 = load i32, i32* @stderr
%24 = load i8**, i8*** %5
%25 = getelementptr inbounds i8*, i8** %24, i64 0
%26 = load i8*, i8** %25
%27 = call i32 (i32, i8*, ...) @fprintf(i32 %23, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0), i8* %26)
%28 = call i32 @exit(i32 8)
unreachable
29: ; preds = %2
%30 = load i8**, i8*** %5
%31 = getelementptr inbounds i8*, i8** %30, i64 1
%32 = load i8*, i8** %31
%33 = call i32* @fopen(i8* %32, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
store i32* %33, i32** %13
%34 = icmp eq i32* %33, null
br i1 %34, label %35, label %42
35: ; preds = %29
%36 = load i32, i32* @stderr
%37 = load i8**, i8*** %5
%38 = getelementptr inbounds i8*, i8** %37, i64 1
%39 = load i8*, i8** %38
%40 = call i32 (i32, i8*, ...) @fprintf(i32 %36, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0), i8* %39)
%41 = call i32 @exit(i32 7)
unreachable
42: ; preds = %29
%43 = load i8**, i8*** %5
%44 = getelementptr inbounds i8*, i8** %43, i64 2
%45 = load i8*, i8** %44
%46 = call i32* @fopen(i8* %45, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
store i32* %46, i32** %14
%47 = icmp eq i32* %46, null
br i1 %47, label %48, label %55
48: ; preds = %42
%49 = load i32, i32* @stderr
%50 = load i8**, i8*** %5
%51 = getelementptr inbounds i8*, i8** %50, i64 2
%52 = load i8*, i8** %51
%53 = call i32 (i32, i8*, ...) @fprintf(i32 %49, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0), i8* %52)
%54 = call i32 @exit(i32 7)
unreachable
55: ; preds = %42
%56 = call i8* (...) @gds_grid2()
store i8* %56, i8** %12
store i32 0, i32* %16
store i32 0, i32* %15
store i64 0, i64* %7
br label %57
57: ; preds = %119, %55
%58 = load i32*, i32** %13
%59 = load i64, i64* %7
%60 = call i64 @rd_grib_msg(i32* %58, i64 %59, i8** %8, i8** %9, i8** %10, i8** %11)
store i64 %60, i64* %6
%61 = load i64, i64* %6
%62 = icmp sle i64 %61, 0
br i1 %62, label %63, label %64
63: ; preds = %57
br label %125
64: ; preds = %57
%65 = load i8*, i8** %8
%66 = getelementptr inbounds i8, i8* %65, i64 6
%67 = load i8, i8* %66
%68 = zext i8 %67 to i32
%69 = icmp eq i32 %68, 3
br i1 %69, label %70, label %112
70: ; preds = %64
%71 = load i8*, i8** %8
%72 = getelementptr inbounds i8, i8* %71, i64 7
%73 = load i8, i8* %72
%74 = zext i8 %73 to i32
%75 = and i32 %74, 64
%76 = icmp ne i32 %75, 0
%77 = zext i1 %76 to i32
%78 = icmp eq i32 %77, 0
br i1 %78, label %79, label %112
79: ; preds = %70
%80 = getelementptr inbounds [100000 x float], [100000 x float]* %18, i64 0, i64 0
%81 = load i8*, i8** %8
%82 = load i8*, i8** %9
%83 = load i8*, i8** %10
%84 = load i8*, i8** %11
%85 = call i32 @unpk_bds(float* %80, i8* %81, i8* %82, i8* %83, i8* %84, i32 100000)
store i32 %85, i32* %17
%86 = load i32, i32* %17
%87 = icmp ne i32 %86, 65160
br i1 %87, label %88, label %93
88: ; preds = %79
%89 = load i32, i32* @stderr
%90 = load i32, i32* %15
%91 = call i32 (i32, i8*, ...) @fprintf(i32 %89, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.4, i64 0, i64 0), i32 %90)
%92 = call i32 @exit(i32 8)
unreachable
93: ; preds = %79
%94 = getelementptr inbounds [100000 x float], [100000 x float]* %18, i64 0, i64 0
%95 = getelementptr inbounds [10512 x float], [10512 x float]* %19, i64 0, i64 0
%96 = call i32 @con1x1(float* %94, float* %95)
%97 = load i8*, i8** %8
%98 = call i32 @set_PDSGridType(i8* %97, i32 2)
%99 = load i8*, i8** %8
%100 = getelementptr inbounds [10512 x float], [10512 x float]* %19, i64 0, i64 0
%101 = call i8* @mk_BDS(i8* %99, float* %100, i32 10512)
store i8* %101, i8** %11
%102 = load i32*, i32** %14
%103 = load i8*, i8** %8
%104 = load i8*, i8** %12
%105 = load i8*, i8** %10
%106 = load i8*, i8** %11
%107 = call i32 @wrt_grib_msg(i32* %102, i8* %103, i8* %104, i8* %105, i8* %106)
%108 = load i32, i32* %16
%109 = add nsw i32 %108, 1
store i32 %109, i32* %16
%110 = load i8*, i8** %11
%111 = call i32 @free(i8* %110)
br label %119
112: ; preds = %70, %64
%113 = load i32*, i32** %14
%114 = load i8*, i8** %8
%115 = load i8*, i8** %9
%116 = load i8*, i8** %10
%117 = load i8*, i8** %11
%118 = call i32 @wrt_grib_msg(i32* %113, i8* %114, i8* %115, i8* %116, i8* %117)
br label %119
119: ; preds = %112, %93
%120 = load i64, i64* %6
%121 = load i64, i64* %7
%122 = add nsw i64 %121, %120
store i64 %122, i64* %7
%123 = load i32, i32* %15
%124 = add nsw i32 %123, 1
store i32 %124, i32* %15
br label %57
125: ; preds = %63
%126 = load i32*, i32** %14
%127 = call i32 @fclose(i32* %126)
%128 = load i32*, i32** %13
%129 = call i32 @fclose(i32* %128)
%130 = load i32, i32* @stderr
%131 = load i32, i32* %16
%132 = load i32, i32* %15
%133 = call i32 (i32, i8*, ...) @fprintf(i32 %130, i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.5, i64 0, i64 0), i32 %131, i32 %132)
ret i32 0
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [33 x i8] c"%s [in gribfile] [out gribfile]\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 = [3 x i8] c"wb\00"
@.str.4 = [33 x i8] c"unexpected grid size, record %d\0A\00"
@.str.5 = [42 x i8] c"converted %d records out of %d to 144x73\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 [10512 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 [10512 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 ([33 x i8], [33 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.3, i64 0, i64 0))
%35 = icmp eq i32* %34, null
br i1 %35, label %36, label %41
36: ; preds = %31
%37 = load i32, i32* @stderr
%38 = load i8*, i8** %32
%39 = tail call i32 (i32, i8*, ...) @fprintf(i32 %37, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0), i8* %38)
%40 = tail call i32 @exit(i32 7)
unreachable
41: ; preds = %31
%42 = tail call i8* (...) @gds_grid2()
%43 = call i64 @rd_grib_msg(i32* %24, i64 0, i8** %3, i8** %4, i8** %5, i8** %6)
%44 = icmp slt i64 %43, 1
br i1 %44, label %95, label %45
45: ; preds = %41
%46 = getelementptr inbounds [100000 x float], [100000 x float]* %7, i64 0, i64 0
%47 = getelementptr inbounds [10512 x float], [10512 x float]* %8, i64 0, i64 0
br label %48
48: ; preds = %45, %89
%49 = phi i64 [ %43, %45 ], [ %93, %89 ]
%50 = phi i64 [ 0, %45 ], [ %91, %89 ]
%51 = phi i32 [ 0, %45 ], [ %90, %89 ]
%52 = phi i32 [ 0, %45 ], [ %92, %89 ]
%53 = load i8*, i8** %3
%54 = getelementptr inbounds i8, i8* %53, i64 6
%55 = load i8, i8* %54
%56 = icmp eq i8 %55, 3
br i1 %56, label %57, label %84
57: ; preds = %48
%58 = getelementptr inbounds i8, i8* %53, i64 7
%59 = load i8, i8* %58
%60 = and i8 %59, 64
%61 = icmp eq i8 %60, 0
br i1 %61, label %62, label %84
62: ; preds = %57
%63 = load i8*, i8** %4
%64 = load i8*, i8** %5
%65 = load i8*, i8** %6
%66 = call i32 @unpk_bds(float* %46, i8* %53, i8* %63, i8* %64, i8* %65, i32 100000)
%67 = icmp eq i32 %66, 65160
br i1 %67, label %72, label %68
68: ; preds = %62
%69 = load i32, i32* @stderr
%70 = call i32 (i32, i8*, ...) @fprintf(i32 %69, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.4, i64 0, i64 0), i32 %52)
%71 = call i32 @exit(i32 8)
unreachable
72: ; preds = %62
%73 = call i32 @con1x1(float* %46, float* %47)
%74 = load i8*, i8** %3
%75 = call i32 @set_PDSGridType(i8* %74, i32 2)
%76 = load i8*, i8** %3
%77 = call i8* @mk_BDS(i8* %76, float* %47, i32 10512)
store i8* %77, i8** %6
%78 = load i8*, i8** %3
%79 = load i8*, i8** %5
%80 = call i32 @wrt_grib_msg(i32* %34, i8* %78, i8* %42, i8* %79, i8* %77)
%81 = add nsw i32 %51, 1
%82 = load i8*, i8** %6
%83 = call i32 @free(i8* %82)
br label %89
84: ; preds = %57, %48
%85 = load i8*, i8** %4
%86 = load i8*, i8** %5
%87 = load i8*, i8** %6
%88 = call i32 @wrt_grib_msg(i32* %34, i8* %53, i8* %85, i8* %86, i8* %87)
br label %89
89: ; preds = %84, %72
%90 = phi i32 [ %81, %72 ], [ %51, %84 ]
%91 = add nsw i64 %49, %50
%92 = add nuw nsw i32 %52, 1
%93 = call i64 @rd_grib_msg(i32* %24, i64 %91, i8** %3, i8** %4, i8** %5, i8** %6)
%94 = icmp slt i64 %93, 1
br i1 %94, label %95, label %48
95: ; preds = %89, %41
%96 = phi i32 [ 0, %41 ], [ %92, %89 ]
%97 = phi i32 [ 0, %41 ], [ %90, %89 ]
%98 = call i32 @fclose(i32* %34)
%99 = call i32 @fclose(i32* %24)
%100 = load i32, i32* @stderr
%101 = call i32 (i32, i8*, ...) @fprintf(i32 %100, i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.5, i64 0, i64 0), i32 %97, i32 %96)
ret i32 0
}