#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 cosf(float);
float sinf(float);
void LatLngToNormal(short n, float *out) {
  const float PI = (3.1415926535897932384626433832795f);
  float lat = (float)(n >> 8);
  float lng = (float)(n & 255);
  lat *= PI / 128.0f;
  lng *= PI / 128.0f;
  out[0] = cosf(lat) * sinf(lng);
  out[1] = sinf(lat) * sinf(lng);
  out[2] = cosf(lng);
}


x86 assembly (clang, -O0):
<LatLngToNormal>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %di,%ax
mov    %ax,-0x2(%rbp)
mov    %rsi,-0x10(%rbp)
movss  0xec9(%rip),%xmm0
movss  %xmm0,-0x14(%rbp)
movswl -0x2(%rbp),%eax
sar    $0x8,%eax
cvtsi2ss %eax,%xmm0
movss  %xmm0,-0x18(%rbp)
movswl -0x2(%rbp),%eax
and    $0xff,%eax
cvtsi2ss %eax,%xmm0
movss  %xmm0,-0x1c(%rbp)
movss  0xe96(%rip),%xmm0
mulss  -0x18(%rbp),%xmm0
movss  %xmm0,-0x18(%rbp)
movss  0xe84(%rip),%xmm0
mulss  -0x1c(%rbp),%xmm0
movss  %xmm0,-0x1c(%rbp)
movss  -0x18(%rbp),%xmm0
call   1040 <cosf@plt>
movss  %xmm0,-0x24(%rbp)
movss  -0x1c(%rbp),%xmm0
call   1030 <sinf@plt>
movaps %xmm0,%xmm1
movss  -0x24(%rbp),%xmm0
mulss  %xmm1,%xmm0
mov    -0x10(%rbp),%rax
movss  %xmm0,(%rax)
movss  -0x18(%rbp),%xmm0
call   1030 <sinf@plt>
movss  %xmm0,-0x20(%rbp)
movss  -0x1c(%rbp),%xmm0
call   1030 <sinf@plt>
movaps %xmm0,%xmm1
movss  -0x20(%rbp),%xmm0
mulss  %xmm1,%xmm0
mov    -0x10(%rbp),%rax
movss  %xmm0,0x4(%rax)
movss  -0x1c(%rbp),%xmm0
call   1040 <cosf@plt>
mov    -0x10(%rbp),%rax
movss  %xmm0,0x8(%rax)
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<LatLngToNormal>:
push   %rbx
sub    $0x10,%rsp
mov    %edi,%eax
sar    $0x8,%eax
cvtsi2ss %eax,%xmm0
movzbl %dil,%eax
cvtsi2ss %eax,%xmm1
mov    %rsi,%rbx
movss  0xebf(%rip),%xmm2
mulss  %xmm2,%xmm0
movss  %xmm0,0x4(%rsp)
mulss  %xmm2,%xmm1
movss  %xmm1,0x8(%rsp)
call   1040 <cosf@plt>
movss  %xmm0,0xc(%rsp)
movss  0x8(%rsp),%xmm0
call   1030 <sinf@plt>
mulss  0xc(%rsp),%xmm0
movss  %xmm0,(%rbx)
movss  0x4(%rsp),%xmm0
call   1030 <sinf@plt>
movss  %xmm0,0x4(%rsp)
movss  0x8(%rsp),%xmm0
call   1030 <sinf@plt>
mulss  0x4(%rsp),%xmm0
movss  %xmm0,0x4(%rbx)
movss  0x8(%rsp),%xmm0
call   1040 <cosf@plt>
movss  %xmm0,0x8(%rbx)
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
define void @LatLngToNormal(i16 signext %0, float* %1) {
%3 = alloca i16
%4 = alloca float*
%5 = alloca float
%6 = alloca float
%7 = alloca float
store i16 %0, i16* %3
store float* %1, float** %4
store float 0x400921FB60000000, float* %5
%8 = load i16, i16* %3
%9 = sext i16 %8 to i32
%10 = ashr i32 %9, 8
%11 = sitofp i32 %10 to float
store float %11, float* %6
%12 = load i16, i16* %3
%13 = sext i16 %12 to i32
%14 = and i32 %13, 255
%15 = sitofp i32 %14 to float
store float %15, float* %7
%16 = load float, float* %6
%17 = fmul float %16, 0x3F9921FB60000000
store float %17, float* %6
%18 = load float, float* %7
%19 = fmul float %18, 0x3F9921FB60000000
store float %19, float* %7
%20 = load float, float* %6
%21 = call float @cosf(float %20)
%22 = load float, float* %7
%23 = call float @sinf(float %22)
%24 = fmul float %21, %23
%25 = load float*, float** %4
%26 = getelementptr inbounds float, float* %25, i64 0
store float %24, float* %26
%27 = load float, float* %6
%28 = call float @sinf(float %27)
%29 = load float, float* %7
%30 = call float @sinf(float %29)
%31 = fmul float %28, %30
%32 = load float*, float** %4
%33 = getelementptr inbounds float, float* %32, i64 1
store float %31, float* %33
%34 = load float, float* %7
%35 = call float @cosf(float %34)
%36 = load float*, float** %4
%37 = getelementptr inbounds float, float* %36, i64 2
store float %35, float* %37
ret void
}

LLVM IR (-O2):
define void @LatLngToNormal(i16 signext %0, float* nocapture writeonly %1) {
%3 = sext i16 %0 to i32
%4 = ashr i32 %3, 8
%5 = sitofp i32 %4 to float
%6 = and i32 %3, 255
%7 = sitofp i32 %6 to float
%8 = fmul float %5, 0x3F9921FB60000000
%9 = fmul float %7, 0x3F9921FB60000000
%10 = tail call float @cosf(float %8)
%11 = tail call float @sinf(float %9)
%12 = fmul float %10, %11
store float %12, float* %1
%13 = tail call float @sinf(float %8)
%14 = tail call float @sinf(float %9)
%15 = fmul float %13, %14
%16 = getelementptr inbounds float, float* %1, i64 1
store float %15, float* %16
%17 = tail call float @cosf(float %9)
%18 = getelementptr inbounds float, float* %1, i64 2
store float %17, float* %18
ret void
}