#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 polyArea(int, double *, double *);
scalar_t__ ptInPoly(double, double, int, double *, double *);
int rectClip(int, double *, double *, double *, double *, double, double,
             double, double);
double computeOverlapPP(double *ix, double *iy, double minX, double maxX,
                        double minY, double maxY, double pixelArea) {
  int npts;
  double area;
  double nx[100];
  double ny[100];
  double xp[4], yp[4];
  npts = rectClip(4, ix, iy, nx, ny, minX, minY, maxX, maxY);
  if (npts < 3) {
    xp[0] = minX;
    yp[0] = minY;
    xp[1] = maxX;
    yp[1] = minY;
    xp[2] = maxX;
    yp[2] = maxY;
    xp[3] = minX;
    yp[3] = maxY;
    if (ptInPoly(ix[0], iy[0], 4, xp, yp)) {
      area = pixelArea;
      return area;
    }
    return 0.;
  }
  area = polyArea(npts, nx, ny) * pixelArea;
  return (area);
}


x86 assembly (clang, -O0):
<computeOverlapPP>:
push   %rbp
mov    %rsp,%rbp
sub    $0x6d0,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
movsd  %xmm0,-0x20(%rbp)
movsd  %xmm1,-0x28(%rbp)
movsd  %xmm2,-0x30(%rbp)
movsd  %xmm3,-0x38(%rbp)
movsd  %xmm4,-0x40(%rbp)
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
lea    -0x370(%rbp),%rcx
lea    -0x690(%rbp),%r8
movsd  -0x20(%rbp),%xmm0
movsd  -0x30(%rbp),%xmm1
movsd  -0x28(%rbp),%xmm2
movsd  -0x38(%rbp),%xmm3
mov    $0x4,%edi
call   1050 <rectClip@plt>
mov    %eax,-0x44(%rbp)
cmpl   $0x3,-0x44(%rbp)
jge    125d <computeOverlapPP+0x12d>
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x6b0(%rbp)
ff
movsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x6d0(%rbp)
ff
movsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x6a8(%rbp)
ff
movsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x6c8(%rbp)
ff
movsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x6a0(%rbp)
ff
movsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x6c0(%rbp)
ff
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x698(%rbp)
ff
movsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x6b8(%rbp)
ff
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm0
mov    -0x18(%rbp),%rax
movsd  (%rax),%xmm1
lea    -0x6b0(%rbp),%rsi
lea    -0x6d0(%rbp),%rdx
mov    $0x4,%edi
call   1030 <ptInPoly@plt>
cmp    $0x0,%rax
je     1250 <computeOverlapPP+0x120>
movsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x50(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1287 <computeOverlapPP+0x157>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1287 <computeOverlapPP+0x157>
mov    -0x44(%rbp),%edi
lea    -0x370(%rbp),%rsi
lea    -0x690(%rbp),%rdx
call   1040 <polyArea@plt>
mulsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x50(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x6d0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<computeOverlapPP>:
push   %r14
push   %rbx
sub    $0x6b8,%rsp
movsd  %xmm4,0x8(%rsp)
movaps %xmm2,%xmm4
movaps %xmm1,%xmm2
mov    %rsi,%r14
mov    %rdi,%rbx
lea    0x390(%rsp),%rcx
lea    0x70(%rsp),%r8
mov    $0x4,%edi
mov    %rbx,%rsi
mov    %r14,%rdx
movsd  %xmm0,0x20(%rsp)
movsd  %xmm4,0x10(%rsp)
movaps %xmm4,%xmm1
movsd  %xmm2,0x18(%rsp)
movsd  %xmm3,0x28(%rsp)
call   1050 <rectClip@plt>
cmp    $0x2,%eax
jg     11ff <computeOverlapPP+0xcf>
movsd  0x20(%rsp),%xmm1
movsd  %xmm1,0x50(%rsp)
movsd  0x10(%rsp),%xmm2
movsd  %xmm2,0x30(%rsp)
movsd  0x18(%rsp),%xmm0
movsd  %xmm0,0x58(%rsp)
movsd  %xmm2,0x38(%rsp)
movsd  %xmm0,0x60(%rsp)
movsd  0x28(%rsp),%xmm0
movsd  %xmm0,0x40(%rsp)
movsd  %xmm1,0x68(%rsp)
movsd  %xmm0,0x48(%rsp)
movsd  (%rbx),%xmm0
movsd  (%r14),%xmm1
lea    0x50(%rsp),%rsi
lea    0x30(%rsp),%rdx
mov    $0x4,%edi
call   1030 <ptInPoly@plt>
xorpd  %xmm0,%xmm0
test   %rax,%rax
je     1219 <computeOverlapPP+0xe9>
movsd  0x8(%rsp),%xmm0
jmp    1219 <computeOverlapPP+0xe9>
lea    0x390(%rsp),%rsi
lea    0x70(%rsp),%rdx
mov    %eax,%edi
call   1040 <polyArea@plt>
mulsd  0x8(%rsp),%xmm0
add    $0x6b8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define double @computeOverlapPP(double* %0, double* %1, double %2, double %3, double %4, double %5, double %6) {
%8 = alloca double
%9 = alloca double*
%10 = alloca double*
%11 = alloca double
%12 = alloca double
%13 = alloca double
%14 = alloca double
%15 = alloca double
%16 = alloca i32
%17 = alloca double
%18 = alloca [100 x double]
%19 = alloca [100 x double]
%20 = alloca [4 x double]
%21 = alloca [4 x double]
store double* %0, double** %9
store double* %1, double** %10
store double %2, double* %11
store double %3, double* %12
store double %4, double* %13
store double %5, double* %14
store double %6, double* %15
%22 = load double*, double** %9
%23 = load double*, double** %10
%24 = getelementptr inbounds [100 x double], [100 x double]* %18, i64 0, i64 0
%25 = getelementptr inbounds [100 x double], [100 x double]* %19, i64 0, i64 0
%26 = load double, double* %11
%27 = load double, double* %13
%28 = load double, double* %12
%29 = load double, double* %14
%30 = call i32 @rectClip(i32 4, double* %22, double* %23, double* %24, double* %25, double %26, double %27, double %28, double %29)
store i32 %30, i32* %16
%31 = load i32, i32* %16
%32 = icmp slt i32 %31, 3
br i1 %32, label %33, label %64
33: ; preds = %7
%34 = load double, double* %11
%35 = getelementptr inbounds [4 x double], [4 x double]* %20, i64 0, i64 0
store double %34, double* %35
%36 = load double, double* %13
%37 = getelementptr inbounds [4 x double], [4 x double]* %21, i64 0, i64 0
store double %36, double* %37
%38 = load double, double* %12
%39 = getelementptr inbounds [4 x double], [4 x double]* %20, i64 0, i64 1
store double %38, double* %39
%40 = load double, double* %13
%41 = getelementptr inbounds [4 x double], [4 x double]* %21, i64 0, i64 1
store double %40, double* %41
%42 = load double, double* %12
%43 = getelementptr inbounds [4 x double], [4 x double]* %20, i64 0, i64 2
store double %42, double* %43
%44 = load double, double* %14
%45 = getelementptr inbounds [4 x double], [4 x double]* %21, i64 0, i64 2
store double %44, double* %45
%46 = load double, double* %11
%47 = getelementptr inbounds [4 x double], [4 x double]* %20, i64 0, i64 3
store double %46, double* %47
%48 = load double, double* %14
%49 = getelementptr inbounds [4 x double], [4 x double]* %21, i64 0, i64 3
store double %48, double* %49
%50 = load double*, double** %9
%51 = getelementptr inbounds double, double* %50, i64 0
%52 = load double, double* %51
%53 = load double*, double** %10
%54 = getelementptr inbounds double, double* %53, i64 0
%55 = load double, double* %54
%56 = getelementptr inbounds [4 x double], [4 x double]* %20, i64 0, i64 0
%57 = getelementptr inbounds [4 x double], [4 x double]* %21, i64 0, i64 0
%58 = call i64 @ptInPoly(double %52, double %55, i32 4, double* %56, double* %57)
%59 = icmp ne i64 %58, 0
br i1 %59, label %60, label %63
60: ; preds = %33
%61 = load double, double* %15
store double %61, double* %17
%62 = load double, double* %17
store double %62, double* %8
br label %72
63: ; preds = %33
store double 0.000000e+00, double* %8
br label %72
64: ; preds = %7
%65 = load i32, i32* %16
%66 = getelementptr inbounds [100 x double], [100 x double]* %18, i64 0, i64 0
%67 = getelementptr inbounds [100 x double], [100 x double]* %19, i64 0, i64 0
%68 = call double @polyArea(i32 %65, double* %66, double* %67)
%69 = load double, double* %15
%70 = fmul double %68, %69
store double %70, double* %17
%71 = load double, double* %17
store double %71, double* %8
br label %72
72: ; preds = %64, %63, %60
%73 = load double, double* %8
ret double %73
}

LLVM IR (-O2):
define double @computeOverlapPP(double* %0, double* %1, double %2, double %3, double %4, double %5, double %6) {
%8 = alloca [100 x double]
%9 = alloca [100 x double]
%10 = alloca [4 x double]
%11 = alloca [4 x double]
%12 = bitcast [100 x double]* %8 to i8*
%13 = bitcast [100 x double]* %9 to i8*
%14 = bitcast [4 x double]* %10 to i8*
%15 = bitcast [4 x double]* %11 to i8*
%16 = getelementptr inbounds [100 x double], [100 x double]* %8, i64 0, i64 0
%17 = getelementptr inbounds [100 x double], [100 x double]* %9, i64 0, i64 0
%18 = call i32 @rectClip(i32 4, double* %0, double* %1, double* %16, double* %17, double %2, double %4, double %3, double %5)
%19 = icmp slt i32 %18, 3
br i1 %19, label %20, label %34
20: ; preds = %7
%21 = getelementptr inbounds [4 x double], [4 x double]* %10, i64 0, i64 0
store double %2, double* %21
%22 = getelementptr inbounds [4 x double], [4 x double]* %11, i64 0, i64 0
store double %4, double* %22
%23 = getelementptr inbounds [4 x double], [4 x double]* %10, i64 0, i64 1
store double %3, double* %23
%24 = getelementptr inbounds [4 x double], [4 x double]* %11, i64 0, i64 1
store double %4, double* %24
%25 = getelementptr inbounds [4 x double], [4 x double]* %10, i64 0, i64 2
store double %3, double* %25
%26 = getelementptr inbounds [4 x double], [4 x double]* %11, i64 0, i64 2
store double %5, double* %26
%27 = getelementptr inbounds [4 x double], [4 x double]* %10, i64 0, i64 3
store double %2, double* %27
%28 = getelementptr inbounds [4 x double], [4 x double]* %11, i64 0, i64 3
store double %5, double* %28
%29 = load double, double* %0
%30 = load double, double* %1
%31 = call i64 @ptInPoly(double %29, double %30, i32 4, double* %21, double* %22)
%32 = icmp eq i64 %31, 0
%33 = select i1 %32, double 0.000000e+00, double %6
br label %37
34: ; preds = %7
%35 = call double @polyArea(i32 %18, double* %16, double* %17)
%36 = fmul double %35, %6
br label %37
37: ; preds = %20, %34
%38 = phi double [ %36, %34 ], [ %33, %20 ]
ret double %38
}