int yas_bma250_read_accel_z(short *data_z) {
  int ret = (0);
  unsigned char reg_address = 0x06;
  unsigned char read_data[2];
  if (yas_bma250_read_reg(reg_address, read_data, 2) != 0) {
    pr_err("%s: read_reg failed!\n", __func__);
  } else {
    *data_z =
        ((read_data[0] & 0xC0) >> 6) | (((read_data[1] & 0xFF) >> 0) << 2);
    *data_z = *data_z << (sizeof(short) * 8 - (2 + 8));
    *data_z = *data_z >> (sizeof(short) * 8 - (2 + 8));
  }
  return ret;
}


x86 assembly (clang, -O0):
<yas_bma250_read_accel_z>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
movb   $0x6,-0xd(%rbp)
movzbl -0xd(%rbp),%edi
lea    -0xf(%rbp),%rsi
mov    $0x2,%edx
mov    $0x0,%al
call   1030 <yas_bma250_read_reg@plt>
cmp    $0x0,%eax
je     116e <yas_bma250_read_accel_z+0x4e>
lea    0xea5(%rip),%rdi
lea    0xeb4(%rip),%rsi
mov    $0x0,%al
call   1040 <pr_err@plt>
jmp    11be <yas_bma250_read_accel_z+0x9e>
movzbl -0xf(%rbp),%eax
and    $0xc0,%eax
sar    $0x6,%eax
movzbl -0xe(%rbp),%ecx
and    $0xff,%ecx
sar    $0x0,%ecx
shl    $0x2,%ecx
or     %ecx,%eax
mov    %ax,%cx
mov    -0x8(%rbp),%rax
mov    %cx,(%rax)
mov    -0x8(%rbp),%rax
movswl (%rax),%eax
shl    $0x6,%eax
mov    %ax,%cx
mov    -0x8(%rbp),%rax
mov    %cx,(%rax)
mov    -0x8(%rbp),%rax
movswl (%rax),%eax
sar    $0x6,%eax
mov    %ax,%cx
mov    -0x8(%rbp),%rax
mov    %cx,(%rax)
mov    -0xc(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<yas_bma250_read_accel_z>:
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%rbx
lea    0xe(%rsp),%rsi
mov    $0x6,%edi
mov    $0x2,%edx
xor    %eax,%eax
call   1030 <yas_bma250_read_reg@plt>
test   %eax,%eax
je     1159 <yas_bma250_read_accel_z+0x39>
lea    0xeb7(%rip),%rdi
lea    0xec6(%rip),%rsi
xor    %eax,%eax
call   1040 <pr_err@plt>
jmp    1164 <yas_bma250_read_accel_z+0x44>
movswl 0xe(%rsp),%eax
shr    $0x6,%eax
mov    %ax,(%rbx)
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [22 x i8] c"%s: read_reg failed!\0A\00"
@__func__.yas_bma250_read_accel_z = [24 x i8] c"yas_bma250_read_accel_z\00"
define i32 @yas_bma250_read_accel_z(i16* %0) {
%2 = alloca i16*
%3 = alloca i32
%4 = alloca i8
%5 = alloca [2 x i8]
store i16* %0, i16** %2
store i32 0, i32* %3
store i8 6, i8* %4
%6 = load i8, i8* %4
%7 = zext i8 %6 to i32
%8 = getelementptr inbounds [2 x i8], [2 x i8]* %5, i64 0, i64 0
%9 = call i32 (i32, i8*, i32, ...) bitcast (i32 (...)* @yas_bma250_read_reg to i32 (i32, i8*, i32, ...)*)(i32 %7, i8* %8, i32 2)
%10 = icmp ne i32 %9, 0
br i1 %10, label %11, label %13
11: ; preds = %1
%12 = call i32 (i8*, i8*, ...) bitcast (i32 (...)* @pr_err to i32 (i8*, i8*, ...)*)(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([24 x i8], [24 x i8]* @__func__.yas_bma250_read_accel_z, i64 0, i64 0))
br label %40
13: ; preds = %1
%14 = getelementptr inbounds [2 x i8], [2 x i8]* %5, i64 0, i64 0
%15 = load i8, i8* %14
%16 = zext i8 %15 to i32
%17 = and i32 %16, 192
%18 = ashr i32 %17, 6
%19 = getelementptr inbounds [2 x i8], [2 x i8]* %5, i64 0, i64 1
%20 = load i8, i8* %19
%21 = zext i8 %20 to i32
%22 = and i32 %21, 255
%23 = ashr i32 %22, 0
%24 = shl i32 %23, 2
%25 = or i32 %18, %24
%26 = trunc i32 %25 to i16
%27 = load i16*, i16** %2
store i16 %26, i16* %27
%28 = load i16*, i16** %2
%29 = load i16, i16* %28
%30 = sext i16 %29 to i32
%31 = shl i32 %30, 6
%32 = trunc i32 %31 to i16
%33 = load i16*, i16** %2
store i16 %32, i16* %33
%34 = load i16*, i16** %2
%35 = load i16, i16* %34
%36 = sext i16 %35 to i32
%37 = ashr i32 %36, 6
%38 = trunc i32 %37 to i16
%39 = load i16*, i16** %2
store i16 %38, i16* %39
br label %40
40: ; preds = %13, %11
%41 = load i32, i32* %3
ret i32 %41
}

LLVM IR (-O2):
@.str = [22 x i8] c"%s: read_reg failed!\0A\00"
@__func__.yas_bma250_read_accel_z = [24 x i8] c"yas_bma250_read_accel_z\00"
define i32 @yas_bma250_read_accel_z(i16* nocapture writeonly %0) {
%2 = alloca [2 x i8]
%3 = getelementptr inbounds [2 x i8], [2 x i8]* %2, i64 0, i64 0
%4 = call i32 (i32, i8*, i32, ...) bitcast (i32 (...)* @yas_bma250_read_reg to i32 (i32, i8*, i32, ...)*)(i32 6, i8* %3, i32 2)
%5 = icmp eq i32 %4, 0
br i1 %5, label %8, label %6
6: ; preds = %1
%7 = call i32 (i8*, i8*, ...) bitcast (i32 (...)* @pr_err to i32 (i8*, i8*, ...)*)(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([24 x i8], [24 x i8]* @__func__.yas_bma250_read_accel_z, i64 0, i64 0))
br label %17
8: ; preds = %1
%9 = load i8, i8* %3
%10 = getelementptr inbounds [2 x i8], [2 x i8]* %2, i64 0, i64 1
%11 = load i8, i8* %10
%12 = zext i8 %11 to i16
%13 = shl nuw i16 %12, 8
%14 = zext i8 %9 to i16
%15 = or i16 %13, %14
%16 = ashr i16 %15, 6
store i16 %16, i16* %0
br label %17
17: ; preds = %8, %6
ret i32 0
}