#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 const cos(double);
double const sin(double);
int amsp_coord_spheric2rect(double out[3], double const r[3]) {
  out[0] = r[2] * sin(out[0]) * cos(out[1]);
  out[0] = r[2] * sin(out[0]) * sin(out[1]);
  out[0] = r[2] * cos(out[0]);
  return 0;
}


x86 assembly (clang, -O0):
<amsp_coord_spheric2rect>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
movsd  0x10(%rax),%xmm0
movsd  %xmm0,-0x38(%rbp)
mov    -0x8(%rbp),%rax
movsd  (%rax),%xmm0
call   1030 <sin@plt>
movaps %xmm0,%xmm1
movsd  -0x38(%rbp),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
mov    -0x8(%rbp),%rax
movsd  0x8(%rax),%xmm0
call   1040 <cos@plt>
movaps %xmm0,%xmm1
movsd  -0x30(%rbp),%xmm0
mulsd  %xmm1,%xmm0
mov    -0x8(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0x10(%rbp),%rax
movsd  0x10(%rax),%xmm0
movsd  %xmm0,-0x28(%rbp)
mov    -0x8(%rbp),%rax
movsd  (%rax),%xmm0
call   1030 <sin@plt>
movaps %xmm0,%xmm1
movsd  -0x28(%rbp),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    -0x8(%rbp),%rax
movsd  0x8(%rax),%xmm0
call   1030 <sin@plt>
movaps %xmm0,%xmm1
movsd  -0x20(%rbp),%xmm0
mulsd  %xmm1,%xmm0
mov    -0x8(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0x10(%rbp),%rax
movsd  0x10(%rax),%xmm0
movsd  %xmm0,-0x18(%rbp)
mov    -0x8(%rbp),%rax
movsd  (%rax),%xmm0
call   1040 <cos@plt>
movaps %xmm0,%xmm1
movsd  -0x18(%rbp),%xmm0
mulsd  %xmm1,%xmm0
mov    -0x8(%rbp),%rax
movsd  %xmm0,(%rax)
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<amsp_coord_spheric2rect>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
movsd  0x10(%rsi),%xmm0
movsd  %xmm0,(%rsp)
movsd  (%rdi),%xmm0
call   1030 <sin@plt>
mulsd  (%rsp),%xmm0
movsd  %xmm0,(%rsp)
movsd  0x8(%rbx),%xmm0
call   1040 <cos@plt>
mulsd  (%rsp),%xmm0
movsd  %xmm0,(%rbx)
movsd  0x10(%r14),%xmm1
movsd  %xmm1,(%rsp)
call   1030 <sin@plt>
mulsd  (%rsp),%xmm0
movsd  %xmm0,(%rsp)
movsd  0x8(%rbx),%xmm0
call   1030 <sin@plt>
mulsd  (%rsp),%xmm0
movsd  %xmm0,(%rbx)
movsd  0x10(%r14),%xmm1
movsd  %xmm1,(%rsp)
call   1040 <cos@plt>
mulsd  (%rsp),%xmm0
movsd  %xmm0,(%rbx)
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define i32 @amsp_coord_spheric2rect(double* %0, double* %1) {
%3 = alloca double*
%4 = alloca double*
store double* %0, double** %3
store double* %1, double** %4
%5 = load double*, double** %4
%6 = getelementptr inbounds double, double* %5, i64 2
%7 = load double, double* %6
%8 = load double*, double** %3
%9 = getelementptr inbounds double, double* %8, i64 0
%10 = load double, double* %9
%11 = call double @sin(double %10)
%12 = fmul double %7, %11
%13 = load double*, double** %3
%14 = getelementptr inbounds double, double* %13, i64 1
%15 = load double, double* %14
%16 = call double @cos(double %15)
%17 = fmul double %12, %16
%18 = load double*, double** %3
%19 = getelementptr inbounds double, double* %18, i64 0
store double %17, double* %19
%20 = load double*, double** %4
%21 = getelementptr inbounds double, double* %20, i64 2
%22 = load double, double* %21
%23 = load double*, double** %3
%24 = getelementptr inbounds double, double* %23, i64 0
%25 = load double, double* %24
%26 = call double @sin(double %25)
%27 = fmul double %22, %26
%28 = load double*, double** %3
%29 = getelementptr inbounds double, double* %28, i64 1
%30 = load double, double* %29
%31 = call double @sin(double %30)
%32 = fmul double %27, %31
%33 = load double*, double** %3
%34 = getelementptr inbounds double, double* %33, i64 0
store double %32, double* %34
%35 = load double*, double** %4
%36 = getelementptr inbounds double, double* %35, i64 2
%37 = load double, double* %36
%38 = load double*, double** %3
%39 = getelementptr inbounds double, double* %38, i64 0
%40 = load double, double* %39
%41 = call double @cos(double %40)
%42 = fmul double %37, %41
%43 = load double*, double** %3
%44 = getelementptr inbounds double, double* %43, i64 0
store double %42, double* %44
ret i32 0
}

LLVM IR (-O2):
define i32 @amsp_coord_spheric2rect(double* nocapture %0, double* nocapture %1) {
%3 = getelementptr inbounds double, double* %1, i64 2
%4 = load double, double* %3
%5 = load double, double* %0
%6 = tail call double @sin(double %5)
%7 = fmul double %4, %6
%8 = getelementptr inbounds double, double* %0, i64 1
%9 = load double, double* %8
%10 = tail call double @cos(double %9)
%11 = fmul double %7, %10
store double %11, double* %0
%12 = load double, double* %3
%13 = tail call double @sin(double %11)
%14 = fmul double %12, %13
%15 = load double, double* %8
%16 = tail call double @sin(double %15)
%17 = fmul double %14, %16
store double %17, double* %0
%18 = load double, double* %3
%19 = tail call double @cos(double %17)
%20 = fmul double %18, %19
store double %20, double* %0
ret i32 0
}