void bu_compile_cadr(name, args) char *name;
struct conscell *args;
{
  char *s;
  char msg[50];
  int n = strlen(name);
  if (bu_compile_arg_list(args) != 1)
    goto er;
  for (s = name + n - 2; *s != 'c'; s--) {
    if (*s == 'd')
      EMIT1ATM("CDR");
    else
      EMIT1ATM("CAR");
    EMITEND();
  }
  return;
er:
  if (n + 20 >= sizeof(msg))
    name = "c{a|d}+r";
  sprintf(msg, "%s: wrong # of args", name);
  cerror(msg, args);
  return;
}


x86 assembly (clang, -O0):
<bu_compile_cadr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x54(%rbp)
mov    -0x10(%rbp),%rdi
mov    $0x0,%al
call   1050 <bu_compile_arg_list@plt>
cmp    $0x1,%eax
je     1195 <bu_compile_cadr+0x35>
jmp    1206 <bu_compile_cadr+0xa6>
mov    -0x8(%rbp),%rax
movslq -0x54(%rbp),%rcx
add    %rcx,%rax
add    $0xfffffffffffffffe,%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x63,%eax
je     1201 <bu_compile_cadr+0xa1>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x64,%eax
jne    11db <bu_compile_cadr+0x7b>
lea    0xe31(%rip),%rdi
mov    $0x0,%al
call   1060 <EMIT1ATM@plt>
jmp    11e9 <bu_compile_cadr+0x89>
lea    0xe22(%rip),%rdi
mov    $0x0,%al
call   1060 <EMIT1ATM@plt>
mov    $0x0,%al
call   1030 <EMITEND@plt>
mov    -0x18(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x18(%rbp)
jmp    11a8 <bu_compile_cadr+0x48>
jmp    1248 <bu_compile_cadr+0xe8>
mov    -0x54(%rbp),%eax
add    $0x14,%eax
cltq
cmp    $0x32,%rax
jb     1223 <bu_compile_cadr+0xc3>
lea    0xde9(%rip),%rax
mov    %rax,-0x8(%rbp)
lea    -0x50(%rbp),%rdi
mov    -0x8(%rbp),%rdx
lea    0xddf(%rip),%rsi
mov    $0x0,%al
call   1070 <sprintf@plt>
lea    -0x50(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    $0x0,%al
call   1080 <cerror@plt>
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<bu_compile_cadr>:
push   %r15
push   %r14
push   %rbx
sub    $0x40,%rsp
mov    %rsi,%r14
mov    %rdi,%r15
call   1040 <strlen@plt>
mov    %rax,%rbx
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <bu_compile_arg_list@plt>
shl    $0x20,%rbx
cmp    $0x1,%eax
jne    11d5 <bu_compile_cadr+0x75>
sar    $0x20,%rbx
add    %r15,%rbx
add    $0xfffffffffffffffe,%rbx
lea    0xe64(%rip),%r14
lea    0xe61(%rip),%r15
jmp    11c2 <bu_compile_cadr+0x62>
cs nopw 0x0(%rax,%rax,1)
nop
xor    %eax,%eax
call   1060 <EMIT1ATM@plt>
xor    %eax,%eax
call   1030 <EMITEND@plt>
add    $0xffffffffffffffff,%rbx
movzbl (%rbx),%eax
mov    %r14,%rdi
cmp    $0x64,%al
je     11b0 <bu_compile_cadr+0x50>
cmp    $0x63,%al
je     121e <bu_compile_cadr+0xbe>
mov    %r15,%rdi
jmp    11b0 <bu_compile_cadr+0x50>
movabs $0xffffffe2ffffffff,%rax
ff ff ff
add    %rax,%rbx
movabs $0xffffffceffffffff,%rax
ff ff ff
cmp    %rax,%rbx
lea    0xe12(%rip),%rax
cmovb  %rax,%r15
lea    0xe10(%rip),%rsi
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    %r15,%rdx
xor    %eax,%eax
call   1070 <sprintf@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1080 <cerror@plt>
add    $0x40,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.conscell = type opaque
@.str = [4 x i8] c"CDR\00"
@.str.1 = [4 x i8] c"CAR\00"
@.str.2 = [9 x i8] c"c{a|d}+r\00"
@.str.3 = [20 x i8] c"%s: wrong # of args\00"
define void @bu_compile_cadr(i8* %0, %struct.conscell* %1) {
%3 = alloca i8*
%4 = alloca %struct.conscell*
%5 = alloca i8*
%6 = alloca [50 x i8]
%7 = alloca i32
store i8* %0, i8** %3
store %struct.conscell* %1, %struct.conscell** %4
%8 = load i8*, i8** %3
%9 = call i64 @strlen(i8* %8)
%10 = trunc i64 %9 to i32
store i32 %10, i32* %7
%11 = load %struct.conscell*, %struct.conscell** %4
%12 = call i32 (%struct.conscell*, ...) bitcast (i32 (...)* @bu_compile_arg_list to i32 (%struct.conscell*, ...)*)(%struct.conscell* %11)
%13 = icmp ne i32 %12, 1
br i1 %13, label %14, label %15
14: ; preds = %2
br label %41
15: ; preds = %2
%16 = load i8*, i8** %3
%17 = load i32, i32* %7
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds i8, i8* %16, i64 %18
%20 = getelementptr inbounds i8, i8* %19, i64 -2
store i8* %20, i8** %5
br label %21
21: ; preds = %37, %15
%22 = load i8*, i8** %5
%23 = load i8, i8* %22
%24 = sext i8 %23 to i32
%25 = icmp ne i32 %24, 99
br i1 %25, label %26, label %40
26: ; preds = %21
%27 = load i8*, i8** %5
%28 = load i8, i8* %27
%29 = sext i8 %28 to i32
%30 = icmp eq i32 %29, 100
br i1 %30, label %31, label %33
31: ; preds = %26
%32 = call i32 (i8*, ...) bitcast (i32 (...)* @EMIT1ATM to i32 (i8*, ...)*)(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
br label %35
33: ; preds = %26
%34 = call i32 (i8*, ...) bitcast (i32 (...)* @EMIT1ATM to i32 (i8*, ...)*)(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
br label %35
35: ; preds = %33, %31
%36 = call i32 (...) @EMITEND()
br label %37
37: ; preds = %35
%38 = load i8*, i8** %5
%39 = getelementptr inbounds i8, i8* %38, i32 -1
store i8* %39, i8** %5
br label %21
40: ; preds = %21
br label %54
41: ; preds = %14
%42 = load i32, i32* %7
%43 = add nsw i32 %42, 20
%44 = sext i32 %43 to i64
%45 = icmp uge i64 %44, 50
br i1 %45, label %46, label %47
46: ; preds = %41
store i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i8** %3
br label %47
47: ; preds = %46, %41
%48 = getelementptr inbounds [50 x i8], [50 x i8]* %6, i64 0, i64 0
%49 = load i8*, i8** %3
%50 = call i32 (i8*, i8*, ...) @sprintf(i8* %48, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.3, i64 0, i64 0), i8* %49)
%51 = getelementptr inbounds [50 x i8], [50 x i8]* %6, i64 0, i64 0
%52 = load %struct.conscell*, %struct.conscell** %4
%53 = call i32 (i8*, %struct.conscell*, ...) bitcast (i32 (...)* @cerror to i32 (i8*, %struct.conscell*, ...)*)(i8* %51, %struct.conscell* %52)
br label %54
54: ; preds = %47, %40
ret void
}

LLVM IR (-O2):
%struct.conscell = type opaque
@.str = [4 x i8] c"CDR\00"
@.str.1 = [4 x i8] c"CAR\00"
@.str.2 = [9 x i8] c"c{a|d}+r\00"
@.str.3 = [20 x i8] c"%s: wrong # of args\00"
define void @bu_compile_cadr(i8* %0, %struct.conscell* %1) {
%3 = alloca [50 x i8]
%4 = getelementptr inbounds [50 x i8], [50 x i8]* %3, i64 0, i64 0
%5 = tail call i64 @strlen(i8* dereferenceable(1) %0)
%6 = tail call i32 (%struct.conscell*, ...) bitcast (i32 (...)* @bu_compile_arg_list to i32 (%struct.conscell*, ...)*)(%struct.conscell* %1)
%7 = icmp eq i32 %6, 1
%8 = shl i64 %5, 32
br i1 %7, label %9, label %22
9: ; preds = %2
%10 = ashr exact i64 %8, 32
%11 = getelementptr inbounds i8, i8* %0, i64 %10
%12 = getelementptr inbounds i8, i8* %11, i64 -2
br label %13
13: ; preds = %17, %9
%14 = phi i8* [ %12, %9 ], [ %21, %17 ]
%15 = load i8, i8* %14
switch i8 %15, label %16 [
i8 99, label %28
i8 100, label %17
]
16: ; preds = %13
br label %17
17: ; preds = %13, %16
%18 = phi i8* [ getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), %16 ], [ getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), %13 ]
%19 = tail call i32 (i8*, ...) bitcast (i32 (...)* @EMIT1ATM to i32 (i8*, ...)*)(i8* %18)
%20 = tail call i32 (...) @EMITEND()
%21 = getelementptr inbounds i8, i8* %14, i64 -1
br label %13
22: ; preds = %2
%23 = add i64 %8, -124554051585
%24 = icmp ult i64 %23, -210453397505
%25 = select i1 %24, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i8* %0
%26 = call i32 (i8*, i8*, ...) @sprintf(i8* %4, i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.3, i64 0, i64 0), i8* %25)
%27 = call i32 (i8*, %struct.conscell*, ...) bitcast (i32 (...)* @cerror to i32 (i8*, %struct.conscell*, ...)*)(i8* %4, %struct.conscell* %1)
br label %28
28: ; preds = %13, %22
ret void
}