#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*/ MesFil_OFILM(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);
int /*<<< orphan*/ SetSinWavePara_OFILM(int, int);
unsigned char TstActMov_OFILM(unsigned char UcDirSel_OFILM) {
  unsigned char UcRsltSts_OFILM;
  unsigned short UsMsppVal_OFILM;
  MesFil_OFILM(3);
  if (!UcDirSel_OFILM) {
    RamWrite32A_Ofilm(0x10D5, 0x3ECCCCCD);
    RamWrite32A_Ofilm(0x11D5, 0x000000);
    SetSinWavePara_OFILM(0x05, 10);
  } else {
    RamWrite32A_Ofilm(0x10D5, 0x000000);
    RamWrite32A_Ofilm(0x11D5, 0x3ECCCCCD);
    SetSinWavePara_OFILM(0x05, 11);
  }
  if (!UcDirSel_OFILM) {
    RegWriteA_Ofilm(0x0194, (unsigned char)0x1433);
    RegWriteA_Ofilm(0x0195, (unsigned char)((0x1433 >> 8) & 0x0001));
  } else {
    RegWriteA_Ofilm(0x0194, (unsigned char)0x14B3);
    RegWriteA_Ofilm(0x0195, (unsigned char)((0x14B3 >> 8) & 0x0001));
  }
  RegWriteA_Ofilm(0x0191, 0x00);
  RegWriteA_Ofilm(0x0193, 0x00);
  RegWriteA_Ofilm(0x0192, 0x02);
  RamWrite32A_Ofilm(0x1230, 0x3F000000);
  RegWriteA_Ofilm(0x0198, 0x00);
  BsyWit_OFILM(0x0190, 0x02);
  RamAccFixMod_OFILM(0x01);
  RamReadA_Ofilm(0x1042, &UsMsppVal_OFILM);
  RamAccFixMod_OFILM(0x00);
  if (!UcDirSel_OFILM) {
    SetSinWavePara_OFILM(0x00, 10);
  } else {
    SetSinWavePara_OFILM(0x00, 11);
  };
  UcRsltSts_OFILM = 0x02;
  if (UsMsppVal_OFILM > 0x0400) {
    if (!UcDirSel_OFILM) {
      UcRsltSts_OFILM = 0x06;
    } else {
      UcRsltSts_OFILM = 0x0A;
    }
  }
  return (UcRsltSts_OFILM);
}


x86 assembly (clang, -O0):
<TstActMov_OFILM>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %dil,%al
mov    %al,-0x1(%rbp)
mov    $0x3,%edi
call   1090 <MesFil_OFILM@plt>
cmpb   $0x0,-0x1(%rbp)
jne    11c1 <TstActMov_OFILM+0x51>
mov    $0x10d5,%edi
mov    $0x3ecccccd,%esi
call   1080 <RamWrite32A_Ofilm@plt>
mov    $0x11d5,%edi
xor    %esi,%esi
call   1080 <RamWrite32A_Ofilm@plt>
mov    $0x5,%edi
mov    $0xa,%esi
call   1030 <SetSinWavePara_OFILM@plt>
jmp    11eb <TstActMov_OFILM+0x7b>
mov    $0x10d5,%edi
xor    %esi,%esi
call   1080 <RamWrite32A_Ofilm@plt>
mov    $0x11d5,%edi
mov    $0x3ecccccd,%esi
call   1080 <RamWrite32A_Ofilm@plt>
mov    $0x5,%edi
mov    $0xb,%esi
call   1030 <SetSinWavePara_OFILM@plt>
cmpb   $0x0,-0x1(%rbp)
jne    1215 <TstActMov_OFILM+0xa5>
mov    $0x194,%edi
mov    $0x33,%esi
call   1070 <RegWriteA_Ofilm@plt>
mov    $0x195,%edi
xor    %esi,%esi
call   1070 <RegWriteA_Ofilm@plt>
jmp    1230 <TstActMov_OFILM+0xc0>
mov    $0x194,%edi
mov    $0xb3,%esi
call   1070 <RegWriteA_Ofilm@plt>
mov    $0x195,%edi
xor    %esi,%esi
call   1070 <RegWriteA_Ofilm@plt>
mov    $0x191,%edi
xor    %esi,%esi
call   1070 <RegWriteA_Ofilm@plt>
mov    $0x193,%edi
xor    %esi,%esi
call   1070 <RegWriteA_Ofilm@plt>
mov    $0x192,%edi
mov    $0x2,%esi
call   1070 <RegWriteA_Ofilm@plt>
mov    $0x1230,%edi
mov    $0x3f000000,%esi
call   1080 <RamWrite32A_Ofilm@plt>
mov    $0x198,%edi
xor    %esi,%esi
call   1070 <RegWriteA_Ofilm@plt>
mov    $0x190,%edi
mov    $0x2,%esi
call   1050 <BsyWit_OFILM@plt>
mov    $0x1,%edi
call   1040 <RamAccFixMod_OFILM@plt>
mov    $0x1042,%edi
lea    -0x4(%rbp),%rsi
call   1060 <RamReadA_Ofilm@plt>
xor    %edi,%edi
call   1040 <RamAccFixMod_OFILM@plt>
cmpb   $0x0,-0x1(%rbp)
jne    12bb <TstActMov_OFILM+0x14b>
xor    %edi,%edi
mov    $0xa,%esi
call   1030 <SetSinWavePara_OFILM@plt>
jmp    12c7 <TstActMov_OFILM+0x157>
xor    %edi,%edi
mov    $0xb,%esi
call   1030 <SetSinWavePara_OFILM@plt>
movb   $0x2,-0x2(%rbp)
movzwl -0x4(%rbp),%eax
cmp    $0x400,%eax
jle    12f6 <TstActMov_OFILM+0x186>
cmpb   $0x0,-0x1(%rbp)
jne    12ed <TstActMov_OFILM+0x17d>
movb   $0x6,-0x2(%rbp)
jmp    12f1 <TstActMov_OFILM+0x181>
movb   $0xa,-0x2(%rbp)
jmp    12f6 <TstActMov_OFILM+0x186>
movzbl -0x2(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<TstActMov_OFILM>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %edi,%ebp
mov    $0x3,%edi
call   1090 <MesFil_OFILM@plt>
xor    %esi,%esi
xor    %r15d,%r15d
xor    %r14d,%r14d
test   %ebp,%ebp
setne  %r15b
mov    $0x3ecccccd,%ebx
cmove  %ebx,%esi
cmove  %ebp,%ebx
sete   %r14b
xor    $0xb,%r14d
mov    %r15d,%ebp
shl    $0x7,%ebp
or     $0x33,%ebp
mov    $0x10d5,%edi
call   1080 <RamWrite32A_Ofilm@plt>
mov    $0x11d5,%edi
mov    %ebx,%esi
call   1080 <RamWrite32A_Ofilm@plt>
mov    $0x5,%edi
mov    %r14d,%esi
call   1030 <SetSinWavePara_OFILM@plt>
mov    $0x194,%edi
mov    %ebp,%esi
call   1070 <RegWriteA_Ofilm@plt>
mov    $0x195,%edi
xor    %esi,%esi
call   1070 <RegWriteA_Ofilm@plt>
mov    $0x191,%edi
xor    %esi,%esi
call   1070 <RegWriteA_Ofilm@plt>
mov    $0x193,%edi
xor    %esi,%esi
call   1070 <RegWriteA_Ofilm@plt>
mov    $0x2,%ebx
mov    $0x192,%edi
mov    $0x2,%esi
call   1070 <RegWriteA_Ofilm@plt>
mov    $0x1230,%edi
mov    $0x3f000000,%esi
call   1080 <RamWrite32A_Ofilm@plt>
mov    $0x198,%edi
xor    %esi,%esi
call   1070 <RegWriteA_Ofilm@plt>
mov    $0x190,%edi
mov    $0x2,%esi
call   1050 <BsyWit_OFILM@plt>
mov    $0x1,%edi
call   1040 <RamAccFixMod_OFILM@plt>
lea    0x6(%rsp),%rsi
mov    $0x1042,%edi
call   1060 <RamReadA_Ofilm@plt>
xor    %edi,%edi
call   1040 <RamAccFixMod_OFILM@plt>
shl    $0x2,%r15b
add    $0x6,%r15b
xor    %edi,%edi
mov    %r14d,%esi
call   1030 <SetSinWavePara_OFILM@plt>
movzwl 0x6(%rsp),%eax
cmp    $0x401,%eax
movzbl %r15b,%eax
cmovb  %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define zeroext i8 @TstActMov_OFILM(i8 zeroext %0) {
%2 = alloca i8
%3 = alloca i8
%4 = alloca i16
store i8 %0, i8* %2
%5 = call i32 @MesFil_OFILM(i32 3)
%6 = load i8, i8* %2
%7 = icmp ne i8 %6, 0
br i1 %7, label %12, label %8
8: ; preds = %1
%9 = call i32 @RamWrite32A_Ofilm(i32 4309, i32 1053609165)
%10 = call i32 @RamWrite32A_Ofilm(i32 4565, i32 0)
%11 = call i32 @SetSinWavePara_OFILM(i32 5, i32 10)
br label %16
12: ; preds = %1
%13 = call i32 @RamWrite32A_Ofilm(i32 4309, i32 0)
%14 = call i32 @RamWrite32A_Ofilm(i32 4565, i32 1053609165)
%15 = call i32 @SetSinWavePara_OFILM(i32 5, i32 11)
br label %16
16: ; preds = %12, %8
%17 = load i8, i8* %2
%18 = icmp ne i8 %17, 0
br i1 %18, label %22, label %19
19: ; preds = %16
%20 = call i32 @RegWriteA_Ofilm(i32 404, i32 51)
%21 = call i32 @RegWriteA_Ofilm(i32 405, i32 0)
br label %25
22: ; preds = %16
%23 = call i32 @RegWriteA_Ofilm(i32 404, i32 179)
%24 = call i32 @RegWriteA_Ofilm(i32 405, i32 0)
br label %25
25: ; preds = %22, %19
%26 = call i32 @RegWriteA_Ofilm(i32 401, i32 0)
%27 = call i32 @RegWriteA_Ofilm(i32 403, i32 0)
%28 = call i32 @RegWriteA_Ofilm(i32 402, i32 2)
%29 = call i32 @RamWrite32A_Ofilm(i32 4656, i32 1056964608)
%30 = call i32 @RegWriteA_Ofilm(i32 408, i32 0)
%31 = call i32 @BsyWit_OFILM(i32 400, i32 2)
%32 = call i32 @RamAccFixMod_OFILM(i32 1)
%33 = call i32 @RamReadA_Ofilm(i32 4162, i16* %4)
%34 = call i32 @RamAccFixMod_OFILM(i32 0)
%35 = load i8, i8* %2
%36 = icmp ne i8 %35, 0
br i1 %36, label %39, label %37
37: ; preds = %25
%38 = call i32 @SetSinWavePara_OFILM(i32 0, i32 10)
br label %41
39: ; preds = %25
%40 = call i32 @SetSinWavePara_OFILM(i32 0, i32 11)
br label %41
41: ; preds = %39, %37
store i8 2, i8* %3
%42 = load i16, i16* %4
%43 = zext i16 %42 to i32
%44 = icmp sgt i32 %43, 1024
br i1 %44, label %45, label %51
45: ; preds = %41
%46 = load i8, i8* %2
%47 = icmp ne i8 %46, 0
br i1 %47, label %49, label %48
48: ; preds = %45
store i8 6, i8* %3
br label %50
49: ; preds = %45
store i8 10, i8* %3
br label %50
50: ; preds = %49, %48
br label %51
51: ; preds = %50, %41
%52 = load i8, i8* %3
ret i8 %52
}

LLVM IR (-O2):
define zeroext i8 @TstActMov_OFILM(i8 zeroext %0) {
%2 = alloca i16
%3 = bitcast i16* %2 to i8*
%4 = tail call i32 @MesFil_OFILM(i32 3)
%5 = icmp eq i8 %0, 0
%6 = select i1 %5, i32 1053609165, i32 0
%7 = select i1 %5, i32 0, i32 1053609165
%8 = select i1 %5, i32 10, i32 11
%9 = select i1 %5, i32 51, i32 179
%10 = tail call i32 @RamWrite32A_Ofilm(i32 4309, i32 %6)
%11 = tail call i32 @RamWrite32A_Ofilm(i32 4565, i32 %7)
%12 = tail call i32 @SetSinWavePara_OFILM(i32 5, i32 %8)
%13 = tail call i32 @RegWriteA_Ofilm(i32 404, i32 %9)
%14 = tail call i32 @RegWriteA_Ofilm(i32 405, i32 0)
%15 = tail call i32 @RegWriteA_Ofilm(i32 401, i32 0)
%16 = tail call i32 @RegWriteA_Ofilm(i32 403, i32 0)
%17 = tail call i32 @RegWriteA_Ofilm(i32 402, i32 2)
%18 = tail call i32 @RamWrite32A_Ofilm(i32 4656, i32 1056964608)
%19 = tail call i32 @RegWriteA_Ofilm(i32 408, i32 0)
%20 = tail call i32 @BsyWit_OFILM(i32 400, i32 2)
%21 = tail call i32 @RamAccFixMod_OFILM(i32 1)
%22 = call i32 @RamReadA_Ofilm(i32 4162, i16* %2)
%23 = call i32 @RamAccFixMod_OFILM(i32 0)
%24 = select i1 %5, i32 10, i32 11
%25 = select i1 %5, i8 6, i8 10
%26 = call i32 @SetSinWavePara_OFILM(i32 0, i32 %24)
%27 = load i16, i16* %2
%28 = icmp ugt i16 %27, 1024
%29 = select i1 %28, i8 %25, i8 2
ret i8 %29
}