#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 */
unsigned char GetBeaconAmpLeft();
unsigned char GetBeaconAmpRight();
unsigned char LeftEqualRight(void) {
  unsigned char LeftVal = GetBeaconAmpLeft();
  unsigned char RightVal = GetBeaconAmpRight();
  int Difference = LeftVal - RightVal;
  if (Difference < 0)
    Difference *= -1;
  if ((LeftVal > 2) && (RightVal > 2) && (Difference < 3))
    return !0;
  else
    return 0;
}


x86 assembly (clang, -O0):
<LeftEqualRight>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0x0,%al
call   1030 <GetBeaconAmpLeft@plt>
mov    %al,-0x2(%rbp)
mov    $0x0,%al
call   1040 <GetBeaconAmpRight@plt>
mov    %al,-0x3(%rbp)
movzbl -0x2(%rbp),%eax
movzbl -0x3(%rbp),%ecx
sub    %ecx,%eax
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
jge    115a <LeftEqualRight+0x3a>
imul   $0xffffffff,-0x8(%rbp),%eax
mov    %eax,-0x8(%rbp)
movzbl -0x2(%rbp),%eax
cmp    $0x2,%eax
jle    1187 <LeftEqualRight+0x67>
movzbl -0x3(%rbp),%eax
cmp    $0x2,%eax
jle    1187 <LeftEqualRight+0x67>
cmpl   $0x3,-0x8(%rbp)
jge    1187 <LeftEqualRight+0x67>
movb   $0x1,-0x1(%rbp)
jmp    118b <LeftEqualRight+0x6b>
movb   $0x0,-0x1(%rbp)
movzbl -0x1(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<LeftEqualRight>:
push   %rbx
xor    %eax,%eax
call   1030 <GetBeaconAmpLeft@plt>
mov    %eax,%ebx
xor    %eax,%eax
call   1040 <GetBeaconAmpRight@plt>
movzbl %bl,%ecx
movzbl %al,%eax
mov    %ecx,%edx
sub    %eax,%edx
mov    %edx,%esi
neg    %esi
cmovs  %edx,%esi
cmp    $0x3,%cl
setae  %cl
cmp    $0x3,%al
setae  %dl
and    %cl,%dl
cmp    $0x3,%esi
setb   %al
and    %dl,%al
pop    %rbx
ret

LLVM IR (-O0):
define zeroext i8 @LeftEqualRight() {
%1 = alloca i8
%2 = alloca i8
%3 = alloca i8
%4 = alloca i32
%5 = call zeroext i8 (...) @GetBeaconAmpLeft()
store i8 %5, i8* %2
%6 = call zeroext i8 (...) @GetBeaconAmpRight()
store i8 %6, i8* %3
%7 = load i8, i8* %2
%8 = zext i8 %7 to i32
%9 = load i8, i8* %3
%10 = zext i8 %9 to i32
%11 = sub nsw i32 %8, %10
store i32 %11, i32* %4
%12 = load i32, i32* %4
%13 = icmp slt i32 %12, 0
br i1 %13, label %14, label %17
14: ; preds = %0
%15 = load i32, i32* %4
%16 = mul nsw i32 %15, -1
store i32 %16, i32* %4
br label %17
17: ; preds = %14, %0
%18 = load i8, i8* %2
%19 = zext i8 %18 to i32
%20 = icmp sgt i32 %19, 2
br i1 %20, label %21, label %29
21: ; preds = %17
%22 = load i8, i8* %3
%23 = zext i8 %22 to i32
%24 = icmp sgt i32 %23, 2
br i1 %24, label %25, label %29
25: ; preds = %21
%26 = load i32, i32* %4
%27 = icmp slt i32 %26, 3
br i1 %27, label %28, label %29
28: ; preds = %25
store i8 1, i8* %1
br label %30
29: ; preds = %25, %21, %17
store i8 0, i8* %1
br label %30
30: ; preds = %29, %28
%31 = load i8, i8* %1
ret i8 %31
}

LLVM IR (-O2):
define zeroext i8 @LeftEqualRight() {
%1 = tail call zeroext i8 (...) @GetBeaconAmpLeft()
%2 = tail call zeroext i8 (...) @GetBeaconAmpRight()
%3 = zext i8 %1 to i32
%4 = zext i8 %2 to i32
%5 = sub nsw i32 %3, %4
%6 = tail call i32 @llvm.abs.i32(i32 %5, i1 true)
%7 = icmp ugt i8 %1, 2
%8 = icmp ugt i8 %2, 2
%9 = select i1 %7, i1 %8, i1 false
%10 = icmp ult i32 %6, 3
%11 = select i1 %9, i1 %10, i1 false
%12 = zext i1 %11 to i8
ret i8 %12
}