#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__ strcmp(char *, char *);
char *substr(char *, int /*<<< orphan*/, int);
int rule_D(char *str) {
  if (strcmp(substr(str, 0, 4), "const") >= 0) {
    return 0;
  } else {
    if (strcmp(substr(str, 0, 2), "var") >= 0) {
      return 0;
    } else {
      if (strcmp(str, "") == 0) {
        return 0;
      } else {
        return -1;
      }
    }
  }
}


x86 assembly (clang, -O0):
<rule_D>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
xor    %esi,%esi
mov    $0x4,%edx
call   1030 <substr@plt>
mov    %rax,%rdi
lea    0xeba(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jl     1161 <rule_D+0x41>
movl   $0x0,-0x4(%rbp)
jmp    11c3 <rule_D+0xa3>
mov    -0x10(%rbp),%rdi
xor    %esi,%esi
mov    $0x2,%edx
call   1030 <substr@plt>
mov    %rax,%rdi
lea    0xe8b(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jl     1196 <rule_D+0x76>
movl   $0x0,-0x4(%rbp)
jmp    11c3 <rule_D+0xa3>
mov    -0x10(%rbp),%rdi
lea    0xe68(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    11bc <rule_D+0x9c>
movl   $0x0,-0x4(%rbp)
jmp    11c3 <rule_D+0xa3>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<rule_D>:
push   %rbp
push   %rbx
push   %rax
mov    %rdi,%rbx
xor    %ebp,%ebp
xor    %esi,%esi
mov    $0x4,%edx
call   1030 <substr@plt>
lea    0xec5(%rip),%rsi
mov    %rax,%rdi
call   1040 <strcmp@plt>
test   %rax,%rax
jns    1181 <rule_D+0x61>
xor    %ebp,%ebp
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x2,%edx
call   1030 <substr@plt>
lea    0xea6(%rip),%rsi
mov    %rax,%rdi
call   1040 <strcmp@plt>
test   %rax,%rax
jns    1181 <rule_D+0x61>
lea    0xe95(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
neg    %rax
sbb    %ebp,%ebp
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [6 x i8] c"const\00"
@.str.1 = [4 x i8] c"var\00"
@.str.2 = [1 x i8] zeroinitializer
define i32 @rule_D(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
store i8* %0, i8** %3
%4 = load i8*, i8** %3
%5 = call i8* @substr(i8* %4, i32 0, i32 4)
%6 = call i64 @strcmp(i8* %5, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%7 = icmp sge i64 %6, 0
br i1 %7, label %8, label %9
8: ; preds = %1
store i32 0, i32* %2
br label %21
9: ; preds = %1
%10 = load i8*, i8** %3
%11 = call i8* @substr(i8* %10, i32 0, i32 2)
%12 = call i64 @strcmp(i8* %11, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%13 = icmp sge i64 %12, 0
br i1 %13, label %14, label %15
14: ; preds = %9
store i32 0, i32* %2
br label %21
15: ; preds = %9
%16 = load i8*, i8** %3
%17 = call i64 @strcmp(i8* %16, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0))
%18 = icmp eq i64 %17, 0
br i1 %18, label %19, label %20
19: ; preds = %15
store i32 0, i32* %2
br label %21
20: ; preds = %15
store i32 -1, i32* %2
br label %21
21: ; preds = %20, %19, %14, %8
%22 = load i32, i32* %2
ret i32 %22
}

LLVM IR (-O2):
@.str = [6 x i8] c"const\00"
@.str.1 = [4 x i8] c"var\00"
@.str.2 = [1 x i8] zeroinitializer
define i32 @rule_D(i8* %0) {
%2 = tail call i8* @substr(i8* %0, i32 0, i32 4)
%3 = tail call i64 @strcmp(i8* %2, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%4 = icmp sgt i64 %3, -1
br i1 %4, label %13, label %5
5: ; preds = %1
%6 = tail call i8* @substr(i8* %0, i32 0, i32 2)
%7 = tail call i64 @strcmp(i8* %6, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%8 = icmp sgt i64 %7, -1
br i1 %8, label %13, label %9
9: ; preds = %5
%10 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0))
%11 = icmp ne i64 %10, 0
%12 = sext i1 %11 to i32
br label %13
13: ; preds = %9, %5, %1
%14 = phi i32 [ 0, %1 ], [ 0, %5 ], [ %12, %9 ]
ret i32 %14
}