#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 */
int stb__wildmatch_raw2(char *, char *, int, int);
int /*<<< orphan*/ stb_strncpy(char *, char *, int);
char *strchr(char *, char);
int stb__wildmatch_raw(char *expr, char *candidate, int search,
                       int insensitive) {
  char buffer[256];
  char *s = strchr(expr, ';');
  char *last = expr;
  while (s) {
    int z;
    if (s - last < 256) {
      stb_strncpy(buffer, last, (int)(s - last + 1));
      z = stb__wildmatch_raw2(buffer, candidate, search, insensitive);
    } else {
      *s = 0;
      z = stb__wildmatch_raw2(last, candidate, search, insensitive);
      *s = ';';
    }
    if (z >= 0)
      return z;
    last = s + 1;
    s = strchr(last, ';');
  }
  return stb__wildmatch_raw2(last, candidate, search, insensitive);
}


x86 assembly (clang, -O0):
<stb__wildmatch_raw>:
push   %rbp
mov    %rsp,%rbp
sub    $0x140,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
mov    %ecx,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
mov    $0x3b,%esi
call   1030 <strchr@plt>
mov    %rax,-0x128(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x130(%rbp)
cmpq   $0x0,-0x128(%rbp)
je     1259 <stb__wildmatch_raw+0x129>
mov    -0x128(%rbp),%rax
mov    -0x130(%rbp),%rcx
sub    %rcx,%rax
cmp    $0x100,%rax
jge    11df <stb__wildmatch_raw+0xaf>
lea    -0x120(%rbp),%rdi
mov    -0x130(%rbp),%rsi
mov    -0x128(%rbp),%rax
mov    -0x130(%rbp),%rcx
sub    %rcx,%rax
add    $0x1,%rax
mov    %eax,%edx
call   1040 <stb_strncpy@plt>
lea    -0x120(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x1c(%rbp),%edx
mov    -0x20(%rbp),%ecx
call   1050 <stb__wildmatch_raw2@plt>
mov    %eax,-0x134(%rbp)
jmp    120f <stb__wildmatch_raw+0xdf>
mov    -0x128(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x130(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x1c(%rbp),%edx
mov    -0x20(%rbp),%ecx
call   1050 <stb__wildmatch_raw2@plt>
mov    %eax,-0x134(%rbp)
mov    -0x128(%rbp),%rax
movb   $0x3b,(%rax)
cmpl   $0x0,-0x134(%rbp)
jl     122a <stb__wildmatch_raw+0xfa>
mov    -0x134(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1272 <stb__wildmatch_raw+0x142>
mov    -0x128(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x130(%rbp)
mov    -0x130(%rbp),%rdi
mov    $0x3b,%esi
call   1030 <strchr@plt>
mov    %rax,-0x128(%rbp)
jmp    1169 <stb__wildmatch_raw+0x39>
mov    -0x130(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x1c(%rbp),%edx
mov    -0x20(%rbp),%ecx
call   1050 <stb__wildmatch_raw2@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x140,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<stb__wildmatch_raw>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x108,%rsp
mov    %ecx,%r14d
mov    %edx,%r12d
mov    %rsi,%r13
mov    %rdi,%rbp
mov    $0x3b,%esi
call   1030 <strchr@plt>
test   %rax,%rax
je     11e7 <stb__wildmatch_raw+0xb7>
mov    %rax,%rbx
mov    %rsp,%r15
cs nopw 0x0(%rax,%rax,1)
mov    %rbx,%rdx
sub    %rbp,%rdx
cmp    $0xff,%rdx
jg     11b0 <stb__wildmatch_raw+0x80>
add    $0x1,%edx
mov    %r15,%rdi
mov    %rbp,%rsi
call   1040 <stb_strncpy@plt>
mov    %r15,%rdi
mov    %r13,%rsi
mov    %r12d,%edx
mov    %r14d,%ecx
call   1050 <stb__wildmatch_raw2@plt>
test   %eax,%eax
js     11cb <stb__wildmatch_raw+0x9b>
jmp    11f8 <stb__wildmatch_raw+0xc8>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movb   $0x0,(%rbx)
mov    %rbp,%rdi
mov    %r13,%rsi
mov    %r12d,%edx
mov    %r14d,%ecx
call   1050 <stb__wildmatch_raw2@plt>
movb   $0x3b,(%rbx)
test   %eax,%eax
jns    11f8 <stb__wildmatch_raw+0xc8>
mov    %rbx,%rbp
add    $0x1,%rbp
mov    %rbp,%rdi
mov    $0x3b,%esi
call   1030 <strchr@plt>
mov    %rax,%rbx
test   %rax,%rax
jne    1170 <stb__wildmatch_raw+0x40>
mov    %rbp,%rdi
mov    %r13,%rsi
mov    %r12d,%edx
mov    %r14d,%ecx
call   1050 <stb__wildmatch_raw2@plt>
add    $0x108,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @stb__wildmatch_raw(i8* %0, i8* %1, i32 %2, i32 %3) {
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i32
%9 = alloca i32
%10 = alloca [256 x i8]
%11 = alloca i8*
%12 = alloca i8*
%13 = alloca i32
store i8* %0, i8** %6
store i8* %1, i8** %7
store i32 %2, i32* %8
store i32 %3, i32* %9
%14 = load i8*, i8** %6
%15 = call i8* @strchr(i8* %14, i8 signext 59)
store i8* %15, i8** %11
%16 = load i8*, i8** %6
store i8* %16, i8** %12
br label %17
17: ; preds = %56, %4
%18 = load i8*, i8** %11
%19 = icmp ne i8* %18, null
br i1 %19, label %20, label %61
20: ; preds = %17
%21 = load i8*, i8** %11
%22 = load i8*, i8** %12
%23 = ptrtoint i8* %21 to i64
%24 = ptrtoint i8* %22 to i64
%25 = sub i64 %23, %24
%26 = icmp slt i64 %25, 256
br i1 %26, label %27, label %43
27: ; preds = %20
%28 = getelementptr inbounds [256 x i8], [256 x i8]* %10, i64 0, i64 0
%29 = load i8*, i8** %12
%30 = load i8*, i8** %11
%31 = load i8*, i8** %12
%32 = ptrtoint i8* %30 to i64
%33 = ptrtoint i8* %31 to i64
%34 = sub i64 %32, %33
%35 = add nsw i64 %34, 1
%36 = trunc i64 %35 to i32
%37 = call i32 @stb_strncpy(i8* %28, i8* %29, i32 %36)
%38 = getelementptr inbounds [256 x i8], [256 x i8]* %10, i64 0, i64 0
%39 = load i8*, i8** %7
%40 = load i32, i32* %8
%41 = load i32, i32* %9
%42 = call i32 @stb__wildmatch_raw2(i8* %38, i8* %39, i32 %40, i32 %41)
store i32 %42, i32* %13
br label %51
43: ; preds = %20
%44 = load i8*, i8** %11
store i8 0, i8* %44
%45 = load i8*, i8** %12
%46 = load i8*, i8** %7
%47 = load i32, i32* %8
%48 = load i32, i32* %9
%49 = call i32 @stb__wildmatch_raw2(i8* %45, i8* %46, i32 %47, i32 %48)
store i32 %49, i32* %13
%50 = load i8*, i8** %11
store i8 59, i8* %50
br label %51
51: ; preds = %43, %27
%52 = load i32, i32* %13
%53 = icmp sge i32 %52, 0
br i1 %53, label %54, label %56
54: ; preds = %51
%55 = load i32, i32* %13
store i32 %55, i32* %5
br label %67
56: ; preds = %51
%57 = load i8*, i8** %11
%58 = getelementptr inbounds i8, i8* %57, i64 1
store i8* %58, i8** %12
%59 = load i8*, i8** %12
%60 = call i8* @strchr(i8* %59, i8 signext 59)
store i8* %60, i8** %11
br label %17
61: ; preds = %17
%62 = load i8*, i8** %12
%63 = load i8*, i8** %7
%64 = load i32, i32* %8
%65 = load i32, i32* %9
%66 = call i32 @stb__wildmatch_raw2(i8* %62, i8* %63, i32 %64, i32 %65)
store i32 %66, i32* %5
br label %67
67: ; preds = %61, %54
%68 = load i32, i32* %5
ret i32 %68
}

LLVM IR (-O2):
define i32 @stb__wildmatch_raw(i8* %0, i8* %1, i32 %2, i32 %3) {
%5 = alloca [256 x i8]
%6 = getelementptr inbounds [256 x i8], [256 x i8]* %5, i64 0, i64 0
%7 = tail call i8* @strchr(i8* dereferenceable(1) %0, i8 signext 59)
%8 = icmp eq i8* %7, null
br i1 %8, label %30, label %9
9: ; preds = %4, %26
%10 = phi i8* [ %27, %26 ], [ %0, %4 ]
%11 = phi i8* [ %28, %26 ], [ %7, %4 ]
%12 = ptrtoint i8* %11 to i64
%13 = ptrtoint i8* %10 to i64
%14 = sub i64 %12, %13
%15 = icmp slt i64 %14, 256
br i1 %15, label %16, label %21
16: ; preds = %9
%17 = trunc i64 %14 to i32
%18 = add i32 %17, 1
%19 = call i32 @stb_strncpy(i8* %6, i8* %10, i32 %18)
%20 = call i32 @stb__wildmatch_raw2(i8* %6, i8* %1, i32 %2, i32 %3)
br label %23
21: ; preds = %9
store i8 0, i8* %11
%22 = call i32 @stb__wildmatch_raw2(i8* %10, i8* %1, i32 %2, i32 %3)
store i8 59, i8* %11
br label %23
23: ; preds = %21, %16
%24 = phi i32 [ %20, %16 ], [ %22, %21 ]
%25 = icmp sgt i32 %24, -1
br i1 %25, label %33, label %26
26: ; preds = %23
%27 = getelementptr inbounds i8, i8* %11, i64 1
%28 = call i8* @strchr(i8* %27, i8 signext 59)
%29 = icmp eq i8* %28, null
br i1 %29, label %30, label %9
30: ; preds = %26, %4
%31 = phi i8* [ %0, %4 ], [ %27, %26 ]
%32 = call i32 @stb__wildmatch_raw2(i8* %31, i8* %1, i32 %2, i32 %3)
br label %33
33: ; preds = %23, %30
%34 = phi i32 [ %32, %30 ], [ %24, %23 ]
ret i32 %34
}