#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*/ SetWaitTime(int);
int /*<<< orphan*/ WitTim(int);
unsigned char FrqDet(void) {
  long SlMeasureParameterA, SlMeasureParameterB;
  long SlMeasureParameterNum;
  unsigned long UlXasP_P, UlYasP_P;
  unsigned char UcRtnVal;
  UcRtnVal = 0;
  MesFil(4);
  SlMeasureParameterNum = 1000;
  SlMeasureParameterA = (unsigned long)0x0004 + 0x0004 + 0x0000 + 0x0270;
  SlMeasureParameterB = (unsigned long)0x0004 + 0x0004 + 0x0000 + 0x02c0;
  WitTim(300);
  MeasureStart(SlMeasureParameterNum, SlMeasureParameterA, SlMeasureParameterB);
  SetWaitTime(1);
  MeasureWait();
  RamRead32A(0x0004 + 0x0004 + 0x0000 + 0x0480, &UlXasP_P);
  RamRead32A(0x0004 + 0x0004 + 0x0000 + 0x04A8, &UlYasP_P);
  WitTim(50);
  if (UlXasP_P > 0x01000000) {
    UcRtnVal = 1;
  }
  if (UlYasP_P > 0x01000000) {
    UcRtnVal |= 2;
  }
  return (UcRtnVal);
}


x86 assembly (clang, -O0):
<FrqDet>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movb   $0x0,-0x29(%rbp)
mov    $0x4,%edi
call   1040 <MesFil@plt>
movq   $0x3e8,-0x18(%rbp)
movq   $0x278,-0x8(%rbp)
movq   $0x2c8,-0x10(%rbp)
mov    $0x12c,%edi
call   1080 <WitTim@plt>
mov    -0x18(%rbp),%rdi
mov    -0x8(%rbp),%rsi
mov    -0x10(%rbp),%rdx
call   1060 <MeasureStart@plt>
mov    $0x1,%edi
call   1030 <SetWaitTime@plt>
mov    $0x0,%al
call   1070 <MeasureWait@plt>
mov    $0x488,%edi
lea    -0x20(%rbp),%rsi
call   1050 <RamRead32A@plt>
mov    $0x4b0,%edi
lea    -0x28(%rbp),%rsi
call   1050 <RamRead32A@plt>
mov    $0x32,%edi
call   1080 <WitTim@plt>
cmpq   $0x1000000,-0x20(%rbp)
01
jbe    11f2 <FrqDet+0x92>
movb   $0x1,-0x29(%rbp)
cmpq   $0x1000000,-0x28(%rbp)
01
jbe    120a <FrqDet+0xaa>
movzbl -0x29(%rbp),%eax
or     $0x2,%eax
mov    %al,-0x29(%rbp)
movzbl -0x29(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<FrqDet>:
sub    $0x18,%rsp
mov    $0x4,%edi
call   1040 <MesFil@plt>
mov    $0x12c,%edi
call   1080 <WitTim@plt>
mov    $0x3e8,%edi
mov    $0x278,%esi
mov    $0x2c8,%edx
call   1060 <MeasureStart@plt>
mov    $0x1,%edi
call   1030 <SetWaitTime@plt>
xor    %eax,%eax
call   1070 <MeasureWait@plt>
lea    0x10(%rsp),%rsi
mov    $0x488,%edi
call   1050 <RamRead32A@plt>
lea    0x8(%rsp),%rsi
mov    $0x4b0,%edi
call   1050 <RamRead32A@plt>
mov    $0x32,%edi
call   1080 <WitTim@plt>
xor    %ecx,%ecx
cmpq   $0x1000001,0x10(%rsp)
setae  %cl
cmpq   $0x1000001,0x8(%rsp)
lea    0x2(%rcx),%eax
movzbl %al,%eax
cmovb  %ecx,%eax
add    $0x18,%rsp
ret

LLVM IR (-O0):
define zeroext i8 @FrqDet() {
%1 = alloca i64
%2 = alloca i64
%3 = alloca i64
%4 = alloca i64
%5 = alloca i64
%6 = alloca i8
store i8 0, i8* %6
%7 = call i32 @MesFil(i32 4)
store i64 1000, i64* %3
store i64 632, i64* %1
store i64 712, i64* %2
%8 = call i32 @WitTim(i32 300)
%9 = load i64, i64* %3
%10 = load i64, i64* %1
%11 = load i64, i64* %2
%12 = call i32 @MeasureStart(i64 %9, i64 %10, i64 %11)
%13 = call i32 @SetWaitTime(i32 1)
%14 = call i32 (...) @MeasureWait()
%15 = call i32 @RamRead32A(i32 1160, i64* %4)
%16 = call i32 @RamRead32A(i32 1200, i64* %5)
%17 = call i32 @WitTim(i32 50)
%18 = load i64, i64* %4
%19 = icmp ugt i64 %18, 16777216
br i1 %19, label %20, label %21
20: ; preds = %0
store i8 1, i8* %6
br label %21
21: ; preds = %20, %0
%22 = load i64, i64* %5
%23 = icmp ugt i64 %22, 16777216
br i1 %23, label %24, label %29
24: ; preds = %21
%25 = load i8, i8* %6
%26 = zext i8 %25 to i32
%27 = or i32 %26, 2
%28 = trunc i32 %27 to i8
store i8 %28, i8* %6
br label %29
29: ; preds = %24, %21
%30 = load i8, i8* %6
ret i8 %30
}

LLVM IR (-O2):
define zeroext i8 @FrqDet() {
%1 = alloca i64
%2 = alloca i64
%3 = bitcast i64* %1 to i8*
%4 = bitcast i64* %2 to i8*
%5 = tail call i32 @MesFil(i32 4)
%6 = tail call i32 @WitTim(i32 300)
%7 = tail call i32 @MeasureStart(i64 1000, i64 632, i64 712)
%8 = tail call i32 @SetWaitTime(i32 1)
%9 = tail call i32 (...) @MeasureWait()
%10 = call i32 @RamRead32A(i32 1160, i64* %1)
%11 = call i32 @RamRead32A(i32 1200, i64* %2)
%12 = call i32 @WitTim(i32 50)
%13 = load i64, i64* %1
%14 = icmp ugt i64 %13, 16777216
%15 = zext i1 %14 to i8
%16 = load i64, i64* %2
%17 = icmp ugt i64 %16, 16777216
%18 = or i8 %15, 2
%19 = select i1 %17, i8 %18, i8 %15
ret i8 %19
}