#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, unsigned char);
void ClrGyr(unsigned short UsClrFil, unsigned char UcClrMod) {
  unsigned char UcRamClr;
  unsigned char count = 0;
  RegWriteA(0x018F, (unsigned char)(UsClrFil >> 8));
  RegWriteA(0x018E, (unsigned char)UsClrFil);
  RegWriteA(0x0102, UcClrMod);
  do {
    RegReadA(0x0102, &UcRamClr);
    UcRamClr &= UcClrMod;
    if (count++ >= 100) {
      break;
    }
  } while (UcRamClr != 0x00);
}


x86 assembly (clang, -O0):
<ClrGyr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %sil,%al
mov    %di,%cx
mov    %cx,-0x2(%rbp)
mov    %al,-0x3(%rbp)
movb   $0x0,-0x5(%rbp)
movzwl -0x2(%rbp),%eax
sar    $0x8,%eax
mov    $0x18f,%edi
movzbl %al,%esi
call   1040 <RegWriteA@plt>
mov    -0x2(%rbp),%ax
mov    $0x18e,%edi
movzbl %al,%esi
call   1040 <RegWriteA@plt>
mov    $0x102,%edi
movzbl -0x3(%rbp),%esi
call   1040 <RegWriteA@plt>
mov    $0x102,%edi
lea    -0x4(%rbp),%rsi
call   1030 <RegReadA@plt>
movzbl -0x3(%rbp),%ecx
movzbl -0x4(%rbp),%eax
and    %ecx,%eax
mov    %al,-0x4(%rbp)
mov    -0x5(%rbp),%al
mov    %al,%cl
add    $0x1,%cl
mov    %cl,-0x5(%rbp)
movzbl %al,%eax
cmp    $0x64,%eax
jl     11a3 <ClrGyr+0x83>
jmp    11b5 <ClrGyr+0x95>
jmp    11a8 <ClrGyr+0x88>
movzbl -0x4(%rbp),%eax
cmp    $0x0,%eax
jne    116c <ClrGyr+0x4c>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ClrGyr>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %esi,%ebx
mov    %edi,%ebp
mov    %edi,%esi
shr    $0x8,%esi
mov    $0x18f,%edi
call   1040 <RegWriteA@plt>
movzbl %bpl,%esi
mov    $0x18e,%edi
call   1040 <RegWriteA@plt>
mov    $0x102,%edi
mov    %ebx,%esi
call   1040 <RegWriteA@plt>
xor    %ebp,%ebp
lea    0xf(%rsp),%r14
nopl   0x0(%rax)
mov    $0x102,%edi
mov    %r14,%rsi
call   1030 <RegReadA@plt>
movzbl 0xf(%rsp),%eax
and    %bl,%al
mov    %al,0xf(%rsp)
cmp    $0x63,%bpl
ja     1186 <ClrGyr+0x66>
add    $0x1,%bpl
test   %al,%al
jne    1160 <ClrGyr+0x40>
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define void @ClrGyr(i16 zeroext %0, i8 zeroext %1) {
%3 = alloca i16
%4 = alloca i8
%5 = alloca i8
%6 = alloca i8
store i16 %0, i16* %3
store i8 %1, i8* %4
store i8 0, i8* %6
%7 = load i16, i16* %3
%8 = zext i16 %7 to i32
%9 = ashr i32 %8, 8
%10 = trunc i32 %9 to i8
%11 = call i32 @RegWriteA(i32 399, i8 zeroext %10)
%12 = load i16, i16* %3
%13 = trunc i16 %12 to i8
%14 = call i32 @RegWriteA(i32 398, i8 zeroext %13)
%15 = load i8, i8* %4
%16 = call i32 @RegWriteA(i32 258, i8 zeroext %15)
br label %17
17: ; preds = %31, %2
%18 = call i32 @RegReadA(i32 258, i8* %5)
%19 = load i8, i8* %4
%20 = zext i8 %19 to i32
%21 = load i8, i8* %5
%22 = zext i8 %21 to i32
%23 = and i32 %22, %20
%24 = trunc i32 %23 to i8
store i8 %24, i8* %5
%25 = load i8, i8* %6
%26 = add i8 %25, 1
store i8 %26, i8* %6
%27 = zext i8 %25 to i32
%28 = icmp sge i32 %27, 100
br i1 %28, label %29, label %30
29: ; preds = %17
br label %35
30: ; preds = %17
br label %31
31: ; preds = %30
%32 = load i8, i8* %5
%33 = zext i8 %32 to i32
%34 = icmp ne i32 %33, 0
br i1 %34, label %17, label %35
35: ; preds = %31, %29
ret void
}

LLVM IR (-O2):
define void @ClrGyr(i16 zeroext %0, i8 zeroext %1) {
%3 = alloca i8
%4 = lshr i16 %0, 8
%5 = trunc i16 %4 to i8
%6 = tail call i32 @RegWriteA(i32 399, i8 zeroext %5)
%7 = trunc i16 %0 to i8
%8 = tail call i32 @RegWriteA(i32 398, i8 zeroext %7)
%9 = tail call i32 @RegWriteA(i32 258, i8 zeroext %1)
br label %10
10: ; preds = %10, %2
%11 = phi i8 [ 0, %2 ], [ %15, %10 ]
%12 = call i32 @RegReadA(i32 258, i8* %3)
%13 = load i8, i8* %3
%14 = and i8 %13, %1
store i8 %14, i8* %3
%15 = add nuw nsw i8 %11, 1
%16 = icmp ult i8 %11, 100
%17 = icmp ne i8 %14, 0
%18 = select i1 %16, i1 %17, i1 false
br i1 %18, label %10, label %19
19: ; preds = %10
ret void
}