#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 */
int /*<<< orphan*/ hasPowerDelivery(int);
int owLevel(int, int);
int owTouchBit(int, int);
int owReadBitPower(int portnum, int applyPowerResponse) {
  if (!hasPowerDelivery(portnum))
    return 0;
  if (owTouchBit(portnum, 0x01) != applyPowerResponse)
    return 0;
  if (owLevel(portnum, 0x02) != 0x02)
    return 0;
  return 1;
}


x86 assembly (clang, -O0):
<owReadBitPower>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0x8(%rbp),%edi
call   1040 <hasPowerDelivery@plt>
cmp    $0x0,%eax
jne    115b <owReadBitPower+0x2b>
movl   $0x0,-0x4(%rbp)
jmp    11a6 <owReadBitPower+0x76>
mov    -0x8(%rbp),%edi
mov    $0x1,%esi
call   1050 <owTouchBit@plt>
cmp    -0xc(%rbp),%eax
je     117d <owReadBitPower+0x4d>
movl   $0x0,-0x4(%rbp)
jmp    11a6 <owReadBitPower+0x76>
mov    -0x8(%rbp),%edi
mov    $0x2,%esi
call   1030 <owLevel@plt>
cmp    $0x2,%eax
je     119f <owReadBitPower+0x6f>
movl   $0x0,-0x4(%rbp)
jmp    11a6 <owReadBitPower+0x76>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<owReadBitPower>:
push   %rbp
push   %r14
push   %rbx
mov    %esi,%r14d
mov    %edi,%ebp
call   1040 <hasPowerDelivery@plt>
xor    %ebx,%ebx
test   %eax,%eax
je     1169 <owReadBitPower+0x39>
mov    %ebp,%edi
mov    $0x1,%esi
call   1050 <owTouchBit@plt>
cmp    %r14d,%eax
jne    1169 <owReadBitPower+0x39>
mov    %ebp,%edi
mov    $0x2,%esi
call   1030 <owLevel@plt>
xor    %ebx,%ebx
cmp    $0x2,%eax
sete   %bl
mov    %ebx,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define i32 @owReadBitPower(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 %0, i32* %4
store i32 %1, i32* %5
%6 = load i32, i32* %4
%7 = call i32 @hasPowerDelivery(i32 %6)
%8 = icmp ne i32 %7, 0
br i1 %8, label %10, label %9
9: ; preds = %2
store i32 0, i32* %3
br label %22
10: ; preds = %2
%11 = load i32, i32* %4
%12 = call i32 @owTouchBit(i32 %11, i32 1)
%13 = load i32, i32* %5
%14 = icmp ne i32 %12, %13
br i1 %14, label %15, label %16
15: ; preds = %10
store i32 0, i32* %3
br label %22
16: ; preds = %10
%17 = load i32, i32* %4
%18 = call i32 @owLevel(i32 %17, i32 2)
%19 = icmp ne i32 %18, 2
br i1 %19, label %20, label %21
20: ; preds = %16
store i32 0, i32* %3
br label %22
21: ; preds = %16
store i32 1, i32* %3
br label %22
22: ; preds = %21, %20, %15, %9
%23 = load i32, i32* %3
ret i32 %23
}

LLVM IR (-O2):
define i32 @owReadBitPower(i32 %0, i32 %1) {
%3 = tail call i32 @hasPowerDelivery(i32 %0)
%4 = icmp eq i32 %3, 0
br i1 %4, label %12, label %5
5: ; preds = %2
%6 = tail call i32 @owTouchBit(i32 %0, i32 1)
%7 = icmp eq i32 %6, %1
br i1 %7, label %8, label %12
8: ; preds = %5
%9 = tail call i32 @owLevel(i32 %0, i32 2)
%10 = icmp eq i32 %9, 2
%11 = zext i1 %10 to i32
br label %12
12: ; preds = %8, %5, %2
%13 = phi i32 [ 0, %2 ], [ 0, %5 ], [ %11, %8 ]
ret i32 %13
}