#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 */
int /*<<< orphan*/ slaStringExport(char *, char *, int);
int /*<<< orphan*/ sla_deuler_(char *, double *, double *, double *, double *,
                               int const);
void slaDeuler(char *order, double phi, double theta, double psi,
               double rmat[3][3]) {
  char ORDER[4];
  const int ORDER_length = 4;
  double PHI;
  double THETA;
  double PSI;
  double RMAT[9];
  int i, j;
  PHI = phi;
  THETA = theta;
  PSI = psi;
  slaStringExport(order, ORDER, 4);
  sla_deuler_(ORDER, &PHI, &THETA, &PSI, (double *)RMAT, ORDER_length);
  for (i = 0; i < 3; i++) {
    for (j = 0; j < 3; j++)
      rmat[i][j] = RMAT[i + 3 * j];
  }
}


x86 assembly (clang, -O0):
<slaDeuler>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
mov    %rdi,-0x8(%rbp)
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
movsd  %xmm2,-0x20(%rbp)
mov    %rsi,-0x28(%rbp)
movl   $0x4,-0x30(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
mov    -0x8(%rbp),%rdi
lea    -0x2c(%rbp),%rsi
mov    $0x4,%edx
call   1030 <slaStringExport@plt>
lea    -0x2c(%rbp),%rdi
lea    -0x90(%rbp),%r8
lea    -0x38(%rbp),%rsi
lea    -0x40(%rbp),%rdx
lea    -0x48(%rbp),%rcx
mov    $0x4,%r9d
call   1040 <sla_deuler_@plt>
movl   $0x0,-0x94(%rbp)
cmpl   $0x3,-0x94(%rbp)
jge    122e <slaDeuler+0x10e>
movl   $0x0,-0x98(%rbp)
cmpl   $0x3,-0x98(%rbp)
jge    1215 <slaDeuler+0xf5>
mov    -0x94(%rbp),%eax
imul   $0x3,-0x98(%rbp),%ecx
add    %ecx,%eax
cltq
movsd  -0x90(%rbp,%rax,8),%xmm0
ff ff
mov    -0x28(%rbp),%rax
movslq -0x94(%rbp),%rcx
imul   $0x18,%rcx,%rcx
add    %rcx,%rax
movslq -0x98(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x98(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x98(%rbp)
jmp    11bc <slaDeuler+0x9c>
jmp    121a <slaDeuler+0xfa>
mov    -0x94(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x94(%rbp)
jmp    11a5 <slaDeuler+0x85>
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<slaDeuler>:
push   %r14
push   %rbx
sub    $0x68,%rsp
mov    %rsi,%rbx
movsd  %xmm0,0x10(%rsp)
movsd  %xmm1,0x8(%rsp)
movsd  %xmm2,(%rsp)
lea    0x1c(%rsp),%r14
mov    %r14,%rsi
mov    $0x4,%edx
call   1030 <slaStringExport@plt>
lea    0x10(%rsp),%rsi
lea    0x8(%rsp),%rdx
mov    %rsp,%rcx
lea    0x20(%rsp),%r8
mov    %r14,%rdi
mov    $0x4,%r9d
call   1040 <sla_deuler_@plt>
movsd  0x20(%rsp),%xmm0
movsd  %xmm0,(%rbx)
movsd  0x38(%rsp),%xmm0
movsd  %xmm0,0x8(%rbx)
movsd  0x50(%rsp),%xmm0
movsd  %xmm0,0x10(%rbx)
movsd  0x28(%rsp),%xmm0
movsd  %xmm0,0x18(%rbx)
movsd  0x40(%rsp),%xmm0
movsd  %xmm0,0x20(%rbx)
movsd  0x58(%rsp),%xmm0
movsd  %xmm0,0x28(%rbx)
movsd  0x30(%rsp),%xmm0
movsd  %xmm0,0x30(%rbx)
movsd  0x48(%rsp),%xmm0
movsd  %xmm0,0x38(%rbx)
movsd  0x60(%rsp),%xmm0
movsd  %xmm0,0x40(%rbx)
add    $0x68,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define void @slaDeuler(i8* %0, double %1, double %2, double %3, [3 x double]* %4) {
%6 = alloca i8*
%7 = alloca double
%8 = alloca double
%9 = alloca double
%10 = alloca [3 x double]*
%11 = alloca [4 x i8]
%12 = alloca i32
%13 = alloca double
%14 = alloca double
%15 = alloca double
%16 = alloca [9 x double]
%17 = alloca i32
%18 = alloca i32
store i8* %0, i8** %6
store double %1, double* %7
store double %2, double* %8
store double %3, double* %9
store [3 x double]* %4, [3 x double]** %10
store i32 4, i32* %12
%19 = load double, double* %7
store double %19, double* %13
%20 = load double, double* %8
store double %20, double* %14
%21 = load double, double* %9
store double %21, double* %15
%22 = load i8*, i8** %6
%23 = getelementptr inbounds [4 x i8], [4 x i8]* %11, i64 0, i64 0
%24 = call i32 @slaStringExport(i8* %22, i8* %23, i32 4)
%25 = getelementptr inbounds [4 x i8], [4 x i8]* %11, i64 0, i64 0
%26 = getelementptr inbounds [9 x double], [9 x double]* %16, i64 0, i64 0
%27 = call i32 @sla_deuler_(i8* %25, double* %13, double* %14, double* %15, double* %26, i32 4)
store i32 0, i32* %17
br label %28
28: ; preds = %54, %5
%29 = load i32, i32* %17
%30 = icmp slt i32 %29, 3
br i1 %30, label %31, label %57
31: ; preds = %28
store i32 0, i32* %18
br label %32
32: ; preds = %50, %31
%33 = load i32, i32* %18
%34 = icmp slt i32 %33, 3
br i1 %34, label %35, label %53
35: ; preds = %32
%36 = load i32, i32* %17
%37 = load i32, i32* %18
%38 = mul nsw i32 3, %37
%39 = add nsw i32 %36, %38
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds [9 x double], [9 x double]* %16, i64 0, i64 %40
%42 = load double, double* %41
%43 = load [3 x double]*, [3 x double]** %10
%44 = load i32, i32* %17
%45 = sext i32 %44 to i64
%46 = getelementptr inbounds [3 x double], [3 x double]* %43, i64 %45
%47 = load i32, i32* %18
%48 = sext i32 %47 to i64
%49 = getelementptr inbounds [3 x double], [3 x double]* %46, i64 0, i64 %48
store double %42, double* %49
br label %50
50: ; preds = %35
%51 = load i32, i32* %18
%52 = add nsw i32 %51, 1
store i32 %52, i32* %18
br label %32
53: ; preds = %32
br label %54
54: ; preds = %53
%55 = load i32, i32* %17
%56 = add nsw i32 %55, 1
store i32 %56, i32* %17
br label %28
57: ; preds = %28
ret void
}

LLVM IR (-O2):
define void @slaDeuler(i8* %0, double %1, double %2, double %3, [3 x double]* nocapture writeonly %4) {
%6 = alloca [4 x i8]
%7 = alloca double
%8 = alloca double
%9 = alloca double
%10 = alloca [9 x double]
%11 = getelementptr inbounds [4 x i8], [4 x i8]* %6, i64 0, i64 0
%12 = bitcast double* %7 to i8*
%13 = bitcast double* %8 to i8*
%14 = bitcast double* %9 to i8*
%15 = bitcast [9 x double]* %10 to i8*
store double %1, double* %7
store double %2, double* %8
store double %3, double* %9
%16 = call i32 @slaStringExport(i8* %0, i8* %11, i32 4)
%17 = getelementptr inbounds [9 x double], [9 x double]* %10, i64 0, i64 0
%18 = call i32 @sla_deuler_(i8* %11, double* %7, double* %8, double* %9, double* %17, i32 4)
%19 = load double, double* %17
%20 = getelementptr inbounds [3 x double], [3 x double]* %4, i64 0, i64 0
store double %19, double* %20
%21 = getelementptr inbounds [9 x double], [9 x double]* %10, i64 0, i64 3
%22 = load double, double* %21
%23 = getelementptr inbounds [3 x double], [3 x double]* %4, i64 0, i64 1
store double %22, double* %23
%24 = getelementptr inbounds [9 x double], [9 x double]* %10, i64 0, i64 6
%25 = load double, double* %24
%26 = getelementptr inbounds [3 x double], [3 x double]* %4, i64 0, i64 2
store double %25, double* %26
%27 = getelementptr inbounds [9 x double], [9 x double]* %10, i64 0, i64 1
%28 = load double, double* %27
%29 = getelementptr inbounds [3 x double], [3 x double]* %4, i64 1, i64 0
store double %28, double* %29
%30 = getelementptr inbounds [9 x double], [9 x double]* %10, i64 0, i64 4
%31 = load double, double* %30
%32 = getelementptr inbounds [3 x double], [3 x double]* %4, i64 1, i64 1
store double %31, double* %32
%33 = getelementptr inbounds [9 x double], [9 x double]* %10, i64 0, i64 7
%34 = load double, double* %33
%35 = getelementptr inbounds [3 x double], [3 x double]* %4, i64 1, i64 2
store double %34, double* %35
%36 = getelementptr inbounds [9 x double], [9 x double]* %10, i64 0, i64 2
%37 = load double, double* %36
%38 = getelementptr inbounds [3 x double], [3 x double]* %4, i64 2, i64 0
store double %37, double* %38
%39 = getelementptr inbounds [9 x double], [9 x double]* %10, i64 0, i64 5
%40 = load double, double* %39
%41 = getelementptr inbounds [3 x double], [3 x double]* %4, i64 2, i64 1
store double %40, double* %41
%42 = getelementptr inbounds [9 x double], [9 x double]* %10, i64 0, i64 8
%43 = load double, double* %42
%44 = getelementptr inbounds [3 x double], [3 x double]* %4, i64 2, i64 2
store double %43, double* %44
ret void
}