#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 */
double cos(double);
double PolygonArea(int np, double *xp, double *yp, double yc) {
  int i, j;
  double area = 0.;
  for (i = 0; i < np; i++) {
    j = (i + 1) % np;
    area += (3.14159265358979323846 / 180.) * xp[i] *
            (3.14159265358979323846 / 180.) * yp[j];
    area -= (3.14159265358979323846 / 180.) * yp[i] *
            (3.14159265358979323846 / 180.) * xp[j];
  }
  area *= 0.5 * cos((3.14159265358979323846 / 180.) * yc);
  return (area);
}


x86 assembly (clang, -O0):
<PolygonArea>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
movsd  %xmm0,-0x20(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x30(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    11f5 <PolygonArea+0xe5>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
cltd
idivl  -0x4(%rbp)
mov    %edx,-0x28(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x24(%rbp),%rcx
movsd  0xea8(%rip),%xmm0
mulsd  (%rax,%rcx,8),%xmm0
movsd  0xe9b(%rip),%xmm1
mulsd  %xmm1,%xmm0
mov    -0x18(%rbp),%rax
movslq -0x28(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm2
movsd  -0x30(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
mov    -0x18(%rbp),%rax
movslq -0x24(%rbp),%rcx
movsd  0xe68(%rip),%xmm0
mulsd  (%rax,%rcx,8),%xmm0
movsd  0xe5b(%rip),%xmm1
mulsd  %xmm1,%xmm0
mov    -0x10(%rbp),%rax
movslq -0x28(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm2
movsd  -0x30(%rbp),%xmm1
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1137 <PolygonArea+0x27>
movsd  0xe0b(%rip),%xmm0
mulsd  -0x20(%rbp),%xmm0
call   1030 <cos@plt>
movaps %xmm0,%xmm1
movsd  0xdee(%rip),%xmm0
mulsd  %xmm1,%xmm0
mulsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x30(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<PolygonArea>:
push   %rax
test   %edi,%edi
jle    118f <PolygonArea+0x7f>
mov    %edi,%edi
neg    %rdi
xorpd  %xmm4,%xmm4
mov    $0x1,%ecx
xor    %r8d,%r8d
movsd  0xed2(%rip),%xmm1
movsd  0xed2(%rip),%xmm2
cs nopw 0x0(%rax,%rax,1)
mov    %rdi,%rax
add    %rcx,%rax
movsd  -0x8(%rsi,%rcx,8),%xmm3
mulsd  %xmm1,%xmm3
mulsd  %xmm1,%xmm3
mov    %rcx,%rax
cmove  %r8,%rax
mulsd  (%rdx,%rax,8),%xmm3
addsd  %xmm4,%xmm3
movsd  -0x8(%rdx,%rcx,8),%xmm4
mulsd  %xmm1,%xmm4
mulsd  %xmm2,%xmm4
mulsd  (%rsi,%rax,8),%xmm4
addsd  %xmm3,%xmm4
lea    (%rdi,%rcx,1),%rax
add    $0x1,%rax
add    $0x1,%rcx
cmp    $0x1,%rax
jne    1140 <PolygonArea+0x30>
jmp    1193 <PolygonArea+0x83>
xorpd  %xmm4,%xmm4
movsd  %xmm4,(%rsp)
mulsd  0xe60(%rip),%xmm0
call   1030 <cos@plt>
mulsd  0xe63(%rip),%xmm0
mulsd  (%rsp),%xmm0
pop    %rax
ret

LLVM IR (-O0):
define double @PolygonArea(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 double
store i32 %0, i32* %5
store double* %1, double** %6
store double* %2, double** %7
store double %3, double* %8
store double 0.000000e+00, double* %11
store i32 0, i32* %9
br label %12
12: ; preds = %50, %4
%13 = load i32, i32* %9
%14 = load i32, i32* %5
%15 = icmp slt i32 %13, %14
br i1 %15, label %16, label %53
16: ; preds = %12
%17 = load i32, i32* %9
%18 = add nsw i32 %17, 1
%19 = load i32, i32* %5
%20 = srem i32 %18, %19
store i32 %20, i32* %10
%21 = load double*, double** %6
%22 = load i32, i32* %9
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds double, double* %21, i64 %23
%25 = load double, double* %24
%26 = fmul double 0x3F91DF46A2529D39, %25
%27 = fmul double %26, 0x3F91DF46A2529D39
%28 = load double*, double** %7
%29 = load i32, i32* %10
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds double, double* %28, i64 %30
%32 = load double, double* %31
%33 = load double, double* %11
%34 = call double @llvm.fmuladd.f64(double %27, double %32, double %33)
store double %34, double* %11
%35 = load double*, double** %7
%36 = load i32, i32* %9
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds double, double* %35, i64 %37
%39 = load double, double* %38
%40 = fmul double 0x3F91DF46A2529D39, %39
%41 = fmul double %40, 0x3F91DF46A2529D39
%42 = load double*, double** %6
%43 = load i32, i32* %10
%44 = sext i32 %43 to i64
%45 = getelementptr inbounds double, double* %42, i64 %44
%46 = load double, double* %45
%47 = load double, double* %11
%48 = fneg double %41
%49 = call double @llvm.fmuladd.f64(double %48, double %46, double %47)
store double %49, double* %11
br label %50
50: ; preds = %16
%51 = load i32, i32* %9
%52 = add nsw i32 %51, 1
store i32 %52, i32* %9
br label %12
53: ; preds = %12
%54 = load double, double* %8
%55 = fmul double 0x3F91DF46A2529D39, %54
%56 = call double @cos(double %55)
%57 = fmul double 5.000000e-01, %56
%58 = load double, double* %11
%59 = fmul double %58, %57
store double %59, double* %11
%60 = load double, double* %11
ret double %60
}

LLVM IR (-O2):
define double @PolygonArea(i32 %0, double* nocapture %1, double* nocapture %2, double %3) {
%5 = icmp sgt i32 %0, 0
br i1 %5, label %6, label %30
6: ; preds = %4
%7 = zext i32 %0 to i64
br label %8
8: ; preds = %6, %8
%9 = phi i64 [ 0, %6 ], [ %11, %8 ]
%10 = phi double [ 0.000000e+00, %6 ], [ %28, %8 ]
%11 = add nuw nsw i64 %9, 1
%12 = icmp eq i64 %11, %7
%13 = getelementptr inbounds double, double* %1, i64 %9
%14 = load double, double* %13
%15 = fmul double %14, 0x3F91DF46A2529D39
%16 = fmul double %15, 0x3F91DF46A2529D39
%17 = and i64 %11, 4294967295
%18 = select i1 %12, i64 0, i64 %17
%19 = getelementptr inbounds double, double* %2, i64 %18
%20 = load double, double* %19
%21 = tail call double @llvm.fmuladd.f64(double %16, double %20, double %10)
%22 = getelementptr inbounds double, double* %2, i64 %9
%23 = load double, double* %22
%24 = fmul double %23, 0x3F91DF46A2529D39
%25 = getelementptr inbounds double, double* %1, i64 %18
%26 = load double, double* %25
%27 = fmul double %24, 0xBF91DF46A2529D39
%28 = tail call double @llvm.fmuladd.f64(double %27, double %26, double %21)
%29 = icmp eq i64 %11, %7
br i1 %29, label %30, label %8
30: ; preds = %8, %4
%31 = phi double [ 0.000000e+00, %4 ], [ %28, %8 ]
%32 = fmul double %3, 0x3F91DF46A2529D39
%33 = tail call double @cos(double %32)
%34 = fmul double %33, 5.000000e-01
%35 = fmul double %31, %34
ret double %35
}