#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 */
float NormofMatrix(float *, unsigned int *);
void Rodrigues(const float *rodrigus, float *quat) {
  unsigned int rodrigusSize[2] = {3, 1};
  float norm = NormofMatrix((float *)rodrigus, rodrigusSize);
  *(quat) = norm;
  *(quat + 1) = (*(rodrigus)) / norm;
  *(quat + 2) = (*(rodrigus + 1)) / norm;
  *(quat + 3) = (*(rodrigus + 2)) / norm;
}


x86 assembly (clang, -O0):
<Rodrigues>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0xed9(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
lea    -0x18(%rbp),%rsi
call   1030 <NormofMatrix@plt>
movss  %xmm0,-0x1c(%rbp)
movss  -0x1c(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movss  %xmm0,(%rax)
mov    -0x8(%rbp),%rax
movss  (%rax),%xmm0
divss  -0x1c(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movss  %xmm0,0x4(%rax)
mov    -0x8(%rbp),%rax
movss  0x4(%rax),%xmm0
divss  -0x1c(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movss  %xmm0,0x8(%rax)
mov    -0x8(%rbp),%rax
movss  0x8(%rax),%xmm0
divss  -0x1c(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movss  %xmm0,0xc(%rax)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Rodrigues>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
movabs $0x100000003,%rax
mov    %rax,(%rsp)
mov    %rsp,%rsi
call   1030 <NormofMatrix@plt>
movss  %xmm0,(%r14)
movss  (%rbx),%xmm1
divss  %xmm0,%xmm1
movss  %xmm1,0x4(%r14)
movss  0x4(%rbx),%xmm1
divss  %xmm0,%xmm1
movss  %xmm1,0x8(%r14)
movss  0x8(%rbx),%xmm1
divss  %xmm0,%xmm1
movss  %xmm1,0xc(%r14)
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@__const.Rodrigues.rodrigusSize = [2 x i32] [i32 3, i32 1]
define void @Rodrigues(float* %0, float* %1) {
%3 = alloca float*
%4 = alloca float*
%5 = alloca [2 x i32]
%6 = alloca float
store float* %0, float** %3
store float* %1, float** %4
%7 = bitcast [2 x i32]* %5 to i8*
%8 = load float*, float** %3
%9 = getelementptr inbounds [2 x i32], [2 x i32]* %5, i64 0, i64 0
%10 = call float @NormofMatrix(float* %8, i32* %9)
store float %10, float* %6
%11 = load float, float* %6
%12 = load float*, float** %4
store float %11, float* %12
%13 = load float*, float** %3
%14 = load float, float* %13
%15 = load float, float* %6
%16 = fdiv float %14, %15
%17 = load float*, float** %4
%18 = getelementptr inbounds float, float* %17, i64 1
store float %16, float* %18
%19 = load float*, float** %3
%20 = getelementptr inbounds float, float* %19, i64 1
%21 = load float, float* %20
%22 = load float, float* %6
%23 = fdiv float %21, %22
%24 = load float*, float** %4
%25 = getelementptr inbounds float, float* %24, i64 2
store float %23, float* %25
%26 = load float*, float** %3
%27 = getelementptr inbounds float, float* %26, i64 2
%28 = load float, float* %27
%29 = load float, float* %6
%30 = fdiv float %28, %29
%31 = load float*, float** %4
%32 = getelementptr inbounds float, float* %31, i64 3
store float %30, float* %32
ret void
}

LLVM IR (-O2):
define void @Rodrigues(float* %0, float* nocapture writeonly %1) {
%3 = alloca i64
%4 = bitcast i64* %3 to i8*
store i64 4294967299, i64* %3
%5 = bitcast i64* %3 to i32*
%6 = call float @NormofMatrix(float* %0, i32* %5)
store float %6, float* %1
%7 = load float, float* %0
%8 = fdiv float %7, %6
%9 = getelementptr inbounds float, float* %1, i64 1
store float %8, float* %9
%10 = getelementptr inbounds float, float* %0, i64 1
%11 = load float, float* %10
%12 = fdiv float %11, %6
%13 = getelementptr inbounds float, float* %1, i64 2
store float %12, float* %13
%14 = getelementptr inbounds float, float* %0, i64 2
%15 = load float, float* %14
%16 = fdiv float %15, %6
%17 = getelementptr inbounds float, float* %1, i64 3
store float %16, float* %17
ret void
}