#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 */
int car(int);
int cdr(int);
int /*<<< orphan*/ display(int);
scalar_t__ pairp(int);
int /*<<< orphan*/ printf(char *);
void display_pair(int32_t val) {
  printf("(");
  display(car(val));
  int32_t x = cdr(val);
  while (pairp(x)) {
    printf(" ");
    display(car(x));
    x = cdr(x);
  }
  if (x != 0x2f) {
    printf(" . ");
    display(x);
  }
  printf(")");
}


x86 assembly (clang, -O0):
<display_pair>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
lea    0xe9e(%rip),%rdi
call   1050 <printf@plt>
mov    -0x4(%rbp),%edi
call   1070 <car@plt>
mov    %eax,%edi
call   1040 <display@plt>
mov    -0x4(%rbp),%edi
call   1030 <cdr@plt>
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%edi
call   1060 <pairp@plt>
cmp    $0x0,%rax
je     11be <display_pair+0x6e>
lea    0xe6a(%rip),%rdi
call   1050 <printf@plt>
mov    -0x8(%rbp),%edi
call   1070 <car@plt>
mov    %eax,%edi
call   1040 <display@plt>
mov    -0x8(%rbp),%edi
call   1030 <cdr@plt>
mov    %eax,-0x8(%rbp)
jmp    1181 <display_pair+0x31>
cmpl   $0x2f,-0x8(%rbp)
je     11dc <display_pair+0x8c>
lea    0xe33(%rip),%rdi
call   1050 <printf@plt>
mov    -0x8(%rbp),%edi
call   1040 <display@plt>
lea    0xe23(%rip),%rdi
call   1050 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<display_pair>:
push   %rbx
mov    %edi,%ebx
mov    $0x28,%edi
nopl   0x0(%rax,%rax,1)
call   1030 <putchar@plt>
mov    %ebx,%edi
call   1080 <car@plt>
mov    %eax,%edi
call   1050 <display@plt>
mov    %ebx,%edi
call   1040 <cdr@plt>
mov    %eax,%ebx
mov    %eax,%edi
call   1070 <pairp@plt>
test   %rax,%rax
je     119f <display_pair+0x3f>
mov    $0x20,%edi
jmp    1170 <display_pair+0x10>
cmp    $0x2f,%ebx
je     11b7 <display_pair+0x57>
lea    0xe55(%rip),%rdi
call   1060 <printf@plt>
mov    %ebx,%edi
call   1050 <display@plt>
mov    $0x29,%edi
pop    %rbx
jmp    1030 <putchar@plt>

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

LLVM IR (-O2):
@.str.2 = [4 x i8] c" . \00"
define void @display_pair(i32 %0) {
%2 = tail call i32 @putchar(i32 40)
%3 = tail call i32 @car(i32 %0)
%4 = tail call i32 @display(i32 %3)
%5 = tail call i32 @cdr(i32 %0)
%6 = tail call i64 @pairp(i32 %5)
%7 = icmp eq i64 %6, 0
br i1 %7, label %16, label %8
8: ; preds = %1, %8
%9 = phi i32 [ %13, %8 ], [ %5, %1 ]
%10 = tail call i32 @putchar(i32 32)
%11 = tail call i32 @car(i32 %9)
%12 = tail call i32 @display(i32 %11)
%13 = tail call i32 @cdr(i32 %9)
%14 = tail call i64 @pairp(i32 %13)
%15 = icmp eq i64 %14, 0
br i1 %15, label %16, label %8
16: ; preds = %8, %1
%17 = phi i32 [ %5, %1 ], [ %13, %8 ]
%18 = icmp eq i32 %17, 47
br i1 %18, label %22, label %19
19: ; preds = %16
%20 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
%21 = tail call i32 @display(i32 %17)
br label %22
22: ; preds = %19, %16
%23 = tail call i32 @putchar(i32 41)
ret void
}