#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(int, int);
int /*<<< orphan*/ MesFil(int);
int /*<<< orphan*/ RamAccFixMod(int);
int /*<<< orphan*/ RamReadA(int, unsigned short *);
int /*<<< orphan*/ RamWrite32A(int, int);
int /*<<< orphan*/ RegWriteA(int, int);
int /*<<< orphan*/ SetSinWavePara(int, int);
unsigned char TstActMov(unsigned char UcDirSel) {
  unsigned char UcRsltSts;
  unsigned short UsMsppVal;
  MesFil(3);
  if (!UcDirSel) {
    RamWrite32A(0x10D5, 0x3ECCCCCD);
    RamWrite32A(0x11D5, 0x000000);
    SetSinWavePara(0x05, 10);
  } else {
    RamWrite32A(0x10D5, 0x000000);
    RamWrite32A(0x11D5, 0x3ECCCCCD);
    SetSinWavePara(0x05, 11);
  }
  if (!UcDirSel) {
    RegWriteA(0x0194, (unsigned char)0x1433);
    RegWriteA(0x0195, (unsigned char)((0x1433 >> 8) & 0x0001));
  } else {
    RegWriteA(0x0194, (unsigned char)0x14B3);
    RegWriteA(0x0195, (unsigned char)((0x14B3 >> 8) & 0x0001));
  }
  RegWriteA(0x0191, 0x00);
  RegWriteA(0x0193, 0x00);
  RegWriteA(0x0192, 0x02);
  RamWrite32A(0x1230, 0x3F000000);
  RegWriteA(0x0198, 0x00);
  BsyWit(0x0190, 0x02);
  RamAccFixMod(0x01);
  RamReadA(0x1042, &UsMsppVal);
  RamAccFixMod(0x00);
  if (!UcDirSel) {
    SetSinWavePara(0x00, 10);
  } else {
    SetSinWavePara(0x00, 11);
  }
  UcRsltSts = 0x02;
  if (UsMsppVal > 0x0400) {
    if (!UcDirSel) {
      UcRsltSts = 0x06;
    } else {
      UcRsltSts = 0x0A;
    }
  }
  return (UcRsltSts);
}


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

x86 assembly (clang, -O2):
<TstActMov>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %edi,%ebp
mov    $0x3,%edi
call   1040 <MesFil@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   1050 <RamWrite32A@plt>
mov    $0x11d5,%edi
mov    %ebx,%esi
call   1050 <RamWrite32A@plt>
mov    $0x5,%edi
mov    %r14d,%esi
call   1060 <SetSinWavePara@plt>
mov    $0x194,%edi
mov    %ebp,%esi
call   1080 <RegWriteA@plt>
mov    $0x195,%edi
xor    %esi,%esi
call   1080 <RegWriteA@plt>
mov    $0x191,%edi
xor    %esi,%esi
call   1080 <RegWriteA@plt>
mov    $0x193,%edi
xor    %esi,%esi
call   1080 <RegWriteA@plt>
mov    $0x2,%ebx
mov    $0x192,%edi
mov    $0x2,%esi
call   1080 <RegWriteA@plt>
mov    $0x1230,%edi
mov    $0x3f000000,%esi
call   1050 <RamWrite32A@plt>
mov    $0x198,%edi
xor    %esi,%esi
call   1080 <RegWriteA@plt>
mov    $0x190,%edi
mov    $0x2,%esi
call   1090 <BsyWit@plt>
mov    $0x1,%edi
call   1070 <RamAccFixMod@plt>
lea    0x6(%rsp),%rsi
mov    $0x1042,%edi
call   1030 <RamReadA@plt>
xor    %edi,%edi
call   1070 <RamAccFixMod@plt>
shl    $0x2,%r15b
add    $0x6,%r15b
xor    %edi,%edi
mov    %r14d,%esi
call   1060 <SetSinWavePara@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(i8 zeroext %0) {
%2 = alloca i8
%3 = alloca i8
%4 = alloca i16
store i8 %0, i8* %2
%5 = call i32 @MesFil(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(i32 4309, i32 1053609165)
%10 = call i32 @RamWrite32A(i32 4565, i32 0)
%11 = call i32 @SetSinWavePara(i32 5, i32 10)
br label %16
12: ; preds = %1
%13 = call i32 @RamWrite32A(i32 4309, i32 0)
%14 = call i32 @RamWrite32A(i32 4565, i32 1053609165)
%15 = call i32 @SetSinWavePara(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(i32 404, i32 51)
%21 = call i32 @RegWriteA(i32 405, i32 0)
br label %25
22: ; preds = %16
%23 = call i32 @RegWriteA(i32 404, i32 179)
%24 = call i32 @RegWriteA(i32 405, i32 0)
br label %25
25: ; preds = %22, %19
%26 = call i32 @RegWriteA(i32 401, i32 0)
%27 = call i32 @RegWriteA(i32 403, i32 0)
%28 = call i32 @RegWriteA(i32 402, i32 2)
%29 = call i32 @RamWrite32A(i32 4656, i32 1056964608)
%30 = call i32 @RegWriteA(i32 408, i32 0)
%31 = call i32 @BsyWit(i32 400, i32 2)
%32 = call i32 @RamAccFixMod(i32 1)
%33 = call i32 @RamReadA(i32 4162, i16* %4)
%34 = call i32 @RamAccFixMod(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(i32 0, i32 10)
br label %41
39: ; preds = %25
%40 = call i32 @SetSinWavePara(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(i8 zeroext %0) {
%2 = alloca i16
%3 = bitcast i16* %2 to i8*
%4 = tail call i32 @MesFil(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(i32 4309, i32 %6)
%11 = tail call i32 @RamWrite32A(i32 4565, i32 %7)
%12 = tail call i32 @SetSinWavePara(i32 5, i32 %8)
%13 = tail call i32 @RegWriteA(i32 404, i32 %9)
%14 = tail call i32 @RegWriteA(i32 405, i32 0)
%15 = tail call i32 @RegWriteA(i32 401, i32 0)
%16 = tail call i32 @RegWriteA(i32 403, i32 0)
%17 = tail call i32 @RegWriteA(i32 402, i32 2)
%18 = tail call i32 @RamWrite32A(i32 4656, i32 1056964608)
%19 = tail call i32 @RegWriteA(i32 408, i32 0)
%20 = tail call i32 @BsyWit(i32 400, i32 2)
%21 = tail call i32 @RamAccFixMod(i32 1)
%22 = call i32 @RamReadA(i32 4162, i16* %2)
%23 = call i32 @RamAccFixMod(i32 0)
%24 = select i1 %5, i32 10, i32 11
%25 = select i1 %5, i8 6, i8 10
%26 = call i32 @SetSinWavePara(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
}