#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*/ RamAccFixMod(int);
int /*<<< orphan*/ RamReadA(int, unsigned short *);
int /*<<< orphan*/ RamWrite32A(int, int);
int /*<<< orphan*/ RegReadA(int, unsigned char *);
int /*<<< orphan*/ RegWriteA(int, int);
int /*<<< orphan*/ WitTim(int);
short GenMesMobile(unsigned short UsRamAdd, unsigned char UcMesMod) {
  short SsMesRlt;
  unsigned char UcMesFin;
  RegWriteA(0x0194, (unsigned char)UsRamAdd);
  RegWriteA(0x0195, (unsigned char)((UsRamAdd >> 8) & 0x0001));
  RamWrite32A(0x1041, 0x00000000);
  if (!UcMesMod) {
    RegWriteA(0x0193, 0x04);
    RegWriteA(0x0192, 0x00);
    RamWrite32A(0x1230, 0x3A7FFFF7);
  } else {
    RegWriteA(0x0193, 0x01);
    RegWriteA(0x0192, 0x00);
    RamWrite32A(0x1230, 0x3F800000);
  }
  RegWriteA(0x0198, 0x00);
  RegWriteA(0x0190, 0x01);
  WitTim(100);
  RegReadA(0x0190, &UcMesFin);
  if (0x00 == UcMesFin) {
    WitTim(100);
  }
  RamAccFixMod(0x01);
  RamReadA(0x1041, (unsigned short *)&SsMesRlt);
  RamAccFixMod(0x00);
  return (SsMesRlt);
}


x86 assembly (clang, -O0):
<GenMesMobile>:
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   1080 <RegWriteA@plt>
movzwl -0x2(%rbp),%eax
sar    $0x8,%eax
and    $0x1,%eax
movzbl %al,%esi
mov    $0x195,%edi
call   1080 <RegWriteA@plt>
mov    $0x1041,%edi
xor    %esi,%esi
call   1040 <RamWrite32A@plt>
cmpb   $0x0,-0x3(%rbp)
jne    11e2 <GenMesMobile+0x82>
mov    $0x193,%edi
mov    $0x4,%esi
call   1080 <RegWriteA@plt>
mov    $0x192,%edi
xor    %esi,%esi
call   1080 <RegWriteA@plt>
mov    $0x1230,%edi
mov    $0x3a7ffff7,%esi
call   1040 <RamWrite32A@plt>
jmp    120c <GenMesMobile+0xac>
mov    $0x193,%edi
mov    $0x1,%esi
call   1080 <RegWriteA@plt>
mov    $0x192,%edi
xor    %esi,%esi
call   1080 <RegWriteA@plt>
mov    $0x1230,%edi
mov    $0x3f800000,%esi
call   1040 <RamWrite32A@plt>
mov    $0x198,%edi
xor    %esi,%esi
call   1080 <RegWriteA@plt>
mov    $0x190,%edi
mov    $0x1,%esi
call   1080 <RegWriteA@plt>
mov    $0x64,%edi
call   1050 <WitTim@plt>
mov    $0x190,%edi
lea    -0x7(%rbp),%rsi
call   1070 <RegReadA@plt>
movzbl -0x7(%rbp),%ecx
xor    %eax,%eax
cmp    %ecx,%eax
jne    1257 <GenMesMobile+0xf7>
mov    $0x64,%edi
call   1050 <WitTim@plt>
mov    $0x1,%edi
call   1060 <RamAccFixMod@plt>
mov    $0x1041,%edi
lea    -0x6(%rbp),%rsi
call   1030 <RamReadA@plt>
xor    %edi,%edi
call   1060 <RamAccFixMod@plt>
movswl -0x6(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<GenMesMobile>:
push   %rbp
push   %rbx
push   %rax
mov    %esi,%ebx
mov    %edi,%ebp
movzbl %bpl,%esi
mov    $0x194,%edi
call   1080 <RegWriteA@plt>
shr    $0x8,%ebp
and    $0x1,%ebp
mov    $0x195,%edi
mov    %ebp,%esi
call   1080 <RegWriteA@plt>
mov    $0x1041,%edi
xor    %esi,%esi
call   1040 <RamWrite32A@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   1080 <RegWriteA@plt>
mov    $0x192,%edi
xor    %esi,%esi
call   1080 <RegWriteA@plt>
mov    $0x1230,%edi
mov    %ebx,%esi
call   1040 <RamWrite32A@plt>
mov    $0x198,%edi
xor    %esi,%esi
call   1080 <RegWriteA@plt>
mov    $0x190,%edi
mov    $0x1,%esi
call   1080 <RegWriteA@plt>
mov    $0x64,%edi
call   1050 <WitTim@plt>
lea    0x5(%rsp),%rsi
mov    $0x190,%edi
call   1070 <RegReadA@plt>
cmpb   $0x0,0x5(%rsp)
jne    1212 <GenMesMobile+0xb2>
mov    $0x64,%edi
call   1050 <WitTim@plt>
mov    $0x1,%edi
call   1060 <RamAccFixMod@plt>
lea    0x6(%rsp),%rsi
mov    $0x1041,%edi
call   1030 <RamReadA@plt>
xor    %edi,%edi
call   1060 <RamAccFixMod@plt>
movzwl 0x6(%rsp),%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define signext i16 @GenMesMobile(i16 zeroext %0, i8 zeroext %1) {
%3 = alloca i16
%4 = alloca i8
%5 = alloca i16
%6 = alloca i8
store i16 %0, i16* %3
store i8 %1, i8* %4
%7 = load i16, i16* %3
%8 = trunc i16 %7 to i8
%9 = zext i8 %8 to i32
%10 = call i32 @RegWriteA(i32 404, i32 %9)
%11 = load i16, i16* %3
%12 = zext i16 %11 to i32
%13 = ashr i32 %12, 8
%14 = and i32 %13, 1
%15 = trunc i32 %14 to i8
%16 = zext i8 %15 to i32
%17 = call i32 @RegWriteA(i32 405, i32 %16)
%18 = call i32 @RamWrite32A(i32 4161, i32 0)
%19 = load i8, i8* %4
%20 = icmp ne i8 %19, 0
br i1 %20, label %25, label %21
21: ; preds = %2
%22 = call i32 @RegWriteA(i32 403, i32 4)
%23 = call i32 @RegWriteA(i32 402, i32 0)
%24 = call i32 @RamWrite32A(i32 4656, i32 981467127)
br label %29
25: ; preds = %2
%26 = call i32 @RegWriteA(i32 403, i32 1)
%27 = call i32 @RegWriteA(i32 402, i32 0)
%28 = call i32 @RamWrite32A(i32 4656, i32 1065353216)
br label %29
29: ; preds = %25, %21
%30 = call i32 @RegWriteA(i32 408, i32 0)
%31 = call i32 @RegWriteA(i32 400, i32 1)
%32 = call i32 @WitTim(i32 100)
%33 = call i32 @RegReadA(i32 400, i8* %6)
%34 = load i8, i8* %6
%35 = zext i8 %34 to i32
%36 = icmp eq i32 0, %35
br i1 %36, label %37, label %39
37: ; preds = %29
%38 = call i32 @WitTim(i32 100)
br label %39
39: ; preds = %37, %29
%40 = call i32 @RamAccFixMod(i32 1)
%41 = call i32 @RamReadA(i32 4161, i16* %5)
%42 = call i32 @RamAccFixMod(i32 0)
%43 = load i16, i16* %5
ret i16 %43
}

LLVM IR (-O2):
define signext i16 @GenMesMobile(i16 zeroext %0, i8 zeroext %1) {
%3 = alloca i16
%4 = alloca i8
%5 = bitcast i16* %3 to i8*
%6 = and i16 %0, 255
%7 = zext i16 %6 to i32
%8 = tail call i32 @RegWriteA(i32 404, i32 %7)
%9 = lshr i16 %0, 8
%10 = and i16 %9, 1
%11 = zext i16 %10 to i32
%12 = tail call i32 @RegWriteA(i32 405, i32 %11)
%13 = tail call i32 @RamWrite32A(i32 4161, i32 0)
%14 = icmp eq i8 %1, 0
%15 = select i1 %14, i32 4, i32 1
%16 = select i1 %14, i32 981467127, i32 1065353216
%17 = tail call i32 @RegWriteA(i32 403, i32 %15)
%18 = tail call i32 @RegWriteA(i32 402, i32 0)
%19 = tail call i32 @RamWrite32A(i32 4656, i32 %16)
%20 = tail call i32 @RegWriteA(i32 408, i32 0)
%21 = tail call i32 @RegWriteA(i32 400, i32 1)
%22 = tail call i32 @WitTim(i32 100)
%23 = call i32 @RegReadA(i32 400, i8* %4)
%24 = load i8, i8* %4
%25 = icmp eq i8 %24, 0
br i1 %25, label %26, label %28
26: ; preds = %2
%27 = call i32 @WitTim(i32 100)
br label %28
28: ; preds = %26, %2
%29 = call i32 @RamAccFixMod(i32 1)
%30 = call i32 @RamReadA(i32 4161, i16* %3)
%31 = call i32 @RamAccFixMod(i32 0)
%32 = load i16, i16* %3
ret i16 %32
}