#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 asin(double);
double cos(double);
double sqrt(double);
void XYZ2Polar(double x, double y, double z, double *range, double *above,
               double *about) {
  double dr;
  *range = sqrt(x * x + y * y + z * z);
  if (*range < 0.000001) {
    *above = 0.0;
    *about = 0.0;
  } else {
    *above = asin(z / *range);
    dr = *range * cos(*above);
    if ((dr < 0 ? -(dr) : (dr)) < 0.000001) {
      *about = 0.0;
    } else {
      *about = asin(y / dr);
    }
  }
  *about *= 57.2957795;
  *above *= 57.2957795;
  *about += 90;
}


x86 assembly (clang, -O0):
<XYZ2Polar>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
movsd  %xmm2,-0x18(%rbp)
mov    %rdi,-0x20(%rbp)
mov    %rsi,-0x28(%rbp)
mov    %rdx,-0x30(%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   1050 <sqrt@plt>
mov    -0x20(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0x20(%rbp),%rax
movsd  0xe66(%rip),%xmm0
ucomisd (%rax),%xmm0
jbe    11bf <XYZ2Polar+0x8f>
mov    -0x28(%rbp),%rax
xorps  %xmm0,%xmm0
movsd  %xmm0,(%rax)
mov    -0x30(%rbp),%rax
xorps  %xmm0,%xmm0
movsd  %xmm0,(%rax)
jmp    1285 <XYZ2Polar+0x155>
movsd  -0x18(%rbp),%xmm0
mov    -0x20(%rbp),%rax
divsd  (%rax),%xmm0
call   1030 <asin@plt>
mov    -0x28(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0x20(%rbp),%rax
movsd  (%rax),%xmm0
movsd  %xmm0,-0x40(%rbp)
mov    -0x28(%rbp),%rax
movsd  (%rax),%xmm0
call   1040 <cos@plt>
movaps %xmm0,%xmm1
movsd  -0x40(%rbp),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
xorps  %xmm0,%xmm0
ucomisd -0x38(%rbp),%xmm0
jbe    1238 <XYZ2Polar+0x108>
movsd  -0x38(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  %xmm0,-0x48(%rbp)
jmp    1242 <XYZ2Polar+0x112>
movsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x48(%rbp),%xmm1
movsd  0xdb1(%rip),%xmm0
ucomisd %xmm1,%xmm0
jbe    1269 <XYZ2Polar+0x139>
mov    -0x30(%rbp),%rax
xorps  %xmm0,%xmm0
movsd  %xmm0,(%rax)
jmp    1280 <XYZ2Polar+0x150>
movsd  -0x10(%rbp),%xmm0
divsd  -0x38(%rbp),%xmm0
call   1030 <asin@plt>
mov    -0x30(%rbp),%rax
movsd  %xmm0,(%rax)
jmp    1285 <XYZ2Polar+0x155>
mov    -0x30(%rbp),%rax
movsd  0xd7f(%rip),%xmm0
mulsd  (%rax),%xmm0
movsd  %xmm0,(%rax)
mov    -0x28(%rbp),%rax
movsd  0xd6b(%rip),%xmm0
mulsd  (%rax),%xmm0
movsd  %xmm0,(%rax)
mov    -0x30(%rbp),%rax
movsd  0xd4f(%rip),%xmm0
addsd  (%rax),%xmm0
movsd  %xmm0,(%rax)
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<XYZ2Polar>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%rbx
movapd %xmm0,%xmm3
movsd  %xmm1,0x8(%rsp)
movapd %xmm1,%xmm0
mulsd  %xmm1,%xmm0
mulsd  %xmm3,%xmm3
addsd  %xmm0,%xmm3
movapd %xmm2,%xmm0
mulsd  %xmm2,%xmm0
addsd  %xmm3,%xmm0
xorpd  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jb     1178 <XYZ2Polar+0x48>
sqrtsd %xmm0,%xmm0
jmp    1187 <XYZ2Polar+0x57>
movsd  %xmm2,(%rsp)
call   1050 <sqrt@plt>
movsd  (%rsp),%xmm2
movsd  %xmm0,(%rbx)
movsd  0xe6d(%rip),%xmm1
ucomisd %xmm0,%xmm1
jbe    11a6 <XYZ2Polar+0x76>
movq   $0x0,(%r15)
xorpd  %xmm0,%xmm0
jmp    1219 <XYZ2Polar+0xe9>
divsd  %xmm0,%xmm2
movapd %xmm2,%xmm0
call   1030 <asin@plt>
movsd  %xmm0,(%r15)
movsd  (%rbx),%xmm1
movsd  %xmm1,(%rsp)
call   1040 <cos@plt>
movapd %xmm0,%xmm1
mulsd  (%rsp),%xmm1
movapd 0xe49(%rip),%xmm2
xorpd  %xmm1,%xmm2
xorpd  %xmm0,%xmm0
movapd %xmm1,%xmm3
cmpltsd %xmm0,%xmm3
andpd  %xmm3,%xmm2
andnpd %xmm1,%xmm3
orpd   %xmm2,%xmm3
movsd  0xe04(%rip),%xmm2
ucomisd %xmm3,%xmm2
ja     1219 <XYZ2Polar+0xe9>
movsd  0x8(%rsp),%xmm0
divsd  %xmm1,%xmm0
call   1030 <asin@plt>
mulsd  0xdef(%rip),%xmm0
movsd  %xmm0,(%r14)
movsd  (%r15),%xmm0
mulsd  0xddd(%rip),%xmm0
movsd  %xmm0,(%r15)
movsd  (%r14),%xmm0
addsd  0xdd3(%rip),%xmm0
movsd  %xmm0,(%r14)
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @XYZ2Polar(double %0, double %1, double %2, double* %3, double* %4, double* %5) {
%7 = alloca double
%8 = alloca double
%9 = alloca double
%10 = alloca double*
%11 = alloca double*
%12 = alloca double*
%13 = alloca double
store double %0, double* %7
store double %1, double* %8
store double %2, double* %9
store double* %3, double** %10
store double* %4, double** %11
store double* %5, double** %12
%14 = load double, double* %7
%15 = load double, double* %7
%16 = load double, double* %8
%17 = load double, double* %8
%18 = fmul double %16, %17
%19 = call double @llvm.fmuladd.f64(double %14, double %15, double %18)
%20 = load double, double* %9
%21 = load double, double* %9
%22 = call double @llvm.fmuladd.f64(double %20, double %21, double %19)
%23 = call double @sqrt(double %22)
%24 = load double*, double** %10
store double %23, double* %24
%25 = load double*, double** %10
%26 = load double, double* %25
%27 = fcmp olt double %26, 0x3EB0C6F7A0B5ED8D
br i1 %27, label %28, label %31
28: ; preds = %6
%29 = load double*, double** %11
store double 0.000000e+00, double* %29
%30 = load double*, double** %12
store double 0.000000e+00, double* %30
br label %63
31: ; preds = %6
%32 = load double, double* %9
%33 = load double*, double** %10
%34 = load double, double* %33
%35 = fdiv double %32, %34
%36 = call double @asin(double %35)
%37 = load double*, double** %11
store double %36, double* %37
%38 = load double*, double** %10
%39 = load double, double* %38
%40 = load double*, double** %11
%41 = load double, double* %40
%42 = call double @cos(double %41)
%43 = fmul double %39, %42
store double %43, double* %13
%44 = load double, double* %13
%45 = fcmp olt double %44, 0.000000e+00
br i1 %45, label %46, label %49
46: ; preds = %31
%47 = load double, double* %13
%48 = fneg double %47
br label %51
49: ; preds = %31
%50 = load double, double* %13
br label %51
51: ; preds = %49, %46
%52 = phi double [ %48, %46 ], [ %50, %49 ]
%53 = fcmp olt double %52, 0x3EB0C6F7A0B5ED8D
br i1 %53, label %54, label %56
54: ; preds = %51
%55 = load double*, double** %12
store double 0.000000e+00, double* %55
br label %62
56: ; preds = %51
%57 = load double, double* %8
%58 = load double, double* %13
%59 = fdiv double %57, %58
%60 = call double @asin(double %59)
%61 = load double*, double** %12
store double %60, double* %61
br label %62
62: ; preds = %56, %54
br label %63
63: ; preds = %62, %28
%64 = load double*, double** %12
%65 = load double, double* %64
%66 = fmul double %65, 0x404CA5DC1A47A9E3
store double %66, double* %64
%67 = load double*, double** %11
%68 = load double, double* %67
%69 = fmul double %68, 0x404CA5DC1A47A9E3
store double %69, double* %67
%70 = load double*, double** %12
%71 = load double, double* %70
%72 = fadd double %71, 9.000000e+01
store double %72, double* %70
ret void
}

LLVM IR (-O2):
define void @XYZ2Polar(double %0, double %1, double %2, double* nocapture %3, double* nocapture %4, double* nocapture %5) {
%7 = fmul double %1, %1
%8 = tail call double @llvm.fmuladd.f64(double %0, double %0, double %7)
%9 = tail call double @llvm.fmuladd.f64(double %2, double %2, double %8)
%10 = tail call double @sqrt(double %9)
store double %10, double* %3
%11 = fcmp olt double %10, 0x3EB0C6F7A0B5ED8D
br i1 %11, label %12, label %13
12: ; preds = %6
store double 0.000000e+00, double* %4
br label %27
13: ; preds = %6
%14 = fdiv double %2, %10
%15 = tail call double @asin(double %14)
store double %15, double* %4
%16 = load double, double* %3
%17 = tail call double @cos(double %15)
%18 = fmul double %16, %17
%19 = fcmp olt double %18, 0.000000e+00
%20 = fneg double %18
%21 = select i1 %19, double %20, double %18
%22 = fcmp olt double %21, 0x3EB0C6F7A0B5ED8D
br i1 %22, label %27, label %23
23: ; preds = %13
%24 = fdiv double %1, %18
%25 = tail call double @asin(double %24)
%26 = fmul double %25, 0x404CA5DC1A47A9E3
br label %27
27: ; preds = %13, %23, %12
%28 = phi double [ %26, %23 ], [ 0.000000e+00, %12 ], [ 0.000000e+00, %13 ]
store double %28, double* %5
%29 = load double, double* %4
%30 = fmul double %29, 0x404CA5DC1A47A9E3
store double %30, double* %4
%31 = load double, double* %5
%32 = fadd double %31, 9.000000e+01
store double %32, double* %5
ret void
}