#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 cosl(int /*<<< orphan*/);
int /*<<< orphan*/ rad(long double);
int sinl(int /*<<< orphan*/);
int _to_cart(long double *a, long double *A) {
  A[0] = 6371000. * cosl(rad(a[0])) * sinl(rad(a[1]));
  A[1] = 6371000. * cosl(rad(a[0])) * cosl(rad(a[1]));
  A[2] = 6371000. * sinl(rad(a[0]));
  return 1;
}


x86 assembly (clang, -O0):
<_to_cart>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rax
fldt   (%rax)
mov    %rsp,%rax
fstpt  (%rax)
call   1050 <rad@plt>
mov    %eax,%edi
call   1040 <cosl@plt>
cvtsi2sd %eax,%xmm0
movsd  0xe9d(%rip),%xmm1
movsd  %xmm1,-0x30(%rbp)
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
mov    -0x8(%rbp),%rax
fldt   0x10(%rax)
mov    %rsp,%rax
fstpt  (%rax)
call   1050 <rad@plt>
mov    %eax,%edi
call   1030 <sinl@plt>
movsd  -0x40(%rbp),%xmm0
cvtsi2sd %eax,%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
fldl   -0x18(%rbp)
mov    -0x10(%rbp),%rax
fstpt  (%rax)
mov    -0x8(%rbp),%rax
fldt   (%rax)
mov    %rsp,%rax
fstpt  (%rax)
call   1050 <rad@plt>
mov    %eax,%edi
call   1040 <cosl@plt>
movsd  -0x30(%rbp),%xmm1
cvtsi2sd %eax,%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
mov    -0x8(%rbp),%rax
fldt   0x10(%rax)
mov    %rsp,%rax
fstpt  (%rax)
call   1050 <rad@plt>
mov    %eax,%edi
call   1040 <cosl@plt>
movsd  -0x38(%rbp),%xmm0
cvtsi2sd %eax,%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
fldl   -0x20(%rbp)
mov    -0x10(%rbp),%rax
fstpt  0x10(%rax)
mov    -0x8(%rbp),%rax
fldt   (%rax)
mov    %rsp,%rax
fstpt  (%rax)
call   1050 <rad@plt>
mov    %eax,%edi
call   1030 <sinl@plt>
movsd  -0x30(%rbp),%xmm1
cvtsi2sd %eax,%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
fldl   -0x28(%rbp)
mov    -0x10(%rbp),%rax
fstpt  0x20(%rax)
mov    $0x1,%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_to_cart>:
push   %r14
push   %rbx
sub    $0x38,%rsp
mov    %rsi,%r14
mov    %rdi,%rbx
fldt   (%rdi)
fstpt  (%rsp)
call   1050 <rad@plt>
mov    %eax,%edi
call   1040 <cosl@plt>
cvtsi2sd %eax,%xmm0
mulsd  0xea6(%rip),%xmm0
movsd  %xmm0,0x18(%rsp)
fldt   0x10(%rbx)
fstpt  (%rsp)
call   1050 <rad@plt>
mov    %eax,%edi
call   1030 <sinl@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
mulsd  0x18(%rsp),%xmm0
movsd  %xmm0,0x30(%rsp)
fldl   0x30(%rsp)
fstpt  (%r14)
fldt   (%rbx)
fstpt  (%rsp)
call   1050 <rad@plt>
mov    %eax,%edi
call   1040 <cosl@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
mulsd  0xe54(%rip),%xmm0
movsd  %xmm0,0x18(%rsp)
fldt   0x10(%rbx)
fstpt  (%rsp)
call   1050 <rad@plt>
mov    %eax,%edi
call   1040 <cosl@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
mulsd  0x18(%rsp),%xmm0
movsd  %xmm0,0x28(%rsp)
fldl   0x28(%rsp)
fstpt  0x10(%r14)
fldt   (%rbx)
fstpt  (%rsp)
call   1050 <rad@plt>
mov    %eax,%edi
call   1030 <sinl@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
mulsd  0xe01(%rip),%xmm0
movsd  %xmm0,0x20(%rsp)
fldl   0x20(%rsp)
fstpt  0x20(%r14)
mov    $0x1,%eax
add    $0x38,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define i32 @_to_cart(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 = call i32 @rad(x86_fp80 %7)
%9 = call i32 @cosl(i32 %8)
%10 = sitofp i32 %9 to double
%11 = fmul double 6.371000e+06, %10
%12 = load x86_fp80*, x86_fp80** %3
%13 = getelementptr inbounds x86_fp80, x86_fp80* %12, i64 1
%14 = load x86_fp80, x86_fp80* %13
%15 = call i32 @rad(x86_fp80 %14)
%16 = call i32 @sinl(i32 %15)
%17 = sitofp i32 %16 to double
%18 = fmul double %11, %17
%19 = fpext double %18 to x86_fp80
%20 = load x86_fp80*, x86_fp80** %4
%21 = getelementptr inbounds x86_fp80, x86_fp80* %20, i64 0
store x86_fp80 %19, x86_fp80* %21
%22 = load x86_fp80*, x86_fp80** %3
%23 = getelementptr inbounds x86_fp80, x86_fp80* %22, i64 0
%24 = load x86_fp80, x86_fp80* %23
%25 = call i32 @rad(x86_fp80 %24)
%26 = call i32 @cosl(i32 %25)
%27 = sitofp i32 %26 to double
%28 = fmul double 6.371000e+06, %27
%29 = load x86_fp80*, x86_fp80** %3
%30 = getelementptr inbounds x86_fp80, x86_fp80* %29, i64 1
%31 = load x86_fp80, x86_fp80* %30
%32 = call i32 @rad(x86_fp80 %31)
%33 = call i32 @cosl(i32 %32)
%34 = sitofp i32 %33 to double
%35 = fmul double %28, %34
%36 = fpext double %35 to x86_fp80
%37 = load x86_fp80*, x86_fp80** %4
%38 = getelementptr inbounds x86_fp80, x86_fp80* %37, i64 1
store x86_fp80 %36, x86_fp80* %38
%39 = load x86_fp80*, x86_fp80** %3
%40 = getelementptr inbounds x86_fp80, x86_fp80* %39, i64 0
%41 = load x86_fp80, x86_fp80* %40
%42 = call i32 @rad(x86_fp80 %41)
%43 = call i32 @sinl(i32 %42)
%44 = sitofp i32 %43 to double
%45 = fmul double 6.371000e+06, %44
%46 = fpext double %45 to x86_fp80
%47 = load x86_fp80*, x86_fp80** %4
%48 = getelementptr inbounds x86_fp80, x86_fp80* %47, i64 2
store x86_fp80 %46, x86_fp80* %48
ret i32 1
}

LLVM IR (-O2):
define i32 @_to_cart(x86_fp80* nocapture %0, x86_fp80* nocapture writeonly %1) {
%3 = load x86_fp80, x86_fp80* %0
%4 = tail call i32 @rad(x86_fp80 %3)
%5 = tail call i32 @cosl(i32 %4)
%6 = sitofp i32 %5 to double
%7 = fmul double %6, 6.371000e+06
%8 = getelementptr inbounds x86_fp80, x86_fp80* %0, i64 1
%9 = load x86_fp80, x86_fp80* %8
%10 = tail call i32 @rad(x86_fp80 %9)
%11 = tail call i32 @sinl(i32 %10)
%12 = sitofp i32 %11 to double
%13 = fmul double %7, %12
%14 = fpext double %13 to x86_fp80
store x86_fp80 %14, x86_fp80* %1
%15 = load x86_fp80, x86_fp80* %0
%16 = tail call i32 @rad(x86_fp80 %15)
%17 = tail call i32 @cosl(i32 %16)
%18 = sitofp i32 %17 to double
%19 = fmul double %18, 6.371000e+06
%20 = load x86_fp80, x86_fp80* %8
%21 = tail call i32 @rad(x86_fp80 %20)
%22 = tail call i32 @cosl(i32 %21)
%23 = sitofp i32 %22 to double
%24 = fmul double %19, %23
%25 = fpext double %24 to x86_fp80
%26 = getelementptr inbounds x86_fp80, x86_fp80* %1, i64 1
store x86_fp80 %25, x86_fp80* %26
%27 = load x86_fp80, x86_fp80* %0
%28 = tail call i32 @rad(x86_fp80 %27)
%29 = tail call i32 @sinl(i32 %28)
%30 = sitofp i32 %29 to double
%31 = fmul double %30, 6.371000e+06
%32 = fpext double %31 to x86_fp80
%33 = getelementptr inbounds x86_fp80, x86_fp80* %1, i64 2
store x86_fp80 %32, x86_fp80* %33
ret i32 1
}