#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_OFILM(int, int);
int /*<<< orphan*/ RamAccFixMod_OFILM(int);
int /*<<< orphan*/ RamReadA_Ofilm(int, unsigned short *);
int /*<<< orphan*/ RamWrite32A_Ofilm(int, int);
int /*<<< orphan*/ RegWriteA_Ofilm(int, int);
short GenMes_OFILM(unsigned short UsRamAdd_OFILM,
                   unsigned char UcMesMod_OFILM) {
  short SsMesRlt_OFILM;
  RegWriteA_Ofilm(0x0194, (unsigned char)UsRamAdd_OFILM);
  RegWriteA_Ofilm(0x0195, (unsigned char)((UsRamAdd_OFILM >> 8) & 0x0001));
  RamWrite32A_Ofilm(0x1041, 0x00000000);
  if (!UcMesMod_OFILM) {
    RegWriteA_Ofilm(0x0193, 0x04);
    RegWriteA_Ofilm(0x0192, 0x00);
    RamWrite32A_Ofilm(0x1230, 0x3A7FFFF7);
  } else {
    RegWriteA_Ofilm(0x0193, 0x00);
    RegWriteA_Ofilm(0x0192, 0x01);
    RamWrite32A_Ofilm(0x1230, 0x3F800000);
  }
  RegWriteA_Ofilm(0x0198, 0x00);
  BsyWit_OFILM(0x0190, 0x01);
  RamAccFixMod_OFILM(0x01);
  RamReadA_Ofilm(0x1041, (unsigned short *)&SsMesRlt_OFILM);
  RamAccFixMod_OFILM(0x00);
  return (SsMesRlt_OFILM);
}


x86 assembly (clang, -O0):
<GenMes_OFILM>:
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   1060 <RegWriteA_Ofilm@plt>
movzwl -0x2(%rbp),%eax
sar    $0x8,%eax
and    $0x1,%eax
movzbl %al,%esi
mov    $0x195,%edi
call   1060 <RegWriteA_Ofilm@plt>
mov    $0x1041,%edi
xor    %esi,%esi
call   1070 <RamWrite32A_Ofilm@plt>
cmpb   $0x0,-0x3(%rbp)
jne    11d2 <GenMes_OFILM+0x82>
mov    $0x193,%edi
mov    $0x4,%esi
call   1060 <RegWriteA_Ofilm@plt>
mov    $0x192,%edi
xor    %esi,%esi
call   1060 <RegWriteA_Ofilm@plt>
mov    $0x1230,%edi
mov    $0x3a7ffff7,%esi
call   1070 <RamWrite32A_Ofilm@plt>
jmp    11fc <GenMes_OFILM+0xac>
mov    $0x193,%edi
xor    %esi,%esi
call   1060 <RegWriteA_Ofilm@plt>
mov    $0x192,%edi
mov    $0x1,%esi
call   1060 <RegWriteA_Ofilm@plt>
mov    $0x1230,%edi
mov    $0x3f800000,%esi
call   1070 <RamWrite32A_Ofilm@plt>
mov    $0x198,%edi
xor    %esi,%esi
call   1060 <RegWriteA_Ofilm@plt>
mov    $0x190,%edi
mov    $0x1,%esi
call   1040 <BsyWit_OFILM@plt>
mov    $0x1,%edi
call   1030 <RamAccFixMod_OFILM@plt>
mov    $0x1041,%edi
lea    -0x6(%rbp),%rsi
call   1050 <RamReadA_Ofilm@plt>
xor    %edi,%edi
call   1030 <RamAccFixMod_OFILM@plt>
movswl -0x6(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<GenMes_OFILM>:
push   %rbp
push   %rbx
push   %rax
mov    %esi,%ebx
mov    %edi,%ebp
movzbl %bpl,%esi
mov    $0x194,%edi
call   1060 <RegWriteA_Ofilm@plt>
shr    $0x8,%ebp
and    $0x1,%ebp
mov    $0x195,%edi
mov    %ebp,%esi
call   1060 <RegWriteA_Ofilm@plt>
mov    $0x1041,%edi
xor    %esi,%esi
call   1070 <RamWrite32A_Ofilm@plt>
xor    %ebp,%ebp
xor    %esi,%esi
test   %ebx,%ebx
setne  %bpl
sete   %sil
mov    $0x3a7ffff7,%eax
mov    $0x3f800000,%ebx
cmove  %eax,%ebx
shl    $0x2,%esi
mov    $0x193,%edi
call   1060 <RegWriteA_Ofilm@plt>
mov    $0x192,%edi
mov    %ebp,%esi
call   1060 <RegWriteA_Ofilm@plt>
mov    $0x1230,%edi
mov    %ebx,%esi
call   1070 <RamWrite32A_Ofilm@plt>
mov    $0x198,%edi
xor    %esi,%esi
call   1060 <RegWriteA_Ofilm@plt>
mov    $0x190,%edi
mov    $0x1,%esi
call   1040 <BsyWit_OFILM@plt>
mov    $0x1,%edi
call   1030 <RamAccFixMod_OFILM@plt>
lea    0x6(%rsp),%rsi
mov    $0x1041,%edi
call   1050 <RamReadA_Ofilm@plt>
xor    %edi,%edi
call   1030 <RamAccFixMod_OFILM@plt>
movzwl 0x6(%rsp),%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define signext i16 @GenMes_OFILM(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_Ofilm(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_Ofilm(i32 405, i32 %15)
%17 = call i32 @RamWrite32A_Ofilm(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_Ofilm(i32 403, i32 4)
%22 = call i32 @RegWriteA_Ofilm(i32 402, i32 0)
%23 = call i32 @RamWrite32A_Ofilm(i32 4656, i32 981467127)
br label %28
24: ; preds = %2
%25 = call i32 @RegWriteA_Ofilm(i32 403, i32 0)
%26 = call i32 @RegWriteA_Ofilm(i32 402, i32 1)
%27 = call i32 @RamWrite32A_Ofilm(i32 4656, i32 1065353216)
br label %28
28: ; preds = %24, %20
%29 = call i32 @RegWriteA_Ofilm(i32 408, i32 0)
%30 = call i32 @BsyWit_OFILM(i32 400, i32 1)
%31 = call i32 @RamAccFixMod_OFILM(i32 1)
%32 = call i32 @RamReadA_Ofilm(i32 4161, i16* %5)
%33 = call i32 @RamAccFixMod_OFILM(i32 0)
%34 = load i16, i16* %5
ret i16 %34
}

LLVM IR (-O2):
define signext i16 @GenMes_OFILM(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_Ofilm(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_Ofilm(i32 405, i32 %10)
%12 = tail call i32 @RamWrite32A_Ofilm(i32 4161, i32 0)
%13 = icmp eq i8 %1, 0
%14 = select i1 %13, i32 4, i32 0
%15 = xor i1 %13, true
%16 = zext i1 %15 to i32
%17 = select i1 %13, i32 981467127, i32 1065353216
%18 = tail call i32 @RegWriteA_Ofilm(i32 403, i32 %14)
%19 = tail call i32 @RegWriteA_Ofilm(i32 402, i32 %16)
%20 = tail call i32 @RamWrite32A_Ofilm(i32 4656, i32 %17)
%21 = tail call i32 @RegWriteA_Ofilm(i32 408, i32 0)
%22 = tail call i32 @BsyWit_OFILM(i32 400, i32 1)
%23 = tail call i32 @RamAccFixMod_OFILM(i32 1)
%24 = call i32 @RamReadA_Ofilm(i32 4161, i16* %3)
%25 = call i32 @RamAccFixMod_OFILM(i32 0)
%26 = load i16, i16* %3
ret i16 %26
}