#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);
double sin(double);
void stony2hcc(double lat, double lon, double P, double B, double *x, double *y,
               double *z) {
  double P0, B0;
  double latitude, longitude;
  P0 = M_PI / 180.0 * P;
  B0 = M_PI / 180.0 * B;
  latitude = M_PI / 180.0 * lat;
  longitude = M_PI / 180.0 * lon;
  *x = 696000000.0 * cos(latitude) * sin(longitude - P0);
  *y = 696000000.0 * (sin(latitude) * cos(B0) -
                      cos(latitude) * cos(longitude - P0) * sin(B0));
  *z = 696000000.0 * (sin(latitude) * sin(B0) +
                      cos(latitude) * cos(longitude - P0) * cos(B0));
  return;
}


x86 assembly (clang, -O0):
<stony2hcc>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
movsd  %xmm2,-0x18(%rbp)
movsd  %xmm3,-0x20(%rbp)
mov    %rdi,-0x28(%rbp)
mov    %rsi,-0x30(%rbp)
mov    %rdx,-0x38(%rbp)
mov    0x2e96(%rip),%rax
movsd  (%rax),%xmm0
movsd  0xeaa(%rip),%xmm1
divsd  %xmm1,%xmm0
mulsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
mov    0x2e75(%rip),%rax
movsd  (%rax),%xmm0
movsd  0xe89(%rip),%xmm1
divsd  %xmm1,%xmm0
mulsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
mov    0x2e54(%rip),%rax
movsd  (%rax),%xmm0
movsd  0xe68(%rip),%xmm1
divsd  %xmm1,%xmm0
mulsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x50(%rbp)
mov    0x2e33(%rip),%rax
movsd  (%rax),%xmm0
movsd  0xe47(%rip),%xmm1
divsd  %xmm1,%xmm0
mulsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  -0x50(%rbp),%xmm0
call   1040 <cos@plt>
movaps %xmm0,%xmm1
movsd  0xe1c(%rip),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0xa0(%rbp)
ff
movsd  -0x58(%rbp),%xmm0
subsd  -0x40(%rbp),%xmm0
call   1030 <sin@plt>
movaps %xmm0,%xmm1
movsd  -0xa0(%rbp),%xmm0
ff
mulsd  %xmm1,%xmm0
mov    -0x28(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x50(%rbp),%xmm0
call   1030 <sin@plt>
movsd  %xmm0,-0x90(%rbp)
ff
movsd  -0x48(%rbp),%xmm0
call   1040 <cos@plt>
movsd  %xmm0,-0x88(%rbp)
ff
movsd  -0x50(%rbp),%xmm0
call   1040 <cos@plt>
movsd  %xmm0,-0x98(%rbp)
ff
movsd  -0x58(%rbp),%xmm0
subsd  -0x40(%rbp),%xmm0
call   1040 <cos@plt>
movaps %xmm0,%xmm1
movsd  -0x98(%rbp),%xmm0
ff
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x80(%rbp)
movsd  -0x48(%rbp),%xmm0
call   1030 <sin@plt>
movsd  -0x90(%rbp),%xmm1
ff
movsd  -0x88(%rbp),%xmm2
ff
movaps %xmm0,%xmm3
movsd  -0x80(%rbp),%xmm0
mulsd  %xmm3,%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
movsd  0xd44(%rip),%xmm0
mulsd  %xmm1,%xmm0
mov    -0x30(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x50(%rbp),%xmm0
call   1030 <sin@plt>
movsd  %xmm0,-0x70(%rbp)
movsd  -0x48(%rbp),%xmm0
call   1030 <sin@plt>
movsd  %xmm0,-0x68(%rbp)
movsd  -0x50(%rbp),%xmm0
call   1040 <cos@plt>
movsd  %xmm0,-0x78(%rbp)
movsd  -0x58(%rbp),%xmm0
subsd  -0x40(%rbp),%xmm0
call   1040 <cos@plt>
movaps %xmm0,%xmm1
movsd  -0x78(%rbp),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x60(%rbp)
movsd  -0x48(%rbp),%xmm0
call   1040 <cos@plt>
movsd  -0x70(%rbp),%xmm1
movsd  -0x68(%rbp),%xmm2
movaps %xmm0,%xmm3
movsd  -0x60(%rbp),%xmm0
mulsd  %xmm3,%xmm0
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
movsd  0xcbb(%rip),%xmm0
mulsd  %xmm1,%xmm0
mov    -0x38(%rbp),%rax
movsd  %xmm0,(%rax)
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<stony2hcc>:
push   %r15
push   %r14
push   %rbx
sub    $0x40,%rsp
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%rbx
mov    0x2eaf(%rip),%rax
movsd  (%rax),%xmm4
divsd  0xebb(%rip),%xmm4
mulsd  %xmm4,%xmm2
mulsd  %xmm4,%xmm3
movsd  %xmm3,0x18(%rsp)
mulsd  %xmm4,%xmm0
movsd  %xmm0,0x8(%rsp)
mulsd  %xmm1,%xmm4
subsd  %xmm2,%xmm4
movsd  %xmm4,0x28(%rsp)
call   1040 <cos@plt>
mulsd  0xe90(%rip),%xmm0
movsd  %xmm0,0x10(%rsp)
movsd  0x28(%rsp),%xmm0
call   1030 <sin@plt>
mulsd  0x10(%rsp),%xmm0
movsd  %xmm0,(%rbx)
movsd  0x8(%rsp),%xmm0
call   1030 <sin@plt>
movsd  %xmm0,0x10(%rsp)
movsd  0x18(%rsp),%xmm0
call   1040 <cos@plt>
movsd  %xmm0,0x20(%rsp)
movsd  0x8(%rsp),%xmm0
call   1040 <cos@plt>
movsd  %xmm0,0x38(%rsp)
movsd  0x28(%rsp),%xmm0
call   1040 <cos@plt>
movsd  %xmm0,0x30(%rsp)
movsd  0x18(%rsp),%xmm0
call   1030 <sin@plt>
movsd  0x30(%rsp),%xmm1
mulsd  0x38(%rsp),%xmm1
mulsd  %xmm0,%xmm1
movsd  0x20(%rsp),%xmm0
mulsd  0x10(%rsp),%xmm0
subsd  %xmm1,%xmm0
mulsd  0xdfe(%rip),%xmm0
movsd  %xmm0,(%r15)
movsd  0x8(%rsp),%xmm0
call   1030 <sin@plt>
movsd  %xmm0,0x10(%rsp)
movsd  0x18(%rsp),%xmm0
call   1030 <sin@plt>
movsd  %xmm0,0x20(%rsp)
movsd  0x8(%rsp),%xmm0
call   1040 <cos@plt>
movsd  %xmm0,0x8(%rsp)
movsd  0x28(%rsp),%xmm0
call   1040 <cos@plt>
mulsd  0x8(%rsp),%xmm0
movsd  %xmm0,0x8(%rsp)
movsd  0x18(%rsp),%xmm0
call   1040 <cos@plt>
mulsd  0x8(%rsp),%xmm0
movsd  0x20(%rsp),%xmm1
mulsd  0x10(%rsp),%xmm1
addsd  %xmm0,%xmm1
mulsd  0xd86(%rip),%xmm1
movsd  %xmm1,(%r14)
add    $0x40,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@M_PI = global double 0.000000e+00
define void @stony2hcc(double %0, double %1, double %2, double %3, double* %4, double* %5, double* %6) {
%8 = alloca double
%9 = alloca double
%10 = alloca double
%11 = alloca double
%12 = alloca double*
%13 = alloca double*
%14 = alloca double*
%15 = alloca double
%16 = alloca double
%17 = alloca double
%18 = alloca double
store double %0, double* %8
store double %1, double* %9
store double %2, double* %10
store double %3, double* %11
store double* %4, double** %12
store double* %5, double** %13
store double* %6, double** %14
%19 = load double, double* @M_PI
%20 = fdiv double %19, 1.800000e+02
%21 = load double, double* %10
%22 = fmul double %20, %21
store double %22, double* %15
%23 = load double, double* @M_PI
%24 = fdiv double %23, 1.800000e+02
%25 = load double, double* %11
%26 = fmul double %24, %25
store double %26, double* %16
%27 = load double, double* @M_PI
%28 = fdiv double %27, 1.800000e+02
%29 = load double, double* %8
%30 = fmul double %28, %29
store double %30, double* %17
%31 = load double, double* @M_PI
%32 = fdiv double %31, 1.800000e+02
%33 = load double, double* %9
%34 = fmul double %32, %33
store double %34, double* %18
%35 = load double, double* %17
%36 = call double @cos(double %35)
%37 = fmul double 6.960000e+08, %36
%38 = load double, double* %18
%39 = load double, double* %15
%40 = fsub double %38, %39
%41 = call double @sin(double %40)
%42 = fmul double %37, %41
%43 = load double*, double** %12
store double %42, double* %43
%44 = load double, double* %17
%45 = call double @sin(double %44)
%46 = load double, double* %16
%47 = call double @cos(double %46)
%48 = load double, double* %17
%49 = call double @cos(double %48)
%50 = load double, double* %18
%51 = load double, double* %15
%52 = fsub double %50, %51
%53 = call double @cos(double %52)
%54 = fmul double %49, %53
%55 = load double, double* %16
%56 = call double @sin(double %55)
%57 = fmul double %54, %56
%58 = fneg double %57
%59 = call double @llvm.fmuladd.f64(double %45, double %47, double %58)
%60 = fmul double 6.960000e+08, %59
%61 = load double*, double** %13
store double %60, double* %61
%62 = load double, double* %17
%63 = call double @sin(double %62)
%64 = load double, double* %16
%65 = call double @sin(double %64)
%66 = load double, double* %17
%67 = call double @cos(double %66)
%68 = load double, double* %18
%69 = load double, double* %15
%70 = fsub double %68, %69
%71 = call double @cos(double %70)
%72 = fmul double %67, %71
%73 = load double, double* %16
%74 = call double @cos(double %73)
%75 = fmul double %72, %74
%76 = call double @llvm.fmuladd.f64(double %63, double %65, double %75)
%77 = fmul double 6.960000e+08, %76
%78 = load double*, double** %14
store double %77, double* %78
ret void
}

LLVM IR (-O2):
@M_PI = global double 0.000000e+00
define void @stony2hcc(double %0, double %1, double %2, double %3, double* nocapture writeonly %4, double* nocapture writeonly %5, double* nocapture writeonly %6) {
%8 = load double, double* @M_PI
%9 = fdiv double %8, 1.800000e+02
%10 = fmul double %9, %2
%11 = fmul double %9, %3
%12 = fmul double %9, %0
%13 = fmul double %9, %1
%14 = tail call double @cos(double %12)
%15 = fmul double %14, 6.960000e+08
%16 = fsub double %13, %10
%17 = tail call double @sin(double %16)
%18 = fmul double %15, %17
store double %18, double* %4
%19 = tail call double @sin(double %12)
%20 = tail call double @cos(double %11)
%21 = tail call double @cos(double %12)
%22 = tail call double @cos(double %16)
%23 = tail call double @sin(double %11)
%24 = fneg double %21
%25 = fmul double %22, %24
%26 = fmul double %25, %23
%27 = tail call double @llvm.fmuladd.f64(double %19, double %20, double %26)
%28 = fmul double %27, 6.960000e+08
store double %28, double* %5
%29 = tail call double @sin(double %12)
%30 = tail call double @sin(double %11)
%31 = tail call double @cos(double %12)
%32 = tail call double @cos(double %16)
%33 = fmul double %31, %32
%34 = tail call double @cos(double %11)
%35 = fmul double %33, %34
%36 = tail call double @llvm.fmuladd.f64(double %29, double %30, double %35)
%37 = fmul double %36, 6.960000e+08
store double %37, double* %6
ret void
}