// File: /workspace/github_cpp_makefile_star2_O2/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
pushq $0x1
popq %rdi
movl $0x6a0, %esi            # imm = 0x6A0
callq 0x52d0
movq %rax, %rbx
movq %r12, 0xc0(%rax)
movq %r15, 0xc8(%rax)
leaq 0x10(%rax), %r12
testq %r14, %r14
je 0xc5fd
movq (%r14), %r15
testq %r15, %r15
je 0xc5fd
movq %r15, %rdi
callq 0xb8d4
cmpl $-0x1, %eax
je 0xc776
movq 0x8(%r14), %rdi
testq %rdi, %rdi
je 0xc78d
movl %eax, %ebp
addq $0x10, %r14
callq 0xcedd
movslq %ebp, %rcx
movq %rax, (%r12,%rcx,8)
jmp 0xc5be
leaq 0xdfdc(%rip), %r14      # 0x1a5e0
cmpq $0x0, -0x10(%r14)
je 0xc636
movq (%r14), %rdi
cmpq $0x0, (%r12)
sete %al
testq %rdi, %rdi
setne %cl
andb %al, %cl
cmpb $0x1, %cl
jne 0xc62c
callq 0xcedd
movq %rax, (%r12)
addq $0x8, %r12
addq $0x18, %r14
jmp 0xc604
movq 0x68(%rbx), %rdi
testq %rdi, %rdi
je 0xc651
leaq 0x30(%rsp), %rsi
callq 0xdb9f
testl %eax, %eax
jne 0xc7ac
movq 0xa8(%rbx), %r15
testq %r15, %r15
je 0xc85e
movq 0x50(%rbx), %r12
leaq 0x64d6(%rip), %rsi      # 0x12b42
leaq 0xe17d(%rip), %rdx      # 0x1a7f0
movq %rbx, %rdi
callq 0xdbed
testl %eax, %eax
je 0xc7ac
leaq 0x64c2(%rip), %rsi      # 0x12b4c
leaq 0xe27f(%rip), %rdx      # 0x1a910
movq %rbx, %rdi
callq 0xdbed
testl %eax, %eax
je 0xc7ac
callq *0xe1f1(%rip)           # 0x1a898
callq *0xe23b(%rip)           # 0x1a8e8
movq 0xe1c4(%rip), %r14      # 0x1a878
callq *0xe1ce(%rip)           # 0x1a888
movq %rax, %rdi
callq *%r14
movq %rax, %r14
testq %rax, %rax
je 0xc7cb
movq 0xc0(%rbx), %rbp
testq %rbp, %rbp
je 0xc704
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)
pushq $0x3
popq %rdi
leaq 0x30(%rsp), %rdx
movq %r14, %rsi
callq *%rbp
pushq $0x1
popq %rdx
movq %r14, %rdi
movq %r15, %rsi
callq *0xe1a5(%rip)           # 0x1a8b8
testl %eax, %eax
je 0xcc69
pushq $0x1
popq %rdx
movq %r14, %rdi
movq %r15, %rsi
callq *0xe17e(%rip)           # 0x1a8a8
testl %eax, %eax
je 0xcce3
testq %r12, %r12
je 0xc7f2
movq %r14, %rdi
movq %r12, %rsi
callq *0xe1b1(%rip)           # 0x1a8f8
testl %eax, %eax
jne 0xc7f2
movq %rbx, 0xe6fa(%rip)      # 0x1ae50
leaq 0xe29b(%rip), %r14      # 0x1a9f8
callq 0xdc94
leaq 0x6406(%rip), %rsi      # 0x12b6f
movq %r14, %rdi
xorl %edx, %edx
movq %r12, %rcx
jmp 0xcd58
movq %rbx, 0xe6d3(%rip)      # 0x1ae50
leaq 0xe274(%rip), %rdi      # 0x1a9f8
leaq 0x600f(%rip), %rsi      # 0x1279a
jmp 0xc7a2
movq %rbx, 0xe6bc(%rip)      # 0x1ae50
leaq 0xe25d(%rip), %rdi      # 0x1a9f8
leaq 0x600b(%rip), %rsi      # 0x127ad
movq %r15, %rdx
xorl %eax, %eax
callq 0xcd67
movq %rbx, %rdi
callq 0xc539
xorl %ebx, %ebx
movq %rbx, %rax
addq $0x488, %rsp            # imm = 0x488
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rbx, 0xe67e(%rip)      # 0x1ae50
leaq 0xe21f(%rip), %r15      # 0x1a9f8
callq 0xdc94
leaq 0x6374(%rip), %rsi      # 0x12b59
movq %r15, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0xcd67
callq *0xe120(%rip)           # 0x1a918
imull $0x28, %eax, %eax
movslq %eax, %rdi
callq 0x5650
movq %rax, 0xe1e6(%rip)      # 0x1a9f0
testq %rax, %rax
je 0xccb0
xorl %r15d, %r15d
xorl %r12d, %r12d
callq *0xe0f9(%rip)           # 0x1a918
cltq
cmpq %rax, %r12
jge 0xc840
movq 0xe1c3(%rip), %rdi      # 0x1a9f0
addq %r15, %rdi
xorl %esi, %esi
callq 0x5780
incq %r12
addq $0x28, %r15
jmp 0xc819
leaq 0x1471(%rip), %rdi      # 0xdcb8
callq *0xe0db(%rip)           # 0x1a928
leaq 0x1481(%rip), %rdi      # 0xdcd5
callq *0xe0de(%rip)           # 0x1a938
movq %r14, 0x8(%rbx)
movq 0x98(%rbx), %r12
leaq 0x8(%rsp), %rax
movl $0x1, (%rax)
xorl %eax, %eax
leaq 0x4(%rsp), %rbp
leaq 0xc(%rsp), %r15
testb $0x1, %al
jne 0xcb47
movq %r12, %rdi
leaq 0x20(%rsp), %rsi
xorl %edx, %edx
callq 0xdcda
testq %rax, %rax
je 0xcb54
movq %rax, %r12
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 0x642d(%rip), %rsi      # 0x12cf2
leaq 0x1c(%rsp), %rdx
leaq 0x18(%rsp), %rcx
leaq 0x14(%rsp), %r8
leaq 0x10(%rsp), %r9
xorl %eax, %eax
pushq %rbp
pushq %r15
callq 0x5470
popq %rcx
popq %rdx
cmpl $0x5, %eax
jne 0xc910
movl 0x1c(%rsp), %eax
shll $0x18, %eax
movl 0x18(%rsp), %ecx
shll $0x10, %ecx
orl %eax, %ecx
movl 0x14(%rsp), %r13d
shll $0x8, %r13d
orl %ecx, %r13d
orl 0x10(%rsp), %r13d
bswapl %r13d
jmp 0xc933
xorl %r13d, %r13d
movq %r14, %rdi
leaq 0x6440(%rip), %rsi      # 0x12d5d
movq %r15, %rdx
movq %rbp, %rcx
xorl %eax, %eax
callq 0x5470
cmpl $0x1, %eax
jne 0xca50
movl %r13d, 0x44(%rsp)
movslq 0x4(%rsp), %rbp
movb (%r14,%rbp), %r13b
movsbl %r13b, %esi
leaq 0x63b7(%rip), %rdi      # 0x12d03
pushq $0x4
popq %rdx
callq 0x5530
testq %rax, %rax
je 0xca50
xorl %eax, %eax
cmpb $0x73, %r13b
sete %al
movl %eax, 0x64(%rsp)
xorl %eax, %eax
cmpb $0x70, (%r14,%rbp)
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, %r13b
jne 0xc9a6
cmpq $0x0, 0x8(%rbx)
je 0xca8e
pushq $0x2
popq %rdi
pushq $0x1
popq %rsi
pushq $0x6
popq %rdx
callq 0x5100
movl %eax, %r13d
cmpl $-0x1, %eax
leaq 0x4(%rsp), %rbp
je 0xca04
movl %r13d, %edi
pushq $0x1
popq %rsi
pushq $0x2
popq %rdx
leaq 0x8(%rsp), %rcx
pushq $0x4
popq %r8
callq 0x5910
testl %eax, %eax
jne 0xca04
movl 0x3c(%rsp), %edx
movl %r13d, %edi
leaq 0x40(%rsp), %rsi
callq 0x50c0
testl %eax, %eax
jne 0xca04
movl %r13d, %edi
pushq $0x14
popq %rsi
callq 0x5550
testl %eax, %eax
je 0xcaac
movl %r13d, %edi
callq 0x59e0
movq %rbx, 0xe43d(%rip)      # 0x1ae50
movq 0x28(%rsp), %r13
callq 0x5050
movl (%rax), %edi
callq 0x5170
leaq 0xdfcd(%rip), %rdi      # 0x1a9f8
leaq 0x62a4(%rip), %rsi      # 0x12cd6
leaq 0x6245(%rip), %rdx      # 0x12c7e
movq %r13, %rcx
movq %r14, %r8
movq %rax, %r9
xorl %eax, %eax
callq 0xcd67
movb $0x1, %al
jmp 0xc87c
movq %rbx, 0xe3f9(%rip)      # 0x1ae50
movq 0x28(%rsp), %rcx
leaq 0xdf95(%rip), %rdi      # 0x1a9f8
leaq 0x61e1(%rip), %rsi      # 0x12c4b
leaq 0x620d(%rip), %rdx      # 0x12c7e
movq %r14, %r8
leaq 0x6214(%rip), %r9       # 0x12c8f
xorl %eax, %eax
callq 0xcd67
movb $0x1, %al
leaq 0x4(%rsp), %rbp
jmp 0xc87c
movq %rbx, 0xe3bb(%rip)      # 0x1ae50
leaq 0xdf5c(%rip), %rdi      # 0x1a9f8
leaq 0x6203(%rip), %rsi      # 0x12ca6
xorl %eax, %eax
callq 0xcd67
jmp 0xca82
pushq $0x1
popq %rdi
pushq $0x40
popq %rsi
callq 0x52d0
testq %rax, %rax
je 0xcb06
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 %r13d, 0x8(%rax)
movl %r13d, %edi
callq 0xdd7d
movq 0xd0(%rbx), %rax
movq %rax, (%r14)
movq %r14, 0xd0(%rbx)
xorl %eax, %eax
jmp 0xc87c
movl %r13d, %edi
callq 0x59e0
movq %rbx, 0xe33b(%rip)      # 0x1ae50
callq 0x5050
movl (%rax), %edi
callq 0x5170
leaq 0xded0(%rip), %rdi      # 0x1a9f8
leaq 0x6050(%rip), %rsi      # 0x12b7f
leaq 0x6148(%rip), %rdx      # 0x12c7e
movq %rax, %rcx
xorl %eax, %eax
callq 0xcd67
movb $0x1, %al
jmp 0xc87c
movq %rbx, %rdi
callq 0xdd8a
jmp 0xc7ac
movq 0xb8(%rbx), %r14
testq %r14, %r14
je 0xcb97
movq %r14, %rdi
callq 0x5380
testq %rax, %rax
je 0xcc8f
movq %rax, %r15
movl 0x14(%rax), %edi
callq 0x5900
cmpl $-0x1, %eax
je 0xcd07
movl 0x10(%r15), %edi
callq 0x5970
cmpl $-0x1, %eax
je 0xcd2a
leaq 0x30(%rsp), %rsi
movq %rbx, %rdi
callq 0xddba
cmpl $-0x1, %eax
je 0xc7ac
pushq $0xd
popq %rdi
pushq $0x1
popq %rsi
callq 0x5940
leaq 0xe0(%rbx), %rdi
xorl %esi, %esi
callq 0x5780
leaq 0x108(%rbx), %rdi
xorl %esi, %esi
callq 0x55c0
leaq 0x670(%rbx), %rdi
xorl %esi, %esi
callq 0x55c0
movq %rbx, %rdi
addq $0x640, %rdi            # imm = 0x640
xorl %esi, %esi
callq 0x55c0
leaq 0x3a0(%rip), %rsi       # 0xcf9a
movq %rbx, %rdi
movq %rbx, %rdx
callq 0xcf17
leaq 0x601(%rip), %r14       # 0xd20d
leaq 0xdde5(%rip), %r15      # 0x1a9f8
leaq 0x5bb3(%rip), %r12      # 0x127cd
xorl %ebp, %ebp
movq 0xb0(%rbx), %rdi
callq 0x5810
cmpl %eax, %ebp
jge 0xc7b6
movq %rbx, %rdi
movq %r14, %rsi
movq %rbx, %rdx
callq 0xcf17
testl %eax, %eax
je 0xcc5f
movq %rbx, 0xe207(%rip)      # 0x1ae50
callq 0x5050
movl (%rax), %edx
movq %r15, %rdi
movq %r12, %rsi
xorl %eax, %eax
callq 0xcd67
jmp 0xcc65
incl 0xd8(%rbx)
incl %ebp
jmp 0xcc1c
movq %rbx, 0xe1e0(%rip)      # 0x1ae50
leaq 0xdd81(%rip), %r14      # 0x1a9f8
callq 0xdc94
leaq 0x5eec(%rip), %rsi      # 0x12b6f
leaq 0x5efc(%rip), %rdx      # 0x12b86
movq %r14, %rdi
jmp 0xcd02
movq %rbx, 0xe1ba(%rip)      # 0x1ae50
leaq 0xdd5b(%rip), %rdi      # 0x1a9f8
leaq 0x6063(%rip), %rsi      # 0x12d07
leaq 0x6072(%rip), %rdx      # 0x12d1d
movq %r14, %rcx
jmp 0xccd7
movq %rbx, 0xe199(%rip)      # 0x1ae50
leaq 0xdd3a(%rip), %r14      # 0x1a9f8
callq 0xdc94
leaq 0x5ecb(%rip), %rsi      # 0x12b95
leaq 0x5eb5(%rip), %rdx      # 0x12b86
movq %r14, %rdi
movq %rax, %rcx
xorl %eax, %eax
callq 0xcd67
jmp 0xc7ac
movq %rbx, 0xe166(%rip)      # 0x1ae50
leaq 0xdd07(%rip), %r14      # 0x1a9f8
callq 0xdc94
leaq 0x5e72(%rip), %rsi      # 0x12b6f
movq %r14, %rdi
xorl %edx, %edx
movq %r15, %rcx
jmp 0xcd58
movq %rbx, 0xe142(%rip)      # 0x1ae50
leaq 0xdce3(%rip), %r15      # 0x1a9f8
callq 0x5050
movl (%rax), %edi
callq 0x5170
leaq 0x6004(%rip), %rsi      # 0x12d2c
jmp 0xcd4b
movq %rbx, 0xe11f(%rip)      # 0x1ae50
leaq 0xdcc0(%rip), %r15      # 0x1a9f8
callq 0x5050
movl (%rax), %edi
callq 0x5170
leaq 0x5ff4(%rip), %rsi      # 0x12d3f
leaq 0x5fcb(%rip), %rdx      # 0x12d1d
movq %r15, %rdi
movq %r14, %rcx
movq %rax, %r8
xorl %eax, %eax
callq 0xcd67
jmp 0xc7ac