// File: /workspace/github_c_makefile_star2_O0/yakushstanislav[P]EagleMQ/src/utils.c
// Function: pattern_match_length
int pattern_match_length(const char *string, int slength, const char *pattern, int plength, int nocase)
{
	while(plength)
	{
		switch(pattern[0])
		{
			case '*':
				while (pattern[1] == '*') {
					pattern++;
					plength--;
				}

				if (plength == 1)
					return 1;

				while(slength)
				{
					if (pattern_match_length(pattern + 1, plength - 1, string, slength, nocase))
						return 1;

					string++;
					slength--;
				}

				return 0;
				break;

			case '?':
				if (slength == 0)
					return 0;

				string++;
				slength--;

				break;

			case '[':
			{
				int not, match;

				pattern++;
				plength--;
				not = pattern[0] == '^';

				if (not) {
					pattern++;
					plength--;
				}

				match = 0;

				while(1) {
					if (pattern[0] == '\\')
					{
						pattern++;
						plength--;

						if (pattern[0] == string[0])
							match = 1;
					} else if (pattern[0] == ']') {
						break;
					} else if (plength == 0) {
						pattern--;
						plength++;
						break;
					} else if (pattern[1] == '-' && plength >= 3) {
						int start = pattern[0];
						int end = pattern[2];
						int c = string[0];

						if (start > end)
						{
							int t = start;
							start = end;
							end = t;
						}

						if (nocase) {
							start = tolower(start);
							end = tolower(end);
							c = tolower(c);
						}

						pattern += 2;
						plength -= 2;

						if (c >= start && c <= end)
							match = 1;
					}
					else
					{
						if (!nocase) {
							if (pattern[0] == string[0])
								match = 1;
						} else {
							if (tolower((int)pattern[0]) == tolower((int)string[0]))
								match = 1;
						}
				}

				pattern++;
				plength--;
			}

			if (not)
				match = !match;

			if (!match)
				return 0;

			string++;
			slength--;

			break;
			}

		case '\\':
			if (plength >= 2) {
				pattern++;
				plength--;
			}

		default:
			if (!nocase) {
				if (pattern[0] != string[0])
					return 0;
			} else {
				if (tolower((int)pattern[0]) != tolower((int)string[0]))
					return 0;
			}

			string++;
			slength--;

			break;
		}

		pattern++;
		plength--;

		if (slength == 0)
		{
			while(*pattern == '*') {
				pattern++;
				plength--;
			}
			break;
		}
	}

	if (plength == 0 && slength == 0)
		return 1;

	return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movq %rdx, -0x20(%rbp)
movl %ecx, -0x24(%rbp)
movl %r8d, -0x28(%rbp)
cmpl $0x0, -0x24(%rbp)
je 0x5ff6
movq -0x20(%rbp), %rax
movsbl (%rax), %eax
movl %eax, -0x44(%rbp)
subl $0x2a, %eax
je 0x5c52
jmp 0x5c25
movl -0x44(%rbp), %eax
subl $0x3f, %eax
je 0x5ce4
jmp 0x5c33
movl -0x44(%rbp), %eax
subl $0x5b, %eax
je 0x5d10
jmp 0x5c41
movl -0x44(%rbp), %eax
subl $0x5c, %eax
je 0x5f28
jmp 0x5f45
jmp 0x5c54
movq -0x20(%rbp), %rax
movsbl 0x1(%rax), %eax
cmpl $0x2a, %eax
jne 0x5c78
movq -0x20(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x20(%rbp)
movl -0x24(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x5c54
cmpl $0x1, -0x24(%rbp)
jne 0x5c8a
movl $0x1, -0x4(%rbp)
jmp 0x6012
jmp 0x5c8c
cmpl $0x0, -0x14(%rbp)
je 0x5cd8
movq -0x20(%rbp), %rdi
addq $0x1, %rdi
movl -0x24(%rbp), %esi
subl $0x1, %esi
movq -0x10(%rbp), %rdx
movl -0x14(%rbp), %ecx
movl -0x28(%rbp), %r8d
callq 0x5bf0
cmpl $0x0, %eax
je 0x5cc1
movl $0x1, -0x4(%rbp)
jmp 0x6012
movq -0x10(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x10(%rbp)
movl -0x14(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0x5c8c
movl $0x0, -0x4(%rbp)
jmp 0x6012
cmpl $0x0, -0x14(%rbp)
jne 0x5cf6
movl $0x0, -0x4(%rbp)
jmp 0x6012
movq -0x10(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x10(%rbp)
movl -0x14(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0x5faf
movq -0x20(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x20(%rbp)
movl -0x24(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x24(%rbp)
movq -0x20(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x5e, %eax
sete %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, -0x2c(%rbp)
cmpl $0x0, -0x2c(%rbp)
je 0x5d55
movq -0x20(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x20(%rbp)
movl -0x24(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x24(%rbp)
movl $0x0, -0x30(%rbp)
movq -0x20(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x5c, %eax
jne 0x5d9b
movq -0x20(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x20(%rbp)
movl -0x24(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x24(%rbp)
movq -0x20(%rbp), %rax
movsbl (%rax), %eax
movq -0x10(%rbp), %rcx
movsbl (%rcx), %ecx
cmpl %ecx, %eax
jne 0x5d96
movl $0x1, -0x30(%rbp)
jmp 0x5ecb
movq -0x20(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x5d, %eax
jne 0x5dac
jmp 0x5ee5
cmpl $0x0, -0x24(%rbp)
jne 0x5dcc
movq -0x20(%rbp), %rax
addq $-0x1, %rax
movq %rax, -0x20(%rbp)
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x5ee5
movq -0x20(%rbp), %rax
movsbl 0x1(%rax), %eax
cmpl $0x2d, %eax
jne 0x5e75
cmpl $0x3, -0x24(%rbp)
jl 0x5e75
movq -0x20(%rbp), %rax
movsbl (%rax), %eax
movl %eax, -0x34(%rbp)
movq -0x20(%rbp), %rax
movsbl 0x2(%rax), %eax
movl %eax, -0x38(%rbp)
movq -0x10(%rbp), %rax
movsbl (%rax), %eax
movl %eax, -0x3c(%rbp)
movl -0x34(%rbp), %eax
cmpl -0x38(%rbp), %eax
jle 0x5e20
movl -0x34(%rbp), %eax
movl %eax, -0x40(%rbp)
movl -0x38(%rbp), %eax
movl %eax, -0x34(%rbp)
movl -0x40(%rbp), %eax
movl %eax, -0x38(%rbp)
cmpl $0x0, -0x28(%rbp)
je 0x5e47
movl -0x34(%rbp), %edi
callq 0x2310
movl %eax, -0x34(%rbp)
movl -0x38(%rbp), %edi
callq 0x2310
movl %eax, -0x38(%rbp)
movl -0x3c(%rbp), %edi
callq 0x2310
movl %eax, -0x3c(%rbp)
movq -0x20(%rbp), %rax
addq $0x2, %rax
movq %rax, -0x20(%rbp)
movl -0x24(%rbp), %eax
subl $0x2, %eax
movl %eax, -0x24(%rbp)
movl -0x3c(%rbp), %eax
cmpl -0x34(%rbp), %eax
jl 0x5e73
movl -0x3c(%rbp), %eax
cmpl -0x38(%rbp), %eax
jg 0x5e73
movl $0x1, -0x30(%rbp)
jmp 0x5ec5
cmpl $0x0, -0x28(%rbp)
jne 0x5e96
movq -0x20(%rbp), %rax
movsbl (%rax), %eax
movq -0x10(%rbp), %rcx
movsbl (%rcx), %ecx
cmpl %ecx, %eax
jne 0x5e94
movl $0x1, -0x30(%rbp)
jmp 0x5ec3
movq -0x20(%rbp), %rax
movsbl (%rax), %edi
callq 0x2310
movl %eax, -0x48(%rbp)
movq -0x10(%rbp), %rax
movsbl (%rax), %edi
callq 0x2310
movl %eax, %ecx
movl -0x48(%rbp), %eax
cmpl %ecx, %eax
jne 0x5ec1
movl $0x1, -0x30(%rbp)
jmp 0x5ec3
jmp 0x5ec5
jmp 0x5ec7
jmp 0x5ec9
jmp 0x5ecb
movq -0x20(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x20(%rbp)
movl -0x24(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x5d5c
cmpl $0x0, -0x2c(%rbp)
je 0x5efc
cmpl $0x0, -0x30(%rbp)
setne %al
xorb $-0x1, %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, -0x30(%rbp)
cmpl $0x0, -0x30(%rbp)
jne 0x5f0e
movl $0x0, -0x4(%rbp)
jmp 0x6012
movq -0x10(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x10(%rbp)
movl -0x14(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0x5faf
cmpl $0x2, -0x24(%rbp)
jl 0x5f43
movq -0x20(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x20(%rbp)
movl -0x24(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x5f45
cmpl $0x0, -0x28(%rbp)
jne 0x5f6b
movq -0x20(%rbp), %rax
movsbl (%rax), %eax
movq -0x10(%rbp), %rcx
movsbl (%rcx), %ecx
cmpl %ecx, %eax
je 0x5f69
movl $0x0, -0x4(%rbp)
jmp 0x6012
jmp 0x5f9a
movq -0x20(%rbp), %rax
movsbl (%rax), %edi
callq 0x2310
movl %eax, -0x4c(%rbp)
movq -0x10(%rbp), %rax
movsbl (%rax), %edi
callq 0x2310
movl %eax, %ecx
movl -0x4c(%rbp), %eax
cmpl %ecx, %eax
je 0x5f98
movl $0x0, -0x4(%rbp)
jmp 0x6012
jmp 0x5f9a
movq -0x10(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x10(%rbp)
movl -0x14(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x14(%rbp)
movq -0x20(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x20(%rbp)
movl -0x24(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x24(%rbp)
cmpl $0x0, -0x14(%rbp)
jne 0x5ff1
jmp 0x5fcc
movq -0x20(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x2a, %eax
jne 0x5fef
movq -0x20(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x20(%rbp)
movl -0x24(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x5fcc
jmp 0x5ff6
jmp 0x5c0a
cmpl $0x0, -0x24(%rbp)
jne 0x600b
cmpl $0x0, -0x14(%rbp)
jne 0x600b
movl $0x1, -0x4(%rbp)
jmp 0x6012
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x50, %rsp
popq %rbp
retq
nopl (%rax,%rax)