#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 /*<<< orphan*/ assert(int);
int f();
int /*<<< orphan*/ from_int(int);
int intval(int);
int pair(int, int /*<<< orphan*/);
int t();
int read_integer(int cell) {
  int value = intval(cell);
  assert(value >= 0);
  return value == 0 ? f() : pair(value & 0x1 ? t() : f(), from_int(value >> 1));
}


x86 assembly (clang, -O0):
<read_integer>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%edi
call   1080 <intval@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
setge  %al
and    $0x1,%al
movzbl %al,%edi
call   1070 <assert@plt>
cmpl   $0x0,-0x8(%rbp)
jne    11a0 <read_integer+0x40>
mov    $0x0,%al
call   1050 <f@plt>
mov    %eax,-0xc(%rbp)
jmp    11e6 <read_integer+0x86>
mov    -0x8(%rbp),%eax
and    $0x1,%eax
cmp    $0x0,%eax
je     11be <read_integer+0x5e>
mov    $0x0,%al
call   1030 <t@plt>
mov    %eax,-0x10(%rbp)
jmp    11c8 <read_integer+0x68>
mov    $0x0,%al
call   1050 <f@plt>
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%edi
sar    $0x1,%edi
call   1040 <from_int@plt>
mov    -0x14(%rbp),%edi
mov    %eax,%esi
call   1060 <pair@plt>
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<read_integer>:
push   %rbp
push   %rbx
push   %rax
call   1080 <intval@plt>
mov    %eax,%ebx
mov    %eax,%edi
not    %edi
shr    $0x1f,%edi
call   1070 <assert@plt>
xor    %eax,%eax
test   %ebx,%ebx
je     1188 <read_integer+0x28>
test   $0x1,%bl
jne    1193 <read_integer+0x33>
call   1050 <f@plt>
jmp    1198 <read_integer+0x38>
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1050 <f@plt>
call   1030 <t@plt>
mov    %eax,%ebp
sar    %ebx
mov    %ebx,%edi
call   1040 <from_int@plt>
mov    %ebp,%edi
mov    %eax,%esi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1060 <pair@plt>

LLVM IR (-O0):
define i32 @read_integer(i32 %0) {
%2 = alloca i32
%3 = alloca i32
store i32 %0, i32* %2
%4 = load i32, i32* %2
%5 = call i32 @intval(i32 %4)
store i32 %5, i32* %3
%6 = load i32, i32* %3
%7 = icmp sge i32 %6, 0
%8 = zext i1 %7 to i32
%9 = call i32 @assert(i32 %8)
%10 = load i32, i32* %3
%11 = icmp eq i32 %10, 0
br i1 %11, label %12, label %14
12: ; preds = %1
%13 = call i32 (...) @f()
br label %28
14: ; preds = %1
%15 = load i32, i32* %3
%16 = and i32 %15, 1
%17 = icmp ne i32 %16, 0
br i1 %17, label %18, label %20
18: ; preds = %14
%19 = call i32 (...) @t()
br label %22
20: ; preds = %14
%21 = call i32 (...) @f()
br label %22
22: ; preds = %20, %18
%23 = phi i32 [ %19, %18 ], [ %21, %20 ]
%24 = load i32, i32* %3
%25 = ashr i32 %24, 1
%26 = call i32 @from_int(i32 %25)
%27 = call i32 @pair(i32 %23, i32 %26)
br label %28
28: ; preds = %22, %12
%29 = phi i32 [ %13, %12 ], [ %27, %22 ]
ret i32 %29
}

LLVM IR (-O2):
define i32 @read_integer(i32 %0) {
%2 = tail call i32 @intval(i32 %0)
%3 = xor i32 %2, -1
%4 = lshr i32 %3, 31
%5 = tail call i32 @assert(i32 %4)
%6 = icmp eq i32 %2, 0
br i1 %6, label %7, label %9
7: ; preds = %1
%8 = tail call i32 (...) @f()
br label %21
9: ; preds = %1
%10 = and i32 %2, 1
%11 = icmp eq i32 %10, 0
br i1 %11, label %14, label %12
12: ; preds = %9
%13 = tail call i32 (...) @t()
br label %16
14: ; preds = %9
%15 = tail call i32 (...) @f()
br label %16
16: ; preds = %14, %12
%17 = phi i32 [ %13, %12 ], [ %15, %14 ]
%18 = ashr i32 %2, 1
%19 = tail call i32 @from_int(i32 %18)
%20 = tail call i32 @pair(i32 %17, i32 %19)
br label %21
21: ; preds = %16, %7
%22 = phi i32 [ %8, %7 ], [ %20, %16 ]
ret i32 %22
}