#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 */
scalar_t__ isalnum(char);
scalar_t__ strcmp(char *, char *);
char tolower(char);
int check_command(char *text) {
  char command[12];
  int length;
  if (*text == 0)
    return 0;
  length = 0;
  while (length < 10 && isalnum(*text)) {
    command[length] = tolower(*text);
    length++;
    text++;
  }
  command[length] = 0;
  if (strcmp(command, "key") == 0)
    return 1;
  return 0;
}


x86 assembly (clang, -O0):
<check_command>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
jne    1158 <check_command+0x28>
movl   $0x0,-0x4(%rbp)
jmp    11fa <check_command+0xca>
movl   $0x0,-0x20(%rbp)
xor    %eax,%eax
cmpl   $0xa,-0x20(%rbp)
mov    %al,-0x21(%rbp)
jge    1184 <check_command+0x54>
mov    -0x10(%rbp),%rax
movsbl (%rax),%edi
call   1030 <isalnum@plt>
cmp    $0x0,%rax
setne  %al
mov    %al,-0x21(%rbp)
mov    -0x21(%rbp),%al
test   $0x1,%al
jne    1194 <check_command+0x64>
jmp    11c4 <check_command+0x94>
mov    -0x10(%rbp),%rax
movsbl (%rax),%edi
call   1050 <tolower@plt>
mov    %al,%cl
movslq -0x20(%rbp),%rax
mov    %cl,-0x1c(%rbp,%rax,1)
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    115f <check_command+0x2f>
movslq -0x20(%rbp),%rax
movb   $0x0,-0x1c(%rbp,%rax,1)
lea    -0x1c(%rbp),%rdi
lea    0xe28(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    11f3 <check_command+0xc3>
movl   $0x1,-0x4(%rbp)
jmp    11fa <check_command+0xca>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<check_command>:
push   %rbx
sub    $0x10,%rsp
mov    (%rdi),%al
test   %al,%al
je     1271 <check_command+0x141>
mov    %rdi,%rbx
movsbl %al,%edi
call   1030 <isalnum@plt>
test   %rax,%rax
je     1275 <check_command+0x145>
movsbl (%rbx),%edi
call   1050 <tolower@plt>
mov    %al,0x4(%rsp)
movsbl 0x1(%rbx),%edi
call   1030 <isalnum@plt>
test   %rax,%rax
je     1279 <check_command+0x149>
movsbl 0x1(%rbx),%edi
call   1050 <tolower@plt>
mov    %al,0x5(%rsp)
movsbl 0x2(%rbx),%edi
call   1030 <isalnum@plt>
test   %rax,%rax
je     1280 <check_command+0x150>
movsbl 0x2(%rbx),%edi
call   1050 <tolower@plt>
mov    %al,0x6(%rsp)
movsbl 0x3(%rbx),%edi
call   1030 <isalnum@plt>
test   %rax,%rax
je     1287 <check_command+0x157>
movsbl 0x3(%rbx),%edi
call   1050 <tolower@plt>
mov    %al,0x7(%rsp)
movsbl 0x4(%rbx),%edi
call   1030 <isalnum@plt>
test   %rax,%rax
je     128e <check_command+0x15e>
movsbl 0x4(%rbx),%edi
call   1050 <tolower@plt>
mov    %al,0x8(%rsp)
movsbl 0x5(%rbx),%edi
call   1030 <isalnum@plt>
test   %rax,%rax
je     1295 <check_command+0x165>
movsbl 0x5(%rbx),%edi
call   1050 <tolower@plt>
mov    %al,0x9(%rsp)
movsbl 0x6(%rbx),%edi
call   1030 <isalnum@plt>
test   %rax,%rax
je     129c <check_command+0x16c>
movsbl 0x6(%rbx),%edi
call   1050 <tolower@plt>
mov    %al,0xa(%rsp)
movsbl 0x7(%rbx),%edi
call   1030 <isalnum@plt>
test   %rax,%rax
je     12a3 <check_command+0x173>
movsbl 0x7(%rbx),%edi
call   1050 <tolower@plt>
mov    %al,0xb(%rsp)
movsbl 0x8(%rbx),%edi
call   1030 <isalnum@plt>
test   %rax,%rax
je     12aa <check_command+0x17a>
movsbl 0x8(%rbx),%edi
call   1050 <tolower@plt>
mov    %al,0xc(%rsp)
movsbl 0x9(%rbx),%edi
call   1030 <isalnum@plt>
test   %rax,%rax
je     12b1 <check_command+0x181>
movsbl 0x9(%rbx),%edi
call   1050 <tolower@plt>
mov    %al,0xd(%rsp)
mov    $0xa,%eax
jmp    12b6 <check_command+0x186>
xor    %eax,%eax
jmp    12d7 <check_command+0x1a7>
xor    %eax,%eax
jmp    12b6 <check_command+0x186>
mov    $0x1,%eax
jmp    12b6 <check_command+0x186>
mov    $0x2,%eax
jmp    12b6 <check_command+0x186>
mov    $0x3,%eax
jmp    12b6 <check_command+0x186>
mov    $0x4,%eax
jmp    12b6 <check_command+0x186>
mov    $0x5,%eax
jmp    12b6 <check_command+0x186>
mov    $0x6,%eax
jmp    12b6 <check_command+0x186>
mov    $0x7,%eax
jmp    12b6 <check_command+0x186>
mov    $0x8,%eax
jmp    12b6 <check_command+0x186>
mov    $0x9,%eax
movb   $0x0,0x4(%rsp,%rax,1)
lea    0xd3e(%rip),%rsi
lea    0x4(%rsp),%rdi
call   1040 <strcmp@plt>
mov    %rax,%rcx
xor    %eax,%eax
test   %rcx,%rcx
sete   %al
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [4 x i8] c"key\00"
define i32 @check_command(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca [12 x i8]
%5 = alloca i32
store i8* %0, i8** %3
%6 = load i8*, i8** %3
%7 = load i8, i8* %6
%8 = sext i8 %7 to i32
%9 = icmp eq i32 %8, 0
br i1 %9, label %10, label %11
10: ; preds = %1
store i32 0, i32* %2
br label %42
11: ; preds = %1
store i32 0, i32* %5
br label %12
12: ; preds = %22, %11
%13 = load i32, i32* %5
%14 = icmp slt i32 %13, 10
br i1 %14, label %15, label %20
15: ; preds = %12
%16 = load i8*, i8** %3
%17 = load i8, i8* %16
%18 = call i64 @isalnum(i8 signext %17)
%19 = icmp ne i64 %18, 0
br label %20
20: ; preds = %15, %12
%21 = phi i1 [ false, %12 ], [ %19, %15 ]
br i1 %21, label %22, label %33
22: ; preds = %20
%23 = load i8*, i8** %3
%24 = load i8, i8* %23
%25 = call signext i8 @tolower(i8 signext %24)
%26 = load i32, i32* %5
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds [12 x i8], [12 x i8]* %4, i64 0, i64 %27
store i8 %25, i8* %28
%29 = load i32, i32* %5
%30 = add nsw i32 %29, 1
store i32 %30, i32* %5
%31 = load i8*, i8** %3
%32 = getelementptr inbounds i8, i8* %31, i32 1
store i8* %32, i8** %3
br label %12
33: ; preds = %20
%34 = load i32, i32* %5
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds [12 x i8], [12 x i8]* %4, i64 0, i64 %35
store i8 0, i8* %36
%37 = getelementptr inbounds [12 x i8], [12 x i8]* %4, i64 0, i64 0
%38 = call i64 @strcmp(i8* %37, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%39 = icmp eq i64 %38, 0
br i1 %39, label %40, label %41
40: ; preds = %33
store i32 1, i32* %2
br label %42
41: ; preds = %33
store i32 0, i32* %2
br label %42
42: ; preds = %41, %40, %10
%43 = load i32, i32* %2
ret i32 %43
}

LLVM IR (-O2):
@.str = [4 x i8] c"key\00"
define i32 @check_command(i8* nocapture %0) {
%2 = alloca [12 x i8]
%3 = getelementptr inbounds [12 x i8], [12 x i8]* %2, i64 0, i64 0
%4 = load i8, i8* %0
%5 = icmp eq i8 %4, 0
br i1 %5, label %90, label %6
6: ; preds = %1
%7 = tail call i64 @isalnum(i8 signext %4)
%8 = icmp eq i64 %7, 0
br i1 %8, label %84, label %9
9: ; preds = %6
%10 = load i8, i8* %0
%11 = tail call signext i8 @tolower(i8 signext %10)
store i8 %11, i8* %3
%12 = getelementptr inbounds i8, i8* %0, i64 1
%13 = load i8, i8* %12
%14 = tail call i64 @isalnum(i8 signext %13)
%15 = icmp eq i64 %14, 0
br i1 %15, label %84, label %16
16: ; preds = %9
%17 = load i8, i8* %12
%18 = tail call signext i8 @tolower(i8 signext %17)
%19 = getelementptr inbounds [12 x i8], [12 x i8]* %2, i64 0, i64 1
store i8 %18, i8* %19
%20 = getelementptr inbounds i8, i8* %0, i64 2
%21 = load i8, i8* %20
%22 = tail call i64 @isalnum(i8 signext %21)
%23 = icmp eq i64 %22, 0
br i1 %23, label %84, label %24
24: ; preds = %16
%25 = load i8, i8* %20
%26 = tail call signext i8 @tolower(i8 signext %25)
%27 = getelementptr inbounds [12 x i8], [12 x i8]* %2, i64 0, i64 2
store i8 %26, i8* %27
%28 = getelementptr inbounds i8, i8* %0, i64 3
%29 = load i8, i8* %28
%30 = tail call i64 @isalnum(i8 signext %29)
%31 = icmp eq i64 %30, 0
br i1 %31, label %84, label %32
32: ; preds = %24
%33 = load i8, i8* %28
%34 = tail call signext i8 @tolower(i8 signext %33)
%35 = getelementptr inbounds [12 x i8], [12 x i8]* %2, i64 0, i64 3
store i8 %34, i8* %35
%36 = getelementptr inbounds i8, i8* %0, i64 4
%37 = load i8, i8* %36
%38 = tail call i64 @isalnum(i8 signext %37)
%39 = icmp eq i64 %38, 0
br i1 %39, label %84, label %40
40: ; preds = %32
%41 = load i8, i8* %36
%42 = tail call signext i8 @tolower(i8 signext %41)
%43 = getelementptr inbounds [12 x i8], [12 x i8]* %2, i64 0, i64 4
store i8 %42, i8* %43
%44 = getelementptr inbounds i8, i8* %0, i64 5
%45 = load i8, i8* %44
%46 = tail call i64 @isalnum(i8 signext %45)
%47 = icmp eq i64 %46, 0
br i1 %47, label %84, label %48
48: ; preds = %40
%49 = load i8, i8* %44
%50 = tail call signext i8 @tolower(i8 signext %49)
%51 = getelementptr inbounds [12 x i8], [12 x i8]* %2, i64 0, i64 5
store i8 %50, i8* %51
%52 = getelementptr inbounds i8, i8* %0, i64 6
%53 = load i8, i8* %52
%54 = tail call i64 @isalnum(i8 signext %53)
%55 = icmp eq i64 %54, 0
br i1 %55, label %84, label %56
56: ; preds = %48
%57 = load i8, i8* %52
%58 = tail call signext i8 @tolower(i8 signext %57)
%59 = getelementptr inbounds [12 x i8], [12 x i8]* %2, i64 0, i64 6
store i8 %58, i8* %59
%60 = getelementptr inbounds i8, i8* %0, i64 7
%61 = load i8, i8* %60
%62 = tail call i64 @isalnum(i8 signext %61)
%63 = icmp eq i64 %62, 0
br i1 %63, label %84, label %64
64: ; preds = %56
%65 = load i8, i8* %60
%66 = tail call signext i8 @tolower(i8 signext %65)
%67 = getelementptr inbounds [12 x i8], [12 x i8]* %2, i64 0, i64 7
store i8 %66, i8* %67
%68 = getelementptr inbounds i8, i8* %0, i64 8
%69 = load i8, i8* %68
%70 = tail call i64 @isalnum(i8 signext %69)
%71 = icmp eq i64 %70, 0
br i1 %71, label %84, label %72
72: ; preds = %64
%73 = load i8, i8* %68
%74 = tail call signext i8 @tolower(i8 signext %73)
%75 = getelementptr inbounds [12 x i8], [12 x i8]* %2, i64 0, i64 8
store i8 %74, i8* %75
%76 = getelementptr inbounds i8, i8* %0, i64 9
%77 = load i8, i8* %76
%78 = tail call i64 @isalnum(i8 signext %77)
%79 = icmp eq i64 %78, 0
br i1 %79, label %84, label %80
80: ; preds = %72
%81 = load i8, i8* %76
%82 = tail call signext i8 @tolower(i8 signext %81)
%83 = getelementptr inbounds [12 x i8], [12 x i8]* %2, i64 0, i64 9
store i8 %82, i8* %83
br label %84
84: ; preds = %80, %72, %64, %56, %48, %40, %32, %24, %16, %9, %6
%85 = phi i64 [ 0, %6 ], [ 1, %9 ], [ 2, %16 ], [ 3, %24 ], [ 4, %32 ], [ 5, %40 ], [ 6, %48 ], [ 7, %56 ], [ 8, %64 ], [ 9, %72 ], [ 10, %80 ]
%86 = getelementptr inbounds [12 x i8], [12 x i8]* %2, i64 0, i64 %85
store i8 0, i8* %86
%87 = call i64 @strcmp(i8* %3, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%88 = icmp eq i64 %87, 0
%89 = zext i1 %88 to i32
br label %90
90: ; preds = %84, %1
%91 = phi i32 [ 0, %1 ], [ %89, %84 ]
ret i32 %91
}