#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*/ RegReadA(int, unsigned char *);
int /*<<< orphan*/ RegWriteA(int, int);
int /*<<< orphan*/ SrvCon(int, unsigned char);
void StbOnnN(unsigned char UcStbY, unsigned char UcStbX) {
  unsigned char UcRegIni;
  unsigned char UcSttMsk = 0;
  RegWriteA(0x017C, 0x01);
  if (UcStbX == 0x01)
    UcSttMsk |= 0x07;
  if (UcStbY == 0x01)
    UcSttMsk |= 0x70;
  SrvCon(0x00, UcStbX);
  SrvCon(0x01, UcStbY);
  UcRegIni = 0x11;
  while ((UcRegIni & UcSttMsk) != (0x66 & UcSttMsk)) {
    RegReadA(0x01F8, &UcRegIni);
  }
  RegWriteA(0x017C, 0x00);
}


x86 assembly (clang, -O0):
<StbOnnN>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %sil,%al
mov    %dil,%cl
mov    %cl,-0x1(%rbp)
mov    %al,-0x2(%rbp)
movb   $0x0,-0x4(%rbp)
mov    $0x17c,%edi
mov    $0x1,%esi
call   1050 <RegWriteA@plt>
movzbl -0x2(%rbp),%eax
cmp    $0x1,%eax
jne    116e <StbOnnN+0x3e>
movzbl -0x4(%rbp),%eax
or     $0x7,%eax
mov    %al,-0x4(%rbp)
movzbl -0x1(%rbp),%eax
cmp    $0x1,%eax
jne    1185 <StbOnnN+0x55>
movzbl -0x4(%rbp),%eax
or     $0x70,%eax
mov    %al,-0x4(%rbp)
xor    %edi,%edi
movzbl -0x2(%rbp),%esi
call   1030 <SrvCon@plt>
mov    $0x1,%edi
movzbl -0x1(%rbp),%esi
call   1030 <SrvCon@plt>
movb   $0x11,-0x3(%rbp)
movzbl -0x3(%rbp),%eax
movzbl -0x4(%rbp),%ecx
and    %ecx,%eax
movzbl -0x4(%rbp),%ecx
and    $0x66,%ecx
cmp    %ecx,%eax
je     11ce <StbOnnN+0x9e>
mov    $0x1f8,%edi
lea    -0x3(%rbp),%rsi
call   1040 <RegReadA@plt>
jmp    11a2 <StbOnnN+0x72>
mov    $0x17c,%edi
xor    %esi,%esi
call   1050 <RegWriteA@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<StbOnnN>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %esi,%ebx
mov    %edi,%r14d
mov    $0x17c,%edi
mov    $0x1,%esi
call   1050 <RegWriteA@plt>
xor    %eax,%eax
cmp    $0x1,%bl
mov    $0x7,%ecx
cmovne %eax,%ecx
lea    0x70(%rcx),%eax
cmp    $0x1,%r14b
movzbl %al,%ebp
cmovne %ecx,%ebp
xor    %edi,%edi
mov    %ebx,%esi
call   1030 <SrvCon@plt>
mov    $0x1,%edi
mov    %r14d,%esi
call   1030 <SrvCon@plt>
movb   $0x11,0xf(%rsp)
test   %bpl,%bpl
je     11a9 <StbOnnN+0x79>
lea    0xf(%rsp),%rbx
nopl   0x0(%rax,%rax,1)
mov    $0x1f8,%edi
mov    %rbx,%rsi
call   1040 <RegReadA@plt>
movzbl 0xf(%rsp),%eax
xor    $0x66,%al
test   %bpl,%al
jne    1190 <StbOnnN+0x60>
mov    $0x17c,%edi
xor    %esi,%esi
call   1050 <RegWriteA@plt>
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define void @StbOnnN(i8 zeroext %0, i8 zeroext %1) {
%3 = alloca i8
%4 = alloca i8
%5 = alloca i8
%6 = alloca i8
store i8 %0, i8* %3
store i8 %1, i8* %4
store i8 0, i8* %6
%7 = call i32 @RegWriteA(i32 380, i32 1)
%8 = load i8, i8* %4
%9 = zext i8 %8 to i32
%10 = icmp eq i32 %9, 1
br i1 %10, label %11, label %16
11: ; preds = %2
%12 = load i8, i8* %6
%13 = zext i8 %12 to i32
%14 = or i32 %13, 7
%15 = trunc i32 %14 to i8
store i8 %15, i8* %6
br label %16
16: ; preds = %11, %2
%17 = load i8, i8* %3
%18 = zext i8 %17 to i32
%19 = icmp eq i32 %18, 1
br i1 %19, label %20, label %25
20: ; preds = %16
%21 = load i8, i8* %6
%22 = zext i8 %21 to i32
%23 = or i32 %22, 112
%24 = trunc i32 %23 to i8
store i8 %24, i8* %6
br label %25
25: ; preds = %20, %16
%26 = load i8, i8* %4
%27 = call i32 @SrvCon(i32 0, i8 zeroext %26)
%28 = load i8, i8* %3
%29 = call i32 @SrvCon(i32 1, i8 zeroext %28)
store i8 17, i8* %5
br label %30
30: ; preds = %40, %25
%31 = load i8, i8* %5
%32 = zext i8 %31 to i32
%33 = load i8, i8* %6
%34 = zext i8 %33 to i32
%35 = and i32 %32, %34
%36 = load i8, i8* %6
%37 = zext i8 %36 to i32
%38 = and i32 102, %37
%39 = icmp ne i32 %35, %38
br i1 %39, label %40, label %42
40: ; preds = %30
%41 = call i32 @RegReadA(i32 504, i8* %5)
br label %30
42: ; preds = %30
%43 = call i32 @RegWriteA(i32 380, i32 0)
ret void
}

LLVM IR (-O2):
define void @StbOnnN(i8 zeroext %0, i8 zeroext %1) {
%3 = alloca i8
%4 = tail call i32 @RegWriteA(i32 380, i32 1)
%5 = icmp eq i8 %1, 1
%6 = select i1 %5, i8 7, i8 0
%7 = icmp eq i8 %0, 1
%8 = or i8 %6, 112
%9 = select i1 %7, i8 %8, i8 %6
%10 = tail call i32 @SrvCon(i32 0, i8 zeroext %1)
%11 = tail call i32 @SrvCon(i32 1, i8 zeroext %0)
store i8 17, i8* %3
%12 = icmp eq i8 %9, 0
br i1 %12, label %19, label %13
13: ; preds = %2, %13
%14 = call i32 @RegReadA(i32 504, i8* %3)
%15 = load i8, i8* %3
%16 = xor i8 %15, 102
%17 = and i8 %16, %9
%18 = icmp eq i8 %17, 0
br i1 %18, label %19, label %13
19: ; preds = %13, %2
%20 = call i32 @RegWriteA(i32 380, i32 0)
ret void
}