#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 eval();
long evallor();
int /*<<< orphan*/ non_fatal(char *, char *);
int /*<<< orphan*/ test(char *);
long evaltern() {
  long val;
  long val_f;
  long val_t;
  val = evallor();
  if (!test("?"))
    return (val);
  val_t = eval();
  if (!test(":")) {
    non_fatal("':' expected", "");
    return ((long)0);
  }
  val_f = eval();
  return (val ? val_t : val_f);
}


x86 assembly (clang, -O0):
<evaltern>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    $0x0,%al
call   1030 <evallor@plt>
mov    %rax,-0x10(%rbp)
lea    0xea6(%rip),%rdi
call   1060 <test@plt>
cmp    $0x0,%eax
jne    1175 <evaltern+0x35>
mov    -0x10(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    11e8 <evaltern+0xa8>
mov    $0x0,%al
call   1050 <eval@plt>
mov    %rax,-0x20(%rbp)
lea    0xe7b(%rip),%rdi
call   1060 <test@plt>
cmp    $0x0,%eax
jne    11b5 <evaltern+0x75>
lea    0xe68(%rip),%rdi
lea    0xe60(%rip),%rsi
call   1040 <non_fatal@plt>
movq   $0x0,-0x8(%rbp)
jmp    11e8 <evaltern+0xa8>
mov    $0x0,%al
call   1050 <eval@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     11d8 <evaltern+0x98>
mov    -0x20(%rbp),%rax
mov    %rax,-0x28(%rbp)
jmp    11e0 <evaltern+0xa0>
mov    -0x18(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<evaltern>:
push   %r14
push   %rbx
push   %rax
xor    %eax,%eax
call   1030 <evallor@plt>
mov    %rax,%rbx
lea    0xeab(%rip),%rdi
call   1060 <test@plt>
test   %eax,%eax
je     11a0 <evaltern+0x60>
xor    %eax,%eax
call   1050 <eval@plt>
mov    %rax,%r14
lea    0xe93(%rip),%rdi
call   1060 <test@plt>
test   %eax,%eax
je     118b <evaltern+0x4b>
xor    %eax,%eax
call   1050 <eval@plt>
test   %rbx,%rbx
cmove  %rax,%r14
mov    %r14,%rbx
jmp    11a0 <evaltern+0x60>
lea    0xe72(%rip),%rdi
lea    0xe6a(%rip),%rsi
call   1040 <non_fatal@plt>
xor    %ebx,%ebx
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [2 x i8] c"?\00"
@.str.1 = [2 x i8] c":\00"
@.str.2 = [13 x i8] c"':' expected\00"
@.str.3 = [1 x i8] zeroinitializer
define i64 @evaltern() {
%1 = alloca i64
%2 = alloca i64
%3 = alloca i64
%4 = alloca i64
%5 = call i64 (...) @evallor()
store i64 %5, i64* %2
%6 = call i32 @test(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%7 = icmp ne i32 %6, 0
br i1 %7, label %10, label %8
8: ; preds = %0
%9 = load i64, i64* %2
store i64 %9, i64* %1
br label %26
10: ; preds = %0
%11 = call i64 (...) @eval()
store i64 %11, i64* %4
%12 = call i32 @test(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%13 = icmp ne i32 %12, 0
br i1 %13, label %16, label %14
14: ; preds = %10
%15 = call i32 @non_fatal(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.3, i64 0, i64 0))
store i64 0, i64* %1
br label %26
16: ; preds = %10
%17 = call i64 (...) @eval()
store i64 %17, i64* %3
%18 = load i64, i64* %2
%19 = icmp ne i64 %18, 0
br i1 %19, label %20, label %22
20: ; preds = %16
%21 = load i64, i64* %4
br label %24
22: ; preds = %16
%23 = load i64, i64* %3
br label %24
24: ; preds = %22, %20
%25 = phi i64 [ %21, %20 ], [ %23, %22 ]
store i64 %25, i64* %1
br label %26
26: ; preds = %24, %14, %8
%27 = load i64, i64* %1
ret i64 %27
}

LLVM IR (-O2):
@.str = [2 x i8] c"?\00"
@.str.1 = [2 x i8] c":\00"
@.str.2 = [13 x i8] c"':' expected\00"
@.str.3 = [1 x i8] zeroinitializer
define i64 @evaltern() {
%1 = tail call i64 (...) @evallor()
%2 = tail call i32 @test(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%3 = icmp eq i32 %2, 0
br i1 %3, label %14, label %4
4: ; preds = %0
%5 = tail call i64 (...) @eval()
%6 = tail call i32 @test(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%7 = icmp eq i32 %6, 0
br i1 %7, label %8, label %10
8: ; preds = %4
%9 = tail call i32 @non_fatal(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.3, i64 0, i64 0))
br label %14
10: ; preds = %4
%11 = tail call i64 (...) @eval()
%12 = icmp eq i64 %1, 0
%13 = select i1 %12, i64 %11, i64 %5
br label %14
14: ; preds = %0, %10, %8
%15 = phi i64 [ %13, %10 ], [ 0, %8 ], [ %1, %0 ]
ret i64 %15
}