// File: /workspace/github_c_makefile_star2_O2/Ziddykins[P]Dawn/src/parse.c
// Function: matches_regex
int matches_regex (char *buf, const char *regular_expression) {
    pcre *regex_compiled;
    pcre_extra *pcre_optimized;
    int pcre_return;
    int pcre_error_offset;
    int substring_vec[30];
    const char *p_sub_str_match_str;
    const char *pcre_error;

    regex_compiled = pcre_compile(regular_expression, PCRE_MULTILINE,
                                  &pcre_error, &pcre_error_offset, NULL);

    if (regex_compiled == NULL) {
        fprintf(stderr, ERR "parse/matches_regex: Could not compile regular expression: %s (%s)\n",
                regular_expression, pcre_error);
        exit(1);
    }

    pcre_optimized = pcre_study(regex_compiled, 0, &pcre_error);

    if (pcre_error != NULL) {
        fprintf(stderr, ERR "parse/matches_regex: Could not optimize regular expression: %s (%s)\n", regular_expression, pcre_error);
        exit(1);
    }

    pcre_return = pcre_exec(regex_compiled, pcre_optimized, buf,
                            (int)strlen(buf), 0, PCRE_NOTEOL, substring_vec, 30);
    pcre_free(regex_compiled);
    pcre_free(pcre_optimized);

    if (pcre_return > 0) {
        int j;
        for (j=0; j<pcre_return; j++) {
            pcre_get_substring(buf, substring_vec, pcre_return, j, &(p_sub_str_match_str));
            strcpy(regex_group[j], p_sub_str_match_str);
            pcre_free_substring(p_sub_str_match_str);
        }
        //We've found a match
        return 1;
    } else {
        //We've not found a match
        return 0;
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x98, %rsp
movq %rsi, %r14
movq %rdi, %rbx
pushq $0x2
popq %rsi
leaq 0x8(%rsp), %rdx
leaq 0x1c(%rsp), %rcx
movq %r14, %rdi
xorl %r8d, %r8d
callq 0x23c0
testq %rax, %rax
je 0xc29f
movq %rax, %r15
movl $0x0, 0x4(%rsp)
leaq 0x8(%rsp), %r13
movq %rax, %rdi
xorl %esi, %esi
movq %r13, %rdx
callq 0x23e0
movq (%r13), %rcx
testq %rcx, %rcx
jne 0xc2b7
movq %rax, %r12
movq %rbx, %rdi
callq 0x20c0
leaq 0x20(%rsp), %r10
movq %r15, %rdi
movq %r12, %rsi
movq %rbx, %rdx
movl %eax, %ecx
xorl %r8d, %r8d
movl $0x100, %r9d            # imm = 0x100
pushq $0x1e
pushq %r10
callq 0x2310
popq %rcx
popq %rdx
movl %eax, %ebp
movq 0x10daf(%rip), %r14     # 0x1cfd0
movq %r15, %rdi
callq *(%r14)
movq %r12, %rdi
callq *(%r14)
testl %ebp, %ebp
jle 0xc289
movl %ebp, %r14d
leaq 0x120a5(%rip), %r15     # 0x1e2e0
xorl %r12d, %r12d
pushq $0x1
popq %rax
movl %eax, 0x4(%rsp)
leaq 0x10(%rsp), %rbp
cmpq %r12, %r14
je 0xc289
movq %rbx, %rdi
leaq 0x20(%rsp), %rsi
movl %r14d, %edx
movl %r12d, %ecx
movq %rbp, %r8
callq 0x2130
movq 0x10(%rsp), %r13
movq %r15, %rdi
movq %r13, %rsi
callq 0x21c0
movq %r13, %rdi
callq 0x21a0
incq %r12
addq $0x190, %r15            # imm = 0x190
jmp 0xc24a
movl 0x4(%rsp), %eax
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x10d32(%rip), %rax     # 0x1cfd8
movq (%rax), %rdi
movq 0x8(%rsp), %rcx
leaq 0xa096(%rip), %rsi      # 0x1634b
jmp 0xc2c8
movq 0x10d1a(%rip), %rax     # 0x1cfd8
movq (%rax), %rdi
leaq 0xa0da(%rip), %rsi      # 0x163a2
movq %r14, %rdx
xorl %eax, %eax
callq 0x2320
pushq $0x1
popq %rdi
callq 0x2270