#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 getrel();
int shift();
relat() {
  register int vl, vr, rel;
  vl = shift();
  while ((rel = getrel()) != -1) {
    vr = shift();
    switch (rel) {
    case 3:
      vl = (vl <= vr);
      break;
    case 2:
      vl = (vl < vr);
      break;
    case 4:
      vl = (vl > vr);
      break;
    case 5:
      vl = (vl >= vr);
      break;
    }
  }
  return (vl);
}


x86 assembly (clang, -O0):
<relat>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    $0x0,%al
call   1040 <shift@plt>
mov    %eax,-0x4(%rbp)
mov    $0x0,%al
call   1030 <getrel@plt>
mov    %eax,-0xc(%rbp)
cmp    $0xffffffff,%eax
je     11d0 <relat+0xb0>
xor    %eax,%eax
call   1040 <shift@plt>
mov    %eax,-0x8(%rbp)
mov    -0xc(%rbp),%eax
add    $0xfffffffe,%eax
mov    %eax,%ecx
mov    %rcx,-0x18(%rbp)
sub    $0x3,%eax
ja     11cb <relat+0xab>
mov    -0x18(%rbp),%rax
lea    0xe91(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0x4(%rbp),%eax
cmp    -0x8(%rbp),%eax
setle  %al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x4(%rbp)
jmp    11cb <relat+0xab>
mov    -0x4(%rbp),%eax
cmp    -0x8(%rbp),%eax
setl   %al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x4(%rbp)
jmp    11cb <relat+0xab>
mov    -0x4(%rbp),%eax
cmp    -0x8(%rbp),%eax
setg   %al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x4(%rbp)
jmp    11cb <relat+0xab>
mov    -0x4(%rbp),%eax
cmp    -0x8(%rbp),%eax
setge  %al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x4(%rbp)
jmp    1132 <relat+0x12>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<relat>:
push   %rbp
push   %r14
push   %rbx
xor    %eax,%eax
call   1040 <shift@plt>
mov    %eax,%ebp
xor    %eax,%eax
call   1030 <getrel@plt>
cmp    $0xffffffff,%eax
je     11a9 <relat+0x89>
mov    %eax,%ebx
lea    0xebe(%rip),%r14
jmp    1167 <relat+0x47>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
xor    %ecx,%ecx
cmp    %eax,%ebp
setge  %cl
mov    %ecx,%ebp
xor    %eax,%eax
call   1030 <getrel@plt>
mov    %eax,%ebx
cmp    $0xffffffff,%eax
je     11a9 <relat+0x89>
xor    %eax,%eax
call   1040 <shift@plt>
add    $0xfffffffe,%ebx
cmp    $0x3,%ebx
ja     1159 <relat+0x39>
movslq (%r14,%rbx,4),%rcx
add    %r14,%rcx
jmp    *%rcx
xor    %ecx,%ecx
cmp    %eax,%ebp
setl   %cl
jmp    1157 <relat+0x37>
nopl   0x0(%rax,%rax,1)
xor    %ecx,%ecx
cmp    %eax,%ebp
setle  %cl
jmp    1157 <relat+0x37>
nopl   0x0(%rax)
xor    %ecx,%ecx
cmp    %eax,%ebp
setg   %cl
jmp    1157 <relat+0x37>
mov    %ebp,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define i32 @relat() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = call i32 (...) @shift()
store i32 %4, i32* %1
br label %5
5: ; preds = %31, %0
%6 = call i32 (...) @getrel()
store i32 %6, i32* %3
%7 = icmp ne i32 %6, -1
br i1 %7, label %8, label %32
8: ; preds = %5
%9 = call i32 (...) @shift()
store i32 %9, i32* %2
%10 = load i32, i32* %3
switch i32 %10, label %31 [
i32 3, label %11
i32 2, label %16
i32 4, label %21
i32 5, label %26
]
11: ; preds = %8
%12 = load i32, i32* %1
%13 = load i32, i32* %2
%14 = icmp sle i32 %12, %13
%15 = zext i1 %14 to i32
store i32 %15, i32* %1
br label %31
16: ; preds = %8
%17 = load i32, i32* %1
%18 = load i32, i32* %2
%19 = icmp slt i32 %17, %18
%20 = zext i1 %19 to i32
store i32 %20, i32* %1
br label %31
21: ; preds = %8
%22 = load i32, i32* %1
%23 = load i32, i32* %2
%24 = icmp sgt i32 %22, %23
%25 = zext i1 %24 to i32
store i32 %25, i32* %1
br label %31
26: ; preds = %8
%27 = load i32, i32* %1
%28 = load i32, i32* %2
%29 = icmp sge i32 %27, %28
%30 = zext i1 %29 to i32
store i32 %30, i32* %1
br label %31
31: ; preds = %8, %26, %21, %16, %11
br label %5
32: ; preds = %5
%33 = load i32, i32* %1
ret i32 %33
}

LLVM IR (-O2):
define i32 @relat() {
%1 = tail call i32 (...) @shift()
%2 = tail call i32 (...) @getrel()
%3 = icmp eq i32 %2, -1
br i1 %3, label %24, label %4
4: ; preds = %0, %20
%5 = phi i32 [ %22, %20 ], [ %2, %0 ]
%6 = phi i32 [ %21, %20 ], [ %1, %0 ]
%7 = tail call i32 (...) @shift()
switch i32 %5, label %20 [
i32 3, label %8
i32 2, label %11
i32 4, label %14
i32 5, label %17
]
8: ; preds = %4
%9 = icmp sle i32 %6, %7
%10 = zext i1 %9 to i32
br label %20
11: ; preds = %4
%12 = icmp slt i32 %6, %7
%13 = zext i1 %12 to i32
br label %20
14: ; preds = %4
%15 = icmp sgt i32 %6, %7
%16 = zext i1 %15 to i32
br label %20
17: ; preds = %4
%18 = icmp sge i32 %6, %7
%19 = zext i1 %18 to i32
br label %20
20: ; preds = %4, %17, %14, %11, %8
%21 = phi i32 [ %6, %4 ], [ %19, %17 ], [ %16, %14 ], [ %13, %11 ], [ %10, %8 ]
%22 = tail call i32 (...) @getrel()
%23 = icmp eq i32 %22, -1
br i1 %23, label %24, label %4
24: ; preds = %20, %0
%25 = phi i32 [ %1, %0 ], [ %21, %20 ]
ret i32 %25
}