#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 clamp(double, int, int);
double normalize_lon(double lon) {
  while (lon > 180.0)
    lon -= 360.0;
  while (lon < -180.0)
    lon += 360.0;
  return (clamp(lon, -180, 180));
}


x86 assembly (clang, -O0):
<normalize_lon>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  0xed6(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    114f <normalize_lon+0x3f>
movsd  -0x8(%rbp),%xmm0
movsd  0xecf(%rip),%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    111d <normalize_lon+0xd>
jmp    1154 <normalize_lon+0x44>
movsd  0xeac(%rip),%xmm0
ucomisd -0x8(%rbp),%xmm0
jbe    117e <normalize_lon+0x6e>
movsd  0xea1(%rip),%xmm0
addsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1154 <normalize_lon+0x44>
movsd  -0x8(%rbp),%xmm0
mov    $0xffffff4c,%edi
mov    $0xb4,%esi
call   1030 <clamp@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<normalize_lon>:
ucomisd 0xee8(%rip),%xmm0
jbe    113a <normalize_lon+0x2a>
movsd  0xee6(%rip),%xmm1
movsd  0xed6(%rip),%xmm2
nopw   0x0(%rax,%rax,1)
addsd  %xmm1,%xmm0
ucomisd %xmm2,%xmm0
ja     1130 <normalize_lon+0x20>
movsd  0xece(%rip),%xmm1
ucomisd %xmm0,%xmm1
jbe    115a <normalize_lon+0x4a>
movsd  0xec8(%rip),%xmm2
addsd  %xmm2,%xmm0
ucomisd %xmm0,%xmm1
ja     1150 <normalize_lon+0x40>
mov    $0xffffff4c,%edi
mov    $0xb4,%esi
jmp    1030 <clamp@plt>

LLVM IR (-O0):
define double @normalize_lon(double %0) {
%2 = alloca double
store double %0, double* %2
br label %3
3: ; preds = %6, %1
%4 = load double, double* %2
%5 = fcmp ogt double %4, 1.800000e+02
br i1 %5, label %6, label %9
6: ; preds = %3
%7 = load double, double* %2
%8 = fsub double %7, 3.600000e+02
store double %8, double* %2
br label %3
9: ; preds = %3
br label %10
10: ; preds = %13, %9
%11 = load double, double* %2
%12 = fcmp olt double %11, -1.800000e+02
br i1 %12, label %13, label %16
13: ; preds = %10
%14 = load double, double* %2
%15 = fadd double %14, 3.600000e+02
store double %15, double* %2
br label %10
16: ; preds = %10
%17 = load double, double* %2
%18 = call double @clamp(double %17, i32 -180, i32 180)
ret double %18
}

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