#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 */
long evalvalue();
scalar_t__ test(char *);
long evaleq() {
  long val;
  for (val = evalvalue();;) {
    if (test("=="))
      val = val == evalvalue();
    else if (test("!="))
      val = val != evalvalue();
    else
      break;
  }
  return (val);
}


x86 assembly (clang, -O0):
<evaleq>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    $0x0,%al
call   1030 <evalvalue@plt>
mov    %rax,-0x8(%rbp)
lea    0xec6(%rip),%rdi
call   1040 <test@plt>
cmp    $0x0,%rax
je     1175 <evaleq+0x55>
mov    -0x8(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    $0x0,%al
call   1030 <evalvalue@plt>
mov    %rax,%rcx
mov    -0x10(%rbp),%rax
cmp    %rcx,%rax
sete   %al
and    $0x1,%al
movzbl %al,%eax
cltq
mov    %rax,-0x8(%rbp)
jmp    11c1 <evaleq+0xa1>
lea    0xe87(%rip),%rdi
call   1040 <test@plt>
cmp    $0x0,%rax
je     11b7 <evaleq+0x97>
mov    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    $0x0,%al
call   1030 <evalvalue@plt>
mov    %rax,%rcx
mov    -0x18(%rbp),%rax
cmp    %rcx,%rax
setne  %al
and    $0x1,%al
movzbl %al,%eax
cltq
mov    %rax,-0x8(%rbp)
jmp    11bc <evaleq+0x9c>
jmp    11c6 <evaleq+0xa6>
jmp    11c1 <evaleq+0xa1>
jmp    1133 <evaleq+0x13>
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<evaleq>:
push   %r15
push   %r14
push   %rbx
xor    %eax,%eax
call   1030 <evalvalue@plt>
mov    %rax,%rbx
lea    0xeca(%rip),%r15
lea    0xec6(%rip),%r14
jmp    1150 <evaleq+0x30>
nop
xor    %eax,%eax
call   1030 <evalvalue@plt>
cmp    %rax,%rbx
sete   %al
movzbl %al,%ebx
mov    %r15,%rdi
call   1040 <test@plt>
test   %rax,%rax
jne    1140 <evaleq+0x20>
mov    %r14,%rdi
call   1040 <test@plt>
test   %rax,%rax
je     117c <evaleq+0x5c>
xor    %eax,%eax
call   1030 <evalvalue@plt>
cmp    %rax,%rbx
setne  %al
movzbl %al,%ebx
jmp    1150 <evaleq+0x30>
mov    %rbx,%rax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [3 x i8] c"==\00"
@.str.1 = [3 x i8] c"!=\00"
define i64 @evaleq() {
%1 = alloca i64
%2 = call i64 (...) @evalvalue()
store i64 %2, i64* %1
br label %3
3: ; preds = %23, %0
%4 = call i64 @test(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%5 = icmp ne i64 %4, 0
br i1 %5, label %6, label %12
6: ; preds = %3
%7 = load i64, i64* %1
%8 = call i64 (...) @evalvalue()
%9 = icmp eq i64 %7, %8
%10 = zext i1 %9 to i32
%11 = sext i32 %10 to i64
store i64 %11, i64* %1
br label %23
12: ; preds = %3
%13 = call i64 @test(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%14 = icmp ne i64 %13, 0
br i1 %14, label %15, label %21
15: ; preds = %12
%16 = load i64, i64* %1
%17 = call i64 (...) @evalvalue()
%18 = icmp ne i64 %16, %17
%19 = zext i1 %18 to i32
%20 = sext i32 %19 to i64
store i64 %20, i64* %1
br label %22
21: ; preds = %12
br label %24
22: ; preds = %15
br label %23
23: ; preds = %22, %6
br label %3
24: ; preds = %21
%25 = load i64, i64* %1
ret i64 %25
}

LLVM IR (-O2):
@.str = [3 x i8] c"==\00"
@.str.1 = [3 x i8] c"!=\00"
define i64 @evaleq() {
%1 = tail call i64 (...) @evalvalue()
br label %2
2: ; preds = %15, %0
%3 = phi i64 [ %1, %0 ], [ %17, %15 ]
%4 = tail call i64 @test(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%5 = icmp eq i64 %4, 0
br i1 %5, label %9, label %6
6: ; preds = %2
%7 = tail call i64 (...) @evalvalue()
%8 = icmp eq i64 %3, %7
br label %15
9: ; preds = %2
%10 = tail call i64 @test(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%11 = icmp eq i64 %10, 0
br i1 %11, label %18, label %12
12: ; preds = %9
%13 = tail call i64 (...) @evalvalue()
%14 = icmp ne i64 %3, %13
br label %15
15: ; preds = %12, %6
%16 = phi i1 [ %8, %6 ], [ %14, %12 ]
%17 = zext i1 %16 to i64
br label %2
18: ; preds = %9
ret i64 %3
}