#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 dtop3(double dx, double dy, double dz, double *pr, double *pe, double *pp) {
  double w;
  static double rtod = 57.295779513082321;
  *pr = sqrt(dx * dx + dy * dy + dz * dz);
  if (dx != 0.0)
    *pe = atan2(dy, dx) * rtod;
  else {
    if (dy < 0.0)
      *pe = -90.0;
    else if (dy > 0.0)
      *pe = 90.0;
    else
      *pe = 0.0;
  }
  w = dx * dx + dy * dy;
  if (dz != 0.0)
    *pp = atan2(sqrt(w), dz) * rtod;
  else {
    if (w < 0.0)
      *pp = -90.0;
    else if (w > 0.0)
      *pp = 90.0;
    else
      *pp = 0.0;
  }
  return 0;
}


x86 assembly (clang, -O0):
<dtop3>:
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),%xmm1
movsd  -0x8(%rbp),%xmm2
movsd  -0x10(%rbp),%xmm0
mulsd  -0x10(%rbp),%xmm0
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
movsd  -0x18(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
call   1040 <sqrt@plt>
mov    -0x20(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x8(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    119b <dtop3+0x7b>
jp     119b <dtop3+0x7b>
jmp    11bf <dtop3+0x9f>
movsd  -0x10(%rbp),%xmm0
movsd  -0x8(%rbp),%xmm1
call   1030 <atan2@plt>
mulsd  0x2e7e(%rip),%xmm0
mov    -0x28(%rbp),%rax
movsd  %xmm0,(%rax)
jmp    121e <dtop3+0xfe>
xorps  %xmm0,%xmm0
ucomisd -0x10(%rbp),%xmm0
jbe    11e2 <dtop3+0xc2>
mov    -0x28(%rbp),%rax
movsd  0xe2f(%rip),%xmm0
movsd  %xmm0,(%rax)
jmp    1219 <dtop3+0xf9>
movsd  -0x10(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jbe    1209 <dtop3+0xe9>
mov    -0x28(%rbp),%rax
movsd  0xe00(%rip),%xmm0
movsd  %xmm0,(%rax)
jmp    1214 <dtop3+0xf4>
mov    -0x28(%rbp),%rax
xorps  %xmm0,%xmm0
movsd  %xmm0,(%rax)
jmp    1219 <dtop3+0xf9>
jmp    121e <dtop3+0xfe>
movsd  -0x8(%rbp),%xmm0
movsd  -0x8(%rbp),%xmm2
movsd  -0x10(%rbp),%xmm1
mulsd  -0x10(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x18(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    125c <dtop3+0x13c>
jp     125c <dtop3+0x13c>
jmp    1285 <dtop3+0x165>
movsd  -0x38(%rbp),%xmm0
call   1040 <sqrt@plt>
movsd  -0x18(%rbp),%xmm1
call   1030 <atan2@plt>
mulsd  0x2db8(%rip),%xmm0
mov    -0x30(%rbp),%rax
movsd  %xmm0,(%rax)
jmp    12e4 <dtop3+0x1c4>
xorps  %xmm0,%xmm0
ucomisd -0x38(%rbp),%xmm0
jbe    12a8 <dtop3+0x188>
mov    -0x30(%rbp),%rax
movsd  0xd69(%rip),%xmm0
movsd  %xmm0,(%rax)
jmp    12df <dtop3+0x1bf>
movsd  -0x38(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jbe    12cf <dtop3+0x1af>
mov    -0x30(%rbp),%rax
movsd  0xd3a(%rip),%xmm0
movsd  %xmm0,(%rax)
jmp    12da <dtop3+0x1ba>
mov    -0x30(%rbp),%rax
xorps  %xmm0,%xmm0
movsd  %xmm0,(%rax)
jmp    12df <dtop3+0x1bf>
jmp    12e4 <dtop3+0x1c4>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dtop3>:
push   %r15
push   %r14
push   %rbx
sub    $0x20,%rsp
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%rbx
movapd %xmm0,%xmm4
movapd %xmm1,%xmm0
mulsd  %xmm1,%xmm0
movapd %xmm4,%xmm3
mulsd  %xmm4,%xmm3
addsd  %xmm0,%xmm3
movsd  %xmm2,0x8(%rsp)
movapd %xmm2,%xmm0
mulsd  %xmm2,%xmm0
movsd  %xmm3,(%rsp)
addsd  %xmm3,%xmm0
xorpd  %xmm2,%xmm2
ucomisd %xmm2,%xmm0
jb     1171 <dtop3+0x51>
sqrtsd %xmm0,%xmm0
jmp    1192 <dtop3+0x72>
movsd  %xmm1,0x18(%rsp)
movsd  %xmm4,0x10(%rsp)
call   1040 <sqrt@plt>
xorpd  %xmm2,%xmm2
movsd  0x10(%rsp),%xmm4
movsd  0x18(%rsp),%xmm1
movsd  %xmm0,(%rbx)
ucomisd %xmm2,%xmm4
jne    119e <dtop3+0x7e>
jnp    11b5 <dtop3+0x95>
movapd %xmm1,%xmm0
movapd %xmm4,%xmm1
call   1030 <atan2@plt>
mulsd  0xe5d(%rip),%xmm0
jmp    11da <dtop3+0xba>
xorpd  %xmm2,%xmm2
ucomisd %xmm1,%xmm2
jbe    11c9 <dtop3+0xa9>
movsd  0xe39(%rip),%xmm0
jmp    11da <dtop3+0xba>
cmpltsd %xmm1,%xmm2
movsd  0xe32(%rip),%xmm0
andpd  %xmm2,%xmm0
movsd  %xmm0,(%r15)
xorpd  %xmm1,%xmm1
movsd  0x8(%rsp),%xmm0
ucomisd %xmm1,%xmm0
jne    11f1 <dtop3+0xd1>
jnp    1202 <dtop3+0xe2>
movsd  (%rsp),%xmm0
ucomisd %xmm1,%xmm0
jb     1216 <dtop3+0xf6>
sqrtsd %xmm0,%xmm0
jmp    121b <dtop3+0xfb>
cmpltsd (%rsp),%xmm1
movsd  0xdf8(%rip),%xmm0
andpd  %xmm1,%xmm0
jmp    122e <dtop3+0x10e>
call   1040 <sqrt@plt>
movsd  0x8(%rsp),%xmm1
call   1030 <atan2@plt>
mulsd  0xde2(%rip),%xmm0
movsd  %xmm0,(%r14)
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@dtop3.rtod = internal global double 0x404CA5DC1A63C1F8
define i32 @dtop3(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
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
%14 = load double, double* %7
%15 = load double, double* %7
%16 = load double, double* %8
%17 = load double, double* %8
%18 = fmul double %16, %17
%19 = call double @llvm.fmuladd.f64(double %14, double %15, double %18)
%20 = load double, double* %9
%21 = load double, double* %9
%22 = call double @llvm.fmuladd.f64(double %20, double %21, double %19)
%23 = call double @sqrt(double %22)
%24 = load double*, double** %10
store double %23, double* %24
%25 = load double, double* %7
%26 = fcmp une double %25, 0.000000e+00
br i1 %26, label %27, label %34
27: ; preds = %6
%28 = load double, double* %8
%29 = load double, double* %7
%30 = call double @atan2(double %28, double %29)
%31 = load double, double* @dtop3.rtod
%32 = fmul double %30, %31
%33 = load double*, double** %11
store double %32, double* %33
br label %48
34: ; preds = %6
%35 = load double, double* %8
%36 = fcmp olt double %35, 0.000000e+00
br i1 %36, label %37, label %39
37: ; preds = %34
%38 = load double*, double** %11
store double -9.000000e+01, double* %38
br label %47
39: ; preds = %34
%40 = load double, double* %8
%41 = fcmp ogt double %40, 0.000000e+00
br i1 %41, label %42, label %44
42: ; preds = %39
%43 = load double*, double** %11
store double 9.000000e+01, double* %43
br label %46
44: ; preds = %39
%45 = load double*, double** %11
store double 0.000000e+00, double* %45
br label %46
46: ; preds = %44, %42
br label %47
47: ; preds = %46, %37
br label %48
48: ; preds = %47, %27
%49 = load double, double* %7
%50 = load double, double* %7
%51 = load double, double* %8
%52 = load double, double* %8
%53 = fmul double %51, %52
%54 = call double @llvm.fmuladd.f64(double %49, double %50, double %53)
store double %54, double* %13
%55 = load double, double* %9
%56 = fcmp une double %55, 0.000000e+00
br i1 %56, label %57, label %65
57: ; preds = %48
%58 = load double, double* %13
%59 = call double @sqrt(double %58)
%60 = load double, double* %9
%61 = call double @atan2(double %59, double %60)
%62 = load double, double* @dtop3.rtod
%63 = fmul double %61, %62
%64 = load double*, double** %12
store double %63, double* %64
br label %79
65: ; preds = %48
%66 = load double, double* %13
%67 = fcmp olt double %66, 0.000000e+00
br i1 %67, label %68, label %70
68: ; preds = %65
%69 = load double*, double** %12
store double -9.000000e+01, double* %69
br label %78
70: ; preds = %65
%71 = load double, double* %13
%72 = fcmp ogt double %71, 0.000000e+00
br i1 %72, label %73, label %75
73: ; preds = %70
%74 = load double*, double** %12
store double 9.000000e+01, double* %74
br label %77
75: ; preds = %70
%76 = load double*, double** %12
store double 0.000000e+00, double* %76
br label %77
77: ; preds = %75, %73
br label %78
78: ; preds = %77, %68
br label %79
79: ; preds = %78, %57
ret i32 0
}

LLVM IR (-O2):
define i32 @dtop3(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 @llvm.fmuladd.f64(double %2, double %2, double %8)
%10 = tail call double @sqrt(double %9)
store double %10, double* %3
%11 = fcmp une double %0, 0.000000e+00
br i1 %11, label %12, label %15
12: ; preds = %6
%13 = tail call double @atan2(double %1, double %0)
%14 = fmul double %13, 0x404CA5DC1A63C1F8
br label %20
15: ; preds = %6
%16 = fcmp olt double %1, 0.000000e+00
br i1 %16, label %20, label %17
17: ; preds = %15
%18 = fcmp ogt double %1, 0.000000e+00
%19 = select i1 %18, double 9.000000e+01, double 0.000000e+00
br label %20
20: ; preds = %17, %15, %12
%21 = phi double [ %14, %12 ], [ -9.000000e+01, %15 ], [ %19, %17 ]
store double %21, double* %4
%22 = fcmp une double %2, 0.000000e+00
br i1 %22, label %23, label %27
23: ; preds = %20
%24 = tail call double @sqrt(double %8)
%25 = tail call double @atan2(double %24, double %2)
%26 = fmul double %25, 0x404CA5DC1A63C1F8
br label %30
27: ; preds = %20
%28 = fcmp ogt double %8, 0.000000e+00
%29 = select i1 %28, double 9.000000e+01, double 0.000000e+00
br label %30
30: ; preds = %27, %23
%31 = phi double [ %26, %23 ], [ %29, %27 ]
store double %31, double* %5
ret i32 0
}