#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 */
int /*<<< orphan*/ asin(long double);
int /*<<< orphan*/ atan2l(long double, long double);
long double deg(int /*<<< orphan*/);
int _to_sphere(long double *x, long double *y) {
  y[1] = deg(atan2l(x[0], x[1]));
  y[0] = deg(asin(x[2] / 6371000.));
  return 1;
}


x86 assembly (clang, -O0):
<_to_sphere>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rax
fldt   (%rax)
fldt   0x10(%rax)
mov    %rsp,%rax
fstpt  0x10(%rax)
fstpt  (%rax)
call   1050 <atan2l@plt>
mov    %eax,%edi
call   1030 <deg@plt>
mov    -0x10(%rbp),%rax
fstpt  0x10(%rax)
mov    -0x8(%rbp),%rax
fldt   0x20(%rax)
flds   0xe8f(%rip)
fdivrp %st,%st(1)
mov    %rsp,%rax
fstpt  (%rax)
call   1040 <asin@plt>
mov    %eax,%edi
call   1030 <deg@plt>
mov    -0x10(%rbp),%rax
fstpt  (%rax)
mov    $0x1,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_to_sphere>:
push   %r14
push   %rbx
sub    $0x28,%rsp
mov    %rsi,%r14
mov    %rdi,%rbx
fldt   (%rdi)
fldt   0x10(%rdi)
fstpt  0x10(%rsp)
fstpt  (%rsp)
call   1050 <atan2l@plt>
mov    %eax,%edi
call   1030 <deg@plt>
fstpt  0x10(%r14)
fldt   0x20(%rbx)
fdivs  0xe9e(%rip)
fstpt  (%rsp)
call   1040 <asin@plt>
mov    %eax,%edi
call   1030 <deg@plt>
fstpt  (%r14)
mov    $0x1,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define i32 @_to_sphere(x86_fp80* %0, x86_fp80* %1) {
%3 = alloca x86_fp80*
%4 = alloca x86_fp80*
store x86_fp80* %0, x86_fp80** %3
store x86_fp80* %1, x86_fp80** %4
%5 = load x86_fp80*, x86_fp80** %3
%6 = getelementptr inbounds x86_fp80, x86_fp80* %5, i64 0
%7 = load x86_fp80, x86_fp80* %6
%8 = load x86_fp80*, x86_fp80** %3
%9 = getelementptr inbounds x86_fp80, x86_fp80* %8, i64 1
%10 = load x86_fp80, x86_fp80* %9
%11 = call i32 @atan2l(x86_fp80 %7, x86_fp80 %10)
%12 = call x86_fp80 @deg(i32 %11)
%13 = load x86_fp80*, x86_fp80** %4
%14 = getelementptr inbounds x86_fp80, x86_fp80* %13, i64 1
store x86_fp80 %12, x86_fp80* %14
%15 = load x86_fp80*, x86_fp80** %3
%16 = getelementptr inbounds x86_fp80, x86_fp80* %15, i64 2
%17 = load x86_fp80, x86_fp80* %16
%18 = fdiv x86_fp80 %17, 0xK4015C26D700000000000
%19 = call i32 @asin(x86_fp80 %18)
%20 = call x86_fp80 @deg(i32 %19)
%21 = load x86_fp80*, x86_fp80** %4
%22 = getelementptr inbounds x86_fp80, x86_fp80* %21, i64 0
store x86_fp80 %20, x86_fp80* %22
ret i32 1
}

LLVM IR (-O2):
define i32 @_to_sphere(x86_fp80* nocapture %0, x86_fp80* nocapture writeonly %1) {
%3 = load x86_fp80, x86_fp80* %0
%4 = getelementptr inbounds x86_fp80, x86_fp80* %0, i64 1
%5 = load x86_fp80, x86_fp80* %4
%6 = tail call i32 @atan2l(x86_fp80 %3, x86_fp80 %5)
%7 = tail call x86_fp80 @deg(i32 %6)
%8 = getelementptr inbounds x86_fp80, x86_fp80* %1, i64 1
store x86_fp80 %7, x86_fp80* %8
%9 = getelementptr inbounds x86_fp80, x86_fp80* %0, i64 2
%10 = load x86_fp80, x86_fp80* %9
%11 = fdiv x86_fp80 %10, 0xK4015C26D700000000000
%12 = tail call i32 @asin(x86_fp80 %11)
%13 = tail call x86_fp80 @deg(i32 %12)
store x86_fp80 %13, x86_fp80* %1
ret i32 1
}