#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 scalar_t__ uint8_t;

/* Variables and functions */
int /*<<< orphan*/ rc_i2c_read_byte(int, scalar_t__, scalar_t__ *);
int rc_i2c_write_byte(int, scalar_t__, scalar_t__);
int rc_i2c_write_bit(int bus, uint8_t regAddr, uint8_t bitNum, uint8_t data) {
  uint8_t b;
  rc_i2c_read_byte(bus, regAddr, &b);
  b = (data != 0) ? (b | (1 << bitNum)) : (b & ~(1 << bitNum));
  return rc_i2c_write_byte(bus, regAddr, b);
}


x86 assembly (clang, -O0):
<rc_i2c_write_bit>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    -0x28(%rbp),%rdx
call   1040 <rc_i2c_read_byte@plt>
cmpq   $0x0,-0x20(%rbp)
je     1172 <rc_i2c_write_bit+0x52>
mov    -0x28(%rbp),%rax
mov    -0x18(%rbp),%rcx
mov    $0x1,%edx
shl    %cl,%edx
mov    %edx,%ecx
movslq %ecx,%rcx
or     %rcx,%rax
mov    %rax,-0x30(%rbp)
jmp    1190 <rc_i2c_write_bit+0x70>
mov    -0x28(%rbp),%rax
mov    -0x18(%rbp),%rcx
mov    $0x1,%edx
shl    %cl,%edx
mov    %edx,%ecx
xor    $0xffffffff,%ecx
movslq %ecx,%rcx
and    %rcx,%rax
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    -0x28(%rbp),%rdx
call   1030 <rc_i2c_write_byte@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<rc_i2c_write_bit>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rcx,%r14
mov    %rdx,%rbx
mov    %rsi,%r15
mov    %edi,%ebp
mov    %rsp,%rdx
call   1040 <rc_i2c_read_byte@plt>
mov    $0x1,%eax
mov    %ebx,%ecx
shl    %cl,%eax
mov    (%rsp),%rdx
test   %r14,%r14
je     1153 <rc_i2c_write_bit+0x33>
cltq
or     %rax,%rdx
jmp    115a <rc_i2c_write_bit+0x3a>
not    %eax
cltq
and    %rax,%rdx
mov    %rdx,(%rsp)
mov    %ebp,%edi
mov    %r15,%rsi
call   1030 <rc_i2c_write_byte@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @rc_i2c_write_bit(i32 %0, i64 %1, i64 %2, i64 %3) {
%5 = alloca i32
%6 = alloca i64
%7 = alloca i64
%8 = alloca i64
%9 = alloca i64
store i32 %0, i32* %5
store i64 %1, i64* %6
store i64 %2, i64* %7
store i64 %3, i64* %8
%10 = load i32, i32* %5
%11 = load i64, i64* %6
%12 = call i32 @rc_i2c_read_byte(i32 %10, i64 %11, i64* %9)
%13 = load i64, i64* %8
%14 = icmp ne i64 %13, 0
br i1 %14, label %15, label %22
15: ; preds = %4
%16 = load i64, i64* %9
%17 = load i64, i64* %7
%18 = trunc i64 %17 to i32
%19 = shl i32 1, %18
%20 = sext i32 %19 to i64
%21 = or i64 %16, %20
br label %30
22: ; preds = %4
%23 = load i64, i64* %9
%24 = load i64, i64* %7
%25 = trunc i64 %24 to i32
%26 = shl i32 1, %25
%27 = xor i32 %26, -1
%28 = sext i32 %27 to i64
%29 = and i64 %23, %28
br label %30
30: ; preds = %22, %15
%31 = phi i64 [ %21, %15 ], [ %29, %22 ]
store i64 %31, i64* %9
%32 = load i32, i32* %5
%33 = load i64, i64* %6
%34 = load i64, i64* %9
%35 = call i32 @rc_i2c_write_byte(i32 %32, i64 %33, i64 %34)
ret i32 %35
}

LLVM IR (-O2):
define i32 @rc_i2c_write_bit(i32 %0, i64 %1, i64 %2, i64 %3) {
%5 = alloca i64
%6 = bitcast i64* %5 to i8*
%7 = call i32 @rc_i2c_read_byte(i32 %0, i64 %1, i64* %5)
%8 = icmp eq i64 %3, 0
%9 = load i64, i64* %5
%10 = trunc i64 %2 to i32
%11 = shl nuw i32 1, %10
br i1 %8, label %15, label %12
12: ; preds = %4
%13 = sext i32 %11 to i64
%14 = or i64 %9, %13
br label %19
15: ; preds = %4
%16 = xor i32 %11, -1
%17 = sext i32 %16 to i64
%18 = and i64 %9, %17
br label %19
19: ; preds = %15, %12
%20 = phi i64 [ %14, %12 ], [ %18, %15 ]
store i64 %20, i64* %5
%21 = call i32 @rc_i2c_write_byte(i32 %0, i64 %1, i64 %20)
ret i32 %21
}