#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;
double __intersects_no_norm(double, double, double, double, double, double,
                            double, double, double *, double *);
int fabs(double);
double 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, double *inter_latitude,
                  double *inter_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 __intersects_no_norm(latitude, longitude, new_latitude, new_longitude,
                              seg_a_latitude, seg_a_longitude, seg_b_latitude,
                              seg_b_longitude, inter_latitude, inter_longitude);
}


x86 assembly (clang, -O0):
<intersects>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%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)
mov    %rdi,-0x48(%rbp)
mov    %rsi,-0x50(%rbp)
xorps  %xmm0,%xmm0
ucomisd -0x10(%rbp),%xmm0
jbe    1180 <intersects+0x60>
mov    0x2e7b(%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    11a8 <intersects+0x88>
mov    0x2e53(%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    11d0 <intersects+0xb0>
mov    0x2e2b(%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    11f8 <intersects+0xd8>
mov    0x2e03(%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    0x2dda(%rip),%rcx
cmp    (%rcx),%eax
jle    126c <intersects+0x14c>
movsd  -0x10(%rbp),%xmm0
ucomisd -0x20(%rbp),%xmm0
jbe    1249 <intersects+0x129>
mov    0x2dbb(%rip),%rax
mov    (%rax),%eax
shl    $0x1,%eax
cvtsi2sd %eax,%xmm1
movsd  -0x10(%rbp),%xmm0
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x10(%rbp)
jmp    1267 <intersects+0x147>
mov    0x2d98(%rip),%rax
mov    (%rax),%eax
shl    $0x1,%eax
cvtsi2sd %eax,%xmm1
movsd  -0x20(%rbp),%xmm0
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
jmp    126c <intersects+0x14c>
movsd  -0x30(%rbp),%xmm0
subsd  -0x40(%rbp),%xmm0
call   1030 <fabs@plt>
mov    0x2d66(%rip),%rcx
cmp    (%rcx),%eax
jle    12e0 <intersects+0x1c0>
movsd  -0x30(%rbp),%xmm0
ucomisd -0x40(%rbp),%xmm0
jbe    12bd <intersects+0x19d>
mov    0x2d47(%rip),%rax
mov    (%rax),%eax
shl    $0x1,%eax
cvtsi2sd %eax,%xmm1
movsd  -0x30(%rbp),%xmm0
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
jmp    12db <intersects+0x1bb>
mov    0x2d24(%rip),%rax
mov    (%rax),%eax
shl    $0x1,%eax
cvtsi2sd %eax,%xmm1
movsd  -0x40(%rbp),%xmm0
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
jmp    12e0 <intersects+0x1c0>
movsd  -0x10(%rbp),%xmm0
subsd  -0x30(%rbp),%xmm0
call   1030 <fabs@plt>
mov    0x2cf2(%rip),%rcx
cmp    (%rcx),%eax
jle    1390 <intersects+0x270>
movsd  -0x10(%rbp),%xmm0
ucomisd -0x30(%rbp),%xmm0
jbe    134f <intersects+0x22f>
mov    0x2cd3(%rip),%rax
mov    (%rax),%eax
shl    $0x1,%eax
cvtsi2sd %eax,%xmm1
movsd  -0x10(%rbp),%xmm0
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x10(%rbp)
mov    0x2cb5(%rip),%rax
mov    (%rax),%eax
shl    $0x1,%eax
cvtsi2sd %eax,%xmm1
movsd  -0x20(%rbp),%xmm0
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
jmp    138b <intersects+0x26b>
mov    0x2c92(%rip),%rax
mov    (%rax),%eax
shl    $0x1,%eax
cvtsi2sd %eax,%xmm1
movsd  -0x30(%rbp),%xmm0
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
mov    0x2c74(%rip),%rax
mov    (%rax),%eax
shl    $0x1,%eax
cvtsi2sd %eax,%xmm1
movsd  -0x40(%rbp),%xmm0
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
jmp    1390 <intersects+0x270>
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
mov    -0x48(%rbp),%rdi
mov    -0x50(%rbp),%rsi
call   1040 <__intersects_no_norm@plt>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<intersects>:
push   %r15
push   %r14
push   %rbx
sub    $0x60,%rsp
mov    0x2eb8(%rip),%rbx
mov    (%rbx),%eax
add    %eax,%eax
cvtsi2sd %eax,%xmm8
mov    %rsi,%r14
mov    %rdi,%r15
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  0xe94(%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    1236 <intersects+0x116>
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    1244 <intersects+0x124>
subsd  %xmm0,%xmm1
movapd %xmm1,(%rsp)
jmp    124e <intersects+0x12e>
movapd 0x10(%rsp),%xmm3
movapd 0x20(%rsp),%xmm4
jmp    124e <intersects+0x12e>
subsd  %xmm0,%xmm2
movapd %xmm2,0x50(%rsp)
movapd %xmm3,%xmm0
subsd  %xmm4,%xmm0
call   1030 <fabs@plt>
mov    (%rbx),%ecx
cmp    %ecx,%eax
jle    1287 <intersects+0x167>
add    %ecx,%ecx
movapd 0x10(%rsp),%xmm2
movapd 0x20(%rsp),%xmm3
ucomisd %xmm3,%xmm2
xorps  %xmm0,%xmm0
cvtsi2sd %ecx,%xmm0
movapd (%rsp),%xmm1
jbe    1294 <intersects+0x174>
subsd  %xmm0,%xmm2
jmp    129e <intersects+0x17e>
movapd (%rsp),%xmm1
movapd 0x10(%rsp),%xmm2
jmp    129e <intersects+0x17e>
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    1304 <intersects+0x1e4>
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    1335 <intersects+0x215>
subsd  %xmm8,%xmm1
subsd  %xmm8,%xmm3
jmp    133f <intersects+0x21f>
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    133f <intersects+0x21f>
subsd  %xmm8,%xmm5
subsd  %xmm8,%xmm7
mov    %r15,%rdi
mov    %r14,%rsi
add    $0x60,%rsp
pop    %rbx
pop    %r14
pop    %r15
jmp    1040 <__intersects_no_norm@plt>

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

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