#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 */
struct inv_sysfs_names_s {
  int dummy;
};

/* Variables and functions */
int inv_read_raw(struct inv_sysfs_names_s const *, long *, long long *);
scalar_t__ inv_read_scale(struct inv_sysfs_names_s const *, float *);
int inv_read_q16(const struct inv_sysfs_names_s *names, long *data,
                 long long *timestamp) {
  int count;
  short raw[3];
  float scale;
  count = inv_read_raw(names, (long *)raw, timestamp);
  count += inv_read_scale(names, &scale);
  data[0] = (long)(raw[0] * (65536.f / scale));
  data[1] = (long)(raw[1] * (65536.f / scale));
  data[2] = (long)(raw[2] * (65536.f / scale));
  return count;
}


x86 assembly (clang, -O0):
<inv_read_q16>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
lea    -0x22(%rbp),%rsi
mov    -0x18(%rbp),%rdx
call   1040 <inv_read_raw@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x8(%rbp),%rdi
lea    -0x28(%rbp),%rsi
call   1030 <inv_read_scale@plt>
mov    %rax,%rcx
movslq -0x1c(%rbp),%rax
add    %rcx,%rax
mov    %eax,-0x1c(%rbp)
movswl -0x22(%rbp),%eax
cvtsi2ss %eax,%xmm0
movss  0xe8e(%rip),%xmm1
divss  -0x28(%rbp),%xmm1
mulss  %xmm1,%xmm0
cvttss2si %xmm0,%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,(%rax)
movswl -0x20(%rbp),%eax
cvtsi2ss %eax,%xmm0
movss  0xe69(%rip),%xmm1
divss  -0x28(%rbp),%xmm1
mulss  %xmm1,%xmm0
cvttss2si %xmm0,%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,0x8(%rax)
movswl -0x1e(%rbp),%eax
cvtsi2ss %eax,%xmm0
movss  0xe43(%rip),%xmm1
divss  -0x28(%rbp),%xmm1
mulss  %xmm1,%xmm0
cvttss2si %xmm0,%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,0x10(%rax)
mov    -0x1c(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<inv_read_q16>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rsi,%r14
mov    %rdi,%rbx
lea    0x6(%rsp),%rsi
call   1040 <inv_read_raw@plt>
mov    %eax,%ebp
lea    0xc(%rsp),%rsi
mov    %rbx,%rdi
call   1030 <inv_read_scale@plt>
movswl 0x6(%rsp),%ecx
cvtsi2ss %ecx,%xmm0
add    %ebp,%eax
movss  0xea6(%rip),%xmm1
divss  0xc(%rsp),%xmm1
mulss  %xmm1,%xmm0
cvttss2si %xmm0,%rcx
mov    %rcx,(%r14)
movswl 0x8(%rsp),%ecx
xorps  %xmm0,%xmm0
cvtsi2ss %ecx,%xmm0
mulss  %xmm1,%xmm0
cvttss2si %xmm0,%rcx
mov    %rcx,0x8(%r14)
movswl 0xa(%rsp),%ecx
xorps  %xmm0,%xmm0
cvtsi2ss %ecx,%xmm0
mulss  %xmm1,%xmm0
cvttss2si %xmm0,%rcx
mov    %rcx,0x10(%r14)
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
%struct.inv_sysfs_names_s = type { i32 }
define i32 @inv_read_q16(%struct.inv_sysfs_names_s* %0, i64* %1, i64* %2) {
%4 = alloca %struct.inv_sysfs_names_s*
%5 = alloca i64*
%6 = alloca i64*
%7 = alloca i32
%8 = alloca [3 x i16]
%9 = alloca float
store %struct.inv_sysfs_names_s* %0, %struct.inv_sysfs_names_s** %4
store i64* %1, i64** %5
store i64* %2, i64** %6
%10 = load %struct.inv_sysfs_names_s*, %struct.inv_sysfs_names_s** %4
%11 = getelementptr inbounds [3 x i16], [3 x i16]* %8, i64 0, i64 0
%12 = bitcast i16* %11 to i64*
%13 = load i64*, i64** %6
%14 = call i32 @inv_read_raw(%struct.inv_sysfs_names_s* %10, i64* %12, i64* %13)
store i32 %14, i32* %7
%15 = load %struct.inv_sysfs_names_s*, %struct.inv_sysfs_names_s** %4
%16 = call i64 @inv_read_scale(%struct.inv_sysfs_names_s* %15, float* %9)
%17 = load i32, i32* %7
%18 = sext i32 %17 to i64
%19 = add nsw i64 %18, %16
%20 = trunc i64 %19 to i32
store i32 %20, i32* %7
%21 = getelementptr inbounds [3 x i16], [3 x i16]* %8, i64 0, i64 0
%22 = load i16, i16* %21
%23 = sext i16 %22 to i32
%24 = sitofp i32 %23 to float
%25 = load float, float* %9
%26 = fdiv float 6.553600e+04, %25
%27 = fmul float %24, %26
%28 = fptosi float %27 to i64
%29 = load i64*, i64** %5
%30 = getelementptr inbounds i64, i64* %29, i64 0
store i64 %28, i64* %30
%31 = getelementptr inbounds [3 x i16], [3 x i16]* %8, i64 0, i64 1
%32 = load i16, i16* %31
%33 = sext i16 %32 to i32
%34 = sitofp i32 %33 to float
%35 = load float, float* %9
%36 = fdiv float 6.553600e+04, %35
%37 = fmul float %34, %36
%38 = fptosi float %37 to i64
%39 = load i64*, i64** %5
%40 = getelementptr inbounds i64, i64* %39, i64 1
store i64 %38, i64* %40
%41 = getelementptr inbounds [3 x i16], [3 x i16]* %8, i64 0, i64 2
%42 = load i16, i16* %41
%43 = sext i16 %42 to i32
%44 = sitofp i32 %43 to float
%45 = load float, float* %9
%46 = fdiv float 6.553600e+04, %45
%47 = fmul float %44, %46
%48 = fptosi float %47 to i64
%49 = load i64*, i64** %5
%50 = getelementptr inbounds i64, i64* %49, i64 2
store i64 %48, i64* %50
%51 = load i32, i32* %7
ret i32 %51
}

LLVM IR (-O2):
%struct.inv_sysfs_names_s = type { i32 }
define i32 @inv_read_q16(%struct.inv_sysfs_names_s* %0, i64* nocapture writeonly %1, i64* %2) {
%4 = alloca [3 x i16]
%5 = alloca float
%6 = bitcast [3 x i16]* %4 to i8*
%7 = bitcast float* %5 to i8*
%8 = getelementptr inbounds [3 x i16], [3 x i16]* %4, i64 0, i64 0
%9 = bitcast [3 x i16]* %4 to i64*
%10 = call i32 @inv_read_raw(%struct.inv_sysfs_names_s* %0, i64* %9, i64* %2)
%11 = call i64 @inv_read_scale(%struct.inv_sysfs_names_s* %0, float* %5)
%12 = trunc i64 %11 to i32
%13 = add i32 %10, %12
%14 = load i16, i16* %8
%15 = sitofp i16 %14 to float
%16 = load float, float* %5
%17 = fdiv float 6.553600e+04, %16
%18 = fmul float %17, %15
%19 = fptosi float %18 to i64
store i64 %19, i64* %1
%20 = getelementptr inbounds [3 x i16], [3 x i16]* %4, i64 0, i64 1
%21 = load i16, i16* %20
%22 = sitofp i16 %21 to float
%23 = fmul float %17, %22
%24 = fptosi float %23 to i64
%25 = getelementptr inbounds i64, i64* %1, i64 1
store i64 %24, i64* %25
%26 = getelementptr inbounds [3 x i16], [3 x i16]* %4, i64 0, i64 2
%27 = load i16, i16* %26
%28 = sitofp i16 %27 to float
%29 = fmul float %17, %28
%30 = fptosi float %29 to i64
%31 = getelementptr inbounds i64, i64* %1, i64 2
store i64 %30, i64* %31
ret i32 %13
}