#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*/ AccWit(int);
int /*<<< orphan*/ ClrGyr(int, int);
int /*<<< orphan*/ GyOutSignal();
int /*<<< orphan*/ RegReadA(int, unsigned char *);
int /*<<< orphan*/ RegWriteA(int, int);
int /*<<< orphan*/ WitTim(int);
void SelectGySleep(unsigned char UcSelMode) {
  unsigned char UcRamIni;
  unsigned char UcGrini;
  if (UcSelMode == 0x01) {
    RegWriteA(0x0101, 0x00);
    RegWriteA(0x0280, 0x01);
    RegReadA(0x0281, &UcGrini);
    RegWriteA(0x0281, (unsigned char)(UcGrini | 0x04));
    RegWriteA(0x0283, 0x6B);
    RegWriteA(0x0282, 0x01);
    AccWit(0x01);
    RegReadA(0x0290, &UcRamIni);
    UcRamIni |= 0x40;
    RegWriteA(0x0283, 0x6B);
    RegWriteA(0x028A, UcRamIni);
    RegWriteA(0x0282, 0x10);
    AccWit(0x10);
  } else {
    RegWriteA(0x0283, 0x6B);
    RegWriteA(0x0282, 0x01);
    AccWit(0x01);
    RegReadA(0x0290, &UcRamIni);
    UcRamIni &= ~0x40;
    RegWriteA(0x028A, UcRamIni);
    RegWriteA(0x0282, 0x10);
    AccWit(0x10);
    RegReadA(0x0281, &UcGrini);
    RegWriteA(0x0281, (unsigned char)(UcGrini & ~0x04));
    GyOutSignal();
    WitTim(50);
    RegWriteA(0x0101, 0x01);
    ClrGyr(0x007F, 0x02);
  }
}


x86 assembly (clang, -O0):
<SelectGySleep>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %dil,%al
mov    %al,-0x1(%rbp)
movzbl -0x1(%rbp),%eax
cmp    $0x1,%eax
jne    1233 <SelectGySleep+0xd3>
mov    $0x101,%edi
xor    %esi,%esi
call   1070 <RegWriteA@plt>
mov    $0x280,%edi
mov    $0x1,%esi
call   1070 <RegWriteA@plt>
mov    $0x281,%edi
lea    -0x3(%rbp),%rsi
call   1060 <RegReadA@plt>
movzbl -0x3(%rbp),%eax
or     $0x4,%eax
movzbl %al,%esi
mov    $0x281,%edi
call   1070 <RegWriteA@plt>
mov    $0x283,%edi
mov    $0x6b,%esi
call   1070 <RegWriteA@plt>
mov    $0x282,%edi
mov    $0x1,%esi
call   1070 <RegWriteA@plt>
mov    $0x1,%edi
call   1030 <AccWit@plt>
mov    $0x290,%edi
lea    -0x2(%rbp),%rsi
call   1060 <RegReadA@plt>
movzbl -0x2(%rbp),%eax
or     $0x40,%eax
mov    %al,-0x2(%rbp)
mov    $0x283,%edi
mov    $0x6b,%esi
call   1070 <RegWriteA@plt>
movzbl -0x2(%rbp),%esi
mov    $0x28a,%edi
call   1070 <RegWriteA@plt>
mov    $0x282,%edi
mov    $0x10,%esi
call   1070 <RegWriteA@plt>
mov    $0x10,%edi
call   1030 <AccWit@plt>
jmp    12eb <SelectGySleep+0x18b>
mov    $0x283,%edi
mov    $0x6b,%esi
call   1070 <RegWriteA@plt>
mov    $0x282,%edi
mov    $0x1,%esi
call   1070 <RegWriteA@plt>
mov    $0x1,%edi
call   1030 <AccWit@plt>
mov    $0x290,%edi
lea    -0x2(%rbp),%rsi
call   1060 <RegReadA@plt>
movzbl -0x2(%rbp),%eax
and    $0xffffffbf,%eax
mov    %al,-0x2(%rbp)
movzbl -0x2(%rbp),%esi
mov    $0x28a,%edi
call   1070 <RegWriteA@plt>
mov    $0x282,%edi
mov    $0x10,%esi
call   1070 <RegWriteA@plt>
mov    $0x10,%edi
call   1030 <AccWit@plt>
mov    $0x281,%edi
lea    -0x3(%rbp),%rsi
call   1060 <RegReadA@plt>
movzbl -0x3(%rbp),%eax
and    $0xfffffffb,%eax
movzbl %al,%esi
mov    $0x281,%edi
call   1070 <RegWriteA@plt>
mov    $0x0,%al
call   1080 <GyOutSignal@plt>
mov    $0x32,%edi
call   1050 <WitTim@plt>
mov    $0x101,%edi
mov    $0x1,%esi
call   1070 <RegWriteA@plt>
mov    $0x7f,%edi
mov    $0x2,%esi
call   1040 <ClrGyr@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<SelectGySleep>:
push   %rax
cmp    $0x1,%dil
jne    121c <SelectGySleep+0xbc>
mov    $0x101,%edi
xor    %esi,%esi
call   1070 <RegWriteA@plt>
mov    $0x280,%edi
mov    $0x1,%esi
call   1070 <RegWriteA@plt>
lea    0x7(%rsp),%rsi
mov    $0x281,%edi
call   1060 <RegReadA@plt>
movzbl 0x7(%rsp),%esi
or     $0x4,%esi
mov    $0x281,%edi
call   1070 <RegWriteA@plt>
mov    $0x283,%edi
mov    $0x6b,%esi
call   1070 <RegWriteA@plt>
mov    $0x282,%edi
mov    $0x1,%esi
call   1070 <RegWriteA@plt>
mov    $0x1,%edi
call   1030 <AccWit@plt>
lea    0x6(%rsp),%rsi
mov    $0x290,%edi
call   1060 <RegReadA@plt>
orb    $0x40,0x6(%rsp)
mov    $0x283,%edi
mov    $0x6b,%esi
call   1070 <RegWriteA@plt>
movzbl 0x6(%rsp),%esi
mov    $0x28a,%edi
call   1070 <RegWriteA@plt>
mov    $0x282,%edi
mov    $0x10,%esi
call   1070 <RegWriteA@plt>
mov    $0x10,%edi
call   1030 <AccWit@plt>
pop    %rax
ret
mov    $0x283,%edi
mov    $0x6b,%esi
call   1070 <RegWriteA@plt>
mov    $0x282,%edi
mov    $0x1,%esi
call   1070 <RegWriteA@plt>
mov    $0x1,%edi
call   1030 <AccWit@plt>
lea    0x6(%rsp),%rsi
mov    $0x290,%edi
call   1060 <RegReadA@plt>
movzbl 0x6(%rsp),%esi
and    $0xffffffbf,%esi
mov    %sil,0x6(%rsp)
mov    $0x28a,%edi
call   1070 <RegWriteA@plt>
mov    $0x282,%edi
mov    $0x10,%esi
call   1070 <RegWriteA@plt>
mov    $0x10,%edi
call   1030 <AccWit@plt>
lea    0x7(%rsp),%rsi
mov    $0x281,%edi
call   1060 <RegReadA@plt>
movzbl 0x7(%rsp),%esi
and    $0xfffffffb,%esi
mov    $0x281,%edi
call   1070 <RegWriteA@plt>
xor    %eax,%eax
call   1080 <GyOutSignal@plt>
mov    $0x32,%edi
call   1050 <WitTim@plt>
mov    $0x101,%edi
mov    $0x1,%esi
call   1070 <RegWriteA@plt>
mov    $0x7f,%edi
mov    $0x2,%esi
call   1040 <ClrGyr@plt>
pop    %rax
ret

LLVM IR (-O0):
define void @SelectGySleep(i8 zeroext %0) {
%2 = alloca i8
%3 = alloca i8
%4 = alloca i8
store i8 %0, i8* %2
%5 = load i8, i8* %2
%6 = zext i8 %5 to i32
%7 = icmp eq i32 %6, 1
br i1 %7, label %8, label %32
8: ; preds = %1
%9 = call i32 @RegWriteA(i32 257, i32 0)
%10 = call i32 @RegWriteA(i32 640, i32 1)
%11 = call i32 @RegReadA(i32 641, i8* %4)
%12 = load i8, i8* %4
%13 = zext i8 %12 to i32
%14 = or i32 %13, 4
%15 = trunc i32 %14 to i8
%16 = zext i8 %15 to i32
%17 = call i32 @RegWriteA(i32 641, i32 %16)
%18 = call i32 @RegWriteA(i32 643, i32 107)
%19 = call i32 @RegWriteA(i32 642, i32 1)
%20 = call i32 @AccWit(i32 1)
%21 = call i32 @RegReadA(i32 656, i8* %3)
%22 = load i8, i8* %3
%23 = zext i8 %22 to i32
%24 = or i32 %23, 64
%25 = trunc i32 %24 to i8
store i8 %25, i8* %3
%26 = call i32 @RegWriteA(i32 643, i32 107)
%27 = load i8, i8* %3
%28 = zext i8 %27 to i32
%29 = call i32 @RegWriteA(i32 650, i32 %28)
%30 = call i32 @RegWriteA(i32 642, i32 16)
%31 = call i32 @AccWit(i32 16)
br label %57
32: ; preds = %1
%33 = call i32 @RegWriteA(i32 643, i32 107)
%34 = call i32 @RegWriteA(i32 642, i32 1)
%35 = call i32 @AccWit(i32 1)
%36 = call i32 @RegReadA(i32 656, i8* %3)
%37 = load i8, i8* %3
%38 = zext i8 %37 to i32
%39 = and i32 %38, -65
%40 = trunc i32 %39 to i8
store i8 %40, i8* %3
%41 = load i8, i8* %3
%42 = zext i8 %41 to i32
%43 = call i32 @RegWriteA(i32 650, i32 %42)
%44 = call i32 @RegWriteA(i32 642, i32 16)
%45 = call i32 @AccWit(i32 16)
%46 = call i32 @RegReadA(i32 641, i8* %4)
%47 = load i8, i8* %4
%48 = zext i8 %47 to i32
%49 = and i32 %48, -5
%50 = trunc i32 %49 to i8
%51 = zext i8 %50 to i32
%52 = call i32 @RegWriteA(i32 641, i32 %51)
%53 = call i32 (...) @GyOutSignal()
%54 = call i32 @WitTim(i32 50)
%55 = call i32 @RegWriteA(i32 257, i32 1)
%56 = call i32 @ClrGyr(i32 127, i32 2)
br label %57
57: ; preds = %32, %8
ret void
}

LLVM IR (-O2):
define void @SelectGySleep(i8 zeroext %0) {
%2 = alloca i8
%3 = alloca i8
%4 = icmp eq i8 %0, 1
br i1 %4, label %5, label %25
5: ; preds = %1
%6 = tail call i32 @RegWriteA(i32 257, i32 0)
%7 = tail call i32 @RegWriteA(i32 640, i32 1)
%8 = call i32 @RegReadA(i32 641, i8* %3)
%9 = load i8, i8* %3
%10 = or i8 %9, 4
%11 = zext i8 %10 to i32
%12 = call i32 @RegWriteA(i32 641, i32 %11)
%13 = call i32 @RegWriteA(i32 643, i32 107)
%14 = call i32 @RegWriteA(i32 642, i32 1)
%15 = call i32 @AccWit(i32 1)
%16 = call i32 @RegReadA(i32 656, i8* %2)
%17 = load i8, i8* %2
%18 = or i8 %17, 64
store i8 %18, i8* %2
%19 = call i32 @RegWriteA(i32 643, i32 107)
%20 = load i8, i8* %2
%21 = zext i8 %20 to i32
%22 = call i32 @RegWriteA(i32 650, i32 %21)
%23 = call i32 @RegWriteA(i32 642, i32 16)
%24 = call i32 @AccWit(i32 16)
br label %45
25: ; preds = %1
%26 = tail call i32 @RegWriteA(i32 643, i32 107)
%27 = tail call i32 @RegWriteA(i32 642, i32 1)
%28 = tail call i32 @AccWit(i32 1)
%29 = call i32 @RegReadA(i32 656, i8* %2)
%30 = load i8, i8* %2
%31 = and i8 %30, -65
store i8 %31, i8* %2
%32 = zext i8 %31 to i32
%33 = call i32 @RegWriteA(i32 650, i32 %32)
%34 = call i32 @RegWriteA(i32 642, i32 16)
%35 = call i32 @AccWit(i32 16)
%36 = call i32 @RegReadA(i32 641, i8* %3)
%37 = load i8, i8* %3
%38 = and i8 %37, -5
%39 = zext i8 %38 to i32
%40 = call i32 @RegWriteA(i32 641, i32 %39)
%41 = call i32 (...) @GyOutSignal()
%42 = call i32 @WitTim(i32 50)
%43 = call i32 @RegWriteA(i32 257, i32 1)
%44 = call i32 @ClrGyr(i32 127, i32 2)
br label %45
45: ; preds = %25, %5
ret void
}