// File: nilnilnil[P]autocomplete/src/main.cpp
// Function: main
int
main(int argc, char* argv[]) {
    parse_options(argc, argv);
    if (opt_show_help) {
        show_usage(argv);
        return 0;
    }

    struct mg_context *ctx;
    const char *options[] = {"listening_ports", port, NULL};

    started_at = time(NULL);

    cerr<<"INFO::Starting lib-face on port '"<<port<<"'\n";

    if (ac_file) {
        int nadded, nlines;
        const time_t start_time = time(NULL);
        int ret = do_import(ac_file, ac_sorted, minus_one, nadded, nlines);
        if (ret < 0) {
            fprintf(stderr, "ERROR::Could not add lines in file '%s'\n", ac_file);
        }
        else {
            fprintf(stderr, "INFO::Successfully added %d/%d records from \"%s\" in %d second(s)\n", 
                    nadded, nlines, ac_file, (int)(time(NULL) - start_time));
        }
    }

    ctx = mg_start(&callback, NULL, options);
    if (!ctx) {
        fprintf(stderr, "ERROR::Could not start the web server\n");
        return 1;
    }

    while (1) {
        // Never stop
        sleep(100);
    }
    mg_stop(ctx);

    return 0;
}

// Assembly:
subq $0xb8, %rsp
movl $0x0, 0xb4(%rsp)
movl %edi, 0xb0(%rsp)
movq %rsi, 0xa8(%rsp)
movl 0xb0(%rsp), %edi
movq 0xa8(%rsp), %rsi
callq 0xbb20
testb $0x1, 0x1fef5(%rip)     # 0x2bb51
je 0xbc7b
movq 0xa8(%rsp), %rdi
callq 0xba80
movl $0x0, 0xb4(%rsp)
jmp 0xbe94
leaq 0x16803(%rip), %rax     # 0x22485
movq %rax, 0x80(%rsp)
movq 0x1f95f(%rip), %rax     # 0x2b5f0
movq %rax, 0x88(%rsp)
movq $0x0, 0x90(%rsp)
xorl %eax, %eax
movl %eax, %edi
callq 0x54f0
movq %rax, 0x1fe93(%rip)     # 0x2bb48
movq 0x1f334(%rip), %rdi     # 0x2aff0
leaq 0x167d2(%rip), %rsi     # 0x22495
callq 0x5550
movq %rax, %rdi
movq 0x1f91e(%rip), %rsi     # 0x2b5f0
callq 0x5550
movq %rax, %rdi
leaq 0x167fc(%rip), %rsi     # 0x224dd
callq 0x5550
cmpq $0x0, 0x1fe6a(%rip)     # 0x2bb58
je 0xbe36
xorl %eax, %eax
movl %eax, %edi
callq 0x54f0
movq %rax, 0x70(%rsp)
movq 0x1fe4f(%rip), %rax     # 0x2bb58
movq %rax, 0x20(%rsp)
leaq 0x47(%rsp), %rdi
movq %rdi, 0x28(%rsp)
callq 0x5a50
movq 0x20(%rsp), %rsi
movq 0x28(%rsp), %rdx
leaq 0x48(%rsp), %rdi
callq 0xddd0
jmp 0xbd33
movzbl 0x1fe16(%rip), %esi     # 0x2bb50
andl $0x1, %esi
leaq 0x48(%rsp), %rdi
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
leaq 0x7c(%rsp), %rcx
leaq 0x78(%rsp), %r8
callq 0xb630
movl %eax, 0x1c(%rsp)
jmp 0xbd5c
leaq 0x48(%rsp), %rdi
callq 0x5320
leaq 0x47(%rsp), %rdi
callq 0x55e0
movl 0x1c(%rsp), %eax
movl %eax, 0x6c(%rsp)
cmpl $0x0, 0x6c(%rsp)
jge 0xbdda
movq 0x1f24a(%rip), %rax     # 0x2afd0
movq (%rax), %rdi
movq 0x1fdc8(%rip), %rdx     # 0x2bb58
leaq 0x16720(%rip), %rsi     # 0x224b7
movb $0x0, %al
callq 0x5850
jmp 0xbe34
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x38(%rsp)
movl %eax, 0x34(%rsp)
jmp 0xbdcb
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x38(%rsp)
movl %eax, 0x34(%rsp)
leaq 0x48(%rsp), %rdi
callq 0x5320
leaq 0x47(%rsp), %rdi
callq 0x55e0
jmp 0xbea3
movq 0x1f1ef(%rip), %rax     # 0x2afd0
movq (%rax), %rax
movq %rax, (%rsp)
movl 0x7c(%rsp), %eax
movl %eax, 0x8(%rsp)
movl 0x78(%rsp), %eax
movl %eax, 0xc(%rsp)
movq 0x1fd59(%rip), %rax     # 0x2bb58
movq %rax, 0x10(%rsp)
xorl %eax, %eax
movl %eax, %edi
callq 0x54f0
movq (%rsp), %rdi
movl 0x8(%rsp), %edx
movl 0xc(%rsp), %ecx
movq 0x10(%rsp), %r8
subq 0x70(%rsp), %rax
movl %eax, %r9d
leaq 0x166b3(%rip), %rsi     # 0x224e0
movb $0x0, %al
callq 0x5850
jmp 0xbe36
leaq 0x80(%rsp), %rdx
leaq 0x6b(%rip), %rdi        # 0xbeb0
xorl %eax, %eax
movl %eax, %esi
callq 0x18190
movq %rax, 0xa0(%rsp)
cmpq $0x0, 0xa0(%rsp)
jne 0xbe86
movq 0x1f168(%rip), %rax     # 0x2afd0
movq (%rax), %rdi
leaq 0x166b0(%rip), %rsi     # 0x22522
movb $0x0, %al
callq 0x5850
movl $0x1, 0xb4(%rsp)
jmp 0xbe94
jmp 0xbe88
movl $0x64, %edi
callq 0x53d0
jmp 0xbe88
movl 0xb4(%rsp), %eax
addq $0xb8, %rsp
retq
movq 0x38(%rsp), %rdi
callq 0x5a40
nopl (%rax)