#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 degRad(double);
int /*<<< orphan*/ fmax(double, double);
double fmin(double, int /*<<< orphan*/);
double log(double);
double pow(double, double);
double sin(double);
double sqrt(double);
double tan(double);
double mercatorY(double lat) {
  lat = fmin(89.5, fmax(lat, -89.5));
  double phi = degRad(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):
<mercatorY>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  0xe96(%rip),%xmm1
call   1070 <fmax@plt>
mov    %eax,%edi
movsd  0xe7f(%rip),%xmm0
call   1050 <fmin@plt>
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
call   1030 <degRad@plt>
movsd  %xmm0,-0x10(%rbp)
movsd  -0x10(%rbp),%xmm0
call   1040 <sin@plt>
movsd  %xmm0,-0x18(%rbp)
movsd  0xe3f(%rip),%xmm0
call   10a0 <sqrt@plt>
mulsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  0xe30(%rip),%xmm0
subsd  -0x20(%rbp),%xmm0
movsd  0xe23(%rip),%xmm1
addsd  -0x20(%rbp),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  0xe05(%rip),%xmm0
call   10a0 <sqrt@plt>
movaps %xmm0,%xmm2
movsd  -0x30(%rbp),%xmm0
movsd  0xde0(%rip),%xmm1
mulsd  %xmm2,%xmm1
call   1090 <pow@plt>
movsd  %xmm0,-0x20(%rbp)
movsd  0xdd2(%rip),%xmm1
subsd  -0x10(%rbp),%xmm1
movsd  0xdbd(%rip),%xmm0
mulsd  %xmm1,%xmm0
call   1060 <tan@plt>
divsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
call   1080 <log@plt>
movsd  0xd90(%rip),%xmm1
mulsd  %xmm1,%xmm0
xorps  %xmm1,%xmm1
addsd  %xmm1,%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mercatorY>:
sub    $0x18,%rsp
movsd  0xe84(%rip),%xmm1
call   1070 <fmax@plt>
movsd  0xe7f(%rip),%xmm0
mov    %eax,%edi
call   1050 <fmin@plt>
call   1030 <degRad@plt>
movsd  %xmm0,0x10(%rsp)
call   1040 <sin@plt>
mulsd  0xe68(%rip),%xmm0
movsd  0xe68(%rip),%xmm1
movapd %xmm1,%xmm2
subsd  %xmm0,%xmm2
addsd  %xmm1,%xmm0
divsd  %xmm0,%xmm2
movsd  0xe58(%rip),%xmm1
movapd %xmm2,%xmm0
call   1090 <pow@plt>
movsd  %xmm0,0x8(%rsp)
movsd  0xe49(%rip),%xmm0
subsd  0x10(%rsp),%xmm0
mulsd  0xe43(%rip),%xmm0
call   1060 <tan@plt>
divsd  0x8(%rsp),%xmm0
call   1080 <log@plt>
mulsd  0xe33(%rip),%xmm0
xorpd  %xmm1,%xmm1
addsd  %xmm1,%xmm0
add    $0x18,%rsp
ret

LLVM IR (-O0):
define double @mercatorY(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 @fmax(double %7, double -8.950000e+01)
%9 = call double @fmin(double 8.950000e+01, i32 %8)
store double %9, double* %2
%10 = load double, double* %2
%11 = call double @degRad(double %10)
store double %11, double* %3
%12 = load double, double* %3
%13 = call double @sin(double %12)
store double %13, double* %4
%14 = call double @sqrt(double 0x3F7B6B90F2F6FA00)
%15 = load double, double* %4
%16 = fmul double %14, %15
store double %16, double* %5
%17 = load double, double* %5
%18 = fsub double 1.000000e+00, %17
%19 = load double, double* %5
%20 = fadd double 1.000000e+00, %19
%21 = fdiv double %18, %20
%22 = call double @sqrt(double 0x3F7B6B90F2F6FA00)
%23 = fmul double 5.000000e-01, %22
%24 = call double @pow(double %21, double %23)
store double %24, double* %5
%25 = load double, double* %3
%26 = fsub double 0x3FF921FB54442D18, %25
%27 = fmul double 5.000000e-01, %26
%28 = call double @tan(double %27)
%29 = load double, double* %5
%30 = fdiv double %28, %29
store double %30, double* %6
%31 = load double, double* %6
%32 = call double @log(double %31)
%33 = call double @llvm.fmuladd.f64(double 0xC15854A640000000, double %32, double 0.000000e+00)
ret double %33
}

LLVM IR (-O2):
define double @mercatorY(double %0) {
%2 = tail call i32 @fmax(double %0, double -8.950000e+01)
%3 = tail call double @fmin(double 8.950000e+01, i32 %2)
%4 = tail call double @degRad(double %3)
%5 = tail call double @sin(double %4)
%6 = fmul double %5, 0x3FB4F21A3D398ECB
%7 = fsub double 1.000000e+00, %6
%8 = fadd double %6, 1.000000e+00
%9 = fdiv double %7, %8
%10 = tail call double @pow(double %9, double 0x3FA4F21A3D398ECB)
%11 = fsub double 0x3FF921FB54442D18, %4
%12 = fmul double %11, 5.000000e-01
%13 = tail call double @tan(double %12)
%14 = fdiv double %13, %10
%15 = tail call double @log(double %14)
%16 = tail call double @llvm.fmuladd.f64(double %15, double 0xC15854A640000000, double 0.000000e+00)
ret double %16
}