#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*/ matrix_3_3_copy(float **, float **);
int /*<<< orphan*/ matrix_3_3_multiply(float **, float **, float **);
int /*<<< orphan*/ rotation_matrix_normalize(float **);
void rotation_matrix_velocity_update(float r[][3], float roll, float pitch,
                                     float yaw, float dt) {
  float r_dth_dt[3][3];
  yaw = yaw * dt;
  pitch = pitch * dt;
  roll = roll * dt;
  r_dth_dt[0][0] = 1;
  r_dth_dt[0][1] = -yaw;
  r_dth_dt[0][2] = pitch;
  r_dth_dt[1][0] = yaw;
  r_dth_dt[1][1] = 1;
  r_dth_dt[1][2] = -roll;
  r_dth_dt[2][0] = -pitch;
  r_dth_dt[2][1] = roll;
  r_dth_dt[2][2] = 1;
  float tmp_matrix[3][3];
  matrix_3_3_multiply(r, r_dth_dt, tmp_matrix);
  matrix_3_3_copy(tmp_matrix, r);
  rotation_matrix_normalize(r);
}


x86 assembly (clang, -O0):
<rotation_matrix_velocity_update>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    %rdi,-0x8(%rbp)
movss  %xmm0,-0xc(%rbp)
movss  %xmm1,-0x10(%rbp)
movss  %xmm2,-0x14(%rbp)
movss  %xmm3,-0x18(%rbp)
movss  -0x14(%rbp),%xmm0
mulss  -0x18(%rbp),%xmm0
movss  %xmm0,-0x14(%rbp)
movss  -0x10(%rbp),%xmm0
mulss  -0x18(%rbp),%xmm0
movss  %xmm0,-0x10(%rbp)
movss  -0xc(%rbp),%xmm0
mulss  -0x18(%rbp),%xmm0
movss  %xmm0,-0xc(%rbp)
movss  0xe7b(%rip),%xmm0
movss  %xmm0,-0x40(%rbp)
movss  -0x14(%rbp),%xmm0
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
movss  %xmm0,-0x3c(%rbp)
movss  -0x10(%rbp),%xmm0
movss  %xmm0,-0x38(%rbp)
movss  -0x14(%rbp),%xmm0
movss  %xmm0,-0x34(%rbp)
movss  0xe43(%rip),%xmm0
movss  %xmm0,-0x30(%rbp)
movss  -0xc(%rbp),%xmm0
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
movss  %xmm0,-0x2c(%rbp)
movss  -0x10(%rbp),%xmm0
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
movss  %xmm0,-0x28(%rbp)
movss  -0xc(%rbp),%xmm0
movss  %xmm0,-0x24(%rbp)
movss  0xdfe(%rip),%xmm0
movss  %xmm0,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
lea    -0x40(%rbp),%rsi
lea    -0x70(%rbp),%rdx
call   1030 <matrix_3_3_multiply@plt>
lea    -0x70(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1050 <matrix_3_3_copy@plt>
mov    -0x8(%rbp),%rdi
call   1040 <rotation_matrix_normalize@plt>
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<rotation_matrix_velocity_update>:
push   %r14
push   %rbx
sub    $0x58,%rsp
mov    %rdi,%rbx
mulss  %xmm3,%xmm2
mulss  %xmm3,%xmm1
mulss  %xmm3,%xmm0
movl   $0x3f800000,(%rsp)
movaps 0xeac(%rip),%xmm3
movaps %xmm2,%xmm4
xorps  %xmm3,%xmm4
movss  %xmm4,0x4(%rsp)
movss  %xmm1,0x8(%rsp)
movss  %xmm2,0xc(%rsp)
movl   $0x3f800000,0x10(%rsp)
3f
movaps %xmm0,%xmm2
xorps  %xmm3,%xmm2
movss  %xmm2,0x14(%rsp)
xorps  %xmm3,%xmm1
movss  %xmm1,0x18(%rsp)
movss  %xmm0,0x1c(%rsp)
movl   $0x3f800000,0x20(%rsp)
3f
mov    %rsp,%rsi
lea    0x30(%rsp),%r14
mov    %r14,%rdx
call   1030 <matrix_3_3_multiply@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1050 <matrix_3_3_copy@plt>
mov    %rbx,%rdi
call   1040 <rotation_matrix_normalize@plt>
add    $0x58,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define void @rotation_matrix_velocity_update([3 x float]* %0, float %1, float %2, float %3, float %4) {
%6 = alloca [3 x float]*
%7 = alloca float
%8 = alloca float
%9 = alloca float
%10 = alloca float
%11 = alloca [3 x [3 x float]]
%12 = alloca [3 x [3 x float]]
store [3 x float]* %0, [3 x float]** %6
store float %1, float* %7
store float %2, float* %8
store float %3, float* %9
store float %4, float* %10
%13 = load float, float* %9
%14 = load float, float* %10
%15 = fmul float %13, %14
store float %15, float* %9
%16 = load float, float* %8
%17 = load float, float* %10
%18 = fmul float %16, %17
store float %18, float* %8
%19 = load float, float* %7
%20 = load float, float* %10
%21 = fmul float %19, %20
store float %21, float* %7
%22 = getelementptr inbounds [3 x [3 x float]], [3 x [3 x float]]* %11, i64 0, i64 0
%23 = getelementptr inbounds [3 x float], [3 x float]* %22, i64 0, i64 0
store float 1.000000e+00, float* %23
%24 = load float, float* %9
%25 = fneg float %24
%26 = getelementptr inbounds [3 x [3 x float]], [3 x [3 x float]]* %11, i64 0, i64 0
%27 = getelementptr inbounds [3 x float], [3 x float]* %26, i64 0, i64 1
store float %25, float* %27
%28 = load float, float* %8
%29 = getelementptr inbounds [3 x [3 x float]], [3 x [3 x float]]* %11, i64 0, i64 0
%30 = getelementptr inbounds [3 x float], [3 x float]* %29, i64 0, i64 2
store float %28, float* %30
%31 = load float, float* %9
%32 = getelementptr inbounds [3 x [3 x float]], [3 x [3 x float]]* %11, i64 0, i64 1
%33 = getelementptr inbounds [3 x float], [3 x float]* %32, i64 0, i64 0
store float %31, float* %33
%34 = getelementptr inbounds [3 x [3 x float]], [3 x [3 x float]]* %11, i64 0, i64 1
%35 = getelementptr inbounds [3 x float], [3 x float]* %34, i64 0, i64 1
store float 1.000000e+00, float* %35
%36 = load float, float* %7
%37 = fneg float %36
%38 = getelementptr inbounds [3 x [3 x float]], [3 x [3 x float]]* %11, i64 0, i64 1
%39 = getelementptr inbounds [3 x float], [3 x float]* %38, i64 0, i64 2
store float %37, float* %39
%40 = load float, float* %8
%41 = fneg float %40
%42 = getelementptr inbounds [3 x [3 x float]], [3 x [3 x float]]* %11, i64 0, i64 2
%43 = getelementptr inbounds [3 x float], [3 x float]* %42, i64 0, i64 0
store float %41, float* %43
%44 = load float, float* %7
%45 = getelementptr inbounds [3 x [3 x float]], [3 x [3 x float]]* %11, i64 0, i64 2
%46 = getelementptr inbounds [3 x float], [3 x float]* %45, i64 0, i64 1
store float %44, float* %46
%47 = getelementptr inbounds [3 x [3 x float]], [3 x [3 x float]]* %11, i64 0, i64 2
%48 = getelementptr inbounds [3 x float], [3 x float]* %47, i64 0, i64 2
store float 1.000000e+00, float* %48
%49 = load [3 x float]*, [3 x float]** %6
%50 = bitcast [3 x float]* %49 to float**
%51 = getelementptr inbounds [3 x [3 x float]], [3 x [3 x float]]* %11, i64 0, i64 0
%52 = bitcast [3 x float]* %51 to float**
%53 = getelementptr inbounds [3 x [3 x float]], [3 x [3 x float]]* %12, i64 0, i64 0
%54 = bitcast [3 x float]* %53 to float**
%55 = call i32 @matrix_3_3_multiply(float** %50, float** %52, float** %54)
%56 = getelementptr inbounds [3 x [3 x float]], [3 x [3 x float]]* %12, i64 0, i64 0
%57 = bitcast [3 x float]* %56 to float**
%58 = load [3 x float]*, [3 x float]** %6
%59 = bitcast [3 x float]* %58 to float**
%60 = call i32 @matrix_3_3_copy(float** %57, float** %59)
%61 = load [3 x float]*, [3 x float]** %6
%62 = bitcast [3 x float]* %61 to float**
%63 = call i32 @rotation_matrix_normalize(float** %62)
ret void
}

LLVM IR (-O2):
define void @rotation_matrix_velocity_update([3 x float]* %0, float %1, float %2, float %3, float %4) {
%6 = alloca [3 x [3 x float]]
%7 = alloca [3 x [3 x float]]
%8 = bitcast [3 x [3 x float]]* %6 to i8*
%9 = fmul float %3, %4
%10 = fmul float %2, %4
%11 = fmul float %1, %4
%12 = getelementptr inbounds [3 x [3 x float]], [3 x [3 x float]]* %6, i64 0, i64 0, i64 0
store float 1.000000e+00, float* %12
%13 = fneg float %9
%14 = getelementptr inbounds [3 x [3 x float]], [3 x [3 x float]]* %6, i64 0, i64 0, i64 1
store float %13, float* %14
%15 = getelementptr inbounds [3 x [3 x float]], [3 x [3 x float]]* %6, i64 0, i64 0, i64 2
store float %10, float* %15
%16 = getelementptr inbounds [3 x [3 x float]], [3 x [3 x float]]* %6, i64 0, i64 1, i64 0
store float %9, float* %16
%17 = getelementptr inbounds [3 x [3 x float]], [3 x [3 x float]]* %6, i64 0, i64 1, i64 1
store float 1.000000e+00, float* %17
%18 = fneg float %11
%19 = getelementptr inbounds [3 x [3 x float]], [3 x [3 x float]]* %6, i64 0, i64 1, i64 2
store float %18, float* %19
%20 = fneg float %10
%21 = getelementptr inbounds [3 x [3 x float]], [3 x [3 x float]]* %6, i64 0, i64 2, i64 0
store float %20, float* %21
%22 = getelementptr inbounds [3 x [3 x float]], [3 x [3 x float]]* %6, i64 0, i64 2, i64 1
store float %11, float* %22
%23 = getelementptr inbounds [3 x [3 x float]], [3 x [3 x float]]* %6, i64 0, i64 2, i64 2
store float 1.000000e+00, float* %23
%24 = bitcast [3 x [3 x float]]* %7 to i8*
%25 = bitcast [3 x float]* %0 to float**
%26 = bitcast [3 x [3 x float]]* %6 to float**
%27 = bitcast [3 x [3 x float]]* %7 to float**
%28 = call i32 @matrix_3_3_multiply(float** %25, float** %26, float** %27)
%29 = call i32 @matrix_3_3_copy(float** %27, float** %25)
%30 = call i32 @rotation_matrix_normalize(float** %25)
ret void
}