#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 atan2(double, double);
scalar_t__ pow(double, double);
double sqrt(scalar_t__);
void geoXyz2Rae(double xyz_in[], double rae_out[]) {
  double horz_dist;
  rae_out[0] =
      sqrt(pow(xyz_in[0], 2.0) + pow(xyz_in[1], 2.0) + pow(xyz_in[2], 2.0));
  rae_out[1] = atan2(xyz_in[0], xyz_in[1]);
  if ((xyz_in[0] < 0.0) && (xyz_in[1] < 0.0))
    rae_out[1] += (2.0 * 3.14159265358979323846);
  if ((xyz_in[0] < 0.0) && (xyz_in[1] > 0.0))
    rae_out[1] += (2.0 * 3.14159265358979323846);
  horz_dist = sqrt(pow(xyz_in[0], 2.0) + pow(xyz_in[1], 2.0));
  rae_out[2] = atan2(xyz_in[2], horz_dist);
  if (rae_out[2] < 0.0)
    rae_out[2] += (2.0 * 3.14159265358979323846);
}


x86 assembly (clang, -O0):
<geoXyz2Rae>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rax
movsd  (%rax),%xmm0
movsd  0xeb0(%rip),%xmm1
call   1040 <pow@plt>
mov    %rax,-0x28(%rbp)
mov    -0x8(%rbp),%rax
movsd  0x8(%rax),%xmm0
movsd  0xe96(%rip),%xmm1
call   1040 <pow@plt>
mov    %rax,%rcx
mov    -0x28(%rbp),%rax
add    %rcx,%rax
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%rax
movsd  0x10(%rax),%xmm0
movsd  0xe72(%rip),%xmm1
call   1040 <pow@plt>
mov    -0x20(%rbp),%rdi
add    %rax,%rdi
call   1050 <sqrt@plt>
mov    -0x10(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0x8(%rbp),%rax
movsd  (%rax),%xmm0
mov    -0x8(%rbp),%rax
movsd  0x8(%rax),%xmm1
call   1030 <atan2@plt>
mov    -0x10(%rbp),%rax
movsd  %xmm0,0x8(%rax)
mov    -0x8(%rbp),%rax
xorps  %xmm0,%xmm0
ucomisd (%rax),%xmm0
jbe    11ff <geoXyz2Rae+0xcf>
mov    -0x8(%rbp),%rax
xorps  %xmm0,%xmm0
ucomisd 0x8(%rax),%xmm0
jbe    11ff <geoXyz2Rae+0xcf>
mov    -0x10(%rbp),%rax
movsd  0xe13(%rip),%xmm0
addsd  0x8(%rax),%xmm0
movsd  %xmm0,0x8(%rax)
mov    -0x8(%rbp),%rax
xorps  %xmm0,%xmm0
ucomisd (%rax),%xmm0
jbe    123c <geoXyz2Rae+0x10c>
mov    -0x8(%rbp),%rax
movsd  0x8(%rax),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jbe    123c <geoXyz2Rae+0x10c>
mov    -0x10(%rbp),%rax
movsd  0xdd6(%rip),%xmm0
addsd  0x8(%rax),%xmm0
movsd  %xmm0,0x8(%rax)
mov    -0x8(%rbp),%rax
movsd  (%rax),%xmm0
movsd  0xdb4(%rip),%xmm1
call   1040 <pow@plt>
mov    %rax,-0x30(%rbp)
mov    -0x8(%rbp),%rax
movsd  0x8(%rax),%xmm0
movsd  0xd9a(%rip),%xmm1
call   1040 <pow@plt>
mov    -0x30(%rbp),%rdi
add    %rax,%rdi
call   1050 <sqrt@plt>
movsd  %xmm0,-0x18(%rbp)
mov    -0x8(%rbp),%rax
movsd  0x10(%rax),%xmm0
movsd  -0x18(%rbp),%xmm1
call   1030 <atan2@plt>
mov    -0x10(%rbp),%rax
movsd  %xmm0,0x10(%rax)
mov    -0x10(%rbp),%rax
xorps  %xmm0,%xmm0
ucomisd 0x10(%rax),%xmm0
jbe    12c0 <geoXyz2Rae+0x190>
mov    -0x10(%rbp),%rax
movsd  0xd52(%rip),%xmm0
addsd  0x10(%rax),%xmm0
movsd  %xmm0,0x10(%rax)
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<geoXyz2Rae>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%r14
mov    %rdi,%r15
movsd  (%rdi),%xmm0
movsd  0xeb9(%rip),%xmm1
call   1040 <pow@plt>
mov    %rax,%rbx
movsd  0x8(%r15),%xmm0
movsd  0xea3(%rip),%xmm1
call   1040 <pow@plt>
add    %rax,%rbx
movsd  0x10(%r15),%xmm0
movsd  0xe8d(%rip),%xmm1
call   1040 <pow@plt>
add    %rax,%rbx
mov    %rbx,%rdi
call   1050 <sqrt@plt>
movsd  %xmm0,(%r14)
movsd  (%r15),%xmm0
movsd  0x8(%r15),%xmm1
call   1030 <atan2@plt>
movsd  %xmm0,0x8(%r14)
movsd  (%r15),%xmm4
xorpd  %xmm2,%xmm2
ucomisd %xmm4,%xmm2
jbe    11c8 <geoXyz2Rae+0x98>
ucomisd 0x8(%r15),%xmm2
jbe    11c8 <geoXyz2Rae+0x98>
addsd  0xe4b(%rip),%xmm0
movsd  %xmm0,0x8(%r14)
movsd  (%r15),%xmm4
ucomisd %xmm4,%xmm2
jbe    11f1 <geoXyz2Rae+0xc1>
movsd  0x8(%r15),%xmm2
xorpd  %xmm3,%xmm3
ucomisd %xmm3,%xmm2
jbe    11f1 <geoXyz2Rae+0xc1>
addsd  0xe22(%rip),%xmm0
movsd  %xmm0,0x8(%r14)
movsd  (%r15),%xmm4
movsd  0xe07(%rip),%xmm1
movapd %xmm4,%xmm0
call   1040 <pow@plt>
mov    %rax,%rbx
movsd  0x8(%r15),%xmm0
movsd  0xded(%rip),%xmm1
call   1040 <pow@plt>
add    %rax,%rbx
mov    %rbx,%rdi
call   1050 <sqrt@plt>
movaps %xmm0,%xmm1
movsd  0x10(%r15),%xmm0
call   1030 <atan2@plt>
movsd  0xdcf(%rip),%xmm1
addsd  %xmm0,%xmm1
xorpd  %xmm2,%xmm2
movapd %xmm0,%xmm3
cmpltsd %xmm2,%xmm3
andpd  %xmm3,%xmm1
andnpd %xmm0,%xmm3
orpd   %xmm1,%xmm3
movlpd %xmm3,0x10(%r14)
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @geoXyz2Rae(double* %0, double* %1) {
%3 = alloca double*
%4 = alloca double*
%5 = alloca double
store double* %0, double** %3
store double* %1, double** %4
%6 = load double*, double** %3
%7 = getelementptr inbounds double, double* %6, i64 0
%8 = load double, double* %7
%9 = call i64 @pow(double %8, double 2.000000e+00)
%10 = load double*, double** %3
%11 = getelementptr inbounds double, double* %10, i64 1
%12 = load double, double* %11
%13 = call i64 @pow(double %12, double 2.000000e+00)
%14 = add nsw i64 %9, %13
%15 = load double*, double** %3
%16 = getelementptr inbounds double, double* %15, i64 2
%17 = load double, double* %16
%18 = call i64 @pow(double %17, double 2.000000e+00)
%19 = add nsw i64 %14, %18
%20 = call double @sqrt(i64 %19)
%21 = load double*, double** %4
%22 = getelementptr inbounds double, double* %21, i64 0
store double %20, double* %22
%23 = load double*, double** %3
%24 = getelementptr inbounds double, double* %23, i64 0
%25 = load double, double* %24
%26 = load double*, double** %3
%27 = getelementptr inbounds double, double* %26, i64 1
%28 = load double, double* %27
%29 = call double @atan2(double %25, double %28)
%30 = load double*, double** %4
%31 = getelementptr inbounds double, double* %30, i64 1
store double %29, double* %31
%32 = load double*, double** %3
%33 = getelementptr inbounds double, double* %32, i64 0
%34 = load double, double* %33
%35 = fcmp olt double %34, 0.000000e+00
br i1 %35, label %36, label %46
36: ; preds = %2
%37 = load double*, double** %3
%38 = getelementptr inbounds double, double* %37, i64 1
%39 = load double, double* %38
%40 = fcmp olt double %39, 0.000000e+00
br i1 %40, label %41, label %46
41: ; preds = %36
%42 = load double*, double** %4
%43 = getelementptr inbounds double, double* %42, i64 1
%44 = load double, double* %43
%45 = fadd double %44, 0x401921FB54442D18
store double %45, double* %43
br label %46
46: ; preds = %41, %36, %2
%47 = load double*, double** %3
%48 = getelementptr inbounds double, double* %47, i64 0
%49 = load double, double* %48
%50 = fcmp olt double %49, 0.000000e+00
br i1 %50, label %51, label %61
51: ; preds = %46
%52 = load double*, double** %3
%53 = getelementptr inbounds double, double* %52, i64 1
%54 = load double, double* %53
%55 = fcmp ogt double %54, 0.000000e+00
br i1 %55, label %56, label %61
56: ; preds = %51
%57 = load double*, double** %4
%58 = getelementptr inbounds double, double* %57, i64 1
%59 = load double, double* %58
%60 = fadd double %59, 0x401921FB54442D18
store double %60, double* %58
br label %61
61: ; preds = %56, %51, %46
%62 = load double*, double** %3
%63 = getelementptr inbounds double, double* %62, i64 0
%64 = load double, double* %63
%65 = call i64 @pow(double %64, double 2.000000e+00)
%66 = load double*, double** %3
%67 = getelementptr inbounds double, double* %66, i64 1
%68 = load double, double* %67
%69 = call i64 @pow(double %68, double 2.000000e+00)
%70 = add nsw i64 %65, %69
%71 = call double @sqrt(i64 %70)
store double %71, double* %5
%72 = load double*, double** %3
%73 = getelementptr inbounds double, double* %72, i64 2
%74 = load double, double* %73
%75 = load double, double* %5
%76 = call double @atan2(double %74, double %75)
%77 = load double*, double** %4
%78 = getelementptr inbounds double, double* %77, i64 2
store double %76, double* %78
%79 = load double*, double** %4
%80 = getelementptr inbounds double, double* %79, i64 2
%81 = load double, double* %80
%82 = fcmp olt double %81, 0.000000e+00
br i1 %82, label %83, label %88
83: ; preds = %61
%84 = load double*, double** %4
%85 = getelementptr inbounds double, double* %84, i64 2
%86 = load double, double* %85
%87 = fadd double %86, 0x401921FB54442D18
store double %87, double* %85
br label %88
88: ; preds = %83, %61
ret void
}

LLVM IR (-O2):
define void @geoXyz2Rae(double* nocapture %0, double* nocapture %1) {
%3 = load double, double* %0
%4 = tail call i64 @pow(double %3, double 2.000000e+00)
%5 = getelementptr inbounds double, double* %0, i64 1
%6 = load double, double* %5
%7 = tail call i64 @pow(double %6, double 2.000000e+00)
%8 = add nsw i64 %7, %4
%9 = getelementptr inbounds double, double* %0, i64 2
%10 = load double, double* %9
%11 = tail call i64 @pow(double %10, double 2.000000e+00)
%12 = add nsw i64 %8, %11
%13 = tail call double @sqrt(i64 %12)
store double %13, double* %1
%14 = load double, double* %0
%15 = load double, double* %5
%16 = tail call double @atan2(double %14, double %15)
%17 = getelementptr inbounds double, double* %1, i64 1
store double %16, double* %17
%18 = load double, double* %0
%19 = fcmp olt double %18, 0.000000e+00
br i1 %19, label %20, label %26
20: ; preds = %2
%21 = load double, double* %5
%22 = fcmp olt double %21, 0.000000e+00
br i1 %22, label %23, label %26
23: ; preds = %20
%24 = fadd double %16, 0x401921FB54442D18
store double %24, double* %17
%25 = load double, double* %0
br label %26
26: ; preds = %23, %20, %2
%27 = phi double [ %24, %23 ], [ %16, %20 ], [ %16, %2 ]
%28 = phi double [ %25, %23 ], [ %18, %20 ], [ %18, %2 ]
%29 = fcmp olt double %28, 0.000000e+00
br i1 %29, label %30, label %36
30: ; preds = %26
%31 = load double, double* %5
%32 = fcmp ogt double %31, 0.000000e+00
br i1 %32, label %33, label %36
33: ; preds = %30
%34 = fadd double %27, 0x401921FB54442D18
store double %34, double* %17
%35 = load double, double* %0
br label %36
36: ; preds = %33, %30, %26
%37 = phi double [ %35, %33 ], [ %28, %30 ], [ %28, %26 ]
%38 = tail call i64 @pow(double %37, double 2.000000e+00)
%39 = load double, double* %5
%40 = tail call i64 @pow(double %39, double 2.000000e+00)
%41 = add nsw i64 %40, %38
%42 = tail call double @sqrt(i64 %41)
%43 = load double, double* %9
%44 = tail call double @atan2(double %43, double %42)
%45 = fcmp olt double %44, 0.000000e+00
%46 = fadd double %44, 0x401921FB54442D18
%47 = select i1 %45, double %46, double %44
%48 = getelementptr inbounds double, double* %1, i64 2
store double %47, double* %48
ret void
}