int dual(c)
register c;
{
  char s[3];
  register char *cp = s;
  *cp++ = c;
  *cp++ = getc(0);
  *cp = 0;
  if ((c = rlookup(s)) == 0)
    unget(*--cp);
  return (c);
}


x86 assembly (clang, -O0):
<dual>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
lea    -0x7(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x4(%rbp),%eax
mov    %al,%cl
mov    -0x10(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x10(%rbp)
mov    %cl,(%rax)
xor    %edi,%edi
mov    $0x0,%al
call   1050 <getc@plt>
mov    %al,%cl
mov    -0x10(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x10(%rbp)
mov    %cl,(%rax)
mov    -0x10(%rbp),%rax
movb   $0x0,(%rax)
lea    -0x7(%rbp),%rdi
mov    $0x0,%al
call   1040 <rlookup@plt>
mov    %eax,-0x4(%rbp)
cmp    $0x0,%eax
jne    11ad <dual+0x7d>
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0xffffffffffffffff,%rcx
mov    %rcx,-0x10(%rbp)
movsbl -0x1(%rax),%edi
mov    $0x0,%al
call   1030 <unget@plt>
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dual>:
push   %rbx
sub    $0x10,%rsp
mov    %dil,0xd(%rsp)
xor    %edi,%edi
xor    %eax,%eax
call   1050 <getc@plt>
mov    %al,0xe(%rsp)
movb   $0x0,0xf(%rsp)
lea    0xd(%rsp),%rdi
xor    %eax,%eax
call   1040 <rlookup@plt>
mov    %eax,%ebx
test   %eax,%eax
jne    116a <dual+0x3a>
movsbl 0xe(%rsp),%edi
xor    %eax,%eax
call   1030 <unget@plt>
mov    %ebx,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
define i32 @dual(i32 %0) {
%2 = alloca i32
%3 = alloca [3 x i8]
%4 = alloca i8*
store i32 %0, i32* %2
%5 = getelementptr inbounds [3 x i8], [3 x i8]* %3, i64 0, i64 0
store i8* %5, i8** %4
%6 = load i32, i32* %2
%7 = trunc i32 %6 to i8
%8 = load i8*, i8** %4
%9 = getelementptr inbounds i8, i8* %8, i32 1
store i8* %9, i8** %4
store i8 %7, i8* %8
%10 = call i32 (i32, ...) bitcast (i32 (...)* @getc to i32 (i32, ...)*)(i32 0)
%11 = trunc i32 %10 to i8
%12 = load i8*, i8** %4
%13 = getelementptr inbounds i8, i8* %12, i32 1
store i8* %13, i8** %4
store i8 %11, i8* %12
%14 = load i8*, i8** %4
store i8 0, i8* %14
%15 = getelementptr inbounds [3 x i8], [3 x i8]* %3, i64 0, i64 0
%16 = call i32 (i8*, ...) bitcast (i32 (...)* @rlookup to i32 (i8*, ...)*)(i8* %15)
store i32 %16, i32* %2
%17 = icmp eq i32 %16, 0
br i1 %17, label %18, label %24
18: ; preds = %1
%19 = load i8*, i8** %4
%20 = getelementptr inbounds i8, i8* %19, i32 -1
store i8* %20, i8** %4
%21 = load i8, i8* %20
%22 = sext i8 %21 to i32
%23 = call i32 (i32, ...) bitcast (i32 (...)* @unget to i32 (i32, ...)*)(i32 %22)
br label %24
24: ; preds = %18, %1
%25 = load i32, i32* %2
ret i32 %25
}

LLVM IR (-O2):
define i32 @dual(i32 %0) {
%2 = alloca [3 x i8]
%3 = getelementptr inbounds [3 x i8], [3 x i8]* %2, i64 0, i64 0
%4 = trunc i32 %0 to i8
%5 = getelementptr inbounds [3 x i8], [3 x i8]* %2, i64 0, i64 1
store i8 %4, i8* %3
%6 = tail call i32 (i32, ...) bitcast (i32 (...)* @getc to i32 (i32, ...)*)(i32 0)
%7 = trunc i32 %6 to i8
%8 = getelementptr inbounds [3 x i8], [3 x i8]* %2, i64 0, i64 2
store i8 %7, i8* %5
store i8 0, i8* %8
%9 = call i32 (i8*, ...) bitcast (i32 (...)* @rlookup to i32 (i8*, ...)*)(i8* %3)
%10 = icmp eq i32 %9, 0
br i1 %10, label %11, label %15
11: ; preds = %1
%12 = load i8, i8* %5
%13 = sext i8 %12 to i32
%14 = call i32 (i32, ...) bitcast (i32 (...)* @unget to i32 (i32, ...)*)(i32 %13)
br label %15
15: ; preds = %11, %1
ret i32 %9
}