#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 */
size_t strlen(char const *);
scalar_t__ strncmp(char const *, char *, size_t);
int is_aim_key(const char *cur_str, char *key) {
  unsigned int i = 0;
  for (; cur_str[i] == ' '; i++)
    ;
  if (strlen(&cur_str[i]) < strlen(key))
    return -1;
  if (strncmp(&cur_str[i], key, strlen(key))) {
    return -1;
  }
  if (cur_str[i + strlen(key)] == ' ' || cur_str[i + strlen(key)] == '=')
    return 1;
  return -1;
}


x86 assembly (clang, -O0):
<is_aim_key>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x10(%rbp),%rax
mov    -0x1c(%rbp),%ecx
movsbl (%rax,%rcx,1),%eax
cmp    $0x20,%eax
jne    115e <is_aim_key+0x3e>
jmp    1150 <is_aim_key+0x30>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1137 <is_aim_key+0x17>
mov    -0x10(%rbp),%rdi
mov    -0x1c(%rbp),%eax
add    %rax,%rdi
call   1040 <strlen@plt>
mov    %rax,-0x28(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <strlen@plt>
mov    %rax,%rcx
mov    -0x28(%rbp),%rax
cmp    %rcx,%rax
jae    1196 <is_aim_key+0x76>
movl   $0xffffffff,-0x4(%rbp)
jmp    1254 <is_aim_key+0x134>
mov    -0x10(%rbp),%rax
mov    -0x1c(%rbp),%ecx
add    %rcx,%rax
mov    %rax,-0x38(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x38(%rbp),%rdi
mov    -0x30(%rbp),%rsi
mov    %rax,%rdx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
je     11db <is_aim_key+0xbb>
movl   $0xffffffff,-0x4(%rbp)
jmp    1254 <is_aim_key+0x134>
mov    -0x10(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    -0x1c(%rbp),%eax
mov    %rax,-0x48(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x48(%rbp),%rcx
mov    %rax,%rdx
mov    -0x40(%rbp),%rax
add    %rdx,%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x20,%eax
je     1241 <is_aim_key+0x121>
mov    -0x10(%rbp),%rax
mov    %rax,-0x50(%rbp)
mov    -0x1c(%rbp),%eax
mov    %rax,-0x58(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x58(%rbp),%rcx
mov    %rax,%rdx
mov    -0x50(%rbp),%rax
add    %rdx,%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x3d,%eax
jne    124d <is_aim_key+0x12d>
movl   $0x1,-0x4(%rbp)
jmp    1254 <is_aim_key+0x134>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<is_aim_key>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
mov    $0xffffffff,%eax
cs nopw 0x0(%rax,%rax,1)
add    $0x1,%eax
cmpb   $0x20,(%rbx,%rax,1)
je     1140 <is_aim_key+0x20>
mov    %eax,%r13d
lea    (%rbx,%r13,1),%r12
mov    %r12,%rdi
call   1040 <strlen@plt>
mov    %rax,%rbp
mov    %r14,%rdi
call   1040 <strlen@plt>
mov    $0xffffffff,%r15d
cmp    %rax,%rbp
jb     11a6 <is_aim_key+0x86>
mov    %r12,%rdi
mov    %r14,%rsi
mov    %rax,%rdx
call   1030 <strncmp@plt>
test   %rax,%rax
jne    11a6 <is_aim_key+0x86>
mov    %r14,%rdi
call   1040 <strlen@plt>
add    %r13,%rax
mov    (%rbx,%rax,1),%al
xor    %ecx,%ecx
cmp    $0x3d,%al
sete   %cl
cmp    $0x20,%al
lea    -0x1(%rcx,%rcx,1),%eax
mov    $0x1,%r15d
cmovne %eax,%r15d
mov    %r15d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define i32 @is_aim_key(i8* %0, i8* %1) {
br label %3
3: ; preds = %3, %2
%4 = phi i32 [ 0, %2 ], [ %9, %3 ]
%5 = zext i32 %4 to i64
%6 = getelementptr inbounds i8, i8* %0, i64 %5
%7 = load i8, i8* %6
%8 = icmp eq i8 %7, 32
%9 = add i32 %4, 1
br i1 %8, label %3, label %10
10: ; preds = %3
%11 = zext i32 %4 to i64
%12 = getelementptr inbounds i8, i8* %0, i64 %11
%13 = tail call i64 @strlen(i8* %12)
%14 = tail call i64 @strlen(i8* dereferenceable(1) %1)
%15 = icmp ult i64 %13, %14
br i1 %15, label %28, label %16
16: ; preds = %10
%17 = tail call i64 @strncmp(i8* %12, i8* %1, i64 %14)
%18 = icmp eq i64 %17, 0
br i1 %18, label %19, label %28
19: ; preds = %16
%20 = tail call i64 @strlen(i8* dereferenceable(1) %1)
%21 = add i64 %20, %11
%22 = getelementptr inbounds i8, i8* %0, i64 %21
%23 = load i8, i8* %22
%24 = icmp eq i8 %23, 32
%25 = icmp eq i8 %23, 61
%26 = or i1 %24, %25
%27 = select i1 %26, i32 1, i32 -1
br label %28
28: ; preds = %19, %16, %10
%29 = phi i32 [ -1, %10 ], [ -1, %16 ], [ %27, %19 ]
ret i32 %29
}