#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 */
typedef int int32_t;

/* Variables and functions */
scalar_t__ booleanp(int);
int /*<<< orphan*/ display_boolean(int);
int /*<<< orphan*/ display_pair(int);
scalar_t__ pairp(int);
int /*<<< orphan*/ printf(char *, ...);
void display(int32_t val) {
  if ((val & 3) == 0) {
    printf("%d", (val >> 2));
  } else if (pairp(val)) {
    display_pair(val);
  } else if (val == 0x2f) {
    printf("()");
  } else if (booleanp(val)) {
    display_boolean(val);
  } else {
    printf("Error: type of %d unknown\n", val);
  }
}


x86 assembly (clang, -O0):
<display>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%eax
and    $0x3,%eax
cmp    $0x0,%eax
jne    1183 <display+0x33>
mov    -0x4(%rbp),%esi
sar    $0x2,%esi
lea    0xe89(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    11fe <display+0xae>
mov    -0x4(%rbp),%edi
call   1070 <pairp@plt>
cmp    $0x0,%rax
je     11a2 <display+0x52>
mov    -0x4(%rbp),%edi
call   1050 <display_pair@plt>
jmp    11f9 <display+0xa9>
cmpl   $0x2f,-0x4(%rbp)
jne    11bf <display+0x6f>
lea    0xe50(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    11f4 <display+0xa4>
mov    -0x4(%rbp),%edi
call   1060 <booleanp@plt>
cmp    $0x0,%rax
je     11de <display+0x8e>
mov    -0x4(%rbp),%edi
call   1030 <display_boolean@plt>
jmp    11ef <display+0x9f>
mov    -0x4(%rbp),%esi
lea    0xe1e(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    11f4 <display+0xa4>
jmp    11f9 <display+0xa9>
jmp    11fe <display+0xae>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<display>:
push   %rbx
mov    %edi,%ebx
test   $0x3,%bl
je     116c <display+0x1c>
mov    %ebx,%edi
call   1070 <pairp@plt>
test   %rax,%rax
je     1180 <display+0x30>
mov    %ebx,%edi
pop    %rbx
jmp    1050 <display_pair@plt>
sar    $0x2,%ebx
lea    0xe8a(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
pop    %rbx
jmp    1040 <printf@plt>
cmp    $0x2f,%ebx
jne    1194 <display+0x44>
lea    0xe77(%rip),%rdi
xor    %eax,%eax
pop    %rbx
jmp    1040 <printf@plt>
mov    %ebx,%edi
call   1060 <booleanp@plt>
test   %rax,%rax
je     11a8 <display+0x58>
mov    %ebx,%edi
pop    %rbx
jmp    1030 <display_boolean@plt>
lea    0xe57(%rip),%rdi
jmp    1176 <display+0x26>

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
@.str.1 = [3 x i8] c"()\00"
@.str.2 = [27 x i8] c"Error: type of %d unknown\0A\00"
define void @display(i32 %0) {
%2 = alloca i32
store i32 %0, i32* %2
%3 = load i32, i32* %2
%4 = and i32 %3, 3
%5 = icmp eq i32 %4, 0
br i1 %5, label %6, label %10
6: ; preds = %1
%7 = load i32, i32* %2
%8 = ashr i32 %7, 2
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %8)
br label %35
10: ; preds = %1
%11 = load i32, i32* %2
%12 = call i64 @pairp(i32 %11)
%13 = icmp ne i64 %12, 0
br i1 %13, label %14, label %17
14: ; preds = %10
%15 = load i32, i32* %2
%16 = call i32 @display_pair(i32 %15)
br label %34
17: ; preds = %10
%18 = load i32, i32* %2
%19 = icmp eq i32 %18, 47
br i1 %19, label %20, label %22
20: ; preds = %17
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
br label %33
22: ; preds = %17
%23 = load i32, i32* %2
%24 = call i64 @booleanp(i32 %23)
%25 = icmp ne i64 %24, 0
br i1 %25, label %26, label %29
26: ; preds = %22
%27 = load i32, i32* %2
%28 = call i32 @display_boolean(i32 %27)
br label %32
29: ; preds = %22
%30 = load i32, i32* %2
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0), i32 %30)
br label %32
32: ; preds = %29, %26
br label %33
33: ; preds = %32, %20
br label %34
34: ; preds = %33, %14
br label %35
35: ; preds = %34, %6
ret void
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
@.str.1 = [3 x i8] c"()\00"
@.str.2 = [27 x i8] c"Error: type of %d unknown\0A\00"
define void @display(i32 %0) {
%2 = and i32 %0, 3
%3 = icmp eq i32 %2, 0
br i1 %3, label %4, label %7
4: ; preds = %1
%5 = ashr i32 %0, 2
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %5)
br label %23
7: ; preds = %1
%8 = tail call i64 @pairp(i32 %0)
%9 = icmp eq i64 %8, 0
br i1 %9, label %12, label %10
10: ; preds = %7
%11 = tail call i32 @display_pair(i32 %0)
br label %23
12: ; preds = %7
%13 = icmp eq i32 %0, 47
br i1 %13, label %14, label %16
14: ; preds = %12
%15 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
br label %23
16: ; preds = %12
%17 = tail call i64 @booleanp(i32 %0)
%18 = icmp eq i64 %17, 0
br i1 %18, label %21, label %19
19: ; preds = %16
%20 = tail call i32 @display_boolean(i32 %0)
br label %23
21: ; preds = %16
%22 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0), i32 %0)
br label %23
23: ; preds = %10, %19, %21, %14, %4
ret void
}