#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 langtomat(double *r, double ta, double pa, double sa) {
  r[0] = sin(pa) * sin(sa) * sin(ta) + cos(sa) * cos(ta);
  r[1] = sin(pa) * sin(sa) * cos(ta) - cos(sa) * sin(ta);
  r[2] = cos(pa) * sin(sa);
  r[3] = cos(pa) * sin(ta);
  r[4] = cos(pa) * cos(ta);
  r[5] = -sin(pa);
  r[6] = sin(pa) * cos(sa) * sin(ta) - sin(sa) * cos(ta);
  r[7] = sin(pa) * cos(sa) * cos(ta) + sin(sa) * sin(ta);
  r[8] = cos(pa) * cos(sa);
}


x86 assembly (clang, -O0):
<langtomat>:
push   %rbp
mov    %rsp,%rbp
sub    $0xc0,%rsp
mov    %rdi,-0x8(%rbp)
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
movsd  %xmm2,-0x20(%rbp)
movsd  -0x18(%rbp),%xmm0
call   1030 <sin@plt>
movsd  %xmm0,-0xc0(%rbp)
ff
movsd  -0x20(%rbp),%xmm0
call   1030 <sin@plt>
movaps %xmm0,%xmm1
movsd  -0xc0(%rbp),%xmm0
ff
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0xa8(%rbp)
ff
movsd  -0x10(%rbp),%xmm0
call   1030 <sin@plt>
movsd  %xmm0,-0xb0(%rbp)
ff
movsd  -0x20(%rbp),%xmm0
call   1040 <cos@plt>
movsd  %xmm0,-0xb8(%rbp)
ff
movsd  -0x10(%rbp),%xmm0
call   1040 <cos@plt>
movsd  -0xb8(%rbp),%xmm1
ff
movsd  -0xb0(%rbp),%xmm2
ff
movaps %xmm0,%xmm3
movsd  -0xa8(%rbp),%xmm0
ff
mulsd  %xmm3,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x8(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x18(%rbp),%xmm0
call   1030 <sin@plt>
movsd  %xmm0,-0xa0(%rbp)
ff
movsd  -0x20(%rbp),%xmm0
call   1030 <sin@plt>
movaps %xmm0,%xmm1
movsd  -0xa0(%rbp),%xmm0
ff
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x88(%rbp)
movsd  -0x10(%rbp),%xmm0
call   1040 <cos@plt>
movsd  %xmm0,-0x90(%rbp)
ff
movsd  -0x20(%rbp),%xmm0
call   1040 <cos@plt>
movsd  %xmm0,-0x98(%rbp)
ff
movsd  -0x10(%rbp),%xmm0
call   1030 <sin@plt>
movsd  -0x98(%rbp),%xmm1
ff
movsd  -0x90(%rbp),%xmm2
ff
movaps %xmm0,%xmm3
movsd  -0x88(%rbp),%xmm0
ff
mulsd  %xmm3,%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x8(%rbp),%rax
movsd  %xmm0,0x8(%rax)
movsd  -0x18(%rbp),%xmm0
call   1040 <cos@plt>
movsd  %xmm0,-0x80(%rbp)
movsd  -0x20(%rbp),%xmm0
call   1030 <sin@plt>
movaps %xmm0,%xmm1
movsd  -0x80(%rbp),%xmm0
mulsd  %xmm1,%xmm0
mov    -0x8(%rbp),%rax
movsd  %xmm0,0x10(%rax)
movsd  -0x18(%rbp),%xmm0
call   1040 <cos@plt>
movsd  %xmm0,-0x78(%rbp)
movsd  -0x10(%rbp),%xmm0
call   1030 <sin@plt>
movaps %xmm0,%xmm1
movsd  -0x78(%rbp),%xmm0
mulsd  %xmm1,%xmm0
mov    -0x8(%rbp),%rax
movsd  %xmm0,0x18(%rax)
movsd  -0x18(%rbp),%xmm0
call   1040 <cos@plt>
movsd  %xmm0,-0x70(%rbp)
movsd  -0x10(%rbp),%xmm0
call   1040 <cos@plt>
movaps %xmm0,%xmm1
movsd  -0x70(%rbp),%xmm0
mulsd  %xmm1,%xmm0
mov    -0x8(%rbp),%rax
movsd  %xmm0,0x20(%rax)
movsd  -0x18(%rbp),%xmm0
call   1030 <sin@plt>
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mov    -0x8(%rbp),%rax
movsd  %xmm0,0x28(%rax)
movsd  -0x18(%rbp),%xmm0
call   1030 <sin@plt>
movsd  %xmm0,-0x68(%rbp)
movsd  -0x20(%rbp),%xmm0
call   1040 <cos@plt>
movaps %xmm0,%xmm1
movsd  -0x68(%rbp),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x10(%rbp),%xmm0
call   1030 <sin@plt>
movsd  %xmm0,-0x58(%rbp)
movsd  -0x20(%rbp),%xmm0
call   1030 <sin@plt>
movsd  %xmm0,-0x60(%rbp)
movsd  -0x10(%rbp),%xmm0
call   1040 <cos@plt>
movsd  -0x60(%rbp),%xmm1
movsd  -0x58(%rbp),%xmm2
movaps %xmm0,%xmm3
movsd  -0x50(%rbp),%xmm0
mulsd  %xmm3,%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x8(%rbp),%rax
movsd  %xmm0,0x30(%rax)
movsd  -0x18(%rbp),%xmm0
call   1030 <sin@plt>
movsd  %xmm0,-0x48(%rbp)
movsd  -0x20(%rbp),%xmm0
call   1040 <cos@plt>
movaps %xmm0,%xmm1
movsd  -0x48(%rbp),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x10(%rbp),%xmm0
call   1040 <cos@plt>
movsd  %xmm0,-0x38(%rbp)
movsd  -0x20(%rbp),%xmm0
call   1030 <sin@plt>
movsd  %xmm0,-0x40(%rbp)
movsd  -0x10(%rbp),%xmm0
call   1030 <sin@plt>
movsd  -0x40(%rbp),%xmm1
movsd  -0x38(%rbp),%xmm2
movaps %xmm0,%xmm3
movsd  -0x30(%rbp),%xmm0
mulsd  %xmm3,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x8(%rbp),%rax
movsd  %xmm0,0x38(%rax)
movsd  -0x18(%rbp),%xmm0
call   1040 <cos@plt>
movsd  %xmm0,-0x28(%rbp)
movsd  -0x20(%rbp),%xmm0
call   1040 <cos@plt>
movaps %xmm0,%xmm1
movsd  -0x28(%rbp),%xmm0
mulsd  %xmm1,%xmm0
mov    -0x8(%rbp),%rax
movsd  %xmm0,0x40(%rax)
add    $0xc0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<langtomat>:
push   %rbx
sub    $0x30,%rsp
movsd  %xmm2,0x10(%rsp)
movsd  %xmm1,0x18(%rsp)
movsd  %xmm0,0x8(%rsp)
mov    %rdi,%rbx
movaps %xmm1,%xmm0
call   1030 <sin@plt>
movsd  %xmm0,(%rsp)
movsd  0x10(%rsp),%xmm0
call   1030 <sin@plt>
mulsd  (%rsp),%xmm0
movsd  %xmm0,(%rsp)
movsd  0x8(%rsp),%xmm0
call   1030 <sin@plt>
movsd  %xmm0,0x28(%rsp)
movsd  0x10(%rsp),%xmm0
call   1040 <cos@plt>
movsd  %xmm0,0x20(%rsp)
movsd  0x8(%rsp),%xmm0
call   1040 <cos@plt>
mulsd  0x20(%rsp),%xmm0
movsd  0x28(%rsp),%xmm1
mulsd  (%rsp),%xmm1
addsd  %xmm0,%xmm1
movsd  %xmm1,(%rbx)
movsd  0x18(%rsp),%xmm0
call   1030 <sin@plt>
movsd  %xmm0,(%rsp)
movsd  0x10(%rsp),%xmm0
call   1030 <sin@plt>
mulsd  (%rsp),%xmm0
movsd  %xmm0,(%rsp)
movsd  0x8(%rsp),%xmm0
call   1040 <cos@plt>
movsd  %xmm0,0x28(%rsp)
movsd  0x10(%rsp),%xmm0
call   1040 <cos@plt>
movsd  %xmm0,0x20(%rsp)
movsd  0x8(%rsp),%xmm0
call   1030 <sin@plt>
mulsd  0x20(%rsp),%xmm0
movsd  0x28(%rsp),%xmm1
mulsd  (%rsp),%xmm1
subsd  %xmm0,%xmm1
movsd  %xmm1,0x8(%rbx)
movsd  0x18(%rsp),%xmm0
call   1040 <cos@plt>
movsd  %xmm0,(%rsp)
movsd  0x10(%rsp),%xmm0
call   1030 <sin@plt>
mulsd  (%rsp),%xmm0
movsd  %xmm0,0x10(%rbx)
movsd  0x18(%rsp),%xmm0
call   1040 <cos@plt>
movsd  %xmm0,(%rsp)
movsd  0x8(%rsp),%xmm0
call   1030 <sin@plt>
mulsd  (%rsp),%xmm0
movsd  %xmm0,0x18(%rbx)
movsd  0x18(%rsp),%xmm0
call   1040 <cos@plt>
movsd  %xmm0,(%rsp)
movsd  0x8(%rsp),%xmm0
call   1040 <cos@plt>
mulsd  (%rsp),%xmm0
movsd  %xmm0,0x20(%rbx)
movsd  0x18(%rsp),%xmm0
call   1030 <sin@plt>
xorps  0xd71(%rip),%xmm0
movlps %xmm0,0x28(%rbx)
movsd  0x18(%rsp),%xmm0
call   1030 <sin@plt>
movsd  %xmm0,(%rsp)
movsd  0x10(%rsp),%xmm0
call   1040 <cos@plt>
mulsd  (%rsp),%xmm0
movsd  %xmm0,(%rsp)
movsd  0x8(%rsp),%xmm0
call   1030 <sin@plt>
movsd  %xmm0,0x28(%rsp)
movsd  0x10(%rsp),%xmm0
call   1030 <sin@plt>
movsd  %xmm0,0x20(%rsp)
movsd  0x8(%rsp),%xmm0
call   1040 <cos@plt>
mulsd  0x20(%rsp),%xmm0
movsd  0x28(%rsp),%xmm1
mulsd  (%rsp),%xmm1
subsd  %xmm0,%xmm1
movsd  %xmm1,0x30(%rbx)
movsd  0x18(%rsp),%xmm0
call   1030 <sin@plt>
movsd  %xmm0,(%rsp)
movsd  0x10(%rsp),%xmm0
call   1040 <cos@plt>
mulsd  (%rsp),%xmm0
movsd  %xmm0,(%rsp)
movsd  0x8(%rsp),%xmm0
call   1040 <cos@plt>
movsd  %xmm0,0x28(%rsp)
movsd  0x10(%rsp),%xmm0
call   1030 <sin@plt>
movsd  %xmm0,0x20(%rsp)
movsd  0x8(%rsp),%xmm0
call   1030 <sin@plt>
mulsd  0x20(%rsp),%xmm0
movsd  0x28(%rsp),%xmm1
mulsd  (%rsp),%xmm1
addsd  %xmm0,%xmm1
movsd  %xmm1,0x38(%rbx)
movsd  0x18(%rsp),%xmm0
call   1040 <cos@plt>
movsd  %xmm0,0x8(%rsp)
movsd  0x10(%rsp),%xmm0
call   1040 <cos@plt>
mulsd  0x8(%rsp),%xmm0
movsd  %xmm0,0x40(%rbx)
add    $0x30,%rsp
pop    %rbx
ret

LLVM IR (-O0):
define void @langtomat(double* %0, double %1, double %2, double %3) {
%5 = alloca double*
%6 = alloca double
%7 = alloca double
%8 = alloca double
store double* %0, double** %5
store double %1, double* %6
store double %2, double* %7
store double %3, double* %8
%9 = load double, double* %7
%10 = call double @sin(double %9)
%11 = load double, double* %8
%12 = call double @sin(double %11)
%13 = fmul double %10, %12
%14 = load double, double* %6
%15 = call double @sin(double %14)
%16 = load double, double* %8
%17 = call double @cos(double %16)
%18 = load double, double* %6
%19 = call double @cos(double %18)
%20 = fmul double %17, %19
%21 = call double @llvm.fmuladd.f64(double %13, double %15, double %20)
%22 = load double*, double** %5
%23 = getelementptr inbounds double, double* %22, i64 0
store double %21, double* %23
%24 = load double, double* %7
%25 = call double @sin(double %24)
%26 = load double, double* %8
%27 = call double @sin(double %26)
%28 = fmul double %25, %27
%29 = load double, double* %6
%30 = call double @cos(double %29)
%31 = load double, double* %8
%32 = call double @cos(double %31)
%33 = load double, double* %6
%34 = call double @sin(double %33)
%35 = fmul double %32, %34
%36 = fneg double %35
%37 = call double @llvm.fmuladd.f64(double %28, double %30, double %36)
%38 = load double*, double** %5
%39 = getelementptr inbounds double, double* %38, i64 1
store double %37, double* %39
%40 = load double, double* %7
%41 = call double @cos(double %40)
%42 = load double, double* %8
%43 = call double @sin(double %42)
%44 = fmul double %41, %43
%45 = load double*, double** %5
%46 = getelementptr inbounds double, double* %45, i64 2
store double %44, double* %46
%47 = load double, double* %7
%48 = call double @cos(double %47)
%49 = load double, double* %6
%50 = call double @sin(double %49)
%51 = fmul double %48, %50
%52 = load double*, double** %5
%53 = getelementptr inbounds double, double* %52, i64 3
store double %51, double* %53
%54 = load double, double* %7
%55 = call double @cos(double %54)
%56 = load double, double* %6
%57 = call double @cos(double %56)
%58 = fmul double %55, %57
%59 = load double*, double** %5
%60 = getelementptr inbounds double, double* %59, i64 4
store double %58, double* %60
%61 = load double, double* %7
%62 = call double @sin(double %61)
%63 = fneg double %62
%64 = load double*, double** %5
%65 = getelementptr inbounds double, double* %64, i64 5
store double %63, double* %65
%66 = load double, double* %7
%67 = call double @sin(double %66)
%68 = load double, double* %8
%69 = call double @cos(double %68)
%70 = fmul double %67, %69
%71 = load double, double* %6
%72 = call double @sin(double %71)
%73 = load double, double* %8
%74 = call double @sin(double %73)
%75 = load double, double* %6
%76 = call double @cos(double %75)
%77 = fmul double %74, %76
%78 = fneg double %77
%79 = call double @llvm.fmuladd.f64(double %70, double %72, double %78)
%80 = load double*, double** %5
%81 = getelementptr inbounds double, double* %80, i64 6
store double %79, double* %81
%82 = load double, double* %7
%83 = call double @sin(double %82)
%84 = load double, double* %8
%85 = call double @cos(double %84)
%86 = fmul double %83, %85
%87 = load double, double* %6
%88 = call double @cos(double %87)
%89 = load double, double* %8
%90 = call double @sin(double %89)
%91 = load double, double* %6
%92 = call double @sin(double %91)
%93 = fmul double %90, %92
%94 = call double @llvm.fmuladd.f64(double %86, double %88, double %93)
%95 = load double*, double** %5
%96 = getelementptr inbounds double, double* %95, i64 7
store double %94, double* %96
%97 = load double, double* %7
%98 = call double @cos(double %97)
%99 = load double, double* %8
%100 = call double @cos(double %99)
%101 = fmul double %98, %100
%102 = load double*, double** %5
%103 = getelementptr inbounds double, double* %102, i64 8
store double %101, double* %103
ret void
}

LLVM IR (-O2):
define void @langtomat(double* nocapture writeonly %0, double %1, double %2, double %3) {
%5 = tail call double @sin(double %2)
%6 = tail call double @sin(double %3)
%7 = fmul double %5, %6
%8 = tail call double @sin(double %1)
%9 = tail call double @cos(double %3)
%10 = tail call double @cos(double %1)
%11 = fmul double %9, %10
%12 = tail call double @llvm.fmuladd.f64(double %7, double %8, double %11)
store double %12, double* %0
%13 = tail call double @sin(double %2)
%14 = tail call double @sin(double %3)
%15 = fmul double %13, %14
%16 = tail call double @cos(double %1)
%17 = tail call double @cos(double %3)
%18 = tail call double @sin(double %1)
%19 = fneg double %17
%20 = fmul double %18, %19
%21 = tail call double @llvm.fmuladd.f64(double %15, double %16, double %20)
%22 = getelementptr inbounds double, double* %0, i64 1
store double %21, double* %22
%23 = tail call double @cos(double %2)
%24 = tail call double @sin(double %3)
%25 = fmul double %23, %24
%26 = getelementptr inbounds double, double* %0, i64 2
store double %25, double* %26
%27 = tail call double @cos(double %2)
%28 = tail call double @sin(double %1)
%29 = fmul double %27, %28
%30 = getelementptr inbounds double, double* %0, i64 3
store double %29, double* %30
%31 = tail call double @cos(double %2)
%32 = tail call double @cos(double %1)
%33 = fmul double %31, %32
%34 = getelementptr inbounds double, double* %0, i64 4
store double %33, double* %34
%35 = tail call double @sin(double %2)
%36 = fneg double %35
%37 = getelementptr inbounds double, double* %0, i64 5
store double %36, double* %37
%38 = tail call double @sin(double %2)
%39 = tail call double @cos(double %3)
%40 = fmul double %38, %39
%41 = tail call double @sin(double %1)
%42 = tail call double @sin(double %3)
%43 = tail call double @cos(double %1)
%44 = fneg double %42
%45 = fmul double %43, %44
%46 = tail call double @llvm.fmuladd.f64(double %40, double %41, double %45)
%47 = getelementptr inbounds double, double* %0, i64 6
store double %46, double* %47
%48 = tail call double @sin(double %2)
%49 = tail call double @cos(double %3)
%50 = fmul double %48, %49
%51 = tail call double @cos(double %1)
%52 = tail call double @sin(double %3)
%53 = tail call double @sin(double %1)
%54 = fmul double %52, %53
%55 = tail call double @llvm.fmuladd.f64(double %50, double %51, double %54)
%56 = getelementptr inbounds double, double* %0, i64 7
store double %55, double* %56
%57 = tail call double @cos(double %2)
%58 = tail call double @cos(double %3)
%59 = fmul double %57, %58
%60 = getelementptr inbounds double, double* %0, i64 8
store double %59, double* %60
ret void
}