#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*/ Quaternion_Add(float *, float *, float *);
int /*<<< orphan*/ Quaternion_Multiply(float *, float *, float *);
int /*<<< orphan*/ Quaternion_Normalize(float *);
int /*<<< orphan*/ Quaternion_Scalar(float *, float *, float);
void Quaternion_RungeKutta4(float *q, float *w, float *dt, int normalize) {
  float half = 0.5f;
  float two = 2.0f;
  float qw[4], k2[4], k3[4], k4[4];
  float tmpq[4], tmpk[4];
  Quaternion_Multiply(qw, q, w);
  Quaternion_Scalar(qw, qw, half);
  Quaternion_Scalar(tmpk, qw, *dt * half);
  Quaternion_Add(tmpk, q, tmpk);
  Quaternion_Multiply(k2, tmpk, w);
  Quaternion_Scalar(k2, k2, half);
  Quaternion_Scalar(tmpk, k2, *dt * half);
  Quaternion_Add(tmpk, q, tmpk);
  Quaternion_Multiply(k3, tmpk, w);
  Quaternion_Scalar(k3, k3, half);
  Quaternion_Scalar(tmpk, k3, *dt);
  Quaternion_Add(tmpk, q, tmpk);
  Quaternion_Multiply(k4, tmpk, w);
  Quaternion_Scalar(k4, k4, half);
  Quaternion_Scalar(tmpk, k2, two);
  Quaternion_Add(tmpq, qw, tmpk);
  Quaternion_Scalar(tmpk, k3, two);
  Quaternion_Add(tmpq, tmpq, tmpk);
  Quaternion_Add(tmpq, tmpq, k4);
  Quaternion_Scalar(tmpq, tmpq, *dt / 6.0f);
  Quaternion_Add(q, q, tmpq);
  if (normalize) {
    Quaternion_Normalize(q);
  }
}


x86 assembly (clang, -O0):
<Quaternion_RungeKutta4>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
movss  0xea6(%rip),%xmm0
movss  %xmm0,-0x20(%rbp)
movss  0xe95(%rip),%xmm0
movss  %xmm0,-0x24(%rbp)
lea    -0x40(%rbp),%rdi
mov    -0x8(%rbp),%rsi
mov    -0x10(%rbp),%rdx
call   1040 <Quaternion_Multiply@plt>
lea    -0x40(%rbp),%rdi
lea    -0x40(%rbp),%rsi
movss  -0x20(%rbp),%xmm0
call   1050 <Quaternion_Scalar@plt>
lea    -0x90(%rbp),%rdi
lea    -0x40(%rbp),%rsi
mov    -0x18(%rbp),%rax
movss  (%rax),%xmm0
mulss  -0x20(%rbp),%xmm0
call   1050 <Quaternion_Scalar@plt>
lea    -0x90(%rbp),%rdi
mov    -0x8(%rbp),%rsi
lea    -0x90(%rbp),%rdx
call   1060 <Quaternion_Add@plt>
lea    -0x50(%rbp),%rdi
lea    -0x90(%rbp),%rsi
mov    -0x10(%rbp),%rdx
call   1040 <Quaternion_Multiply@plt>
lea    -0x50(%rbp),%rdi
lea    -0x50(%rbp),%rsi
movss  -0x20(%rbp),%xmm0
call   1050 <Quaternion_Scalar@plt>
lea    -0x90(%rbp),%rdi
lea    -0x50(%rbp),%rsi
mov    -0x18(%rbp),%rax
movss  (%rax),%xmm0
mulss  -0x20(%rbp),%xmm0
call   1050 <Quaternion_Scalar@plt>
lea    -0x90(%rbp),%rdi
mov    -0x8(%rbp),%rsi
lea    -0x90(%rbp),%rdx
call   1060 <Quaternion_Add@plt>
lea    -0x60(%rbp),%rdi
lea    -0x90(%rbp),%rsi
mov    -0x10(%rbp),%rdx
call   1040 <Quaternion_Multiply@plt>
lea    -0x60(%rbp),%rdi
lea    -0x60(%rbp),%rsi
movss  -0x20(%rbp),%xmm0
call   1050 <Quaternion_Scalar@plt>
lea    -0x90(%rbp),%rdi
lea    -0x60(%rbp),%rsi
mov    -0x18(%rbp),%rax
movss  (%rax),%xmm0
call   1050 <Quaternion_Scalar@plt>
lea    -0x90(%rbp),%rdi
mov    -0x8(%rbp),%rsi
lea    -0x90(%rbp),%rdx
call   1060 <Quaternion_Add@plt>
lea    -0x70(%rbp),%rdi
lea    -0x90(%rbp),%rsi
mov    -0x10(%rbp),%rdx
call   1040 <Quaternion_Multiply@plt>
lea    -0x70(%rbp),%rdi
lea    -0x70(%rbp),%rsi
movss  -0x20(%rbp),%xmm0
call   1050 <Quaternion_Scalar@plt>
lea    -0x90(%rbp),%rdi
lea    -0x50(%rbp),%rsi
movss  -0x24(%rbp),%xmm0
call   1050 <Quaternion_Scalar@plt>
lea    -0x80(%rbp),%rdi
lea    -0x40(%rbp),%rsi
lea    -0x90(%rbp),%rdx
call   1060 <Quaternion_Add@plt>
lea    -0x90(%rbp),%rdi
lea    -0x60(%rbp),%rsi
movss  -0x24(%rbp),%xmm0
call   1050 <Quaternion_Scalar@plt>
lea    -0x80(%rbp),%rdi
lea    -0x80(%rbp),%rsi
lea    -0x90(%rbp),%rdx
call   1060 <Quaternion_Add@plt>
lea    -0x80(%rbp),%rdi
lea    -0x80(%rbp),%rsi
lea    -0x70(%rbp),%rdx
call   1060 <Quaternion_Add@plt>
lea    -0x80(%rbp),%rdi
lea    -0x80(%rbp),%rsi
mov    -0x18(%rbp),%rax
movss  (%rax),%xmm0
movss  0xce5(%rip),%xmm1
divss  %xmm1,%xmm0
call   1050 <Quaternion_Scalar@plt>
mov    -0x8(%rbp),%rdi
mov    -0x8(%rbp),%rsi
lea    -0x80(%rbp),%rdx
call   1060 <Quaternion_Add@plt>
cmpl   $0x0,-0x1c(%rbp)
je     1348 <Quaternion_RungeKutta4+0x208>
mov    -0x8(%rbp),%rdi
call   1030 <Quaternion_Normalize@plt>
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Quaternion_RungeKutta4>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x78,%rsp
mov    %ecx,0x4(%rsp)
mov    %rdx,%rbx
mov    %rsi,%r13
mov    %rdi,%r14
lea    0x20(%rsp),%rbp
mov    %rbp,%rdi
mov    %r14,%rsi
mov    %r13,%rdx
call   1040 <Quaternion_Multiply@plt>
movss  0xe8a(%rip),%xmm0
mov    %rbp,%rdi
mov    %rbp,%rsi
call   1050 <Quaternion_Scalar@plt>
movss  (%rbx),%xmm0
mulss  0xe73(%rip),%xmm0
lea    0x30(%rsp),%r12
mov    %r12,%rdi
mov    %rbp,%rsi
call   1050 <Quaternion_Scalar@plt>
mov    %r12,%rdi
mov    %r14,%rsi
mov    %r12,%rdx
call   1060 <Quaternion_Add@plt>
lea    0x10(%rsp),%rbp
mov    %rbp,%rdi
mov    %r12,%rsi
mov    %r13,%rdx
call   1040 <Quaternion_Multiply@plt>
mov    %rbp,%rdi
mov    %rbp,%rsi
movss  0xe34(%rip),%xmm0
call   1050 <Quaternion_Scalar@plt>
movss  (%rbx),%xmm0
mov    %rbx,0x8(%rsp)
mulss  0xe1e(%rip),%xmm0
mov    %r12,%rdi
mov    %rbp,%rsi
call   1050 <Quaternion_Scalar@plt>
mov    %r12,%rdi
mov    %r14,%rsi
mov    %r12,%rdx
call   1060 <Quaternion_Add@plt>
lea    0x60(%rsp),%r15
mov    %r15,%rdi
mov    %r12,%rsi
mov    %r13,%rdx
call   1040 <Quaternion_Multiply@plt>
mov    %r15,%rdi
mov    %r15,%rsi
movss  0xde4(%rip),%xmm0
call   1050 <Quaternion_Scalar@plt>
movss  (%rbx),%xmm0
mov    %r12,%rdi
mov    %r15,%rsi
call   1050 <Quaternion_Scalar@plt>
mov    %r12,%rdi
mov    %r14,%rsi
mov    %r12,%rdx
call   1060 <Quaternion_Add@plt>
lea    0x50(%rsp),%rbp
mov    %rbp,%rdi
mov    %r12,%rsi
mov    %r13,%rdx
call   1040 <Quaternion_Multiply@plt>
mov    %rbp,%rdi
mov    %rbp,%rsi
movss  0xda1(%rip),%xmm0
call   1050 <Quaternion_Scalar@plt>
movss  0xd98(%rip),%xmm0
mov    %r12,%rdi
lea    0x10(%rsp),%rsi
call   1050 <Quaternion_Scalar@plt>
lea    0x40(%rsp),%rbx
mov    %rbx,%rdi
lea    0x20(%rsp),%rsi
mov    %r12,%rdx
call   1060 <Quaternion_Add@plt>
mov    %r12,%rdi
mov    %r15,%rsi
movss  0xd68(%rip),%xmm0
call   1050 <Quaternion_Scalar@plt>
mov    %rbx,%rdi
mov    %rbx,%rsi
mov    %r12,%rdx
call   1060 <Quaternion_Add@plt>
mov    %rbx,%rdi
mov    %rbx,%rsi
mov    %rbp,%rdx
call   1060 <Quaternion_Add@plt>
mov    0x8(%rsp),%rax
movss  (%rax),%xmm0
divss  0xd3a(%rip),%xmm0
mov    %rbx,%rdi
mov    %rbx,%rsi
call   1050 <Quaternion_Scalar@plt>
mov    %r14,%rdi
mov    %r14,%rsi
mov    %rbx,%rdx
call   1060 <Quaternion_Add@plt>
cmpl   $0x0,0x4(%rsp)
je     12f6 <Quaternion_RungeKutta4+0x1b6>
mov    %r14,%rdi
call   1030 <Quaternion_Normalize@plt>
add    $0x78,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @Quaternion_RungeKutta4(float* %0, float* %1, float* %2, i32 %3) {
%5 = alloca float*
%6 = alloca float*
%7 = alloca float*
%8 = alloca i32
%9 = alloca float
%10 = alloca float
%11 = alloca [4 x float]
%12 = alloca [4 x float]
%13 = alloca [4 x float]
%14 = alloca [4 x float]
%15 = alloca [4 x float]
%16 = alloca [4 x float]
store float* %0, float** %5
store float* %1, float** %6
store float* %2, float** %7
store i32 %3, i32* %8
store float 5.000000e-01, float* %9
store float 2.000000e+00, float* %10
%17 = getelementptr inbounds [4 x float], [4 x float]* %11, i64 0, i64 0
%18 = load float*, float** %5
%19 = load float*, float** %6
%20 = call i32 @Quaternion_Multiply(float* %17, float* %18, float* %19)
%21 = getelementptr inbounds [4 x float], [4 x float]* %11, i64 0, i64 0
%22 = getelementptr inbounds [4 x float], [4 x float]* %11, i64 0, i64 0
%23 = load float, float* %9
%24 = call i32 @Quaternion_Scalar(float* %21, float* %22, float %23)
%25 = getelementptr inbounds [4 x float], [4 x float]* %16, i64 0, i64 0
%26 = getelementptr inbounds [4 x float], [4 x float]* %11, i64 0, i64 0
%27 = load float*, float** %7
%28 = load float, float* %27
%29 = load float, float* %9
%30 = fmul float %28, %29
%31 = call i32 @Quaternion_Scalar(float* %25, float* %26, float %30)
%32 = getelementptr inbounds [4 x float], [4 x float]* %16, i64 0, i64 0
%33 = load float*, float** %5
%34 = getelementptr inbounds [4 x float], [4 x float]* %16, i64 0, i64 0
%35 = call i32 @Quaternion_Add(float* %32, float* %33, float* %34)
%36 = getelementptr inbounds [4 x float], [4 x float]* %12, i64 0, i64 0
%37 = getelementptr inbounds [4 x float], [4 x float]* %16, i64 0, i64 0
%38 = load float*, float** %6
%39 = call i32 @Quaternion_Multiply(float* %36, float* %37, float* %38)
%40 = getelementptr inbounds [4 x float], [4 x float]* %12, i64 0, i64 0
%41 = getelementptr inbounds [4 x float], [4 x float]* %12, i64 0, i64 0
%42 = load float, float* %9
%43 = call i32 @Quaternion_Scalar(float* %40, float* %41, float %42)
%44 = getelementptr inbounds [4 x float], [4 x float]* %16, i64 0, i64 0
%45 = getelementptr inbounds [4 x float], [4 x float]* %12, i64 0, i64 0
%46 = load float*, float** %7
%47 = load float, float* %46
%48 = load float, float* %9
%49 = fmul float %47, %48
%50 = call i32 @Quaternion_Scalar(float* %44, float* %45, float %49)
%51 = getelementptr inbounds [4 x float], [4 x float]* %16, i64 0, i64 0
%52 = load float*, float** %5
%53 = getelementptr inbounds [4 x float], [4 x float]* %16, i64 0, i64 0
%54 = call i32 @Quaternion_Add(float* %51, float* %52, float* %53)
%55 = getelementptr inbounds [4 x float], [4 x float]* %13, i64 0, i64 0
%56 = getelementptr inbounds [4 x float], [4 x float]* %16, i64 0, i64 0
%57 = load float*, float** %6
%58 = call i32 @Quaternion_Multiply(float* %55, float* %56, float* %57)
%59 = getelementptr inbounds [4 x float], [4 x float]* %13, i64 0, i64 0
%60 = getelementptr inbounds [4 x float], [4 x float]* %13, i64 0, i64 0
%61 = load float, float* %9
%62 = call i32 @Quaternion_Scalar(float* %59, float* %60, float %61)
%63 = getelementptr inbounds [4 x float], [4 x float]* %16, i64 0, i64 0
%64 = getelementptr inbounds [4 x float], [4 x float]* %13, i64 0, i64 0
%65 = load float*, float** %7
%66 = load float, float* %65
%67 = call i32 @Quaternion_Scalar(float* %63, float* %64, float %66)
%68 = getelementptr inbounds [4 x float], [4 x float]* %16, i64 0, i64 0
%69 = load float*, float** %5
%70 = getelementptr inbounds [4 x float], [4 x float]* %16, i64 0, i64 0
%71 = call i32 @Quaternion_Add(float* %68, float* %69, float* %70)
%72 = getelementptr inbounds [4 x float], [4 x float]* %14, i64 0, i64 0
%73 = getelementptr inbounds [4 x float], [4 x float]* %16, i64 0, i64 0
%74 = load float*, float** %6
%75 = call i32 @Quaternion_Multiply(float* %72, float* %73, float* %74)
%76 = getelementptr inbounds [4 x float], [4 x float]* %14, i64 0, i64 0
%77 = getelementptr inbounds [4 x float], [4 x float]* %14, i64 0, i64 0
%78 = load float, float* %9
%79 = call i32 @Quaternion_Scalar(float* %76, float* %77, float %78)
%80 = getelementptr inbounds [4 x float], [4 x float]* %16, i64 0, i64 0
%81 = getelementptr inbounds [4 x float], [4 x float]* %12, i64 0, i64 0
%82 = load float, float* %10
%83 = call i32 @Quaternion_Scalar(float* %80, float* %81, float %82)
%84 = getelementptr inbounds [4 x float], [4 x float]* %15, i64 0, i64 0
%85 = getelementptr inbounds [4 x float], [4 x float]* %11, i64 0, i64 0
%86 = getelementptr inbounds [4 x float], [4 x float]* %16, i64 0, i64 0
%87 = call i32 @Quaternion_Add(float* %84, float* %85, float* %86)
%88 = getelementptr inbounds [4 x float], [4 x float]* %16, i64 0, i64 0
%89 = getelementptr inbounds [4 x float], [4 x float]* %13, i64 0, i64 0
%90 = load float, float* %10
%91 = call i32 @Quaternion_Scalar(float* %88, float* %89, float %90)
%92 = getelementptr inbounds [4 x float], [4 x float]* %15, i64 0, i64 0
%93 = getelementptr inbounds [4 x float], [4 x float]* %15, i64 0, i64 0
%94 = getelementptr inbounds [4 x float], [4 x float]* %16, i64 0, i64 0
%95 = call i32 @Quaternion_Add(float* %92, float* %93, float* %94)
%96 = getelementptr inbounds [4 x float], [4 x float]* %15, i64 0, i64 0
%97 = getelementptr inbounds [4 x float], [4 x float]* %15, i64 0, i64 0
%98 = getelementptr inbounds [4 x float], [4 x float]* %14, i64 0, i64 0
%99 = call i32 @Quaternion_Add(float* %96, float* %97, float* %98)
%100 = getelementptr inbounds [4 x float], [4 x float]* %15, i64 0, i64 0
%101 = getelementptr inbounds [4 x float], [4 x float]* %15, i64 0, i64 0
%102 = load float*, float** %7
%103 = load float, float* %102
%104 = fdiv float %103, 6.000000e+00
%105 = call i32 @Quaternion_Scalar(float* %100, float* %101, float %104)
%106 = load float*, float** %5
%107 = load float*, float** %5
%108 = getelementptr inbounds [4 x float], [4 x float]* %15, i64 0, i64 0
%109 = call i32 @Quaternion_Add(float* %106, float* %107, float* %108)
%110 = load i32, i32* %8
%111 = icmp ne i32 %110, 0
br i1 %111, label %112, label %115
112: ; preds = %4
%113 = load float*, float** %5
%114 = call i32 @Quaternion_Normalize(float* %113)
br label %115
115: ; preds = %112, %4
ret void
}

LLVM IR (-O2):
define void @Quaternion_RungeKutta4(float* %0, float* %1, float* nocapture %2, i32 %3) {
%5 = alloca [4 x float]
%6 = alloca [4 x float]
%7 = alloca [4 x float]
%8 = alloca [4 x float]
%9 = alloca [4 x float]
%10 = alloca [4 x float]
%11 = bitcast [4 x float]* %5 to i8*
%12 = bitcast [4 x float]* %6 to i8*
%13 = bitcast [4 x float]* %7 to i8*
%14 = bitcast [4 x float]* %8 to i8*
%15 = bitcast [4 x float]* %9 to i8*
%16 = bitcast [4 x float]* %10 to i8*
%17 = getelementptr inbounds [4 x float], [4 x float]* %5, i64 0, i64 0
%18 = call i32 @Quaternion_Multiply(float* %17, float* %0, float* %1)
%19 = call i32 @Quaternion_Scalar(float* %17, float* %17, float 5.000000e-01)
%20 = getelementptr inbounds [4 x float], [4 x float]* %10, i64 0, i64 0
%21 = load float, float* %2
%22 = fmul float %21, 5.000000e-01
%23 = call i32 @Quaternion_Scalar(float* %20, float* %17, float %22)
%24 = call i32 @Quaternion_Add(float* %20, float* %0, float* %20)
%25 = getelementptr inbounds [4 x float], [4 x float]* %6, i64 0, i64 0
%26 = call i32 @Quaternion_Multiply(float* %25, float* %20, float* %1)
%27 = call i32 @Quaternion_Scalar(float* %25, float* %25, float 5.000000e-01)
%28 = load float, float* %2
%29 = fmul float %28, 5.000000e-01
%30 = call i32 @Quaternion_Scalar(float* %20, float* %25, float %29)
%31 = call i32 @Quaternion_Add(float* %20, float* %0, float* %20)
%32 = getelementptr inbounds [4 x float], [4 x float]* %7, i64 0, i64 0
%33 = call i32 @Quaternion_Multiply(float* %32, float* %20, float* %1)
%34 = call i32 @Quaternion_Scalar(float* %32, float* %32, float 5.000000e-01)
%35 = load float, float* %2
%36 = call i32 @Quaternion_Scalar(float* %20, float* %32, float %35)
%37 = call i32 @Quaternion_Add(float* %20, float* %0, float* %20)
%38 = getelementptr inbounds [4 x float], [4 x float]* %8, i64 0, i64 0
%39 = call i32 @Quaternion_Multiply(float* %38, float* %20, float* %1)
%40 = call i32 @Quaternion_Scalar(float* %38, float* %38, float 5.000000e-01)
%41 = call i32 @Quaternion_Scalar(float* %20, float* %25, float 2.000000e+00)
%42 = getelementptr inbounds [4 x float], [4 x float]* %9, i64 0, i64 0
%43 = call i32 @Quaternion_Add(float* %42, float* %17, float* %20)
%44 = call i32 @Quaternion_Scalar(float* %20, float* %32, float 2.000000e+00)
%45 = call i32 @Quaternion_Add(float* %42, float* %42, float* %20)
%46 = call i32 @Quaternion_Add(float* %42, float* %42, float* %38)
%47 = load float, float* %2
%48 = fdiv float %47, 6.000000e+00
%49 = call i32 @Quaternion_Scalar(float* %42, float* %42, float %48)
%50 = call i32 @Quaternion_Add(float* %0, float* %0, float* %42)
%51 = icmp eq i32 %3, 0
br i1 %51, label %54, label %52
52: ; preds = %4
%53 = call i32 @Quaternion_Normalize(float* %0)
br label %54
54: ; preds = %52, %4
ret void
}