#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 M_PI;
double cos(double);
scalar_t__ floor(double);
double log(scalar_t__);
double pow(double, int);
scalar_t__ tan(double);
int lat2tile(double lat, int z) {
  return (int)(floor(
      (1.0 -
       log(tan(lat * M_PI / 180.0) + 1.0 / cos(lat * M_PI / 180.0)) / M_PI) /
      2.0 * pow(2.0, z)));
}


x86 assembly (clang, -O0):
<lat2tile>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movsd  %xmm0,-0x8(%rbp)
mov    %edi,-0xc(%rbp)
movsd  -0x8(%rbp),%xmm0
mov    0x2e7c(%rip),%rax
mulsd  (%rax),%xmm0
movsd  0xe98(%rip),%xmm1
divsd  %xmm1,%xmm0
call   1030 <tan@plt>
cvtsi2sd %rax,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x8(%rbp),%xmm0
mov    0x2e51(%rip),%rax
mulsd  (%rax),%xmm0
movsd  0xe6d(%rip),%xmm1
divsd  %xmm1,%xmm0
call   1040 <cos@plt>
movaps %xmm0,%xmm2
movsd  -0x20(%rbp),%xmm0
movsd  0xe4c(%rip),%xmm1
divsd  %xmm2,%xmm1
addsd  %xmm1,%xmm0
cvttsd2si %xmm0,%rdi
call   1050 <log@plt>
movaps %xmm0,%xmm1
mov    0x2e10(%rip),%rax
divsd  (%rax),%xmm1
movsd  0xe24(%rip),%xmm0
subsd  %xmm1,%xmm0
movsd  0xe10(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
mov    -0xc(%rbp),%edi
movsd  0xdfc(%rip),%xmm0
call   1060 <pow@plt>
movaps %xmm0,%xmm1
movsd  -0x18(%rbp),%xmm0
mulsd  %xmm1,%xmm0
call   1070 <floor@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<lat2tile>:
push   %rbp
push   %rbx
sub    $0x18,%rsp
mov    %edi,%ebp
movapd %xmm0,%xmm1
movsd  %xmm0,0x10(%rsp)
mov    0x2e7f(%rip),%rbx
movsd  (%rbx),%xmm0
mulsd  %xmm1,%xmm0
divsd  0xe87(%rip),%xmm0
call   1030 <tan@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
movsd  %xmm0,0x8(%rsp)
movsd  0x10(%rsp),%xmm0
mulsd  (%rbx),%xmm0
divsd  0xe62(%rip),%xmm0
call   1040 <cos@plt>
movsd  0xe5d(%rip),%xmm1
divsd  %xmm0,%xmm1
addsd  0x8(%rsp),%xmm1
cvttsd2si %xmm1,%rdi
call   1050 <log@plt>
divsd  (%rbx),%xmm0
movsd  0xe3d(%rip),%xmm1
subsd  %xmm0,%xmm1
mulsd  0xe39(%rip),%xmm1
movsd  %xmm1,0x8(%rsp)
movsd  0xe33(%rip),%xmm0
mov    %ebp,%edi
call   1060 <pow@plt>
mulsd  0x8(%rsp),%xmm0
add    $0x18,%rsp
pop    %rbx
pop    %rbp
jmp    1070 <floor@plt>

LLVM IR (-O0):
@M_PI = global double 0.000000e+00
define i32 @lat2tile(double %0, i32 %1) {
%3 = alloca double
%4 = alloca i32
store double %0, double* %3
store i32 %1, i32* %4
%5 = load double, double* %3
%6 = load double, double* @M_PI
%7 = fmul double %5, %6
%8 = fdiv double %7, 1.800000e+02
%9 = call i64 @tan(double %8)
%10 = sitofp i64 %9 to double
%11 = load double, double* %3
%12 = load double, double* @M_PI
%13 = fmul double %11, %12
%14 = fdiv double %13, 1.800000e+02
%15 = call double @cos(double %14)
%16 = fdiv double 1.000000e+00, %15
%17 = fadd double %10, %16
%18 = fptosi double %17 to i64
%19 = call double @log(i64 %18)
%20 = load double, double* @M_PI
%21 = fdiv double %19, %20
%22 = fsub double 1.000000e+00, %21
%23 = fdiv double %22, 2.000000e+00
%24 = load i32, i32* %4
%25 = call double @pow(double 2.000000e+00, i32 %24)
%26 = fmul double %23, %25
%27 = call i64 @floor(double %26)
%28 = trunc i64 %27 to i32
ret i32 %28
}

LLVM IR (-O2):
@M_PI = global double 0.000000e+00
define i32 @lat2tile(double %0, i32 %1) {
%3 = load double, double* @M_PI
%4 = fmul double %3, %0
%5 = fdiv double %4, 1.800000e+02
%6 = tail call i64 @tan(double %5)
%7 = sitofp i64 %6 to double
%8 = load double, double* @M_PI
%9 = fmul double %8, %0
%10 = fdiv double %9, 1.800000e+02
%11 = tail call double @cos(double %10)
%12 = fdiv double 1.000000e+00, %11
%13 = fadd double %12, %7
%14 = fptosi double %13 to i64
%15 = tail call double @log(i64 %14)
%16 = load double, double* @M_PI
%17 = fdiv double %15, %16
%18 = fsub double 1.000000e+00, %17
%19 = fmul double %18, 5.000000e-01
%20 = tail call double @pow(double 2.000000e+00, i32 %1)
%21 = fmul double %20, %19
%22 = tail call i64 @floor(double %21)
%23 = trunc i64 %22 to i32
ret i32 %23
}