#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 atan(double);
double exp(double);
double fabs(double);
double pow(double, double);
double rad_deg(double);
double sin(double);
double sqrt(double);
double merc_lat(double y) {
  double ts = exp(-y / 6378137.0);
  double phi = 1.57079632679489661923132169163975144 - 2 * atan(ts);
  double dphi = 1.0;
  int i;
  for (i = 0; fabs(dphi) > 0.000000001 && i < 15; i++) {
    double con = (sqrt(1.0 - ((6356752.3142 / 6378137.0) *
                              (6356752.3142 / 6378137.0)))) *
                 sin(phi);
    dphi =
        1.57079632679489661923132169163975144 -
        2 * atan(ts * pow((1.0 - con) / (1.0 + con),
                          (0.5 * (sqrt(1.0 - ((6356752.3142 / 6378137.0) *
                                              (6356752.3142 / 6378137.0))))))) -
        phi;
    phi += dphi;
  }
  return rad_deg(phi);
}


x86 assembly (clang, -O0):
<merc_lat>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  0xe7f(%rip),%xmm1
divsd  %xmm1,%xmm0
call   1060 <exp@plt>
movsd  %xmm0,-0x10(%rbp)
movsd  -0x10(%rbp),%xmm0
call   1050 <atan@plt>
shl    $0x1,%eax
cvtsi2sd %eax,%xmm1
movsd  0xe50(%rip),%xmm0
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  0xe37(%rip),%xmm0
movsd  %xmm0,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
movsd  -0x20(%rbp),%xmm0
movaps 0xe4f(%rip),%xmm1
pand   %xmm1,%xmm0
xor    %eax,%eax
movsd  0xe29(%rip),%xmm1
ucomisd %xmm1,%xmm0
mov    %al,-0x31(%rbp)
jbe    1206 <merc_lat+0xa6>
cmpl   $0xf,-0x24(%rbp)
setl   %al
mov    %al,-0x31(%rbp)
mov    -0x31(%rbp),%al
test   $0x1,%al
jne    1216 <merc_lat+0xb6>
jmp    12e1 <merc_lat+0x181>
movsd  0xe0a(%rip),%xmm0
call   1080 <sqrt@plt>
movsd  %xmm0,-0x50(%rbp)
movsd  -0x18(%rbp),%xmm0
call   1030 <sin@plt>
movaps %xmm0,%xmm1
movsd  -0x50(%rbp),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  0xdab(%rip),%xmm0
subsd  -0x30(%rbp),%xmm0
movsd  0xd9e(%rip),%xmm1
addsd  -0x30(%rbp),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  0xdb0(%rip),%xmm0
call   1080 <sqrt@plt>
movaps %xmm0,%xmm2
movsd  -0x48(%rbp),%xmm0
movsd  0xd93(%rip),%xmm1
mulsd  %xmm2,%xmm1
call   1070 <pow@plt>
movaps %xmm0,%xmm1
movsd  -0x40(%rbp),%xmm0
mulsd  %xmm1,%xmm0
call   1050 <atan@plt>
shl    $0x1,%eax
cvtsi2sd %eax,%xmm1
movsd  0xd52(%rip),%xmm0
subsd  %xmm1,%xmm0
subsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
addsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    11d5 <merc_lat+0x75>
movsd  -0x18(%rbp),%xmm0
call   1040 <rad_deg@plt>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<merc_lat>:
push   %rbx
sub    $0x10,%rsp
divsd  0xea3(%rip),%xmm0
call   1060 <exp@plt>
movsd  %xmm0,(%rsp)
call   1050 <atan@plt>
add    %eax,%eax
cvtsi2sd %eax,%xmm1
movsd  0xe8e(%rip),%xmm0
subsd  %xmm1,%xmm0
xor    %ebx,%ebx
movsd  %xmm0,0x8(%rsp)
call   1030 <sin@plt>
mulsd  0xe7d(%rip),%xmm0
movsd  0xe7d(%rip),%xmm2
movapd %xmm2,%xmm1
subsd  %xmm0,%xmm1
addsd  %xmm2,%xmm0
divsd  %xmm0,%xmm1
movapd %xmm1,%xmm0
movsd  0xe69(%rip),%xmm1
call   1070 <pow@plt>
mulsd  (%rsp),%xmm0
call   1050 <atan@plt>
movsd  0x8(%rsp),%xmm0
add    %eax,%eax
xorps  %xmm2,%xmm2
cvtsi2sd %eax,%xmm2
movsd  0xe2b(%rip),%xmm1
subsd  %xmm2,%xmm1
subsd  %xmm0,%xmm1
addsd  %xmm1,%xmm0
andpd  0xe3f(%rip),%xmm1
ucomisd 0xe2f(%rip),%xmm1
jbe    1209 <merc_lat+0xb9>
lea    0x1(%rbx),%eax
cmp    $0xe,%ebx
mov    %eax,%ebx
jb     1180 <merc_lat+0x30>
add    $0x10,%rsp
pop    %rbx
jmp    1040 <rad_deg@plt>

LLVM IR (-O0):
define double @merc_lat(double %0) {
%2 = alloca double
%3 = alloca double
%4 = alloca double
%5 = alloca double
%6 = alloca i32
%7 = alloca double
store double %0, double* %2
%8 = load double, double* %2
%9 = fneg double %8
%10 = fdiv double %9, 0x415854A640000000
%11 = call double @exp(double %10)
store double %11, double* %3
%12 = load double, double* %3
%13 = call i32 @atan(double %12)
%14 = mul nsw i32 2, %13
%15 = sitofp i32 %14 to double
%16 = fsub double 0x3FF921FB54442D18, %15
store double %16, double* %4
store double 1.000000e+00, double* %5
store i32 0, i32* %6
br label %17
17: ; preds = %50, %1
%18 = load double, double* %5
%19 = call double @llvm.fabs.f64(double %18)
%20 = fcmp ogt double %19, 1.000000e-09
br i1 %20, label %21, label %24
21: ; preds = %17
%22 = load i32, i32* %6
%23 = icmp slt i32 %22, 15
br label %24
24: ; preds = %21, %17
%25 = phi i1 [ false, %17 ], [ %23, %21 ]
br i1 %25, label %26, label %53
26: ; preds = %24
%27 = call double @sqrt(double 0x3F7B6B90F2F6FA00)
%28 = load double, double* %4
%29 = call double @sin(double %28)
%30 = fmul double %27, %29
store double %30, double* %7
%31 = load double, double* %3
%32 = load double, double* %7
%33 = fsub double 1.000000e+00, %32
%34 = load double, double* %7
%35 = fadd double 1.000000e+00, %34
%36 = fdiv double %33, %35
%37 = call double @sqrt(double 0x3F7B6B90F2F6FA00)
%38 = fmul double 5.000000e-01, %37
%39 = call double @pow(double %36, double %38)
%40 = fmul double %31, %39
%41 = call i32 @atan(double %40)
%42 = mul nsw i32 2, %41
%43 = sitofp i32 %42 to double
%44 = fsub double 0x3FF921FB54442D18, %43
%45 = load double, double* %4
%46 = fsub double %44, %45
store double %46, double* %5
%47 = load double, double* %5
%48 = load double, double* %4
%49 = fadd double %48, %47
store double %49, double* %4
br label %50
50: ; preds = %26
%51 = load i32, i32* %6
%52 = add nsw i32 %51, 1
store i32 %52, i32* %6
br label %17
53: ; preds = %24
%54 = load double, double* %4
%55 = call double @rad_deg(double %54)
ret double %55
}

LLVM IR (-O2):
define double @merc_lat(double %0) {
%2 = fdiv double %0, 0xC15854A640000000
%3 = tail call double @exp(double %2)
%4 = tail call i32 @atan(double %3)
%5 = shl nsw i32 %4, 1
%6 = sitofp i32 %5 to double
%7 = fsub double 0x3FF921FB54442D18, %6
br label %8
8: ; preds = %1, %8
%9 = phi double [ %7, %1 ], [ %23, %8 ]
%10 = phi i32 [ 0, %1 ], [ %24, %8 ]
%11 = tail call double @sin(double %9)
%12 = fmul double %11, 0x3FB4F21A3D398ECB
%13 = fsub double 1.000000e+00, %12
%14 = fadd double %12, 1.000000e+00
%15 = fdiv double %13, %14
%16 = tail call double @pow(double %15, double 0x3FA4F21A3D398ECB)
%17 = fmul double %3, %16
%18 = tail call i32 @atan(double %17)
%19 = shl nsw i32 %18, 1
%20 = sitofp i32 %19 to double
%21 = fsub double 0x3FF921FB54442D18, %20
%22 = fsub double %21, %9
%23 = fadd double %9, %22
%24 = add nuw nsw i32 %10, 1
%25 = tail call double @llvm.fabs.f64(double %22)
%26 = fcmp ogt double %25, 1.000000e-09
%27 = icmp ult i32 %10, 14
%28 = select i1 %26, i1 %27, i1 false
br i1 %28, label %8, label %29
29: ; preds = %8
%30 = tail call double @rad_deg(double %23)
ret double %30
}