#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 MapsWithMe_LonIn180180(double);
int MapsWithMe_LonToInt(double lon, int maxValue) {
  double const x =
      (MapsWithMe_LonIn180180(lon) + 180.0) / 360.0 * (maxValue + 1.0) + 0.5;
  return (x <= 0 || x >= maxValue + 1) ? 0 : (int)x;
}


x86 assembly (clang, -O0):
<MapsWithMe_LonToInt>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movsd  %xmm0,-0x8(%rbp)
mov    %edi,-0xc(%rbp)
movsd  -0x8(%rbp),%xmm0
call   1030 <MapsWithMe_LonIn180180@plt>
movsd  0xee6(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  0xed2(%rip),%xmm1
divsd  %xmm1,%xmm0
cvtsi2sdl -0xc(%rbp),%xmm1
movsd  0xeb9(%rip),%xmm2
addsd  %xmm2,%xmm1
mulsd  %xmm1,%xmm0
movsd  0xea1(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
xorps  %xmm0,%xmm0
ucomisd -0x18(%rbp),%xmm0
jae    118f <MapsWithMe_LonToInt+0x7f>
movsd  -0x18(%rbp),%xmm0
mov    -0xc(%rbp),%eax
add    $0x1,%eax
cvtsi2sd %eax,%xmm1
ucomisd %xmm1,%xmm0
jb     1199 <MapsWithMe_LonToInt+0x89>
xor    %eax,%eax
mov    %eax,-0x1c(%rbp)
jmp    11a1 <MapsWithMe_LonToInt+0x91>
cvttsd2si -0x18(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<MapsWithMe_LonToInt>:
push   %rbx
mov    %edi,%ebx
call   1030 <MapsWithMe_LonIn180180@plt>
addsd  0xee0(%rip),%xmm0
divsd  0xee0(%rip),%xmm0
cvtsi2sd %ebx,%xmm1
addsd  0xedc(%rip),%xmm1
mulsd  %xmm0,%xmm1
addsd  0xed8(%rip),%xmm1
xor    %eax,%eax
xorpd  %xmm0,%xmm0
ucomisd %xmm1,%xmm0
jae    1160 <MapsWithMe_LonToInt+0x50>
add    $0x1,%ebx
xorps  %xmm0,%xmm0
cvtsi2sd %ebx,%xmm0
ucomisd %xmm0,%xmm1
jae    1160 <MapsWithMe_LonToInt+0x50>
cvttsd2si %xmm1,%eax
pop    %rbx
ret

LLVM IR (-O0):
define i32 @MapsWithMe_LonToInt(double %0, i32 %1) {
%3 = alloca double
%4 = alloca i32
%5 = alloca double
store double %0, double* %3
store i32 %1, i32* %4
%6 = load double, double* %3
%7 = call double @MapsWithMe_LonIn180180(double %6)
%8 = fadd double %7, 1.800000e+02
%9 = fdiv double %8, 3.600000e+02
%10 = load i32, i32* %4
%11 = sitofp i32 %10 to double
%12 = fadd double %11, 1.000000e+00
%13 = call double @llvm.fmuladd.f64(double %9, double %12, double 5.000000e-01)
store double %13, double* %5
%14 = load double, double* %5
%15 = fcmp ole double %14, 0.000000e+00
br i1 %15, label %22, label %16
16: ; preds = %2
%17 = load double, double* %5
%18 = load i32, i32* %4
%19 = add nsw i32 %18, 1
%20 = sitofp i32 %19 to double
%21 = fcmp oge double %17, %20
br i1 %21, label %22, label %23
22: ; preds = %16, %2
br label %26
23: ; preds = %16
%24 = load double, double* %5
%25 = fptosi double %24 to i32
br label %26
26: ; preds = %23, %22
%27 = phi i32 [ 0, %22 ], [ %25, %23 ]
ret i32 %27
}

LLVM IR (-O2):
define i32 @MapsWithMe_LonToInt(double %0, i32 %1) {
%3 = tail call double @MapsWithMe_LonIn180180(double %0)
%4 = fadd double %3, 1.800000e+02
%5 = fdiv double %4, 3.600000e+02
%6 = sitofp i32 %1 to double
%7 = fadd double %6, 1.000000e+00
%8 = tail call double @llvm.fmuladd.f64(double %5, double %7, double 5.000000e-01)
%9 = fcmp ugt double %8, 0.000000e+00
br i1 %9, label %10, label %16
10: ; preds = %2
%11 = add nsw i32 %1, 1
%12 = sitofp i32 %11 to double
%13 = fcmp ult double %8, %12
br i1 %13, label %14, label %16
14: ; preds = %10
%15 = fptosi double %8 to i32
br label %16
16: ; preds = %2, %10, %14
%17 = phi i32 [ %15, %14 ], [ 0, %10 ], [ 0, %2 ]
ret i32 %17
}