#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 fmod(double, double);
double MapsWithMe_LonIn180180(double lon) {
  if (lon >= 0)
    return fmod(lon + 180.0, 360.0) - 180.0;
  else {
    double const l = fmod(lon - 180.0, 360.0) + 180.0;
    return l < 180.0 ? l : l - 360.0;
  }
}


x86 assembly (clang, -O0):
<MapsWithMe_LonIn180180>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movsd  %xmm0,-0x10(%rbp)
movsd  -0x10(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jb     115f <MapsWithMe_LonIn180180+0x4f>
movsd  0xec9(%rip),%xmm0
addsd  -0x10(%rbp),%xmm0
movsd  0xec4(%rip),%xmm1
call   1030 <fmod@plt>
movsd  0xeaf(%rip),%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    11d0 <MapsWithMe_LonIn180180+0xc0>
movsd  -0x10(%rbp),%xmm0
movsd  0xe94(%rip),%xmm1
subsd  %xmm1,%xmm0
movsd  0xe90(%rip),%xmm1
call   1030 <fmod@plt>
movsd  0xe7b(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  0xe6a(%rip),%xmm0
ucomisd -0x18(%rbp),%xmm0
jbe    11b0 <MapsWithMe_LonIn180180+0xa0>
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
jmp    11c6 <MapsWithMe_LonIn180180+0xb6>
movsd  -0x18(%rbp),%xmm0
movsd  0xe4b(%rip),%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<MapsWithMe_LonIn180180>:
push   %rax
xorpd  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jae    1163 <MapsWithMe_LonIn180180+0x53>
addsd  0xeed(%rip),%xmm0
movsd  0xedd(%rip),%xmm1
call   1030 <fmod@plt>
movapd %xmm0,%xmm1
movsd  0xec4(%rip),%xmm2
addsd  %xmm2,%xmm1
movsd  0xed0(%rip),%xmm3
addsd  %xmm1,%xmm3
movapd %xmm1,%xmm0
cmpltsd %xmm2,%xmm0
andpd  %xmm0,%xmm1
andnpd %xmm3,%xmm0
orpd   %xmm1,%xmm0
pop    %rax
ret
addsd  0xe95(%rip),%xmm0
movsd  0xe95(%rip),%xmm1
call   1030 <fmod@plt>
addsd  0xe90(%rip),%xmm0
pop    %rax
ret

LLVM IR (-O0):
define double @MapsWithMe_LonIn180180(double %0) {
%2 = alloca double
%3 = alloca double
%4 = alloca double
store double %0, double* %3
%5 = load double, double* %3
%6 = fcmp oge double %5, 0.000000e+00
br i1 %6, label %7, label %12
7: ; preds = %1
%8 = load double, double* %3
%9 = fadd double %8, 1.800000e+02
%10 = call double @fmod(double %9, double 3.600000e+02)
%11 = fsub double %10, 1.800000e+02
store double %11, double* %2
br label %26
12: ; preds = %1
%13 = load double, double* %3
%14 = fsub double %13, 1.800000e+02
%15 = call double @fmod(double %14, double 3.600000e+02)
%16 = fadd double %15, 1.800000e+02
store double %16, double* %4
%17 = load double, double* %4
%18 = fcmp olt double %17, 1.800000e+02
br i1 %18, label %19, label %21
19: ; preds = %12
%20 = load double, double* %4
br label %24
21: ; preds = %12
%22 = load double, double* %4
%23 = fsub double %22, 3.600000e+02
br label %24
24: ; preds = %21, %19
%25 = phi double [ %20, %19 ], [ %23, %21 ]
store double %25, double* %2
br label %26
26: ; preds = %24, %7
%27 = load double, double* %2
ret double %27
}

LLVM IR (-O2):
define double @MapsWithMe_LonIn180180(double %0) {
%2 = fcmp ult double %0, 0.000000e+00
br i1 %2, label %7, label %3
3: ; preds = %1
%4 = fadd double %0, 1.800000e+02
%5 = tail call double @fmod(double %4, double 3.600000e+02)
%6 = fadd double %5, -1.800000e+02
br label %14
7: ; preds = %1
%8 = fadd double %0, -1.800000e+02
%9 = tail call double @fmod(double %8, double 3.600000e+02)
%10 = fadd double %9, 1.800000e+02
%11 = fcmp olt double %10, 1.800000e+02
%12 = fadd double %10, -3.600000e+02
%13 = select i1 %11, double %10, double %12
br label %14
14: ; preds = %7, %3
%15 = phi double [ %6, %3 ], [ %13, %7 ]
ret double %15
}