#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 */
char get_char_key(char, int);
int /*<<< orphan*/ printf(char *, char *);
void do_phone_number_letters(char *number, int len, char *buffer) {
  if (*buffer == '\0') {
    printf("%s\n", buffer - len);
    return;
  }
  for (int i = 0; i < 3; i++) {
    buffer[0] = get_char_key(number[0] - '0', i);
    do_phone_number_letters(number + 1, len, buffer + 1);
    if (number[0] == '0' || number[0] == '1') {
      return;
    }
  }
}


x86 assembly (clang, -O0):
<do_phone_number_letters>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
jne    1174 <do_phone_number_letters+0x44>
mov    -0x18(%rbp),%rsi
movslq -0xc(%rbp),%rcx
xor    %eax,%eax
sub    %rcx,%rax
add    %rax,%rsi
lea    0xe96(%rip),%rdi
call   1040 <printf@plt>
jmp    11f2 <do_phone_number_letters+0xc2>
movl   $0x0,-0x1c(%rbp)
cmpl   $0x3,-0x1c(%rbp)
jge    11f2 <do_phone_number_letters+0xc2>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
sub    $0x30,%eax
mov    -0x1c(%rbp),%esi
movsbl %al,%edi
call   1030 <get_char_key@plt>
mov    %al,%cl
mov    -0x18(%rbp),%rax
mov    %cl,(%rax)
mov    -0x8(%rbp),%rdi
add    $0x1,%rdi
mov    -0xc(%rbp),%esi
mov    -0x18(%rbp),%rdx
add    $0x1,%rdx
call   1050 <do_phone_number_letters@plt>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x30,%eax
je     11da <do_phone_number_letters+0xaa>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x31,%eax
jne    11df <do_phone_number_letters+0xaf>
jmp    11f2 <do_phone_number_letters+0xc2>
jmp    11e4 <do_phone_number_letters+0xb4>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    117b <do_phone_number_letters+0x4b>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<do_phone_number_letters>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rdx,%rbx
mov    %esi,%r12d
cmpb   $0x0,(%rdx)
je     11ae <do_phone_number_letters+0x7e>
mov    %rdi,%rbp
lea    0x1(%rdi),%r15
lea    0x1(%rbx),%r14
mov    (%rdi),%al
add    $0xd0,%al
movsbl %al,%edi
xor    %esi,%esi
call   1030 <get_char_key@plt>
mov    %al,(%rbx)
mov    %r15,%rdi
mov    %r12d,%esi
mov    %r14,%rdx
call   1050 <do_phone_number_letters@plt>
mov    0x0(%rbp),%al
mov    %eax,%ecx
and    $0xfe,%cl
cmp    $0x30,%cl
je     11a5 <do_phone_number_letters+0x75>
add    $0xd0,%al
movsbl %al,%edi
mov    $0x1,%esi
call   1030 <get_char_key@plt>
mov    %al,(%rbx)
mov    %r15,%rdi
mov    %r12d,%esi
mov    %r14,%rdx
call   1050 <do_phone_number_letters@plt>
mov    0x0(%rbp),%al
mov    %eax,%ecx
and    $0xfe,%cl
cmp    $0x30,%cl
jne    11cb <do_phone_number_letters+0x9b>
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
movslq %r12d,%rax
sub    %rax,%rbx
lea    0xe45(%rip),%rdi
mov    %rbx,%rsi
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <printf@plt>
add    $0xd0,%al
movsbl %al,%edi
mov    $0x2,%esi
call   1030 <get_char_key@plt>
mov    %al,(%rbx)
mov    %r15,%rdi
mov    %r12d,%esi
mov    %r14,%rdx
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1050 <do_phone_number_letters@plt>

LLVM IR (-O0):
@.str = [4 x i8] c"%s\0A\00"
define void @do_phone_number_letters(i8* %0, i32 %1, i8* %2) {
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i32
store i8* %0, i8** %4
store i32 %1, i32* %5
store i8* %2, i8** %6
%8 = load i8*, i8** %6
%9 = load i8, i8* %8
%10 = sext i8 %9 to i32
%11 = icmp eq i32 %10, 0
br i1 %11, label %12, label %19
12: ; preds = %3
%13 = load i8*, i8** %6
%14 = load i32, i32* %5
%15 = sext i32 %14 to i64
%16 = sub i64 0, %15
%17 = getelementptr inbounds i8, i8* %13, i64 %16
%18 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %17)
br label %55
19: ; preds = %3
store i32 0, i32* %7
br label %20
20: ; preds = %52, %19
%21 = load i32, i32* %7
%22 = icmp slt i32 %21, 3
br i1 %22, label %23, label %55
23: ; preds = %20
%24 = load i8*, i8** %4
%25 = getelementptr inbounds i8, i8* %24, i64 0
%26 = load i8, i8* %25
%27 = sext i8 %26 to i32
%28 = sub nsw i32 %27, 48
%29 = trunc i32 %28 to i8
%30 = load i32, i32* %7
%31 = call signext i8 @get_char_key(i8 signext %29, i32 %30)
%32 = load i8*, i8** %6
%33 = getelementptr inbounds i8, i8* %32, i64 0
store i8 %31, i8* %33
%34 = load i8*, i8** %4
%35 = getelementptr inbounds i8, i8* %34, i64 1
%36 = load i32, i32* %5
%37 = load i8*, i8** %6
%38 = getelementptr inbounds i8, i8* %37, i64 1
%39 = load i8*, i8** %4
%40 = getelementptr inbounds i8, i8* %39, i64 0
%41 = load i8, i8* %40
%42 = sext i8 %41 to i32
%43 = icmp eq i32 %42, 48
br i1 %43, label %50, label %44
44: ; preds = %23
%45 = load i8*, i8** %4
%46 = getelementptr inbounds i8, i8* %45, i64 0
%47 = load i8, i8* %46
%48 = sext i8 %47 to i32
%49 = icmp eq i32 %48, 49
br i1 %49, label %50, label %51
50: ; preds = %44, %23
br label %55
51: ; preds = %44
br label %52
52: ; preds = %51
%53 = load i32, i32* %7
%54 = add nsw i32 %53, 1
store i32 %54, i32* %7
br label %20
55: ; preds = %12, %50, %20
ret void
}

LLVM IR (-O2):
@.str = [4 x i8] c"%s\0A\00"
define void @do_phone_number_letters(i8* nocapture %0, i32 %1, i8* %2) {
%4 = load i8, i8* %2
%5 = icmp eq i8 %4, 0
br i1 %5, label %15, label %6
6: ; preds = %3
%7 = getelementptr inbounds i8, i8* %0, i64 1
%8 = getelementptr inbounds i8, i8* %2, i64 1
%9 = load i8, i8* %0
%10 = add i8 %9, -48
%11 = tail call signext i8 @get_char_key(i8 signext %10, i32 0)
store i8 %11, i8* %2
tail call void @do_phone_number_letters(i8* %7, i32 %1, i8* %8)
%12 = load i8, i8* %0
%13 = and i8 %12, -2
%14 = icmp eq i8 %13, 48
br i1 %14, label %29, label %20
15: ; preds = %3
%16 = sext i32 %1 to i64
%17 = sub nsw i64 0, %16
%18 = getelementptr inbounds i8, i8* %2, i64 %17
%19 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %18)
br label %29
20: ; preds = %6
%21 = add i8 %12, -48
%22 = tail call signext i8 @get_char_key(i8 signext %21, i32 1)
store i8 %22, i8* %2
tail call void @do_phone_number_letters(i8* %7, i32 %1, i8* %8)
%23 = load i8, i8* %0
%24 = and i8 %23, -2
%25 = icmp eq i8 %24, 48
br i1 %25, label %29, label %26
26: ; preds = %20
%27 = add i8 %23, -48
%28 = tail call signext i8 @get_char_key(i8 signext %27, i32 2)
store i8 %28, i8* %2
tail call void @do_phone_number_letters(i8* %7, i32 %1, i8* %8)
br label %29
29: ; preds = %26, %6, %20, %15
ret void
}