#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 table_lookup(char, int);
int number_matches_letter(char no, char letter) {
  if (letter == '\0')
    return 0;
  if (letter == table_lookup(no, 1) || letter == table_lookup(no, 2) ||
      letter == table_lookup(no, 3) || letter == table_lookup(no, 4))
    return 1;
  return 0;
}


x86 assembly (clang, -O0):
<number_matches_letter>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %sil,%al
mov    %dil,%cl
mov    %cl,-0x5(%rbp)
mov    %al,-0x6(%rbp)
movsbl -0x6(%rbp),%eax
cmp    $0x0,%eax
jne    113d <number_matches_letter+0x2d>
movl   $0x0,-0x4(%rbp)
jmp    11e4 <number_matches_letter+0xd4>
movsbl -0x6(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    $0x1,%esi
movsbl -0x5(%rbp),%edi
call   1030 <table_lookup@plt>
mov    %al,%cl
mov    -0xc(%rbp),%eax
movsbl %cl,%ecx
cmp    %ecx,%eax
je     11d1 <number_matches_letter+0xc1>
movsbl -0x6(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    $0x2,%esi
movsbl -0x5(%rbp),%edi
call   1030 <table_lookup@plt>
mov    %al,%cl
mov    -0x10(%rbp),%eax
movsbl %cl,%ecx
cmp    %ecx,%eax
je     11d1 <number_matches_letter+0xc1>
movsbl -0x6(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    $0x3,%esi
movsbl -0x5(%rbp),%edi
call   1030 <table_lookup@plt>
mov    %al,%cl
mov    -0x14(%rbp),%eax
movsbl %cl,%ecx
cmp    %ecx,%eax
je     11d1 <number_matches_letter+0xc1>
movsbl -0x6(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    $0x4,%esi
movsbl -0x5(%rbp),%edi
call   1030 <table_lookup@plt>
mov    %al,%cl
mov    -0x18(%rbp),%eax
movsbl %cl,%ecx
cmp    %ecx,%eax
jne    11dd <number_matches_letter+0xcd>
movl   $0x1,-0x4(%rbp)
jmp    11e4 <number_matches_letter+0xd4>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<number_matches_letter>:
push   %rbp
push   %r14
push   %rbx
mov    %esi,%ebx
test   %bl,%bl
je     116d <number_matches_letter+0x5d>
movsbl %dil,%r14d
mov    $0x1,%ebp
mov    %r14d,%edi
mov    $0x1,%esi
call   1030 <table_lookup@plt>
cmp    %bl,%al
je     116f <number_matches_letter+0x5f>
mov    %r14d,%edi
mov    $0x2,%esi
call   1030 <table_lookup@plt>
cmp    %bl,%al
je     116f <number_matches_letter+0x5f>
mov    %r14d,%edi
mov    $0x3,%esi
call   1030 <table_lookup@plt>
cmp    %bl,%al
je     116f <number_matches_letter+0x5f>
mov    %r14d,%edi
mov    $0x4,%esi
call   1030 <table_lookup@plt>
xor    %ebp,%ebp
cmp    %bl,%al
sete   %bpl
jmp    116f <number_matches_letter+0x5f>
xor    %ebp,%ebp
mov    %ebp,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define i32 @number_matches_letter(i8 signext %0, i8 signext %1) {
%3 = alloca i32
%4 = alloca i8
%5 = alloca i8
store i8 %0, i8* %4
store i8 %1, i8* %5
%6 = load i8, i8* %5
%7 = sext i8 %6 to i32
%8 = icmp eq i32 %7, 0
br i1 %8, label %9, label %10
9: ; preds = %2
store i32 0, i32* %3
br label %40
10: ; preds = %2
%11 = load i8, i8* %5
%12 = sext i8 %11 to i32
%13 = load i8, i8* %4
%14 = call signext i8 @table_lookup(i8 signext %13, i32 1)
%15 = sext i8 %14 to i32
%16 = icmp eq i32 %12, %15
br i1 %16, label %38, label %17
17: ; preds = %10
%18 = load i8, i8* %5
%19 = sext i8 %18 to i32
%20 = load i8, i8* %4
%21 = call signext i8 @table_lookup(i8 signext %20, i32 2)
%22 = sext i8 %21 to i32
%23 = icmp eq i32 %19, %22
br i1 %23, label %38, label %24
24: ; preds = %17
%25 = load i8, i8* %5
%26 = sext i8 %25 to i32
%27 = load i8, i8* %4
%28 = call signext i8 @table_lookup(i8 signext %27, i32 3)
%29 = sext i8 %28 to i32
%30 = icmp eq i32 %26, %29
br i1 %30, label %38, label %31
31: ; preds = %24
%32 = load i8, i8* %5
%33 = sext i8 %32 to i32
%34 = load i8, i8* %4
%35 = call signext i8 @table_lookup(i8 signext %34, i32 4)
%36 = sext i8 %35 to i32
%37 = icmp eq i32 %33, %36
br i1 %37, label %38, label %39
38: ; preds = %31, %24, %17, %10
store i32 1, i32* %3
br label %40
39: ; preds = %31
store i32 0, i32* %3
br label %40
40: ; preds = %39, %38, %9
%41 = load i32, i32* %3
ret i32 %41
}

LLVM IR (-O2):
define i32 @number_matches_letter(i8 signext %0, i8 signext %1) {
%3 = icmp eq i8 %1, 0
br i1 %3, label %17, label %4
4: ; preds = %2
%5 = tail call signext i8 @table_lookup(i8 signext %0, i32 1)
%6 = icmp eq i8 %5, %1
br i1 %6, label %17, label %7
7: ; preds = %4
%8 = tail call signext i8 @table_lookup(i8 signext %0, i32 2)
%9 = icmp eq i8 %8, %1
br i1 %9, label %17, label %10
10: ; preds = %7
%11 = tail call signext i8 @table_lookup(i8 signext %0, i32 3)
%12 = icmp eq i8 %11, %1
br i1 %12, label %17, label %13
13: ; preds = %10
%14 = tail call signext i8 @table_lookup(i8 signext %0, i32 4)
%15 = icmp eq i8 %14, %1
%16 = zext i1 %15 to i32
br label %17
17: ; preds = %13, %4, %7, %10, %2
%18 = phi i32 [ 0, %2 ], [ 1, %10 ], [ 1, %7 ], [ 1, %4 ], [ %16, %13 ]
ret i32 %18
}