#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);
int /*<<< orphan*/ matMakeRotMat(double, double, double, double, double *);
int /*<<< orphan*/ matMultMM(double *, double *, double *);
double sin(double);
int matPolarToMat(double omega, double phi, double kappa, double *mat) {
  double ax, ay, az;
  double mat1[16], mat2[16], mat3[16], mat4[16];
  matMakeRotMat(omega, 0.0, 0.0, 1.0, mat1);
  matMakeRotMat(phi, 1.0, 0.0, 0.0, mat2);
  ax = cos(omega);
  ay = sin(omega) * cos(phi);
  az = sin(omega) * sin(phi);
  matMakeRotMat(kappa, ax, ay, az, mat3);
  matMultMM(mat1, mat2, mat4);
  matMultMM(mat4, mat3, mat);
  matMultMM(mat1, mat2, mat);
  return 0;
}


x86 assembly (clang, -O0):
<matPolarToMat>:
push   %rbp
mov    %rsp,%rbp
sub    $0x250,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
movsd  %xmm2,-0x18(%rbp)
mov    %rdi,-0x20(%rbp)
movsd  -0x8(%rbp),%xmm0
lea    -0xc0(%rbp),%rdi
xorps  %xmm2,%xmm2
movsd  0xe8b(%rip),%xmm3
movaps %xmm2,%xmm1
call   1060 <matMakeRotMat@plt>
movsd  -0x10(%rbp),%xmm0
lea    -0x140(%rbp),%rdi
movsd  0xe6f(%rip),%xmm1
xorps  %xmm3,%xmm3
movaps %xmm3,%xmm2
call   1060 <matMakeRotMat@plt>
movsd  -0x8(%rbp),%xmm0
call   1050 <cos@plt>
movsd  %xmm0,-0x28(%rbp)
movsd  -0x8(%rbp),%xmm0
call   1040 <sin@plt>
movsd  %xmm0,-0x250(%rbp)
ff
movsd  -0x10(%rbp),%xmm0
call   1050 <cos@plt>
movaps %xmm0,%xmm1
movsd  -0x250(%rbp),%xmm0
ff
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x8(%rbp),%xmm0
call   1040 <sin@plt>
movsd  %xmm0,-0x248(%rbp)
ff
movsd  -0x10(%rbp),%xmm0
call   1040 <sin@plt>
movaps %xmm0,%xmm1
movsd  -0x248(%rbp),%xmm0
ff
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  -0x28(%rbp),%xmm1
movsd  -0x30(%rbp),%xmm2
movsd  -0x38(%rbp),%xmm3
lea    -0x1c0(%rbp),%rdi
call   1060 <matMakeRotMat@plt>
lea    -0xc0(%rbp),%rdi
lea    -0x140(%rbp),%rsi
lea    -0x240(%rbp),%rdx
call   1030 <matMultMM@plt>
lea    -0x240(%rbp),%rdi
lea    -0x1c0(%rbp),%rsi
mov    -0x20(%rbp),%rdx
call   1030 <matMultMM@plt>
lea    -0xc0(%rbp),%rdi
lea    -0x140(%rbp),%rsi
mov    -0x20(%rbp),%rdx
call   1030 <matMultMM@plt>
xor    %eax,%eax
add    $0x250,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<matPolarToMat>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x230,%rsp
mov    %rdi,%r12
movsd  %xmm2,0x28(%rsp)
movsd  %xmm1,0x18(%rsp)
movsd  %xmm0,0x8(%rsp)
movsd  0xe93(%rip),%xmm3
lea    0x1b0(%rsp),%r14
xorps  %xmm1,%xmm1
xorps  %xmm2,%xmm2
mov    %r14,%rdi
call   1060 <matMakeRotMat@plt>
lea    0x130(%rsp),%r15
xorps  %xmm2,%xmm2
xorps  %xmm3,%xmm3
movsd  0x18(%rsp),%xmm0
movsd  0xe61(%rip),%xmm1
mov    %r15,%rdi
call   1060 <matMakeRotMat@plt>
movsd  0x8(%rsp),%xmm0
call   1050 <cos@plt>
movsd  %xmm0,0x20(%rsp)
movsd  0x8(%rsp),%xmm0
call   1040 <sin@plt>
movsd  %xmm0,0x10(%rsp)
movsd  0x18(%rsp),%xmm0
call   1050 <cos@plt>
movsd  0x10(%rsp),%xmm1
mulsd  %xmm0,%xmm1
movsd  %xmm1,0x10(%rsp)
movsd  0x8(%rsp),%xmm0
call   1040 <sin@plt>
movsd  %xmm0,0x8(%rsp)
movsd  0x18(%rsp),%xmm0
call   1040 <sin@plt>
movsd  0x8(%rsp),%xmm3
mulsd  %xmm0,%xmm3
lea    0xb0(%rsp),%r13
movsd  0x28(%rsp),%xmm0
movsd  0x20(%rsp),%xmm1
movsd  0x10(%rsp),%xmm2
mov    %r13,%rdi
call   1060 <matMakeRotMat@plt>
lea    0x30(%rsp),%rbx
mov    %r14,%rdi
mov    %r15,%rsi
mov    %rbx,%rdx
call   1030 <matMultMM@plt>
mov    %rbx,%rdi
mov    %r13,%rsi
mov    %r12,%rdx
call   1030 <matMultMM@plt>
mov    %r14,%rdi
mov    %r15,%rsi
mov    %r12,%rdx
call   1030 <matMultMM@plt>
xor    %eax,%eax
add    $0x230,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i32 @matPolarToMat(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 [16 x double]
%13 = alloca [16 x double]
%14 = alloca [16 x double]
%15 = alloca [16 x double]
store double %0, double* %5
store double %1, double* %6
store double %2, double* %7
store double* %3, double** %8
%16 = load double, double* %5
%17 = getelementptr inbounds [16 x double], [16 x double]* %12, i64 0, i64 0
%18 = call i32 @matMakeRotMat(double %16, double 0.000000e+00, double 0.000000e+00, double 1.000000e+00, double* %17)
%19 = load double, double* %6
%20 = getelementptr inbounds [16 x double], [16 x double]* %13, i64 0, i64 0
%21 = call i32 @matMakeRotMat(double %19, double 1.000000e+00, double 0.000000e+00, double 0.000000e+00, double* %20)
%22 = load double, double* %5
%23 = call double @cos(double %22)
store double %23, double* %9
%24 = load double, double* %5
%25 = call double @sin(double %24)
%26 = load double, double* %6
%27 = call double @cos(double %26)
%28 = fmul double %25, %27
store double %28, double* %10
%29 = load double, double* %5
%30 = call double @sin(double %29)
%31 = load double, double* %6
%32 = call double @sin(double %31)
%33 = fmul double %30, %32
store double %33, double* %11
%34 = load double, double* %7
%35 = load double, double* %9
%36 = load double, double* %10
%37 = load double, double* %11
%38 = getelementptr inbounds [16 x double], [16 x double]* %14, i64 0, i64 0
%39 = call i32 @matMakeRotMat(double %34, double %35, double %36, double %37, double* %38)
%40 = getelementptr inbounds [16 x double], [16 x double]* %12, i64 0, i64 0
%41 = getelementptr inbounds [16 x double], [16 x double]* %13, i64 0, i64 0
%42 = getelementptr inbounds [16 x double], [16 x double]* %15, i64 0, i64 0
%43 = call i32 @matMultMM(double* %40, double* %41, double* %42)
%44 = getelementptr inbounds [16 x double], [16 x double]* %15, i64 0, i64 0
%45 = getelementptr inbounds [16 x double], [16 x double]* %14, i64 0, i64 0
%46 = load double*, double** %8
%47 = call i32 @matMultMM(double* %44, double* %45, double* %46)
%48 = getelementptr inbounds [16 x double], [16 x double]* %12, i64 0, i64 0
%49 = getelementptr inbounds [16 x double], [16 x double]* %13, i64 0, i64 0
%50 = load double*, double** %8
%51 = call i32 @matMultMM(double* %48, double* %49, double* %50)
ret i32 0
}

LLVM IR (-O2):
define i32 @matPolarToMat(double %0, double %1, double %2, double* %3) {
%5 = alloca [16 x double]
%6 = alloca [16 x double]
%7 = alloca [16 x double]
%8 = alloca [16 x double]
%9 = bitcast [16 x double]* %5 to i8*
%10 = bitcast [16 x double]* %6 to i8*
%11 = bitcast [16 x double]* %7 to i8*
%12 = bitcast [16 x double]* %8 to i8*
%13 = getelementptr inbounds [16 x double], [16 x double]* %5, i64 0, i64 0
%14 = call i32 @matMakeRotMat(double %0, double 0.000000e+00, double 0.000000e+00, double 1.000000e+00, double* %13)
%15 = getelementptr inbounds [16 x double], [16 x double]* %6, i64 0, i64 0
%16 = call i32 @matMakeRotMat(double %1, double 1.000000e+00, double 0.000000e+00, double 0.000000e+00, double* %15)
%17 = call double @cos(double %0)
%18 = call double @sin(double %0)
%19 = call double @cos(double %1)
%20 = fmul double %18, %19
%21 = call double @sin(double %0)
%22 = call double @sin(double %1)
%23 = fmul double %21, %22
%24 = getelementptr inbounds [16 x double], [16 x double]* %7, i64 0, i64 0
%25 = call i32 @matMakeRotMat(double %2, double %17, double %20, double %23, double* %24)
%26 = getelementptr inbounds [16 x double], [16 x double]* %8, i64 0, i64 0
%27 = call i32 @matMultMM(double* %13, double* %15, double* %26)
%28 = call i32 @matMultMM(double* %26, double* %24, double* %3)
%29 = call i32 @matMultMM(double* %13, double* %15, double* %3)
ret i32 0
}