#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 */
struct addresslistent {
  int dummy;
};

/* Variables and functions */
unsigned long long qp_getkey(struct addresslistent *, int);
int qp_compare(struct addresslistent *entry, unsigned long long pv, int ch,
               int side) {
  int result = 0;
  unsigned long long value;
  value = qp_getkey(entry, ch);
  if (ch == 'R') {
    if (side == 0)
      result = (value <= pv);
    else
      result = (value > pv);
  } else {
    if (side == 0)
      result = (value >= pv);
    else
      result = (value < pv);
  }
  return result;
}


x86 assembly (clang, -O0):
<qp_compare>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %ecx,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   1030 <qp_getkey@plt>
mov    %rax,-0x28(%rbp)
cmpl   $0x52,-0x14(%rbp)
jne    1181 <qp_compare+0x71>
cmpl   $0x0,-0x18(%rbp)
jne    1169 <qp_compare+0x59>
mov    -0x28(%rbp),%rax
cmp    -0x10(%rbp),%rax
setbe  %al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x1c(%rbp)
jmp    117c <qp_compare+0x6c>
mov    -0x28(%rbp),%rax
cmp    -0x10(%rbp),%rax
seta   %al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x1c(%rbp)
jmp    11bb <qp_compare+0xab>
cmpl   $0x0,-0x18(%rbp)
jne    11a3 <qp_compare+0x93>
mov    -0x28(%rbp),%rax
cmp    -0x10(%rbp),%rax
setae  %al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x1c(%rbp)
jmp    11b6 <qp_compare+0xa6>
mov    -0x28(%rbp),%rax
cmp    -0x10(%rbp),%rax
setb   %al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x1c(%rbp)
jmp    11bb <qp_compare+0xab>
mov    -0x1c(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<qp_compare>:
push   %rbp
push   %r14
push   %rbx
mov    %ecx,%ebp
mov    %edx,%ebx
mov    %rsi,%r14
mov    %edx,%esi
call   1030 <qp_getkey@plt>
cmp    $0x52,%ebx
jne    1133 <qp_compare+0x23>
test   %ebp,%ebp
je     113f <qp_compare+0x2f>
cmp    %r14,%rax
seta   %al
jmp    114d <qp_compare+0x3d>
test   %ebp,%ebp
je     1147 <qp_compare+0x37>
cmp    %r14,%rax
setb   %al
jmp    114d <qp_compare+0x3d>
cmp    %r14,%rax
setbe  %al
jmp    114d <qp_compare+0x3d>
cmp    %r14,%rax
setae  %al
movzbl %al,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
%struct.addresslistent = type { i32 }
define i32 @qp_compare(%struct.addresslistent* %0, i64 %1, i32 %2, i32 %3) {
%5 = alloca %struct.addresslistent*
%6 = alloca i64
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i64
store %struct.addresslistent* %0, %struct.addresslistent** %5
store i64 %1, i64* %6
store i32 %2, i32* %7
store i32 %3, i32* %8
store i32 0, i32* %9
%11 = load %struct.addresslistent*, %struct.addresslistent** %5
%12 = load i32, i32* %7
%13 = call i64 @qp_getkey(%struct.addresslistent* %11, i32 %12)
store i64 %13, i64* %10
%14 = load i32, i32* %7
%15 = icmp eq i32 %14, 82
br i1 %15, label %16, label %30
16: ; preds = %4
%17 = load i32, i32* %8
%18 = icmp eq i32 %17, 0
br i1 %18, label %19, label %24
19: ; preds = %16
%20 = load i64, i64* %10
%21 = load i64, i64* %6
%22 = icmp ule i64 %20, %21
%23 = zext i1 %22 to i32
store i32 %23, i32* %9
br label %29
24: ; preds = %16
%25 = load i64, i64* %10
%26 = load i64, i64* %6
%27 = icmp ugt i64 %25, %26
%28 = zext i1 %27 to i32
store i32 %28, i32* %9
br label %29
29: ; preds = %24, %19
br label %44
30: ; preds = %4
%31 = load i32, i32* %8
%32 = icmp eq i32 %31, 0
br i1 %32, label %33, label %38
33: ; preds = %30
%34 = load i64, i64* %10
%35 = load i64, i64* %6
%36 = icmp uge i64 %34, %35
%37 = zext i1 %36 to i32
store i32 %37, i32* %9
br label %43
38: ; preds = %30
%39 = load i64, i64* %10
%40 = load i64, i64* %6
%41 = icmp ult i64 %39, %40
%42 = zext i1 %41 to i32
store i32 %42, i32* %9
br label %43
43: ; preds = %38, %33
br label %44
44: ; preds = %43, %29
%45 = load i32, i32* %9
ret i32 %45
}

LLVM IR (-O2):
%struct.addresslistent = type { i32 }
define i32 @qp_compare(%struct.addresslistent* %0, i64 %1, i32 %2, i32 %3) {
%5 = tail call i64 @qp_getkey(%struct.addresslistent* %0, i32 %2)
%6 = icmp eq i32 %2, 82
%7 = icmp eq i32 %3, 0
br i1 %6, label %8, label %13
8: ; preds = %4
br i1 %7, label %9, label %11
9: ; preds = %8
%10 = icmp ule i64 %5, %1
br label %18
11: ; preds = %8
%12 = icmp ugt i64 %5, %1
br label %18
13: ; preds = %4
br i1 %7, label %14, label %16
14: ; preds = %13
%15 = icmp uge i64 %5, %1
br label %18
16: ; preds = %13
%17 = icmp ult i64 %5, %1
br label %18
18: ; preds = %14, %16, %9, %11
%19 = phi i1 [ %10, %9 ], [ %12, %11 ], [ %15, %14 ], [ %17, %16 ]
%20 = zext i1 %19 to i32
ret i32 %20
}