#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 owTouchByte(int, int);
int owWriteBytePower(int portnum, int sendbyte) {
  if (!hasPowerDelivery(portnum))
    return 0;
  if (owTouchByte(portnum, sendbyte) != sendbyte)
    return 0;
  if (owLevel(portnum, 0x02) != 0x02)
    return 0;
  return 1;
}


x86 assembly (clang, -O0):
<owWriteBytePower>:
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 <owWriteBytePower+0x2b>
movl   $0x0,-0x4(%rbp)
jmp    11a4 <owWriteBytePower+0x74>
mov    -0x8(%rbp),%edi
mov    -0xc(%rbp),%esi
call   1050 <owTouchByte@plt>
cmp    -0xc(%rbp),%eax
je     117b <owWriteBytePower+0x4b>
movl   $0x0,-0x4(%rbp)
jmp    11a4 <owWriteBytePower+0x74>
mov    -0x8(%rbp),%edi
mov    $0x2,%esi
call   1030 <owLevel@plt>
cmp    $0x2,%eax
je     119d <owWriteBytePower+0x6d>
movl   $0x0,-0x4(%rbp)
jmp    11a4 <owWriteBytePower+0x74>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<owWriteBytePower>:
push   %rbp
push   %r14
push   %rbx
mov    %esi,%r14d
mov    %edi,%ebp
call   1040 <hasPowerDelivery@plt>
xor    %ebx,%ebx
test   %eax,%eax
je     1167 <owWriteBytePower+0x37>
mov    %ebp,%edi
mov    %r14d,%esi
call   1050 <owTouchByte@plt>
cmp    %r14d,%eax
jne    1167 <owWriteBytePower+0x37>
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 @owWriteBytePower(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 %23
10: ; preds = %2
%11 = load i32, i32* %4
%12 = load i32, i32* %5
%13 = call i32 @owTouchByte(i32 %11, i32 %12)
%14 = load i32, i32* %5
%15 = icmp ne i32 %13, %14
br i1 %15, label %16, label %17
16: ; preds = %10
store i32 0, i32* %3
br label %23
17: ; preds = %10
%18 = load i32, i32* %4
%19 = call i32 @owLevel(i32 %18, i32 2)
%20 = icmp ne i32 %19, 2
br i1 %20, label %21, label %22
21: ; preds = %17
store i32 0, i32* %3
br label %23
22: ; preds = %17
store i32 1, i32* %3
br label %23
23: ; preds = %22, %21, %16, %9
%24 = load i32, i32* %3
ret i32 %24
}

LLVM IR (-O2):
define i32 @owWriteBytePower(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 @owTouchByte(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
}