#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*/ mag;
typedef scalar_t__ int16_t;

/* Variables and functions */
int /*<<< orphan*/ FifoProtocol_memcpy(scalar_t__ *, int /*<<< orphan*/ const *,
                                       int);
void inv_fifo_protocol_helper_decode_mag_data(const void *in, uint16_t len,
                                              float *x, float *y, float *z) {
  const uint8_t *buf = (const uint8_t *)in;
  int16_t mag;
  FifoProtocol_memcpy((&mag), (&buf[0]), (sizeof(mag)));
  *x = ((float)(int16_t)(mag) / (float)(1ULL << (4)));
  FifoProtocol_memcpy((&mag), (&buf[2]), (sizeof(mag)));
  *y = ((float)(int16_t)(mag) / (float)(1ULL << (4)));
  FifoProtocol_memcpy((&mag), (&buf[4]), (sizeof(mag)));
  *z = ((float)(int16_t)(mag) / (float)(1ULL << (4)));
  (void)len;
}


x86 assembly (clang, -O0):
<inv_fifo_protocol_helper_decode_mag_data>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rsi
lea    -0x38(%rbp),%rdi
mov    $0x8,%edx
call   1030 <FifoProtocol_memcpy@plt>
cvtsi2ssq -0x38(%rbp),%xmm0
movss  0xead(%rip),%xmm1
divss  %xmm1,%xmm0
mov    -0x18(%rbp),%rax
movss  %xmm0,(%rax)
mov    -0x30(%rbp),%rsi
add    $0x8,%rsi
lea    -0x38(%rbp),%rdi
mov    $0x8,%edx
call   1030 <FifoProtocol_memcpy@plt>
cvtsi2ssq -0x38(%rbp),%xmm0
movss  0xe7d(%rip),%xmm1
divss  %xmm1,%xmm0
mov    -0x20(%rbp),%rax
movss  %xmm0,(%rax)
mov    -0x30(%rbp),%rsi
add    $0x10,%rsi
lea    -0x38(%rbp),%rdi
mov    $0x8,%edx
call   1030 <FifoProtocol_memcpy@plt>
cvtsi2ssq -0x38(%rbp),%xmm0
movss  0xe4d(%rip),%xmm1
divss  %xmm1,%xmm0
mov    -0x28(%rbp),%rax
movss  %xmm0,(%rax)
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<inv_fifo_protocol_helper_decode_mag_data>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x10,%rsp
mov    %r8,%r14
mov    %rcx,%r15
mov    %rdx,%r12
mov    %rdi,%rbx
lea    0x8(%rsp),%r13
mov    %r13,%rdi
mov    %rbx,%rsi
mov    $0x8,%edx
call   1030 <FifoProtocol_memcpy@plt>
cvtsi2ssq 0x8(%rsp),%xmm0
mulss  0xeb3(%rip),%xmm0
movss  %xmm0,(%r12)
lea    0x8(%rbx),%rsi
mov    %r13,%rdi
mov    $0x8,%edx
call   1030 <FifoProtocol_memcpy@plt>
xorps  %xmm0,%xmm0
cvtsi2ssq 0x8(%rsp),%xmm0
mulss  0xe8a(%rip),%xmm0
movss  %xmm0,(%r15)
add    $0x10,%rbx
mov    %r13,%rdi
mov    %rbx,%rsi
mov    $0x8,%edx
call   1030 <FifoProtocol_memcpy@plt>
xorps  %xmm0,%xmm0
cvtsi2ssq 0x8(%rsp),%xmm0
mulss  0xe5f(%rip),%xmm0
movss  %xmm0,(%r14)
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @inv_fifo_protocol_helper_decode_mag_data(i8* %0, i32 %1, float* %2, float* %3, float* %4) {
%6 = alloca i8*
%7 = alloca i32
%8 = alloca float*
%9 = alloca float*
%10 = alloca float*
%11 = alloca i32*
%12 = alloca i64
store i8* %0, i8** %6
store i32 %1, i32* %7
store float* %2, float** %8
store float* %3, float** %9
store float* %4, float** %10
%13 = load i8*, i8** %6
%14 = bitcast i8* %13 to i32*
store i32* %14, i32** %11
%15 = load i32*, i32** %11
%16 = getelementptr inbounds i32, i32* %15, i64 0
%17 = call i32 @FifoProtocol_memcpy(i64* %12, i32* %16, i32 8)
%18 = load i64, i64* %12
%19 = sitofp i64 %18 to float
%20 = fdiv float %19, 1.600000e+01
%21 = load float*, float** %8
store float %20, float* %21
%22 = load i32*, i32** %11
%23 = getelementptr inbounds i32, i32* %22, i64 2
%24 = call i32 @FifoProtocol_memcpy(i64* %12, i32* %23, i32 8)
%25 = load i64, i64* %12
%26 = sitofp i64 %25 to float
%27 = fdiv float %26, 1.600000e+01
%28 = load float*, float** %9
store float %27, float* %28
%29 = load i32*, i32** %11
%30 = getelementptr inbounds i32, i32* %29, i64 4
%31 = call i32 @FifoProtocol_memcpy(i64* %12, i32* %30, i32 8)
%32 = load i64, i64* %12
%33 = sitofp i64 %32 to float
%34 = fdiv float %33, 1.600000e+01
%35 = load float*, float** %10
store float %34, float* %35
%36 = load i32, i32* %7
ret void
}

LLVM IR (-O2):
define void @inv_fifo_protocol_helper_decode_mag_data(i8* %0, i32 %1, float* nocapture writeonly %2, float* nocapture writeonly %3, float* nocapture writeonly %4) {
%6 = alloca i64
%7 = bitcast i8* %0 to i32*
%8 = bitcast i64* %6 to i8*
%9 = call i32 @FifoProtocol_memcpy(i64* %6, i32* %7, i32 8)
%10 = load i64, i64* %6
%11 = sitofp i64 %10 to float
%12 = fmul float %11, 6.250000e-02
store float %12, float* %2
%13 = getelementptr inbounds i8, i8* %0, i64 8
%14 = bitcast i8* %13 to i32*
%15 = call i32 @FifoProtocol_memcpy(i64* %6, i32* %14, i32 8)
%16 = load i64, i64* %6
%17 = sitofp i64 %16 to float
%18 = fmul float %17, 6.250000e-02
store float %18, float* %3
%19 = getelementptr inbounds i8, i8* %0, i64 16
%20 = bitcast i8* %19 to i32*
%21 = call i32 @FifoProtocol_memcpy(i64* %6, i32* %20, i32 8)
%22 = load i64, i64* %6
%23 = sitofp i64 %22 to float
%24 = fmul float %23, 6.250000e-02
store float %24, float* %4
ret void
}