#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 */

/* Variables and functions */
unsigned char McSrv_ReadI2C(unsigned char, unsigned short);
int /*<<< orphan*/ McSrv_Sleep(unsigned long);
signed long WaitBitRelease(unsigned char bSlaveAddr, unsigned short wRegAddr,
                           unsigned char bBit, unsigned long dCycleTime,
                           unsigned long dTimeOut) {
  unsigned char bData;
  unsigned long dCycles;
  signed long sdRet;
  dCycles = 0;
  sdRet = (-2);
  while (dCycles < dTimeOut) {
    bData = McSrv_ReadI2C(bSlaveAddr, wRegAddr);
    if (0 == (bData & bBit)) {
      sdRet = ((signed long)0);
      break;
    }
    McSrv_Sleep(dCycleTime);
    dCycles++;
  }
  return sdRet;
}


x86 assembly (clang, -O0):
<WaitBitRelease>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %dl,%al
mov    %si,%dx
mov    %dil,%sil
mov    %sil,-0x1(%rbp)
mov    %dx,-0x4(%rbp)
mov    %al,-0x5(%rbp)
mov    %rcx,-0x10(%rbp)
mov    %r8,-0x18(%rbp)
movq   $0x0,-0x28(%rbp)
movq   $0xfffffffffffffffe,-0x30(%rbp)
ff
mov    -0x28(%rbp),%rax
cmp    -0x18(%rbp),%rax
jae    11ae <WaitBitRelease+0x8e>
mov    -0x1(%rbp),%al
movzbl %al,%edi
movzwl -0x4(%rbp),%esi
call   1030 <McSrv_ReadI2C@plt>
mov    %al,-0x19(%rbp)
movzbl -0x19(%rbp),%ecx
movzbl -0x5(%rbp),%eax
and    %eax,%ecx
xor    %eax,%eax
cmp    %ecx,%eax
jne    1194 <WaitBitRelease+0x74>
movq   $0x0,-0x30(%rbp)
jmp    11ae <WaitBitRelease+0x8e>
mov    -0x10(%rbp),%rdi
call   1040 <McSrv_Sleep@plt>
mov    -0x28(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
jmp    1153 <WaitBitRelease+0x33>
mov    -0x30(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<WaitBitRelease>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    $0xfffffffffffffffe,%r14
test   %r8,%r8
je     1172 <WaitBitRelease+0x52>
mov    %r8,%rbx
mov    %rcx,%r15
mov    %edx,%r12d
movzbl %dil,%r13d
movzwl %si,%ebp
nopw   0x0(%rax,%rax,1)
mov    %r13d,%edi
mov    %ebp,%esi
call   1030 <McSrv_ReadI2C@plt>
test   %r12b,%al
je     116f <WaitBitRelease+0x4f>
mov    %r15,%rdi
call   1040 <McSrv_Sleep@plt>
add    $0xffffffffffffffff,%rbx
jne    1150 <WaitBitRelease+0x30>
jmp    1172 <WaitBitRelease+0x52>
xor    %r14d,%r14d
mov    %r14,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i64 @WaitBitRelease(i8 zeroext %0, i16 zeroext %1, i8 zeroext %2, i64 %3, i64 %4) {
%6 = alloca i8
%7 = alloca i16
%8 = alloca i8
%9 = alloca i64
%10 = alloca i64
%11 = alloca i8
%12 = alloca i64
%13 = alloca i64
store i8 %0, i8* %6
store i16 %1, i16* %7
store i8 %2, i8* %8
store i64 %3, i64* %9
store i64 %4, i64* %10
store i64 0, i64* %12
store i64 -2, i64* %13
br label %14
14: ; preds = %29, %5
%15 = load i64, i64* %12
%16 = load i64, i64* %10
%17 = icmp ult i64 %15, %16
br i1 %17, label %18, label %34
18: ; preds = %14
%19 = load i8, i8* %6
%20 = load i16, i16* %7
%21 = call zeroext i8 @McSrv_ReadI2C(i8 zeroext %19, i16 zeroext %20)
store i8 %21, i8* %11
%22 = load i8, i8* %11
%23 = zext i8 %22 to i32
%24 = load i8, i8* %8
%25 = zext i8 %24 to i32
%26 = and i32 %23, %25
%27 = icmp eq i32 0, %26
br i1 %27, label %28, label %29
28: ; preds = %18
store i64 0, i64* %13
br label %34
29: ; preds = %18
%30 = load i64, i64* %9
%31 = call i32 @McSrv_Sleep(i64 %30)
%32 = load i64, i64* %12
%33 = add i64 %32, 1
store i64 %33, i64* %12
br label %14
34: ; preds = %28, %14
%35 = load i64, i64* %13
ret i64 %35
}

LLVM IR (-O2):
define i64 @WaitBitRelease(i8 zeroext %0, i16 zeroext %1, i8 zeroext %2, i64 %3, i64 %4) {
%6 = icmp eq i64 %4, 0
br i1 %6, label %16, label %7
7: ; preds = %5, %12
%8 = phi i64 [ %14, %12 ], [ 0, %5 ]
%9 = tail call zeroext i8 @McSrv_ReadI2C(i8 zeroext %0, i16 zeroext %1)
%10 = and i8 %9, %2
%11 = icmp eq i8 %10, 0
br i1 %11, label %16, label %12
12: ; preds = %7
%13 = tail call i32 @McSrv_Sleep(i64 %3)
%14 = add nuw i64 %8, 1
%15 = icmp eq i64 %14, %4
br i1 %15, label %16, label %7
16: ; preds = %12, %7, %5
%17 = phi i64 [ -2, %5 ], [ 0, %7 ], [ -2, %12 ]
ret i64 %17
}