#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 asin(double);
double atan2(double, double);
double sqrt(double);
int scoord_(double *px, double *py, double *pz, double *plat, double *plon,
            double *pnrm) {
  *pnrm = sqrt(*px * *px + *py * *py + *pz * *pz);
  if (*px != 0. || *py != 0.) {
    *plon = atan2(*py, *px);
  } else {
    *plon = 0.;
  }
  if (*pnrm != 0.) {
    *plat = asin(*pz / *pnrm);
  } else {
    *plat = 0.;
  }
  return 0;
}


x86 assembly (clang, -O0):
<scoord_>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    %r9,-0x30(%rbp)
mov    -0x8(%rbp),%rax
movsd  (%rax),%xmm1
mov    -0x8(%rbp),%rax
movsd  (%rax),%xmm2
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm0
mov    -0x10(%rbp),%rax
mulsd  (%rax),%xmm0
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
mov    -0x18(%rbp),%rax
movsd  (%rax),%xmm0
mov    -0x18(%rbp),%rax
movsd  (%rax),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
call   1050 <sqrt@plt>
mov    -0x30(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0x8(%rbp),%rax
movsd  (%rax),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    11d8 <scoord_+0xa8>
jp     11d8 <scoord_+0xa8>
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    11d8 <scoord_+0xa8>
jp     11d8 <scoord_+0xa8>
jmp    11fa <scoord_+0xca>
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm0
mov    -0x8(%rbp),%rax
movsd  (%rax),%xmm1
call   1030 <atan2@plt>
mov    -0x28(%rbp),%rax
movsd  %xmm0,(%rax)
jmp    1205 <scoord_+0xd5>
mov    -0x28(%rbp),%rax
xorps  %xmm0,%xmm0
movsd  %xmm0,(%rax)
mov    -0x30(%rbp),%rax
movsd  (%rax),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    1225 <scoord_+0xf5>
jp     1225 <scoord_+0xf5>
jmp    1247 <scoord_+0x117>
mov    -0x18(%rbp),%rax
movsd  (%rax),%xmm0
mov    -0x30(%rbp),%rax
divsd  (%rax),%xmm0
call   1040 <asin@plt>
mov    -0x20(%rbp),%rax
movsd  %xmm0,(%rax)
jmp    1252 <scoord_+0x122>
mov    -0x20(%rbp),%rax
xorps  %xmm0,%xmm0
movsd  %xmm0,(%rax)
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<scoord_>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %r9,%r13
mov    %r8,%r12
mov    %rcx,%r14
mov    %rdx,%r15
mov    %rsi,%rbx
mov    %rdi,%rbp
movsd  (%rdi),%xmm1
movsd  (%rsi),%xmm0
mulsd  %xmm0,%xmm0
mulsd  %xmm1,%xmm1
addsd  %xmm0,%xmm1
movsd  (%rdx),%xmm0
mulsd  %xmm0,%xmm0
addsd  %xmm1,%xmm0
xorpd  %xmm3,%xmm3
ucomisd %xmm3,%xmm0
jb     117d <scoord_+0x4d>
sqrtsd %xmm0,%xmm0
jmp    1186 <scoord_+0x56>
call   1050 <sqrt@plt>
xorpd  %xmm3,%xmm3
movsd  %xmm0,0x0(%r13)
movsd  0x0(%rbp),%xmm1
ucomisd %xmm3,%xmm1
movsd  (%rbx),%xmm0
jne    11a9 <scoord_+0x79>
jp     11a9 <scoord_+0x79>
xorpd  %xmm2,%xmm2
ucomisd %xmm2,%xmm0
jne    11a9 <scoord_+0x79>
jnp    11b2 <scoord_+0x82>
call   1030 <atan2@plt>
movapd %xmm0,%xmm3
movsd  %xmm3,(%r12)
movsd  0x0(%r13),%xmm1
xorpd  %xmm0,%xmm0
ucomisd %xmm0,%xmm1
jne    11ca <scoord_+0x9a>
jnp    11d8 <scoord_+0xa8>
movsd  (%r15),%xmm0
divsd  %xmm1,%xmm0
call   1040 <asin@plt>
movsd  %xmm0,(%r14)
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @scoord_(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* %13
%15 = load double*, double** %7
%16 = load double, double* %15
%17 = load double*, double** %8
%18 = load double, double* %17
%19 = load double*, double** %8
%20 = load double, double* %19
%21 = fmul double %18, %20
%22 = call double @llvm.fmuladd.f64(double %14, double %16, double %21)
%23 = load double*, double** %9
%24 = load double, double* %23
%25 = load double*, double** %9
%26 = load double, double* %25
%27 = call double @llvm.fmuladd.f64(double %24, double %26, double %22)
%28 = call double @sqrt(double %27)
%29 = load double*, double** %12
store double %28, double* %29
%30 = load double*, double** %7
%31 = load double, double* %30
%32 = fcmp une double %31, 0.000000e+00
br i1 %32, label %37, label %33
33: ; preds = %6
%34 = load double*, double** %8
%35 = load double, double* %34
%36 = fcmp une double %35, 0.000000e+00
br i1 %36, label %37, label %44
37: ; preds = %33, %6
%38 = load double*, double** %8
%39 = load double, double* %38
%40 = load double*, double** %7
%41 = load double, double* %40
%42 = call double @atan2(double %39, double %41)
%43 = load double*, double** %11
store double %42, double* %43
br label %46
44: ; preds = %33
%45 = load double*, double** %11
store double 0.000000e+00, double* %45
br label %46
46: ; preds = %44, %37
%47 = load double*, double** %12
%48 = load double, double* %47
%49 = fcmp une double %48, 0.000000e+00
br i1 %49, label %50, label %58
50: ; preds = %46
%51 = load double*, double** %9
%52 = load double, double* %51
%53 = load double*, double** %12
%54 = load double, double* %53
%55 = fdiv double %52, %54
%56 = call double @asin(double %55)
%57 = load double*, double** %10
store double %56, double* %57
br label %60
58: ; preds = %46
%59 = load double*, double** %10
store double 0.000000e+00, double* %59
br label %60
60: ; preds = %58, %50
ret i32 0
}

LLVM IR (-O2):
define i32 @scoord_(double* nocapture %0, double* nocapture %1, double* nocapture %2, double* nocapture writeonly %3, double* nocapture writeonly %4, double* nocapture %5) {
%7 = load double, double* %0
%8 = load double, double* %1
%9 = fmul double %8, %8
%10 = tail call double @llvm.fmuladd.f64(double %7, double %7, double %9)
%11 = load double, double* %2
%12 = tail call double @llvm.fmuladd.f64(double %11, double %11, double %10)
%13 = tail call double @sqrt(double %12)
store double %13, double* %5
%14 = load double, double* %0
%15 = fcmp une double %14, 0.000000e+00
%16 = load double, double* %1
%17 = fcmp une double %16, 0.000000e+00
%18 = select i1 %15, i1 true, i1 %17
br i1 %18, label %19, label %21
19: ; preds = %6
%20 = tail call double @atan2(double %16, double %14)
br label %21
21: ; preds = %6, %19
%22 = phi double [ %20, %19 ], [ 0.000000e+00, %6 ]
store double %22, double* %4
%23 = load double, double* %5
%24 = fcmp une double %23, 0.000000e+00
br i1 %24, label %25, label %29
25: ; preds = %21
%26 = load double, double* %2
%27 = fdiv double %26, %23
%28 = tail call double @asin(double %27)
br label %29
29: ; preds = %21, %25
%30 = phi double [ %28, %25 ], [ 0.000000e+00, %21 ]
store double %30, double* %3
ret i32 0
}