#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 */
scalar_t__ I2C_HAL_BitRead_I2C_SCL();
int /*<<< orphan*/ I2C_HAL_SCL_IN_MODE();
int /*<<< orphan*/ SynaSleep(int);
int /*<<< orphan*/ printk(char *);
unsigned char I2C_SCL_HIGH(void) {
  signed long bDelay = 5000000;
  I2C_HAL_SCL_IN_MODE();
  while ((I2C_HAL_BitRead_I2C_SCL() == 0) && (bDelay > 0)) {
    bDelay--;
    SynaSleep(1);
  }
  if (bDelay == 0) {
    printk("[TSP][ERROR] I2C_SCL_HIGH fail. bDelay==0\n");
    return 1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<I2C_SCL_HIGH>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movq   $0x4c4b40,-0x10(%rbp)
mov    $0x0,%al
call   1060 <I2C_HAL_SCL_IN_MODE@plt>
mov    $0x0,%al
call   1040 <I2C_HAL_BitRead_I2C_SCL@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    $0x0,%rcx
mov    %al,-0x11(%rbp)
jne    117b <I2C_SCL_HIGH+0x3b>
cmpq   $0x0,-0x10(%rbp)
setg   %al
mov    %al,-0x11(%rbp)
mov    -0x11(%rbp),%al
test   $0x1,%al
jne    118b <I2C_SCL_HIGH+0x4b>
jmp    11a6 <I2C_SCL_HIGH+0x66>
mov    -0x10(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x10(%rbp)
mov    $0x1,%edi
call   1050 <SynaSleep@plt>
jmp    1157 <I2C_SCL_HIGH+0x17>
cmpq   $0x0,-0x10(%rbp)
jne    11c6 <I2C_SCL_HIGH+0x86>
lea    0xe48(%rip),%rdi
call   1030 <printk@plt>
movb   $0x1,-0x1(%rbp)
jmp    11ca <I2C_SCL_HIGH+0x8a>
movb   $0x0,-0x1(%rbp)
movzbl -0x1(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<I2C_SCL_HIGH>:
push   %r14
push   %rbx
push   %rax
xor    %ebx,%ebx
xor    %eax,%eax
call   1060 <I2C_HAL_SCL_IN_MODE@plt>
xor    %eax,%eax
call   1040 <I2C_HAL_BitRead_I2C_SCL@plt>
test   %rax,%rax
jne    119a <I2C_SCL_HIGH+0x5a>
mov    $0x4c4b40,%ebx
xchg   %ax,%ax
lea    -0x1(%rbx),%r14
mov    $0x1,%edi
call   1050 <SynaSleep@plt>
xor    %eax,%eax
call   1040 <I2C_HAL_BitRead_I2C_SCL@plt>
test   %rax,%rax
jne    1183 <I2C_SCL_HIGH+0x43>
cmp    $0x1,%rbx
mov    %r14,%rbx
jne    1160 <I2C_SCL_HIGH+0x20>
test   %r14,%r14
je     118c <I2C_SCL_HIGH+0x4c>
xor    %ebx,%ebx
jmp    119a <I2C_SCL_HIGH+0x5a>
lea    0xe6d(%rip),%rdi
call   1030 <printk@plt>
mov    $0x1,%bl
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [43 x i8] c"[TSP][ERROR] I2C_SCL_HIGH fail. bDelay==0\0A\00"
define zeroext i8 @I2C_SCL_HIGH() {
%1 = alloca i8
%2 = alloca i64
store i64 5000000, i64* %2
%3 = call i32 (...) @I2C_HAL_SCL_IN_MODE()
br label %4
4: ; preds = %12, %0
%5 = call i64 (...) @I2C_HAL_BitRead_I2C_SCL()
%6 = icmp eq i64 %5, 0
br i1 %6, label %7, label %10
7: ; preds = %4
%8 = load i64, i64* %2
%9 = icmp sgt i64 %8, 0
br label %10
10: ; preds = %7, %4
%11 = phi i1 [ false, %4 ], [ %9, %7 ]
br i1 %11, label %12, label %16
12: ; preds = %10
%13 = load i64, i64* %2
%14 = add nsw i64 %13, -1
store i64 %14, i64* %2
%15 = call i32 @SynaSleep(i32 1)
br label %4
16: ; preds = %10
%17 = load i64, i64* %2
%18 = icmp eq i64 %17, 0
br i1 %18, label %19, label %21
19: ; preds = %16
%20 = call i32 @printk(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str, i64 0, i64 0))
store i8 1, i8* %1
br label %22
21: ; preds = %16
store i8 0, i8* %1
br label %22
22: ; preds = %21, %19
%23 = load i8, i8* %1
ret i8 %23
}

LLVM IR (-O2):
@.str = [43 x i8] c"[TSP][ERROR] I2C_SCL_HIGH fail. bDelay==0\0A\00"
define zeroext i8 @I2C_SCL_HIGH() {
%1 = tail call i32 (...) @I2C_HAL_SCL_IN_MODE()
%2 = tail call i64 (...) @I2C_HAL_BitRead_I2C_SCL()
%3 = icmp eq i64 %2, 0
br i1 %3, label %4, label %16
4: ; preds = %0, %4
%5 = phi i64 [ %6, %4 ], [ 5000000, %0 ]
%6 = add nsw i64 %5, -1
%7 = tail call i32 @SynaSleep(i32 1)
%8 = tail call i64 (...) @I2C_HAL_BitRead_I2C_SCL()
%9 = icmp eq i64 %8, 0
%10 = icmp ne i64 %6, 0
%11 = select i1 %9, i1 %10, i1 false
br i1 %11, label %4, label %12
12: ; preds = %4
%13 = icmp eq i64 %6, 0
br i1 %13, label %14, label %16
14: ; preds = %12
%15 = tail call i32 @printk(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str, i64 0, i64 0))
br label %16
16: ; preds = %0, %12, %14
%17 = phi i8 [ 1, %14 ], [ 0, %12 ], [ 0, %0 ]
ret i8 %17
}