#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 arg(double, double);
double asin(double);
double cos(double);
double sin(double);
double sqrt(double);
void hcc2stony(double x, double y, double z, double P, double B, double *lat,
               double *lon) {
  double P0, B0;
  double r;
  P0 = M_PI / 180.0 * P;
  B0 = M_PI / 180.0 * B;
  r = sqrt(x * x + y * y + z * z);
  *lat = 180.0 / M_PI * (asin((y * cos(B0) + z * sin(B0)) / r));
  *lon = 180.0 / M_PI * (P0 + arg(z * cos(B0) - y * sin(B0), x));
  return;
}


x86 assembly (clang, -O0):
<hcc2stony>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
movsd  %xmm2,-0x18(%rbp)
movsd  %xmm3,-0x20(%rbp)
movsd  %xmm4,-0x28(%rbp)
mov    %rdi,-0x30(%rbp)
mov    %rsi,-0x38(%rbp)
mov    0x2e65(%rip),%rax
movsd  (%rax),%xmm0
movsd  0xe71(%rip),%xmm1
divsd  %xmm1,%xmm0
mulsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
mov    0x2e44(%rip),%rax
movsd  (%rax),%xmm0
movsd  0xe50(%rip),%xmm1
divsd  %xmm1,%xmm0
mulsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x8(%rbp),%xmm1
movsd  -0x8(%rbp),%xmm2
movsd  -0x10(%rbp),%xmm0
mulsd  -0x10(%rbp),%xmm0
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
movsd  -0x18(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
call   1070 <sqrt@plt>
movsd  %xmm0,-0x50(%rbp)
movsd  0xe02(%rip),%xmm0
mov    0x2de3(%rip),%rax
divsd  (%rax),%xmm0
movsd  %xmm0,-0x80(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x88(%rbp)
ff
movsd  -0x48(%rbp),%xmm0
call   1060 <cos@plt>
movsd  %xmm0,-0x90(%rbp)
ff
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x98(%rbp)
ff
movsd  -0x48(%rbp),%xmm0
call   1040 <sin@plt>
movsd  -0x98(%rbp),%xmm1
ff
movsd  -0x90(%rbp),%xmm2
ff
movaps %xmm0,%xmm3
movsd  -0x88(%rbp),%xmm0
ff
mulsd  %xmm3,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
divsd  -0x50(%rbp),%xmm0
call   1050 <asin@plt>
movaps %xmm0,%xmm1
movsd  -0x80(%rbp),%xmm0
mulsd  %xmm1,%xmm0
mov    -0x30(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  0xd6f(%rip),%xmm0
mov    0x2d50(%rip),%rax
divsd  (%rax),%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x60(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x68(%rbp)
movsd  -0x48(%rbp),%xmm0
call   1060 <cos@plt>
movsd  %xmm0,-0x70(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x78(%rbp)
movsd  -0x48(%rbp),%xmm0
call   1040 <sin@plt>
movsd  -0x78(%rbp),%xmm1
movsd  -0x70(%rbp),%xmm2
movaps %xmm0,%xmm3
movsd  -0x68(%rbp),%xmm0
mulsd  %xmm3,%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  -0x8(%rbp),%xmm1
call   1030 <arg@plt>
movsd  -0x60(%rbp),%xmm1
movaps %xmm0,%xmm2
movsd  -0x58(%rbp),%xmm0
addsd  %xmm2,%xmm1
mulsd  %xmm1,%xmm0
mov    -0x38(%rbp),%rax
movsd  %xmm0,(%rax)
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<hcc2stony>:
push   %r15
push   %r14
push   %rbx
sub    $0x50,%rsp
mov    %rsi,%r14
mov    %rdi,%r15
mov    0x2e82(%rip),%rbx
movsd  (%rbx),%xmm5
divsd  0xe8e(%rip),%xmm5
mulsd  %xmm5,%xmm3
movsd  %xmm3,0x48(%rsp)
mulsd  %xmm4,%xmm5
movsd  %xmm5,0x10(%rsp)
movsd  %xmm1,0x20(%rsp)
movapd %xmm1,%xmm3
mulsd  %xmm1,%xmm3
movsd  %xmm0,0x40(%rsp)
movapd %xmm0,%xmm1
mulsd  %xmm0,%xmm1
addsd  %xmm3,%xmm1
movsd  %xmm2,0x28(%rsp)
movapd %xmm2,%xmm0
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
xorpd  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jb     11c8 <hcc2stony+0x78>
sqrtsd %xmm0,%xmm0
jmp    11cd <hcc2stony+0x7d>
call   1070 <sqrt@plt>
movsd  %xmm0,0x8(%rsp)
movsd  0xe25(%rip),%xmm0
movsd  %xmm0,0x18(%rsp)
divsd  (%rbx),%xmm0
movsd  %xmm0,0x38(%rsp)
movsd  0x10(%rsp),%xmm0
call   1060 <cos@plt>
movsd  %xmm0,0x30(%rsp)
movsd  0x10(%rsp),%xmm0
call   1040 <sin@plt>
mulsd  0x28(%rsp),%xmm0
movsd  0x30(%rsp),%xmm1
mulsd  0x20(%rsp),%xmm1
addsd  %xmm1,%xmm0
divsd  0x8(%rsp),%xmm0
call   1050 <asin@plt>
mulsd  0x38(%rsp),%xmm0
movsd  %xmm0,(%r15)
movsd  0x18(%rsp),%xmm0
divsd  (%rbx),%xmm0
movsd  %xmm0,0x18(%rsp)
movsd  0x10(%rsp),%xmm0
call   1060 <cos@plt>
movsd  %xmm0,0x8(%rsp)
movsd  0x10(%rsp),%xmm0
call   1040 <sin@plt>
mulsd  0x20(%rsp),%xmm0
movsd  0x8(%rsp),%xmm1
mulsd  0x28(%rsp),%xmm1
subsd  %xmm0,%xmm1
movapd %xmm1,%xmm0
movsd  0x40(%rsp),%xmm1
call   1030 <arg@plt>
movsd  0x48(%rsp),%xmm1
addsd  %xmm0,%xmm1
mulsd  0x18(%rsp),%xmm1
movsd  %xmm1,(%r14)
add    $0x50,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@M_PI = global double 0.000000e+00
define void @hcc2stony(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
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
%18 = load double, double* @M_PI
%19 = fdiv double %18, 1.800000e+02
%20 = load double, double* %11
%21 = fmul double %19, %20
store double %21, double* %15
%22 = load double, double* @M_PI
%23 = fdiv double %22, 1.800000e+02
%24 = load double, double* %12
%25 = fmul double %23, %24
store double %25, double* %16
%26 = load double, double* %8
%27 = load double, double* %8
%28 = load double, double* %9
%29 = load double, double* %9
%30 = fmul double %28, %29
%31 = call double @llvm.fmuladd.f64(double %26, double %27, double %30)
%32 = load double, double* %10
%33 = load double, double* %10
%34 = call double @llvm.fmuladd.f64(double %32, double %33, double %31)
%35 = call double @sqrt(double %34)
store double %35, double* %17
%36 = load double, double* @M_PI
%37 = fdiv double 1.800000e+02, %36
%38 = load double, double* %9
%39 = load double, double* %16
%40 = call double @cos(double %39)
%41 = load double, double* %10
%42 = load double, double* %16
%43 = call double @sin(double %42)
%44 = fmul double %41, %43
%45 = call double @llvm.fmuladd.f64(double %38, double %40, double %44)
%46 = load double, double* %17
%47 = fdiv double %45, %46
%48 = call double @asin(double %47)
%49 = fmul double %37, %48
%50 = load double*, double** %13
store double %49, double* %50
%51 = load double, double* @M_PI
%52 = fdiv double 1.800000e+02, %51
%53 = load double, double* %15
%54 = load double, double* %10
%55 = load double, double* %16
%56 = call double @cos(double %55)
%57 = load double, double* %9
%58 = load double, double* %16
%59 = call double @sin(double %58)
%60 = fmul double %57, %59
%61 = fneg double %60
%62 = call double @llvm.fmuladd.f64(double %54, double %56, double %61)
%63 = load double, double* %8
%64 = call double @arg(double %62, double %63)
%65 = fadd double %53, %64
%66 = fmul double %52, %65
%67 = load double*, double** %14
store double %66, double* %67
ret void
}

LLVM IR (-O2):
@M_PI = global double 0.000000e+00
define void @hcc2stony(double %0, double %1, double %2, double %3, double %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, %3
%11 = fmul double %9, %4
%12 = fmul double %1, %1
%13 = tail call double @llvm.fmuladd.f64(double %0, double %0, double %12)
%14 = tail call double @llvm.fmuladd.f64(double %2, double %2, double %13)
%15 = tail call double @sqrt(double %14)
%16 = load double, double* @M_PI
%17 = fdiv double 1.800000e+02, %16
%18 = tail call double @cos(double %11)
%19 = tail call double @sin(double %11)
%20 = fmul double %19, %2
%21 = tail call double @llvm.fmuladd.f64(double %1, double %18, double %20)
%22 = fdiv double %21, %15
%23 = tail call double @asin(double %22)
%24 = fmul double %17, %23
store double %24, double* %5
%25 = load double, double* @M_PI
%26 = fdiv double 1.800000e+02, %25
%27 = tail call double @cos(double %11)
%28 = tail call double @sin(double %11)
%29 = fneg double %28
%30 = fmul double %29, %1
%31 = tail call double @llvm.fmuladd.f64(double %2, double %27, double %30)
%32 = tail call double @arg(double %31, double %0)
%33 = fadd double %10, %32
%34 = fmul double %26, %33
store double %34, double* %6
ret void
}