#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*/ AfSrvCurPos();
int /*<<< orphan*/ RamAccFixMod(int);
int /*<<< orphan*/ RamWriteA(int, int);
int /*<<< orphan*/ RegReadA(int, unsigned char *);
int /*<<< orphan*/ RegWriteA(int, int);
void AfSrvOnOffset(void) {
  unsigned char UcRegDat;
  RegReadA(0x01E0, &UcRegDat);
  if ((UcRegDat & 0x13) != 0x13) {
    RegWriteA(0x01E0, 0x02);
    RamAccFixMod(0x01);
    RamWriteA(0x1504, 0x0000);
    RamWriteA(0x150B, 0x0000);
    RamWriteA(0x150C, 0x0000);
    RamWriteA(0x150E, 0x0000);
    RamWriteA(0x150F, 0x0000);
    RamWriteA(0x1511, 0x0000);
    RamWriteA(0x1512, 0x0000);
    RamWriteA(0x1505, 0x0000);
    RamWriteA(0x1506, 0x0000);
    RamWriteA(0x1508, 0x0000);
    RamWriteA(0x1509, 0x0000);
    RamWriteA(0x1516, 0x0000);
    RamWriteA(0x1517, 0x0000);
    RamWriteA(0x1518, 0x0000);
    RamWriteA(0x1519, 0x0000);
    RamWriteA(0x151B, 0x0000);
    RamWriteA(0x151A, 0x0000);
    RamWriteA(0x151C, 0x0000);
    RamWriteA(0x151D, 0x0000);
    AfSrvCurPos();
    RamAccFixMod(0x00);
    RegWriteA(0x01E0, 0x13);
  }
}


x86 assembly (clang, -O0):
<AfSrvOnOffset>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0x1e0,%edi
lea    -0x1(%rbp),%rsi
call   1050 <RegReadA@plt>
movzbl -0x1(%rbp),%eax
and    $0x13,%eax
cmp    $0x13,%eax
je     1290 <AfSrvOnOffset+0x140>
mov    $0x1e0,%edi
mov    $0x2,%esi
call   1060 <RegWriteA@plt>
mov    $0x1,%edi
call   1040 <RamAccFixMod@plt>
mov    $0x1504,%edi
xor    %esi,%esi
call   1030 <RamWriteA@plt>
mov    $0x150b,%edi
xor    %esi,%esi
call   1030 <RamWriteA@plt>
mov    $0x150c,%edi
xor    %esi,%esi
call   1030 <RamWriteA@plt>
mov    $0x150e,%edi
xor    %esi,%esi
call   1030 <RamWriteA@plt>
mov    $0x150f,%edi
xor    %esi,%esi
call   1030 <RamWriteA@plt>
mov    $0x1511,%edi
xor    %esi,%esi
call   1030 <RamWriteA@plt>
mov    $0x1512,%edi
xor    %esi,%esi
call   1030 <RamWriteA@plt>
mov    $0x1505,%edi
xor    %esi,%esi
call   1030 <RamWriteA@plt>
mov    $0x1506,%edi
xor    %esi,%esi
call   1030 <RamWriteA@plt>
mov    $0x1508,%edi
xor    %esi,%esi
call   1030 <RamWriteA@plt>
mov    $0x1509,%edi
xor    %esi,%esi
call   1030 <RamWriteA@plt>
mov    $0x1516,%edi
xor    %esi,%esi
call   1030 <RamWriteA@plt>
mov    $0x1517,%edi
xor    %esi,%esi
call   1030 <RamWriteA@plt>
mov    $0x1518,%edi
xor    %esi,%esi
call   1030 <RamWriteA@plt>
mov    $0x1519,%edi
xor    %esi,%esi
call   1030 <RamWriteA@plt>
mov    $0x151b,%edi
xor    %esi,%esi
call   1030 <RamWriteA@plt>
mov    $0x151a,%edi
xor    %esi,%esi
call   1030 <RamWriteA@plt>
mov    $0x151c,%edi
xor    %esi,%esi
call   1030 <RamWriteA@plt>
mov    $0x151d,%edi
xor    %esi,%esi
call   1030 <RamWriteA@plt>
mov    $0x0,%al
call   1070 <AfSrvCurPos@plt>
xor    %edi,%edi
call   1040 <RamAccFixMod@plt>
mov    $0x1e0,%edi
mov    $0x13,%esi
call   1060 <RegWriteA@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<AfSrvOnOffset>:
push   %rax
lea    0x7(%rsp),%rsi
mov    $0x1e0,%edi
call   1050 <RegReadA@plt>
mov    0x7(%rsp),%al
not    %al
test   $0x13,%al
je     1288 <AfSrvOnOffset+0x138>
mov    $0x1e0,%edi
mov    $0x2,%esi
call   1060 <RegWriteA@plt>
mov    $0x1,%edi
call   1040 <RamAccFixMod@plt>
mov    $0x1504,%edi
xor    %esi,%esi
call   1030 <RamWriteA@plt>
mov    $0x150b,%edi
xor    %esi,%esi
call   1030 <RamWriteA@plt>
mov    $0x150c,%edi
xor    %esi,%esi
call   1030 <RamWriteA@plt>
mov    $0x150e,%edi
xor    %esi,%esi
call   1030 <RamWriteA@plt>
mov    $0x150f,%edi
xor    %esi,%esi
call   1030 <RamWriteA@plt>
mov    $0x1511,%edi
xor    %esi,%esi
call   1030 <RamWriteA@plt>
mov    $0x1512,%edi
xor    %esi,%esi
call   1030 <RamWriteA@plt>
mov    $0x1505,%edi
xor    %esi,%esi
call   1030 <RamWriteA@plt>
mov    $0x1506,%edi
xor    %esi,%esi
call   1030 <RamWriteA@plt>
mov    $0x1508,%edi
xor    %esi,%esi
call   1030 <RamWriteA@plt>
mov    $0x1509,%edi
xor    %esi,%esi
call   1030 <RamWriteA@plt>
mov    $0x1516,%edi
xor    %esi,%esi
call   1030 <RamWriteA@plt>
mov    $0x1517,%edi
xor    %esi,%esi
call   1030 <RamWriteA@plt>
mov    $0x1518,%edi
xor    %esi,%esi
call   1030 <RamWriteA@plt>
mov    $0x1519,%edi
xor    %esi,%esi
call   1030 <RamWriteA@plt>
mov    $0x151b,%edi
xor    %esi,%esi
call   1030 <RamWriteA@plt>
mov    $0x151a,%edi
xor    %esi,%esi
call   1030 <RamWriteA@plt>
mov    $0x151c,%edi
xor    %esi,%esi
call   1030 <RamWriteA@plt>
mov    $0x151d,%edi
xor    %esi,%esi
call   1030 <RamWriteA@plt>
xor    %eax,%eax
call   1070 <AfSrvCurPos@plt>
xor    %edi,%edi
call   1040 <RamAccFixMod@plt>
mov    $0x1e0,%edi
mov    $0x13,%esi
call   1060 <RegWriteA@plt>
pop    %rax
ret

LLVM IR (-O0):
define void @AfSrvOnOffset() {
%1 = alloca i8
%2 = call i32 @RegReadA(i32 480, i8* %1)
%3 = load i8, i8* %1
%4 = zext i8 %3 to i32
%5 = and i32 %4, 19
%6 = icmp ne i32 %5, 19
br i1 %6, label %7, label %32
7: ; preds = %0
%8 = call i32 @RegWriteA(i32 480, i32 2)
%9 = call i32 @RamAccFixMod(i32 1)
%10 = call i32 @RamWriteA(i32 5380, i32 0)
%11 = call i32 @RamWriteA(i32 5387, i32 0)
%12 = call i32 @RamWriteA(i32 5388, i32 0)
%13 = call i32 @RamWriteA(i32 5390, i32 0)
%14 = call i32 @RamWriteA(i32 5391, i32 0)
%15 = call i32 @RamWriteA(i32 5393, i32 0)
%16 = call i32 @RamWriteA(i32 5394, i32 0)
%17 = call i32 @RamWriteA(i32 5381, i32 0)
%18 = call i32 @RamWriteA(i32 5382, i32 0)
%19 = call i32 @RamWriteA(i32 5384, i32 0)
%20 = call i32 @RamWriteA(i32 5385, i32 0)
%21 = call i32 @RamWriteA(i32 5398, i32 0)
%22 = call i32 @RamWriteA(i32 5399, i32 0)
%23 = call i32 @RamWriteA(i32 5400, i32 0)
%24 = call i32 @RamWriteA(i32 5401, i32 0)
%25 = call i32 @RamWriteA(i32 5403, i32 0)
%26 = call i32 @RamWriteA(i32 5402, i32 0)
%27 = call i32 @RamWriteA(i32 5404, i32 0)
%28 = call i32 @RamWriteA(i32 5405, i32 0)
%29 = call i32 (...) @AfSrvCurPos()
%30 = call i32 @RamAccFixMod(i32 0)
%31 = call i32 @RegWriteA(i32 480, i32 19)
br label %32
32: ; preds = %7, %0
ret void
}

LLVM IR (-O2):
define void @AfSrvOnOffset() {
%1 = alloca i8
%2 = call i32 @RegReadA(i32 480, i8* %1)
%3 = load i8, i8* %1
%4 = and i8 %3, 19
%5 = icmp eq i8 %4, 19
br i1 %5, label %31, label %6
6: ; preds = %0
%7 = call i32 @RegWriteA(i32 480, i32 2)
%8 = call i32 @RamAccFixMod(i32 1)
%9 = call i32 @RamWriteA(i32 5380, i32 0)
%10 = call i32 @RamWriteA(i32 5387, i32 0)
%11 = call i32 @RamWriteA(i32 5388, i32 0)
%12 = call i32 @RamWriteA(i32 5390, i32 0)
%13 = call i32 @RamWriteA(i32 5391, i32 0)
%14 = call i32 @RamWriteA(i32 5393, i32 0)
%15 = call i32 @RamWriteA(i32 5394, i32 0)
%16 = call i32 @RamWriteA(i32 5381, i32 0)
%17 = call i32 @RamWriteA(i32 5382, i32 0)
%18 = call i32 @RamWriteA(i32 5384, i32 0)
%19 = call i32 @RamWriteA(i32 5385, i32 0)
%20 = call i32 @RamWriteA(i32 5398, i32 0)
%21 = call i32 @RamWriteA(i32 5399, i32 0)
%22 = call i32 @RamWriteA(i32 5400, i32 0)
%23 = call i32 @RamWriteA(i32 5401, i32 0)
%24 = call i32 @RamWriteA(i32 5403, i32 0)
%25 = call i32 @RamWriteA(i32 5402, i32 0)
%26 = call i32 @RamWriteA(i32 5404, i32 0)
%27 = call i32 @RamWriteA(i32 5405, i32 0)
%28 = call i32 (...) @AfSrvCurPos()
%29 = call i32 @RamAccFixMod(i32 0)
%30 = call i32 @RegWriteA(i32 480, i32 19)
br label %31
31: ; preds = %6, %0
ret void
}