// File: /workspace/github_c_makefile_star2_O0/mruby-zest[P]osc-bridge/src/schema.c
// Function: match_path
static int match_path(const char *uri, const char *pattern)
{
    if(!pattern)
        return 0;

    //uri_i = pattern_j when uri_i !\in range
    //range = atoi(pattern_j) when \in  range

    while(*uri && *pattern)
    {
        if(*pattern != '[') {
            if(*uri != *pattern)
                return 0;
            uri++;
            pattern++;
        } else {
            pattern++;
            assert(isdigit(*pattern));
            int low = atoi(pattern);
            while(*pattern && isdigit(*pattern))
                pattern++;
            assert(*pattern == ',');
            pattern++;
            int high = atoi(pattern);
            while(*pattern && isdigit(*pattern))
                pattern++;
            assert(*pattern == ']');
            pattern++;

            int real = atoi(uri);
            while(*uri && isdigit(*uri))
                uri++;

            if(real < low || real > high)
                return 0;
        }

    }

    //partial match, but not a complete one
    if(!*pattern && *uri)
        return 0;

    return 1;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
cmpq $0x0, -0x18(%rbp)
jne 0x83a3
movl $0x0, -0x4(%rbp)
jmp 0x8625
jmp 0x83a5
movq -0x10(%rbp), %rax
movsbl (%rax), %ecx
xorl %eax, %eax
cmpl $0x0, %ecx
movb %al, -0x25(%rbp)
je 0x83c6
movq -0x18(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x0, %eax
setne %al
movb %al, -0x25(%rbp)
movb -0x25(%rbp), %al
testb $0x1, %al
jne 0x83d2
jmp 0x8600
movq -0x18(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x5b, %eax
je 0x8419
movq -0x10(%rbp), %rax
movsbl (%rax), %eax
movq -0x18(%rbp), %rcx
movsbl (%rcx), %ecx
cmpl %ecx, %eax
je 0x83fc
movl $0x0, -0x4(%rbp)
jmp 0x8625
movq -0x10(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x10(%rbp)
movq -0x18(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x18(%rbp)
jmp 0x85fb
movq -0x18(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x18(%rbp)
callq 0x22d0
movq (%rax), %rax
movq -0x18(%rbp), %rcx
movsbl (%rcx), %ecx
movslq %ecx, %rcx
movzwl (%rax,%rcx,2), %eax
andl $0x800, %eax            # imm = 0x800
cmpl $0x0, %eax
je 0x8447
jmp 0x8466
leaq 0x447f(%rip), %rdi      # 0xc8cd
leaq 0x448a(%rip), %rsi      # 0xc8df
movl $0x19, %edx
leaq 0x448b(%rip), %rcx      # 0xc8ec
callq 0x2120
movq -0x18(%rbp), %rdi
callq 0x2270
movl %eax, -0x1c(%rbp)
movq -0x18(%rbp), %rax
movsbl (%rax), %ecx
xorl %eax, %eax
cmpl $0x0, %ecx
movb %al, -0x26(%rbp)
je 0x84a7
callq 0x22d0
movq (%rax), %rax
movq -0x18(%rbp), %rcx
movsbl (%rcx), %ecx
movslq %ecx, %rcx
movzwl (%rax,%rcx,2), %eax
andl $0x800, %eax            # imm = 0x800
cmpl $0x0, %eax
setne %al
movb %al, -0x26(%rbp)
movb -0x26(%rbp), %al
testb $0x1, %al
jne 0x84b0
jmp 0x84be
movq -0x18(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x18(%rbp)
jmp 0x8472
movq -0x18(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x2c, %eax
jne 0x84cc
jmp 0x84eb
leaq 0x4444(%rip), %rdi      # 0xc917
leaq 0x4405(%rip), %rsi      # 0xc8df
movl $0x1d, %edx
leaq 0x4406(%rip), %rcx      # 0xc8ec
callq 0x2120
movq -0x18(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rdi
callq 0x2270
movl %eax, -0x20(%rbp)
movq -0x18(%rbp), %rax
movsbl (%rax), %ecx
xorl %eax, %eax
cmpl $0x0, %ecx
movb %al, -0x27(%rbp)
je 0x8538
callq 0x22d0
movq (%rax), %rax
movq -0x18(%rbp), %rcx
movsbl (%rcx), %ecx
movslq %ecx, %rcx
movzwl (%rax,%rcx,2), %eax
andl $0x800, %eax            # imm = 0x800
cmpl $0x0, %eax
setne %al
movb %al, -0x27(%rbp)
movb -0x27(%rbp), %al
testb $0x1, %al
jne 0x8541
jmp 0x854f
movq -0x18(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x18(%rbp)
jmp 0x8503
movq -0x18(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x5d, %eax
jne 0x855d
jmp 0x857c
leaq 0x43c3(%rip), %rdi      # 0xc927
leaq 0x4374(%rip), %rsi      # 0xc8df
movl $0x22, %edx
leaq 0x4375(%rip), %rcx      # 0xc8ec
callq 0x2120
movq -0x18(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x18(%rbp)
movq -0x10(%rbp), %rdi
callq 0x2270
movl %eax, -0x24(%rbp)
movq -0x10(%rbp), %rax
movsbl (%rax), %ecx
xorl %eax, %eax
cmpl $0x0, %ecx
movb %al, -0x28(%rbp)
je 0x85c9
callq 0x22d0
movq (%rax), %rax
movq -0x10(%rbp), %rcx
movsbl (%rcx), %ecx
movslq %ecx, %rcx
movzwl (%rax,%rcx,2), %eax
andl $0x800, %eax            # imm = 0x800
cmpl $0x0, %eax
setne %al
movb %al, -0x28(%rbp)
movb -0x28(%rbp), %al
testb $0x1, %al
jne 0x85d2
jmp 0x85e0
movq -0x10(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x10(%rbp)
jmp 0x8594
movl -0x24(%rbp), %eax
cmpl -0x1c(%rbp), %eax
jl 0x85f0
movl -0x24(%rbp), %eax
cmpl -0x20(%rbp), %eax
jle 0x85f9
movl $0x0, -0x4(%rbp)
jmp 0x8625
jmp 0x85fb
jmp 0x83a5
movq -0x18(%rbp), %rax
cmpb $0x0, (%rax)
jne 0x861e
movq -0x10(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x0, %eax
je 0x861e
movl $0x0, -0x4(%rbp)
jmp 0x8625
movl $0x1, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x30, %rsp
popq %rbp
retq
nop