#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);
double sqrt(double);
void xyz2cyl(double x, double y, double z, double *pr, double *pphi,
             double *pz) {
  double r, phi;
  r = sqrt(x * x + y * y);
  phi = atan2(y, x);
  *pr = r;
  *pphi = phi;
  *pz = z;
}


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

x86 assembly (clang, -O2):
<xyz2cyl>:
push   %r15
push   %r14
push   %rbx
sub    $0x20,%rsp
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%rbx
movsd  %xmm2,0x18(%rsp)
movapd %xmm1,%xmm3
movapd %xmm0,%xmm2
mulsd  %xmm1,%xmm1
mulsd  %xmm0,%xmm0
addsd  %xmm1,%xmm0
xorpd  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jb     115c <xyz2cyl+0x3c>
sqrtsd %xmm0,%xmm0
jmp    1179 <xyz2cyl+0x59>
movsd  %xmm2,0x10(%rsp)
movsd  %xmm3,0x8(%rsp)
call   1040 <sqrt@plt>
movsd  0x8(%rsp),%xmm3
movsd  0x10(%rsp),%xmm2
movsd  %xmm0,(%rsp)
movapd %xmm3,%xmm0
movapd %xmm2,%xmm1
call   1030 <atan2@plt>
movsd  (%rsp),%xmm1
movsd  %xmm1,(%rbx)
movsd  %xmm0,(%r15)
movsd  0x18(%rsp),%xmm0
movsd  %xmm0,(%r14)
add    $0x20,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @xyz2cyl(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
%14 = 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
%15 = load double, double* %7
%16 = load double, double* %7
%17 = load double, double* %8
%18 = load double, double* %8
%19 = fmul double %17, %18
%20 = call double @llvm.fmuladd.f64(double %15, double %16, double %19)
%21 = call double @sqrt(double %20)
store double %21, double* %13
%22 = load double, double* %8
%23 = load double, double* %7
%24 = call double @atan2(double %22, double %23)
store double %24, double* %14
%25 = load double, double* %13
%26 = load double*, double** %10
store double %25, double* %26
%27 = load double, double* %14
%28 = load double*, double** %11
store double %27, double* %28
%29 = load double, double* %9
%30 = load double*, double** %12
store double %29, double* %30
ret void
}

LLVM IR (-O2):
define void @xyz2cyl(double %0, double %1, double %2, double* nocapture writeonly %3, double* nocapture writeonly %4, double* nocapture writeonly %5) {
%7 = fmul double %1, %1
%8 = tail call double @llvm.fmuladd.f64(double %0, double %0, double %7)
%9 = tail call double @sqrt(double %8)
%10 = tail call double @atan2(double %1, double %0)
store double %9, double* %3
store double %10, double* %4
store double %2, double* %5
ret void
}