#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;
struct inv_icm30xxx {
  int dummy;
};

/* Variables and functions */
int inv_icm30xxx_read_reg_one(struct inv_icm30xxx *, int /*<<< orphan*/,
                              int /*<<< orphan*/, int /*<<< orphan*/ *);
int inv_icm30xxx_get_reg_bits(struct inv_icm30xxx *s, uint8_t bank, uint8_t reg,
                              uint8_t bits_mask, uint8_t *bits_mask_state) {
  int rc;
  if ((rc = inv_icm30xxx_read_reg_one(s, bank, reg, bits_mask_state)) != 0)
    return rc;
  *bits_mask_state &= bits_mask;
  return 0;
}


x86 assembly (clang, -O0):
<inv_icm30xxx_get_reg_bits>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %edx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    %r8,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0x18(%rbp),%edx
mov    -0x28(%rbp),%rcx
call   1030 <inv_icm30xxx_read_reg_one@plt>
mov    %eax,-0x2c(%rbp)
cmp    $0x0,%eax
je     1153 <inv_icm30xxx_get_reg_bits+0x43>
mov    -0x2c(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1165 <inv_icm30xxx_get_reg_bits+0x55>
mov    -0x1c(%rbp),%ecx
mov    -0x28(%rbp),%rax
and    (%rax),%ecx
mov    %ecx,(%rax)
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<inv_icm30xxx_get_reg_bits>:
push   %rbp
push   %rbx
push   %rax
mov    %r8,%rbx
mov    %ecx,%ebp
mov    %r8,%rcx
call   1030 <inv_icm30xxx_read_reg_one@plt>
test   %eax,%eax
jne    1126 <inv_icm30xxx_get_reg_bits+0x16>
and    %ebp,(%rbx)
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
%struct.inv_icm30xxx = type { i32 }
define i32 @inv_icm30xxx_get_reg_bits(%struct.inv_icm30xxx* %0, i32 %1, i32 %2, i32 %3, i32* %4) {
%6 = alloca i32
%7 = alloca %struct.inv_icm30xxx*
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32*
%12 = alloca i32
store %struct.inv_icm30xxx* %0, %struct.inv_icm30xxx** %7
store i32 %1, i32* %8
store i32 %2, i32* %9
store i32 %3, i32* %10
store i32* %4, i32** %11
%13 = load %struct.inv_icm30xxx*, %struct.inv_icm30xxx** %7
%14 = load i32, i32* %8
%15 = load i32, i32* %9
%16 = load i32*, i32** %11
%17 = call i32 @inv_icm30xxx_read_reg_one(%struct.inv_icm30xxx* %13, i32 %14, i32 %15, i32* %16)
store i32 %17, i32* %12
%18 = icmp ne i32 %17, 0
br i1 %18, label %19, label %21
19: ; preds = %5
%20 = load i32, i32* %12
store i32 %20, i32* %6
br label %26
21: ; preds = %5
%22 = load i32, i32* %10
%23 = load i32*, i32** %11
%24 = load i32, i32* %23
%25 = and i32 %24, %22
store i32 %25, i32* %23
store i32 0, i32* %6
br label %26
26: ; preds = %21, %19
%27 = load i32, i32* %6
ret i32 %27
}

LLVM IR (-O2):
%struct.inv_icm30xxx = type { i32 }
define i32 @inv_icm30xxx_get_reg_bits(%struct.inv_icm30xxx* %0, i32 %1, i32 %2, i32 %3, i32* %4) {
%6 = tail call i32 @inv_icm30xxx_read_reg_one(%struct.inv_icm30xxx* %0, i32 %1, i32 %2, i32* %4)
%7 = icmp eq i32 %6, 0
br i1 %7, label %8, label %11
8: ; preds = %5
%9 = load i32, i32* %4
%10 = and i32 %9, %3
store i32 %10, i32* %4
br label %11
11: ; preds = %5, %8
ret i32 %6
}