#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, int);
void StbOnn(void) {
  unsigned char UcRegValx, UcRegValy;
  unsigned char UcRegIni;
  unsigned char UcRegIniCnt = 0;
  RegReadA(0x0170, &UcRegValx);
  RegReadA(0x0171, &UcRegValy);
  if (((UcRegValx & 0x01) != 0x01) && ((UcRegValy & 0x01) != 0x01)) {
    RegWriteA(0x017C, 0x01);
    SrvCon(0x00, 0x01);
    SrvCon(0x01, 0x01);
    UcRegIni = 0x11;
    while ((UcRegIni & 0x77) != 0x66) {
      RegReadA(0x01F8, &UcRegIni);
      if (CmdRdChk() != 0)
        break;
      if ((UcRegIni & 0x77) == 0)
        UcRegIniCnt++;
      if (UcRegIniCnt > 10) {
        break;
      }
    }
    RegWriteA(0x017C, 0x00);
  } else {
    SrvCon(0x00, 0x01);
    SrvCon(0x01, 0x01);
  }
}


x86 assembly (clang, -O0):
<StbOnn>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movb   $0x0,-0x4(%rbp)
mov    $0x170,%edi
lea    -0x1(%rbp),%rsi
call   1050 <RegReadA@plt>
mov    $0x171,%edi
lea    -0x2(%rbp),%rsi
call   1050 <RegReadA@plt>
movzbl -0x1(%rbp),%eax
and    $0x1,%eax
cmp    $0x1,%eax
je     1227 <StbOnn+0xe7>
movzbl -0x2(%rbp),%eax
and    $0x1,%eax
cmp    $0x1,%eax
je     1227 <StbOnn+0xe7>
mov    $0x17c,%edi
mov    $0x1,%esi
call   1060 <RegWriteA@plt>
xor    %edi,%edi
mov    $0x1,%esi
call   1040 <SrvCon@plt>
mov    $0x1,%esi
mov    %esi,%edi
call   1040 <SrvCon@plt>
movb   $0x11,-0x3(%rbp)
movzbl -0x3(%rbp),%eax
and    $0x77,%eax
cmp    $0x66,%eax
je     1216 <StbOnn+0xd6>
mov    $0x1f8,%edi
lea    -0x3(%rbp),%rsi
call   1050 <RegReadA@plt>
mov    $0x0,%al
call   1030 <CmdRdChk@plt>
cmp    $0x0,%rax
je     11e7 <StbOnn+0xa7>
jmp    1216 <StbOnn+0xd6>
movzbl -0x3(%rbp),%eax
and    $0x77,%eax
cmp    $0x0,%eax
jne    11ff <StbOnn+0xbf>
mov    -0x4(%rbp),%al
add    $0x1,%al
mov    %al,-0x4(%rbp)
movzbl -0x4(%rbp),%eax
cmp    $0xa,%eax
jle    1211 <StbOnn+0xd1>
jmp    1216 <StbOnn+0xd6>
jmp    11b3 <StbOnn+0x73>
mov    $0x17c,%edi
xor    %esi,%esi
call   1060 <RegWriteA@plt>
jmp    123f <StbOnn+0xff>
xor    %edi,%edi
mov    $0x1,%esi
call   1040 <SrvCon@plt>
mov    $0x1,%esi
mov    %esi,%edi
call   1040 <SrvCon@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<StbOnn>:
push   %rbp
push   %rbx
push   %rax
lea    0x7(%rsp),%rsi
mov    $0x170,%edi
call   1050 <RegReadA@plt>
lea    0x6(%rsp),%rsi
mov    $0x171,%edi
call   1050 <RegReadA@plt>
testb  $0x1,0x7(%rsp)
jne    11f4 <StbOnn+0xb4>
testb  $0x1,0x6(%rsp)
jne    11f4 <StbOnn+0xb4>
mov    $0x17c,%edi
mov    $0x1,%esi
call   1060 <RegWriteA@plt>
xor    %edi,%edi
mov    $0x1,%esi
call   1040 <SrvCon@plt>
mov    $0x1,%edi
mov    $0x1,%esi
call   1040 <SrvCon@plt>
movb   $0x11,0x5(%rsp)
mov    $0x11,%al
lea    0x5(%rsp),%rbx
xor    %ebp,%ebp
nop
and    $0x77,%al
cmp    $0x66,%al
je     11e6 <StbOnn+0xa6>
mov    $0x1f8,%edi
mov    %rbx,%rsi
call   1050 <RegReadA@plt>
xor    %eax,%eax
call   1030 <CmdRdChk@plt>
test   %rax,%rax
jne    11e6 <StbOnn+0xa6>
movzbl 0x5(%rsp),%eax
mov    %eax,%ecx
and    $0x77,%cl
cmp    $0x1,%cl
adc    $0x0,%bpl
cmp    $0xb,%bpl
jb     11b0 <StbOnn+0x70>
mov    $0x17c,%edi
xor    %esi,%esi
call   1060 <RegWriteA@plt>
jmp    120f <StbOnn+0xcf>
xor    %edi,%edi
mov    $0x1,%esi
call   1040 <SrvCon@plt>
mov    $0x1,%edi
mov    $0x1,%esi
call   1040 <SrvCon@plt>
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

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

LLVM IR (-O2):
define void @StbOnn() {
%1 = alloca i8
%2 = alloca i8
%3 = alloca i8
%4 = call i32 @RegReadA(i32 368, i8* %1)
%5 = call i32 @RegReadA(i32 369, i8* %2)
%6 = load i8, i8* %1
%7 = and i8 %6, 1
%8 = icmp eq i8 %7, 0
br i1 %8, label %9, label %35
9: ; preds = %0
%10 = load i8, i8* %2
%11 = and i8 %10, 1
%12 = icmp eq i8 %11, 0
br i1 %12, label %13, label %35
13: ; preds = %9
%14 = call i32 @RegWriteA(i32 380, i32 1)
%15 = call i32 @SrvCon(i32 0, i32 1)
%16 = call i32 @SrvCon(i32 1, i32 1)
store i8 17, i8* %3
br label %17
17: ; preds = %26, %13
%18 = phi i8 [ 17, %13 ], [ %27, %26 ]
%19 = phi i8 [ 0, %13 ], [ %31, %26 ]
%20 = and i8 %18, 119
%21 = icmp eq i8 %20, 102
br i1 %21, label %33, label %22
22: ; preds = %17
%23 = call i32 @RegReadA(i32 504, i8* %3)
%24 = call i64 (...) @CmdRdChk()
%25 = icmp eq i64 %24, 0
br i1 %25, label %26, label %33
26: ; preds = %22
%27 = load i8, i8* %3
%28 = and i8 %27, 119
%29 = icmp eq i8 %28, 0
%30 = zext i1 %29 to i8
%31 = add nuw nsw i8 %19, %30
%32 = icmp ugt i8 %31, 10
br i1 %32, label %33, label %17
33: ; preds = %26, %22, %17
%34 = call i32 @RegWriteA(i32 380, i32 0)
br label %38
35: ; preds = %9, %0
%36 = call i32 @SrvCon(i32 0, i32 1)
%37 = call i32 @SrvCon(i32 1, i32 1)
br label %38
38: ; preds = %35, %33
ret void
}