#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 acos(double const);
double sqrt(double const);
void get_coords_from_rpz(const double *rpz, double *x) {
  double r = sqrt(rpz[0] * rpz[0] + rpz[2] * rpz[2]);
  x[0] = r;
  x[1] = rpz[1];
  x[2] = acos(rpz[2] / r);
}


x86 assembly (clang, -O0):
<get_coords_from_rpz>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rax
movsd  (%rax),%xmm0
mov    -0x8(%rbp),%rax
movsd  (%rax),%xmm2
mov    -0x8(%rbp),%rax
movsd  0x10(%rax),%xmm1
mov    -0x8(%rbp),%rax
mulsd  0x10(%rax),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
call   1040 <sqrt@plt>
movsd  %xmm0,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0x8(%rbp),%rax
movsd  0x8(%rax),%xmm0
mov    -0x10(%rbp),%rax
movsd  %xmm0,0x8(%rax)
mov    -0x8(%rbp),%rax
movsd  0x10(%rax),%xmm0
divsd  -0x18(%rbp),%xmm0
call   1030 <acos@plt>
mov    -0x10(%rbp),%rax
movsd  %xmm0,0x10(%rax)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_coords_from_rpz>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
movsd  (%rdi),%xmm0
movsd  0x10(%rdi),%xmm1
mulsd  %xmm1,%xmm1
mulsd  %xmm0,%xmm0
addsd  %xmm1,%xmm0
xorpd  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jb     114f <get_coords_from_rpz+0x2f>
sqrtsd %xmm0,%xmm0
jmp    1154 <get_coords_from_rpz+0x34>
call   1040 <sqrt@plt>
movsd  %xmm0,(%r14)
movsd  0x8(%rbx),%xmm1
movsd  %xmm1,0x8(%r14)
movsd  0x10(%rbx),%xmm1
divsd  %xmm0,%xmm1
movapd %xmm1,%xmm0
call   1030 <acos@plt>
movsd  %xmm0,0x10(%r14)
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define void @get_coords_from_rpz(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 = load double*, double** %3
%10 = getelementptr inbounds double, double* %9, i64 0
%11 = load double, double* %10
%12 = load double*, double** %3
%13 = getelementptr inbounds double, double* %12, i64 2
%14 = load double, double* %13
%15 = load double*, double** %3
%16 = getelementptr inbounds double, double* %15, i64 2
%17 = load double, double* %16
%18 = fmul double %14, %17
%19 = call double @llvm.fmuladd.f64(double %8, double %11, double %18)
%20 = call double @sqrt(double %19)
store double %20, double* %5
%21 = load double, double* %5
%22 = load double*, double** %4
%23 = getelementptr inbounds double, double* %22, i64 0
store double %21, double* %23
%24 = load double*, double** %3
%25 = getelementptr inbounds double, double* %24, i64 1
%26 = load double, double* %25
%27 = load double*, double** %4
%28 = getelementptr inbounds double, double* %27, i64 1
store double %26, double* %28
%29 = load double*, double** %3
%30 = getelementptr inbounds double, double* %29, i64 2
%31 = load double, double* %30
%32 = load double, double* %5
%33 = fdiv double %31, %32
%34 = call double @acos(double %33)
%35 = load double*, double** %4
%36 = getelementptr inbounds double, double* %35, i64 2
store double %34, double* %36
ret void
}

LLVM IR (-O2):
define void @get_coords_from_rpz(double* nocapture %0, double* nocapture writeonly %1) {
%3 = load double, double* %0
%4 = getelementptr inbounds double, double* %0, i64 2
%5 = load double, double* %4
%6 = fmul double %5, %5
%7 = tail call double @llvm.fmuladd.f64(double %3, double %3, double %6)
%8 = tail call double @sqrt(double %7)
store double %8, double* %1
%9 = getelementptr inbounds double, double* %0, i64 1
%10 = load double, double* %9
%11 = getelementptr inbounds double, double* %1, i64 1
store double %10, double* %11
%12 = load double, double* %4
%13 = fdiv double %12, %8
%14 = tail call double @acos(double %13)
%15 = getelementptr inbounds double, double* %1, i64 2
store double %14, double* %15
ret void
}