#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, 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);
    UcCnt = 0;
    UcRegIni = 0x11;
    while ((UcRegIni & 0x77) != 0x66) {
      RegReadA(0x01F8, &UcRegIni);
      WitTim(1);
      UcCnt = UcCnt + 1;
      if (UcCnt > 60) {
        break;
      }
    }
    RegWriteA(0x017C, 0x00);
  } 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   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     120d <StbOnn+0xcd>
movzbl -0x2(%rbp),%eax
and    $0x1,%eax
cmp    $0x1,%eax
je     120d <StbOnn+0xcd>
mov    $0x17c,%edi
mov    $0x1,%esi
call   1060 <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)
movb   $0x11,-0x3(%rbp)
movzbl -0x3(%rbp),%eax
and    $0x77,%eax
cmp    $0x66,%eax
je     11fc <StbOnn+0xbc>
mov    $0x1f8,%edi
lea    -0x3(%rbp),%rsi
call   1050 <RegReadA@plt>
mov    $0x1,%edi
call   1040 <WitTim@plt>
movzbl -0x4(%rbp),%eax
add    $0x1,%eax
mov    %al,-0x4(%rbp)
movzbl -0x4(%rbp),%eax
cmp    $0x3c,%eax
jle    11f7 <StbOnn+0xb7>
jmp    11fc <StbOnn+0xbc>
jmp    11b3 <StbOnn+0x73>
mov    $0x17c,%edi
xor    %esi,%esi
call   1060 <RegWriteA@plt>
jmp    1225 <StbOnn+0xe5>
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   %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    11f0 <StbOnn+0xb0>
testb  $0x1,0x6(%rsp)
jne    11f0 <StbOnn+0xb0>
mov    $0x17c,%edi
mov    $0x1,%esi
call   1060 <RegWriteA@plt>
xor    %ebp,%ebp
xor    %edi,%edi
mov    $0x1,%esi
call   1030 <SrvCon@plt>
mov    $0x1,%edi
mov    $0x1,%esi
call   1030 <SrvCon@plt>
movb   $0x11,0x5(%rsp)
lea    0x5(%rsp),%rbx
nopl   (%rax)
mov    $0x1f8,%edi
mov    %rbx,%rsi
call   1050 <RegReadA@plt>
mov    $0x1,%edi
call   1040 <WitTim@plt>
movzbl %bpl,%ebp
add    $0x1,%ebp
movzbl %bpl,%eax
cmp    $0x3c,%eax
ja     11e2 <StbOnn+0xa2>
movzbl 0x5(%rsp),%eax
and    $0x77,%al
cmp    $0x66,%al
jne    11b0 <StbOnn+0x70>
mov    $0x17c,%edi
xor    %esi,%esi
call   1060 <RegWriteA@plt>
jmp    120b <StbOnn+0xcb>
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    %rbp
ret

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 %39
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 %39
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
store i8 17, i8* %3
br label %20
20: ; preds = %36, %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 %37
25: ; preds = %20
%26 = call i32 @RegReadA(i32 504, i8* %3)
%27 = call i32 @WitTim(i32 1)
%28 = load i8, i8* %4
%29 = zext i8 %28 to i32
%30 = add nsw i32 %29, 1
%31 = trunc i32 %30 to i8
store i8 %31, i8* %4
%32 = load i8, i8* %4
%33 = zext i8 %32 to i32
%34 = icmp sgt i32 %33, 60
br i1 %34, label %35, label %36
35: ; preds = %25
br label %37
36: ; preds = %25
br label %20
37: ; preds = %35, %20
%38 = call i32 @RegWriteA(i32 380, i32 0)
br label %42
39: ; preds = %11, %0
%40 = call i32 @SrvCon(i32 0, i32 1)
%41 = call i32 @SrvCon(i32 1, i32 1)
br label %42
42: ; preds = %39, %37
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 %31
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 %31
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 = %13, %25
%18 = phi i32 [ 0, %13 ], [ %22, %25 ]
%19 = call i32 @RegReadA(i32 504, i8* %3)
%20 = call i32 @WitTim(i32 1)
%21 = and i32 %18, 255
%22 = add nuw nsw i32 %21, 1
%23 = and i32 %22, 255
%24 = icmp ugt i32 %23, 60
br i1 %24, label %29, label %25
25: ; preds = %17
%26 = load i8, i8* %3
%27 = and i8 %26, 119
%28 = icmp eq i8 %27, 102
br i1 %28, label %29, label %17
29: ; preds = %17, %25
%30 = call i32 @RegWriteA(i32 380, i32 0)
br label %34
31: ; preds = %9, %0
%32 = call i32 @SrvCon(i32 0, i32 1)
%33 = call i32 @SrvCon(i32 1, i32 1)
br label %34
34: ; preds = %31, %29
ret void
}