#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__ CmdRdChk();
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;
  unsigned char UcRegIniCnt = 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);
    if (CmdRdChk() != 0)
      break;
    if ((UcRegIni & 0x77) == 0)
      UcRegIniCnt++;
    if (UcRegIniCnt > 10) {
      break;
    }
  }
  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)
movb   $0x0,-0x5(%rbp)
mov    $0x17c,%edi
mov    $0x1,%esi
call   1060 <RegWriteA@plt>
movzbl -0x2(%rbp),%eax
cmp    $0x1,%eax
jne    1182 <StbOnnN+0x42>
movzbl -0x4(%rbp),%eax
or     $0x7,%eax
mov    %al,-0x4(%rbp)
movzbl -0x1(%rbp),%eax
cmp    $0x1,%eax
jne    1199 <StbOnnN+0x59>
movzbl -0x4(%rbp),%eax
or     $0x70,%eax
mov    %al,-0x4(%rbp)
xor    %edi,%edi
movzbl -0x2(%rbp),%esi
call   1040 <SrvCon@plt>
mov    $0x1,%edi
movzbl -0x1(%rbp),%esi
call   1040 <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     1222 <StbOnnN+0xe2>
mov    $0x1f8,%edi
lea    -0x3(%rbp),%rsi
call   1050 <RegReadA@plt>
mov    $0x0,%al
call   1030 <CmdRdChk@plt>
cmp    $0x0,%rax
je     11f3 <StbOnnN+0xb3>
jmp    1222 <StbOnnN+0xe2>
movzbl -0x3(%rbp),%eax
and    $0x77,%eax
cmp    $0x0,%eax
jne    120b <StbOnnN+0xcb>
mov    -0x5(%rbp),%al
add    $0x1,%al
mov    %al,-0x5(%rbp)
movzbl -0x5(%rbp),%eax
cmp    $0xa,%eax
jle    121d <StbOnnN+0xdd>
jmp    1222 <StbOnnN+0xe2>
jmp    11b6 <StbOnnN+0x76>
mov    $0x17c,%edi
xor    %esi,%esi
call   1060 <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   1060 <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   1040 <SrvCon@plt>
mov    $0x1,%edi
mov    %r14d,%esi
call   1040 <SrvCon@plt>
movb   $0x11,0xf(%rsp)
mov    $0x11,%al
lea    0xf(%rsp),%r14
xor    %ebx,%ebx
nopw   0x0(%rax,%rax,1)
xor    $0x66,%al
test   %bpl,%al
je     11d5 <StbOnnN+0x95>
mov    $0x1f8,%edi
mov    %r14,%rsi
call   1050 <RegReadA@plt>
xor    %eax,%eax
call   1030 <CmdRdChk@plt>
test   %rax,%rax
jne    11d5 <StbOnnN+0x95>
movzbl 0xf(%rsp),%eax
mov    %eax,%ecx
and    $0x77,%cl
cmp    $0x1,%cl
adc    $0x0,%bl
cmp    $0xb,%bl
jb     11a0 <StbOnnN+0x60>
mov    $0x17c,%edi
xor    %esi,%esi
call   1060 <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
%7 = alloca i8
store i8 %0, i8* %3
store i8 %1, i8* %4
store i8 0, i8* %6
store i8 0, i8* %7
%8 = call i32 @RegWriteA(i32 380, i32 1)
%9 = load i8, i8* %4
%10 = zext i8 %9 to i32
%11 = icmp eq i32 %10, 1
br i1 %11, label %12, label %17
12: ; preds = %2
%13 = load i8, i8* %6
%14 = zext i8 %13 to i32
%15 = or i32 %14, 7
%16 = trunc i32 %15 to i8
store i8 %16, i8* %6
br label %17
17: ; preds = %12, %2
%18 = load i8, i8* %3
%19 = zext i8 %18 to i32
%20 = icmp eq i32 %19, 1
br i1 %20, label %21, label %26
21: ; preds = %17
%22 = load i8, i8* %6
%23 = zext i8 %22 to i32
%24 = or i32 %23, 112
%25 = trunc i32 %24 to i8
store i8 %25, i8* %6
br label %26
26: ; preds = %21, %17
%27 = load i8, i8* %4
%28 = call i32 @SrvCon(i32 0, i8 zeroext %27)
%29 = load i8, i8* %3
%30 = call i32 @SrvCon(i32 1, i8 zeroext %29)
store i8 17, i8* %5
br label %31
31: ; preds = %59, %26
%32 = load i8, i8* %5
%33 = zext i8 %32 to i32
%34 = load i8, i8* %6
%35 = zext i8 %34 to i32
%36 = and i32 %33, %35
%37 = load i8, i8* %6
%38 = zext i8 %37 to i32
%39 = and i32 102, %38
%40 = icmp ne i32 %36, %39
br i1 %40, label %41, label %60
41: ; preds = %31
%42 = call i32 @RegReadA(i32 504, i8* %5)
%43 = call i64 (...) @CmdRdChk()
%44 = icmp ne i64 %43, 0
br i1 %44, label %45, label %46
45: ; preds = %41
br label %60
46: ; preds = %41
%47 = load i8, i8* %5
%48 = zext i8 %47 to i32
%49 = and i32 %48, 119
%50 = icmp eq i32 %49, 0
br i1 %50, label %51, label %54
51: ; preds = %46
%52 = load i8, i8* %7
%53 = add i8 %52, 1
store i8 %53, i8* %7
br label %54
54: ; preds = %51, %46
%55 = load i8, i8* %7
%56 = zext i8 %55 to i32
%57 = icmp sgt i32 %56, 10
br i1 %57, label %58, label %59
58: ; preds = %54
br label %60
59: ; preds = %54
br label %31
60: ; preds = %58, %45, %31
%61 = 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
br label %12
12: ; preds = %22, %2
%13 = phi i8 [ 17, %2 ], [ %23, %22 ]
%14 = phi i8 [ 0, %2 ], [ %27, %22 ]
%15 = xor i8 %13, 102
%16 = and i8 %15, %9
%17 = icmp eq i8 %16, 0
br i1 %17, label %29, label %18
18: ; preds = %12
%19 = call i32 @RegReadA(i32 504, i8* %3)
%20 = call i64 (...) @CmdRdChk()
%21 = icmp eq i64 %20, 0
br i1 %21, label %22, label %29
22: ; preds = %18
%23 = load i8, i8* %3
%24 = and i8 %23, 119
%25 = icmp eq i8 %24, 0
%26 = zext i1 %25 to i8
%27 = add nuw nsw i8 %14, %26
%28 = icmp ugt i8 %27, 10
br i1 %28, label %29, label %12
29: ; preds = %22, %18, %12
%30 = call i32 @RegWriteA(i32 380, i32 0)
ret void
}