#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);
int ctop3(double cr, double ct, double cz, double *pr, double *pe, double *pp) {
  static double rtod = 57.29577951308232088;
  *pr = sqrt(cr * cr + cz * cz);
  *pe = ct;
  if (cz != 0)
    *pp = atan2(cr, cz) * rtod;
  else {
    if (cr < 0.0)
      *pp = -90.0;
    else if (cr > 0.0)
      *pp = 90.0;
    else
      *pp = 0.0;
  }
  return 0;
}


x86 assembly (clang, -O0):
<ctop3>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%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  -0x18(%rbp),%xmm1
mulsd  -0x18(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
call   1040 <sqrt@plt>
mov    -0x20(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x10(%rbp),%xmm0
mov    -0x28(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x18(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    1196 <ctop3+0x76>
jp     1196 <ctop3+0x76>
jmp    11ba <ctop3+0x9a>
movsd  -0x8(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
call   1030 <atan2@plt>
mulsd  0x2e83(%rip),%xmm0
mov    -0x30(%rbp),%rax
movsd  %xmm0,(%rax)
jmp    1219 <ctop3+0xf9>
xorps  %xmm0,%xmm0
ucomisd -0x8(%rbp),%xmm0
jbe    11dd <ctop3+0xbd>
mov    -0x30(%rbp),%rax
movsd  0xe34(%rip),%xmm0
movsd  %xmm0,(%rax)
jmp    1214 <ctop3+0xf4>
movsd  -0x8(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jbe    1204 <ctop3+0xe4>
mov    -0x30(%rbp),%rax
movsd  0xe05(%rip),%xmm0
movsd  %xmm0,(%rax)
jmp    120f <ctop3+0xef>
mov    -0x30(%rbp),%rax
xorps  %xmm0,%xmm0
movsd  %xmm0,(%rax)
jmp    1214 <ctop3+0xf4>
jmp    1219 <ctop3+0xf9>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ctop3>:
push   %r15
push   %r14
push   %rbx
sub    $0x20,%rsp
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%rbx
movapd %xmm0,%xmm3
movapd %xmm2,%xmm4
mulsd  %xmm2,%xmm4
mulsd  %xmm0,%xmm0
addsd  %xmm4,%xmm0
xorpd  %xmm4,%xmm4
ucomisd %xmm4,%xmm0
jb     1156 <ctop3+0x36>
sqrtsd %xmm0,%xmm0
jmp    1183 <ctop3+0x63>
movsd  %xmm3,0x18(%rsp)
movsd  %xmm2,0x10(%rsp)
movsd  %xmm1,0x8(%rsp)
call   1040 <sqrt@plt>
xorpd  %xmm4,%xmm4
movsd  0x8(%rsp),%xmm1
movsd  0x10(%rsp),%xmm2
movsd  0x18(%rsp),%xmm3
movsd  %xmm0,(%rbx)
movsd  %xmm1,(%r15)
ucomisd %xmm4,%xmm2
jne    1194 <ctop3+0x74>
jnp    11ab <ctop3+0x8b>
movapd %xmm3,%xmm0
movapd %xmm2,%xmm1
call   1030 <atan2@plt>
mulsd  0xe67(%rip),%xmm0
jmp    11d0 <ctop3+0xb0>
xorpd  %xmm1,%xmm1
ucomisd %xmm3,%xmm1
jbe    11bf <ctop3+0x9f>
movsd  0xe43(%rip),%xmm0
jmp    11d0 <ctop3+0xb0>
cmpltsd %xmm3,%xmm1
movsd  0xe3c(%rip),%xmm0
andpd  %xmm1,%xmm0
movsd  %xmm0,(%r14)
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@ctop3.rtod = internal global double 0x404CA5DC1A63C1F8
define i32 @ctop3(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*
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
%13 = load double, double* %7
%14 = load double, double* %7
%15 = load double, double* %9
%16 = load double, double* %9
%17 = fmul double %15, %16
%18 = call double @llvm.fmuladd.f64(double %13, double %14, double %17)
%19 = call double @sqrt(double %18)
%20 = load double*, double** %10
store double %19, double* %20
%21 = load double, double* %8
%22 = load double*, double** %11
store double %21, double* %22
%23 = load double, double* %9
%24 = fcmp une double %23, 0.000000e+00
br i1 %24, label %25, label %32
25: ; preds = %6
%26 = load double, double* %7
%27 = load double, double* %9
%28 = call double @atan2(double %26, double %27)
%29 = load double, double* @ctop3.rtod
%30 = fmul double %28, %29
%31 = load double*, double** %12
store double %30, double* %31
br label %46
32: ; preds = %6
%33 = load double, double* %7
%34 = fcmp olt double %33, 0.000000e+00
br i1 %34, label %35, label %37
35: ; preds = %32
%36 = load double*, double** %12
store double -9.000000e+01, double* %36
br label %45
37: ; preds = %32
%38 = load double, double* %7
%39 = fcmp ogt double %38, 0.000000e+00
br i1 %39, label %40, label %42
40: ; preds = %37
%41 = load double*, double** %12
store double 9.000000e+01, double* %41
br label %44
42: ; preds = %37
%43 = load double*, double** %12
store double 0.000000e+00, double* %43
br label %44
44: ; preds = %42, %40
br label %45
45: ; preds = %44, %35
br label %46
46: ; preds = %45, %25
ret i32 0
}

LLVM IR (-O2):
define i32 @ctop3(double %0, double %1, double %2, double* nocapture writeonly %3, double* nocapture writeonly %4, double* nocapture writeonly %5) {
%7 = fmul double %2, %2
%8 = tail call double @llvm.fmuladd.f64(double %0, double %0, double %7)
%9 = tail call double @sqrt(double %8)
store double %9, double* %3
store double %1, double* %4
%10 = fcmp une double %2, 0.000000e+00
br i1 %10, label %11, label %14
11: ; preds = %6
%12 = tail call double @atan2(double %0, double %2)
%13 = fmul double %12, 0x404CA5DC1A63C1F8
br label %19
14: ; preds = %6
%15 = fcmp olt double %0, 0.000000e+00
br i1 %15, label %19, label %16
16: ; preds = %14
%17 = fcmp ogt double %0, 0.000000e+00
%18 = select i1 %17, double 9.000000e+01, double 0.000000e+00
br label %19
19: ; preds = %16, %14, %11
%20 = phi double [ %13, %11 ], [ -9.000000e+01, %14 ], [ %18, %16 ]
store double %20, double* %5
ret i32 0
}