// File: /workspace/github_c_makefile_star2_O0/sfeakes[P]unifi-motion/mongoose.c
// Function: mg_resolve_async_opt
int mg_resolve_async_opt(struct mg_mgr *mgr, const char *name, int query,
                         mg_resolve_callback_t cb, void *data,
                         struct mg_resolve_async_opts opts) {
  struct mg_resolve_async_request *req;
  struct mg_connection *dns_nc;
  const char *nameserver = opts.nameserver;
  char dns_server_buff[17], nameserver_url[26];

  if (nameserver == NULL) {
    nameserver = mgr->nameserver;
  }

  DBG(("%s %d %p", name, query, opts.dns_conn));

  /* resolve with DNS */
  req = (struct mg_resolve_async_request *) MG_CALLOC(1, sizeof(*req));
  if (req == NULL) {
    return -1;
  }

  strncpy(req->name, name, sizeof(req->name));
  req->query = query;
  req->callback = cb;
  req->data = data;
  /* TODO(mkm): parse defaults out of resolve.conf */
  req->max_retries = opts.max_retries ? opts.max_retries : 2;
  req->timeout = opts.timeout ? opts.timeout : 5;

  /* Lazily initialize dns server */
  if (nameserver == NULL) {
    if (mg_get_ip_address_of_nameserver(dns_server_buff,
                                        sizeof(dns_server_buff)) != -1) {
      nameserver = dns_server_buff;
    } else {
      nameserver = MG_DEFAULT_NAMESERVER;
    }
  }

  snprintf(nameserver_url, sizeof(nameserver_url), "udp://%s:53", nameserver);

  dns_nc = mg_connect(mgr, nameserver_url, MG_CB(mg_resolve_async_eh, NULL));
  if (dns_nc == NULL) {
    MG_FREE(req);
    return -1;
  }
  dns_nc->user_data = req;
  if (opts.dns_conn != NULL) {
    *opts.dns_conn = dns_nc;
  }

  return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x90, %rsp
leaq 0x10(%rbp), %rax
movq %rax, -0x88(%rbp)
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movl %edx, -0x1c(%rbp)
movq %rcx, -0x28(%rbp)
movq %r8, -0x30(%rbp)
movq (%rax), %rax
movq %rax, -0x48(%rbp)
cmpq $0x0, -0x48(%rbp)
jne 0xc653
movq -0x10(%rbp), %rax
movq 0x30(%rax), %rax
movq %rax, -0x48(%rbp)
jmp 0xc655
movl $0x4, %edi
leaq 0x13a71(%rip), %rsi     # 0x200d2
leaq 0x12ee2(%rip), %rdx     # 0x1f54a
callq 0x4650
cmpl $0x0, %eax
je 0xc692
movq -0x88(%rbp), %rax
movq -0x18(%rbp), %rsi
movl -0x1c(%rbp), %edx
movq 0x18(%rax), %rcx
leaq 0x13a5c(%rip), %rdi     # 0x200e7
movb $0x0, %al
callq 0x47a0
jmp 0xc694
movl $0x1, %edi
movl $0x438, %esi            # imm = 0x438
callq 0x3330
movq %rax, -0x38(%rbp)
cmpq $0x0, -0x38(%rbp)
jne 0xc6ba
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0xc826
movq -0x38(%rbp), %rdi
movq -0x18(%rbp), %rsi
movl $0x400, %edx            # imm = 0x400
callq 0x30a0
movq -0x88(%rbp), %rax
movl -0x1c(%rbp), %edx
movq -0x38(%rbp), %rcx
movl %edx, 0x400(%rcx)
movq -0x28(%rbp), %rdx
movq -0x38(%rbp), %rcx
movq %rdx, 0x408(%rcx)
movq -0x30(%rbp), %rdx
movq -0x38(%rbp), %rcx
movq %rdx, 0x410(%rcx)
cmpl $0x0, 0x8(%rax)
je 0xc716
movq -0x88(%rbp), %rax
movl 0x8(%rax), %eax
movl %eax, -0x8c(%rbp)
jmp 0xc723
movl $0x2, %eax
movl %eax, -0x8c(%rbp)
jmp 0xc723
movq -0x88(%rbp), %rax
movl -0x8c(%rbp), %edx
movq -0x38(%rbp), %rcx
movl %edx, 0x420(%rcx)
cmpl $0x0, 0xc(%rax)
je 0xc752
movq -0x88(%rbp), %rax
movl 0xc(%rax), %eax
movl %eax, -0x90(%rbp)
jmp 0xc75f
movl $0x5, %eax
movl %eax, -0x90(%rbp)
jmp 0xc75f
movl -0x90(%rbp), %eax
movslq %eax, %rcx
movq -0x38(%rbp), %rax
movq %rcx, 0x418(%rax)
cmpq $0x0, -0x48(%rbp)
jne 0xc7a4
leaq -0x60(%rbp), %rdi
movl $0x11, %esi
callq 0x18ef0
cmpl $-0x1, %eax
je 0xc797
leaq -0x60(%rbp), %rax
movq %rax, -0x48(%rbp)
jmp 0xc7a2
leaq 0x13952(%rip), %rax     # 0x200f0
movq %rax, -0x48(%rbp)
jmp 0xc7a4
leaq -0x80(%rbp), %rdi
movq -0x48(%rbp), %rcx
movl $0x1a, %esi
leaq 0x13940(%rip), %rdx     # 0x200f8
movb $0x0, %al
callq 0x31f0
movq -0x10(%rbp), %rdi
leaq -0x80(%rbp), %rsi
leaq 0xc822(%rip), %rdx      # 0x18ff0
callq 0xc0a0
movq %rax, -0x40(%rbp)
cmpq $0x0, -0x40(%rbp)
jne 0xc7f0
movq -0x38(%rbp), %rdi
callq 0x3050
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0xc826
movq -0x88(%rbp), %rax
movq -0x38(%rbp), %rdx
movq -0x40(%rbp), %rcx
movq %rdx, 0xa0(%rcx)
cmpq $0x0, 0x18(%rax)
je 0xc81f
movq -0x88(%rbp), %rax
movq -0x40(%rbp), %rcx
movq 0x18(%rax), %rax
movq %rcx, (%rax)
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x90, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)