#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*/ fatal_error(char *, char *);
int /*<<< orphan*/ get_nxny(unsigned char **, int *, int *, unsigned int *,
                            int *, int *);
double int4(unsigned char *);
scalar_t__ malloc(int);
int irr_grid2ll(unsigned char **sec, double **lat, double **lon) {
  unsigned char *gds;
  double *llat, *llon;
  int nnx, nny, nres, nscan;
  unsigned int i, nnpnts;
  get_nxny(sec, &nnx, &nny, &nnpnts, &nres, &nscan);
  if (nnpnts == 0)
    return 0;
  if ((*lat = (double *)malloc(sizeof(double) * (size_t)nnpnts)) == NULL) {
    fatal_error("space_view2ll memory allocation failed", "");
  }
  if ((*lon = (double *)malloc(sizeof(double) * (size_t)nnpnts)) == NULL) {
    fatal_error("space_view2ll memory allocation failed", "");
  }
  llat = *lat;
  llon = *lon;
  gds = sec[3];
  for (i = 0; i < nnpnts; i++) {
    *llat++ = (double)1e-6 * int4(gds + 30 + i * 8);
    *llon++ = (double)1e-6 * int4(gds + 34 + i * 8);
  }
  return 0;
}


x86 assembly (clang, -O0):
<irr_grid2ll>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
lea    -0x3c(%rbp),%rsi
lea    -0x40(%rbp),%rdx
lea    -0x50(%rbp),%rcx
lea    -0x44(%rbp),%r8
lea    -0x48(%rbp),%r9
call   1060 <get_nxny@plt>
cmpl   $0x0,-0x50(%rbp)
jne    1187 <irr_grid2ll+0x47>
movl   $0x0,-0x4(%rbp)
jmp    12a9 <irr_grid2ll+0x169>
mov    -0x50(%rbp),%eax
shl    $0x3,%rax
mov    %eax,%edi
call   1050 <malloc@plt>
mov    -0x18(%rbp),%rcx
mov    %rax,(%rcx)
cmp    $0x0,%rax
jne    11b9 <irr_grid2ll+0x79>
lea    0xe5b(%rip),%rdi
lea    0xe7a(%rip),%rsi
call   1040 <fatal_error@plt>
mov    -0x50(%rbp),%eax
shl    $0x3,%rax
mov    %eax,%edi
call   1050 <malloc@plt>
mov    -0x20(%rbp),%rcx
mov    %rax,(%rcx)
cmp    $0x0,%rax
jne    11eb <irr_grid2ll+0xab>
lea    0xe29(%rip),%rdi
lea    0xe48(%rip),%rsi
call   1040 <fatal_error@plt>
mov    -0x18(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x30(%rbp)
mov    -0x20(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x38(%rbp)
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rax
mov    %rax,-0x28(%rbp)
movl   $0x0,-0x4c(%rbp)
mov    -0x4c(%rbp),%eax
cmp    -0x50(%rbp),%eax
jae    12a2 <irr_grid2ll+0x162>
mov    -0x28(%rbp),%rdi
add    $0x1e,%rdi
mov    -0x4c(%rbp),%eax
shl    $0x3,%eax
mov    %eax,%eax
add    %rax,%rdi
call   1030 <int4@plt>
movaps %xmm0,%xmm1
movsd  0xdbd(%rip),%xmm0
mulsd  %xmm1,%xmm0
mov    -0x30(%rbp),%rax
mov    %rax,%rcx
add    $0x8,%rcx
mov    %rcx,-0x30(%rbp)
movsd  %xmm0,(%rax)
mov    -0x28(%rbp),%rdi
add    $0x22,%rdi
mov    -0x4c(%rbp),%eax
shl    $0x3,%eax
mov    %eax,%eax
add    %rax,%rdi
call   1030 <int4@plt>
movaps %xmm0,%xmm1
movsd  0xd83(%rip),%xmm0
mulsd  %xmm1,%xmm0
mov    -0x38(%rbp),%rax
mov    %rax,%rcx
add    $0x8,%rcx
mov    %rcx,-0x38(%rbp)
movsd  %xmm0,(%rax)
mov    -0x4c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4c(%rbp)
jmp    1214 <irr_grid2ll+0xd4>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<irr_grid2ll>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%rbx
lea    0x14(%rsp),%rsi
lea    0x10(%rsp),%rdx
lea    0x4(%rsp),%rcx
lea    0xc(%rsp),%r8
lea    0x8(%rsp),%r9
call   1060 <get_nxny@plt>
mov    0x4(%rsp),%edi
test   %edi,%edi
je     124e <irr_grid2ll+0x10e>
shl    $0x3,%edi
call   1050 <malloc@plt>
mov    %rax,(%r15)
test   %rax,%rax
jne    11a4 <irr_grid2ll+0x64>
lea    0xe70(%rip),%rdi
lea    0xe8f(%rip),%rsi
call   1040 <fatal_error@plt>
mov    0x4(%rsp),%edi
shl    $0x3,%edi
call   1050 <malloc@plt>
mov    %rax,(%r14)
test   %rax,%rax
je     11c4 <irr_grid2ll+0x84>
cmpl   $0x0,0x4(%rsp)
jne    11de <irr_grid2ll+0x9e>
jmp    124e <irr_grid2ll+0x10e>
lea    0xe3d(%rip),%rdi
lea    0xe5c(%rip),%rsi
call   1040 <fatal_error@plt>
cmpl   $0x0,0x4(%rsp)
je     124e <irr_grid2ll+0x10e>
mov    0x18(%rbx),%r12
mov    (%r14),%r14
mov    (%r15),%r15
lea    0x1e(%r12),%r13
add    $0x22,%r12
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
lea    0x0(,%rbp,8),%ebx
lea    (%rbx,%r13,1),%rdi
call   1030 <int4@plt>
movsd  0xde8(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,(%r15)
add    $0x8,%r15
add    %r12,%rbx
mov    %rbx,%rdi
call   1030 <int4@plt>
mulsd  0xdc8(%rip),%xmm0
movsd  %xmm0,(%r14)
add    $0x8,%r14
add    $0x1,%rbp
mov    0x4(%rsp),%eax
cmp    %rax,%rbp
jb     1200 <irr_grid2ll+0xc0>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [39 x i8] c"space_view2ll memory allocation failed\00"
@.str.1 = [1 x i8] zeroinitializer
define i32 @irr_grid2ll(i8** %0, double** %1, double** %2) {
%4 = alloca i32
%5 = alloca i8**
%6 = alloca double**
%7 = alloca double**
%8 = alloca i8*
%9 = alloca double*
%10 = alloca double*
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
%16 = alloca i32
store i8** %0, i8*** %5
store double** %1, double*** %6
store double** %2, double*** %7
%17 = load i8**, i8*** %5
%18 = call i32 @get_nxny(i8** %17, i32* %11, i32* %12, i32* %16, i32* %13, i32* %14)
%19 = load i32, i32* %16
%20 = icmp eq i32 %19, 0
br i1 %20, label %21, label %22
21: ; preds = %3
store i32 0, i32* %4
br label %81
22: ; preds = %3
%23 = load i32, i32* %16
%24 = zext i32 %23 to i64
%25 = mul i64 8, %24
%26 = trunc i64 %25 to i32
%27 = call i64 @malloc(i32 %26)
%28 = inttoptr i64 %27 to double*
%29 = load double**, double*** %6
store double* %28, double** %29
%30 = icmp eq double* %28, null
br i1 %30, label %31, label %33
31: ; preds = %22
%32 = call i32 @fatal_error(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0))
br label %33
33: ; preds = %31, %22
%34 = load i32, i32* %16
%35 = zext i32 %34 to i64
%36 = mul i64 8, %35
%37 = trunc i64 %36 to i32
%38 = call i64 @malloc(i32 %37)
%39 = inttoptr i64 %38 to double*
%40 = load double**, double*** %7
store double* %39, double** %40
%41 = icmp eq double* %39, null
br i1 %41, label %42, label %44
42: ; preds = %33
%43 = call i32 @fatal_error(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0))
br label %44
44: ; preds = %42, %33
%45 = load double**, double*** %6
%46 = load double*, double** %45
store double* %46, double** %9
%47 = load double**, double*** %7
%48 = load double*, double** %47
store double* %48, double** %10
%49 = load i8**, i8*** %5
%50 = getelementptr inbounds i8*, i8** %49, i64 3
%51 = load i8*, i8** %50
store i8* %51, i8** %8
store i32 0, i32* %15
br label %52
52: ; preds = %77, %44
%53 = load i32, i32* %15
%54 = load i32, i32* %16
%55 = icmp ult i32 %53, %54
br i1 %55, label %56, label %80
56: ; preds = %52
%57 = load i8*, i8** %8
%58 = getelementptr inbounds i8, i8* %57, i64 30
%59 = load i32, i32* %15
%60 = mul i32 %59, 8
%61 = zext i32 %60 to i64
%62 = getelementptr inbounds i8, i8* %58, i64 %61
%63 = call double @int4(i8* %62)
%64 = fmul double 0x3EB0C6F7A0B5ED8D, %63
%65 = load double*, double** %9
%66 = getelementptr inbounds double, double* %65, i32 1
store double* %66, double** %9
store double %64, double* %65
%67 = load i8*, i8** %8
%68 = getelementptr inbounds i8, i8* %67, i64 34
%69 = load i32, i32* %15
%70 = mul i32 %69, 8
%71 = zext i32 %70 to i64
%72 = getelementptr inbounds i8, i8* %68, i64 %71
%73 = call double @int4(i8* %72)
%74 = fmul double 0x3EB0C6F7A0B5ED8D, %73
%75 = load double*, double** %10
%76 = getelementptr inbounds double, double* %75, i32 1
store double* %76, double** %10
store double %74, double* %75
br label %77
77: ; preds = %56
%78 = load i32, i32* %15
%79 = add i32 %78, 1
store i32 %79, i32* %15
br label %52
80: ; preds = %52
store i32 0, i32* %4
br label %81
81: ; preds = %80, %21
%82 = load i32, i32* %4
ret i32 %82
}

LLVM IR (-O2):
@.str = [39 x i8] c"space_view2ll memory allocation failed\00"
@.str.1 = [1 x i8] zeroinitializer
define i32 @irr_grid2ll(i8** %0, double** nocapture %1, double** nocapture %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = bitcast i32* %4 to i8*
%10 = bitcast i32* %5 to i8*
%11 = bitcast i32* %6 to i8*
%12 = bitcast i32* %7 to i8*
%13 = bitcast i32* %8 to i8*
%14 = call i32 @get_nxny(i8** %0, i32* %4, i32* %5, i32* %8, i32* %6, i32* %7)
%15 = load i32, i32* %8
%16 = icmp eq i32 %15, 0
br i1 %16, label %60, label %17
17: ; preds = %3
%18 = shl i32 %15, 3
%19 = call i64 @malloc(i32 %18)
%20 = inttoptr i64 %19 to double*
store double* %20, double** %1
%21 = icmp eq i64 %19, 0
br i1 %21, label %22, label %24
22: ; preds = %17
%23 = call i32 @fatal_error(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0))
br label %24
24: ; preds = %22, %17
%25 = load i32, i32* %8
%26 = shl i32 %25, 3
%27 = call i64 @malloc(i32 %26)
%28 = inttoptr i64 %27 to double*
store double* %28, double** %2
%29 = icmp eq i64 %27, 0
br i1 %29, label %30, label %32
30: ; preds = %24
%31 = call i32 @fatal_error(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0))
br label %32
32: ; preds = %30, %24
%33 = getelementptr inbounds i8*, i8** %0, i64 3
%34 = load i8*, i8** %33
%35 = load i32, i32* %8
%36 = icmp eq i32 %35, 0
br i1 %36, label %60, label %37
37: ; preds = %32
%38 = load double*, double** %2
%39 = load double*, double** %1
%40 = getelementptr inbounds i8, i8* %34, i64 30
%41 = getelementptr inbounds i8, i8* %34, i64 34
br label %42
42: ; preds = %37, %42
%43 = phi i64 [ 0, %37 ], [ %56, %42 ]
%44 = phi double* [ %38, %37 ], [ %55, %42 ]
%45 = phi double* [ %39, %37 ], [ %51, %42 ]
%46 = shl i64 %43, 3
%47 = and i64 %46, 4294967288
%48 = getelementptr inbounds i8, i8* %40, i64 %47
%49 = call double @int4(i8* %48)
%50 = fmul double %49, 0x3EB0C6F7A0B5ED8D
%51 = getelementptr inbounds double, double* %45, i64 1
store double %50, double* %45
%52 = getelementptr inbounds i8, i8* %41, i64 %47
%53 = call double @int4(i8* %52)
%54 = fmul double %53, 0x3EB0C6F7A0B5ED8D
%55 = getelementptr inbounds double, double* %44, i64 1
store double %54, double* %44
%56 = add nuw nsw i64 %43, 1
%57 = load i32, i32* %8
%58 = zext i32 %57 to i64
%59 = icmp ult i64 %56, %58
br i1 %59, label %42, label %60
60: ; preds = %42, %32, %3
ret i32 0
}