// File: /workspace/github_cpp_makefile_star2_O3/nilnilnil[P]autocomplete/deps/mongoose/mongoose.c
// Function: mg_start
struct mg_context *mg_start(mg_callback_t user_callback, void *user_data,
                            const char **options) {
  struct mg_context *ctx;
  const char *name, *value, *default_value;
  int i;

#if defined(_WIN32) && !defined(__SYMBIAN32__)
  WSADATA data;
  WSAStartup(MAKEWORD(2,2), &data);
#endif // _WIN32

  // Allocate context and initialize reasonable general case defaults.
  // TODO(lsm): do proper error handling here.
  ctx = (struct mg_context *) calloc(1, sizeof(*ctx));
  ctx->user_callback = user_callback;
  ctx->user_data = user_data;

  while (options && (name = *options++) != NULL) {
    if ((i = get_option_index(name)) == -1) {
      cry(fc(ctx), "Invalid option: %s", name);
      free_context(ctx);
      return NULL;
    } else if ((value = *options++) == NULL) {
      cry(fc(ctx), "%s: option value cannot be NULL", name);
      free_context(ctx);
      return NULL;
    }
    ctx->config[i] = mg_strdup(value);
    DEBUG_TRACE(("[%s] -> [%s]", name, value));
  }

  // Set default value if needed
  for (i = 0; config_options[i * ENTRIES_PER_CONFIG_OPTION] != NULL; i++) {
    default_value = config_options[i * ENTRIES_PER_CONFIG_OPTION + 2];
    if (ctx->config[i] == NULL && default_value != NULL) {
      ctx->config[i] = mg_strdup(default_value);
      DEBUG_TRACE(("Setting default: [%s] -> [%s]",
                   config_options[i * ENTRIES_PER_CONFIG_OPTION + 1],
                   default_value));
    }
  }

  // NOTE(lsm): order is important here. SSL certificates must
  // be initialized before listening ports. UID must be set last.
  if (!set_gpass_option(ctx) ||
#if !defined(NO_SSL)
      !set_ssl_option(ctx) ||
#endif
      !set_ports_option(ctx) ||
#if !defined(_WIN32)
      !set_uid_option(ctx) ||
#endif
      !set_acl_option(ctx)) {
    free_context(ctx);
    return NULL;
  }

#if !defined(_WIN32) && !defined(__SYMBIAN32__)
  // Ignore SIGPIPE signal, so if browser cancels the request, it
  // won't kill the whole process.
  (void) signal(SIGPIPE, SIG_IGN);
#endif // !_WIN32

  (void) pthread_mutex_init(&ctx->mutex, NULL);
  (void) pthread_cond_init(&ctx->cond, NULL);
  (void) pthread_cond_init(&ctx->sq_empty, NULL);
  (void) pthread_cond_init(&ctx->sq_full, NULL);

  // Start master (listening) thread
  start_thread(ctx, (mg_thread_func_t) master_thread, ctx);

  // Start worker threads
  for (i = 0; i < atoi(ctx->config[NUM_THREADS]); i++) {
    if (start_thread(ctx, (mg_thread_func_t) worker_thread, ctx) != 0) {
      cry(fc(ctx), "Cannot start worker thread: %d", ERRNO);
    } else {
      ctx->num_threads++;
    }
  }

  return ctx;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x488, %rsp            # imm = 0x488
movq %rdx, %r14
movq %rsi, %r15
movq %rdi, %r12
movl $0x1, %edi
movl $0x6a0, %esi            # imm = 0x6A0
callq 0x52d0
movq %rax, %rbx
movq %r12, 0xc0(%rax)
movq %r15, 0xc8(%rax)
testq %r14, %r14
je 0xf31a
movq (%r14), %r15
testq %r15, %r15
je 0xf31a
addq $0x10, %r14
movq %r15, %rdi
callq 0xe550
cmpl $-0x1, %eax
je 0xf4a8
movq -0x8(%r14), %rdi
testq %rdi, %rdi
je 0xf4bf
movl %eax, %ebp
callq 0xfd09
movslq %ebp, %rcx
movq %rax, 0x10(%rbx,%rcx,8)
movq (%r14), %r15
addq $0x10, %r14
testq %r15, %r15
jne 0xf2e1
cmpq $0x0, 0xd29e(%rip)      # 0x1c5c0
je 0xf360
leaq 0x10(%rbx), %r14
movl $0x2, %r12d
leaq 0xd28b(%rip), %r15      # 0x1c5c0
cmpq $0x0, (%r14)
jne 0xf34f
movl %r12d, %eax
movq (%r15,%rax,8), %rdi
testq %rdi, %rdi
je 0xf34f
callq 0xfd09
movq %rax, (%r14)
addq $0x8, %r14
cmpq $0x0, 0x8(%r15,%r12,8)
leaq 0x3(%r12), %r12
jne 0xf335
movq 0x68(%rbx), %rdi
testq %rdi, %rdi
je 0xf37b
leaq 0x30(%rsp), %rsi
callq 0x5420
testl %eax, %eax
jne 0xfb2f
movq 0xa8(%rbx), %r15
testq %r15, %r15
je 0xf5ea
movq 0x50(%rbx), %r12
leaq 0x67ac(%rip), %rsi      # 0x15b42
leaq 0xd443(%rip), %rdx      # 0x1c7e0
movq %rbx, %rdi
callq 0x11c2f
testl %eax, %eax
je 0xfb2f
leaq 0x6798(%rip), %rsi      # 0x15b4c
leaq 0xd545(%rip), %rdx      # 0x1c900
movq %rbx, %rdi
callq 0x11c2f
testl %eax, %eax
je 0xfb2f
callq *0xd4b7(%rip)           # 0x1c888
callq *0xd501(%rip)           # 0x1c8d8
movq 0xd48a(%rip), %r14      # 0x1c868
callq *0xd494(%rip)           # 0x1c878
movq %rax, %rdi
callq *%r14
movq %rax, %r14
testq %rax, %rax
je 0xf4e3
movq 0xc0(%rbx), %rbp
testq %rbp, %rbp
je 0xf430
leaq 0x38(%rsp), %r13
movl $0x448, %edx            # imm = 0x448
movq %r13, %rdi
xorl %esi, %esi
callq 0x5270
movq 0xc8(%rbx), %rax
movq %rax, -0x8(%r13)
leaq 0x30(%rsp), %rdx
movl $0x3, %edi
movq %r14, %rsi
callq *%rbp
movq %r14, %rdi
movq %r15, %rsi
movl $0x1, %edx
callq *0xd467(%rip)           # 0x1c8a8
testl %eax, %eax
je 0xf505
movq %r14, %rdi
movq %r15, %rsi
movl $0x1, %edx
callq *0xd43e(%rip)           # 0x1c898
testl %eax, %eax
je 0xf52e
testq %r12, %r12
je 0xf573
movq %r14, %rdi
movq %r12, %rsi
callq *0xd471(%rip)           # 0x1c8e8
testl %eax, %eax
jne 0xf573
movq %rbx, 0xd9ba(%rip)      # 0x1ce40
callq *0xd4ac(%rip)           # 0x1c938
testq %rax, %rax
je 0xfb4e
movq %rax, %rdi
xorl %esi, %esi
callq *0xd4a8(%rip)           # 0x1c948
movq %rax, %r8
jmp 0xfb55
movq %rbx, 0xd991(%rip)      # 0x1ce40
leaq 0xd532(%rip), %rdi      # 0x1c9e8
leaq 0x62dd(%rip), %rsi      # 0x1579a
jmp 0xf4d4
movq %rbx, 0xd97a(%rip)      # 0x1ce40
leaq 0xd51b(%rip), %rdi      # 0x1c9e8
leaq 0x62d9(%rip), %rsi      # 0x157ad
movq %r15, %rdx
xorl %eax, %eax
callq 0xfb6a
jmp 0xfb2f
movq %rbx, 0xd956(%rip)      # 0x1ce40
callq *0xd448(%rip)           # 0x1c938
testq %rax, %rax
je 0xf557
movq %rax, %rdi
xorl %esi, %esi
callq *0xd448(%rip)           # 0x1c948
movq %rax, %rdx
jmp 0xf55e
movq %rbx, 0xd934(%rip)      # 0x1ce40
callq *0xd426(%rip)           # 0x1c938
testq %rax, %rax
je 0xfa74
movq %rax, %rdi
xorl %esi, %esi
callq *0xd422(%rip)           # 0x1c948
movq %rax, %r8
jmp 0xfa7b
movq %rbx, 0xd90b(%rip)      # 0x1ce40
callq *0xd3fd(%rip)           # 0x1c938
testq %rax, %rax
je 0xfb0e
movq %rax, %rdi
xorl %esi, %esi
callq *0xd3f9(%rip)           # 0x1c948
movq %rax, %r8
jmp 0xfb15
leaq 0x6ce1(%rip), %rdx      # 0x1623f
leaq 0xd483(%rip), %rdi      # 0x1c9e8
leaq 0x65ed(%rip), %rsi      # 0x15b59
xorl %eax, %eax
callq 0xfb6a
callq *0xd38f(%rip)           # 0x1c908
shll $0x3, %eax
leal (%rax,%rax,4), %eax
movslq %eax, %rdi
callq 0x5660
movq %rax, 0xd452(%rip)      # 0x1c9e0
testq %rax, %rax
je 0xf9c0
callq *0xd36b(%rip)           # 0x1c908
testl %eax, %eax
jle 0xf5cc
xorl %r15d, %r15d
xorl %r12d, %r12d
movq 0xd432(%rip), %rdi      # 0x1c9e0
addq %r15, %rdi
xorl %esi, %esi
callq 0x5770
incq %r12
callq *0xd347(%rip)           # 0x1c908
cltq
addq $0x28, %r15
cmpq %rax, %r12
jl 0xf5a7
leaq 0x2715(%rip), %rdi      # 0x11ce8
callq *0xd33f(%rip)           # 0x1c918
leaq 0x2729(%rip), %rdi      # 0x11d09
callq *0xd342(%rip)           # 0x1c928
movq %r14, 0x8(%rbx)
movq 0x98(%rbx), %rdi
movl $0x1, 0x8(%rsp)
leaq 0x20(%rsp), %rsi
xorl %edx, %edx
callq 0x11d0e
testq %rax, %rax
je 0xf814
movq %rax, %r15
leaq 0x4(%rsp), %r12
leaq 0xc(%rsp), %r13
xorps %xmm0, %xmm0
movaps %xmm0, 0x30(%rsp)
movaps %xmm0, 0x40(%rsp)
movaps %xmm0, 0x50(%rsp)
movaps %xmm0, 0x60(%rsp)
movq 0x20(%rsp), %r14
movq %r14, %rdi
leaq 0x66b1(%rip), %rsi      # 0x15cf2
leaq 0x1c(%rsp), %rdx
leaq 0x18(%rsp), %rcx
leaq 0x14(%rsp), %r8
leaq 0x10(%rsp), %r9
xorl %eax, %eax
pushq %r12
pushq %r13
callq 0x5490
addq $0x10, %rsp
cmpl $0x5, %eax
jne 0xf68a
movl 0x1c(%rsp), %eax
shll $0x18, %eax
movl 0x18(%rsp), %ecx
shll $0x10, %ecx
orl %eax, %ecx
movl 0x14(%rsp), %ebp
shll $0x8, %ebp
orl %ecx, %ebp
orl 0x10(%rsp), %ebp
bswapl %ebp
jmp 0xf6ac
xorl %ebp, %ebp
movq %r14, %rdi
leaq 0x66c7(%rip), %rsi      # 0x15d5d
movq %r13, %rdx
movq %r12, %rcx
xorl %eax, %eax
callq 0x5490
cmpl $0x1, %eax
jne 0xf97d
movl %ebp, 0x44(%rsp)
movslq 0x4(%rsp), %r12
movb (%r14,%r12), %bpl
movsbl %bpl, %esi
movl $0x4, %edx
leaq 0x663a(%rip), %rdi      # 0x15d03
callq 0x5540
testq %rax, %rax
je 0xf97d
xorl %eax, %eax
cmpb $0x73, %bpl
sete %al
movl %eax, 0x64(%rsp)
xorl %eax, %eax
cmpb $0x70, (%r14,%r12)
sete %al
movzwl 0xc(%rsp), %ecx
rolw $0x8, %cx
movl %eax, 0x68(%rsp)
movl $0x10, 0x3c(%rsp)
movw $0x2, 0x40(%rsp)
movw %cx, 0x42(%rsp)
cmpb $0x73, %bpl
jne 0xf720
cmpq $0x0, 0x8(%rbx)
je 0xfaba
movl $0x2, %edi
movl $0x1, %esi
movl $0x6, %edx
callq 0x5110
movl %eax, %ebp
cmpl $-0x1, %eax
je 0xf93b
movl %ebp, %edi
movl $0x1, %esi
movl $0x2, %edx
leaq 0x8(%rsp), %rcx
movl $0x4, %r8d
callq 0x5910
testl %eax, %eax
jne 0xf93b
movl 0x3c(%rsp), %edx
movl %ebp, %edi
leaq 0x40(%rsp), %rsi
callq 0x50d0
testl %eax, %eax
jne 0xf93b
movl %ebp, %edi
movl $0x14, %esi
callq 0x5560
testl %eax, %eax
jne 0xf93b
movl $0x1, %edi
movl $0x40, %esi
callq 0x52d0
testq %rax, %rax
je 0xfa0d
movq %rax, %r14
movaps 0x30(%rsp), %xmm0
movaps 0x40(%rsp), %xmm1
movaps 0x50(%rsp), %xmm2
movaps 0x60(%rsp), %xmm3
movups %xmm0, (%rax)
movups %xmm3, 0x30(%rax)
movups %xmm2, 0x20(%rax)
movups %xmm1, 0x10(%rax)
movl %ebp, 0x8(%rax)
movl %ebp, %edi
movl $0x2, %esi
movl $0x1, %edx
xorl %eax, %eax
callq 0x5290
movq 0xd0(%rbx), %rax
movq %rax, (%r14)
movq %r14, 0xd0(%rbx)
movq %r15, %rdi
leaq 0x20(%rsp), %rsi
xorl %edx, %edx
callq 0x11d0e
movq %rax, %r15
testq %rax, %rax
leaq 0x4(%rsp), %r12
jne 0xf61b
movq 0xb8(%rbx), %r14
testq %r14, %r14
je 0xf857
movq %r14, %rdi
callq 0x5390
testq %rax, %rax
je 0xf9e9
movq %rax, %r15
movl 0x14(%rax), %edi
callq 0x5900
cmpl $-0x1, %eax
je 0xfa4e
movl 0x10(%r15), %edi
callq 0x5970
cmpl $-0x1, %eax
je 0xfadb
movq %rbx, %rdi
callq 0x11de7
cmpl $-0x1, %eax
je 0xfb2f
movl $0x1, %esi
movl $0xd, %edi
callq 0x5940
leaq 0xe0(%rbx), %rdi
xorl %esi, %esi
callq 0x5770
leaq 0x108(%rbx), %rdi
xorl %esi, %esi
callq 0x55e0
leaq 0x670(%rbx), %rdi
xorl %esi, %esi
callq 0x55e0
movq %rbx, %rdi
addq $0x640, %rdi            # imm = 0x640
xorl %esi, %esi
callq 0x55e0
leaq 0x537(%rip), %rsi       # 0xfdf0
movq %rbx, %rdi
movq %rbx, %rdx
callq 0xfd6b
movq 0xb0(%rbx), %rdi
callq 0x5810
testl %eax, %eax
jle 0xfb39
leaq 0x811(%rip), %r14       # 0x100f0
leaq 0xd102(%rip), %r15      # 0x1c9e8
leaq 0x5ee0(%rip), %r12      # 0x157cd
xorl %ebp, %ebp
movq %rbx, %rdi
movq %r14, %rsi
movq %rbx, %rdx
callq 0xfd6b
testl %eax, %eax
je 0xf91e
movq %rbx, 0xd538(%rip)      # 0x1ce40
callq 0x5060
movl (%rax), %edx
movq %r15, %rdi
movq %r12, %rsi
xorl %eax, %eax
callq 0xfb6a
jmp 0xf924
incl 0xd8(%rbx)
incl %ebp
movq 0xb0(%rbx), %rdi
callq 0x5810
cmpl %eax, %ebp
jl 0xf8ef
jmp 0xfb39
movl %ebp, %edi
callq 0x59c0
movq %rbx, 0xd4f7(%rip)      # 0x1ce40
leaq 0xd098(%rip), %r15      # 0x1c9e8
movq 0x28(%rsp), %r12
callq 0x5060
movl (%rax), %edi
callq 0x51a0
leaq 0x636e(%rip), %rsi      # 0x15cd6
leaq 0x630f(%rip), %rdx      # 0x15c7e
movq %r15, %rdi
movq %r12, %rcx
movq %r14, %r8
movq %rax, %r9
jmp 0xf9a8
movq %rbx, 0xd4bc(%rip)      # 0x1ce40
leaq 0xd05d(%rip), %rdi      # 0x1c9e8
movq 0x28(%rsp), %rcx
leaq 0x62b4(%rip), %rsi      # 0x15c4b
leaq 0x62e0(%rip), %rdx      # 0x15c7e
leaq 0x62ea(%rip), %r9       # 0x15c8f
movq %r14, %r8
xorl %eax, %eax
callq 0xfb6a
movq 0xd0(%rbx), %rdi
callq 0x11db8
jmp 0xfb2f
movq %rbx, 0xd479(%rip)      # 0x1ce40
callq *0xcf6b(%rip)           # 0x1c938
testq %rax, %rax
je 0xfa95
movq %rax, %rdi
xorl %esi, %esi
callq *0xcf67(%rip)           # 0x1c948
movq %rax, %rcx
jmp 0xfa9c
movq %rbx, 0xd450(%rip)      # 0x1ce40
leaq 0xcff1(%rip), %rdi      # 0x1c9e8
leaq 0x6309(%rip), %rsi      # 0x15d07
leaq 0x6318(%rip), %rdx      # 0x15d1d
movq %r14, %rcx
jmp 0xfab1
movl %ebp, %edi
callq 0x59c0
movq %rbx, 0xd425(%rip)      # 0x1ce40
leaq 0xcfc6(%rip), %r14      # 0x1c9e8
callq 0x5060
movl (%rax), %edi
callq 0x51a0
leaq 0x614a(%rip), %rsi      # 0x15b7f
leaq 0x6242(%rip), %rdx      # 0x15c7e
movq %r14, %rdi
movq %rax, %rcx
xorl %eax, %eax
callq 0xfb6a
jmp 0xf9af
movq %rbx, 0xd3eb(%rip)      # 0x1ce40
leaq 0xcf8c(%rip), %r15      # 0x1c9e8
callq 0x5060
movl (%rax), %edi
callq 0x51a0
leaq 0x62bd(%rip), %rsi      # 0x15d2c
jmp 0xfafc
leaq 0x67c4(%rip), %r8       # 0x1623f
leaq 0xcf66(%rip), %rdi      # 0x1c9e8
leaq 0x60e6(%rip), %rsi      # 0x15b6f
leaq 0x60f6(%rip), %rdx      # 0x15b86
jmp 0xfb25
leaq 0x67a3(%rip), %rcx      # 0x1623f
leaq 0xcf45(%rip), %rdi      # 0x1c9e8
leaq 0x60eb(%rip), %rsi      # 0x15b95
leaq 0x60d5(%rip), %rdx      # 0x15b86
xorl %eax, %eax
callq 0xfb6a
jmp 0xfb2f
movq %rbx, 0xd37f(%rip)      # 0x1ce40
leaq 0xcf20(%rip), %rdi      # 0x1c9e8
leaq 0x61d7(%rip), %rsi      # 0x15ca6
xorl %eax, %eax
callq 0xfb6a
jmp 0xf9af
movq %rbx, 0xd35e(%rip)      # 0x1ce40
leaq 0xceff(%rip), %r15      # 0x1c9e8
callq 0x5060
movl (%rax), %edi
callq 0x51a0
leaq 0x6243(%rip), %rsi      # 0x15d3f
leaq 0x621a(%rip), %rdx      # 0x15d1d
movq %r15, %rdi
movq %r14, %rcx
movq %rax, %r8
jmp 0xfb28
leaq 0x672a(%rip), %r8       # 0x1623f
leaq 0xcecc(%rip), %rdi      # 0x1c9e8
leaq 0x604c(%rip), %rsi      # 0x15b6f
xorl %edx, %edx
movq %r15, %rcx
xorl %eax, %eax
callq 0xfb6a
movq %rbx, %rdi
callq 0xf243
xorl %ebx, %ebx
movq %rbx, %rax
addq $0x488, %rsp            # imm = 0x488
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x66ea(%rip), %r8       # 0x1623f
leaq 0xce8c(%rip), %rdi      # 0x1c9e8
leaq 0x600c(%rip), %rsi      # 0x15b6f
xorl %edx, %edx
movq %r12, %rcx
jmp 0xfb28