int typecmp(str)
register char *str;
{
  static char *type[] = {"exe", "lib", "obj", "odl", "olb", "pmd", "stb", "sys",
                         "tsk", "dir", "upd", "tlo", "tlb", "hlb", ""};
  register int i;
  i = -1;
  while (*type[++i])
    if (strncmp(str, type[i], 3) == 0)
      return (0);
  return (1);
}


x86 assembly (clang, -O0):
<typecmp>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
movl   $0xffffffff,-0x14(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
movslq %eax,%rcx
lea    0x2efa(%rip),%rax
mov    (%rax,%rcx,8),%rax
cmpb   $0x0,(%rax)
je     117a <typecmp+0x6a>
mov    -0x10(%rbp),%rdi
movslq -0x14(%rbp),%rcx
lea    0x2ede(%rip),%rax
mov    (%rax,%rcx,8),%rsi
mov    $0x3,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%eax
jne    1175 <typecmp+0x65>
movl   $0x0,-0x4(%rbp)
jmp    1181 <typecmp+0x71>
jmp    1123 <typecmp+0x13>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<typecmp>:
push   %rbp
push   %rbx
push   %rax
mov    %rdi,%rbx
lea    0xee3(%rip),%rsi
mov    $0x3,%edx
call   1030 <strncmp@plt>
xor    %ebp,%ebp
test   %eax,%eax
je     1289 <typecmp+0x179>
lea    0xecc(%rip),%rsi
mov    $0x3,%edx
mov    %rbx,%rdi
call   1030 <strncmp@plt>
test   %eax,%eax
je     1289 <typecmp+0x179>
lea    0xeb4(%rip),%rsi
mov    $0x3,%edx
mov    %rbx,%rdi
call   1030 <strncmp@plt>
test   %eax,%eax
je     1289 <typecmp+0x179>
lea    0xe9c(%rip),%rsi
mov    $0x3,%edx
mov    %rbx,%rdi
call   1030 <strncmp@plt>
test   %eax,%eax
je     1289 <typecmp+0x179>
lea    0xe84(%rip),%rsi
mov    $0x3,%edx
mov    %rbx,%rdi
call   1030 <strncmp@plt>
test   %eax,%eax
je     1289 <typecmp+0x179>
lea    0xe6c(%rip),%rsi
mov    $0x3,%edx
mov    %rbx,%rdi
call   1030 <strncmp@plt>
test   %eax,%eax
je     1289 <typecmp+0x179>
lea    0xe54(%rip),%rsi
mov    $0x3,%edx
mov    %rbx,%rdi
call   1030 <strncmp@plt>
test   %eax,%eax
je     1289 <typecmp+0x179>
lea    0xe3c(%rip),%rsi
mov    $0x3,%edx
mov    %rbx,%rdi
call   1030 <strncmp@plt>
test   %eax,%eax
je     1289 <typecmp+0x179>
lea    0xe24(%rip),%rsi
mov    $0x3,%edx
mov    %rbx,%rdi
call   1030 <strncmp@plt>
test   %eax,%eax
je     1289 <typecmp+0x179>
lea    0xe10(%rip),%rsi
mov    $0x3,%edx
mov    %rbx,%rdi
call   1030 <strncmp@plt>
test   %eax,%eax
je     1289 <typecmp+0x179>
lea    0xdfc(%rip),%rsi
mov    $0x3,%edx
mov    %rbx,%rdi
call   1030 <strncmp@plt>
test   %eax,%eax
je     1289 <typecmp+0x179>
lea    0xde8(%rip),%rsi
mov    $0x3,%edx
mov    %rbx,%rdi
call   1030 <strncmp@plt>
test   %eax,%eax
je     1289 <typecmp+0x179>
lea    0xdd4(%rip),%rsi
mov    $0x3,%edx
mov    %rbx,%rdi
call   1030 <strncmp@plt>
test   %eax,%eax
je     1289 <typecmp+0x179>
lea    0xdc0(%rip),%rsi
mov    $0x3,%edx
mov    %rbx,%rdi
call   1030 <strncmp@plt>
xor    %ebp,%ebp
test   %eax,%eax
setne  %bpl
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@typecmp.type = internal global [15 x i8*] [i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.8, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.9, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.10, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.11, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.12, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.13, i32 0, i32 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.14, i32 0, i32 0)]
@.str = [4 x i8] c"exe\00"
@.str.1 = [4 x i8] c"lib\00"
@.str.2 = [4 x i8] c"obj\00"
@.str.3 = [4 x i8] c"odl\00"
@.str.4 = [4 x i8] c"olb\00"
@.str.5 = [4 x i8] c"pmd\00"
@.str.6 = [4 x i8] c"stb\00"
@.str.7 = [4 x i8] c"sys\00"
@.str.8 = [4 x i8] c"tsk\00"
@.str.9 = [4 x i8] c"dir\00"
@.str.10 = [4 x i8] c"upd\00"
@.str.11 = [4 x i8] c"tlo\00"
@.str.12 = [4 x i8] c"tlb\00"
@.str.13 = [4 x i8] c"hlb\00"
@.str.14 = [1 x i8] zeroinitializer
define i32 @typecmp(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i32
store i8* %0, i8** %3
store i32 -1, i32* %4
br label %5
5: ; preds = %22, %1
%6 = load i32, i32* %4
%7 = add nsw i32 %6, 1
store i32 %7, i32* %4
%8 = sext i32 %7 to i64
%9 = getelementptr inbounds [15 x i8*], [15 x i8*]* @typecmp.type, i64 0, i64 %8
%10 = load i8*, i8** %9
%11 = load i8, i8* %10
%12 = icmp ne i8 %11, 0
br i1 %12, label %13, label %23
13: ; preds = %5
%14 = load i8*, i8** %3
%15 = load i32, i32* %4
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds [15 x i8*], [15 x i8*]* @typecmp.type, i64 0, i64 %16
%18 = load i8*, i8** %17
%19 = call i32 @strncmp(i8* %14, i8* %18, i64 3)
%20 = icmp eq i32 %19, 0
br i1 %20, label %21, label %22
21: ; preds = %13
store i32 0, i32* %2
br label %24
22: ; preds = %13
br label %5
23: ; preds = %5
store i32 1, i32* %2
br label %24
24: ; preds = %23, %21
%25 = load i32, i32* %2
ret i32 %25
}

LLVM IR (-O2):
@.str = [4 x i8] c"exe\00"
@.str.1 = [4 x i8] c"lib\00"
@.str.2 = [4 x i8] c"obj\00"
@.str.3 = [4 x i8] c"odl\00"
@.str.4 = [4 x i8] c"olb\00"
@.str.5 = [4 x i8] c"pmd\00"
@.str.6 = [4 x i8] c"stb\00"
@.str.7 = [4 x i8] c"sys\00"
@.str.8 = [4 x i8] c"tsk\00"
@.str.9 = [4 x i8] c"dir\00"
@.str.10 = [4 x i8] c"upd\00"
@.str.11 = [4 x i8] c"tlo\00"
@.str.12 = [4 x i8] c"tlb\00"
@.str.13 = [4 x i8] c"hlb\00"
define i32 @typecmp(i8* nocapture %0) {
%2 = tail call i32 @strncmp(i8* dereferenceable(1) %0, i8* dereferenceable(4) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i64 3)
%3 = icmp eq i32 %2, 0
br i1 %3, label %44, label %4
4: ; preds = %1
%5 = tail call i32 @strncmp(i8* dereferenceable(1) %0, i8* dereferenceable(4) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i64 3)
%6 = icmp eq i32 %5, 0
br i1 %6, label %44, label %7
7: ; preds = %4
%8 = tail call i32 @strncmp(i8* dereferenceable(1) %0, i8* dereferenceable(4) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i64 3)
%9 = icmp eq i32 %8, 0
br i1 %9, label %44, label %10
10: ; preds = %7
%11 = tail call i32 @strncmp(i8* dereferenceable(1) %0, i8* dereferenceable(4) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i64 3)
%12 = icmp eq i32 %11, 0
br i1 %12, label %44, label %13
13: ; preds = %10
%14 = tail call i32 @strncmp(i8* dereferenceable(1) %0, i8* dereferenceable(4) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i64 3)
%15 = icmp eq i32 %14, 0
br i1 %15, label %44, label %16
16: ; preds = %13
%17 = tail call i32 @strncmp(i8* dereferenceable(1) %0, i8* dereferenceable(4) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i64 3)
%18 = icmp eq i32 %17, 0
br i1 %18, label %44, label %19
19: ; preds = %16
%20 = tail call i32 @strncmp(i8* dereferenceable(1) %0, i8* dereferenceable(4) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), i64 3)
%21 = icmp eq i32 %20, 0
br i1 %21, label %44, label %22
22: ; preds = %19
%23 = tail call i32 @strncmp(i8* dereferenceable(1) %0, i8* dereferenceable(4) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0), i64 3)
%24 = icmp eq i32 %23, 0
br i1 %24, label %44, label %25
25: ; preds = %22
%26 = tail call i32 @strncmp(i8* dereferenceable(1) %0, i8* dereferenceable(4) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.8, i64 0, i64 0), i64 3)
%27 = icmp eq i32 %26, 0
br i1 %27, label %44, label %28
28: ; preds = %25
%29 = tail call i32 @strncmp(i8* dereferenceable(1) %0, i8* dereferenceable(4) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.9, i64 0, i64 0), i64 3)
%30 = icmp eq i32 %29, 0
br i1 %30, label %44, label %31
31: ; preds = %28
%32 = tail call i32 @strncmp(i8* dereferenceable(1) %0, i8* dereferenceable(4) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.10, i64 0, i64 0), i64 3)
%33 = icmp eq i32 %32, 0
br i1 %33, label %44, label %34
34: ; preds = %31
%35 = tail call i32 @strncmp(i8* dereferenceable(1) %0, i8* dereferenceable(4) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.11, i64 0, i64 0), i64 3)
%36 = icmp eq i32 %35, 0
br i1 %36, label %44, label %37
37: ; preds = %34
%38 = tail call i32 @strncmp(i8* dereferenceable(1) %0, i8* dereferenceable(4) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.12, i64 0, i64 0), i64 3)
%39 = icmp eq i32 %38, 0
br i1 %39, label %44, label %40
40: ; preds = %37
%41 = tail call i32 @strncmp(i8* dereferenceable(1) %0, i8* dereferenceable(4) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.13, i64 0, i64 0), i64 3)
%42 = icmp ne i32 %41, 0
%43 = zext i1 %42 to i32
br label %44
44: ; preds = %40, %37, %34, %31, %28, %25, %22, %19, %16, %13, %10, %7, %4, %1
%45 = phi i32 [ 0, %1 ], [ 0, %4 ], [ 0, %7 ], [ 0, %10 ], [ 0, %13 ], [ 0, %16 ], [ 0, %19 ], [ 0, %22 ], [ 0, %25 ], [ 0, %28 ], [ 0, %31 ], [ 0, %34 ], [ 0, %37 ], [ %43, %40 ]
ret i32 %45
}