#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(double *, double *, int);
void get_grid_area_ug(const int *npts, const double *lon, const double *lat,
                      double *area) {
  int nl, l, n_in, nv;
  double x_in[20], y_in[20];
  nl = *npts;
  nv = 4;
  for (l = 0; l < nl; l++) {
    x_in[0] = lon[l * nv];
    x_in[1] = lon[l * nv + 1];
    x_in[2] = lon[l * nv + 2];
    x_in[3] = lon[l * nv + 3];
    y_in[0] = lat[l * nv];
    y_in[1] = lat[l * nv + 1];
    y_in[2] = lat[l * nv + 2];
    y_in[3] = lat[l * nv + 3];
    n_in = fix_lon(x_in, y_in, nv, M_PI);
    area[l] = poly_area(x_in, y_in, n_in);
  }
}


x86 assembly (clang, -O0):
<get_grid_area_ug>:
push   %rbp
mov    %rsp,%rbp
sub    $0x170,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x24(%rbp)
movl   $0x4,-0x30(%rbp)
movl   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%eax
cmp    -0x24(%rbp),%eax
jge    129b <get_grid_area_ug+0x17b>
mov    -0x10(%rbp),%rax
mov    -0x28(%rbp),%ecx
imul   -0x30(%rbp),%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0xd0(%rbp)
ff
mov    -0x10(%rbp),%rax
mov    -0x28(%rbp),%ecx
imul   -0x30(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0xc8(%rbp)
ff
mov    -0x10(%rbp),%rax
mov    -0x28(%rbp),%ecx
imul   -0x30(%rbp),%ecx
add    $0x2,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0xc0(%rbp)
ff
mov    -0x10(%rbp),%rax
mov    -0x28(%rbp),%ecx
imul   -0x30(%rbp),%ecx
add    $0x3,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0xb8(%rbp)
ff
mov    -0x18(%rbp),%rax
mov    -0x28(%rbp),%ecx
imul   -0x30(%rbp),%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x170(%rbp)
ff
mov    -0x18(%rbp),%rax
mov    -0x28(%rbp),%ecx
imul   -0x30(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x168(%rbp)
ff
mov    -0x18(%rbp),%rax
mov    -0x28(%rbp),%ecx
imul   -0x30(%rbp),%ecx
add    $0x2,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x160(%rbp)
ff
mov    -0x18(%rbp),%rax
mov    -0x28(%rbp),%ecx
imul   -0x30(%rbp),%ecx
add    $0x3,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x158(%rbp)
ff
lea    -0xd0(%rbp),%rdi
lea    -0x170(%rbp),%rsi
mov    -0x30(%rbp),%edx
mov    0x2d88(%rip),%rax
mov    (%rax),%ecx
call   1040 <fix_lon@plt>
mov    %eax,-0x2c(%rbp)
lea    -0xd0(%rbp),%rdi
lea    -0x170(%rbp),%rsi
mov    -0x2c(%rbp),%edx
call   1030 <poly_area@plt>
mov    -0x20(%rbp),%rax
movslq -0x28(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    1152 <get_grid_area_ug+0x32>
add    $0x170,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_grid_area_ug>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x158,%rsp
mov    (%rdi),%eax
mov    %rax,0x8(%rsp)
test   %eax,%eax
jle    11c8 <get_grid_area_ug+0xa8>
mov    %rcx,%rbp
mov    %rdx,%r15
mov    %rsi,%rbx
shlq   $0x3,0x8(%rsp)
xor    %r14d,%r14d
lea    0xb0(%rsp),%r12
lea    0x10(%rsp),%r13
nop
movups (%rbx,%r14,4),%xmm0
movaps %xmm0,0xb0(%rsp)
movups 0x10(%rbx,%r14,4),%xmm0
movaps %xmm0,0xc0(%rsp)
movups (%r15,%r14,4),%xmm0
movaps %xmm0,0x10(%rsp)
movups 0x10(%r15,%r14,4),%xmm0
movaps %xmm0,0x20(%rsp)
mov    0x2e51(%rip),%rax
mov    (%rax),%ecx
mov    %r12,%rdi
mov    %r13,%rsi
mov    $0x4,%edx
call   1040 <fix_lon@plt>
mov    %r12,%rdi
mov    %r13,%rsi
mov    %eax,%edx
call   1030 <poly_area@plt>
movsd  %xmm0,0x0(%rbp,%r14,1)
add    $0x8,%r14
cmp    %r14,0x8(%rsp)
jne    1160 <get_grid_area_ug+0x40>
add    $0x158,%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_ug(i32* %0, double* %1, double* %2, double* %3) {
%5 = alloca i32*
%6 = alloca double*
%7 = alloca double*
%8 = alloca double*
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca [20 x double]
%14 = alloca [20 x double]
store i32* %0, i32** %5
store double* %1, double** %6
store double* %2, double** %7
store double* %3, double** %8
%15 = load i32*, i32** %5
%16 = load i32, i32* %15
store i32 %16, i32* %9
store i32 4, i32* %12
store i32 0, i32* %10
br label %17
17: ; preds = %105, %4
%18 = load i32, i32* %10
%19 = load i32, i32* %9
%20 = icmp slt i32 %18, %19
br i1 %20, label %21, label %108
21: ; preds = %17
%22 = load double*, double** %6
%23 = load i32, i32* %10
%24 = load i32, i32* %12
%25 = mul nsw i32 %23, %24
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds double, double* %22, i64 %26
%28 = load double, double* %27
%29 = getelementptr inbounds [20 x double], [20 x double]* %13, i64 0, i64 0
store double %28, double* %29
%30 = load double*, double** %6
%31 = load i32, i32* %10
%32 = load i32, i32* %12
%33 = mul nsw i32 %31, %32
%34 = add nsw i32 %33, 1
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds double, double* %30, i64 %35
%37 = load double, double* %36
%38 = getelementptr inbounds [20 x double], [20 x double]* %13, i64 0, i64 1
store double %37, double* %38
%39 = load double*, double** %6
%40 = load i32, i32* %10
%41 = load i32, i32* %12
%42 = mul nsw i32 %40, %41
%43 = add nsw i32 %42, 2
%44 = sext i32 %43 to i64
%45 = getelementptr inbounds double, double* %39, i64 %44
%46 = load double, double* %45
%47 = getelementptr inbounds [20 x double], [20 x double]* %13, i64 0, i64 2
store double %46, double* %47
%48 = load double*, double** %6
%49 = load i32, i32* %10
%50 = load i32, i32* %12
%51 = mul nsw i32 %49, %50
%52 = add nsw i32 %51, 3
%53 = sext i32 %52 to i64
%54 = getelementptr inbounds double, double* %48, i64 %53
%55 = load double, double* %54
%56 = getelementptr inbounds [20 x double], [20 x double]* %13, i64 0, i64 3
store double %55, double* %56
%57 = load double*, double** %7
%58 = load i32, i32* %10
%59 = load i32, i32* %12
%60 = mul nsw i32 %58, %59
%61 = sext i32 %60 to i64
%62 = getelementptr inbounds double, double* %57, i64 %61
%63 = load double, double* %62
%64 = getelementptr inbounds [20 x double], [20 x double]* %14, i64 0, i64 0
store double %63, double* %64
%65 = load double*, double** %7
%66 = load i32, i32* %10
%67 = load i32, i32* %12
%68 = mul nsw i32 %66, %67
%69 = add nsw i32 %68, 1
%70 = sext i32 %69 to i64
%71 = getelementptr inbounds double, double* %65, i64 %70
%72 = load double, double* %71
%73 = getelementptr inbounds [20 x double], [20 x double]* %14, i64 0, i64 1
store double %72, double* %73
%74 = load double*, double** %7
%75 = load i32, i32* %10
%76 = load i32, i32* %12
%77 = mul nsw i32 %75, %76
%78 = add nsw i32 %77, 2
%79 = sext i32 %78 to i64
%80 = getelementptr inbounds double, double* %74, i64 %79
%81 = load double, double* %80
%82 = getelementptr inbounds [20 x double], [20 x double]* %14, i64 0, i64 2
store double %81, double* %82
%83 = load double*, double** %7
%84 = load i32, i32* %10
%85 = load i32, i32* %12
%86 = mul nsw i32 %84, %85
%87 = add nsw i32 %86, 3
%88 = sext i32 %87 to i64
%89 = getelementptr inbounds double, double* %83, i64 %88
%90 = load double, double* %89
%91 = getelementptr inbounds [20 x double], [20 x double]* %14, i64 0, i64 3
store double %90, double* %91
%92 = getelementptr inbounds [20 x double], [20 x double]* %13, i64 0, i64 0
%93 = getelementptr inbounds [20 x double], [20 x double]* %14, i64 0, i64 0
%94 = load i32, i32* %12
%95 = load i32, i32* @M_PI
%96 = call i32 @fix_lon(double* %92, double* %93, i32 %94, i32 %95)
store i32 %96, i32* %11
%97 = getelementptr inbounds [20 x double], [20 x double]* %13, i64 0, i64 0
%98 = getelementptr inbounds [20 x double], [20 x double]* %14, i64 0, i64 0
%99 = load i32, i32* %11
%100 = call double @poly_area(double* %97, double* %98, i32 %99)
%101 = load double*, double** %8
%102 = load i32, i32* %10
%103 = sext i32 %102 to i64
%104 = getelementptr inbounds double, double* %101, i64 %103
store double %100, double* %104
br label %105
105: ; preds = %21
%106 = load i32, i32* %10
%107 = add nsw i32 %106, 1
store i32 %107, i32* %10
br label %17
108: ; preds = %17
ret void
}

LLVM IR (-O2):
@M_PI = global i32 0
define void @get_grid_area_ug(i32* nocapture %0, double* nocapture %1, double* nocapture %2, double* nocapture writeonly %3) {
%5 = alloca [20 x double]
%6 = alloca [20 x double]
%7 = bitcast [20 x double]* %5 to i8*
%8 = bitcast [20 x double]* %6 to i8*
%9 = load i32, i32* %0
%10 = icmp sgt i32 %9, 0
br i1 %10, label %11, label %43
11: ; preds = %4
%12 = getelementptr inbounds [20 x double], [20 x double]* %5, i64 0, i64 0
%13 = getelementptr inbounds [20 x double], [20 x double]* %5, i64 0, i64 2
%14 = getelementptr inbounds [20 x double], [20 x double]* %6, i64 0, i64 0
%15 = getelementptr inbounds [20 x double], [20 x double]* %6, i64 0, i64 2
%16 = zext i32 %9 to i64
%17 = bitcast [20 x double]* %5 to <2 x double>*
%18 = bitcast double* %13 to <2 x double>*
%19 = bitcast [20 x double]* %6 to <2 x double>*
%20 = bitcast double* %15 to <2 x double>*
br label %21
21: ; preds = %11, %21
%22 = phi i64 [ 0, %11 ], [ %41, %21 ]
%23 = shl nsw i64 %22, 2
%24 = getelementptr inbounds double, double* %1, i64 %23
%25 = bitcast double* %24 to <2 x double>*
%26 = load <2 x double>, <2 x double>* %25
store <2 x double> %26, <2 x double>* %17
%27 = or i64 %23, 2
%28 = getelementptr inbounds double, double* %1, i64 %27
%29 = bitcast double* %28 to <2 x double>*
%30 = load <2 x double>, <2 x double>* %29
store <2 x double> %30, <2 x double>* %18
%31 = getelementptr inbounds double, double* %2, i64 %23
%32 = bitcast double* %31 to <2 x double>*
%33 = load <2 x double>, <2 x double>* %32
store <2 x double> %33, <2 x double>* %19
%34 = getelementptr inbounds double, double* %2, i64 %27
%35 = bitcast double* %34 to <2 x double>*
%36 = load <2 x double>, <2 x double>* %35
store <2 x double> %36, <2 x double>* %20
%37 = load i32, i32* @M_PI
%38 = call i32 @fix_lon(double* %12, double* %14, i32 4, i32 %37)
%39 = call double @poly_area(double* %12, double* %14, i32 %38)
%40 = getelementptr inbounds double, double* %3, i64 %22
store double %39, double* %40
%41 = add nuw nsw i64 %22, 1
%42 = icmp eq i64 %41, %16
br i1 %42, label %43, label %21
43: ; preds = %21, %4
ret void
}