#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__ data_pattern_cmp(char const *, char const *);
char *strchr(char const *, char);
int data_match_rules1(const char *pattern, const char *data) {
  const char *end;
  ++pattern;
  end = strchr(pattern, ']');
  if (!end) {
    return 0;
  }
  if (pattern == end) {
    return 2;
  }
  for (; pattern < end; ++pattern) {
    if (pattern + 2 < end && pattern[1] == '-') {
      if (*data >= pattern[0] && *data <= pattern[2])
        break;
      else {
        pattern += 2;
        continue;
      }
    } else if (data_pattern_cmp(data, pattern))
      break;
  }
  if (pattern >= end) {
    return 0;
  }
  return 1;
}


x86 assembly (clang, -O0):
<data_match_rules1>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
mov    $0x5d,%esi
call   1030 <strchr@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    1165 <data_match_rules1+0x45>
movl   $0x0,-0x4(%rbp)
jmp    1250 <data_match_rules1+0x130>
mov    -0x10(%rbp),%rax
cmp    -0x20(%rbp),%rax
jne    117f <data_match_rules1+0x5f>
movl   $0x2,-0x4(%rbp)
jmp    1250 <data_match_rules1+0x130>
jmp    1184 <data_match_rules1+0x64>
mov    -0x10(%rbp),%rax
cmp    -0x20(%rbp),%rax
jae    122f <data_match_rules1+0x10f>
mov    -0x10(%rbp),%rax
add    $0x2,%rax
cmp    -0x20(%rbp),%rax
jae    11f8 <data_match_rules1+0xd8>
mov    -0x10(%rbp),%rax
movsbl 0x1(%rax),%eax
cmp    $0x2d,%eax
jne    11f8 <data_match_rules1+0xd8>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
mov    -0x10(%rbp),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
jl     11e7 <data_match_rules1+0xc7>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
mov    -0x10(%rbp),%rcx
movsbl 0x2(%rcx),%ecx
cmp    %ecx,%eax
jg     11e7 <data_match_rules1+0xc7>
jmp    122f <data_match_rules1+0x10f>
mov    -0x10(%rbp),%rax
add    $0x2,%rax
mov    %rax,-0x10(%rbp)
jmp    121e <data_match_rules1+0xfe>
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1040 <data_pattern_cmp@plt>
cmp    $0x0,%rax
je     1214 <data_match_rules1+0xf4>
jmp    122f <data_match_rules1+0x10f>
jmp    1219 <data_match_rules1+0xf9>
jmp    121e <data_match_rules1+0xfe>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    1184 <data_match_rules1+0x64>
mov    -0x10(%rbp),%rax
cmp    -0x20(%rbp),%rax
jb     1249 <data_match_rules1+0x129>
movl   $0x0,-0x4(%rbp)
jmp    1250 <data_match_rules1+0x130>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<data_match_rules1>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r15
mov    %rdi,%rbp
add    $0x1,%rbp
mov    %rbp,%rdi
mov    $0x5d,%esi
call   1030 <strchr@plt>
xor    %r14d,%r14d
test   %rax,%rax
je     11ab <data_match_rules1+0x8b>
mov    %rax,%rbx
cmp    %rax,%rbp
je     11a5 <data_match_rules1+0x85>
jb     1179 <data_match_rules1+0x59>
jmp    11ab <data_match_rules1+0x8b>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %r15,%rdi
mov    %rbp,%rsi
call   1040 <data_pattern_cmp@plt>
test   %rax,%rax
jne    119d <data_match_rules1+0x7d>
add    $0x1,%rbp
cmp    %rbx,%rbp
jae    11ab <data_match_rules1+0x8b>
lea    0x2(%rbp),%rax
cmp    %rbx,%rax
jae    1160 <data_match_rules1+0x40>
cmpb   $0x2d,0x1(%rbp)
jne    1160 <data_match_rules1+0x40>
movzbl (%r15),%ecx
cmp    0x0(%rbp),%cl
jge    1196 <data_match_rules1+0x76>
mov    %rax,%rbp
jmp    1170 <data_match_rules1+0x50>
mov    %rax,%rbp
cmp    (%rax),%cl
jg     1170 <data_match_rules1+0x50>
mov    $0x1,%r14d
jmp    11ab <data_match_rules1+0x8b>
mov    $0x2,%r14d
mov    %r14d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @data_match_rules1(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** %4
%8 = getelementptr inbounds i8, i8* %7, i32 1
store i8* %8, i8** %4
%9 = load i8*, i8** %4
%10 = call i8* @strchr(i8* %9, i8 signext 93)
store i8* %10, i8** %6
%11 = load i8*, i8** %6
%12 = icmp ne i8* %11, null
br i1 %12, label %14, label %13
13: ; preds = %2
store i32 0, i32* %3
br label %74
14: ; preds = %2
%15 = load i8*, i8** %4
%16 = load i8*, i8** %6
%17 = icmp eq i8* %15, %16
br i1 %17, label %18, label %19
18: ; preds = %14
store i32 2, i32* %3
br label %74
19: ; preds = %14
br label %20
20: ; preds = %65, %19
%21 = load i8*, i8** %4
%22 = load i8*, i8** %6
%23 = icmp ult i8* %21, %22
br i1 %23, label %24, label %68
24: ; preds = %20
%25 = load i8*, i8** %4
%26 = getelementptr inbounds i8, i8* %25, i64 2
%27 = load i8*, i8** %6
%28 = icmp ult i8* %26, %27
br i1 %28, label %29, label %57
29: ; preds = %24
%30 = load i8*, i8** %4
%31 = getelementptr inbounds i8, i8* %30, i64 1
%32 = load i8, i8* %31
%33 = sext i8 %32 to i32
%34 = icmp eq i32 %33, 45
br i1 %34, label %35, label %57
35: ; preds = %29
%36 = load i8*, i8** %5
%37 = load i8, i8* %36
%38 = sext i8 %37 to i32
%39 = load i8*, i8** %4
%40 = getelementptr inbounds i8, i8* %39, i64 0
%41 = load i8, i8* %40
%42 = sext i8 %41 to i32
%43 = icmp sge i32 %38, %42
br i1 %43, label %44, label %54
44: ; preds = %35
%45 = load i8*, i8** %5
%46 = load i8, i8* %45
%47 = sext i8 %46 to i32
%48 = load i8*, i8** %4
%49 = getelementptr inbounds i8, i8* %48, i64 2
%50 = load i8, i8* %49
%51 = sext i8 %50 to i32
%52 = icmp sle i32 %47, %51
br i1 %52, label %53, label %54
53: ; preds = %44
br label %68
54: ; preds = %44, %35
%55 = load i8*, i8** %4
%56 = getelementptr inbounds i8, i8* %55, i64 2
store i8* %56, i8** %4
br label %65
57: ; preds = %29, %24
%58 = load i8*, i8** %5
%59 = load i8*, i8** %4
%60 = call i64 @data_pattern_cmp(i8* %58, i8* %59)
%61 = icmp ne i64 %60, 0
br i1 %61, label %62, label %63
62: ; preds = %57
br label %68
63: ; preds = %57
br label %64
64: ; preds = %63
br label %65
65: ; preds = %64, %54
%66 = load i8*, i8** %4
%67 = getelementptr inbounds i8, i8* %66, i32 1
store i8* %67, i8** %4
br label %20
68: ; preds = %62, %53, %20
%69 = load i8*, i8** %4
%70 = load i8*, i8** %6
%71 = icmp uge i8* %69, %70
br i1 %71, label %72, label %73
72: ; preds = %68
store i32 0, i32* %3
br label %74
73: ; preds = %68
store i32 1, i32* %3
br label %74
74: ; preds = %73, %72, %18, %13
%75 = load i32, i32* %3
ret i32 %75
}

LLVM IR (-O2):
define i32 @data_match_rules1(i8* %0, i8* %1) {
%3 = getelementptr inbounds i8, i8* %0, i64 1
%4 = tail call i8* @strchr(i8* %3, i8 signext 93)
%5 = icmp eq i8* %4, null
br i1 %5, label %32, label %6
6: ; preds = %2
%7 = icmp eq i8* %3, %4
br i1 %7, label %32, label %8
8: ; preds = %6
%9 = icmp ult i8* %3, %4
br i1 %9, label %10, label %32
10: ; preds = %8, %28
%11 = phi i8* [ %30, %28 ], [ %3, %8 ]
%12 = getelementptr inbounds i8, i8* %11, i64 2
%13 = icmp ult i8* %12, %4
br i1 %13, label %14, label %25
14: ; preds = %10
%15 = getelementptr inbounds i8, i8* %11, i64 1
%16 = load i8, i8* %15
%17 = icmp eq i8 %16, 45
br i1 %17, label %18, label %25
18: ; preds = %14
%19 = load i8, i8* %1
%20 = load i8, i8* %11
%21 = icmp slt i8 %19, %20
br i1 %21, label %28, label %22
22: ; preds = %18
%23 = load i8, i8* %12
%24 = icmp sgt i8 %19, %23
br i1 %24, label %28, label %32
25: ; preds = %14, %10
%26 = tail call i64 @data_pattern_cmp(i8* %1, i8* %11)
%27 = icmp eq i64 %26, 0
br i1 %27, label %28, label %32
28: ; preds = %18, %22, %25
%29 = phi i8* [ %11, %25 ], [ %12, %22 ], [ %12, %18 ]
%30 = getelementptr inbounds i8, i8* %29, i64 1
%31 = icmp ult i8* %30, %4
br i1 %31, label %10, label %32
32: ; preds = %25, %22, %28, %8, %6, %2
%33 = phi i32 [ 0, %2 ], [ 2, %6 ], [ 0, %8 ], [ 1, %25 ], [ 1, %22 ], [ 0, %28 ]
ret i32 %33
}