#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*/ BsyWit_lc898122_sharp(int, int);
int /*<<< orphan*/ RamAccFixMod_lc898122_sharp(int);
int /*<<< orphan*/ RamReadA_lc898122_sharp(int, unsigned short *);
int /*<<< orphan*/ RamWrite32A_lc898122_sharp(int, int);
int /*<<< orphan*/ RegWriteA_lc898122_sharp(int, int);
short GenMes_lc898122_sharp(unsigned short UsRamAdd, unsigned char UcMesMod) {
  short SsMesRlt;
  RegWriteA_lc898122_sharp(0x0194, (unsigned char)UsRamAdd);
  RegWriteA_lc898122_sharp(0x0195, (unsigned char)((UsRamAdd >> 8) & 0x0001));
  RamWrite32A_lc898122_sharp(0x1041, 0x00000000);
  if (!UcMesMod) {
    RegWriteA_lc898122_sharp(0x0193, 0x04);
    RegWriteA_lc898122_sharp(0x0192, 0x00);
    RamWrite32A_lc898122_sharp(0x1230, 0x3A7FFFF7);
  } else {
    RegWriteA_lc898122_sharp(0x0193, 0x01);
    RegWriteA_lc898122_sharp(0x0192, 0x00);
    RamWrite32A_lc898122_sharp(0x1230, 0x3F800000);
  }
  RegWriteA_lc898122_sharp(0x0198, 0x00);
  BsyWit_lc898122_sharp(0x0190, 0x01);
  RamAccFixMod_lc898122_sharp(0x01);
  RamReadA_lc898122_sharp(0x1041, (unsigned short *)&SsMesRlt);
  RamAccFixMod_lc898122_sharp(0x00);
  return (SsMesRlt);
}


x86 assembly (clang, -O0):
<GenMes_lc898122_sharp>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %sil,%al
mov    %di,%cx
mov    %cx,-0x2(%rbp)
mov    %al,-0x3(%rbp)
mov    -0x2(%rbp),%ax
movzbl %al,%esi
mov    $0x194,%edi
call   1030 <RegWriteA_lc898122_sharp@plt>
movzwl -0x2(%rbp),%eax
sar    $0x8,%eax
and    $0x1,%eax
movzbl %al,%esi
mov    $0x195,%edi
call   1030 <RegWriteA_lc898122_sharp@plt>
mov    $0x1041,%edi
xor    %esi,%esi
call   1070 <RamWrite32A_lc898122_sharp@plt>
cmpb   $0x0,-0x3(%rbp)
jne    11d2 <GenMes_lc898122_sharp+0x82>
mov    $0x193,%edi
mov    $0x4,%esi
call   1030 <RegWriteA_lc898122_sharp@plt>
mov    $0x192,%edi
xor    %esi,%esi
call   1030 <RegWriteA_lc898122_sharp@plt>
mov    $0x1230,%edi
mov    $0x3a7ffff7,%esi
call   1070 <RamWrite32A_lc898122_sharp@plt>
jmp    11fc <GenMes_lc898122_sharp+0xac>
mov    $0x193,%edi
mov    $0x1,%esi
call   1030 <RegWriteA_lc898122_sharp@plt>
mov    $0x192,%edi
xor    %esi,%esi
call   1030 <RegWriteA_lc898122_sharp@plt>
mov    $0x1230,%edi
mov    $0x3f800000,%esi
call   1070 <RamWrite32A_lc898122_sharp@plt>
mov    $0x198,%edi
xor    %esi,%esi
call   1030 <RegWriteA_lc898122_sharp@plt>
mov    $0x190,%edi
mov    $0x1,%esi
call   1050 <BsyWit_lc898122_sharp@plt>
mov    $0x1,%edi
call   1060 <RamAccFixMod_lc898122_sharp@plt>
mov    $0x1041,%edi
lea    -0x6(%rbp),%rsi
call   1040 <RamReadA_lc898122_sharp@plt>
xor    %edi,%edi
call   1060 <RamAccFixMod_lc898122_sharp@plt>
movswl -0x6(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<GenMes_lc898122_sharp>:
push   %rbp
push   %rbx
push   %rax
mov    %esi,%ebx
mov    %edi,%ebp
movzbl %bpl,%esi
mov    $0x194,%edi
call   1030 <RegWriteA_lc898122_sharp@plt>
shr    $0x8,%ebp
and    $0x1,%ebp
mov    $0x195,%edi
mov    %ebp,%esi
call   1030 <RegWriteA_lc898122_sharp@plt>
mov    $0x1041,%edi
xor    %esi,%esi
call   1070 <RamWrite32A_lc898122_sharp@plt>
xor    %eax,%eax
test   %ebx,%ebx
sete   %al
lea    0x1(%rax,%rax,2),%esi
mov    $0x3a7ffff7,%eax
mov    $0x3f800000,%ebx
cmove  %eax,%ebx
mov    $0x193,%edi
call   1030 <RegWriteA_lc898122_sharp@plt>
mov    $0x192,%edi
xor    %esi,%esi
call   1030 <RegWriteA_lc898122_sharp@plt>
mov    $0x1230,%edi
mov    %ebx,%esi
call   1070 <RamWrite32A_lc898122_sharp@plt>
mov    $0x198,%edi
xor    %esi,%esi
call   1030 <RegWriteA_lc898122_sharp@plt>
mov    $0x190,%edi
mov    $0x1,%esi
call   1050 <BsyWit_lc898122_sharp@plt>
mov    $0x1,%edi
call   1060 <RamAccFixMod_lc898122_sharp@plt>
lea    0x6(%rsp),%rsi
mov    $0x1041,%edi
call   1040 <RamReadA_lc898122_sharp@plt>
xor    %edi,%edi
call   1060 <RamAccFixMod_lc898122_sharp@plt>
movzwl 0x6(%rsp),%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define signext i16 @GenMes_lc898122_sharp(i16 zeroext %0, i8 zeroext %1) {
%3 = alloca i16
%4 = alloca i8
%5 = alloca i16
store i16 %0, i16* %3
store i8 %1, i8* %4
%6 = load i16, i16* %3
%7 = trunc i16 %6 to i8
%8 = zext i8 %7 to i32
%9 = call i32 @RegWriteA_lc898122_sharp(i32 404, i32 %8)
%10 = load i16, i16* %3
%11 = zext i16 %10 to i32
%12 = ashr i32 %11, 8
%13 = and i32 %12, 1
%14 = trunc i32 %13 to i8
%15 = zext i8 %14 to i32
%16 = call i32 @RegWriteA_lc898122_sharp(i32 405, i32 %15)
%17 = call i32 @RamWrite32A_lc898122_sharp(i32 4161, i32 0)
%18 = load i8, i8* %4
%19 = icmp ne i8 %18, 0
br i1 %19, label %24, label %20
20: ; preds = %2
%21 = call i32 @RegWriteA_lc898122_sharp(i32 403, i32 4)
%22 = call i32 @RegWriteA_lc898122_sharp(i32 402, i32 0)
%23 = call i32 @RamWrite32A_lc898122_sharp(i32 4656, i32 981467127)
br label %28
24: ; preds = %2
%25 = call i32 @RegWriteA_lc898122_sharp(i32 403, i32 1)
%26 = call i32 @RegWriteA_lc898122_sharp(i32 402, i32 0)
%27 = call i32 @RamWrite32A_lc898122_sharp(i32 4656, i32 1065353216)
br label %28
28: ; preds = %24, %20
%29 = call i32 @RegWriteA_lc898122_sharp(i32 408, i32 0)
%30 = call i32 @BsyWit_lc898122_sharp(i32 400, i32 1)
%31 = call i32 @RamAccFixMod_lc898122_sharp(i32 1)
%32 = call i32 @RamReadA_lc898122_sharp(i32 4161, i16* %5)
%33 = call i32 @RamAccFixMod_lc898122_sharp(i32 0)
%34 = load i16, i16* %5
ret i16 %34
}

LLVM IR (-O2):
define signext i16 @GenMes_lc898122_sharp(i16 zeroext %0, i8 zeroext %1) {
%3 = alloca i16
%4 = bitcast i16* %3 to i8*
%5 = and i16 %0, 255
%6 = zext i16 %5 to i32
%7 = tail call i32 @RegWriteA_lc898122_sharp(i32 404, i32 %6)
%8 = lshr i16 %0, 8
%9 = and i16 %8, 1
%10 = zext i16 %9 to i32
%11 = tail call i32 @RegWriteA_lc898122_sharp(i32 405, i32 %10)
%12 = tail call i32 @RamWrite32A_lc898122_sharp(i32 4161, i32 0)
%13 = icmp eq i8 %1, 0
%14 = select i1 %13, i32 4, i32 1
%15 = select i1 %13, i32 981467127, i32 1065353216
%16 = tail call i32 @RegWriteA_lc898122_sharp(i32 403, i32 %14)
%17 = tail call i32 @RegWriteA_lc898122_sharp(i32 402, i32 0)
%18 = tail call i32 @RamWrite32A_lc898122_sharp(i32 4656, i32 %15)
%19 = tail call i32 @RegWriteA_lc898122_sharp(i32 408, i32 0)
%20 = tail call i32 @BsyWit_lc898122_sharp(i32 400, i32 1)
%21 = tail call i32 @RamAccFixMod_lc898122_sharp(i32 1)
%22 = call i32 @RamReadA_lc898122_sharp(i32 4161, i16* %3)
%23 = call i32 @RamAccFixMod_lc898122_sharp(i32 0)
%24 = load i16, i16* %3
ret i16 %24
}