#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 DegToRad(double);
double RadToDeg(int /*<<< orphan*/);
int /*<<< orphan*/ atan(int /*<<< orphan*/);
double log(double);
double pow(double, double);
double sin(double);
int /*<<< orphan*/ sinh(double);
double sqrt(double);
double tan(double);
double MercatorLatitude(double lat) {
  if (lat > RadToDeg(atan(sinh(3.14159265358979323846264338327950288))))
    lat = RadToDeg(atan(sinh(3.14159265358979323846264338327950288)));
  if (lat < -RadToDeg(atan(sinh(3.14159265358979323846264338327950288))))
    lat = -RadToDeg(atan(sinh(3.14159265358979323846264338327950288)));
  double phi = DegToRad(lat);
  double sinphi = sin(phi);
  double con =
      (sqrt(1.0 - ((6356752.3142 / 6378137.0) * (6356752.3142 / 6378137.0)))) *
      sinphi;
  con = pow(((1.0 - con) / (1.0 + con)),
            (0.5 * (sqrt(1.0 - ((6356752.3142 / 6378137.0) *
                                (6356752.3142 / 6378137.0))))));
  double ts =
      tan(0.5 * ((3.14159265358979323846264338327950288 * 0.5) - phi)) / con;
  return 0 - 6378137.0 * log(ts);
}


x86 assembly (clang, -O0):
<MercatorLatitude>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  0xe51(%rip),%xmm0
call   1040 <sinh@plt>
mov    %eax,%edi
call   1070 <atan@plt>
mov    %eax,%edi
call   1030 <RadToDeg@plt>
movaps %xmm0,%xmm1
movsd  -0x30(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    11f4 <MercatorLatitude+0x64>
movsd  0xe24(%rip),%xmm0
call   1040 <sinh@plt>
mov    %eax,%edi
call   1070 <atan@plt>
mov    %eax,%edi
call   1030 <RadToDeg@plt>
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  0xdfa(%rip),%xmm0
call   1040 <sinh@plt>
mov    %eax,%edi
call   1070 <atan@plt>
mov    %eax,%edi
call   1030 <RadToDeg@plt>
movsd  -0x38(%rbp),%xmm1
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
ucomisd %xmm1,%xmm0
jbe    1276 <MercatorLatitude+0xe6>
movsd  0xdb9(%rip),%xmm0
call   1040 <sinh@plt>
mov    %eax,%edi
call   1070 <atan@plt>
mov    %eax,%edi
call   1030 <RadToDeg@plt>
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
call   1050 <DegToRad@plt>
movsd  %xmm0,-0x10(%rbp)
movsd  -0x10(%rbp),%xmm0
call   1060 <sin@plt>
movsd  %xmm0,-0x18(%rbp)
movsd  0xd84(%rip),%xmm0
call   10b0 <sqrt@plt>
mulsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  0xd75(%rip),%xmm0
subsd  -0x20(%rbp),%xmm0
movsd  0xd68(%rip),%xmm1
addsd  -0x20(%rbp),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  0xd4a(%rip),%xmm0
call   10b0 <sqrt@plt>
movaps %xmm0,%xmm2
movsd  -0x40(%rbp),%xmm0
movsd  0xd25(%rip),%xmm1
mulsd  %xmm2,%xmm1
call   10a0 <pow@plt>
movsd  %xmm0,-0x20(%rbp)
movsd  0xd17(%rip),%xmm1
subsd  -0x10(%rbp),%xmm1
movsd  0xd02(%rip),%xmm0
mulsd  %xmm1,%xmm0
call   1080 <tan@plt>
divsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
call   1090 <log@plt>
movsd  0xcd5(%rip),%xmm1
mulsd  %xmm1,%xmm0
xorps  %xmm1,%xmm1
addsd  %xmm1,%xmm0
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<MercatorLatitude>:
sub    $0x18,%rsp
movaps %xmm0,(%rsp)
movsd  0xe70(%rip),%xmm0
call   1040 <sinh@plt>
mov    %eax,%edi
call   1070 <atan@plt>
mov    %eax,%edi
call   1030 <RadToDeg@plt>
movapd (%rsp),%xmm1
ucomisd %xmm0,%xmm1
movapd %xmm1,%xmm0
jbe    11cd <MercatorLatitude+0x4d>
movsd  0xe46(%rip),%xmm0
call   1040 <sinh@plt>
mov    %eax,%edi
call   1070 <atan@plt>
mov    %eax,%edi
call   1030 <RadToDeg@plt>
movapd %xmm0,(%rsp)
movsd  0xe26(%rip),%xmm0
call   1040 <sinh@plt>
mov    %eax,%edi
call   1070 <atan@plt>
mov    %eax,%edi
call   1030 <RadToDeg@plt>
xorpd  0xe4b(%rip),%xmm0
ucomisd (%rsp),%xmm0
movapd (%rsp),%xmm0
jbe    1224 <MercatorLatitude+0xa4>
movsd  0xdf7(%rip),%xmm0
call   1040 <sinh@plt>
mov    %eax,%edi
call   1070 <atan@plt>
mov    %eax,%edi
call   1030 <RadToDeg@plt>
xorpd  0xe1c(%rip),%xmm0
call   1050 <DegToRad@plt>
movsd  %xmm0,(%rsp)
call   1060 <sin@plt>
mulsd  0xdcd(%rip),%xmm0
movsd  0xdcd(%rip),%xmm1
movapd %xmm1,%xmm2
subsd  %xmm0,%xmm2
addsd  %xmm1,%xmm0
divsd  %xmm0,%xmm2
movsd  0xdbd(%rip),%xmm1
movapd %xmm2,%xmm0
call   10a0 <pow@plt>
movsd  %xmm0,0x10(%rsp)
movsd  0xdae(%rip),%xmm0
subsd  (%rsp),%xmm0
mulsd  0xda9(%rip),%xmm0
call   1080 <tan@plt>
divsd  0x10(%rsp),%xmm0
call   1090 <log@plt>
mulsd  0xd99(%rip),%xmm0
xorpd  %xmm1,%xmm1
addsd  %xmm1,%xmm0
add    $0x18,%rsp
ret

LLVM IR (-O0):
define double @MercatorLatitude(double %0) {
%2 = alloca double
%3 = alloca double
%4 = alloca double
%5 = alloca double
%6 = alloca double
store double %0, double* %2
%7 = load double, double* %2
%8 = call i32 @sinh(double 0x400921FB54442D18)
%9 = call i32 @atan(i32 %8)
%10 = call double @RadToDeg(i32 %9)
%11 = fcmp ogt double %7, %10
br i1 %11, label %12, label %16
12: ; preds = %1
%13 = call i32 @sinh(double 0x400921FB54442D18)
%14 = call i32 @atan(i32 %13)
%15 = call double @RadToDeg(i32 %14)
store double %15, double* %2
br label %16
16: ; preds = %12, %1
%17 = load double, double* %2
%18 = call i32 @sinh(double 0x400921FB54442D18)
%19 = call i32 @atan(i32 %18)
%20 = call double @RadToDeg(i32 %19)
%21 = fneg double %20
%22 = fcmp olt double %17, %21
br i1 %22, label %23, label %28
23: ; preds = %16
%24 = call i32 @sinh(double 0x400921FB54442D18)
%25 = call i32 @atan(i32 %24)
%26 = call double @RadToDeg(i32 %25)
%27 = fneg double %26
store double %27, double* %2
br label %28
28: ; preds = %23, %16
%29 = load double, double* %2
%30 = call double @DegToRad(double %29)
store double %30, double* %3
%31 = load double, double* %3
%32 = call double @sin(double %31)
store double %32, double* %4
%33 = call double @sqrt(double 0x3F7B6B90F2F6FA00)
%34 = load double, double* %4
%35 = fmul double %33, %34
store double %35, double* %5
%36 = load double, double* %5
%37 = fsub double 1.000000e+00, %36
%38 = load double, double* %5
%39 = fadd double 1.000000e+00, %38
%40 = fdiv double %37, %39
%41 = call double @sqrt(double 0x3F7B6B90F2F6FA00)
%42 = fmul double 5.000000e-01, %41
%43 = call double @pow(double %40, double %42)
store double %43, double* %5
%44 = load double, double* %3
%45 = fsub double 0x3FF921FB54442D18, %44
%46 = fmul double 5.000000e-01, %45
%47 = call double @tan(double %46)
%48 = load double, double* %5
%49 = fdiv double %47, %48
store double %49, double* %6
%50 = load double, double* %6
%51 = call double @log(double %50)
%52 = call double @llvm.fmuladd.f64(double 0xC15854A640000000, double %51, double 0.000000e+00)
ret double %52
}

LLVM IR (-O2):
define double @MercatorLatitude(double %0) {
%2 = tail call i32 @sinh(double 0x400921FB54442D18)
%3 = tail call i32 @atan(i32 %2)
%4 = tail call double @RadToDeg(i32 %3)
%5 = fcmp olt double %4, %0
br i1 %5, label %6, label %10
6: ; preds = %1
%7 = tail call i32 @sinh(double 0x400921FB54442D18)
%8 = tail call i32 @atan(i32 %7)
%9 = tail call double @RadToDeg(i32 %8)
br label %10
10: ; preds = %6, %1
%11 = phi double [ %9, %6 ], [ %0, %1 ]
%12 = tail call i32 @sinh(double 0x400921FB54442D18)
%13 = tail call i32 @atan(i32 %12)
%14 = tail call double @RadToDeg(i32 %13)
%15 = fneg double %14
%16 = fcmp olt double %11, %15
br i1 %16, label %17, label %22
17: ; preds = %10
%18 = tail call i32 @sinh(double 0x400921FB54442D18)
%19 = tail call i32 @atan(i32 %18)
%20 = tail call double @RadToDeg(i32 %19)
%21 = fneg double %20
br label %22
22: ; preds = %17, %10
%23 = phi double [ %21, %17 ], [ %11, %10 ]
%24 = tail call double @DegToRad(double %23)
%25 = tail call double @sin(double %24)
%26 = fmul double %25, 0x3FB4F21A3D398ECB
%27 = fsub double 1.000000e+00, %26
%28 = fadd double %26, 1.000000e+00
%29 = fdiv double %27, %28
%30 = tail call double @pow(double %29, double 0x3FA4F21A3D398ECB)
%31 = fsub double 0x3FF921FB54442D18, %24
%32 = fmul double %31, 5.000000e-01
%33 = tail call double @tan(double %32)
%34 = fdiv double %33, %30
%35 = tail call double @log(double %34)
%36 = tail call double @llvm.fmuladd.f64(double %35, double 0xC15854A640000000, double 0.000000e+00)
ret double %36
}