#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*/ RamWriteA(int, int /*<<< orphan*/);
int /*<<< orphan*/ RegReadA(int, unsigned char *);
int /*<<< orphan*/ RegWriteA(int, int);
int /*<<< orphan*/ SrvCon(int, int);
int /*<<< orphan*/ WitTim(int);
void StbOnn(void) {
  unsigned char UcRegValx, UcRegValy;
  unsigned char UcRegIni;
  unsigned char UcCnt;
  RegReadA(0x0170, &UcRegValx);
  RegReadA(0x0171, &UcRegValy);
  if (((UcRegValx & 0x01) != 0x01) && ((UcRegValy & 0x01) != 0x01)) {
    RegWriteA(0x017C, 0x01);
    SrvCon(0x00, 0x01);
    SrvCon(0x01, 0x01);
    for (UcCnt = 0; UcCnt < 60; UcCnt++) {
      RegReadA(0x01F8, &UcRegIni);
      if ((UcRegIni & 0x77) == 0x66)
        break;
      WitTim(10);
    }
    RegWriteA(0x017C, 0x00);
    if (UcCnt == 60) {
      RamWriteA(0x1462, 0);
      RamWriteA(0x14E2, 0);
    }
  } else {
    SrvCon(0x00, 0x01);
    SrvCon(0x01, 0x01);
  }
}


x86 assembly (clang, -O0):
<StbOnn>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0x170,%edi
lea    -0x1(%rbp),%rsi
call   1060 <RegReadA@plt>
mov    $0x171,%edi
lea    -0x2(%rbp),%rsi
call   1060 <RegReadA@plt>
movzbl -0x1(%rbp),%eax
and    $0x1,%eax
cmp    $0x1,%eax
je     123c <StbOnn+0xec>
movzbl -0x2(%rbp),%eax
and    $0x1,%eax
cmp    $0x1,%eax
je     123c <StbOnn+0xec>
mov    $0x17c,%edi
mov    $0x1,%esi
call   1070 <RegWriteA@plt>
xor    %edi,%edi
mov    $0x1,%esi
call   1030 <SrvCon@plt>
mov    $0x1,%esi
mov    %esi,%edi
call   1030 <SrvCon@plt>
movb   $0x0,-0x4(%rbp)
movzbl -0x4(%rbp),%eax
cmp    $0x3c,%eax
jge    1206 <StbOnn+0xb6>
mov    $0x1f8,%edi
lea    -0x3(%rbp),%rsi
call   1060 <RegReadA@plt>
movzbl -0x3(%rbp),%eax
and    $0x77,%eax
cmp    $0x66,%eax
jne    11ef <StbOnn+0x9f>
jmp    1206 <StbOnn+0xb6>
mov    $0xa,%edi
call   1050 <WitTim@plt>
mov    -0x4(%rbp),%al
add    $0x1,%al
mov    %al,-0x4(%rbp)
jmp    11bf <StbOnn+0x6f>
mov    $0x17c,%edi
xor    %esi,%esi
call   1070 <RegWriteA@plt>
movzbl -0x4(%rbp),%eax
cmp    $0x3c,%eax
jne    1237 <StbOnn+0xe7>
mov    $0x1462,%edi
xor    %esi,%esi
call   1040 <RamWriteA@plt>
mov    $0x14e2,%edi
xor    %esi,%esi
call   1040 <RamWriteA@plt>
jmp    1254 <StbOnn+0x104>
xor    %edi,%edi
mov    $0x1,%esi
call   1030 <SrvCon@plt>
mov    $0x1,%esi
mov    %esi,%edi
call   1030 <SrvCon@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<StbOnn>:
push   %r14
push   %rbx
push   %rax
lea    0x7(%rsp),%rsi
mov    $0x170,%edi
call   1060 <RegReadA@plt>
lea    0x6(%rsp),%rsi
mov    $0x171,%edi
call   1060 <RegReadA@plt>
testb  $0x1,0x7(%rsp)
jne    120d <StbOnn+0xbd>
testb  $0x1,0x6(%rsp)
jne    120d <StbOnn+0xbd>
mov    $0x17c,%edi
mov    $0x1,%esi
call   1070 <RegWriteA@plt>
xor    %edi,%edi
mov    $0x1,%esi
call   1030 <SrvCon@plt>
mov    $0x1,%edi
mov    $0x1,%esi
call   1030 <SrvCon@plt>
mov    $0x3c,%bl
lea    0x5(%rsp),%r14
nopl   0x0(%rax)
mov    $0x1f8,%edi
mov    %r14,%rsi
call   1060 <RegReadA@plt>
movzbl 0x5(%rsp),%eax
and    $0x77,%al
cmp    $0x66,%al
je     1230 <StbOnn+0xe0>
mov    $0xa,%edi
call   1050 <WitTim@plt>
add    $0xff,%bl
jne    11c0 <StbOnn+0x70>
mov    $0x17c,%edi
xor    %esi,%esi
call   1070 <RegWriteA@plt>
mov    $0x1462,%edi
xor    %esi,%esi
call   1040 <RamWriteA@plt>
mov    $0x14e2,%edi
xor    %esi,%esi
call   1040 <RamWriteA@plt>
jmp    1228 <StbOnn+0xd8>
xor    %edi,%edi
mov    $0x1,%esi
call   1030 <SrvCon@plt>
mov    $0x1,%edi
mov    $0x1,%esi
call   1030 <SrvCon@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret
mov    $0x17c,%edi
xor    %esi,%esi
call   1070 <RegWriteA@plt>
jmp    1228 <StbOnn+0xd8>

LLVM IR (-O0):
define void @StbOnn() {
%1 = alloca i8
%2 = alloca i8
%3 = alloca i8
%4 = alloca i8
%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 %45
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 %45
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 0, i8* %4
br label %20
20: ; preds = %33, %16
%21 = load i8, i8* %4
%22 = zext i8 %21 to i32
%23 = icmp slt i32 %22, 60
br i1 %23, label %24, label %36
24: ; preds = %20
%25 = call i32 @RegReadA(i32 504, i8* %3)
%26 = load i8, i8* %3
%27 = zext i8 %26 to i32
%28 = and i32 %27, 119
%29 = icmp eq i32 %28, 102
br i1 %29, label %30, label %31
30: ; preds = %24
br label %36
31: ; preds = %24
%32 = call i32 @WitTim(i32 10)
br label %33
33: ; preds = %31
%34 = load i8, i8* %4
%35 = add i8 %34, 1
store i8 %35, i8* %4
br label %20
36: ; preds = %30, %20
%37 = call i32 @RegWriteA(i32 380, i32 0)
%38 = load i8, i8* %4
%39 = zext i8 %38 to i32
%40 = icmp eq i32 %39, 60
br i1 %40, label %41, label %44
41: ; preds = %36
%42 = call i32 @RamWriteA(i32 5218, i32 0)
%43 = call i32 @RamWriteA(i32 5346, i32 0)
br label %44
44: ; preds = %41, %36
br label %48
45: ; preds = %11, %0
%46 = call i32 @SrvCon(i32 0, i32 1)
%47 = call i32 @SrvCon(i32 1, i32 1)
br label %48
48: ; preds = %45, %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 %33
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 %33
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)
br label %17
17: ; preds = %13, %25
%18 = phi i8 [ 0, %13 ], [ %27, %25 ]
%19 = call i32 @RegReadA(i32 504, i8* %3)
%20 = load i8, i8* %3
%21 = and i8 %20, 119
%22 = icmp eq i8 %21, 102
br i1 %22, label %23, label %25
23: ; preds = %17
%24 = call i32 @RegWriteA(i32 380, i32 0)
br label %36
25: ; preds = %17
%26 = call i32 @WitTim(i32 10)
%27 = add nuw nsw i8 %18, 1
%28 = icmp eq i8 %27, 60
br i1 %28, label %29, label %17
29: ; preds = %25
%30 = call i32 @RegWriteA(i32 380, i32 0)
%31 = call i32 @RamWriteA(i32 5218, i32 0)
%32 = call i32 @RamWriteA(i32 5346, i32 0)
br label %36
33: ; preds = %9, %0
%34 = call i32 @SrvCon(i32 0, i32 1)
%35 = call i32 @SrvCon(i32 1, i32 1)
br label %36
36: ; preds = %23, %29, %33
ret void
}