int conv_spherical_to_mercator(float i_lng, float i_lat, int i_zoom, int *o_x,
                               int *o_y) {
  int retCode;
  float lng_rd, lat_rd;
  float mer_x, mer_y;
  if ((i_lng > 180) || (i_lng <= -180) || (i_lat > 85.05115) ||
      (i_lat <= -85.05115)) {
    do {
      retCode = (15);
      if (retCode) {
        printf("Exception raised in '%s' : file %s line %d\n", __func__,
               "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/"
               "outputs/2022-01-22/02-19-57/repos/javellej/LocationFinder/refs/"
               "heads/master/src/coordinates.c",
               20);
        goto ERROR;
      }
    } while (0);
  }
  lng_rd = i_lng * 3.14159265358979 / 180;
  lat_rd = i_lat * 3.14159265358979 / 180;
  mer_x = lng_rd;
  mer_y = log(tan(3.14159265358979 / 4 + lat_rd / 2));
  *o_x = (int)(mer_x * pow(2, i_zoom + 7) / 3.14159265358979);
  *o_y = (int)(mer_y * pow(2, i_zoom + 7) / 3.14159265358979);
  return 0;
ERROR:
  return retCode;
}


x86 assembly (clang, -O0):
<conv_spherical_to_mercator>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movss  %xmm0,-0x8(%rbp)
movss  %xmm1,-0xc(%rbp)
mov    %edi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
movss  -0x8(%rbp),%xmm0
movss  0xe96(%rip),%xmm1
ucomiss %xmm1,%xmm0
ja     11bb <conv_spherical_to_mercator+0x7b>
movss  0xe89(%rip),%xmm0
ucomiss -0x8(%rbp),%xmm0
jae    11bb <conv_spherical_to_mercator+0x7b>
movss  -0xc(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xe7a(%rip),%xmm1
ucomisd %xmm1,%xmm0
ja     11bb <conv_spherical_to_mercator+0x7b>
movss  -0xc(%rbp),%xmm0
cvtss2sd %xmm0,%xmm1
movsd  0xe67(%rip),%xmm0
ucomisd %xmm1,%xmm0
jb     1201 <conv_spherical_to_mercator+0xc1>
jmp    11c0 <conv_spherical_to_mercator+0x80>
movl   $0xf,-0x24(%rbp)
cmpl   $0x0,-0x24(%rbp)
je     11f7 <conv_spherical_to_mercator+0xb7>
lea    0xe68(%rip),%rdi
lea    0xe8d(%rip),%rsi
lea    0xea1(%rip),%rdx
mov    $0x14,%ecx
mov    $0x0,%al
call   1030 <printf@plt>
jmp    132d <conv_spherical_to_mercator+0x1ed>
jmp    11fc <conv_spherical_to_mercator+0xbc>
jmp    1201 <conv_spherical_to_mercator+0xc1>
movss  -0x8(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xe0e(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xe1a(%rip),%xmm1
divsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x28(%rbp)
movss  -0xc(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xde4(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xdf0(%rip),%xmm1
divsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x2c(%rbp)
movss  -0x28(%rbp),%xmm0
movss  %xmm0,-0x30(%rbp)
movss  -0x2c(%rbp),%xmm0
movss  0xd9c(%rip),%xmm1
divss  %xmm1,%xmm0
cvtss2sd %xmm0,%xmm1
movsd  0xdb4(%rip),%xmm0
addsd  %xmm1,%xmm0
call   1040 <tan@plt>
call   1050 <log@plt>
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x34(%rbp)
movss  -0x30(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  %xmm0,-0x48(%rbp)
mov    -0x10(%rbp),%eax
add    $0x7,%eax
cvtsi2sd %eax,%xmm1
movsd  0xd75(%rip),%xmm0
call   1060 <pow@plt>
movaps %xmm0,%xmm1
movsd  -0x48(%rbp),%xmm0
mulsd  %xmm1,%xmm0
movsd  0xd54(%rip),%xmm1
divsd  %xmm1,%xmm0
cvttsd2si %xmm0,%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
movss  -0x34(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  %xmm0,-0x40(%rbp)
mov    -0x10(%rbp),%eax
add    $0x7,%eax
cvtsi2sd %eax,%xmm1
movsd  0xd2e(%rip),%xmm0
call   1060 <pow@plt>
movaps %xmm0,%xmm1
movsd  -0x40(%rbp),%xmm0
mulsd  %xmm1,%xmm0
movsd  0xd0d(%rip),%xmm1
divsd  %xmm1,%xmm0
cvttsd2si %xmm0,%ecx
mov    -0x20(%rbp),%rax
mov    %ecx,(%rax)
movl   $0x0,-0x4(%rbp)
jmp    1333 <conv_spherical_to_mercator+0x1f3>
mov    -0x24(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<conv_spherical_to_mercator>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
ucomiss 0xeb1(%rip),%xmm0
ja     1257 <conv_spherical_to_mercator+0x117>
movss  0xea7(%rip),%xmm2
ucomiss %xmm0,%xmm2
jae    1257 <conv_spherical_to_mercator+0x117>
cvtss2sd %xmm1,%xmm1
ucomisd 0xe9e(%rip),%xmm1
ja     1257 <conv_spherical_to_mercator+0x117>
movsd  0xe98(%rip),%xmm2
ucomisd %xmm1,%xmm2
jae    1257 <conv_spherical_to_mercator+0x117>
mov    %rdx,%r14
mov    %rsi,%rbx
mov    %edi,%ebp
cvtss2sd %xmm0,%xmm0
movsd  0xe82(%rip),%xmm3
mulsd  %xmm3,%xmm0
movsd  0xe7e(%rip),%xmm2
divsd  %xmm2,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,(%rsp)
mulsd  %xmm3,%xmm1
divsd  %xmm2,%xmm1
xorps  %xmm0,%xmm0
cvtsd2ss %xmm1,%xmm0
mulss  0xe3a(%rip),%xmm0
cvtss2sd %xmm0,%xmm0
addsd  0xe56(%rip),%xmm0
call   1050 <tan@plt>
call   1060 <log@plt>
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,0xc(%rsp)
movss  (%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  %xmm0,(%rsp)
add    $0x7,%ebp
movsd  0xe31(%rip),%xmm0
mov    %ebp,%edi
call   1030 <ldexp@plt>
mulsd  (%rsp),%xmm0
divsd  0xe05(%rip),%xmm0
cvttsd2si %xmm0,%eax
mov    %eax,(%rbx)
movss  0xc(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  %xmm0,(%rsp)
movsd  0xe00(%rip),%xmm0
mov    %ebp,%edi
call   1030 <ldexp@plt>
mulsd  (%rsp),%xmm0
divsd  0xdd4(%rip),%xmm0
cvttsd2si %xmm0,%eax
mov    %eax,(%r14)
xor    %eax,%eax
jmp    127d <conv_spherical_to_mercator+0x13d>
lea    0xde2(%rip),%rdi
lea    0xe07(%rip),%rsi
lea    0xe1b(%rip),%rdx
mov    $0x14,%ecx
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0xf,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [44 x i8] c"Exception raised in '%s' : file %s line %d\0A\00"
@__func__.conv_spherical_to_mercator = [27 x i8] c"conv_spherical_to_mercator\00"
@.str.1 = [150 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/javellej/LocationFinder/refs/heads/master/src/coordinates.c\00"
define i32 @conv_spherical_to_mercator(float %0, float %1, i32 %2, i32* %3, i32* %4) {
%6 = alloca i32
%7 = alloca float
%8 = alloca float
%9 = alloca i32
%10 = alloca i32*
%11 = alloca i32*
%12 = alloca i32
%13 = alloca float
%14 = alloca float
%15 = alloca float
%16 = alloca float
store float %0, float* %7
store float %1, float* %8
store i32 %2, i32* %9
store i32* %3, i32** %10
store i32* %4, i32** %11
%17 = load float, float* %7
%18 = fcmp ogt float %17, 1.800000e+02
br i1 %18, label %30, label %19
19: ; preds = %5
%20 = load float, float* %7
%21 = fcmp ole float %20, -1.800000e+02
br i1 %21, label %30, label %22
22: ; preds = %19
%23 = load float, float* %8
%24 = fpext float %23 to double
%25 = fcmp ogt double %24, 0x405543460AA64C30
br i1 %25, label %30, label %26
26: ; preds = %22
%27 = load float, float* %8
%28 = fpext float %27 to double
%29 = fcmp ole double %28, 0xC05543460AA64C30
br i1 %29, label %30, label %38
30: ; preds = %26, %22, %19, %5
br label %31
31: ; preds = %30
store i32 15, i32* %12
%32 = load i32, i32* %12
%33 = icmp ne i32 %32, 0
br i1 %33, label %34, label %36
34: ; preds = %31
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([27 x i8], [27 x i8]* @__func__.conv_spherical_to_mercator, i64 0, i64 0), i8* getelementptr inbounds ([150 x i8], [150 x i8]* @.str.1, i64 0, i64 0), i32 20)
br label %77
36: ; preds = %31
br label %37
37: ; preds = %36
br label %38
38: ; preds = %37, %26
%39 = load float, float* %7
%40 = fpext float %39 to double
%41 = fmul double %40, 0x400921FB54442D11
%42 = fdiv double %41, 1.800000e+02
%43 = fptrunc double %42 to float
store float %43, float* %13
%44 = load float, float* %8
%45 = fpext float %44 to double
%46 = fmul double %45, 0x400921FB54442D11
%47 = fdiv double %46, 1.800000e+02
%48 = fptrunc double %47 to float
store float %48, float* %14
%49 = load float, float* %13
store float %49, float* %15
%50 = load float, float* %14
%51 = fdiv float %50, 2.000000e+00
%52 = fpext float %51 to double
%53 = fadd double 0x3FE921FB54442D11, %52
%54 = call double @tan(double %53)
%55 = call double @log(double %54)
%56 = fptrunc double %55 to float
store float %56, float* %16
%57 = load float, float* %15
%58 = fpext float %57 to double
%59 = load i32, i32* %9
%60 = add nsw i32 %59, 7
%61 = sitofp i32 %60 to double
%62 = call double @pow(double 2.000000e+00, double %61)
%63 = fmul double %58, %62
%64 = fdiv double %63, 0x400921FB54442D11
%65 = fptosi double %64 to i32
%66 = load i32*, i32** %10
store i32 %65, i32* %66
%67 = load float, float* %16
%68 = fpext float %67 to double
%69 = load i32, i32* %9
%70 = add nsw i32 %69, 7
%71 = sitofp i32 %70 to double
%72 = call double @pow(double 2.000000e+00, double %71)
%73 = fmul double %68, %72
%74 = fdiv double %73, 0x400921FB54442D11
%75 = fptosi double %74 to i32
%76 = load i32*, i32** %11
store i32 %75, i32* %76
store i32 0, i32* %6
br label %79
77: ; preds = %34
%78 = load i32, i32* %12
store i32 %78, i32* %6
br label %79
79: ; preds = %77, %38
%80 = load i32, i32* %6
ret i32 %80
}

LLVM IR (-O2):
@.str = [44 x i8] c"Exception raised in '%s' : file %s line %d\0A\00"
@__func__.conv_spherical_to_mercator = [27 x i8] c"conv_spherical_to_mercator\00"
@.str.1 = [150 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/javellej/LocationFinder/refs/heads/master/src/coordinates.c\00"
define i32 @conv_spherical_to_mercator(float %0, float %1, i32 %2, i32* nocapture writeonly %3, i32* nocapture writeonly %4) {
%6 = fcmp ogt float %0, 1.800000e+02
%7 = fcmp ole float %0, -1.800000e+02
%8 = or i1 %6, %7
br i1 %8, label %14, label %9
9: ; preds = %5
%10 = fpext float %1 to double
%11 = fcmp ule double %10, 0x405543460AA64C30
%12 = fcmp ugt double %10, 0xC05543460AA64C30
%13 = and i1 %11, %12
br i1 %13, label %16, label %14
14: ; preds = %9, %5
%15 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([44 x i8], [44 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([27 x i8], [27 x i8]* @__func__.conv_spherical_to_mercator, i64 0, i64 0), i8* getelementptr inbounds ([150 x i8], [150 x i8]* @.str.1, i64 0, i64 0), i32 20)
br label %41
16: ; preds = %9
%17 = fpext float %0 to double
%18 = fmul double %17, 0x400921FB54442D11
%19 = fdiv double %18, 1.800000e+02
%20 = fptrunc double %19 to float
%21 = fmul double %10, 0x400921FB54442D11
%22 = fdiv double %21, 1.800000e+02
%23 = fptrunc double %22 to float
%24 = fmul float %23, 5.000000e-01
%25 = fpext float %24 to double
%26 = fadd double %25, 0x3FE921FB54442D11
%27 = tail call double @tan(double %26)
%28 = tail call double @log(double %27)
%29 = fptrunc double %28 to float
%30 = fpext float %20 to double
%31 = add nsw i32 %2, 7
%32 = tail call double @ldexp(double 1.000000e+00, i32 %31)
%33 = fmul double %32, %30
%34 = fdiv double %33, 0x400921FB54442D11
%35 = fptosi double %34 to i32
store i32 %35, i32* %3
%36 = fpext float %29 to double
%37 = tail call double @ldexp(double 1.000000e+00, i32 %31)
%38 = fmul double %37, %36
%39 = fdiv double %38, 0x400921FB54442D11
%40 = fptosi double %39 to i32
store i32 %40, i32* %4
br label %41
41: ; preds = %14, %16
%42 = phi i32 [ 15, %14 ], [ 0, %16 ]
ret i32 %42
}