#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 */
typedef int /*<<< orphan*/ uint8_t;
typedef int /*<<< orphan*/ uint16_t;
typedef int /*<<< orphan*/ quat;
typedef int /*<<< orphan*/ prec;
typedef int int32_t;
typedef int int16_t;

/* Variables and functions */
int /*<<< orphan*/ FifoProtocol_memcpy(int *, int /*<<< orphan*/ const *, int);
void inv_fifo_protocol_helper_decode_q30_quat(const void *in, uint16_t len,
                                              float *x, float *y, float *z,
                                              float *w, float *a) {
  const uint8_t *buf = (const uint8_t *)in;
  int32_t quat;
  int16_t prec;
  FifoProtocol_memcpy((&quat), (&buf[0]), (sizeof(quat) - 1));
  *x = ((float)(int32_t)(quat << 8) / (float)(1ULL << (30)));
  FifoProtocol_memcpy((&quat), (&buf[3]), (sizeof(quat) - 1));
  *y = ((float)(int32_t)(quat << 8) / (float)(1ULL << (30)));
  FifoProtocol_memcpy((&quat), (&buf[6]), (sizeof(quat) - 1));
  *z = ((float)(int32_t)(quat << 8) / (float)(1ULL << (30)));
  FifoProtocol_memcpy((&quat), (&buf[9]), (sizeof(quat) - 1));
  *w = ((float)(int32_t)(quat << 8) / (float)(1ULL << (30)));
  if (a) {
    FifoProtocol_memcpy((&prec), (&buf[12]), (sizeof(prec)));
    *a = ((float)(int16_t)(prec) / (float)(1ULL << (6)));
  }
  (void)len;
}


x86 assembly (clang, -O0):
<inv_fifo_protocol_helper_decode_q30_quat>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    0x10(%rbp),%rax
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    %r9,-0x30(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rsi
lea    -0x3c(%rbp),%rdi
mov    $0x3,%edx
call   1030 <FifoProtocol_memcpy@plt>
mov    -0x3c(%rbp),%eax
shl    $0x8,%eax
cvtsi2ss %eax,%xmm0
movss  0xea1(%rip),%xmm1
divss  %xmm1,%xmm0
mov    -0x18(%rbp),%rax
movss  %xmm0,(%rax)
mov    -0x38(%rbp),%rsi
add    $0xc,%rsi
lea    -0x3c(%rbp),%rdi
mov    $0x3,%edx
call   1030 <FifoProtocol_memcpy@plt>
mov    -0x3c(%rbp),%eax
shl    $0x8,%eax
cvtsi2ss %eax,%xmm0
movss  0xe6d(%rip),%xmm1
divss  %xmm1,%xmm0
mov    -0x20(%rbp),%rax
movss  %xmm0,(%rax)
mov    -0x38(%rbp),%rsi
add    $0x18,%rsi
lea    -0x3c(%rbp),%rdi
mov    $0x3,%edx
call   1030 <FifoProtocol_memcpy@plt>
mov    -0x3c(%rbp),%eax
shl    $0x8,%eax
cvtsi2ss %eax,%xmm0
movss  0xe39(%rip),%xmm1
divss  %xmm1,%xmm0
mov    -0x28(%rbp),%rax
movss  %xmm0,(%rax)
mov    -0x38(%rbp),%rsi
add    $0x24,%rsi
lea    -0x3c(%rbp),%rdi
mov    $0x3,%edx
call   1030 <FifoProtocol_memcpy@plt>
mov    -0x3c(%rbp),%eax
shl    $0x8,%eax
cvtsi2ss %eax,%xmm0
movss  0xe05(%rip),%xmm1
divss  %xmm1,%xmm0
mov    -0x30(%rbp),%rax
movss  %xmm0,(%rax)
cmpq   $0x0,0x10(%rbp)
je     1241 <inv_fifo_protocol_helper_decode_q30_quat+0x131>
mov    -0x38(%rbp),%rsi
add    $0x30,%rsi
lea    -0x40(%rbp),%rdi
mov    $0x4,%edx
call   1030 <FifoProtocol_memcpy@plt>
cvtsi2ssl -0x40(%rbp),%xmm0
movss  0xdcf(%rip),%xmm1
divss  %xmm1,%xmm0
mov    0x10(%rbp),%rax
movss  %xmm0,(%rax)
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<inv_fifo_protocol_helper_decode_q30_quat>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %r9,%r14
mov    %r8,%r15
mov    %rcx,%r13
mov    %rdx,%rbp
mov    %rdi,%rbx
mov    %rsp,%r12
mov    %r12,%rdi
mov    %rbx,%rsi
mov    $0x3,%edx
call   1030 <FifoProtocol_memcpy@plt>
mov    (%rsp),%eax
shl    $0x8,%eax
cvtsi2ss %eax,%xmm0
mulss  0xeb1(%rip),%xmm0
movss  %xmm0,0x0(%rbp)
lea    0xc(%rbx),%rsi
mov    %r12,%rdi
mov    $0x3,%edx
call   1030 <FifoProtocol_memcpy@plt>
mov    (%rsp),%eax
shl    $0x8,%eax
xorps  %xmm0,%xmm0
cvtsi2ss %eax,%xmm0
mulss  0xe86(%rip),%xmm0
movss  %xmm0,0x0(%r13)
lea    0x18(%rbx),%rsi
mov    %r12,%rdi
mov    $0x3,%edx
call   1030 <FifoProtocol_memcpy@plt>
mov    (%rsp),%eax
shl    $0x8,%eax
xorps  %xmm0,%xmm0
cvtsi2ss %eax,%xmm0
mulss  0xe5a(%rip),%xmm0
movss  %xmm0,(%r15)
lea    0x24(%rbx),%rsi
mov    %r12,%rdi
mov    $0x3,%edx
call   1030 <FifoProtocol_memcpy@plt>
mov    (%rsp),%eax
shl    $0x8,%eax
xorps  %xmm0,%xmm0
cvtsi2ss %eax,%xmm0
mulss  0xe2f(%rip),%xmm0
movss  %xmm0,(%r14)
mov    0x40(%rsp),%rbp
test   %rbp,%rbp
je     120c <inv_fifo_protocol_helper_decode_q30_quat+0xfc>
add    $0x30,%rbx
lea    0x4(%rsp),%rdi
mov    %rbx,%rsi
mov    $0x4,%edx
call   1030 <FifoProtocol_memcpy@plt>
xorps  %xmm0,%xmm0
cvtsi2ssl 0x4(%rsp),%xmm0
mulss  0xdfd(%rip),%xmm0
movss  %xmm0,0x0(%rbp)
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @inv_fifo_protocol_helper_decode_q30_quat(i8* %0, i32 %1, float* %2, float* %3, float* %4, float* %5, float* %6) {
%8 = alloca i8*
%9 = alloca i32
%10 = alloca float*
%11 = alloca float*
%12 = alloca float*
%13 = alloca float*
%14 = alloca float*
%15 = alloca i32*
%16 = alloca i32
%17 = alloca i32
store i8* %0, i8** %8
store i32 %1, i32* %9
store float* %2, float** %10
store float* %3, float** %11
store float* %4, float** %12
store float* %5, float** %13
store float* %6, float** %14
%18 = load i8*, i8** %8
%19 = bitcast i8* %18 to i32*
store i32* %19, i32** %15
%20 = load i32*, i32** %15
%21 = getelementptr inbounds i32, i32* %20, i64 0
%22 = call i32 @FifoProtocol_memcpy(i32* %16, i32* %21, i32 3)
%23 = load i32, i32* %16
%24 = shl i32 %23, 8
%25 = sitofp i32 %24 to float
%26 = fdiv float %25, 0x41D0000000000000
%27 = load float*, float** %10
store float %26, float* %27
%28 = load i32*, i32** %15
%29 = getelementptr inbounds i32, i32* %28, i64 3
%30 = call i32 @FifoProtocol_memcpy(i32* %16, i32* %29, i32 3)
%31 = load i32, i32* %16
%32 = shl i32 %31, 8
%33 = sitofp i32 %32 to float
%34 = fdiv float %33, 0x41D0000000000000
%35 = load float*, float** %11
store float %34, float* %35
%36 = load i32*, i32** %15
%37 = getelementptr inbounds i32, i32* %36, i64 6
%38 = call i32 @FifoProtocol_memcpy(i32* %16, i32* %37, i32 3)
%39 = load i32, i32* %16
%40 = shl i32 %39, 8
%41 = sitofp i32 %40 to float
%42 = fdiv float %41, 0x41D0000000000000
%43 = load float*, float** %12
store float %42, float* %43
%44 = load i32*, i32** %15
%45 = getelementptr inbounds i32, i32* %44, i64 9
%46 = call i32 @FifoProtocol_memcpy(i32* %16, i32* %45, i32 3)
%47 = load i32, i32* %16
%48 = shl i32 %47, 8
%49 = sitofp i32 %48 to float
%50 = fdiv float %49, 0x41D0000000000000
%51 = load float*, float** %13
store float %50, float* %51
%52 = load float*, float** %14
%53 = icmp ne float* %52, null
br i1 %53, label %54, label %62
54: ; preds = %7
%55 = load i32*, i32** %15
%56 = getelementptr inbounds i32, i32* %55, i64 12
%57 = call i32 @FifoProtocol_memcpy(i32* %17, i32* %56, i32 4)
%58 = load i32, i32* %17
%59 = sitofp i32 %58 to float
%60 = fdiv float %59, 6.400000e+01
%61 = load float*, float** %14
store float %60, float* %61
br label %62
62: ; preds = %54, %7
%63 = load i32, i32* %9
ret void
}

LLVM IR (-O2):
define void @inv_fifo_protocol_helper_decode_q30_quat(i8* %0, i32 %1, float* nocapture writeonly %2, float* nocapture writeonly %3, float* nocapture writeonly %4, float* nocapture writeonly %5, float* writeonly %6) {
%8 = alloca i32
%9 = alloca i32
%10 = bitcast i8* %0 to i32*
%11 = bitcast i32* %8 to i8*
%12 = bitcast i32* %9 to i8*
%13 = call i32 @FifoProtocol_memcpy(i32* %8, i32* %10, i32 3)
%14 = load i32, i32* %8
%15 = shl i32 %14, 8
%16 = sitofp i32 %15 to float
%17 = fmul float %16, 0x3E10000000000000
store float %17, float* %2
%18 = getelementptr inbounds i8, i8* %0, i64 12
%19 = bitcast i8* %18 to i32*
%20 = call i32 @FifoProtocol_memcpy(i32* %8, i32* %19, i32 3)
%21 = load i32, i32* %8
%22 = shl i32 %21, 8
%23 = sitofp i32 %22 to float
%24 = fmul float %23, 0x3E10000000000000
store float %24, float* %3
%25 = getelementptr inbounds i8, i8* %0, i64 24
%26 = bitcast i8* %25 to i32*
%27 = call i32 @FifoProtocol_memcpy(i32* %8, i32* %26, i32 3)
%28 = load i32, i32* %8
%29 = shl i32 %28, 8
%30 = sitofp i32 %29 to float
%31 = fmul float %30, 0x3E10000000000000
store float %31, float* %4
%32 = getelementptr inbounds i8, i8* %0, i64 36
%33 = bitcast i8* %32 to i32*
%34 = call i32 @FifoProtocol_memcpy(i32* %8, i32* %33, i32 3)
%35 = load i32, i32* %8
%36 = shl i32 %35, 8
%37 = sitofp i32 %36 to float
%38 = fmul float %37, 0x3E10000000000000
store float %38, float* %5
%39 = icmp eq float* %6, null
br i1 %39, label %47, label %40
40: ; preds = %7
%41 = getelementptr inbounds i8, i8* %0, i64 48
%42 = bitcast i8* %41 to i32*
%43 = call i32 @FifoProtocol_memcpy(i32* %9, i32* %42, i32 4)
%44 = load i32, i32* %9
%45 = sitofp i32 %44 to float
%46 = fmul float %45, 1.562500e-02
store float %46, float* %6
br label %47
47: ; preds = %40, %7
ret void
}