#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__ isspace(char);
int /*<<< orphan*/ strlen(char const *);
scalar_t__ strncmp(char *, char *, int /*<<< orphan*/);
char *strstr(char *, char const *);
int check_feature(char *buffer, const char *feature) {
  char *p;
  if (*feature == 0)
    return 0;
  if (strncmp(buffer, "flags", strlen("flags")) != 0)
    return 0;
  buffer += strlen("flags");
  while (isspace(*buffer))
    buffer++;
  while ((p = strstr(buffer, feature))) {
    if (p > buffer && !isspace(*(p - 1))) {
      buffer++;
      continue;
    }
    p += strlen(feature);
    if (*p != 0 && !isspace(*p)) {
      buffer++;
      continue;
    }
    return 1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<check_feature>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
jne    116c <check_feature+0x2c>
movl   $0x0,-0x4(%rbp)
jmp    12a4 <check_feature+0x164>
mov    -0x10(%rbp),%rax
mov    %rax,-0x28(%rbp)
lea    0xe85(%rip),%rdi
call   1040 <strlen@plt>
mov    -0x28(%rbp),%rdi
mov    %eax,%edx
lea    0xe73(%rip),%rsi
call   1030 <strncmp@plt>
cmp    $0x0,%rax
je     11a8 <check_feature+0x68>
movl   $0x0,-0x4(%rbp)
jmp    12a4 <check_feature+0x164>
lea    0xe51(%rip),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0x10(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%edi
call   1050 <isspace@plt>
cmp    $0x0,%rax
je     11eb <check_feature+0xab>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    11c4 <check_feature+0x84>
jmp    11f0 <check_feature+0xb0>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1060 <strstr@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
je     129d <check_feature+0x15d>
mov    -0x20(%rbp),%rax
cmp    -0x10(%rbp),%rax
jbe    1241 <check_feature+0x101>
mov    -0x20(%rbp),%rax
movsbl -0x1(%rax),%edi
call   1050 <isspace@plt>
cmp    $0x0,%rax
jne    1241 <check_feature+0x101>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    11f0 <check_feature+0xb0>
mov    -0x18(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0x20(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     1291 <check_feature+0x151>
mov    -0x20(%rbp),%rax
movsbl (%rax),%edi
call   1050 <isspace@plt>
cmp    $0x0,%rax
jne    1291 <check_feature+0x151>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    11f0 <check_feature+0xb0>
movl   $0x1,-0x4(%rbp)
jmp    12a4 <check_feature+0x164>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<check_feature>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
cmpb   $0x0,(%rsi)
je     1173 <check_feature+0x33>
mov    %rsi,%r14
mov    %rdi,%rbx
lea    0xea7(%rip),%rbp
mov    %rbp,%rdi
call   1040 <strlen@plt>
mov    %rbx,%rdi
mov    %rbp,%rsi
mov    %eax,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
je     1182 <check_feature+0x42>
xor    %ebp,%ebp
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xe77(%rip),%rdi
call   1040 <strlen@plt>
cltq
add    %rax,%rbx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movsbl (%rbx),%edi
call   1050 <isspace@plt>
add    $0x1,%rbx
test   %rax,%rax
jne    11a0 <check_feature+0x60>
lea    -0x1(%rbx),%rdi
mov    %r14,%rsi
call   1060 <strstr@plt>
test   %rax,%rax
je     1173 <check_feature+0x33>
mov    %rax,%r15
mov    $0x1,%ebp
jmp    11e7 <check_feature+0xa7>
nopl   0x0(%rax)
mov    %rbx,%rdi
mov    %r14,%rsi
call   1060 <strstr@plt>
mov    %rax,%r15
add    $0x1,%rbx
test   %rax,%rax
je     1173 <check_feature+0x33>
lea    -0x1(%rbx),%rax
cmp    %rax,%r15
jbe    11ff <check_feature+0xbf>
movsbl -0x1(%r15),%edi
call   1050 <isspace@plt>
test   %rax,%rax
je     11d0 <check_feature+0x90>
mov    %r14,%rdi
call   1040 <strlen@plt>
cltq
movzbl (%r15,%rax,1),%eax
test   %al,%al
je     1175 <check_feature+0x35>
movsbl %al,%edi
call   1050 <isspace@plt>
test   %rax,%rax
je     11d0 <check_feature+0x90>
jmp    1175 <check_feature+0x35>

LLVM IR (-O0):
@.str = [6 x i8] c"flags\00"
define i32 @check_feature(i8* %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
store i8* %0, i8** %4
store i8* %1, i8** %5
%7 = load i8*, i8** %5
%8 = load i8, i8* %7
%9 = sext i8 %8 to i32
%10 = icmp eq i32 %9, 0
br i1 %10, label %11, label %12
11: ; preds = %2
store i32 0, i32* %3
br label %70
12: ; preds = %2
%13 = load i8*, i8** %4
%14 = call i32 @strlen(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%15 = call i64 @strncmp(i8* %13, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 %14)
%16 = icmp ne i64 %15, 0
br i1 %16, label %17, label %18
17: ; preds = %12
store i32 0, i32* %3
br label %70
18: ; preds = %12
%19 = call i32 @strlen(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%20 = load i8*, i8** %4
%21 = sext i32 %19 to i64
%22 = getelementptr inbounds i8, i8* %20, i64 %21
store i8* %22, i8** %4
br label %23
23: ; preds = %28, %18
%24 = load i8*, i8** %4
%25 = load i8, i8* %24
%26 = call i64 @isspace(i8 signext %25)
%27 = icmp ne i64 %26, 0
br i1 %27, label %28, label %31
28: ; preds = %23
%29 = load i8*, i8** %4
%30 = getelementptr inbounds i8, i8* %29, i32 1
store i8* %30, i8** %4
br label %23
31: ; preds = %23
br label %32
32: ; preds = %65, %47, %31
%33 = load i8*, i8** %4
%34 = load i8*, i8** %5
%35 = call i8* @strstr(i8* %33, i8* %34)
store i8* %35, i8** %6
%36 = icmp ne i8* %35, null
br i1 %36, label %37, label %69
37: ; preds = %32
%38 = load i8*, i8** %6
%39 = load i8*, i8** %4
%40 = icmp ugt i8* %38, %39
br i1 %40, label %41, label %50
41: ; preds = %37
%42 = load i8*, i8** %6
%43 = getelementptr inbounds i8, i8* %42, i64 -1
%44 = load i8, i8* %43
%45 = call i64 @isspace(i8 signext %44)
%46 = icmp ne i64 %45, 0
br i1 %46, label %50, label %47
47: ; preds = %41
%48 = load i8*, i8** %4
%49 = getelementptr inbounds i8, i8* %48, i32 1
store i8* %49, i8** %4
br label %32
50: ; preds = %41, %37
%51 = load i8*, i8** %5
%52 = call i32 @strlen(i8* %51)
%53 = load i8*, i8** %6
%54 = sext i32 %52 to i64
%55 = getelementptr inbounds i8, i8* %53, i64 %54
store i8* %55, i8** %6
%56 = load i8*, i8** %6
%57 = load i8, i8* %56
%58 = sext i8 %57 to i32
%59 = icmp ne i32 %58, 0
br i1 %59, label %60, label %68
60: ; preds = %50
%61 = load i8*, i8** %6
%62 = load i8, i8* %61
%63 = call i64 @isspace(i8 signext %62)
%64 = icmp ne i64 %63, 0
br i1 %64, label %68, label %65
65: ; preds = %60
%66 = load i8*, i8** %4
%67 = getelementptr inbounds i8, i8* %66, i32 1
store i8* %67, i8** %4
br label %32
68: ; preds = %60, %50
store i32 1, i32* %3
br label %70
69: ; preds = %32
store i32 0, i32* %3
br label %70
70: ; preds = %69, %68, %17, %11
%71 = load i32, i32* %3
ret i32 %71
}

LLVM IR (-O2):
@.str = [6 x i8] c"flags\00"
define i32 @check_feature(i8* %0, i8* %1) {
%3 = load i8, i8* %1
%4 = icmp eq i8 %3, 0
br i1 %4, label %44, label %5
5: ; preds = %2
%6 = tail call i32 @strlen(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%7 = tail call i64 @strncmp(i8* %0, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 %6)
%8 = icmp eq i64 %7, 0
br i1 %8, label %9, label %44
9: ; preds = %5
%10 = tail call i32 @strlen(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%11 = sext i32 %10 to i64
%12 = getelementptr inbounds i8, i8* %0, i64 %11
br label %13
13: ; preds = %13, %9
%14 = phi i8* [ %12, %9 ], [ %18, %13 ]
%15 = load i8, i8* %14
%16 = tail call i64 @isspace(i8 signext %15)
%17 = icmp eq i64 %16, 0
%18 = getelementptr inbounds i8, i8* %14, i64 1
br i1 %17, label %19, label %13
19: ; preds = %13
%20 = tail call i8* @strstr(i8* %14, i8* %1)
%21 = icmp eq i8* %20, null
br i1 %21, label %44, label %22
22: ; preds = %19, %31
%23 = phi i8* [ %33, %31 ], [ %20, %19 ]
%24 = phi i8* [ %32, %31 ], [ %14, %19 ]
%25 = icmp ugt i8* %23, %24
br i1 %25, label %26, label %35
26: ; preds = %22
%27 = getelementptr inbounds i8, i8* %23, i64 -1
%28 = load i8, i8* %27
%29 = tail call i64 @isspace(i8 signext %28)
%30 = icmp eq i64 %29, 0
br i1 %30, label %31, label %35
31: ; preds = %41, %26
%32 = getelementptr inbounds i8, i8* %24, i64 1
%33 = tail call i8* @strstr(i8* %32, i8* %1)
%34 = icmp eq i8* %33, null
br i1 %34, label %44, label %22
35: ; preds = %26, %22
%36 = tail call i32 @strlen(i8* %1)
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds i8, i8* %23, i64 %37
%39 = load i8, i8* %38
%40 = icmp eq i8 %39, 0
br i1 %40, label %44, label %41
41: ; preds = %35
%42 = tail call i64 @isspace(i8 signext %39)
%43 = icmp eq i64 %42, 0
br i1 %43, label %31, label %44
44: ; preds = %41, %35, %31, %19, %5, %2
%45 = phi i32 [ 0, %2 ], [ 0, %5 ], [ 0, %19 ], [ 1, %41 ], [ 1, %35 ], [ 0, %31 ]
ret i32 %45
}