#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_write_reg_one(struct inv_icm30xxx *, int /*<<< orphan*/,
                               int /*<<< orphan*/, int /*<<< orphan*/);
int inv_icm30xxx_set_reg_bits(struct inv_icm30xxx *s, uint8_t bank, uint8_t reg,
                              uint8_t bits_mask) {
  int rc;
  uint8_t reg_value;
  if ((rc = inv_icm30xxx_read_reg_one(s, bank, reg, &reg_value)) != 0)
    return rc;
  reg_value |= bits_mask;
  if ((rc = inv_icm30xxx_write_reg_one(s, bank, reg, reg_value)) != 0)
    return rc;
  return 0;
}


x86 assembly (clang, -O0):
<inv_icm30xxx_set_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    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0x18(%rbp),%edx
lea    -0x24(%rbp),%rcx
call   1040 <inv_icm30xxx_read_reg_one@plt>
mov    %eax,-0x20(%rbp)
cmp    $0x0,%eax
je     115f <inv_icm30xxx_set_reg_bits+0x3f>
mov    -0x20(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1198 <inv_icm30xxx_set_reg_bits+0x78>
mov    -0x1c(%rbp),%eax
or     -0x24(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0x18(%rbp),%edx
mov    -0x24(%rbp),%ecx
call   1030 <inv_icm30xxx_write_reg_one@plt>
mov    %eax,-0x20(%rbp)
cmp    $0x0,%eax
je     1191 <inv_icm30xxx_set_reg_bits+0x71>
mov    -0x20(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1198 <inv_icm30xxx_set_reg_bits+0x78>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<inv_icm30xxx_set_reg_bits>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %ecx,%r15d
mov    %edx,%r14d
mov    %esi,%ebp
mov    %rdi,%rbx
lea    0x4(%rsp),%rcx
call   1040 <inv_icm30xxx_read_reg_one@plt>
test   %eax,%eax
jne    115a <inv_icm30xxx_set_reg_bits+0x3a>
or     0x4(%rsp),%r15d
mov    %r15d,0x4(%rsp)
mov    %rbx,%rdi
mov    %ebp,%esi
mov    %r14d,%edx
mov    %r15d,%ecx
call   1030 <inv_icm30xxx_write_reg_one@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
%struct.inv_icm30xxx = type { i32 }
define i32 @inv_icm30xxx_set_reg_bits(%struct.inv_icm30xxx* %0, i32 %1, i32 %2, i32 %3) {
%5 = alloca i32
%6 = bitcast i32* %5 to i8*
%7 = call i32 @inv_icm30xxx_read_reg_one(%struct.inv_icm30xxx* %0, i32 %1, i32 %2, i32* %5)
%8 = icmp eq i32 %7, 0
br i1 %8, label %9, label %13
9: ; preds = %4
%10 = load i32, i32* %5
%11 = or i32 %10, %3
store i32 %11, i32* %5
%12 = call i32 @inv_icm30xxx_write_reg_one(%struct.inv_icm30xxx* %0, i32 %1, i32 %2, i32 %11)
br label %13
13: ; preds = %9, %4
%14 = phi i32 [ %7, %4 ], [ %12, %9 ]
ret i32 %14
}