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


x86 assembly (clang, -O0):
<get_rpz>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%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  0x8(%rax),%xmm1
mov    -0x8(%rbp),%rax
mulsd  0x8(%rax),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
call   1040 <sqrt@plt>
mov    -0x10(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0x8(%rbp),%rax
movsd  0x8(%rax),%xmm0
mov    -0x8(%rbp),%rax
movsd  (%rax),%xmm1
call   1030 <atan2@plt>
mov    -0x10(%rbp),%rax
movsd  %xmm0,0x8(%rax)
mov    -0x8(%rbp),%rax
movsd  0x10(%rax),%xmm0
mov    -0x10(%rbp),%rax
movsd  %xmm0,0x10(%rax)
add    $0x10,%rsp
pop    %rbp
ret

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

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

LLVM IR (-O2):
define void @get_rpz(double* nocapture %0, double* nocapture writeonly %1) {
%3 = load double, double* %0
%4 = getelementptr inbounds double, double* %0, i64 1
%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 = load double, double* %4
%10 = load double, double* %0
%11 = tail call double @atan2(double %9, double %10)
%12 = getelementptr inbounds double, double* %1, i64 1
store double %11, double* %12
%13 = getelementptr inbounds double, double* %0, i64 2
%14 = load double, double* %13
%15 = getelementptr inbounds double, double* %1, i64 2
store double %14, double* %15
ret void
}