#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 M_PI;
int __check_intersects_no_norm(double, double, double, double, double, double,
                               double, double);
int fabs(double);
int check_intersects(double latitude, double longitude, double new_latitude,
                     double new_longitude, double seg_a_latitude,
                     double seg_a_longitude, double seg_b_latitude,
                     double seg_b_longitude) {
  if (longitude < 0) {
    longitude += M_PI * 2;
  }
  if (new_longitude < 0) {
    new_longitude += M_PI * 2;
  }
  if (seg_a_longitude < 0) {
    seg_a_longitude += M_PI * 2;
  }
  if (seg_b_longitude < 0) {
    seg_b_longitude += M_PI * 2;
  }
  if (fabs(longitude - new_longitude) > M_PI) {
    if (longitude > new_longitude) {
      longitude -= M_PI * 2;
    } else {
      new_longitude -= M_PI * 2;
    }
  }
  if (fabs(seg_a_longitude - seg_b_longitude) > M_PI) {
    if (seg_a_longitude > seg_b_longitude) {
      seg_a_longitude -= M_PI * 2;
    } else {
      seg_b_longitude -= M_PI * 2;
    }
  }
  if (fabs(longitude - seg_a_longitude) > M_PI) {
    if (longitude > seg_a_longitude) {
      longitude -= M_PI * 2;
      new_longitude -= M_PI * 2;
    } else {
      seg_a_longitude -= M_PI * 2;
      seg_b_longitude -= M_PI * 2;
    }
  }
  return __check_intersects_no_norm(
      latitude, longitude, new_latitude, new_longitude, seg_a_latitude,
      seg_a_longitude, seg_b_latitude, seg_b_longitude);
}


x86 assembly (clang, -O0):
<check_intersects>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
movsd  %xmm2,-0x18(%rbp)
movsd  %xmm3,-0x20(%rbp)
movsd  %xmm4,-0x28(%rbp)
movsd  %xmm5,-0x30(%rbp)
movsd  %xmm6,-0x38(%rbp)
movsd  %xmm7,-0x40(%rbp)
xorps  %xmm0,%xmm0
ucomisd -0x10(%rbp),%xmm0
jbe    1178 <check_intersects+0x58>
mov    0x2e83(%rip),%rax
mov    (%rax),%eax
shl    $0x1,%eax
cvtsi2sd %eax,%xmm0
addsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x10(%rbp)
xorps  %xmm0,%xmm0
ucomisd -0x20(%rbp),%xmm0
jbe    11a0 <check_intersects+0x80>
mov    0x2e5b(%rip),%rax
mov    (%rax),%eax
shl    $0x1,%eax
cvtsi2sd %eax,%xmm0
addsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
xorps  %xmm0,%xmm0
ucomisd -0x30(%rbp),%xmm0
jbe    11c8 <check_intersects+0xa8>
mov    0x2e33(%rip),%rax
mov    (%rax),%eax
shl    $0x1,%eax
cvtsi2sd %eax,%xmm0
addsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
xorps  %xmm0,%xmm0
ucomisd -0x40(%rbp),%xmm0
jbe    11f0 <check_intersects+0xd0>
mov    0x2e0b(%rip),%rax
mov    (%rax),%eax
shl    $0x1,%eax
cvtsi2sd %eax,%xmm0
addsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x10(%rbp),%xmm0
subsd  -0x20(%rbp),%xmm0
call   1030 <fabs@plt>
mov    0x2de2(%rip),%rcx
cmp    (%rcx),%eax
jle    1264 <check_intersects+0x144>
movsd  -0x10(%rbp),%xmm0
ucomisd -0x20(%rbp),%xmm0
jbe    1241 <check_intersects+0x121>
mov    0x2dc3(%rip),%rax
mov    (%rax),%eax
shl    $0x1,%eax
cvtsi2sd %eax,%xmm1
movsd  -0x10(%rbp),%xmm0
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x10(%rbp)
jmp    125f <check_intersects+0x13f>
mov    0x2da0(%rip),%rax
mov    (%rax),%eax
shl    $0x1,%eax
cvtsi2sd %eax,%xmm1
movsd  -0x20(%rbp),%xmm0
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
jmp    1264 <check_intersects+0x144>
movsd  -0x30(%rbp),%xmm0
subsd  -0x40(%rbp),%xmm0
call   1030 <fabs@plt>
mov    0x2d6e(%rip),%rcx
cmp    (%rcx),%eax
jle    12d8 <check_intersects+0x1b8>
movsd  -0x30(%rbp),%xmm0
ucomisd -0x40(%rbp),%xmm0
jbe    12b5 <check_intersects+0x195>
mov    0x2d4f(%rip),%rax
mov    (%rax),%eax
shl    $0x1,%eax
cvtsi2sd %eax,%xmm1
movsd  -0x30(%rbp),%xmm0
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
jmp    12d3 <check_intersects+0x1b3>
mov    0x2d2c(%rip),%rax
mov    (%rax),%eax
shl    $0x1,%eax
cvtsi2sd %eax,%xmm1
movsd  -0x40(%rbp),%xmm0
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
jmp    12d8 <check_intersects+0x1b8>
movsd  -0x10(%rbp),%xmm0
subsd  -0x30(%rbp),%xmm0
call   1030 <fabs@plt>
mov    0x2cfa(%rip),%rcx
cmp    (%rcx),%eax
jle    1388 <check_intersects+0x268>
movsd  -0x10(%rbp),%xmm0
ucomisd -0x30(%rbp),%xmm0
jbe    1347 <check_intersects+0x227>
mov    0x2cdb(%rip),%rax
mov    (%rax),%eax
shl    $0x1,%eax
cvtsi2sd %eax,%xmm1
movsd  -0x10(%rbp),%xmm0
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x10(%rbp)
mov    0x2cbd(%rip),%rax
mov    (%rax),%eax
shl    $0x1,%eax
cvtsi2sd %eax,%xmm1
movsd  -0x20(%rbp),%xmm0
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
jmp    1383 <check_intersects+0x263>
mov    0x2c9a(%rip),%rax
mov    (%rax),%eax
shl    $0x1,%eax
cvtsi2sd %eax,%xmm1
movsd  -0x30(%rbp),%xmm0
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
mov    0x2c7c(%rip),%rax
mov    (%rax),%eax
shl    $0x1,%eax
cvtsi2sd %eax,%xmm1
movsd  -0x40(%rbp),%xmm0
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
jmp    1388 <check_intersects+0x268>
movsd  -0x8(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm1
movsd  -0x18(%rbp),%xmm2
movsd  -0x20(%rbp),%xmm3
movsd  -0x28(%rbp),%xmm4
movsd  -0x30(%rbp),%xmm5
movsd  -0x38(%rbp),%xmm6
movsd  -0x40(%rbp),%xmm7
call   1040 <__check_intersects_no_norm@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<check_intersects>:
push   %rbx
sub    $0x60,%rsp
mov    0x2ebc(%rip),%rbx
mov    (%rbx),%eax
add    %eax,%eax
cvtsi2sd %eax,%xmm8
movsd  %xmm6,0x48(%rsp)
movsd  %xmm4,0x40(%rsp)
movsd  %xmm2,0x38(%rsp)
movsd  %xmm0,0x30(%rsp)
xorpd  %xmm0,%xmm0
movapd %xmm1,%xmm6
cmpltsd %xmm0,%xmm6
movsd  0xe9e(%rip),%xmm2
movapd %xmm6,%xmm4
andnpd %xmm2,%xmm4
andpd  %xmm8,%xmm6
orpd   %xmm4,%xmm6
addsd  %xmm1,%xmm6
movapd %xmm3,%xmm4
cmpltsd %xmm0,%xmm4
movapd %xmm4,%xmm1
andnpd %xmm2,%xmm1
andpd  %xmm8,%xmm4
orpd   %xmm1,%xmm4
addsd  %xmm3,%xmm4
movapd %xmm5,%xmm3
cmpltsd %xmm0,%xmm3
movapd %xmm3,%xmm1
andnpd %xmm2,%xmm1
andpd  %xmm8,%xmm3
orpd   %xmm1,%xmm3
addsd  %xmm5,%xmm3
movapd %xmm3,0x10(%rsp)
movapd %xmm7,%xmm1
cmpltsd %xmm0,%xmm1
movapd %xmm1,%xmm0
andnpd %xmm2,%xmm0
andpd  %xmm8,%xmm1
orpd   %xmm0,%xmm1
addsd  %xmm7,%xmm1
movapd %xmm1,0x20(%rsp)
movapd %xmm6,(%rsp)
movapd %xmm6,%xmm0
movapd %xmm4,0x50(%rsp)
subsd  %xmm4,%xmm0
call   1030 <fabs@plt>
mov    (%rbx),%ecx
cmp    %ecx,%eax
jle    122c <check_intersects+0x10c>
add    %ecx,%ecx
movapd (%rsp),%xmm1
movapd 0x50(%rsp),%xmm2
ucomisd %xmm2,%xmm1
xorps  %xmm0,%xmm0
cvtsi2sd %ecx,%xmm0
movapd 0x10(%rsp),%xmm3
movapd 0x20(%rsp),%xmm4
jbe    123a <check_intersects+0x11a>
subsd  %xmm0,%xmm1
movapd %xmm1,(%rsp)
jmp    1244 <check_intersects+0x124>
movapd 0x10(%rsp),%xmm3
movapd 0x20(%rsp),%xmm4
jmp    1244 <check_intersects+0x124>
subsd  %xmm0,%xmm2
movapd %xmm2,0x50(%rsp)
movapd %xmm3,%xmm0
subsd  %xmm4,%xmm0
call   1030 <fabs@plt>
mov    (%rbx),%ecx
cmp    %ecx,%eax
jle    127d <check_intersects+0x15d>
add    %ecx,%ecx
movapd 0x10(%rsp),%xmm2
movapd 0x20(%rsp),%xmm3
ucomisd %xmm3,%xmm2
xorps  %xmm0,%xmm0
cvtsi2sd %ecx,%xmm0
movapd (%rsp),%xmm1
jbe    128a <check_intersects+0x16a>
subsd  %xmm0,%xmm2
jmp    1294 <check_intersects+0x174>
movapd (%rsp),%xmm1
movapd 0x10(%rsp),%xmm2
jmp    1294 <check_intersects+0x174>
subsd  %xmm0,%xmm3
movapd %xmm3,0x20(%rsp)
movapd %xmm1,(%rsp)
movapd %xmm2,0x10(%rsp)
movapd %xmm1,%xmm0
subsd  %xmm2,%xmm0
call   1030 <fabs@plt>
mov    (%rbx),%ecx
cmp    %ecx,%eax
jle    12fa <check_intersects+0x1da>
add    %ecx,%ecx
movapd 0x10(%rsp),%xmm5
movapd (%rsp),%xmm1
ucomisd %xmm5,%xmm1
cvtsi2sd %ecx,%xmm8
movsd  0x48(%rsp),%xmm6
movsd  0x40(%rsp),%xmm4
movsd  0x38(%rsp),%xmm2
movsd  0x30(%rsp),%xmm0
movapd 0x50(%rsp),%xmm3
movapd 0x20(%rsp),%xmm7
jbe    132b <check_intersects+0x20b>
subsd  %xmm8,%xmm1
subsd  %xmm8,%xmm3
jmp    1335 <check_intersects+0x215>
movsd  0x48(%rsp),%xmm6
movsd  0x40(%rsp),%xmm4
movsd  0x38(%rsp),%xmm2
movsd  0x30(%rsp),%xmm0
movapd (%rsp),%xmm1
movapd 0x50(%rsp),%xmm3
movapd 0x10(%rsp),%xmm5
movapd 0x20(%rsp),%xmm7
jmp    1335 <check_intersects+0x215>
subsd  %xmm8,%xmm5
subsd  %xmm8,%xmm7
add    $0x60,%rsp
pop    %rbx
jmp    1040 <__check_intersects_no_norm@plt>

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

LLVM IR (-O2):
@M_PI = global i32 0
define i32 @check_intersects(double %0, double %1, double %2, double %3, double %4, double %5, double %6, double %7) {
%9 = fcmp olt double %1, 0.000000e+00
%10 = load i32, i32* @M_PI
%11 = shl nsw i32 %10, 1
%12 = sitofp i32 %11 to double
%13 = select i1 %9, double %12, double -0.000000e+00
%14 = fadd double %13, %1
%15 = fcmp olt double %3, 0.000000e+00
%16 = select i1 %15, double %12, double -0.000000e+00
%17 = fadd double %16, %3
%18 = fcmp olt double %5, 0.000000e+00
%19 = select i1 %18, double %12, double -0.000000e+00
%20 = fadd double %19, %5
%21 = fcmp olt double %7, 0.000000e+00
%22 = select i1 %21, double %12, double -0.000000e+00
%23 = fadd double %22, %7
%24 = fsub double %14, %17
%25 = tail call i32 @fabs(double %24)
%26 = load i32, i32* @M_PI
%27 = icmp sgt i32 %25, %26
br i1 %27, label %28, label %36
28: ; preds = %8
%29 = fcmp ogt double %14, %17
%30 = shl nsw i32 %26, 1
%31 = sitofp i32 %30 to double
br i1 %29, label %32, label %34
32: ; preds = %28
%33 = fsub double %14, %31
br label %36
34: ; preds = %28
%35 = fsub double %17, %31
br label %36
36: ; preds = %32, %34, %8
%37 = phi double [ %17, %32 ], [ %35, %34 ], [ %17, %8 ]
%38 = phi double [ %33, %32 ], [ %14, %34 ], [ %14, %8 ]
%39 = fsub double %20, %23
%40 = tail call i32 @fabs(double %39)
%41 = load i32, i32* @M_PI
%42 = icmp sgt i32 %40, %41
br i1 %42, label %43, label %51
43: ; preds = %36
%44 = fcmp ogt double %20, %23
%45 = shl nsw i32 %41, 1
%46 = sitofp i32 %45 to double
br i1 %44, label %47, label %49
47: ; preds = %43
%48 = fsub double %20, %46
br label %51
49: ; preds = %43
%50 = fsub double %23, %46
br label %51
51: ; preds = %47, %49, %36
%52 = phi double [ %48, %47 ], [ %20, %49 ], [ %20, %36 ]
%53 = phi double [ %23, %47 ], [ %50, %49 ], [ %23, %36 ]
%54 = fsub double %38, %52
%55 = tail call i32 @fabs(double %54)
%56 = load i32, i32* @M_PI
%57 = icmp sgt i32 %55, %56
br i1 %57, label %58, label %68
58: ; preds = %51
%59 = fcmp ogt double %38, %52
%60 = shl nsw i32 %56, 1
%61 = sitofp i32 %60 to double
br i1 %59, label %62, label %65
62: ; preds = %58
%63 = fsub double %38, %61
%64 = fsub double %37, %61
br label %68
65: ; preds = %58
%66 = fsub double %52, %61
%67 = fsub double %53, %61
br label %68
68: ; preds = %62, %65, %51
%69 = phi double [ %64, %62 ], [ %37, %65 ], [ %37, %51 ]
%70 = phi double [ %52, %62 ], [ %66, %65 ], [ %52, %51 ]
%71 = phi double [ %63, %62 ], [ %38, %65 ], [ %38, %51 ]
%72 = phi double [ %53, %62 ], [ %67, %65 ], [ %53, %51 ]
%73 = tail call i32 @__check_intersects_no_norm(double %0, double %71, double %2, double %69, double %4, double %70, double %6, double %72)
ret i32 %73
}