#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*/ msDelay(int);
int /*<<< orphan*/ owRaiseError(int);
int /*<<< orphan*/ owTouchBit(int, int);
int /*<<< orphan*/ owTouchByte(int, int);
scalar_t__ owTouchReset(int);
int rw1990WriteEnable(int portnum, int delay, int sbit) {
  if (owTouchReset(portnum)) {
    owTouchByte(portnum, 0xD1);
    owTouchBit(portnum, sbit);
    msDelay(delay);
  } else {
    owRaiseError(12);
    return 0;
  }
  return 1;
}


x86 assembly (clang, -O0):
<rw1990WriteEnable>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    -0x8(%rbp),%edi
call   1050 <owTouchReset@plt>
cmp    $0x0,%rax
je     1198 <rw1990WriteEnable+0x48>
mov    -0x8(%rbp),%edi
mov    $0xd1,%esi
call   1040 <owTouchByte@plt>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%esi
call   1070 <owTouchBit@plt>
mov    -0xc(%rbp),%edi
call   1030 <msDelay@plt>
jmp    11ae <rw1990WriteEnable+0x5e>
mov    $0xc,%edi
call   1060 <owRaiseError@plt>
movl   $0x0,-0x4(%rbp)
jmp    11b5 <rw1990WriteEnable+0x65>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<rw1990WriteEnable>:
push   %rbp
push   %r14
push   %rbx
mov    %edx,%ebp
mov    %esi,%r14d
mov    %edi,%ebx
call   1050 <owTouchReset@plt>
test   %rax,%rax
je     1189 <rw1990WriteEnable+0x39>
mov    %ebx,%edi
mov    $0xd1,%esi
call   1040 <owTouchByte@plt>
mov    %ebx,%edi
mov    %ebp,%esi
call   1070 <owTouchBit@plt>
mov    %r14d,%edi
call   1030 <msDelay@plt>
mov    $0x1,%eax
jmp    1195 <rw1990WriteEnable+0x45>
mov    $0xc,%edi
call   1060 <owRaiseError@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

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

LLVM IR (-O2):
define i32 @rw1990WriteEnable(i32 %0, i32 %1, i32 %2) {
%4 = tail call i64 @owTouchReset(i32 %0)
%5 = icmp eq i64 %4, 0
br i1 %5, label %10, label %6
6: ; preds = %3
%7 = tail call i32 @owTouchByte(i32 %0, i32 209)
%8 = tail call i32 @owTouchBit(i32 %0, i32 %2)
%9 = tail call i32 @msDelay(i32 %1)
br label %12
10: ; preds = %3
%11 = tail call i32 @owRaiseError(i32 12)
br label %12
12: ; preds = %6, %10
%13 = phi i32 [ 1, %6 ], [ 0, %10 ]
ret i32 %13
}