#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 cos(double);
double sin(double);
void point_pos(double *cur_point, double *next_point, double theta, double thi,
               double p_len) {
  next_point[0] = p_len * cos(theta) * sin(thi) + cur_point[0];
  next_point[1] = p_len * sin(theta) * sin(thi) + cur_point[1];
  next_point[2] = p_len * cos(thi) + cur_point[2];
}


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

x86 assembly (clang, -O2):
<point_pos>:
push   %r14
push   %rbx
sub    $0x28,%rsp
movsd  %xmm2,0x18(%rsp)
movsd  %xmm1,0x10(%rsp)
movsd  %xmm0,0x8(%rsp)
mov    %rsi,%r14
mov    %rdi,%rbx
call   1040 <cos@plt>
mulsd  0x18(%rsp),%xmm0
movsd  %xmm0,0x20(%rsp)
movsd  0x10(%rsp),%xmm0
call   1030 <sin@plt>
mulsd  0x20(%rsp),%xmm0
addsd  (%rbx),%xmm0
movsd  %xmm0,(%r14)
movsd  0x8(%rsp),%xmm0
call   1030 <sin@plt>
mulsd  0x18(%rsp),%xmm0
movsd  %xmm0,0x8(%rsp)
movsd  0x10(%rsp),%xmm0
call   1030 <sin@plt>
mulsd  0x8(%rsp),%xmm0
addsd  0x8(%rbx),%xmm0
movsd  %xmm0,0x8(%r14)
movsd  0x10(%rsp),%xmm0
call   1040 <cos@plt>
mulsd  0x18(%rsp),%xmm0
addsd  0x10(%rbx),%xmm0
movsd  %xmm0,0x10(%r14)
add    $0x28,%rsp
pop    %rbx
pop    %r14
ret

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

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