#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;
int log(int /*<<< orphan*/);
int /*<<< orphan*/ tan(int);
double mercator_sheet_y(double latitude) {
  if (latitude < -85.0511)
    latitude = -85.0511;
  else if (latitude > 85.0511)
    latitude = 85.0511;
  return log(tan(M_PI / 4 + (latitude * M_PI / 180 / 2))) / (M_PI / 180);
}


x86 assembly (clang, -O0):
<mercator_sheet_y>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  0xecb(%rip),%xmm0
ucomisd -0x8(%rbp),%xmm0
jbe    1152 <mercator_sheet_y+0x32>
movsd  0xeb8(%rip),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    117b <mercator_sheet_y+0x5b>
movsd  -0x8(%rbp),%xmm0
movsd  0xea9(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    1176 <mercator_sheet_y+0x56>
movsd  0xe97(%rip),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    117b <mercator_sheet_y+0x5b>
mov    0x2e66(%rip),%rax
mov    (%rax),%eax
mov    $0x4,%ecx
cltd
idiv   %ecx
cvtsi2sd %eax,%xmm0
movsd  -0x8(%rbp),%xmm1
mov    0x2e4c(%rip),%rax
cvtsi2sdl (%rax),%xmm2
mulsd  %xmm2,%xmm1
movsd  0xe6c(%rip),%xmm2
divsd  %xmm2,%xmm1
movsd  0xe58(%rip),%xmm2
divsd  %xmm2,%xmm1
addsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edi
call   1030 <tan@plt>
mov    %eax,%edi
call   1040 <log@plt>
mov    %eax,-0xc(%rbp)
mov    0x2e0e(%rip),%rax
mov    (%rax),%eax
mov    $0xb4,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0xc(%rbp),%eax
cltd
idiv   %ecx
cvtsi2sd %eax,%xmm0
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mercator_sheet_y>:
push   %rbx
movsd  0xed7(%rip),%xmm1
ucomisd %xmm0,%xmm1
ja     1145 <mercator_sheet_y+0x25>
ucomisd 0xed1(%rip),%xmm0
movapd %xmm0,%xmm1
jbe    1145 <mercator_sheet_y+0x25>
movsd  0xec3(%rip),%xmm1
mov    0x2e9c(%rip),%rbx
mov    (%rbx),%eax
lea    0x3(%rax),%ecx
test   %eax,%eax
cmovns %eax,%ecx
sar    $0x2,%ecx
xorps  %xmm0,%xmm0
cvtsi2sd %ecx,%xmm0
cvtsi2sd %eax,%xmm2
mulsd  %xmm1,%xmm2
divsd  0xea0(%rip),%xmm2
mulsd  0xea0(%rip),%xmm2
addsd  %xmm0,%xmm2
cvttsd2si %xmm2,%edi
call   1030 <tan@plt>
mov    %eax,%edi
call   1040 <log@plt>
movslq (%rbx),%rcx
imul   $0xffffffffb60b60b7,%rcx,%rsi
shr    $0x20,%rsi
add    %ecx,%esi
mov    %esi,%ecx
shr    $0x1f,%ecx
sar    $0x7,%esi
add    %ecx,%esi
cltd
idiv   %esi
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
pop    %rbx
ret

LLVM IR (-O0):
@M_PI = global i32 0
define double @mercator_sheet_y(double %0) {
%2 = alloca double
store double %0, double* %2
%3 = load double, double* %2
%4 = fcmp olt double %3, -8.505110e+01
br i1 %4, label %5, label %6
5: ; preds = %1
store double -8.505110e+01, double* %2
br label %11
6: ; preds = %1
%7 = load double, double* %2
%8 = fcmp ogt double %7, 8.505110e+01
br i1 %8, label %9, label %10
9: ; preds = %6
store double 8.505110e+01, double* %2
br label %10
10: ; preds = %9, %6
br label %11
11: ; preds = %10, %5
%12 = load i32, i32* @M_PI
%13 = sdiv i32 %12, 4
%14 = sitofp i32 %13 to double
%15 = load double, double* %2
%16 = load i32, i32* @M_PI
%17 = sitofp i32 %16 to double
%18 = fmul double %15, %17
%19 = fdiv double %18, 1.800000e+02
%20 = fdiv double %19, 2.000000e+00
%21 = fadd double %14, %20
%22 = fptosi double %21 to i32
%23 = call i32 @tan(i32 %22)
%24 = call i32 @log(i32 %23)
%25 = load i32, i32* @M_PI
%26 = sdiv i32 %25, 180
%27 = sdiv i32 %24, %26
%28 = sitofp i32 %27 to double
ret double %28
}

LLVM IR (-O2):
@M_PI = global i32 0
define double @mercator_sheet_y(double %0) {
%2 = fcmp olt double %0, -8.505110e+01
br i1 %2, label %6, label %3
3: ; preds = %1
%4 = fcmp ogt double %0, 8.505110e+01
br i1 %4, label %5, label %6
5: ; preds = %3
br label %6
6: ; preds = %1, %3, %5
%7 = phi double [ 8.505110e+01, %5 ], [ %0, %3 ], [ -8.505110e+01, %1 ]
%8 = load i32, i32* @M_PI
%9 = sdiv i32 %8, 4
%10 = sitofp i32 %9 to double
%11 = sitofp i32 %8 to double
%12 = fmul double %7, %11
%13 = fdiv double %12, 1.800000e+02
%14 = fmul double %13, 5.000000e-01
%15 = fadd double %14, %10
%16 = fptosi double %15 to i32
%17 = tail call i32 @tan(i32 %16)
%18 = tail call i32 @log(i32 %17)
%19 = load i32, i32* @M_PI
%20 = sdiv i32 %19, 180
%21 = sdiv i32 %18, %20
%22 = sitofp i32 %21 to double
ret double %22
}