// File: nilnilnil[P]autocomplete/deps/mongoose/mongoose.c
// Function: cry
static void cry(struct mg_connection *conn, const char *fmt, ...) {
  char buf[BUFSIZ];
  va_list ap;
  FILE *fp;
  time_t timestamp;

  va_start(ap, fmt);
  (void) vsnprintf(buf, sizeof(buf), fmt, ap);
  va_end(ap);

  // Do not lock when getting the callback value, here and below.
  // I suppose this is fine, since function cannot disappear in the
  // same way string option can.
  conn->request_info.log_message = buf;
  if (call_user(conn, MG_EVENT_LOG) == NULL) {
    fp = conn->ctx->config[ERROR_LOG_FILE] == NULL ? NULL :
      mg_fopen(conn->ctx->config[ERROR_LOG_FILE], "a+");

    if (fp != NULL) {
      flockfile(fp);
      timestamp = time(NULL);

      (void) fprintf(fp,
          "[%010lu] [error] [client %s] ",
          (unsigned long) timestamp,
          inet_ntoa(conn->client.rsa.u.sin.sin_addr));

      if (conn->request_info.request_method != NULL) {
        (void) fprintf(fp, "%s %s: ",
            conn->request_info.request_method,
            conn->request_info.uri);
      }

      (void) fprintf(fp, "%s", buf);
      fputc('\n', fp);
      funlockfile(fp);
      if (fp != stderr) {
        fclose(fp);
      }
    }
  }
  conn->request_info.log_message = NULL;
}

// Assembly:
subq $0x2118, %rsp           # imm = 0x2118
testb %al, %al
je 0x18522
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 %r9, 0x48(%rsp)
movq %r8, 0x40(%rsp)
movq %rcx, 0x38(%rsp)
movq %rdx, 0x30(%rsp)
movq %rdi, 0x2110(%rsp)
movq %rsi, 0x2108(%rsp)
leaq 0xe0(%rsp), %rax
leaq 0x20(%rsp), %rcx
movq %rcx, 0x10(%rax)
leaq 0x2120(%rsp), %rcx
movq %rcx, 0x8(%rax)
movl $0x30, 0x4(%rax)
movl $0x10, (%rax)
leaq 0x100(%rsp), %rdi
movq 0x2108(%rsp), %rdx
leaq 0xe0(%rsp), %rcx
movl $0x2000, %esi           # imm = 0x2000
callq 0x5340
leaq 0xe0(%rsp), %rax
leaq 0x100(%rsp), %rcx
movq 0x2110(%rsp), %rax
movq %rcx, 0x38(%rax)
movq 0x2110(%rsp), %rdi
movl $0x2, %esi
callq 0x1a7d0
cmpq $0x0, %rax
jne 0x1872e
movq 0x2110(%rsp), %rax
movq 0x458(%rax), %rax
cmpq $0x0, 0x60(%rax)
jne 0x185e9
xorl %eax, %eax
movq %rax, 0x18(%rsp)
jmp 0x1860d
movq 0x2110(%rsp), %rax
movq 0x458(%rax), %rax
movq 0x60(%rax), %rdi
leaq 0xa17f(%rip), %rsi      # 0x22782
callq 0x56b0
movq %rax, 0x18(%rsp)
movq 0x18(%rsp), %rax
movq %rax, 0xd8(%rsp)
cmpq $0x0, 0xd8(%rsp)
je 0x1872c
movq 0xd8(%rsp), %rdi
callq 0x51a0
xorl %eax, %eax
movl %eax, %edi
callq 0x54f0
movq %rax, 0xd0(%rsp)
movq 0xd8(%rsp), %rax
movq %rax, 0x8(%rsp)
movq 0xd0(%rsp), %rax
movq %rax, 0x10(%rsp)
movq 0x2110(%rsp), %rax
movl 0x490(%rax), %edi
callq 0x5240
movq 0x8(%rsp), %rdi
movq 0x10(%rsp), %rdx
movq %rax, %rcx
leaq 0xa49c(%rip), %rsi      # 0x22b24
movb $0x0, %al
callq 0x5850
movq 0x2110(%rsp), %rax
cmpq $0x0, 0x10(%rax)
je 0x186cc
movq 0xd8(%rsp), %rdi
movq 0x2110(%rsp), %rax
movq 0x10(%rax), %rdx
movq 0x2110(%rsp), %rax
movq 0x18(%rax), %rcx
leaq 0xa47d(%rip), %rsi      # 0x22b42
movb $0x0, %al
callq 0x5850
movq 0xd8(%rsp), %rdi
leaq 0x100(%rsp), %rdx
leaq 0xb095(%rip), %rsi      # 0x23778
movb $0x0, %al
callq 0x5850
movq 0xd8(%rsp), %rsi
movl $0xa, %edi
callq 0x5730
movq 0xd8(%rsp), %rdi
callq 0x5460
movq 0xd8(%rsp), %rax
movq 0x128b8(%rip), %rcx     # 0x2afd0
cmpq (%rcx), %rax
je 0x1872a
movq 0xd8(%rsp), %rdi
callq 0x5560
jmp 0x1872c
jmp 0x1872e
movq 0x2110(%rsp), %rax
movq $0x0, 0x38(%rax)
addq $0x2118, %rsp           # imm = 0x2118
retq
nopw %cs:(%rax,%rax)