#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 fabs(double);
double AdjustLongitude(double x) {
  long count = 0;
  for (;;) {
    if (fabs(x) <= 3.14159265358979323846264338327950288419716939937510)
      break;
    else if (((long)fabs(
                 x / 3.14159265358979323846264338327950288419716939937510)) < 2)
      x = x - (((x) < 0 ? -1 : 1) * 6.283185307179586476925286766558);
    else if (((long)fabs(x / 6.283185307179586476925286766558)) < 2147483647.) {
      x = x - (((long)(x / 6.283185307179586476925286766558)) *
               6.283185307179586476925286766558);
    } else if (((long)fabs(x /
                           (2147483647. * 6.283185307179586476925286766558))) <
               2147483647.) {
      x = x - (((long)(x / (2147483647. * 6.283185307179586476925286766558))) *
               (6.283185307179586476925286766558 * 2147483647.));
    } else if (((long)fabs(
                   x / (4.61168601e18 * 6.283185307179586476925286766558))) <
               2147483647.) {
      x = x -
          (((long)(x / (4.61168601e18 * 6.283185307179586476925286766558))) *
           (6.283185307179586476925286766558 * 4.61168601e18));
    } else
      x = x - (((x) < 0 ? -1 : 1) * 6.283185307179586476925286766558);
    count++;
    if (count > 4)
      break;
  }
  return (x);
}


x86 assembly (clang, -O0):
<AdjustLongitude>:
push   %rbp
mov    %rsp,%rbp
movsd  %xmm0,-0x8(%rbp)
movq   $0x0,-0x10(%rbp)
movsd  -0x8(%rbp),%xmm1
movaps 0xf13(%rip),%xmm0
pand   %xmm0,%xmm1
movsd  0xed7(%rip),%xmm0
ucomisd %xmm1,%xmm0
jb     1138 <AdjustLongitude+0x38>
jmp    13d4 <AdjustLongitude+0x2d4>
movsd  -0x8(%rbp),%xmm0
movsd  0xebb(%rip),%xmm1
divsd  %xmm1,%xmm0
movaps 0xee0(%rip),%xmm1
pand   %xmm1,%xmm0
cvttsd2si %xmm0,%rax
cmp    $0x2,%rax
jge    11b6 <AdjustLongitude+0xb6>
movsd  -0x8(%rbp),%xmm1
movsd  -0x8(%rbp),%xmm2
xorps  %xmm0,%xmm0
mov    $0x1,%eax
mov    $0xffffffff,%ecx
ucomisd %xmm2,%xmm0
cmova  %ecx,%eax
cvtsi2sd %eax,%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  0xe6c(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    13ae <AdjustLongitude+0x2ae>
movsd  -0x8(%rbp),%xmm0
movsd  0xe4d(%rip),%xmm1
divsd  %xmm1,%xmm0
movaps 0xe62(%rip),%xmm1
pand   %xmm1,%xmm0
cvttsd2si %xmm0,%rax
cvtsi2sd %rax,%xmm1
movsd  0xe24(%rip),%xmm0
ucomisd %xmm1,%xmm0
jbe    123f <AdjustLongitude+0x13f>
movsd  -0x8(%rbp),%xmm1
movsd  -0x8(%rbp),%xmm0
movsd  0xe10(%rip),%xmm2
divsd  %xmm2,%xmm0
cvttsd2si %xmm0,%rax
cvtsi2sd %rax,%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  0xde3(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    13a9 <AdjustLongitude+0x2a9>
movsd  -0x8(%rbp),%xmm0
movsd  0xdcc(%rip),%xmm1
divsd  %xmm1,%xmm0
movaps 0xdd9(%rip),%xmm1
pand   %xmm1,%xmm0
cvttsd2si %xmm0,%rax
cvtsi2sd %rax,%xmm1
movsd  0xd9b(%rip),%xmm0
ucomisd %xmm1,%xmm0
jbe    12c8 <AdjustLongitude+0x1c8>
movsd  -0x8(%rbp),%xmm1
movsd  -0x8(%rbp),%xmm0
movsd  0xd8f(%rip),%xmm2
divsd  %xmm2,%xmm0
cvttsd2si %xmm0,%rax
cvtsi2sd %rax,%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  0xd62(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    13a4 <AdjustLongitude+0x2a4>
movsd  -0x8(%rbp),%xmm0
movsd  0xd4b(%rip),%xmm1
divsd  %xmm1,%xmm0
movaps 0xd50(%rip),%xmm1
pand   %xmm1,%xmm0
cvttsd2si %xmm0,%rax
cvtsi2sd %rax,%xmm1
movsd  0xd12(%rip),%xmm0
ucomisd %xmm1,%xmm0
jbe    1351 <AdjustLongitude+0x251>
movsd  -0x8(%rbp),%xmm1
movsd  -0x8(%rbp),%xmm0
movsd  0xd0e(%rip),%xmm2
divsd  %xmm2,%xmm0
cvttsd2si %xmm0,%rax
cvtsi2sd %rax,%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  0xce1(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    139f <AdjustLongitude+0x29f>
movsd  -0x8(%rbp),%xmm1
movsd  -0x8(%rbp),%xmm2
xorps  %xmm0,%xmm0
mov    $0x1,%eax
mov    $0xffffffff,%ecx
ucomisd %xmm2,%xmm0
cmova  %ecx,%eax
cvtsi2sd %eax,%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  0xc7e(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    13a4 <AdjustLongitude+0x2a4>
jmp    13a9 <AdjustLongitude+0x2a9>
jmp    13ae <AdjustLongitude+0x2ae>
jmp    13b3 <AdjustLongitude+0x2b3>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
cmpq   $0x4,-0x10(%rbp)
jle    13cf <AdjustLongitude+0x2cf>
jmp    13d4 <AdjustLongitude+0x2d4>
jmp    1111 <AdjustLongitude+0x11>
movsd  -0x8(%rbp),%xmm0
pop    %rbp
ret

x86 assembly (clang, -O2):
<AdjustLongitude>:
mov    $0x5,%eax
movapd 0xef3(%rip),%xmm1
movsd  0xf0b(%rip),%xmm2
xorpd  %xmm3,%xmm3
lea    0xef0(%rip),%rcx
movsd  0xf00(%rip),%xmm4
movsd  0xf1f(%rip),%xmm11
movsd  0xef7(%rip),%xmm6
movsd  0xf06(%rip),%xmm8
movsd  0xeed(%rip),%xmm10
movsd  0xeec(%rip),%xmm9
jmp    1178 <AdjustLongitude+0x78>
cs nopw 0x0(%rax,%rax,1)
xor    %edx,%edx
ucomisd %xmm0,%xmm3
seta   %dl
addsd  (%rcx,%rdx,8),%xmm0
add    $0xffffffffffffffff,%rax
je     1257 <AdjustLongitude+0x157>
movapd %xmm0,%xmm7
andpd  %xmm1,%xmm7
ucomisd %xmm7,%xmm2
jae    1257 <AdjustLongitude+0x157>
movapd %xmm0,%xmm7
divsd  %xmm2,%xmm7
andpd  %xmm1,%xmm7
cvttsd2si %xmm7,%rdx
cmp    $0x1,%rdx
jle    1160 <AdjustLongitude+0x60>
movapd %xmm0,%xmm5
divsd  %xmm4,%xmm5
movapd %xmm5,%xmm7
andpd  %xmm1,%xmm7
cvttsd2si %xmm7,%rdx
cmp    $0x7ffffffe,%rdx
jg     11e0 <AdjustLongitude+0xe0>
cvttsd2si %xmm5,%rdx
xorps  %xmm5,%xmm5
cvtsi2sd %rdx,%xmm5
mulsd  %xmm11,%xmm5
addsd  %xmm5,%xmm0
jmp    116e <AdjustLongitude+0x6e>
nopw   0x0(%rax,%rax,1)
movapd %xmm0,%xmm7
divsd  %xmm6,%xmm7
movapd %xmm7,%xmm5
andpd  %xmm1,%xmm5
cvttsd2si %xmm5,%rdx
cmp    $0x7ffffffe,%rdx
jg     1219 <AdjustLongitude+0x119>
cvttsd2si %xmm7,%rdx
xorps  %xmm5,%xmm5
cvtsi2sd %rdx,%xmm5
mulsd  %xmm8,%xmm5
addsd  %xmm5,%xmm0
jmp    116e <AdjustLongitude+0x6e>
movapd %xmm0,%xmm7
divsd  %xmm10,%xmm7
movapd %xmm7,%xmm5
andpd  %xmm1,%xmm5
cvttsd2si %xmm5,%rdx
cmp    $0x7ffffffe,%rdx
jg     1160 <AdjustLongitude+0x60>
cvttsd2si %xmm7,%rdx
xorps  %xmm5,%xmm5
cvtsi2sd %rdx,%xmm5
mulsd  %xmm9,%xmm5
addsd  %xmm5,%xmm0
jmp    116e <AdjustLongitude+0x6e>
ret

LLVM IR (-O0):
define double @AdjustLongitude(double %0) {
%2 = alloca double
%3 = alloca i64
store double %0, double* %2
store i64 0, i64* %3
br label %4
4: ; preds = %88, %1
%5 = load double, double* %2
%6 = call double @llvm.fabs.f64(double %5)
%7 = fcmp ole double %6, 0x400921FB54442D18
br i1 %7, label %8, label %9
8: ; preds = %4
br label %89
9: ; preds = %4
%10 = load double, double* %2
%11 = fdiv double %10, 0x400921FB54442D18
%12 = call double @llvm.fabs.f64(double %11)
%13 = fptosi double %12 to i64
%14 = icmp slt i64 %13, 2
br i1 %14, label %15, label %24
15: ; preds = %9
%16 = load double, double* %2
%17 = load double, double* %2
%18 = fcmp olt double %17, 0.000000e+00
%19 = zext i1 %18 to i64
%20 = select i1 %18, i32 -1, i32 1
%21 = sitofp i32 %20 to double
%22 = fneg double %21
%23 = call double @llvm.fmuladd.f64(double %22, double 0x401921FB54442D18, double %16)
store double %23, double* %2
br label %81
24: ; preds = %9
%25 = load double, double* %2
%26 = fdiv double %25, 0x401921FB54442D18
%27 = call double @llvm.fabs.f64(double %26)
%28 = fptosi double %27 to i64
%29 = sitofp i64 %28 to double
%30 = fcmp olt double %29, 0x41DFFFFFFFC00000
br i1 %30, label %31, label %39
31: ; preds = %24
%32 = load double, double* %2
%33 = load double, double* %2
%34 = fdiv double %33, 0x401921FB54442D18
%35 = fptosi double %34 to i64
%36 = sitofp i64 %35 to double
%37 = fneg double %36
%38 = call double @llvm.fmuladd.f64(double %37, double 0x401921FB54442D18, double %32)
store double %38, double* %2
br label %80
39: ; preds = %24
%40 = load double, double* %2
%41 = fdiv double %40, 0x420921FB5411E921
%42 = call double @llvm.fabs.f64(double %41)
%43 = fptosi double %42 to i64
%44 = sitofp i64 %43 to double
%45 = fcmp olt double %44, 0x41DFFFFFFFC00000
br i1 %45, label %46, label %54
46: ; preds = %39
%47 = load double, double* %2
%48 = load double, double* %2
%49 = fdiv double %48, 0x420921FB5411E921
%50 = fptosi double %49 to i64
%51 = sitofp i64 %50 to double
%52 = fneg double %51
%53 = call double @llvm.fmuladd.f64(double %52, double 0x420921FB5411E921, double %47)
store double %53, double* %2
br label %79
54: ; preds = %39
%55 = load double, double* %2
%56 = fdiv double %55, 0x43F921FB537EEB3D
%57 = call double @llvm.fabs.f64(double %56)
%58 = fptosi double %57 to i64
%59 = sitofp i64 %58 to double
%60 = fcmp olt double %59, 0x41DFFFFFFFC00000
br i1 %60, label %61, label %69
61: ; preds = %54
%62 = load double, double* %2
%63 = load double, double* %2
%64 = fdiv double %63, 0x43F921FB537EEB3D
%65 = fptosi double %64 to i64
%66 = sitofp i64 %65 to double
%67 = fneg double %66
%68 = call double @llvm.fmuladd.f64(double %67, double 0x43F921FB537EEB3D, double %62)
store double %68, double* %2
br label %78
69: ; preds = %54
%70 = load double, double* %2
%71 = load double, double* %2
%72 = fcmp olt double %71, 0.000000e+00
%73 = zext i1 %72 to i64
%74 = select i1 %72, i32 -1, i32 1
%75 = sitofp i32 %74 to double
%76 = fneg double %75
%77 = call double @llvm.fmuladd.f64(double %76, double 0x401921FB54442D18, double %70)
store double %77, double* %2
br label %78
78: ; preds = %69, %61
br label %79
79: ; preds = %78, %46
br label %80
80: ; preds = %79, %31
br label %81
81: ; preds = %80, %15
br label %82
82: ; preds = %81
%83 = load i64, i64* %3
%84 = add nsw i64 %83, 1
store i64 %84, i64* %3
%85 = load i64, i64* %3
%86 = icmp sgt i64 %85, 4
br i1 %86, label %87, label %88
87: ; preds = %82
br label %89
88: ; preds = %82
br label %4
89: ; preds = %87, %8
%90 = load double, double* %2
ret double %90
}

LLVM IR (-O2):
define double @AdjustLongitude(double %0) {
br label %2
2: ; preds = %52, %1
%3 = phi double [ %0, %1 ], [ %53, %52 ]
%4 = phi i64 [ 0, %1 ], [ %54, %52 ]
%5 = tail call double @llvm.fabs.f64(double %3)
%6 = fcmp ugt double %5, 0x400921FB54442D18
br i1 %6, label %7, label %56
7: ; preds = %2
%8 = fdiv double %3, 0x400921FB54442D18
%9 = tail call double @llvm.fabs.f64(double %8)
%10 = fptosi double %9 to i64
%11 = icmp slt i64 %10, 2
br i1 %11, label %12, label %17
12: ; preds = %7
%13 = fcmp olt double %3, 0.000000e+00
%14 = select i1 %13, double -1.000000e+00, double 1.000000e+00
%15 = fneg double %14
%16 = tail call double @llvm.fmuladd.f64(double %15, double 0x401921FB54442D18, double %3)
br label %52
17: ; preds = %7
%18 = fdiv double %3, 0x401921FB54442D18
%19 = tail call double @llvm.fabs.f64(double %18)
%20 = fptosi double %19 to i64
%21 = icmp slt i64 %20, 2147483647
br i1 %21, label %22, label %27
22: ; preds = %17
%23 = fptosi double %18 to i64
%24 = sitofp i64 %23 to double
%25 = fneg double %24
%26 = tail call double @llvm.fmuladd.f64(double %25, double 0x401921FB54442D18, double %3)
br label %52
27: ; preds = %17
%28 = fdiv double %3, 0x420921FB5411E921
%29 = tail call double @llvm.fabs.f64(double %28)
%30 = fptosi double %29 to i64
%31 = icmp slt i64 %30, 2147483647
br i1 %31, label %32, label %37
32: ; preds = %27
%33 = fptosi double %28 to i64
%34 = sitofp i64 %33 to double
%35 = fneg double %34
%36 = tail call double @llvm.fmuladd.f64(double %35, double 0x420921FB5411E921, double %3)
br label %52
37: ; preds = %27
%38 = fdiv double %3, 0x43F921FB537EEB3D
%39 = tail call double @llvm.fabs.f64(double %38)
%40 = fptosi double %39 to i64
%41 = icmp slt i64 %40, 2147483647
br i1 %41, label %42, label %47
42: ; preds = %37
%43 = fptosi double %38 to i64
%44 = sitofp i64 %43 to double
%45 = fneg double %44
%46 = tail call double @llvm.fmuladd.f64(double %45, double 0x43F921FB537EEB3D, double %3)
br label %52
47: ; preds = %37
%48 = fcmp olt double %3, 0.000000e+00
%49 = select i1 %48, double -1.000000e+00, double 1.000000e+00
%50 = fneg double %49
%51 = tail call double @llvm.fmuladd.f64(double %50, double 0x401921FB54442D18, double %3)
br label %52
52: ; preds = %12, %32, %47, %42, %22
%53 = phi double [ %16, %12 ], [ %26, %22 ], [ %36, %32 ], [ %46, %42 ], [ %51, %47 ]
%54 = add nuw nsw i64 %4, 1
%55 = icmp eq i64 %54, 5
br i1 %55, label %56, label %2
56: ; preds = %52, %2
%57 = phi double [ %3, %2 ], [ %53, %52 ]
ret double %57
}