#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*/ MeasureStart(long, long, long);
int /*<<< orphan*/ MeasureWait();
int /*<<< orphan*/ MesFil(int);
int /*<<< orphan*/ RamRead32A(int, unsigned long *);
int /*<<< orphan*/ RamWrite32A(int, int);
int /*<<< orphan*/ SetSinWavGenInt();
int /*<<< orphan*/ SetTransDataAdr(int, unsigned long);
unsigned char TstActMov(unsigned char UcDirSel) {
  unsigned char UcRsltSts = 0;
  long SlMeasureParameterNum;
  long SlMeasureParameterA, SlMeasureParameterB;
  unsigned long UlMsppVal;
  SlMeasureParameterNum = 5005;
  if (UcDirSel == 0x00) {
    SlMeasureParameterA = 0x0010 + 0x01d0;
    SlMeasureParameterB = 0x0010 + 0x0220;
  } else if (UcDirSel == 0x01) {
    SlMeasureParameterA = 0x0010 + 0x0220;
    SlMeasureParameterB = 0x0010 + 0x01d0;
  }
  SetSinWavGenInt();
  RamWrite32A(0x0000 + 0x00c4, 0x00068C16);
  RamWrite32A(0x0004 + 0x0004 + 0x0000 + 0x00c4, 0x33320000);
  RamWrite32A(0x0004 + 0x0000 + 0x00b8, 0x00000001);
  if (UcDirSel == 0x00) {
    SetTransDataAdr(0x0004 + 0x0004 + 0x0004 + 0x0004 + 0x0000 + 0x00c4,
                    (unsigned long)0x0004 + 0x0000 + 0x0270);
  } else if (UcDirSel == 0x01) {
    SetTransDataAdr(0x0004 + 0x0004 + 0x0004 + 0x0004 + 0x0000 + 0x00c4,
                    (unsigned long)0x0004 + 0x0000 + 0x02c0);
  }
  MesFil(3);
  MeasureStart(SlMeasureParameterNum, SlMeasureParameterA, SlMeasureParameterB);
  MeasureWait();
  RamWrite32A(0x0004 + 0x0000 + 0x00b8, 0x00000000);
  if (UcDirSel == 0x00) {
    SetTransDataAdr(0x0004 + 0x0004 + 0x0004 + 0x0004 + 0x0000 + 0x00c4,
                    (unsigned long)0x00000000);
    RamWrite32A(0x0004 + 0x0000 + 0x0270, 0x00000000);
  } else if (UcDirSel == 0x01) {
    SetTransDataAdr(0x0004 + 0x0004 + 0x0004 + 0x0004 + 0x0000 + 0x00c4,
                    (unsigned long)0x00000000);
    RamWrite32A(0x0004 + 0x0000 + 0x02c0, 0x00000000);
  }
  RamRead32A(0x0004 + 0x0004 + 0x0000 + 0x0480, (unsigned long *)&UlMsppVal);
  UcRsltSts = 0x00000002L;
  if (UlMsppVal > 0x0A3D0000) {
    if (!UcDirSel) {
      UcRsltSts = 0x06;
    } else {
      UcRsltSts = 0x0A;
    }
  }
  return (UcRsltSts);
}


x86 assembly (clang, -O0):
<TstActMov>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %dil,%al
mov    %al,-0x1(%rbp)
movb   $0x0,-0x2(%rbp)
movq   $0x138d,-0x10(%rbp)
movzbl -0x1(%rbp),%eax
cmp    $0x0,%eax
jne    11ac <TstActMov+0x3c>
movq   $0x1e0,-0x18(%rbp)
movq   $0x230,-0x20(%rbp)
jmp    11ce <TstActMov+0x5e>
movzbl -0x1(%rbp),%eax
cmp    $0x1,%eax
jne    11c9 <TstActMov+0x59>
movq   $0x230,-0x18(%rbp)
movq   $0x1e0,-0x20(%rbp)
jmp    11ce <TstActMov+0x5e>
mov    $0x0,%al
call   1090 <SetSinWavGenInt@plt>
mov    $0xc4,%edi
mov    $0x68c16,%esi
call   1060 <RamWrite32A@plt>
mov    $0xcc,%edi
mov    $0x33320000,%esi
call   1060 <RamWrite32A@plt>
mov    $0xbc,%edi
mov    $0x1,%esi
call   1060 <RamWrite32A@plt>
movzbl -0x1(%rbp),%eax
cmp    $0x0,%eax
jne    1223 <TstActMov+0xb3>
mov    $0xd4,%edi
mov    $0x274,%esi
call   1030 <SetTransDataAdr@plt>
jmp    1244 <TstActMov+0xd4>
movzbl -0x1(%rbp),%eax
cmp    $0x1,%eax
jne    123f <TstActMov+0xcf>
mov    $0xd4,%edi
mov    $0x2c4,%esi
call   1030 <SetTransDataAdr@plt>
jmp    1244 <TstActMov+0xd4>
mov    $0x3,%edi
call   1040 <MesFil@plt>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
call   1070 <MeasureStart@plt>
mov    $0x0,%al
call   1080 <MeasureWait@plt>
mov    $0xbc,%edi
xor    %esi,%esi
call   1060 <RamWrite32A@plt>
movzbl -0x1(%rbp),%eax
cmp    $0x0,%eax
jne    129e <TstActMov+0x12e>
mov    $0xd4,%edi
xor    %eax,%eax
mov    %eax,%esi
call   1030 <SetTransDataAdr@plt>
mov    $0x274,%edi
xor    %esi,%esi
call   1060 <RamWrite32A@plt>
jmp    12ca <TstActMov+0x15a>
movzbl -0x1(%rbp),%eax
cmp    $0x1,%eax
jne    12c5 <TstActMov+0x155>
mov    $0xd4,%edi
xor    %eax,%eax
mov    %eax,%esi
call   1030 <SetTransDataAdr@plt>
mov    $0x2c4,%edi
xor    %esi,%esi
call   1060 <RamWrite32A@plt>
jmp    12ca <TstActMov+0x15a>
mov    $0x488,%edi
lea    -0x28(%rbp),%rsi
call   1050 <RamRead32A@plt>
movb   $0x2,-0x2(%rbp)
cmpq   $0xa3d0000,-0x28(%rbp)
0a
jbe    1306 <TstActMov+0x196>
cmpb   $0x0,-0x1(%rbp)
jne    12fd <TstActMov+0x18d>
movb   $0x6,-0x2(%rbp)
jmp    1301 <TstActMov+0x191>
movb   $0xa,-0x2(%rbp)
jmp    1306 <TstActMov+0x196>
movzbl -0x2(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<TstActMov>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %edi,%r14d
test   %edi,%edi
mov    $0x1e0,%ebx
mov    $0x230,%eax
mov    $0x230,%ebp
cmove  %rbx,%rbp
cmove  %rax,%rbx
xor    %eax,%eax
call   1090 <SetSinWavGenInt@plt>
mov    $0xc4,%edi
mov    $0x68c16,%esi
call   1060 <RamWrite32A@plt>
mov    $0xcc,%edi
mov    $0x33320000,%esi
call   1060 <RamWrite32A@plt>
mov    $0xbc,%edi
mov    $0x1,%esi
call   1060 <RamWrite32A@plt>
cmp    $0x1,%r14b
ja     11e9 <TstActMov+0x79>
test   %r14b,%r14b
mov    $0x274,%eax
mov    $0x2c4,%esi
cmove  %rax,%rsi
mov    $0xd4,%edi
call   1030 <SetTransDataAdr@plt>
mov    $0x3,%edi
call   1040 <MesFil@plt>
mov    $0x138d,%edi
mov    %rbp,%rsi
mov    %rbx,%rdx
call   1070 <MeasureStart@plt>
xor    %eax,%eax
call   1080 <MeasureWait@plt>
mov    $0xbc,%edi
xor    %esi,%esi
call   1060 <RamWrite32A@plt>
mov    $0xa,%bl
cmp    $0x1,%r14b
ja     124c <TstActMov+0xdc>
test   %r14b,%r14b
setne  %bl
mov    $0x274,%eax
mov    $0x2c4,%ebp
cmove  %eax,%ebp
shl    $0x2,%bl
add    $0x6,%bl
mov    $0xd4,%edi
xor    %esi,%esi
call   1030 <SetTransDataAdr@plt>
mov    %ebp,%edi
xor    %esi,%esi
call   1060 <RamWrite32A@plt>
lea    0x8(%rsp),%rsi
mov    $0x488,%edi
call   1050 <RamRead32A@plt>
cmpq   $0xa3d0001,0x8(%rsp)
3d 0a
movzbl %bl,%ecx
mov    $0x2,%eax
cmovae %ecx,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define zeroext i8 @TstActMov(i8 zeroext %0) {
%2 = alloca i8
%3 = alloca i8
%4 = alloca i64
%5 = alloca i64
%6 = alloca i64
%7 = alloca i64
store i8 %0, i8* %2
store i8 0, i8* %3
store i64 5005, i64* %4
%8 = load i8, i8* %2
%9 = zext i8 %8 to i32
%10 = icmp eq i32 %9, 0
br i1 %10, label %11, label %12
11: ; preds = %1
store i64 480, i64* %5
store i64 560, i64* %6
br label %18
12: ; preds = %1
%13 = load i8, i8* %2
%14 = zext i8 %13 to i32
%15 = icmp eq i32 %14, 1
br i1 %15, label %16, label %17
16: ; preds = %12
store i64 560, i64* %5
store i64 480, i64* %6
br label %17
17: ; preds = %16, %12
br label %18
18: ; preds = %17, %11
%19 = call i32 (...) @SetSinWavGenInt()
%20 = call i32 @RamWrite32A(i32 196, i32 429078)
%21 = call i32 @RamWrite32A(i32 204, i32 858914816)
%22 = call i32 @RamWrite32A(i32 188, i32 1)
%23 = load i8, i8* %2
%24 = zext i8 %23 to i32
%25 = icmp eq i32 %24, 0
br i1 %25, label %26, label %28
26: ; preds = %18
%27 = call i32 @SetTransDataAdr(i32 212, i64 628)
br label %35
28: ; preds = %18
%29 = load i8, i8* %2
%30 = zext i8 %29 to i32
%31 = icmp eq i32 %30, 1
br i1 %31, label %32, label %34
32: ; preds = %28
%33 = call i32 @SetTransDataAdr(i32 212, i64 708)
br label %34
34: ; preds = %32, %28
br label %35
35: ; preds = %34, %26
%36 = call i32 @MesFil(i32 3)
%37 = load i64, i64* %4
%38 = load i64, i64* %5
%39 = load i64, i64* %6
%40 = call i32 @MeasureStart(i64 %37, i64 %38, i64 %39)
%41 = call i32 (...) @MeasureWait()
%42 = call i32 @RamWrite32A(i32 188, i32 0)
%43 = load i8, i8* %2
%44 = zext i8 %43 to i32
%45 = icmp eq i32 %44, 0
br i1 %45, label %46, label %49
46: ; preds = %35
%47 = call i32 @SetTransDataAdr(i32 212, i64 0)
%48 = call i32 @RamWrite32A(i32 628, i32 0)
br label %57
49: ; preds = %35
%50 = load i8, i8* %2
%51 = zext i8 %50 to i32
%52 = icmp eq i32 %51, 1
br i1 %52, label %53, label %56
53: ; preds = %49
%54 = call i32 @SetTransDataAdr(i32 212, i64 0)
%55 = call i32 @RamWrite32A(i32 708, i32 0)
br label %56
56: ; preds = %53, %49
br label %57
57: ; preds = %56, %46
%58 = call i32 @RamRead32A(i32 1160, i64* %7)
store i8 2, i8* %3
%59 = load i64, i64* %7
%60 = icmp ugt i64 %59, 171769856
br i1 %60, label %61, label %67
61: ; preds = %57
%62 = load i8, i8* %2
%63 = icmp ne i8 %62, 0
br i1 %63, label %65, label %64
64: ; preds = %61
store i8 6, i8* %3
br label %66
65: ; preds = %61
store i8 10, i8* %3
br label %66
66: ; preds = %65, %64
br label %67
67: ; preds = %66, %57
%68 = load i8, i8* %3
ret i8 %68
}

LLVM IR (-O2):
define zeroext i8 @TstActMov(i8 zeroext %0) {
%2 = alloca i64
%3 = bitcast i64* %2 to i8*
%4 = icmp eq i8 %0, 0
%5 = select i1 %4, i64 480, i64 560
%6 = select i1 %4, i64 560, i64 480
%7 = tail call i32 (...) @SetSinWavGenInt()
%8 = tail call i32 @RamWrite32A(i32 196, i32 429078)
%9 = tail call i32 @RamWrite32A(i32 204, i32 858914816)
%10 = tail call i32 @RamWrite32A(i32 188, i32 1)
%11 = icmp ult i8 %0, 2
br i1 %11, label %12, label %15
12: ; preds = %1
%13 = select i1 %4, i64 628, i64 708
%14 = tail call i32 @SetTransDataAdr(i32 212, i64 %13)
br label %15
15: ; preds = %1, %12
%16 = tail call i32 @MesFil(i32 3)
%17 = tail call i32 @MeasureStart(i64 5005, i64 %5, i64 %6)
%18 = tail call i32 (...) @MeasureWait()
%19 = tail call i32 @RamWrite32A(i32 188, i32 0)
%20 = icmp ult i8 %0, 2
br i1 %20, label %21, label %26
21: ; preds = %15
%22 = select i1 %4, i8 6, i8 10
%23 = select i1 %4, i32 628, i32 708
%24 = tail call i32 @SetTransDataAdr(i32 212, i64 0)
%25 = tail call i32 @RamWrite32A(i32 %23, i32 0)
br label %26
26: ; preds = %15, %21
%27 = phi i8 [ %22, %21 ], [ 10, %15 ]
%28 = call i32 @RamRead32A(i32 1160, i64* %2)
%29 = load i64, i64* %2
%30 = icmp ugt i64 %29, 171769856
%31 = select i1 %30, i8 %27, i8 2
ret i8 %31
}