#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 */
int strlen(char const *);
unsigned char IsWithinAlphabet(char *input, int size, const char *alphabet) {
  int i, j;
  for (i = 0; i < size; i++) {
    char curChar = input[i];
    unsigned char foundIt = 0;
    for (j = 0; j < strlen(alphabet); j++) {
      if (curChar == alphabet[j]) {
        foundIt = 1;
        break;
      }
    }
    if (!foundIt) {
      return 0;
    }
  }
  return 1;
}


x86 assembly (clang, -O0):
<IsWithinAlphabet>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %rdx,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    11c5 <IsWithinAlphabet+0xb5>
mov    -0x10(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    (%rax,%rcx,1),%al
mov    %al,-0x29(%rbp)
movb   $0x0,-0x2a(%rbp)
movl   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%eax
mov    %eax,-0x30(%rbp)
mov    -0x20(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x30(%rbp),%eax
cmp    %ecx,%eax
jge    119f <IsWithinAlphabet+0x8f>
movsbl -0x29(%rbp),%eax
mov    -0x20(%rbp),%rcx
movslq -0x28(%rbp),%rdx
movsbl (%rcx,%rdx,1),%ecx
cmp    %ecx,%eax
jne    118c <IsWithinAlphabet+0x7c>
movb   $0x1,-0x2a(%rbp)
jmp    119f <IsWithinAlphabet+0x8f>
jmp    1191 <IsWithinAlphabet+0x81>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    114f <IsWithinAlphabet+0x3f>
cmpb   $0x0,-0x2a(%rbp)
jne    11b2 <IsWithinAlphabet+0xa2>
movb   $0x0,-0x1(%rbp)
jmp    11c9 <IsWithinAlphabet+0xb9>
jmp    11b7 <IsWithinAlphabet+0xa7>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    112a <IsWithinAlphabet+0x1a>
movb   $0x1,-0x1(%rbp)
movzbl -0x1(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<IsWithinAlphabet>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    $0x1,%r14b
test   %esi,%esi
jle    117f <IsWithinAlphabet+0x6f>
mov    %rdx,%rbx
mov    %rdi,%r12
mov    %esi,%eax
mov    %rax,(%rsp)
xor    %ebp,%ebp
mov    (%r12,%rbp,1),%r13b
mov    %rbx,%rdi
call   1030 <strlen@plt>
test   %eax,%eax
jle    117c <IsWithinAlphabet+0x6c>
xor    %r15d,%r15d
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
cmp    (%rbx,%r15,1),%r13b
je     1170 <IsWithinAlphabet+0x60>
add    $0x1,%r15
mov    %rbx,%rdi
call   1030 <strlen@plt>
cltq
cmp    %rax,%r15
jl     1150 <IsWithinAlphabet+0x40>
jmp    117c <IsWithinAlphabet+0x6c>
nopl   0x0(%rax,%rax,1)
add    $0x1,%rbp
cmp    (%rsp),%rbp
jne    1130 <IsWithinAlphabet+0x20>
jmp    117f <IsWithinAlphabet+0x6f>
xor    %r14d,%r14d
mov    %r14d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define zeroext i8 @IsWithinAlphabet(i8* %0, i32 %1, i8* %2) {
%4 = alloca i8
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i32
%9 = alloca i32
%10 = alloca i8
%11 = alloca i8
store i8* %0, i8** %5
store i32 %1, i32* %6
store i8* %2, i8** %7
store i32 0, i32* %8
br label %12
12: ; preds = %47, %3
%13 = load i32, i32* %8
%14 = load i32, i32* %6
%15 = icmp slt i32 %13, %14
br i1 %15, label %16, label %50
16: ; preds = %12
%17 = load i8*, i8** %5
%18 = load i32, i32* %8
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds i8, i8* %17, i64 %19
%21 = load i8, i8* %20
store i8 %21, i8* %10
store i8 0, i8* %11
store i32 0, i32* %9
br label %22
22: ; preds = %39, %16
%23 = load i32, i32* %9
%24 = load i8*, i8** %7
%25 = call i32 @strlen(i8* %24)
%26 = icmp slt i32 %23, %25
br i1 %26, label %27, label %42
27: ; preds = %22
%28 = load i8, i8* %10
%29 = sext i8 %28 to i32
%30 = load i8*, i8** %7
%31 = load i32, i32* %9
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds i8, i8* %30, i64 %32
%34 = load i8, i8* %33
%35 = sext i8 %34 to i32
%36 = icmp eq i32 %29, %35
br i1 %36, label %37, label %38
37: ; preds = %27
store i8 1, i8* %11
br label %42
38: ; preds = %27
br label %39
39: ; preds = %38
%40 = load i32, i32* %9
%41 = add nsw i32 %40, 1
store i32 %41, i32* %9
br label %22
42: ; preds = %37, %22
%43 = load i8, i8* %11
%44 = icmp ne i8 %43, 0
br i1 %44, label %46, label %45
45: ; preds = %42
store i8 0, i8* %4
br label %51
46: ; preds = %42
br label %47
47: ; preds = %46
%48 = load i32, i32* %8
%49 = add nsw i32 %48, 1
store i32 %49, i32* %8
br label %12
50: ; preds = %12
store i8 1, i8* %4
br label %51
51: ; preds = %50, %45
%52 = load i8, i8* %4
ret i8 %52
}

LLVM IR (-O2):
define zeroext i8 @IsWithinAlphabet(i8* nocapture %0, i32 %1, i8* %2) {
%4 = icmp sgt i32 %1, 0
br i1 %4, label %5, label %26
5: ; preds = %3
%6 = zext i32 %1 to i64
br label %7
7: ; preds = %5, %23
%8 = phi i64 [ 0, %5 ], [ %24, %23 ]
%9 = getelementptr inbounds i8, i8* %0, i64 %8
%10 = load i8, i8* %9
%11 = tail call i32 @strlen(i8* %2)
%12 = icmp sgt i32 %11, 0
br i1 %12, label %17, label %26
13: ; preds = %17
%14 = tail call i32 @strlen(i8* %2)
%15 = sext i32 %14 to i64
%16 = icmp slt i64 %22, %15
br i1 %16, label %17, label %26
17: ; preds = %7, %13
%18 = phi i64 [ %22, %13 ], [ 0, %7 ]
%19 = getelementptr inbounds i8, i8* %2, i64 %18
%20 = load i8, i8* %19
%21 = icmp eq i8 %10, %20
%22 = add nuw nsw i64 %18, 1
br i1 %21, label %23, label %13
23: ; preds = %17
%24 = add nuw nsw i64 %8, 1
%25 = icmp eq i64 %24, %6
br i1 %25, label %26, label %7
26: ; preds = %23, %7, %13, %3
%27 = phi i8 [ 1, %3 ], [ 0, %13 ], [ 0, %7 ], [ 1, %23 ]
ret i8 %27
}