LLM4Binary/decompile-bench-makefile huggingface dataset:
// File: /workspace/github_cpp_makefile_star2_O1/nilnilnil[P]autocomplete/./include/suggest.hpp
// Function: naive_suggest(PhraseMap&, SegmentTree&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, unsigned int)
vp_t
naive_suggest(PhraseMap& pm, RMQ& st, std::string prefix, uint_t n = 16) {
    pvpi_t phrases = pm.query(prefix);
    std::vector<uint_t> indexes;
    vp_t ret;

    while (phrases.first != phrases.second) {
        indexes.push_back(phrases.first - pm.repr.begin());
        ++phrases.first;
    }

    while (ret.size() < n && !indexes.empty()) {
        uint_t mi = 0;
        for (size_t i = 1; i < indexes.size(); ++i) {
            if (pm.repr[indexes[i]].weight > pm.repr[indexes[mi]].weight) {
                mi = i;
            }
        }
        ret.push_back(pm.repr[indexes[mi]]);
        indexes.erase(indexes.begin() + mi);
    }
    return ret;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movl %r8d, 0x20(%rsp)
movq %rsi, %r14
movq %rdi, %rbx
movq (%rsi), %rdi
movq 0x8(%rsi), %rsi
movq %rcx, %rdx
callq 0xcbab
movq %rax, %r13
xorl %eax, %eax
movq %rax, 0x10(%rsp)
xorps %xmm0, %xmm0
movaps %xmm0, (%rsp)
movq %rax, 0x10(%rbx)
movups %xmm0, (%rbx)
cmpq %rdx, %r13
je 0x71bd
movq %rdx, %r12
leaq 0x24(%rsp), %rbp
movq %r13, %r15
movq %r13, %rax
subq (%r14), %rax
shrq $0x3, %rax
imull $0xb6db6db7, %eax, %eax # imm = 0xB6DB6DB7
movl %eax, 0x24(%rsp)
movq 0x8(%rsp), %rsi
cmpq 0x10(%rsp), %rsi
je 0x71a5
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x8(%rsp)
jmp 0x71b0
movq %rsp, %rdi
movq %rbp, %rdx
callq 0xdfc6
addq $0x38, %r15
addq $0x38, %r13
cmpq %r12, %r15
jne 0x7178
movl 0x20(%rsp), %r15d
movq 0x8(%rbx), %rax
subq (%rbx), %rax
sarq $0x3, %rax
movabsq $0x6db6db6db6db6db7, %r12 # imm = 0x6DB6DB6DB6DB6DB7
imulq %r12, %rax
cmpq %r15, %rax
jae 0x728e
movq (%rsp), %rax
movq 0x8(%rsp), %rcx
cmpq %rcx, %rax
je 0x728e
subq %rax, %rcx
sarq $0x2, %rcx
cmpq $0x2, %rcx
jb 0x7240
movq (%r14), %rdx
xorl %edi, %edi
movl $0x1, %esi
movl (%rax,%rsi,4), %r8d
imulq $0x38, %r8, %r8
movl (%rdx,%r8), %r9d
movl %edi, %r8d
movl (%rax,%r8,4), %r8d
imulq $0x38, %r8, %r10
movl %esi, %r8d
cmpl (%rdx,%r10), %r9d
ja 0x7230
movl %edi, %r8d
incq %rsi
movl %r8d, %edi
cmpq %rsi, %rcx
jne 0x720d
movl %r8d, %r13d
jmp 0x7243
xorl %r13d, %r13d
movl (%rax,%r13,4), %eax
imulq $0x38, %rax, %rsi
addq (%r14), %rsi
movq %rbx, %rdi
callq 0xc11c
movq (%rsp), %rax
movq 0x8(%rsp), %rdx
leaq (%rax,%r13,4), %rsi
addq $0x4, %rsi
cmpq %rdx, %rsi
je 0x7278
leaq (%rax,%r13,4), %rdi
subq %rsi, %rdx
callq 0x5870
addq $-0x4, 0x8(%rsp)
movq 0x8(%rbx), %rax
subq (%rbx), %rax
sarq $0x3, %rax
jmp 0x71d7
movq (%rsp), %rdi
testq %rdi, %rdi
je 0x72a4
movq 0x10(%rsp), %rsi
subq %rdi, %rsi
callq 0x54c0
movq %rbx, %rax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x72b8
movq %rax, %r14
movq %rbx, %rdi
callq 0xc17a
movq (%rsp), %rdi
testq %rdi, %rdi
je 0x72d9
movq 0x10(%rsp), %rsi
subq %rdi, %rsi
callq 0x54c0
movq %r14, %rdi
callq 0x58e0
// File: /workspace/github_cpp_makefile_star2_O1/nilnilnil[P]autocomplete/src/main.cpp
// Function: get_qs(mg_request_info const*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&)
std::string
get_qs(const struct mg_request_info *request_info, std::string const& key) {
    char val[1024];
    std::string rv;

    val[1023] = val[0] = '\0';
    // printf("query string: %s\n", request_info->query_string);

    int val_len = 0;
    if (request_info->query_string) {
        val_len = mg_get_var(request_info->query_string, 
                             strlen(request_info->query_string), 
                             key.c_str(), val, 1023);
        rv = val;
    }
    return rv;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x408, %rsp            # imm = 0x408
movq %rdi, %rbx
leaq 0x10(%rdi), %r12
movq %r12, (%rdi)
movq $0x0, 0x8(%rdi)
xorl %eax, %eax
movb %al, 0x10(%rdi)
movb %al, (%rsp)
movb %al, 0x3ff(%rsp)
movq 0x20(%rsi), %r15
testq %r15, %r15
je 0x8621
movq %rdx, %r14
movq %r15, %rdi
callq 0x5210
movq (%r14), %rdx
movq %rsp, %rcx
movl $0x3ff, %r8d            # imm = 0x3FF
movq %r15, %rdi
movq %rax, %rsi
callq 0xea3c
movq 0x8(%rbx), %r14
movq %rsp, %r15
movq %r15, %rdi
callq 0x5210
movq %rbx, %rdi
xorl %esi, %esi
movq %r14, %rdx
movq %r15, %rcx
movq %rax, %r8
callq 0x57f0
movq %rbx, %rax
addq $0x408, %rsp            # imm = 0x408
popq %rbx
popq %r12
popq %r14
popq %r15
retq
movq %rax, %r14
movq (%rbx), %rdi
cmpq %r12, %rdi
je 0x864a
movq (%r12), %rsi
incq %rsi
callq 0x54c0
movq %r14, %rdi
callq 0x58e0
// File: /workspace/github_cpp_makefile_star2_O1/nilnilnil[P]autocomplete/src/main.cpp
// Function: get_memory_usage(int)
int
get_memory_usage(pid_t pid) {
    char cbuff[4096];
    sprintf(cbuff, "pmap -x %d | tail -n +3 | awk 'BEGIN { S=0;T=0 } { if (match($3, /\\-/)) {S=1} if (S==0) {T+=$3} } END { print T }'", pid);
    FILE *pf = popen(cbuff, "r");
    if (!pf) {
        return -1;
    }
    int r = fread(cbuff, 1, 100, pf);
    if (r < 0) {
        fclose(pf);
        return -1;
    }
    cbuff[r-1] = '\0';
    r = atoi(cbuff);
    fclose(pf);
    return r;
}

// Assembly:
pushq %rbp
pushq %rbx
subq $0x1008, %rsp           # imm = 0x1008
movl %edi, %edx
leaq 0xcb6f(%rip), %rsi      # 0x151d3
movq %rsp, %rbx
movq %rbx, %rdi
xorl %eax, %eax
callq 0x50f0
leaq 0xe30e(%rip), %rsi      # 0x16986
movq %rbx, %rdi
callq 0x5150
testq %rax, %rax
je 0x86c2
movq %rax, %rbx
movq %rsp, %rdi
movl $0x1, %esi
movl $0x64, %edx
movq %rax, %rcx
callq 0x5780
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
testl %eax, %eax
js 0x86b8
decl %eax
cltq
movb $0x0, (%rsp,%rax)
movq %rsp, %rdi
callq 0x5810
movl %eax, %ebp
movq %rbx, %rdi
callq 0x54a0
jmp 0x86c7
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
movl %ebp, %eax
addq $0x1008, %rsp           # imm = 0x1008
popq %rbx
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O1/nilnilnil[P]autocomplete/src/main.cpp
// Function: escape_special_chars(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>&)
void
escape_special_chars(std::string& str) {
    std::string ret;
    ret.reserve(str.size() + 10);
    for (size_t j = 0; j < str.size(); ++j) {
        switch (str[j]) {
        case '"':
            ret += "\\\"";
            break;

        case '\\':
            ret += "\\\\";
            break;

        case '\n':
            ret += "\\n";
            break;

        case '\t':
            ret += "\\t";
            break;

        default:
            ret += str[j];
        }
    }
    ret.swap(str);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rdi, %rbx
leaq 0x18(%rsp), %rax
movq %rax, -0x10(%rax)
movq $0x0, -0x8(%rax)
movb $0x0, (%rax)
movq 0x8(%rdi), %rsi
addq $0xa, %rsi
leaq 0x8(%rsp), %rdi
callq 0x5830
cmpq $0x0, 0x8(%rbx)
je 0x87a1
xorl %r12d, %r12d
leaq 0xcb4b(%rip), %r13      # 0x15284
leaq 0xcb4a(%rip), %r15      # 0x1528a
leaq 0x8(%rsp), %r14
leaq 0xcb3b(%rip), %rbp      # 0x15287
movq (%rbx), %rax
movb (%rax,%r12), %al
movzbl %al, %ecx
cmpl $0x21, %ecx
jg 0x876a
cmpl $0x9, %ecx
je 0x8789
cmpl $0xa, %ecx
jne 0x877c
movq %r15, %rsi
jmp 0x8790
movq %r13, %rsi
cmpl $0x22, %ecx
je 0x8790
cmpl $0x5c, %ecx
jne 0x877c
movq %rbp, %rsi
jmp 0x8790
movsbl %al, %esi
movq %r14, %rdi
callq 0x53f0
jmp 0x8798
leaq 0xcafd(%rip), %rsi      # 0x1528d
movq %r14, %rdi
callq 0x5990
incq %r12
cmpq 0x8(%rbx), %r12
jb 0x874c
leaq 0x8(%rsp), %r14
movq %r14, %rdi
movq %rbx, %rsi
callq 0x5320
movq (%r14), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x87cb
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x54c0
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x87dc
movq %rax, %rbx
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x87fb
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x54c0
movq %rbx, %rdi
callq 0x58e0
// File: /workspace/github_cpp_makefile_star2_O1/nilnilnil[P]autocomplete/src/main.cpp
// Function: show_usage(char**)
void
show_usage(char *argv[]) {
    printf("Usage: %s [OPTION]...\n", basename(argv[0]));
    printf("Start lib-face.\n\n");
    printf("Optional arguments:\n\n");
    printf("-h, --help           This screen\n");
    printf("-f, --file=PATH      Path of the file containing the phrases\n");
    printf("-p, --port=PORT      TCP port on which to start lib-face (default: 6767)\n");
    printf("-s, --sorted         If specified, the input file (PATH) is assumed to be sorted by phrase\n");
    printf("\n");
    printf("Please visit https://code.google.com/p/lib-face/ for more information.\n");
}

// Assembly:
pushq %rax
movq (%rdi), %rdi
callq 0x58d0
leaq 0xa78a(%rip), %rdi      # 0x152e4
movq %rax, %rsi
xorl %eax, %eax
callq 0x5070
leaq 0xaa5c(%rip), %rdi      # 0x155c7
callq 0x57e0
leaq 0xaa61(%rip), %rdi      # 0x155d8
callq 0x57e0
leaq 0xaa6a(%rip), %rdi      # 0x155ed
callq 0x57e0
leaq 0xaa7f(%rip), %rdi      # 0x1560e
callq 0x57e0
leaq 0xaab0(%rip), %rdi      # 0x1564b
callq 0x57e0
leaq 0xaaed(%rip), %rdi      # 0x15694
callq 0x57e0
movl $0xa, %edi
callq 0x56a0
leaq 0xab32(%rip), %rdi      # 0x156ef
popq %rax
jmp 0x57e0
// File: /workspace/github_cpp_makefile_star2_O1/nilnilnil[P]autocomplete/src/main.cpp
// Function: parse_options(int, char**)
void
parse_options(int argc, char *argv[]) {
    int c;

    while (1) {
        int option_index = 0;
        static struct option long_options[] = {
            {"file", 1, 0, 'f'},
            {"port", 1, 0, 'p'},
            {"sorted", 0, 0, 's'},
            {"help", 0, 0, 'h'},
            {0, 0, 0, 0}
        };

        c = getopt_long(argc, argv, "f:p:sh",
                        long_options, &option_index);

        if (c == -1)
            break;

        switch (c) {
        case 0:
        case 'f':
            DCERR("File: "<<optarg<<endl);
            ac_file = optarg;
            break;

        case 'p':
            DCERR("Port: "<<optarg<<" ("<<atoi(optarg)<<")\n");
            port = optarg;
            break;

        case 's':
            DCERR("File is Sorted\n");
            ac_sorted = true;
            break;
          
        case 'h':
            opt_show_help = true;
            break;

        case '?':
            cerr<<"ERROR::Invalid option: "<<optopt<<endl;
            break;
        }
    }


}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rsi, %rbx
movl %edi, %ebp
leaq 0xa732(%rip), %r14      # 0x1530c
leaq 0x1192f(%rip), %r15     # 0x1c510
leaq 0x4(%rsp), %r12
movq 0x113bb(%rip), %r13     # 0x1bfa8
movl $0x0, 0x4(%rsp)
movl %ebp, %edi
movq %rbx, %rsi
movq %r14, %rdx
movq %r15, %rcx
movq %r12, %r8
callq 0x58a0
cmpl $0x67, %eax
jg 0xac1e
cmpl $0x3e, %eax
jle 0xac3e
cmpl $0x3f, %eax
je 0xac53
cmpl $0x66, %eax
je 0xac46
jmp 0xabed
cmpl $0x68, %eax
je 0xacc5
cmpl $0x70, %eax
je 0xacd1
cmpl $0x73, %eax
jne 0xabed
movb $0x1, 0x11d94(%rip)     # 0x1c9d0
jmp 0xabed
testl %eax, %eax
jne 0xace1
movq (%r13), %rax
movq %rax, 0x11d87(%rip)     # 0x1c9d8
jmp 0xabed
movl $0x17, %edx
movq 0x11391(%rip), %r12     # 0x1bff0
movq %r12, %rdi
leaq 0xa6aa(%rip), %rsi      # 0x15313
callq 0x5590
movq 0x1134b(%rip), %rax     # 0x1bfc0
movl (%rax), %esi
movq %r12, %rdi
callq 0x58c0
movq %r15, %r12
movq %r14, %r15
movq %r13, %r14
movq %rax, %r13
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r13, %rdi
movl $0xa, %esi
callq 0x5480
movsbl %al, %esi
movq %r13, %rdi
movq %r14, %r13
movq %r15, %r14
movq %r12, %r15
leaq 0x4(%rsp), %r12
callq 0x5040
movq %rax, %rdi
callq 0x5300
jmp 0xabed
movb $0x1, 0x11d05(%rip)     # 0x1c9d1
jmp 0xabed
movq (%r13), %rax
movq %rax, 0x11824(%rip)     # 0x1c500
jmp 0xabed
cmpl $-0x1, %eax
jne 0xabed
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O1/nilnilnil[P]autocomplete/./include/segtree.hpp
// Function: SegmentTree::initialize(std::vector<unsigned int, std::allocator<unsigned int>> const&)
void initialize(vui_t const& elems) {
        if (elems.empty()) {
            this->initialize(0);
        }
        else {
            this->initialize(elems.size());
            this->_init(0, 0, elems.size() - 1, elems);
        }
    }

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rsi, %r14
movq %rdi, %rbx
movq (%rsi), %rax
movq 0x8(%rsi), %rsi
cmpq %rsi, %rax
je 0xbc16
subq %rax, %rsi
shrq $0x2, %rsi
movq %rbx, %rdi
callq 0xc590
movq 0x8(%r14), %rcx
subq (%r14), %rcx
shrq $0x2, %rcx
decl %ecx
movq %rbx, %rdi
xorl %esi, %esi
xorl %edx, %edx
movq %r14, %r8
addq $0x8, %rsp
popq %rbx
popq %r14
jmp 0xc758
movl $0x0, 0x18(%rbx)
movq (%rbx), %rax
cmpq %rax, 0x8(%rbx)
je 0xbc2a
movq %rax, 0x8(%rbx)
movl $0x4, %esi
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %r14
jmp 0xc5c6
// File: /workspace/github_cpp_makefile_star2_O1/nilnilnil[P]autocomplete/./include/sparsetable.hpp
// Function: SparseTable::query_max(unsigned int, unsigned int)
pui_t
    query_max(uint_t qf, uint_t ql) {
        if (qf >= this->len || ql >= this->len || ql < qf) {
            return make_pair(minus_one, minus_one);
        }

        const int rlen = ql - qf + 1;
        const size_t ti = log2(rlen);
        const size_t f = qf, l = ql + 1 - (1 << ti);

        // cerr<<"query_max("<<qf<<", "<<ql<<"), ti: "<<ti<<", f: "<<f<<", l: "<<l<<endl;
        if (this->repr[ti][f].first > this->repr[ti][l].first) {
            return this->repr[ti][f];
        }
        else {
            return this->repr[ti][l];
        }
    }

// Assembly:
movl %edx, %r8d
movq $-0x1, %rax
subl %esi, %r8d
jb 0xbee2
movl 0x18(%rdi), %ecx
cmpl %esi, %ecx
jbe 0xbee2
cmpl %edx, %ecx
jbe 0xbee2
incl %r8d
xorl %ecx, %ecx
cmpl $0x2, %r8d
jb 0xbeb7
xorl %ecx, %ecx
movl %r8d, %eax
shrl %eax
incl %ecx
cmpl $0x3, %r8d
movl %eax, %r8d
ja 0xbeaa
movl %ecx, %eax
movl $0xffffffff, %r8d       # imm = 0xFFFFFFFF
shll %cl, %r8d
movl %esi, %ecx
addl %r8d, %edx
incl %edx
movq (%rdi), %rsi
leaq (%rax,%rax,2), %rax
movq (%rsi,%rax,8), %rax
movl (%rax,%rcx,8), %esi
cmpl (%rax,%rdx,8), %esi
cmovaq %rcx, %rdx
movq (%rax,%rdx,8), %rax
retq
nop
// File: /workspace/github_cpp_makefile_star2_O1/nilnilnil[P]autocomplete/src/main.cpp
// Function: uint_to_string[abi:cxx11](unsigned int, unsigned int)
inline std::string
uint_to_string(uint_t n, uint_t pad = 0) {
    std::string ret;
    if (!n) {
        ret = "0";
    }
    else {
        while (n) {
            ret.insert(0, 1, ('0' + (n % 10)));
            n /= 10;
        }
    }
    while (pad && ret.size() < pad) {
        ret = "0" + ret;
    }

    return ret;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movl %edx, %ebp
movq %rdi, %rbx
leaq 0x10(%rdi), %rax
movq %rax, (%rsp)
movq %rax, (%rdi)
movq $0x0, 0x8(%rdi)
movb $0x0, 0x10(%rdi)
testl %esi, %esi
je 0xc350
movl %esi, %r14d
movl $0xcccccccd, %r15d      # imm = 0xCCCCCCCD
movl %r14d, %r12d
imulq %r15, %r12
shrq $0x23, %r12
leal (%r12,%r12), %eax
leal (%rax,%rax,4), %eax
movl %r14d, %ecx
subl %eax, %ecx
orb $0x30, %cl
movzbl %cl, %ecx
movl $0x1, %edx
movq %rbx, %rdi
xorl %esi, %esi
callq 0x59d0
cmpl $0x9, %r14d
movl %r12d, %r14d
ja 0xc319
jmp 0xc369
leaq 0x9b17(%rip), %rcx      # 0x15e6e
movl $0x1, %r8d
movq %rbx, %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x57f0
testl %ebp, %ebp
je 0xc3c1
movl %ebp, %r13d
cmpq %r13, 0x8(%rbx)
jae 0xc3c1
leaq 0x18(%rsp), %r12
leaq 0x9aec(%rip), %r14      # 0x15e6e
leaq 0x8(%rsp), %r15
movq %r15, %rdi
movq %r14, %rsi
movq %rbx, %rdx
callq 0xc25a
movq %rbx, %rdi
movq %r15, %rsi
callq 0x5620
movq 0x8(%rsp), %rdi
cmpq %r12, %rdi
je 0xc3b7
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x54c0
testl %ebp, %ebp
je 0xc3c1
cmpq %r13, 0x8(%rbx)
jb 0xc387
movq %rbx, %rax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0xc3d7
jmp 0xc3d7
movq %rax, %r14
movq (%rbx), %rdi
cmpq (%rsp), %rdi
je 0xc3f2
movq (%rsp), %rax
movq (%rax), %rsi
incq %rsi
callq 0x54c0
movq %r14, %rdi
callq 0x58e0
// File: /workspace/github_cpp_makefile_star2_O1/nilnilnil[P]autocomplete/./include/segtree.hpp
// Function: SegmentTree::_init(unsigned int, unsigned int, unsigned int, std::vector<unsigned int, std::allocator<unsigned int>> const&)
pui_t
    _init(uint_t ni, uint_t b, uint_t e, vui_t const& elems) {
        // printf("ni: %u, b: %u, e: %u, size: %u\n", ni, b, e, elems.size());

        uint_t m = b + (e-b) / 2;
        if (b == e) {
            this->repr[ni] = pui_t(elems[b], b);
            // printf("Returning: [%u, %u]\n", this->repr[ni].first, this->repr[ni].second);
            return this->repr[ni];
        }
        else {
            pui_t lhs = this->_init(ni*2 + 1, b, m, elems);
            pui_t rhs = this->_init(ni*2 + 2, m+1, e, elems);
            return this->repr[ni] = (lhs.first > rhs.first ? lhs : rhs);
        }
    }

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl %edx, %ebx
movl %esi, %r15d
movq %rdi, %r14
movl %ecx, %r12d
subl %edx, %r12d
jne 0xc789
movl %ebx, %eax
movq (%r8), %rcx
movl (%rcx,%rax,4), %ecx
movl %r15d, %eax
movq (%r14), %rdx
leaq (%rdx,%rax,8), %rax
movl %ecx, (%rax)
jmp 0xc7e7
movl %ecx, %ebp
shrl %r12d
leal (%r12,%rbx), %ecx
leal 0x1(,%r15,2), %esi
movq %r14, %rdi
movl %ebx, %edx
movq %r8, (%rsp)
callq 0xc758
movq %rax, %r13
leal 0x2(,%r15,2), %esi
leal (%r12,%rbx), %edx
incl %edx
movq %r14, %rdi
movl %ebp, %ecx
movq (%rsp), %r8
callq 0xc758
movq %rax, %rbx
cmpl %ebx, %r13d
movl %r15d, %eax
movq (%r14), %rcx
leaq (%rcx,%rax,8), %rax
movl %ebx, %ecx
cmoval %r13d, %ecx
movl %ecx, (%rax)
cmovaq %r13, %rbx
shrq $0x20, %rbx
movl %ebx, 0x4(%rax)
movq (%rax), %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O1/nilnilnil[P]autocomplete/./include/segtree.hpp
// Function: SegmentTree::_query_max(unsigned int, unsigned int, unsigned int, unsigned int, unsigned int)
pui_t
    _query_max(uint_t ni, uint_t b, uint_t e, uint_t qf, uint_t ql) {
        // printf("_query_max(%u, %u, %u, %u, %u)\n", ni, b, e, qf, ql);
        if (b > e || qf > e || ql < b) {
            // printf("[1] Returning: (-1, -1)\n");
            return pui_t(minus_one, minus_one);
        }

        if (b >= qf && e <= ql) {
            // printf("[2] Returning: (%d, %d)\n", this->repr[ni].first, this->repr[ni].second);
            return this->repr[ni];
        }

        uint_t m = b + (e-b) / 2;
        pui_t lhs = this->_query_max(ni*2 + 1, b, m, qf, ql);
        pui_t rhs = this->_query_max(ni*2 + 2, m+1, e, qf, ql);

        // printf("lhs.second is minus_one: %d, rhs.second is minus_one: %d\n", lhs.second == minus_one, rhs.second == minus_one);

        if (lhs.second == minus_one) {
            // printf("[3] Returning: (%d, %d)\n", rhs.first, rhs.second);
            return rhs;
        }
        else if (rhs.second == minus_one) {
            // printf("[4] Returning: (%d, %d)\n", lhs.first, lhs.second);
            return lhs;
        }
        else {
            pui_t &tmp = lhs.first > rhs.first ? lhs : rhs;
            // printf("[5] Returning: (%d, %d)\n", tmp.first, tmp.second);
            return tmp;
        }

    }

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movl %ecx, %r14d
movl %edx, %r12d
movl %esi, %r13d
movabsq $-0x100000000, %rsi     # imm = 0xFFFFFFFF00000000
movl %ecx, %r15d
subl %edx, %r15d
setb %al
cmpl %ecx, %r8d
seta %cl
cmpl %edx, %r9d
setb %dl
orb %al, %dl
orb %cl, %dl
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
jne 0xc8d1
movl %r9d, %ebx
movl %r8d, %ebp
cmpl %r8d, %r12d
setb %al
cmpl %r9d, %r14d
seta %cl
orb %al, %cl
je 0xc8c4
shrl %r15d
leal (%r15,%r12), %ecx
leal 0x1(,%r13,2), %esi
movq %rdi, 0x10(%rsp)
movl %r12d, %edx
movl %ebp, %r8d
movl %ebx, %r9d
callq 0xc7fc
movq %rax, 0x8(%rsp)
leal 0x2(,%r13,2), %esi
leal (%r15,%r12), %edx
incl %edx
movq 0x10(%rsp), %rdi
movl %r14d, %ecx
movl %ebp, %r8d
movl %ebx, %r9d
callq 0xc7fc
movq 0x8(%rsp), %rdx
movabsq $-0x100000000, %rsi     # imm = 0xFFFFFFFF00000000
leaq -0x1(%rsi), %rcx
cmpq %rcx, %rdx
ja 0xc8ce
cmpq %rcx, %rax
jbe 0xc8e5
andq %rdx, %rsi
movq %rdx, %rax
jmp 0xc8d1
movl %r13d, %eax
movq (%rdi), %rcx
movq (%rcx,%rax,8), %rax
andq %rax, %rsi
movl %eax, %eax
orq %rsi, %rax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
cmpl %eax, %edx
cmovaq %rdx, %rax
jmp 0xc8ce
nop
// File: /workspace/github_cpp_makefile_star2_O1/nilnilnil[P]autocomplete/deps/mongoose/mongoose.c
// Function: get_option_index
static int get_option_index(const char *name) {
  int i;

  for (i = 0; config_options[i] != NULL; i += ENTRIES_PER_CONFIG_OPTION) {
    if (strcmp(config_options[i], name) == 0 ||
        strcmp(config_options[i + 1], name) == 0) {
      return i / ENTRIES_PER_CONFIG_OPTION;
    }
  }
  return -1;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %r14
movq 0xdfb6(%rip), %rdi      # 0x1c5c0
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
testq %rdi, %rdi
je 0xe65b
xorl %r15d, %r15d
leaq 0xdfa2(%rip), %r12      # 0x1c5c0
movq %r14, %rsi
callq 0x56b0
testl %eax, %eax
je 0xe64b
movq 0x8(%r12,%r15,8), %rdi
movq %r14, %rsi
callq 0x56b0
testl %eax, %eax
je 0xe64b
movq 0x18(%r12,%r15,8), %rdi
addq $0x3, %r15
testq %rdi, %rdi
jne 0xe61e
jmp 0xe65b
movl %r15d, %eax
movl $0xaaaaaaab, %ebx       # imm = 0xAAAAAAAB
imulq %rax, %rbx
shrq $0x21, %rbx
movl %ebx, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
// File: /workspace/github_cpp_makefile_star2_O1/nilnilnil[P]autocomplete/deps/mongoose/mongoose.c
// Function: get_header
static const char *get_header(const struct mg_request_info *ri,
                              const char *name) {
  int i;

  for (i = 0; i < ri->num_headers; i++)
    if (!mg_strcasecmp(name, ri->http_headers[i].name))
      return ri->http_headers[i].value;

  return NULL;
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movslq 0x4c(%rdi), %r15
testq %r15, %r15
jle 0xe6db
movq %rsi, %rbx
movq %rdi, %r14
addq $0x50, %r14
callq 0x50e0
movq (%rax), %rcx
xorl %eax, %eax
xorl %edx, %edx
movq %rdx, %rdi
shlq $0x4, %rdi
leaq (%r14,%rdi), %rsi
movq (%r14,%rdi), %rdi
xorl %r8d, %r8d
movzbl (%rbx,%r8), %r11d
movl (%rcx,%r11,4), %r9d
movzbl (%rdi,%r8), %r10d
movl (%rcx,%r10,4), %r10d
testl %r11d, %r11d
je 0xe6cc
incq %r8
cmpl %r10d, %r9d
je 0xe6ad
cmpl %r10d, %r9d
je 0xe6df
incq %rdx
cmpq %r15, %rdx
jne 0xe69b
jmp 0xe6e3
xorl %eax, %eax
jmp 0xe6e3
movq 0x8(%rsi), %rax
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_cpp_makefile_star2_O1/nilnilnil[P]autocomplete/deps/mongoose/mongoose.c
// Function: mg_read
int mg_read(struct mg_connection *conn, void *buf, size_t len) {
  int n, buffered_len, nread;
  const char *buffered;

  assert((conn->content_len == -1 && conn->consumed_content == 0) ||
         conn->consumed_content <= conn->content_len);
  DEBUG_TRACE(("%p %zu %lld %lld", buf, len,
               conn->content_len, conn->consumed_content));
  nread = 0;
  if (conn->consumed_content < conn->content_len) {

    // Adjust number of bytes to read.
    int64_t to_read = conn->content_len - conn->consumed_content;
    if (to_read < (int64_t) len) {
      len = (int) to_read;
    }

    // How many bytes of data we have buffered in the request buffer?
    buffered = conn->buf + conn->request_len + conn->consumed_content;
    buffered_len = conn->data_len - conn->request_len;
    assert(buffered_len >= 0);

    // Return buffered data back if we haven't done that yet.
    if (conn->consumed_content < (int64_t) buffered_len) {
      buffered_len -= (int) conn->consumed_content;
      if (len < (size_t) buffered_len) {
        buffered_len = len;
      }
      memcpy(buf, buffered, (size_t)buffered_len);
      len -= buffered_len;
      buf = (char *) buf + buffered_len;
      conn->consumed_content += buffered_len;
      nread = buffered_len;
    }

    // We have returned all buffered data. Read new data from the remote socket.
    while (len > 0) {
      n = pull(NULL, conn->client.sock, conn->ssl, (char *) buf, (int) len);
      if (n <= 0) {
        break;
      }
      buf = (char *) buf + n;
      conn->consumed_content += n;
      nread += n;
      len -= n;
    }
  }
  return nread;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
movq 0x4b8(%rdi), %rcx
movq 0x4c0(%rdi), %rax
xorl %r12d, %r12d
subq %rax, %rcx
jle 0xe7b1
movq %rsi, %rbx
movq %rdi, %r14
cmpq %rdx, %rcx
movslq %ecx, %r15
cmovgeq %rdx, %r15
movslq 0x4d4(%rdi), %rsi
movslq 0x4d8(%rdi), %rcx
subq %rsi, %rcx
xorl %r12d, %r12d
cmpq %rcx, %rax
jge 0xe766
addq 0x4c8(%r14), %rsi
addq %rax, %rsi
subl %eax, %ecx
movslq %ecx, %r12
cmpq %r12, %r15
cmovbl %r15d, %r12d
movslq %r12d, %r13
movq %rbx, %rdi
movq %r13, %rdx
callq 0x53b0
subq %r13, %r15
addq %r13, %rbx
addq %r13, 0x4c0(%r14)
testq %r15, %r15
je 0xe7b1
movq 0x460(%r14), %rdi
testq %rdi, %rdi
je 0xe785
movq %rbx, %rsi
movl %r15d, %edx
callq *0xe095(%rip)           # 0x1c818
jmp 0xe799
movl 0x470(%r14), %edi
movslq %r15d, %rdx
movq %rbx, %rsi
xorl %ecx, %ecx
callq 0x5180
testl %eax, %eax
jle 0xe7b1
movl %eax, %ecx
addq %rcx, 0x4c0(%r14)
addq %rcx, %rbx
addl %eax, %r12d
subq %rcx, %r15
jne 0xe76b
movl %r12d, %eax
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
// File: /workspace/github_cpp_makefile_star2_O1/nilnilnil[P]autocomplete/deps/mongoose/mongoose.c
// Function: pull
static int pull(FILE *fp, SOCKET sock, SSL *ssl, char *buf, int len) {
  int nread;

  if (ssl != NULL) {
    nread = SSL_read(ssl, buf, len);
  } else if (fp != NULL) {
    // Use read() instead of fread(), because if we're reading from the CGI
    // pipe, fread() may block until IO buffer is filled up. We cannot afford
    // to block and must pass all read bytes immediately to the client.
    nread = read(fileno(fp), buf, (size_t) len);
    if (ferror(fp))
      nread = -1;
  } else {
    nread = recv(sock, buf, (size_t) len, 0);
  }

  return nread;
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
movl %r8d, %ebp
movq %rcx, %rbx
testq %rdx, %rdx
je 0xe7e2
movq 0xe044(%rip), %rax      # 0x1c818
movq %rdx, %rdi
movq %rbx, %rsi
movl %ebp, %edx
popq %rbx
popq %r14
popq %rbp
jmpq *%rax
movq %rdi, %r14
testq %rdi, %rdi
je 0xe816
movq %r14, %rdi
callq 0x54f0
movslq %ebp, %rdx
movl %eax, %edi
movq %rbx, %rsi
callq 0x5700
movq %rax, %rbx
movq %r14, %rdi
callq 0x5960
movl %eax, %ecx
xorl %eax, %eax
negl %ecx
sbbl %eax, %eax
orl %ebx, %eax
jmp 0xe825
movslq %ebp, %rdx
movl %esi, %edi
movq %rbx, %rsi
xorl %ecx, %ecx
callq 0x5180
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O1/nilnilnil[P]autocomplete/deps/mongoose/mongoose.c
// Function: push
static int64_t push(FILE *fp, SOCKET sock, SSL *ssl, const char *buf,
                    int64_t len) {
  int64_t sent;
  int n, k;

  sent = 0;
  while (sent < len) {

    /* How many bytes we send in this iteration */
    k = len - sent > INT_MAX ? INT_MAX : (int) (len - sent);

    if (ssl != NULL) {
      n = SSL_write(ssl, buf + sent, k);
    } else if (fp != NULL) {
      n = fwrite(buf + sent, 1, (size_t)k, fp);
      if (ferror(fp))
        n = -1;
    } else {
      n = send(sock, buf + sent, (size_t)k, 0);
    }

    if (n < 0)
      break;

    sent += n;
  }

  return sent;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl %esi, 0x4(%rsp)
xorl %ebx, %ebx
testq %r8, %r8
jle 0xe8eb
movq %r8, %r14
movq %rcx, %r15
movq %rdx, %r12
movq %rdi, %rbp
movl $0x7fffffff, %r13d      # imm = 0x7FFFFFFF
movq %r14, %rdx
subq %rbx, %rdx
cmpq %r13, %rdx
cmovgeq %r13, %rdx
testq %r12, %r12
je 0xe88e
leaq (%r15,%rbx), %rsi
movq %r12, %rdi
callq *0xdf9c(%rip)           # 0x1c828
jmp 0xe8dd
leaq (%r15,%rbx), %rax
movslq %edx, %rdx
testq %rbp, %rbp
je 0xe8cf
movl $0x1, %esi
movq %rax, %rdi
movq %rbp, %rcx
callq 0x59b0
movq %r15, %r13
movq %rax, %r15
movq %rbp, %rdi
callq 0x5960
negl %eax
movl $0x0, %eax
sbbl %eax, %eax
orl %r15d, %eax
movq %r13, %r15
movl $0x7fffffff, %r13d      # imm = 0x7FFFFFFF
jmp 0xe8dd
movl 0x4(%rsp), %edi
movq %rax, %rsi
xorl %ecx, %ecx
callq 0x5250
testl %eax, %eax
js 0xe8eb
movl %eax, %eax
addq %rax, %rbx
cmpq %r14, %rbx
jl 0xe86d
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O1/nilnilnil[P]autocomplete/deps/mongoose/mongoose.c
// Function: mg_printf
int mg_printf(struct mg_connection *conn, const char *fmt, ...) {
  char buf[BUFSIZ];
  int len;
  va_list ap;

  va_start(ap, fmt);
  len = mg_vsnprintf(conn, buf, sizeof(buf), fmt, ap);
  va_end(ap);

  return mg_write(conn, buf, (size_t)len);
}

// Assembly:
pushq %r14
pushq %rbx
subq $0x20d8, %rsp           # imm = 0x20D8
movq %rsi, %r10
movq %rdi, %rbx
leaq 0x20(%rsp), %rsi
movq %rdx, 0x10(%rsi)
movq %rcx, 0x18(%rsi)
movq %r8, 0x20(%rsi)
movq %r9, 0x28(%rsi)
testb %al, %al
je 0xe95d
movaps %xmm0, 0x50(%rsp)
movaps %xmm1, 0x60(%rsp)
movaps %xmm2, 0x70(%rsp)
movaps %xmm3, 0x80(%rsp)
movaps %xmm4, 0x90(%rsp)
movaps %xmm5, 0xa0(%rsp)
movaps %xmm6, 0xb0(%rsp)
movaps %xmm7, 0xc0(%rsp)
movq %rsp, %r8
movq %rsi, 0x10(%r8)
leaq 0x20f0(%rsp), %rax
movq %rax, 0x8(%r8)
movabsq $0x3000000010, %rax     # imm = 0x3000000010
movq %rax, (%r8)
leaq 0xd0(%rsp), %r14
movl $0x2000, %edx           # imm = 0x2000
movq %r14, %rsi
movq %r10, %rcx
callq 0xe9ba
movslq %eax, %r8
movl 0x470(%rbx), %esi
movq 0x460(%rbx), %rdx
xorl %edi, %edi
movq %r14, %rcx
callq 0xe841
addq $0x20d8, %rsp           # imm = 0x20D8
popq %rbx
popq %r14
retq
// File: /workspace/github_cpp_makefile_star2_O1/nilnilnil[P]autocomplete/deps/mongoose/mongoose.c
// Function: mg_vsnprintf
static int mg_vsnprintf(struct mg_connection *conn, char *buf, size_t buflen,
                        const char *fmt, va_list ap) {
  int n;

  if (buflen == 0)
    return 0;

  n = vsnprintf(buf, buflen, fmt, ap);

  if (n < 0) {
    cry(conn, "vsnprintf error");
    n = 0;
  } else if (n >= (int) buflen) {
    cry(conn, "truncating vsnprintf buffer: [%.*s]",
        n > 200 ? 200 : n, buf);
    n = (int) buflen - 1;
  }
  buf[n] = '\0';

  return n;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
testq %rdx, %rdx
je 0xea11
movq %rdx, %r14
movq %rsi, %rbx
movq %rdi, %r15
movq %rsi, %rdi
movq %rdx, %rsi
movq %rcx, %rdx
movq %r8, %rcx
callq 0x52c0
testl %eax, %eax
js 0xea15
movl %eax, %ebp
cmpl %r14d, %eax
jl 0xea28
movl $0xc8, %edx
cmpl %edx, %ebp
cmovll %ebp, %edx
leaq 0x70eb(%rip), %rsi      # 0x15ae7
movq %r15, %rdi
movq %rbx, %rcx
xorl %eax, %eax
callq 0xfc79
decl %r14d
movl %r14d, %ebp
jmp 0xea28
xorl %ebp, %ebp
jmp 0xea2f
leaq 0x70bb(%rip), %rsi      # 0x15ad7
xorl %ebp, %ebp
movq %r15, %rdi
xorl %eax, %eax
callq 0xfc79
movslq %ebp, %rax
movb $0x0, (%rbx,%rax)
movl %ebp, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O1/nilnilnil[P]autocomplete/deps/mongoose/mongoose.c
// Function: mg_get_var
int mg_get_var(const char *buf, size_t buf_len, const char *name,
               char *dst, size_t dst_len) {
  const char *p, *e, *s;
  size_t name_len, len;

  name_len = strlen(name);
  e = buf + buf_len;
  len = -1;
  dst[0] = '\0';

  // buf is "var1=val1&var2=val2...". Find variable first
  for (p = buf; p != NULL && p + name_len < e; p++) {
    if ((p == buf || p[-1] == '&') && p[name_len] == '=' &&
        !mg_strncasecmp(name, p, name_len)) {

      // Point p to variable value
      p += name_len + 1;

      // Point s to the end of the value
      s = (const char *) memchr(p, '&', (size_t)(e - p));
      if (s == NULL) {
        s = e;
      }
      assert(s >= p);

      // Decode variable into destination buffer
      if ((size_t) (s - p) < dst_len) {
        len = url_decode(p, (size_t)(s - p), dst, dst_len, 1);
      }
      break;
    }
  }

  return len;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %r8, %r15
movq %rcx, %r12
movq %rdx, %rbx
movq %rsi, %r13
movq %rdi, %r14
movq %rdx, %rdi
callq 0x5210
movq %rax, %rbp
movb $0x0, (%r12)
testq %r14, %r14
setne %al
cmpq %r13, %rbp
setl %cl
andb %al, %cl
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
cmpb $0x1, %cl
jne 0xead5
movq %r12, (%rsp)
movq %r15, 0x10(%rsp)
movq %r13, 0x8(%rsp)
leaq (%r14,%r13), %r15
leaq (%r14,%rbp), %r12
xorl %r13d, %r13d
testq %r13, %r13
je 0xeaa7
cmpb $0x26, -0x1(%r14,%r13)
jne 0xeac1
cmpb $0x3d, (%r12,%r13)
jne 0xeac1
leaq (%r14,%r13), %rsi
movq %rbx, %rdi
movq %rbp, %rdx
callq 0xeb3c
testl %eax, %eax
je 0xeae4
leaq (%r12,%r13), %rax
incq %rax
incq %r13
cmpq %r15, %rax
jb 0xea9a
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq (%r12,%r13), %rbx
incq %rbx
notq %rbp
addq 0x8(%rsp), %rbp
subq %r13, %rbp
movq %rbx, %rdi
movl $0x26, %esi
movq %rbp, %rdx
callq 0x5540
testq %rax, %rax
cmovneq %rax, %r15
notq %r12
addq %r15, %r12
subq %r13, %r12
movq 0x10(%rsp), %rcx
cmpq %rcx, %r12
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
jae 0xead5
movq %rbx, %rdi
movq %r12, %rsi
movq (%rsp), %rdx
movl $0x1, %r8d
callq 0xeb8a
jmp 0xead5
// File: /workspace/github_cpp_makefile_star2_O1/nilnilnil[P]autocomplete/deps/mongoose/mongoose.c
// Function: mg_strncasecmp
static int mg_strncasecmp(const char *s1, const char *s2, size_t len) {
  int diff = 0;

  if (len > 0)
    do {
      diff = lowercase(s1++) - lowercase(s2++);
    } while (diff == 0 && s1[-1] != '\0' && --len > 0);

  return diff;
}

// Assembly:
testq %rdx, %rdx
je 0xeb87
pushq %r15
pushq %r14
pushq %rbx
movq %rdx, %rbx
movq %rsi, %r14
movq %rdi, %r15
callq 0x50e0
movq (%rax), %rcx
decq %rbx
xorl %edx, %edx
movzbl (%r15,%rdx), %esi
movl (%rcx,%rsi,4), %eax
movzbl (%r14,%rdx), %edi
subl (%rcx,%rdi,4), %eax
jne 0xeb81
xorl %eax, %eax
testb %sil, %sil
je 0xeb81
leaq 0x1(%rdx), %rsi
cmpq %rdx, %rbx
movq %rsi, %rdx
jne 0xeb5c
popq %rbx
popq %r14
popq %r15
retq
xorl %eax, %eax
retq
// File: /workspace/github_cpp_makefile_star2_O1/nilnilnil[P]autocomplete/deps/mongoose/mongoose.c
// Function: url_decode
static size_t url_decode(const char *src, size_t src_len, char *dst,
                         size_t dst_len, int is_form_url_encoded) {
  size_t i, j;
  int a, b;
#define HEXTOI(x) (isdigit(x) ? x - '0' : x - 'W')

  for (i = j = 0; i < src_len && j < dst_len - 1; i++, j++) {
    if (src[i] == '%' &&
        isxdigit(* (const unsigned char *) (src + i + 1)) &&
        isxdigit(* (const unsigned char *) (src + i + 2))) {
      a = tolower(* (const unsigned char *) (src + i + 1));
      b = tolower(* (const unsigned char *) (src + i + 2));
      dst[j] = (char) ((HEXTOI(a) << 4) | HEXTOI(b));
      i += 2;
    } else if (is_form_url_encoded && src[i] == '+') {
      dst[j] = ' ';
    } else {
      dst[j] = src[i];
    }
  }

  dst[j] = '\0'; /* Null-terminate the destination */

  return j;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movl %r8d, 0xc(%rsp)
movq %rdx, (%rsp)
movq %rsi, 0x20(%rsp)
testq %rsi, %rsi
sete %al
decq %rcx
movq %rcx, 0x18(%rsp)
sete %cl
orb %al, %cl
jne 0xec87
xorl %ebp, %ebp
xorl %r13d, %r13d
movq %rdi, 0x10(%rsp)
movb (%rdi,%rbp), %r15b
cmpb $0x25, %r15b
jne 0xebfc
callq 0x5520
movq 0x10(%rsp), %rcx
movq (%rax), %rbx
movzbl 0x1(%rcx,%rbp), %r14d
testb $0x10, 0x1(%rbx,%r14,2)
je 0xebfc
movzbl 0x2(%rcx,%rbp), %r12d
testb $0x10, 0x1(%rbx,%r12,2)
jne 0xec1e
cmpl $0x0, 0xc(%rsp)
je 0xec14
cmpb $0x2b, %r15b
jne 0xec14
movq (%rsp), %rax
movb $0x20, (%rax,%r13)
jmp 0xec68
movq (%rsp), %rax
movb %r15b, (%rax,%r13)
jmp 0xec68
callq 0x50e0
movq (%rax), %rax
movslq (%rax,%r14,4), %rcx
movslq (%rax,%r12,4), %rax
movzwl (%rbx,%rcx,2), %edx
xorl %esi, %esi
btl $0xb, %edx
setae %sil
leal (%rsi,%rsi,8), %edx
addl %ecx, %edx
shll $0x4, %edx
movzwl (%rbx,%rax,2), %ecx
leal 0xd0(%rax), %esi
addl $0xa9, %eax
btl $0xb, %ecx
cmovbl %esi, %eax
orl %edx, %eax
movq (%rsp), %rcx
movb %al, (%rcx,%r13)
addq $0x2, %rbp
incq %rbp
incq %r13
cmpq 0x20(%rsp), %rbp
jae 0xec8a
cmpq 0x18(%rsp), %r13
movq 0x10(%rsp), %rdi
jb 0xebc9
jmp 0xec8a
xorl %r13d, %r13d
movq (%rsp), %rax
movb $0x0, (%rax,%r13)
movq %r13, %rax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O1/nilnilnil[P]autocomplete/deps/mongoose/mongoose.c
// Function: mg_get_cookie
int mg_get_cookie(const struct mg_connection *conn, const char *cookie_name,
                  char *dst, size_t dst_size) {
  const char *s, *p, *end;
  int name_len, len = -1;

  dst[0] = '\0';
  if ((s = mg_get_header(conn, "Cookie")) == NULL) {
    return 0;
  }

  name_len = strlen(cookie_name);
  end = s + strlen(s);

  for (; (s = strstr(s, cookie_name)) != NULL; s += name_len)
    if (s[name_len] == '=') {
      s += name_len + 1;
      if ((p = strchr(s, ' ')) == NULL)
        p = end;
      if (p[-1] == ';')
        p--;
      if (*s == '"' && p[-1] == '"' && p > s + 1) {
        s++;
        p--;
      }
      if ((size_t) (p - s) < dst_size) {
        len = (p - s) + 1;
        mg_strlcpy(dst, s, (size_t)len);
      }
      break;
    }

  return len;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rcx, %r12
movq %rdx, %rbx
movq %rsi, %r15
movb $0x0, (%rdx)
addq $0x8, %rdi
leaq 0x6aa2(%rip), %rsi      # 0x1576c
callq 0xe677
testq %rax, %rax
je 0xed98
movq %rax, %r14
movq %r12, (%rsp)
movq %r15, %rdi
callq 0x5210
movq %rax, %r13
movq %r14, %rdi
callq 0x5210
addq %r14, %rax
movq %rax, 0x10(%rsp)
movq %r13, %rax
shlq $0x20, %rax
movq %rax, 0x8(%rsp)
movslq %r13d, %r12
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
movq %r14, %rdi
movq %r15, %rsi
callq 0x5100
testq %rax, %rax
je 0xede0
movq %rax, %r13
leaq (%rax,%r12), %r14
cmpb $0x3d, (%rax,%r12)
jne 0xed0e
movabsq $0x100000000, %rax      # imm = 0x100000000
movq 0x8(%rsp), %r14
addq %rax, %r14
sarq $0x20, %r14
movq %r13, %r15
addq %r14, %r15
movq %r15, %rdi
movl $0x20, %esi
callq 0x51e0
testq %rax, %rax
movq 0x10(%rsp), %rcx
cmovneq %rax, %rcx
leaq -0x1(%rcx), %rax
cmpb $0x3b, -0x1(%rcx)
cmovneq %rcx, %rax
cmpb $0x22, (%r13,%r14)
jne 0xed9c
cmpb $0x22, -0x1(%rax)
movq (%rsp), %rsi
jne 0xeda0
leaq -0x1(%rax), %rcx
leaq 0x1(%r15), %rdx
cmpq %rdx, %rax
cmovaq %rcx, %rax
cmovaq %rdx, %r15
jmp 0xeda0
xorl %ebp, %ebp
jmp 0xede0
movq (%rsp), %rsi
subq %r15, %rax
cmpq %rsi, %rax
jae 0xede0
movl %eax, %ebp
incl %ebp
cmpl $0x2, %ebp
jb 0xeddd
movb (%r15), %al
testb %al, %al
je 0xeddd
movslq %ebp, %rcx
decq %rcx
incq %r15
movb %al, (%rbx)
incq %rbx
movb (%r15), %al
testb %al, %al
je 0xeddd
leaq -0x1(%rcx), %rdx
incq %r15
cmpq $0x1, %rcx
movq %rdx, %rcx
ja 0xedc1
movb $0x0, (%rbx)
movl %ebp, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O1/nilnilnil[P]autocomplete/deps/mongoose/mongoose.c
// Function: mg_stop
void mg_stop(struct mg_context *ctx) {
  ctx->stop_flag = 1;

  // Wait until mg_fini() stops
  while (ctx->stop_flag != 2) {
    (void) sleep(0);
  }
  free_context(ctx);

#if defined(_WIN32) && !defined(__SYMBIAN32__)
  (void) WSACleanup();
#endif // _WIN32
}

// Assembly:
pushq %rbx
movq %rdi, %rbx
movl $0x1, (%rdi)
movl (%rdi), %eax
cmpl $0x2, %eax
je 0xf328
xorl %edi, %edi
callq 0x5350
movl (%rbx), %eax
jmp 0xf318
movq %rbx, %rdi
popq %rbx
jmp 0xf32e
// File: /workspace/github_cpp_makefile_star2_O1/nilnilnil[P]autocomplete/deps/mongoose/mongoose.c
// Function: free_context
static void free_context(struct mg_context *ctx) {
  int i;

  // Deallocate config parameters
  for (i = 0; i < NUM_OPTIONS; i++) {
    if (ctx->config[i] != NULL)
      free(ctx->config[i]);
  }

  // Deallocate SSL context
  if (ctx->ssl_ctx != NULL) {
    SSL_CTX_free(ctx->ssl_ctx);
  }
#ifndef NO_SSL
  if (ssl_mutexes != NULL) {
    free(ssl_mutexes);
  }
#endif // !NO_SSL

  // Deallocate context itself
  free(ctx);
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %rbx
movl $0x2, %r14d
movq (%rbx,%r14,8), %rdi
testq %rdi, %rdi
je 0xf349
callq 0x55d0
incq %r14
cmpq $0x18, %r14
jne 0xf33b
movq 0x8(%rbx), %rdi
testq %rdi, %rdi
je 0xf361
callq *0xd567(%rip)           # 0x1c8c8
movq 0xd678(%rip), %rdi      # 0x1c9e0
testq %rdi, %rdi
je 0xf372
callq 0x55d0
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %r14
jmp 0x55d0
// File: /workspace/github_cpp_makefile_star2_O1/nilnilnil[P]autocomplete/deps/mongoose/mongoose.c
// Function: start_thread
static int start_thread(struct mg_context *ctx, mg_thread_func_t func,
                        void *param) {
  pthread_t thread_id;
  pthread_attr_t attr;
  int retval;

  (void) pthread_attr_init(&attr);
  (void) pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
  // TODO(lsm): figure out why mongoose dies on Linux if next line is enabled
  // (void) pthread_attr_setstacksize(&attr, sizeof(struct mg_connection) * 5);

  if ((retval = pthread_create(&thread_id, &attr, func, param)) != 0) {
    cry(fc(ctx), "%s: %s", __func__, strerror(retval));
  }

  return retval;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %rdx, %rbx
movq %rsi, %r15
movq %rdi, %r14
leaq 0x10(%rsp), %r12
movq %r12, %rdi
callq 0x5600
movq %r12, %rdi
movl $0x1, %esi
callq 0x5650
leaq 0x8(%rsp), %rdi
movq %r12, %rsi
movq %r15, %rdx
movq %rbx, %rcx
callq 0x5950
movl %eax, %ebx
testl %eax, %eax
je 0xfef2
movq %r14, 0xcf77(%rip)      # 0x1ce40
leaq 0xcb18(%rip), %r14      # 0x1c9e8
movl %ebx, %edi
callq 0x51a0
leaq 0x5ca1(%rip), %rsi      # 0x15b7f
leaq 0x5f03(%rip), %rdx      # 0x15de8
movq %r14, %rdi
movq %rax, %rcx
xorl %eax, %eax
callq 0xfc79
movl %ebx, %eax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
// File: /workspace/github_cpp_makefile_star2_O1/nilnilnil[P]autocomplete/deps/mongoose/mongoose.c
// Function: mg_stat
static int mg_stat(const char *path, struct mgstat *stp) {
  struct stat st;
  int ok;

  if (stat(path, &st) == 0) {
    ok = 0;
    stp->size = st.st_size;
    stp->mtime = st.st_mtime;
    stp->is_directory = S_ISDIR(st.st_mode);
  } else {
    ok = -1;
  }

  return ok;
}

// Assembly:
pushq %rbx
subq $0x90, %rsp
movq %rsi, %rbx
movq %rsp, %rsi
callq 0x5420
movl %eax, %ecx
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
testl %ecx, %ecx
jne 0x1288e
movq 0x30(%rsp), %rax
movq %rax, 0x8(%rbx)
movq 0x58(%rsp), %rax
movq %rax, 0x10(%rbx)
movl $0xf000, %eax           # imm = 0xF000
andl 0x18(%rsp), %eax
xorl %ecx, %ecx
cmpl $0x4000, %eax           # imm = 0x4000
sete %cl
movl %ecx, (%rbx)
xorl %eax, %eax
addq $0x90, %rsp
popq %rbx
retq
// File: /workspace/github_cpp_makefile_star2_O1/nilnilnil[P]autocomplete/deps/mongoose/mongoose.c
// Function: load_dll
static int load_dll(struct mg_context *ctx, const char *dll_name,
                    struct ssl_func *sw) {
  union {void *p; void (*fp)(void);} u;
  void  *dll_handle;
  struct ssl_func *fp;

  if ((dll_handle = dlopen(dll_name, RTLD_LAZY)) == NULL) {
    cry(fc(ctx), "%s: cannot load %s", __func__, dll_name);
    return 0;
  }

  for (fp = sw; fp->name != NULL; fp++) {
#ifdef _WIN32
    // GetProcAddress() returns pointer to function
    u.fp = (void (*)(void)) dlsym(dll_handle, fp->name);
#else
    // dlsym() on UNIX returns void *. ISO C forbids casts of data pointers to
    // function pointers. We need to use a union to make a cast.
    u.p = dlsym(dll_handle, fp->name);
#endif /* _WIN32 */
    if (u.fp == NULL) {
      cry(fc(ctx), "%s: %s: cannot find %s", __func__, dll_name, fp->name);
      return 0;
    } else {
      fp->ptr = u.fp;
    }
  }

  return 1;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
movq %rdx, %r15
movq %rsi, %r14
movq %rdi, %r12
movl $0x1, %ebx
movq %rsi, %rdi
movl $0x1, %esi
callq 0x5690
testq %rax, %rax
je 0x128ee
movq (%r15), %rsi
testq %rsi, %rsi
je 0x12944
movq %rax, %r13
addq $0x10, %r15
movq %r13, %rdi
callq 0x5450
testq %rax, %rax
je 0x12918
movq %rax, -0x8(%r15)
movq (%r15), %rsi
addq $0x10, %r15
testq %rsi, %rsi
jne 0x128cf
jmp 0x12944
movq %r12, 0xa54b(%rip)      # 0x1ce40
leaq 0xa0ec(%rip), %rdi      # 0x1c9e8
leaq 0x32b2(%rip), %rsi      # 0x15bb5
leaq 0x32be(%rip), %rdx      # 0x15bc8
xorl %ebx, %ebx
movq %r14, %rcx
xorl %eax, %eax
callq 0xfc79
jmp 0x12944
movq %r12, 0xa521(%rip)      # 0x1ce40
leaq 0xa0c2(%rip), %rdi      # 0x1c9e8
movq -0x10(%r15), %r8
leaq 0x32a0(%rip), %rsi      # 0x15bd1
leaq 0x3290(%rip), %rdx      # 0x15bc8
xorl %ebx, %ebx
movq %r14, %rcx
xorl %eax, %eax
callq 0xfc79
movl %ebx, %eax
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
// File: /workspace/github_cpp_makefile_star2_O1/nilnilnil[P]autocomplete/deps/mongoose/mongoose.c
// Function: next_option
static const char *next_option(const char *list, struct vec *val,
                               struct vec *eq_val) {
  if (list == NULL || *list == '\0') {
    /* End of the list */
    list = NULL;
  } else {
    val->ptr = list;
    if ((list = strchr(val->ptr, ',')) != NULL) {
      /* Comma found. Store length and shift the list ptr */
      val->len = list - val->ptr;
      list++;
    } else {
      /* This value is the last one */
      list = val->ptr + strlen(val->ptr);
      val->len = list - val->ptr;
    }

    if (eq_val != NULL) {
      /*
       * Value has form "x=y", adjust pointers and lengths
       * so that val points to "x", and eq_val points to "y".
       */
      eq_val->len = 0;
      eq_val->ptr = (const char *) memchr(val->ptr, '=', val->len);
      if (eq_val->ptr != NULL) {
        eq_val->ptr++;  /* Skip over '=' character */
        eq_val->len = val->ptr + val->len - eq_val->ptr;
        val->len = (eq_val->ptr - val->ptr) - 1;
      }
    }
  }

  return list;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
testq %rdi, %rdi
je 0x129b6
movq %rdi, %r12
cmpb $0x0, (%rdi)
je 0x129b6
movq %rdx, %r15
movq %rsi, %rbx
movq %r12, (%rsi)
movq %r12, %rdi
movl $0x2c, %esi
callq 0x51e0
testq %rax, %rax
je 0x129bb
movq %rax, %r14
subq %r12, %rax
movq %rax, 0x8(%rbx)
incq %r14
jmp 0x129cb
xorl %r14d, %r14d
jmp 0x12a15
movq %r12, %rdi
callq 0x5210
leaq (%r12,%rax), %r14
movq %rax, 0x8(%rbx)
testq %r15, %r15
je 0x12a15
movq $0x0, 0x8(%r15)
movq 0x8(%rbx), %r13
movq %r12, %rdi
movl $0x3d, %esi
movq %r13, %rdx
callq 0x5540
movq %rax, (%r15)
testq %rax, %rax
je 0x12a15
leaq 0x1(%rax), %rcx
movq %rcx, (%r15)
movq (%rbx), %rdx
addq %rdx, %r13
subq %rcx, %r13
movq %r13, 0x8(%r15)
notq %rdx
addq %rdx, %rax
incq %rax
movq %rax, 0x8(%rbx)
movq %r14, %rax
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
// File: /workspace/github_cpp_makefile_star2_O1/nilnilnil[P]autocomplete/deps/mongoose/mongoose.c
// Function: close_all_listening_sockets
static void close_all_listening_sockets(struct mg_context *ctx) {
  struct socket *sp, *tmp;
  for (sp = ctx->listening_sockets; sp != NULL; sp = tmp) {
    tmp = sp->next;
    (void) closesocket(sp->sock);
    free(sp);
  }
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq 0xd0(%rdi), %rbx
testq %rbx, %rbx
je 0x12a4d
movq (%rbx), %r14
movl 0x8(%rbx), %edi
callq 0x59c0
movq %rbx, %rdi
callq 0x55d0
movq %r14, %rbx
testq %r14, %r14
jne 0x12a32
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_cpp_makefile_star2_O1/nilnilnil[P]autocomplete/deps/mongoose/mongoose.c
// Function: close_connection
static void close_connection(struct mg_connection *conn) {
  if (conn->ssl) {
    SSL_free(conn->ssl);
    conn->ssl = NULL;
  }

  if (conn->client.sock != INVALID_SOCKET) {
    close_socket_gracefully(conn->client.sock);
  }
}

// Assembly:
pushq %r14
pushq %rbx
subq $0x2008, %rsp           # imm = 0x2008
movq %rdi, %rbx
movq 0x460(%rdi), %rdi
testq %rdi, %rdi
je 0x12d03
callq *0x9af0(%rip)           # 0x1c7e8
movq $0x0, 0x460(%rbx)
movl 0x470(%rbx), %ebx
cmpl $-0x1, %ebx
je 0x12d5e
movl %ebx, %edi
movl $0x1, %esi
callq 0x5680
movl %ebx, %edi
movl $0x3, %esi
xorl %edx, %edx
xorl %eax, %eax
callq 0x5290
orl $0x800, %eax            # imm = 0x800
movl %ebx, %edi
movl $0x4, %esi
movl %eax, %edx
xorl %eax, %eax
callq 0x5290
movq %rsp, %r14
movl $0x2000, %edx           # imm = 0x2000
movl %ebx, %edi
movq %r14, %rsi
xorl %ecx, %ecx
callq 0x5180
testl %eax, %eax
jg 0x12d42
movl %ebx, %edi
callq 0x59c0
addq $0x2008, %rsp           # imm = 0x2008
popq %rbx
popq %r14
retq