int isns_source_pattern_match(const char *pattern, const char *source) {
  unsigned int rev_len;
  isns_debug_message("%s(%s, %s)\n", __FUNCTION__, pattern, source);
  if (!strcmp(pattern, "*"))
    return 1;
  if (strncmp(pattern, "match:", 6))
    return !strcasecmp(pattern, source);
  pattern += 6;
  if (strncasecmp(source, "iqn.", 4))
    return 0;
  source += 4;
  rev_len = strlen(pattern);
  if (strncasecmp(source, pattern, rev_len)) {
    if (!(isdigit(source[0]) && isdigit(source[1]) && isdigit(source[2]) &&
          isdigit(source[3]) && source[4] == '-' && isdigit(source[5]) &&
          isdigit(source[6]) && source[7] == '.'))
      return 0;
    source += 8;
    if (strncasecmp(source, pattern, rev_len))
      return 0;
  }
  source += rev_len;
  if (source[0] != '.' && source[0] != ':' && source[0] != '-' &&
      source[0] != '\0')
    return 0;
  return 1;
}


x86 assembly (clang, -O0):
<isns_source_pattern_match>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rdx
mov    -0x18(%rbp),%rcx
lea    0xe71(%rip),%rdi
lea    0xe76(%rip),%rsi
mov    $0x0,%al
call   1060 <isns_debug_message@plt>
mov    -0x10(%rbp),%rdi
lea    0xe7e(%rip),%rsi
call   1080 <strcmp@plt>
cmp    $0x0,%eax
jne    11c2 <isns_source_pattern_match+0x52>
movl   $0x1,-0x4(%rbp)
jmp    13b7 <isns_source_pattern_match+0x247>
mov    -0x10(%rbp),%rdi
lea    0xe5b(%rip),%rsi
mov    $0x6,%edx
call   1040 <strncmp@plt>
cmp    $0x0,%eax
je     1202 <isns_source_pattern_match+0x92>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1030 <strcasecmp@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x4(%rbp)
jmp    13b7 <isns_source_pattern_match+0x247>
mov    -0x10(%rbp),%rax
add    $0x6,%rax
mov    %rax,-0x10(%rbp)
mov    -0x18(%rbp),%rdi
lea    0xe16(%rip),%rsi
mov    $0x4,%edx
call   1090 <strncasecmp@plt>
cmp    $0x0,%eax
je     1238 <isns_source_pattern_match+0xc8>
movl   $0x0,-0x4(%rbp)
jmp    13b7 <isns_source_pattern_match+0x247>
mov    -0x18(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
call   1070 <strlen@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x1c(%rbp),%eax
mov    %eax,%edx
call   1090 <strncasecmp@plt>
cmp    $0x0,%eax
je     1354 <isns_source_pattern_match+0x1e4>
mov    -0x18(%rbp),%rax
movsbl (%rax),%edi
call   1050 <isdigit@plt>
cmp    $0x0,%eax
je     1310 <isns_source_pattern_match+0x1a0>
mov    -0x18(%rbp),%rax
movsbl 0x1(%rax),%edi
call   1050 <isdigit@plt>
cmp    $0x0,%eax
je     1310 <isns_source_pattern_match+0x1a0>
mov    -0x18(%rbp),%rax
movsbl 0x2(%rax),%edi
call   1050 <isdigit@plt>
cmp    $0x0,%eax
je     1310 <isns_source_pattern_match+0x1a0>
mov    -0x18(%rbp),%rax
movsbl 0x3(%rax),%edi
call   1050 <isdigit@plt>
cmp    $0x0,%eax
je     1310 <isns_source_pattern_match+0x1a0>
mov    -0x18(%rbp),%rax
movsbl 0x4(%rax),%eax
cmp    $0x2d,%eax
jne    1310 <isns_source_pattern_match+0x1a0>
mov    -0x18(%rbp),%rax
movsbl 0x5(%rax),%edi
call   1050 <isdigit@plt>
cmp    $0x0,%eax
je     1310 <isns_source_pattern_match+0x1a0>
mov    -0x18(%rbp),%rax
movsbl 0x6(%rax),%edi
call   1050 <isdigit@plt>
cmp    $0x0,%eax
je     1310 <isns_source_pattern_match+0x1a0>
mov    -0x18(%rbp),%rax
movsbl 0x7(%rax),%eax
cmp    $0x2e,%eax
je     131c <isns_source_pattern_match+0x1ac>
movl   $0x0,-0x4(%rbp)
jmp    13b7 <isns_source_pattern_match+0x247>
mov    -0x18(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x1c(%rbp),%eax
mov    %eax,%edx
call   1090 <strncasecmp@plt>
cmp    $0x0,%eax
je     134f <isns_source_pattern_match+0x1df>
movl   $0x0,-0x4(%rbp)
jmp    13b7 <isns_source_pattern_match+0x247>
jmp    1354 <isns_source_pattern_match+0x1e4>
mov    -0x1c(%rbp),%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,%ecx
add    %rcx,%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2e,%eax
je     13b0 <isns_source_pattern_match+0x240>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x3a,%eax
je     13b0 <isns_source_pattern_match+0x240>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2d,%eax
je     13b0 <isns_source_pattern_match+0x240>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     13b0 <isns_source_pattern_match+0x240>
movl   $0x0,-0x4(%rbp)
jmp    13b7 <isns_source_pattern_match+0x247>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<isns_source_pattern_match>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
lea    0xe88(%rip),%rdi
lea    0xe8d(%rip),%rsi
mov    %rbx,%rdx
mov    %r14,%rcx
xor    %eax,%eax
call   1050 <isns_debug_message@plt>
lea    0xe93(%rip),%rsi
mov    %rbx,%rdi
call   1070 <strcmp@plt>
mov    $0x1,%ebp
test   %eax,%eax
je     11f1 <isns_source_pattern_match+0x91>
lea    0xe7d(%rip),%rsi
mov    $0x6,%edx
mov    %rbx,%rdi
call   1040 <strncmp@plt>
test   %eax,%eax
je     11d1 <isns_source_pattern_match+0x71>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1030 <strcasecmp@plt>
xor    %ebp,%ebp
test   %eax,%eax
sete   %bpl
jmp    11f1 <isns_source_pattern_match+0x91>
lea    0xe57(%rip),%rsi
mov    $0x4,%r13d
mov    $0x4,%edx
mov    %r14,%rdi
call   1080 <strncasecmp@plt>
xor    %ebp,%ebp
test   %eax,%eax
je     1202 <isns_source_pattern_match+0xa2>
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
add    $0x6,%rbx
lea    0x4(%r14),%r12
mov    %rbx,%rdi
call   1060 <strlen@plt>
mov    %eax,%r15d
mov    %r12,%rdi
mov    %rbx,%rsi
mov    %r15,%rdx
call   1080 <strncasecmp@plt>
test   %eax,%eax
je     12b0 <isns_source_pattern_match+0x150>
movsbl (%r12),%eax
add    $0xffffffd0,%eax
cmp    $0x9,%eax
ja     11f1 <isns_source_pattern_match+0x91>
movsbl 0x5(%r14),%eax
add    $0xffffffd0,%eax
cmp    $0x9,%eax
ja     11f1 <isns_source_pattern_match+0x91>
movsbl 0x6(%r14),%eax
add    $0xffffffd0,%eax
cmp    $0x9,%eax
ja     11f1 <isns_source_pattern_match+0x91>
movsbl 0x7(%r14),%eax
add    $0xffffffd0,%eax
cmp    $0x9,%eax
ja     11f1 <isns_source_pattern_match+0x91>
cmpb   $0x2d,0x8(%r14)
jne    11f1 <isns_source_pattern_match+0x91>
movsbl 0x9(%r14),%eax
add    $0xffffffd0,%eax
cmp    $0x9,%eax
ja     11f1 <isns_source_pattern_match+0x91>
movsbl 0xa(%r14),%eax
add    $0xffffffd0,%eax
cmp    $0x9,%eax
ja     11f1 <isns_source_pattern_match+0x91>
cmpb   $0x2e,0xb(%r14)
jne    11f1 <isns_source_pattern_match+0x91>
lea    0xc(%r14),%rdi
mov    %rbx,%rsi
mov    %r15,%rdx
call   1080 <strncasecmp@plt>
test   %eax,%eax
jne    11f1 <isns_source_pattern_match+0x91>
mov    $0xc,%r13d
add    %r13,%r14
movzbl (%r15,%r14,1),%eax
cmp    $0x3a,%rax
ja     11f1 <isns_source_pattern_match+0x91>
movabs $0x400600000000001,%rcx
bt     %rax,%rcx
jae    11f1 <isns_source_pattern_match+0x91>
mov    $0x1,%ebp
jmp    11f1 <isns_source_pattern_match+0x91>

LLVM IR (-O0):
@.str = [12 x i8] c"%s(%s, %s)\0A\00"
@__FUNCTION__.isns_source_pattern_match = [26 x i8] c"isns_source_pattern_match\00"
@.str.1 = [2 x i8] c"*\00"
@.str.2 = [7 x i8] c"match:\00"
@.str.3 = [5 x i8] c"iqn.\00"
define i32 @isns_source_pattern_match(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
%7 = load i8*, i8** %4
%8 = load i8*, i8** %5
%9 = call i32 (i8*, i8*, i8*, i8*, ...) bitcast (i32 (...)* @isns_debug_message to i32 (i8*, i8*, i8*, i8*, ...)*)(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([26 x i8], [26 x i8]* @__FUNCTION__.isns_source_pattern_match, i64 0, i64 0), i8* %7, i8* %8)
%10 = load i8*, i8** %4
%11 = call i32 @strcmp(i8* %10, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%12 = icmp ne i32 %11, 0
br i1 %12, label %14, label %13
13: ; preds = %2
store i32 1, i32* %3
br label %140
14: ; preds = %2
%15 = load i8*, i8** %4
%16 = call i32 @strncmp(i8* %15, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i64 6)
%17 = icmp ne i32 %16, 0
br i1 %17, label %18, label %25
18: ; preds = %14
%19 = load i8*, i8** %4
%20 = load i8*, i8** %5
%21 = call i32 @strcasecmp(i8* %19, i8* %20)
%22 = icmp ne i32 %21, 0
%23 = xor i1 %22, true
%24 = zext i1 %23 to i32
store i32 %24, i32* %3
br label %140
25: ; preds = %14
%26 = load i8*, i8** %4
%27 = getelementptr inbounds i8, i8* %26, i64 6
store i8* %27, i8** %4
%28 = load i8*, i8** %5
%29 = call i32 @strncasecmp(i8* %28, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i64 4)
%30 = icmp ne i32 %29, 0
br i1 %30, label %31, label %32
31: ; preds = %25
store i32 0, i32* %3
br label %140
32: ; preds = %25
%33 = load i8*, i8** %5
%34 = getelementptr inbounds i8, i8* %33, i64 4
store i8* %34, i8** %5
%35 = load i8*, i8** %4
%36 = call i64 @strlen(i8* %35)
%37 = trunc i64 %36 to i32
store i32 %37, i32* %6
%38 = load i8*, i8** %5
%39 = load i8*, i8** %4
%40 = load i32, i32* %6
%41 = zext i32 %40 to i64
%42 = call i32 @strncasecmp(i8* %38, i8* %39, i64 %41)
%43 = icmp ne i32 %42, 0
br i1 %43, label %44, label %110
44: ; preds = %32
%45 = load i8*, i8** %5
%46 = getelementptr inbounds i8, i8* %45, i64 0
%47 = load i8, i8* %46
%48 = sext i8 %47 to i32
%49 = call i32 @isdigit(i32 %48)
%50 = icmp ne i32 %49, 0
br i1 %50, label %51, label %98
51: ; preds = %44
%52 = load i8*, i8** %5
%53 = getelementptr inbounds i8, i8* %52, i64 1
%54 = load i8, i8* %53
%55 = sext i8 %54 to i32
%56 = call i32 @isdigit(i32 %55)
%57 = icmp ne i32 %56, 0
br i1 %57, label %58, label %98
58: ; preds = %51
%59 = load i8*, i8** %5
%60 = getelementptr inbounds i8, i8* %59, i64 2
%61 = load i8, i8* %60
%62 = sext i8 %61 to i32
%63 = call i32 @isdigit(i32 %62)
%64 = icmp ne i32 %63, 0
br i1 %64, label %65, label %98
65: ; preds = %58
%66 = load i8*, i8** %5
%67 = getelementptr inbounds i8, i8* %66, i64 3
%68 = load i8, i8* %67
%69 = sext i8 %68 to i32
%70 = call i32 @isdigit(i32 %69)
%71 = icmp ne i32 %70, 0
br i1 %71, label %72, label %98
72: ; preds = %65
%73 = load i8*, i8** %5
%74 = getelementptr inbounds i8, i8* %73, i64 4
%75 = load i8, i8* %74
%76 = sext i8 %75 to i32
%77 = icmp eq i32 %76, 45
br i1 %77, label %78, label %98
78: ; preds = %72
%79 = load i8*, i8** %5
%80 = getelementptr inbounds i8, i8* %79, i64 5
%81 = load i8, i8* %80
%82 = sext i8 %81 to i32
%83 = call i32 @isdigit(i32 %82)
%84 = icmp ne i32 %83, 0
br i1 %84, label %85, label %98
85: ; preds = %78
%86 = load i8*, i8** %5
%87 = getelementptr inbounds i8, i8* %86, i64 6
%88 = load i8, i8* %87
%89 = sext i8 %88 to i32
%90 = call i32 @isdigit(i32 %89)
%91 = icmp ne i32 %90, 0
br i1 %91, label %92, label %98
92: ; preds = %85
%93 = load i8*, i8** %5
%94 = getelementptr inbounds i8, i8* %93, i64 7
%95 = load i8, i8* %94
%96 = sext i8 %95 to i32
%97 = icmp eq i32 %96, 46
br i1 %97, label %99, label %98
98: ; preds = %92, %85, %78, %72, %65, %58, %51, %44
store i32 0, i32* %3
br label %140
99: ; preds = %92
%100 = load i8*, i8** %5
%101 = getelementptr inbounds i8, i8* %100, i64 8
store i8* %101, i8** %5
%102 = load i8*, i8** %5
%103 = load i8*, i8** %4
%104 = load i32, i32* %6
%105 = zext i32 %104 to i64
%106 = call i32 @strncasecmp(i8* %102, i8* %103, i64 %105)
%107 = icmp ne i32 %106, 0
br i1 %107, label %108, label %109
108: ; preds = %99
store i32 0, i32* %3
br label %140
109: ; preds = %99
br label %110
110: ; preds = %109, %32
%111 = load i32, i32* %6
%112 = load i8*, i8** %5
%113 = zext i32 %111 to i64
%114 = getelementptr inbounds i8, i8* %112, i64 %113
store i8* %114, i8** %5
%115 = load i8*, i8** %5
%116 = getelementptr inbounds i8, i8* %115, i64 0
%117 = load i8, i8* %116
%118 = sext i8 %117 to i32
%119 = icmp ne i32 %118, 46
br i1 %119, label %120, label %139
120: ; preds = %110
%121 = load i8*, i8** %5
%122 = getelementptr inbounds i8, i8* %121, i64 0
%123 = load i8, i8* %122
%124 = sext i8 %123 to i32
%125 = icmp ne i32 %124, 58
br i1 %125, label %126, label %139
126: ; preds = %120
%127 = load i8*, i8** %5
%128 = getelementptr inbounds i8, i8* %127, i64 0
%129 = load i8, i8* %128
%130 = sext i8 %129 to i32
%131 = icmp ne i32 %130, 45
br i1 %131, label %132, label %139
132: ; preds = %126
%133 = load i8*, i8** %5
%134 = getelementptr inbounds i8, i8* %133, i64 0
%135 = load i8, i8* %134
%136 = sext i8 %135 to i32
%137 = icmp ne i32 %136, 0
br i1 %137, label %138, label %139
138: ; preds = %132
store i32 0, i32* %3
br label %140
139: ; preds = %132, %126, %120, %110
store i32 1, i32* %3
br label %140
140: ; preds = %139, %138, %108, %98, %31, %18, %13
%141 = load i32, i32* %3
ret i32 %141
}

LLVM IR (-O2):
@.str = [12 x i8] c"%s(%s, %s)\0A\00"
@__FUNCTION__.isns_source_pattern_match = [26 x i8] c"isns_source_pattern_match\00"
@.str.1 = [2 x i8] c"*\00"
@.str.2 = [7 x i8] c"match:\00"
@.str.3 = [5 x i8] c"iqn.\00"
define i32 @isns_source_pattern_match(i8* %0, i8* %1) {
%3 = tail call i32 (i8*, i8*, i8*, i8*, ...) bitcast (i32 (...)* @isns_debug_message to i32 (i8*, i8*, i8*, i8*, ...)*)(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([26 x i8], [26 x i8]* @__FUNCTION__.isns_source_pattern_match, i64 0, i64 0), i8* %0, i8* %1)
%4 = tail call i32 @strcmp(i8* dereferenceable(1) %0, i8* dereferenceable(2) getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%5 = icmp eq i32 %4, 0
br i1 %5, label %76, label %6
6: ; preds = %2
%7 = tail call i32 @strncmp(i8* dereferenceable(1) %0, i8* dereferenceable(7) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i64 6)
%8 = icmp eq i32 %7, 0
br i1 %8, label %13, label %9
9: ; preds = %6
%10 = tail call i32 @strcasecmp(i8* %0, i8* %1)
%11 = icmp eq i32 %10, 0
%12 = zext i1 %11 to i32
br label %76
13: ; preds = %6
%14 = getelementptr inbounds i8, i8* %0, i64 6
%15 = tail call i32 @strncasecmp(i8* %1, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i64 4)
%16 = icmp eq i32 %15, 0
br i1 %16, label %17, label %76
17: ; preds = %13
%18 = getelementptr inbounds i8, i8* %1, i64 4
%19 = tail call i64 @strlen(i8* %14)
%20 = and i64 %19, 4294967295
%21 = tail call i32 @strncasecmp(i8* %18, i8* %14, i64 %20)
%22 = icmp eq i32 %21, 0
br i1 %22, label %70, label %23
23: ; preds = %17
%24 = load i8, i8* %18
%25 = sext i8 %24 to i32
%26 = add nsw i32 %25, -48
%27 = icmp ult i32 %26, 10
br i1 %27, label %28, label %76
28: ; preds = %23
%29 = getelementptr inbounds i8, i8* %1, i64 5
%30 = load i8, i8* %29
%31 = sext i8 %30 to i32
%32 = add nsw i32 %31, -48
%33 = icmp ult i32 %32, 10
br i1 %33, label %34, label %76
34: ; preds = %28
%35 = getelementptr inbounds i8, i8* %1, i64 6
%36 = load i8, i8* %35
%37 = sext i8 %36 to i32
%38 = add nsw i32 %37, -48
%39 = icmp ult i32 %38, 10
br i1 %39, label %40, label %76
40: ; preds = %34
%41 = getelementptr inbounds i8, i8* %1, i64 7
%42 = load i8, i8* %41
%43 = sext i8 %42 to i32
%44 = add nsw i32 %43, -48
%45 = icmp ult i32 %44, 10
br i1 %45, label %46, label %76
46: ; preds = %40
%47 = getelementptr inbounds i8, i8* %1, i64 8
%48 = load i8, i8* %47
%49 = icmp eq i8 %48, 45
br i1 %49, label %50, label %76
50: ; preds = %46
%51 = getelementptr inbounds i8, i8* %1, i64 9
%52 = load i8, i8* %51
%53 = sext i8 %52 to i32
%54 = add nsw i32 %53, -48
%55 = icmp ult i32 %54, 10
br i1 %55, label %56, label %76
56: ; preds = %50
%57 = getelementptr inbounds i8, i8* %1, i64 10
%58 = load i8, i8* %57
%59 = sext i8 %58 to i32
%60 = add nsw i32 %59, -48
%61 = icmp ult i32 %60, 10
br i1 %61, label %62, label %76
62: ; preds = %56
%63 = getelementptr inbounds i8, i8* %1, i64 11
%64 = load i8, i8* %63
%65 = icmp eq i8 %64, 46
br i1 %65, label %66, label %76
66: ; preds = %62
%67 = getelementptr inbounds i8, i8* %1, i64 12
%68 = tail call i32 @strncasecmp(i8* %67, i8* %14, i64 %20)
%69 = icmp eq i32 %68, 0
br i1 %69, label %70, label %76
70: ; preds = %66, %17
%71 = phi i64 [ 12, %66 ], [ 4, %17 ]
%72 = getelementptr inbounds i8, i8* %1, i64 %71
%73 = getelementptr inbounds i8, i8* %72, i64 %20
%74 = load i8, i8* %73
switch i8 %74, label %76 [
i8 46, label %75
i8 58, label %75
i8 45, label %75
i8 0, label %75
]
75: ; preds = %70, %70, %70, %70
br label %76
76: ; preds = %70, %66, %23, %28, %34, %40, %46, %50, %56, %62, %13, %2, %75, %9
%77 = phi i32 [ %12, %9 ], [ 1, %75 ], [ 1, %2 ], [ 0, %13 ], [ 0, %62 ], [ 0, %56 ], [ 0, %50 ], [ 0, %46 ], [ 0, %40 ], [ 0, %34 ], [ 0, %28 ], [ 0, %23 ], [ 0, %66 ], [ 0, %70 ]
ret i32 %77
}