#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*/ M_PI;
int fix_lon(double *, double *, int, int /*<<< orphan*/);
double poly_area_dimensionless(double *, double *, int);
void get_grid_area_dimensionless(const int *nlon, const int *nlat,
                                 const double *lon, const double *lat,
                                 double *area) {
  int nx, ny, nxp, i, j, n_in;
  double x_in[20], y_in[20];
  nx = *nlon;
  ny = *nlat;
  nxp = nx + 1;
  for (j = 0; j < ny; j++)
    for (i = 0; i < nx; i++) {
      x_in[0] = lon[j * nxp + i];
      x_in[1] = lon[j * nxp + i + 1];
      x_in[2] = lon[(j + 1) * nxp + i + 1];
      x_in[3] = lon[(j + 1) * nxp + i];
      y_in[0] = lat[j * nxp + i];
      y_in[1] = lat[j * nxp + i + 1];
      y_in[2] = lat[(j + 1) * nxp + i + 1];
      y_in[3] = lat[(j + 1) * nxp + i];
      n_in = fix_lon(x_in, y_in, 4, M_PI);
      area[j * nx + i] = poly_area_dimensionless(x_in, y_in, n_in);
    }
}


x86 assembly (clang, -O0):
<get_grid_area_dimensionless>:
push   %rbp
mov    %rsp,%rbp
sub    $0x180,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x2c(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x30(%rbp)
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
movl   $0x0,-0x3c(%rbp)
mov    -0x3c(%rbp),%eax
cmp    -0x30(%rbp),%eax
jge    12f9 <get_grid_area_dimensionless+0x1d9>
movl   $0x0,-0x38(%rbp)
mov    -0x38(%rbp),%eax
cmp    -0x2c(%rbp),%eax
jge    12e6 <get_grid_area_dimensionless+0x1c6>
mov    -0x18(%rbp),%rax
mov    -0x3c(%rbp),%ecx
imul   -0x34(%rbp),%ecx
add    -0x38(%rbp),%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0xe0(%rbp)
ff
mov    -0x18(%rbp),%rax
mov    -0x3c(%rbp),%ecx
imul   -0x34(%rbp),%ecx
add    -0x38(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0xd8(%rbp)
ff
mov    -0x18(%rbp),%rax
mov    -0x3c(%rbp),%ecx
add    $0x1,%ecx
imul   -0x34(%rbp),%ecx
add    -0x38(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0xd0(%rbp)
ff
mov    -0x18(%rbp),%rax
mov    -0x3c(%rbp),%ecx
add    $0x1,%ecx
imul   -0x34(%rbp),%ecx
add    -0x38(%rbp),%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0xc8(%rbp)
ff
mov    -0x20(%rbp),%rax
mov    -0x3c(%rbp),%ecx
imul   -0x34(%rbp),%ecx
add    -0x38(%rbp),%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x180(%rbp)
ff
mov    -0x20(%rbp),%rax
mov    -0x3c(%rbp),%ecx
imul   -0x34(%rbp),%ecx
add    -0x38(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x178(%rbp)
ff
mov    -0x20(%rbp),%rax
mov    -0x3c(%rbp),%ecx
add    $0x1,%ecx
imul   -0x34(%rbp),%ecx
add    -0x38(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x170(%rbp)
ff
mov    -0x20(%rbp),%rax
mov    -0x3c(%rbp),%ecx
add    $0x1,%ecx
imul   -0x34(%rbp),%ecx
add    -0x38(%rbp),%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x168(%rbp)
ff
lea    -0xe0(%rbp),%rdi
lea    -0x180(%rbp),%rsi
mov    0x2d4b(%rip),%rax
mov    (%rax),%ecx
mov    $0x4,%edx
call   1040 <fix_lon@plt>
mov    %eax,-0x40(%rbp)
lea    -0xe0(%rbp),%rdi
lea    -0x180(%rbp),%rsi
mov    -0x40(%rbp),%edx
call   1030 <poly_area_dimensionless@plt>
mov    -0x28(%rbp),%rax
mov    -0x3c(%rbp),%ecx
imul   -0x2c(%rbp),%ecx
add    -0x38(%rbp),%ecx
movslq %ecx,%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x38(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x38(%rbp)
jmp    1174 <get_grid_area_dimensionless+0x54>
jmp    12eb <get_grid_area_dimensionless+0x1cb>
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
jmp    1161 <get_grid_area_dimensionless+0x41>
add    $0x180,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_grid_area_dimensionless>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x1a8,%rsp
mov    %r8,0x28(%rsp)
mov    %rcx,0x20(%rsp)
mov    %rdx,0x18(%rsp)
mov    (%rsi),%eax
mov    %rax,0x30(%rsp)
test   %eax,%eax
jle    127e <get_grid_area_dimensionless+0x15e>
movslq (%rdi),%rsi
lea    0x1(%rsi),%rax
mov    %rax,0x8(%rsp)
mov    %esi,%r14d
xor    %ebx,%ebx
mov    0x2e81(%rip),%rbp
lea    0x100(%rsp),%r12
lea    0x60(%rsp),%r15
mov    %rsi,0x10(%rsp)
jmp    1192 <get_grid_area_dimensionless+0x72>
nopl   0x0(%rax,%rax,1)
add    $0x1,%rbx
mov    %rbx,%rcx
cmp    0x30(%rsp),%rcx
je     127e <get_grid_area_dimensionless+0x15e>
test   %esi,%esi
jle    1180 <get_grid_area_dimensionless+0x60>
mov    %rbx,%rcx
mov    0x8(%rsp),%rdi
imul   %rdi,%rcx
lea    0x1(%rbx),%rdx
mov    %rdx,0x38(%rsp)
imul   %rdi,%rdx
imul   %rsi,%rbx
mov    0x28(%rsp),%rsi
lea    (%rsi,%rbx,8),%rsi
mov    %rsi,0x58(%rsp)
mov    0x18(%rsp),%rsi
lea    (%rsi,%rdx,8),%rdi
mov    %rdi,0x50(%rsp)
mov    0x20(%rsp),%rdi
lea    (%rdi,%rdx,8),%rdx
mov    %rdx,0x48(%rsp)
lea    (%rsi,%rcx,8),%rdx
mov    %rdx,0x40(%rsp)
lea    (%rdi,%rcx,8),%r13
xor    %ebx,%ebx
nopl   0x0(%rax)
mov    0x40(%rsp),%rcx
movups (%rcx,%rbx,8),%xmm0
movaps %xmm0,0x100(%rsp)
mov    0x50(%rsp),%rcx
movups (%rcx,%rbx,8),%xmm0
shufps $0x4e,%xmm0,%xmm0
movaps %xmm0,0x110(%rsp)
movups 0x0(%r13,%rbx,8),%xmm0
movaps %xmm0,0x60(%rsp)
mov    0x48(%rsp),%rcx
movups (%rcx,%rbx,8),%xmm0
shufps $0x4e,%xmm0,%xmm0
movaps %xmm0,0x70(%rsp)
mov    0x0(%rbp),%ecx
mov    %r12,%rdi
mov    %r15,%rsi
mov    $0x4,%edx
call   1040 <fix_lon@plt>
mov    %r12,%rdi
mov    %r15,%rsi
mov    %eax,%edx
call   1030 <poly_area_dimensionless@plt>
mov    0x58(%rsp),%rcx
movsd  %xmm0,(%rcx,%rbx,8)
add    $0x1,%rbx
cmp    %rbx,%r14
jne    11f0 <get_grid_area_dimensionless+0xd0>
mov    0x38(%rsp),%rcx
mov    %rcx,%rbx
mov    0x10(%rsp),%rsi
cmp    0x30(%rsp),%rcx
jne    1192 <get_grid_area_dimensionless+0x72>
add    $0x1a8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@M_PI = global i32 0
define void @get_grid_area_dimensionless(i32* %0, i32* %1, double* %2, double* %3, double* %4) {
%6 = alloca i32*
%7 = alloca i32*
%8 = alloca double*
%9 = alloca double*
%10 = alloca double*
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
%16 = alloca i32
%17 = alloca [20 x double]
%18 = alloca [20 x double]
store i32* %0, i32** %6
store i32* %1, i32** %7
store double* %2, double** %8
store double* %3, double** %9
store double* %4, double** %10
%19 = load i32*, i32** %6
%20 = load i32, i32* %19
store i32 %20, i32* %11
%21 = load i32*, i32** %7
%22 = load i32, i32* %21
store i32 %22, i32* %12
%23 = load i32, i32* %11
%24 = add nsw i32 %23, 1
store i32 %24, i32* %13
store i32 0, i32* %15
br label %25
25: ; preds = %143, %5
%26 = load i32, i32* %15
%27 = load i32, i32* %12
%28 = icmp slt i32 %26, %27
br i1 %28, label %29, label %146
29: ; preds = %25
store i32 0, i32* %14
br label %30
30: ; preds = %139, %29
%31 = load i32, i32* %14
%32 = load i32, i32* %11
%33 = icmp slt i32 %31, %32
br i1 %33, label %34, label %142
34: ; preds = %30
%35 = load double*, double** %8
%36 = load i32, i32* %15
%37 = load i32, i32* %13
%38 = mul nsw i32 %36, %37
%39 = load i32, i32* %14
%40 = add nsw i32 %38, %39
%41 = sext i32 %40 to i64
%42 = getelementptr inbounds double, double* %35, i64 %41
%43 = load double, double* %42
%44 = getelementptr inbounds [20 x double], [20 x double]* %17, i64 0, i64 0
store double %43, double* %44
%45 = load double*, double** %8
%46 = load i32, i32* %15
%47 = load i32, i32* %13
%48 = mul nsw i32 %46, %47
%49 = load i32, i32* %14
%50 = add nsw i32 %48, %49
%51 = add nsw i32 %50, 1
%52 = sext i32 %51 to i64
%53 = getelementptr inbounds double, double* %45, i64 %52
%54 = load double, double* %53
%55 = getelementptr inbounds [20 x double], [20 x double]* %17, i64 0, i64 1
store double %54, double* %55
%56 = load double*, double** %8
%57 = load i32, i32* %15
%58 = add nsw i32 %57, 1
%59 = load i32, i32* %13
%60 = mul nsw i32 %58, %59
%61 = load i32, i32* %14
%62 = add nsw i32 %60, %61
%63 = add nsw i32 %62, 1
%64 = sext i32 %63 to i64
%65 = getelementptr inbounds double, double* %56, i64 %64
%66 = load double, double* %65
%67 = getelementptr inbounds [20 x double], [20 x double]* %17, i64 0, i64 2
store double %66, double* %67
%68 = load double*, double** %8
%69 = load i32, i32* %15
%70 = add nsw i32 %69, 1
%71 = load i32, i32* %13
%72 = mul nsw i32 %70, %71
%73 = load i32, i32* %14
%74 = add nsw i32 %72, %73
%75 = sext i32 %74 to i64
%76 = getelementptr inbounds double, double* %68, i64 %75
%77 = load double, double* %76
%78 = getelementptr inbounds [20 x double], [20 x double]* %17, i64 0, i64 3
store double %77, double* %78
%79 = load double*, double** %9
%80 = load i32, i32* %15
%81 = load i32, i32* %13
%82 = mul nsw i32 %80, %81
%83 = load i32, i32* %14
%84 = add nsw i32 %82, %83
%85 = sext i32 %84 to i64
%86 = getelementptr inbounds double, double* %79, i64 %85
%87 = load double, double* %86
%88 = getelementptr inbounds [20 x double], [20 x double]* %18, i64 0, i64 0
store double %87, double* %88
%89 = load double*, double** %9
%90 = load i32, i32* %15
%91 = load i32, i32* %13
%92 = mul nsw i32 %90, %91
%93 = load i32, i32* %14
%94 = add nsw i32 %92, %93
%95 = add nsw i32 %94, 1
%96 = sext i32 %95 to i64
%97 = getelementptr inbounds double, double* %89, i64 %96
%98 = load double, double* %97
%99 = getelementptr inbounds [20 x double], [20 x double]* %18, i64 0, i64 1
store double %98, double* %99
%100 = load double*, double** %9
%101 = load i32, i32* %15
%102 = add nsw i32 %101, 1
%103 = load i32, i32* %13
%104 = mul nsw i32 %102, %103
%105 = load i32, i32* %14
%106 = add nsw i32 %104, %105
%107 = add nsw i32 %106, 1
%108 = sext i32 %107 to i64
%109 = getelementptr inbounds double, double* %100, i64 %108
%110 = load double, double* %109
%111 = getelementptr inbounds [20 x double], [20 x double]* %18, i64 0, i64 2
store double %110, double* %111
%112 = load double*, double** %9
%113 = load i32, i32* %15
%114 = add nsw i32 %113, 1
%115 = load i32, i32* %13
%116 = mul nsw i32 %114, %115
%117 = load i32, i32* %14
%118 = add nsw i32 %116, %117
%119 = sext i32 %118 to i64
%120 = getelementptr inbounds double, double* %112, i64 %119
%121 = load double, double* %120
%122 = getelementptr inbounds [20 x double], [20 x double]* %18, i64 0, i64 3
store double %121, double* %122
%123 = getelementptr inbounds [20 x double], [20 x double]* %17, i64 0, i64 0
%124 = getelementptr inbounds [20 x double], [20 x double]* %18, i64 0, i64 0
%125 = load i32, i32* @M_PI
%126 = call i32 @fix_lon(double* %123, double* %124, i32 4, i32 %125)
store i32 %126, i32* %16
%127 = getelementptr inbounds [20 x double], [20 x double]* %17, i64 0, i64 0
%128 = getelementptr inbounds [20 x double], [20 x double]* %18, i64 0, i64 0
%129 = load i32, i32* %16
%130 = call double @poly_area_dimensionless(double* %127, double* %128, i32 %129)
%131 = load double*, double** %10
%132 = load i32, i32* %15
%133 = load i32, i32* %11
%134 = mul nsw i32 %132, %133
%135 = load i32, i32* %14
%136 = add nsw i32 %134, %135
%137 = sext i32 %136 to i64
%138 = getelementptr inbounds double, double* %131, i64 %137
store double %130, double* %138
br label %139
139: ; preds = %34
%140 = load i32, i32* %14
%141 = add nsw i32 %140, 1
store i32 %141, i32* %14
br label %30
142: ; preds = %30
br label %143
143: ; preds = %142
%144 = load i32, i32* %15
%145 = add nsw i32 %144, 1
store i32 %145, i32* %15
br label %25
146: ; preds = %25
ret void
}

LLVM IR (-O2):
@M_PI = global i32 0
define void @get_grid_area_dimensionless(i32* nocapture %0, i32* nocapture %1, double* nocapture %2, double* nocapture %3, double* nocapture writeonly %4) {
%6 = alloca [20 x double]
%7 = alloca [20 x double]
%8 = bitcast [20 x double]* %6 to i8*
%9 = bitcast [20 x double]* %7 to i8*
%10 = load i32, i32* %0
%11 = load i32, i32* %1
%12 = icmp sgt i32 %11, 0
br i1 %12, label %13, label %65
13: ; preds = %5
%14 = add nsw i32 %10, 1
%15 = icmp sgt i32 %10, 0
%16 = getelementptr inbounds [20 x double], [20 x double]* %6, i64 0, i64 0
%17 = getelementptr inbounds [20 x double], [20 x double]* %6, i64 0, i64 2
%18 = getelementptr inbounds [20 x double], [20 x double]* %7, i64 0, i64 0
%19 = getelementptr inbounds [20 x double], [20 x double]* %7, i64 0, i64 2
%20 = sext i32 %14 to i64
%21 = sext i32 %10 to i64
%22 = zext i32 %11 to i64
%23 = zext i32 %10 to i64
%24 = bitcast [20 x double]* %6 to <2 x double>*
%25 = bitcast double* %17 to <2 x double>*
%26 = bitcast [20 x double]* %7 to <2 x double>*
%27 = bitcast double* %19 to <2 x double>*
br label %28
28: ; preds = %13, %62
%29 = phi i64 [ 0, %13 ], [ %63, %62 ]
br i1 %15, label %32, label %30
30: ; preds = %28
%31 = add nuw nsw i64 %29, 1
br label %62
32: ; preds = %28
%33 = mul nsw i64 %29, %20
%34 = add nuw nsw i64 %29, 1
%35 = mul nsw i64 %34, %20
%36 = mul nsw i64 %29, %21
br label %37
37: ; preds = %32, %37
%38 = phi i64 [ 0, %32 ], [ %60, %37 ]
%39 = add nsw i64 %38, %33
%40 = getelementptr inbounds double, double* %2, i64 %39
%41 = bitcast double* %40 to <2 x double>*
%42 = load <2 x double>, <2 x double>* %41
store <2 x double> %42, <2 x double>* %24
%43 = add nsw i64 %38, %35
%44 = getelementptr inbounds double, double* %2, i64 %43
%45 = bitcast double* %44 to <2 x double>*
%46 = load <2 x double>, <2 x double>* %45
%47 = shufflevector <2 x double> %46, <2 x double> poison, <2 x i32> <i32 1, i32 0>
store <2 x double> %47, <2 x double>* %25
%48 = getelementptr inbounds double, double* %3, i64 %39
%49 = bitcast double* %48 to <2 x double>*
%50 = load <2 x double>, <2 x double>* %49
store <2 x double> %50, <2 x double>* %26
%51 = getelementptr inbounds double, double* %3, i64 %43
%52 = bitcast double* %51 to <2 x double>*
%53 = load <2 x double>, <2 x double>* %52
%54 = shufflevector <2 x double> %53, <2 x double> poison, <2 x i32> <i32 1, i32 0>
store <2 x double> %54, <2 x double>* %27
%55 = load i32, i32* @M_PI
%56 = call i32 @fix_lon(double* %16, double* %18, i32 4, i32 %55)
%57 = call double @poly_area_dimensionless(double* %16, double* %18, i32 %56)
%58 = add nsw i64 %38, %36
%59 = getelementptr inbounds double, double* %4, i64 %58
store double %57, double* %59
%60 = add nuw nsw i64 %38, 1
%61 = icmp eq i64 %60, %23
br i1 %61, label %62, label %37
62: ; preds = %37, %30
%63 = phi i64 [ %31, %30 ], [ %34, %37 ]
%64 = icmp eq i64 %63, %22
br i1 %64, label %65, label %28
65: ; preds = %62, %5
ret void
}