// File: /workspace/github_cpp_makefile_star2_O1/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 0xf405
movq (%r14), %r15
testq %r15, %r15
je 0xf405
addq $0x10, %r14
movq %r15, %rdi
callq 0xe5f8
cmpl $-0x1, %eax
je 0xf51b
movq -0x8(%r14), %rdi
testq %rdi, %rdi
je 0xf532
movl %eax, %ebp
callq 0xfe19
movslq %ebp, %rcx
movq %rax, 0x10(%rbx,%rcx,8)
movq (%r14), %r15
addq $0x10, %r14
testq %r15, %r15
jne 0xf3cc
cmpq $0x0, 0xd1b3(%rip)      # 0x1c5c0
je 0xf44b
leaq 0x10(%rbx), %r14
movl $0x2, %r12d
leaq 0xd1a0(%rip), %r15      # 0x1c5c0
cmpq $0x0, (%r14)
jne 0xf43a
movl %r12d, %eax
movq (%r15,%rax,8), %rdi
testq %rdi, %rdi
je 0xf43a
callq 0xfe19
movq %rax, (%r14)
addq $0x8, %r14
cmpq $0x0, 0x8(%r15,%r12,8)
leaq 0x3(%r12), %r12
jne 0xf420
movq 0x68(%rbx), %rdi
testq %rdi, %rdi
je 0xf466
leaq 0x30(%rsp), %rsi
callq 0x5420
testl %eax, %eax
jne 0xfc5a
movq 0xa8(%rbx), %r14
testq %r14, %r14
je 0xf669
movq 0x50(%rbx), %r15
leaq 0x66c1(%rip), %rsi      # 0x15b42
leaq 0xd358(%rip), %rdx      # 0x1c7e0
movq %rbx, %rdi
callq 0x12897
testl %eax, %eax
je 0xfc5a
leaq 0x66ad(%rip), %rsi      # 0x15b4c
leaq 0xd45a(%rip), %rdx      # 0x1c900
movq %rbx, %rdi
callq 0x12897
testl %eax, %eax
je 0xfc5a
callq *0xd3cc(%rip)           # 0x1c888
callq *0xd416(%rip)           # 0x1c8d8
movq 0xd39f(%rip), %r12      # 0x1c868
callq *0xd3a9(%rip)           # 0x1c878
movq %rax, %rdi
callq *%r12
movq %rax, %r12
testq %rax, %rax
je 0xf556
movq 0xc0(%rbx), %rbp
testq %rbp, %rbp
je 0xf594
leaq 0x30(%rsp), %r13
movl $0x450, %edx            # imm = 0x450
movq %r13, %rdi
xorl %esi, %esi
callq 0x5270
movq 0xc8(%rbx), %rax
movq %rax, (%r13)
movl $0x3, %edi
movq %r12, %rsi
movq %r13, %rdx
callq *%rbp
jmp 0xf594
movq %rbx, 0xd91e(%rip)      # 0x1ce40
leaq 0xd4bf(%rip), %rdi      # 0x1c9e8
leaq 0x626a(%rip), %rsi      # 0x1579a
jmp 0xf547
movq %rbx, 0xd907(%rip)      # 0x1ce40
leaq 0xd4a8(%rip), %rdi      # 0x1c9e8
leaq 0x6266(%rip), %rsi      # 0x157ad
movq %r15, %rdx
xorl %eax, %eax
callq 0xfc79
jmp 0xfc5a
movq %rbx, 0xd8e3(%rip)      # 0x1ce40
callq *0xd3d5(%rip)           # 0x1c938
testq %rax, %rax
je 0xf578
movq %rax, %rdi
xorl %esi, %esi
callq *0xd3d5(%rip)           # 0x1c948
movq %rax, %rdx
jmp 0xf57f
leaq 0x6cc3(%rip), %rdx      # 0x16242
leaq 0xd462(%rip), %rdi      # 0x1c9e8
leaq 0x65cc(%rip), %rsi      # 0x15b59
xorl %eax, %eax
callq 0xfc79
testq %r12, %r12
je 0xf5cb
movq %r12, %rdi
movq %r14, %rsi
movl $0x1, %edx
callq *0xd2fe(%rip)           # 0x1c8a8
testl %eax, %eax
je 0xfae0
movq %r12, %rdi
movq %r14, %rsi
movl $0x1, %edx
callq *0xd2d5(%rip)           # 0x1c898
testl %eax, %eax
je 0xfb55
testq %r12, %r12
setne %al
testq %r15, %r15
setne %cl
andb %al, %cl
cmpb $0x1, %cl
jne 0xf5f2
movq %r12, %rdi
movq %r15, %rsi
callq *0xd2fe(%rip)           # 0x1c8e8
testl %eax, %eax
je 0xfb7e
callq *0xd310(%rip)           # 0x1c908
shll $0x3, %eax
leal (%rax,%rax,4), %eax
movslq %eax, %rdi
callq 0x5660
movq %rax, 0xd3d3(%rip)      # 0x1c9e0
testq %rax, %rax
je 0xfb09
callq *0xd2ec(%rip)           # 0x1c908
testl %eax, %eax
jle 0xf64b
xorl %r14d, %r14d
xorl %r15d, %r15d
movq 0xd3b3(%rip), %rdi      # 0x1c9e0
addq %r14, %rdi
xorl %esi, %esi
callq 0x5770
incq %r15
callq *0xd2c8(%rip)           # 0x1c908
cltq
addq $0x28, %r14
cmpq %rax, %r15
jl 0xf626
leaq 0x32fe(%rip), %rdi      # 0x12950
callq *0xd2c0(%rip)           # 0x1c918
leaq 0x3312(%rip), %rdi      # 0x12971
callq *0xd2c3(%rip)           # 0x1c928
movq %r12, 0x8(%rbx)
movq 0x98(%rbx), %rdi
movl $0x1, 0x4(%rsp)
leaq 0x20(%rsp), %rsi
xorl %edx, %edx
callq 0x12976
testq %rax, %rax
je 0xf977
movq %rax, %r15
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 0x6637(%rip), %rsi      # 0x15cf2
leaq 0x1c(%rsp), %rdx
leaq 0x18(%rsp), %rcx
leaq 0x14(%rsp), %r8
leaq 0x10(%rsp), %r9
xorl %eax, %eax
leaq 0x8(%rsp), %r12
pushq %r12
pushq %r13
callq 0x5490
addq $0x10, %rsp
cmpl $0x5, %eax
jne 0xf709
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 0xf72b
xorl %ebp, %ebp
movq %r14, %rdi
leaq 0x6648(%rip), %rsi      # 0x15d5d
movq %r13, %rdx
movq %r12, %rcx
xorl %eax, %eax
callq 0x5490
cmpl $0x1, %eax
jne 0xf844
movl %ebp, 0x44(%rsp)
movslq 0x8(%rsp), %r12
movb (%r14,%r12), %bpl
movsbl %bpl, %esi
movl $0x4, %edx
leaq 0x65bb(%rip), %rdi      # 0x15d03
callq 0x5540
testq %rax, %rax
je 0xf844
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 0xf79f
cmpq $0x0, 0x8(%rbx)
je 0xf8a5
movl $0x2, %edi
movl $0x1, %esi
movl $0x6, %edx
callq 0x5110
movl %eax, %ebp
cmpl $-0x1, %eax
je 0xf802
movl %ebp, %edi
movl $0x1, %esi
movl $0x2, %edx
leaq 0x4(%rsp), %rcx
movl $0x4, %r8d
callq 0x5910
testl %eax, %eax
jne 0xf802
movl 0x3c(%rsp), %edx
movl %ebp, %edi
leaq 0x40(%rsp), %rsi
callq 0x50d0
testl %eax, %eax
jne 0xf802
movl %ebp, %edi
movl $0x14, %esi
callq 0x5560
testl %eax, %eax
je 0xf8c6
movl %ebp, %edi
callq 0x59c0
movq %rbx, 0xd630(%rip)      # 0x1ce40
movq 0x28(%rsp), %rbp
callq 0x5060
movl (%rax), %edi
callq 0x51a0
xorl %r12d, %r12d
leaq 0xd1bd(%rip), %rdi      # 0x1c9e8
leaq 0x64a4(%rip), %rsi      # 0x15cd6
leaq 0x6445(%rip), %rdx      # 0x15c7e
movq %rbp, %rcx
movq %r14, %r8
movq %rax, %r9
jmp 0xf872
movq %rbx, 0xd5f5(%rip)      # 0x1ce40
movq 0x28(%rsp), %rcx
xorl %r12d, %r12d
leaq 0xd18e(%rip), %rdi      # 0x1c9e8
leaq 0x63ea(%rip), %rsi      # 0x15c4b
leaq 0x6416(%rip), %rdx      # 0x15c7e
movq %r14, %r8
leaq 0x641d(%rip), %r9       # 0x15c8f
xorl %eax, %eax
callq 0xfc79
movb $0x1, %r14b
testb %r14b, %r14b
jne 0xf97f
movq %r15, %rdi
leaq 0x20(%rsp), %rsi
xorl %edx, %edx
callq 0x12976
movq %rax, %r15
testq %rax, %rax
jne 0xf695
jmp 0xf987
movq %rbx, 0xd594(%rip)      # 0x1ce40
xorl %r12d, %r12d
leaq 0xd132(%rip), %rdi      # 0x1c9e8
leaq 0x63e9(%rip), %rsi      # 0x15ca6
xorl %eax, %eax
callq 0xfc79
jmp 0xf879
movl $0x1, %edi
movl $0x40, %esi
callq 0x52d0
testq %rax, %rax
je 0xf936
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)
xorl %r14d, %r14d
movl $0x1, %r12d
movl %ebp, %edi
movl $0x2, %esi
movl $0x1, %edx
movq %rax, %rbp
xorl %eax, %eax
callq 0x5290
movq 0xd0(%rbx), %rax
movq %rax, (%rbp)
movq %rbp, 0xd0(%rbx)
jmp 0xf87c
movl %ebp, %edi
callq 0x59c0
movq %rbx, 0xd4fc(%rip)      # 0x1ce40
callq 0x5060
movl (%rax), %edi
callq 0x51a0
xorl %r12d, %r12d
leaq 0xd08e(%rip), %rdi      # 0x1c9e8
leaq 0x621e(%rip), %rsi      # 0x15b7f
leaq 0x6316(%rip), %rdx      # 0x15c7e
movq %rax, %rcx
xorl %eax, %eax
callq 0xfc79
jmp 0xf879
movl $0x1, %r12d
jmp 0xf987
movq %rbx, %rdi
callq 0x12a22
testl %r12d, %r12d
je 0xfc5a
movq 0xb8(%rbx), %r14
testq %r14, %r14
je 0xf9d3
movq %r14, %rdi
callq 0x5390
testq %rax, %rax
je 0xfabc
movq %rax, %r15
movl 0x14(%rax), %edi
callq 0x5900
cmpl $-0x1, %eax
je 0xfb32
movl 0x10(%r15), %edi
callq 0x5970
cmpl $-0x1, %eax
je 0xfba7
leaq 0x30(%rsp), %rsi
movq %rbx, %rdi
callq 0x12a55
cmpl $-0x1, %eax
je 0xfc5a
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 0x4c6(%rip), %rsi       # 0xff00
movq %rbx, %rdi
movq %rbx, %rdx
callq 0xfe7b
movq 0xb0(%rbx), %rdi
callq 0x5810
testl %eax, %eax
jle 0xfc64
leaq 0x79b(%rip), %r14       # 0x101fb
leaq 0xcf81(%rip), %r15      # 0x1c9e8
leaq 0x5d5f(%rip), %r12      # 0x157cd
xorl %ebp, %ebp
movq %rbx, %rdi
movq %r14, %rsi
movq %rbx, %rdx
callq 0xfe7b
testl %eax, %eax
je 0xfa9f
movq %rbx, 0xd3b7(%rip)      # 0x1ce40
callq 0x5060
movl (%rax), %edx
movq %r15, %rdi
movq %r12, %rsi
xorl %eax, %eax
callq 0xfc79
jmp 0xfaa5
incl 0xd8(%rbx)
incl %ebp
movq 0xb0(%rbx), %rdi
callq 0x5810
cmpl %eax, %ebp
jl 0xfa70
jmp 0xfc64
movq %rbx, 0xd37d(%rip)      # 0x1ce40
leaq 0xcf1e(%rip), %rdi      # 0x1c9e8
leaq 0x6236(%rip), %rsi      # 0x15d07
leaq 0x6245(%rip), %rdx      # 0x15d1d
movq %r14, %rcx
jmp 0xfc14
movq %rbx, 0xd359(%rip)      # 0x1ce40
callq *0xce4b(%rip)           # 0x1c938
testq %rax, %rax
je 0xfbda
movq %rax, %rdi
xorl %esi, %esi
callq *0xce47(%rip)           # 0x1c948
movq %rax, %r8
jmp 0xfbe1
movq %rbx, 0xd330(%rip)      # 0x1ce40
callq *0xce22(%rip)           # 0x1c938
testq %rax, %rax
je 0xfbf8
movq %rax, %rdi
xorl %esi, %esi
callq *0xce1e(%rip)           # 0x1c948
movq %rax, %rcx
jmp 0xfbff
movq %rbx, 0xd307(%rip)      # 0x1ce40
leaq 0xcea8(%rip), %r15      # 0x1c9e8
callq 0x5060
movl (%rax), %edi
callq 0x51a0
leaq 0x61d9(%rip), %rsi      # 0x15d2c
jmp 0xfbc8
movq %rbx, 0xd2e4(%rip)      # 0x1ce40
callq *0xcdd6(%rip)           # 0x1c938
testq %rax, %rax
je 0xfc1d
movq %rax, %rdi
xorl %esi, %esi
callq *0xcdd2(%rip)           # 0x1c948
movq %rax, %r8
jmp 0xfc24
movq %rbx, 0xd2bb(%rip)      # 0x1ce40
callq *0xcdad(%rip)           # 0x1c938
testq %rax, %rax
je 0xfc39
movq %rax, %rdi
xorl %esi, %esi
callq *0xcda9(%rip)           # 0x1c948
movq %rax, %r8
jmp 0xfc40
movq %rbx, 0xd292(%rip)      # 0x1ce40
leaq 0xce33(%rip), %r15      # 0x1c9e8
callq 0x5060
movl (%rax), %edi
callq 0x51a0
leaq 0x6177(%rip), %rsi      # 0x15d3f
leaq 0x614e(%rip), %rdx      # 0x15d1d
movq %r15, %rdi
movq %r14, %rcx
movq %rax, %r8
jmp 0xfc53
leaq 0x6661(%rip), %r8       # 0x16242
leaq 0xce00(%rip), %rdi      # 0x1c9e8
leaq 0x5f80(%rip), %rsi      # 0x15b6f
leaq 0x5f90(%rip), %rdx      # 0x15b86
jmp 0xfc34
leaq 0x6643(%rip), %rcx      # 0x16242
leaq 0xcde2(%rip), %rdi      # 0x1c9e8
leaq 0x5f88(%rip), %rsi      # 0x15b95
leaq 0x5f72(%rip), %rdx      # 0x15b86
xorl %eax, %eax
callq 0xfc79
jmp 0xfc5a
leaq 0x661e(%rip), %r8       # 0x16242
leaq 0xcdbd(%rip), %rdi      # 0x1c9e8
leaq 0x5f3d(%rip), %rsi      # 0x15b6f
xorl %edx, %edx
movq %r14, %rcx
jmp 0xfc53
leaq 0x6602(%rip), %r8       # 0x16242
leaq 0xcda1(%rip), %rdi      # 0x1c9e8
leaq 0x5f21(%rip), %rsi      # 0x15b6f
xorl %edx, %edx
movq %r15, %rcx
xorl %eax, %eax
callq 0xfc79
movq %rbx, %rdi
callq 0xf32e
xorl %ebx, %ebx
movq %rbx, %rax
addq $0x488, %rsp            # imm = 0x488
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq