#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 */
float M_PI;
int log(int);
int pow(int, int);
float sin(float);
void latlon2xy(float lat, float lon, float *x, float *y, int z) {
  float e = sin(lat * M_PI / 180);
  if (e > 0.9999)
    e = 0.9999;
  if (e < -0.9999)
    e = -0.9999;
  *x = pow(2, 17 - z) * (lon + 180) / 360;
  *y = pow(2, 16 - z) * (1 - log((1 + e) / (1 - e)) / 2 / M_PI);
}


x86 assembly (clang, -O0):
<latlon2xy>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movss  %xmm0,-0x4(%rbp)
movss  %xmm1,-0x8(%rbp)
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
movss  -0x4(%rbp),%xmm0
mov    0x2e8f(%rip),%rax
mulss  (%rax),%xmm0
movss  0xeab(%rip),%xmm1
divss  %xmm1,%xmm0
call   1030 <sin@plt>
movss  %xmm0,-0x20(%rbp)
movss  -0x20(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xe7c(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    119b <latlon2xy+0x6b>
movss  0xe7e(%rip),%xmm0
movss  %xmm0,-0x20(%rbp)
movss  -0x20(%rbp),%xmm0
cvtss2sd %xmm0,%xmm1
movsd  0xe5c(%rip),%xmm0
ucomisd %xmm1,%xmm0
jbe    11c3 <latlon2xy+0x93>
movss  0xe5a(%rip),%xmm0
movss  %xmm0,-0x20(%rbp)
mov    $0x11,%esi
sub    -0x1c(%rbp),%esi
mov    $0x2,%edi
call   1050 <pow@plt>
cvtsi2ss %eax,%xmm0
movss  0xe2f(%rip),%xmm1
addss  -0x8(%rbp),%xmm1
mulss  %xmm1,%xmm0
movss  0xe2e(%rip),%xmm1
divss  %xmm1,%xmm0
mov    -0x10(%rbp),%rax
movss  %xmm0,(%rax)
mov    $0x10,%esi
sub    -0x1c(%rbp),%esi
mov    $0x2,%edi
call   1050 <pow@plt>
cvtsi2ss %eax,%xmm0
movss  %xmm0,-0x24(%rbp)
movss  0xdfb(%rip),%xmm0
addss  -0x20(%rbp),%xmm0
movss  0xdee(%rip),%xmm1
subss  -0x20(%rbp),%xmm1
divss  %xmm1,%xmm0
cvttss2si %xmm0,%edi
call   1040 <log@plt>
movss  -0x24(%rbp),%xmm0
mov    $0x2,%ecx
cltd
idiv   %ecx
cvtsi2ss %eax,%xmm2
mov    0x2d90(%rip),%rax
divss  (%rax),%xmm2
movss  0xdb8(%rip),%xmm1
subss  %xmm2,%xmm1
mulss  %xmm1,%xmm0
mov    -0x18(%rbp),%rax
movss  %xmm0,(%rax)
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<latlon2xy>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %edx,%ebp
mov    %rsi,%r14
mov    %rdi,%rbx
movss  %xmm1,(%rsp)
mov    0x2e9d(%rip),%r15
mulss  (%r15),%xmm0
divss  0xea8(%rip),%xmm0
call   1030 <sin@plt>
xorps  %xmm1,%xmm1
cvtss2sd %xmm0,%xmm1
ucomisd 0xeac(%rip),%xmm1
jbe    1176 <latlon2xy+0x46>
movss  0xe8e(%rip),%xmm0
cvtss2sd %xmm0,%xmm2
movsd  0xe9e(%rip),%xmm1
ucomisd %xmm2,%xmm1
jbe    1190 <latlon2xy+0x60>
movss  0xe78(%rip),%xmm0
movss  %xmm0,0x4(%rsp)
mov    $0x11,%esi
sub    %ebp,%esi
mov    $0x2,%edi
call   1050 <pow@plt>
xorps  %xmm0,%xmm0
cvtsi2ss %eax,%xmm0
movss  (%rsp),%xmm1
addss  0xe45(%rip),%xmm1
mulss  %xmm0,%xmm1
divss  0xe45(%rip),%xmm1
movss  %xmm1,(%rbx)
mov    $0x10,%esi
sub    %ebp,%esi
mov    $0x2,%edi
call   1050 <pow@plt>
xorps  %xmm0,%xmm0
cvtsi2ss %eax,%xmm0
movss  %xmm0,(%rsp)
movss  0xe20(%rip),%xmm2
movaps %xmm2,%xmm0
movss  0x4(%rsp),%xmm1
subss  %xmm1,%xmm0
addss  %xmm2,%xmm1
divss  %xmm0,%xmm1
cvttss2si %xmm1,%edi
call   1040 <log@plt>
mov    %eax,%ecx
shr    $0x1f,%ecx
add    %eax,%ecx
sar    %ecx
xorps  %xmm0,%xmm0
cvtsi2ss %ecx,%xmm0
divss  (%r15),%xmm0
movss  0xde5(%rip),%xmm1
subss  %xmm0,%xmm1
mulss  (%rsp),%xmm1
movss  %xmm1,(%r14)
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@M_PI = global float 0.000000e+00
define void @latlon2xy(float %0, float %1, float* %2, float* %3, i32 %4) {
%6 = alloca float
%7 = alloca float
%8 = alloca float*
%9 = alloca float*
%10 = alloca i32
%11 = alloca float
store float %0, float* %6
store float %1, float* %7
store float* %2, float** %8
store float* %3, float** %9
store i32 %4, i32* %10
%12 = load float, float* %6
%13 = load float, float* @M_PI
%14 = fmul float %12, %13
%15 = fdiv float %14, 1.800000e+02
%16 = call float @sin(float %15)
store float %16, float* %11
%17 = load float, float* %11
%18 = fpext float %17 to double
%19 = fcmp ogt double %18, 9.999000e-01
br i1 %19, label %20, label %21
20: ; preds = %5
store float 0x3FEFFF2E40000000, float* %11
br label %21
21: ; preds = %20, %5
%22 = load float, float* %11
%23 = fpext float %22 to double
%24 = fcmp olt double %23, -9.999000e-01
br i1 %24, label %25, label %26
25: ; preds = %21
store float 0xBFEFFF2E40000000, float* %11
br label %26
26: ; preds = %25, %21
%27 = load i32, i32* %10
%28 = sub nsw i32 17, %27
%29 = call i32 @pow(i32 2, i32 %28)
%30 = sitofp i32 %29 to float
%31 = load float, float* %7
%32 = fadd float %31, 1.800000e+02
%33 = fmul float %30, %32
%34 = fdiv float %33, 3.600000e+02
%35 = load float*, float** %8
store float %34, float* %35
%36 = load i32, i32* %10
%37 = sub nsw i32 16, %36
%38 = call i32 @pow(i32 2, i32 %37)
%39 = sitofp i32 %38 to float
%40 = load float, float* %11
%41 = fadd float 1.000000e+00, %40
%42 = load float, float* %11
%43 = fsub float 1.000000e+00, %42
%44 = fdiv float %41, %43
%45 = fptosi float %44 to i32
%46 = call i32 @log(i32 %45)
%47 = sdiv i32 %46, 2
%48 = sitofp i32 %47 to float
%49 = load float, float* @M_PI
%50 = fdiv float %48, %49
%51 = fsub float 1.000000e+00, %50
%52 = fmul float %39, %51
%53 = load float*, float** %9
store float %52, float* %53
ret void
}

LLVM IR (-O2):
@M_PI = global float 0.000000e+00
define void @latlon2xy(float %0, float %1, float* nocapture writeonly %2, float* nocapture writeonly %3, i32 %4) {
%6 = load float, float* @M_PI
%7 = fmul float %6, %0
%8 = fdiv float %7, 1.800000e+02
%9 = tail call float @sin(float %8)
%10 = fpext float %9 to double
%11 = fcmp ogt double %10, 9.999000e-01
%12 = select i1 %11, float 0x3FEFFF2E40000000, float %9
%13 = fpext float %12 to double
%14 = fcmp olt double %13, -9.999000e-01
%15 = select i1 %14, float 0xBFEFFF2E40000000, float %12
%16 = sub nsw i32 17, %4
%17 = tail call i32 @pow(i32 2, i32 %16)
%18 = sitofp i32 %17 to float
%19 = fadd float %1, 1.800000e+02
%20 = fmul float %19, %18
%21 = fdiv float %20, 3.600000e+02
store float %21, float* %2
%22 = sub nsw i32 16, %4
%23 = tail call i32 @pow(i32 2, i32 %22)
%24 = sitofp i32 %23 to float
%25 = fadd float %15, 1.000000e+00
%26 = fsub float 1.000000e+00, %15
%27 = fdiv float %25, %26
%28 = fptosi float %27 to i32
%29 = tail call i32 @log(i32 %28)
%30 = sdiv i32 %29, 2
%31 = sitofp i32 %30 to float
%32 = load float, float* @M_PI
%33 = fdiv float %31, %32
%34 = fsub float 1.000000e+00, %33
%35 = fmul float %34, %24
store float %35, float* %3
ret void
}