#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*/ RamRead32A(int, unsigned long *);
int /*<<< orphan*/ RamWrite32A(int, int);
int /*<<< orphan*/ WitTim(int);
void GyroSleep(unsigned char UcCtrl) {
  unsigned char UcReg;
  unsigned long UlVal;
  RamWrite32A(0xF01D, 0x6B000000);
  WitTim(5);
  RamRead32A(0xF01D, &UlVal);
  WitTim(5);
  UcReg = (unsigned char)(UlVal >> 24);
  if (UcCtrl == 0x01) {
    UcReg = UcReg | 0x40;
  } else if (UcCtrl == 0x00) {
    UcReg = UcReg & 0xBF;
  }
  RamWrite32A(0xF01E, (0x6B000000 | (UcReg << 16)));
}


x86 assembly (clang, -O0):
<GyroSleep>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %dil,%al
mov    %al,-0x1(%rbp)
mov    $0xf01d,%edi
mov    $0x6b000000,%esi
call   1040 <RamWrite32A@plt>
mov    $0x5,%edi
call   1050 <WitTim@plt>
mov    $0xf01d,%edi
lea    -0x10(%rbp),%rsi
call   1030 <RamRead32A@plt>
mov    $0x5,%edi
call   1050 <WitTim@plt>
mov    -0x10(%rbp),%rax
shr    $0x18,%rax
mov    %al,-0x2(%rbp)
movzbl -0x1(%rbp),%eax
cmp    $0x1,%eax
jne    1196 <GyroSleep+0x66>
movzbl -0x2(%rbp),%eax
or     $0x40,%eax
mov    %al,-0x2(%rbp)
jmp    11b4 <GyroSleep+0x84>
movzbl -0x1(%rbp),%eax
cmp    $0x0,%eax
jne    11af <GyroSleep+0x7f>
movzbl -0x2(%rbp),%eax
and    $0xbf,%eax
mov    %al,-0x2(%rbp)
jmp    11b4 <GyroSleep+0x84>
movzbl -0x2(%rbp),%esi
shl    $0x10,%esi
or     $0x6b000000,%esi
mov    $0xf01e,%edi
call   1040 <RamWrite32A@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<GyroSleep>:
push   %rbx
sub    $0x10,%rsp
mov    %edi,%ebx
mov    $0xf01d,%edi
mov    $0x6b000000,%esi
call   1040 <RamWrite32A@plt>
mov    $0x5,%edi
call   1050 <WitTim@plt>
lea    0x8(%rsp),%rsi
mov    $0xf01d,%edi
call   1030 <RamRead32A@plt>
mov    $0x5,%edi
call   1050 <WitTim@plt>
mov    0xb(%rsp),%eax
mov    %eax,%ecx
or     $0x40,%ecx
mov    %eax,%edx
and    $0xbf,%edx
test   %ebx,%ebx
cmovne %eax,%edx
cmp    $0x1,%bl
cmove  %ecx,%edx
movzbl %dl,%esi
shl    $0x10,%esi
or     $0x6b000000,%esi
mov    $0xf01e,%edi
call   1040 <RamWrite32A@plt>
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
define void @GyroSleep(i8 zeroext %0) {
%2 = alloca i8
%3 = alloca i8
%4 = alloca i64
store i8 %0, i8* %2
%5 = call i32 @RamWrite32A(i32 61469, i32 1795162112)
%6 = call i32 @WitTim(i32 5)
%7 = call i32 @RamRead32A(i32 61469, i64* %4)
%8 = call i32 @WitTim(i32 5)
%9 = load i64, i64* %4
%10 = lshr i64 %9, 24
%11 = trunc i64 %10 to i8
store i8 %11, i8* %3
%12 = load i8, i8* %2
%13 = zext i8 %12 to i32
%14 = icmp eq i32 %13, 1
br i1 %14, label %15, label %20
15: ; preds = %1
%16 = load i8, i8* %3
%17 = zext i8 %16 to i32
%18 = or i32 %17, 64
%19 = trunc i32 %18 to i8
store i8 %19, i8* %3
br label %30
20: ; preds = %1
%21 = load i8, i8* %2
%22 = zext i8 %21 to i32
%23 = icmp eq i32 %22, 0
br i1 %23, label %24, label %29
24: ; preds = %20
%25 = load i8, i8* %3
%26 = zext i8 %25 to i32
%27 = and i32 %26, 191
%28 = trunc i32 %27 to i8
store i8 %28, i8* %3
br label %29
29: ; preds = %24, %20
br label %30
30: ; preds = %29, %15
%31 = load i8, i8* %3
%32 = zext i8 %31 to i32
%33 = shl i32 %32, 16
%34 = or i32 1795162112, %33
%35 = call i32 @RamWrite32A(i32 61470, i32 %34)
ret void
}

LLVM IR (-O2):
define void @GyroSleep(i8 zeroext %0) {
%2 = alloca i64
%3 = bitcast i64* %2 to i8*
%4 = tail call i32 @RamWrite32A(i32 61469, i32 1795162112)
%5 = tail call i32 @WitTim(i32 5)
%6 = call i32 @RamRead32A(i32 61469, i64* %2)
%7 = call i32 @WitTim(i32 5)
%8 = load i64, i64* %2
%9 = lshr i64 %8, 24
%10 = icmp eq i8 %0, 1
%11 = trunc i64 %9 to i32
%12 = or i32 %11, 64
%13 = icmp eq i8 %0, 0
%14 = and i32 %11, 191
%15 = select i1 %13, i32 %14, i32 %11
%16 = select i1 %10, i32 %12, i32 %15
%17 = shl i32 %16, 16
%18 = and i32 %17, 16711680
%19 = or i32 %18, 1795162112
%20 = call i32 @RamWrite32A(i32 61470, i32 %19)
ret void
}