#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 labgtomat(double *r, double alpha, double beta, double gamma) {
  double ca = cos(alpha), cb = cos(beta), cg = cos(gamma);
  double sa = sin(alpha), sb = sin(beta), sg = sin(gamma);
  r[0] = cg * ca - sg * cb * sa;
  r[1] = sg * ca + cg * cb * sa;
  r[2] = sb * sa;
  r[3] = -cg * sa - sg * cb * ca;
  r[4] = -sg * sa + cg * cb * ca;
  r[5] = sb * ca;
  r[6] = sg * sb;
  r[7] = -cg * sb;
  r[8] = cb;
}


x86 assembly (clang, -O0):
<labgtomat>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
movsd  %xmm2,-0x20(%rbp)
movsd  -0x10(%rbp),%xmm0
call   1040 <cos@plt>
movsd  %xmm0,-0x28(%rbp)
movsd  -0x18(%rbp),%xmm0
call   1040 <cos@plt>
movsd  %xmm0,-0x30(%rbp)
movsd  -0x20(%rbp),%xmm0
call   1040 <cos@plt>
movsd  %xmm0,-0x38(%rbp)
movsd  -0x10(%rbp),%xmm0
call   1030 <sin@plt>
movsd  %xmm0,-0x40(%rbp)
movsd  -0x18(%rbp),%xmm0
call   1030 <sin@plt>
movsd  %xmm0,-0x48(%rbp)
movsd  -0x20(%rbp),%xmm0
call   1030 <sin@plt>
movsd  %xmm0,-0x50(%rbp)
movsd  -0x38(%rbp),%xmm0
movsd  -0x28(%rbp),%xmm2
movsd  -0x50(%rbp),%xmm1
mulsd  -0x30(%rbp),%xmm1
mulsd  -0x40(%rbp),%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,(%rax)
movsd  -0x50(%rbp),%xmm0
movsd  -0x28(%rbp),%xmm2
movsd  -0x38(%rbp),%xmm1
mulsd  -0x30(%rbp),%xmm1
mulsd  -0x40(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x8(%rbp),%rax
movsd  %xmm0,0x8(%rax)
movsd  -0x48(%rbp),%xmm0
mulsd  -0x40(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movsd  %xmm0,0x10(%rax)
movsd  -0x38(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  -0x40(%rbp),%xmm2
movsd  -0x50(%rbp),%xmm1
mulsd  -0x30(%rbp),%xmm1
mulsd  -0x28(%rbp),%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,0x18(%rax)
movsd  -0x50(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  -0x40(%rbp),%xmm2
movsd  -0x38(%rbp),%xmm1
mulsd  -0x30(%rbp),%xmm1
mulsd  -0x28(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x8(%rbp),%rax
movsd  %xmm0,0x20(%rax)
movsd  -0x48(%rbp),%xmm0
mulsd  -0x28(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movsd  %xmm0,0x28(%rax)
movsd  -0x50(%rbp),%xmm0
mulsd  -0x48(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movsd  %xmm0,0x30(%rax)
movsd  -0x38(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  -0x48(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movsd  %xmm0,0x38(%rax)
movsd  -0x30(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movsd  %xmm0,0x40(%rax)
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<labgtomat>:
push   %rbx
sub    $0x60,%rsp
movsd  %xmm2,0x8(%rsp)
movsd  %xmm1,0x10(%rsp)
movsd  %xmm0,0x20(%rsp)
mov    %rdi,%rbx
call   1040 <cos@plt>
movaps %xmm0,0x50(%rsp)
movsd  0x10(%rsp),%xmm0
call   1040 <cos@plt>
movaps %xmm0,0x40(%rsp)
movsd  0x8(%rsp),%xmm0
call   1040 <cos@plt>
movaps %xmm0,0x30(%rsp)
movsd  0x20(%rsp),%xmm0
call   1030 <sin@plt>
movaps %xmm0,0x20(%rsp)
movsd  0x10(%rsp),%xmm0
call   1030 <sin@plt>
movaps %xmm0,0x10(%rsp)
movsd  0x8(%rsp),%xmm0
call   1030 <sin@plt>
movapd 0x40(%rsp),%xmm8
movapd %xmm8,%xmm2
unpcklpd %xmm8,%xmm2
movapd 0x30(%rsp),%xmm5
movapd %xmm5,%xmm3
unpcklpd %xmm0,%xmm3
movapd 0xe4a(%rip),%xmm1
xorpd  %xmm3,%xmm1
movapd %xmm1,%xmm4
shufpd $0x1,%xmm5,%xmm4
mulpd  %xmm2,%xmm4
movapd 0x20(%rsp),%xmm9
movapd %xmm9,%xmm2
unpcklpd %xmm9,%xmm2
movapd %xmm2,%xmm5
mulpd  %xmm4,%xmm5
movapd 0x50(%rsp),%xmm7
movapd %xmm7,%xmm6
unpcklpd %xmm7,%xmm6
mulpd  %xmm3,%xmm2
mulpd  %xmm6,%xmm3
addpd  %xmm5,%xmm3
movupd %xmm3,(%rbx)
movapd 0x10(%rsp),%xmm3
movapd %xmm9,%xmm5
mulsd  %xmm3,%xmm5
movsd  %xmm5,0x10(%rbx)
mulpd  %xmm4,%xmm6
subpd  %xmm2,%xmm6
movupd %xmm6,0x18(%rbx)
movapd %xmm3,%xmm2
movapd %xmm3,%xmm4
unpcklpd %xmm3,%xmm2
movapd %xmm7,%xmm3
unpcklpd %xmm0,%xmm3
mulpd  %xmm2,%xmm3
movupd %xmm3,0x28(%rbx)
mulsd  %xmm4,%xmm1
movsd  %xmm1,0x38(%rbx)
movsd  %xmm8,0x40(%rbx)
add    $0x60,%rsp
pop    %rbx
ret

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

LLVM IR (-O2):
define void @labgtomat(double* nocapture writeonly %0, double %1, double %2, double %3) {
%5 = tail call double @cos(double %1)
%6 = tail call double @cos(double %2)
%7 = tail call double @cos(double %3)
%8 = tail call double @sin(double %1)
%9 = tail call double @sin(double %2)
%10 = tail call double @sin(double %3)
%11 = insertelement <2 x double> poison, double %6, i64 0
%12 = shufflevector <2 x double> %11, <2 x double> poison, <2 x i32> zeroinitializer
%13 = insertelement <2 x double> poison, double %7, i64 0
%14 = insertelement <2 x double> %13, double %10, i64 1
%15 = fneg <2 x double> %14
%16 = extractelement <2 x double> %15, i64 1
%17 = insertelement <2 x double> poison, double %16, i64 0
%18 = insertelement <2 x double> %17, double %7, i64 1
%19 = fmul <2 x double> %12, %18
%20 = insertelement <2 x double> poison, double %8, i64 0
%21 = shufflevector <2 x double> %20, <2 x double> poison, <2 x i32> zeroinitializer
%22 = fmul <2 x double> %21, %19
%23 = insertelement <2 x double> poison, double %5, i64 0
%24 = shufflevector <2 x double> %23, <2 x double> poison, <2 x i32> zeroinitializer
%25 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %14, <2 x double> %24, <2 x double> %22)
%26 = bitcast double* %0 to <2 x double>*
store <2 x double> %25, <2 x double>* %26
%27 = fmul double %8, %9
%28 = getelementptr inbounds double, double* %0, i64 2
store double %27, double* %28
%29 = getelementptr inbounds double, double* %0, i64 3
%30 = fmul <2 x double> %24, %19
%31 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %15, <2 x double> %21, <2 x double> %30)
%32 = bitcast double* %29 to <2 x double>*
store <2 x double> %31, <2 x double>* %32
%33 = getelementptr inbounds double, double* %0, i64 5
%34 = insertelement <2 x double> poison, double %9, i64 0
%35 = shufflevector <2 x double> %34, <2 x double> poison, <2 x i32> zeroinitializer
%36 = insertelement <2 x double> %23, double %10, i64 1
%37 = fmul <2 x double> %35, %36
%38 = bitcast double* %33 to <2 x double>*
store <2 x double> %37, <2 x double>* %38
%39 = extractelement <2 x double> %15, i64 0
%40 = fmul double %9, %39
%41 = getelementptr inbounds double, double* %0, i64 7
store double %40, double* %41
%42 = getelementptr inbounds double, double* %0, i64 8
store double %6, double* %42
ret void
}