// File: /workspace/github_c_makefile_star2_O1/sfeakes[P]unifi-motion/mongoose.c
// Function: mg_if_recv_udp_cb
void mg_if_recv_udp_cb(struct mg_connection *nc, void *buf, int len,
                       union socket_address *sa, size_t sa_len) {
  assert(nc->flags & MG_F_UDP);
  DBG(("%p %u", nc, (unsigned int) len));
  if (nc->flags & MG_F_LISTENING) {
    struct mg_connection *lc = nc;
    /*
     * Do we have an existing connection for this source?
     * This is very inefficient for long connection lists.
     */
    for (nc = mg_next(lc->mgr, NULL); nc != NULL; nc = mg_next(lc->mgr, nc)) {
      if (memcmp(&nc->sa.sa, &sa->sa, sa_len) == 0 && nc->listener == lc) {
        break;
      }
    }
    if (nc == NULL) {
      struct mg_add_sock_opts opts;
      memset(&opts, 0, sizeof(opts));
      /* Create fake connection w/out sock initialization */
      nc = mg_create_connection_base(lc->mgr, lc->handler, opts);
      if (nc != NULL) {
        nc->sock = lc->sock;
        nc->listener = lc;
        nc->sa = *sa;
        nc->proto_handler = lc->proto_handler;
        nc->user_data = lc->user_data;
        nc->recv_mbuf_limit = lc->recv_mbuf_limit;
        nc->flags = MG_F_UDP;
        /*
         * Long-lived UDP "connections" i.e. interactions that involve more
         * than one request and response are rare, most are transactional:
         * response is sent and the "connection" is closed. Or - should be.
         * But users (including ourselves) tend to forget about that part,
         * because UDP is connectionless and one does not think about
         * processing a UDP request as handling a connection that needs to be
         * closed. Thus, we begin with SEND_AND_CLOSE flag set, which should
         * be a reasonable default for most use cases, but it is possible to
         * turn it off the connection should be kept alive after processing.
         */
        nc->flags |= MG_F_SEND_AND_CLOSE;
        mg_add_conn(lc->mgr, nc);
        mg_call(nc, NULL, nc->user_data, MG_EV_ACCEPT, &nc->sa);
      } else {
        DBG(("OOM"));
        /* No return here, we still need to drop on the floor */
      }
    }
  }
  if (nc != NULL) {
    mg_recv_common(nc, buf, len, 1);
  } else {
    /* Drop on the floor. */
    MG_FREE(buf);
    nc->iface->vtable->recved(nc, len);
  }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
testb $0x2, 0xc8(%rdi)
je 0x88c5
movq %r8, %rbp
movq %rcx, %r13
movl %edx, %ebx
movq %rsi, %r14
movq %rdi, %r12
leaq 0xd018(%rip), %rsi      # 0x1573f
leaq 0xce7c(%rip), %rdx      # 0x155aa
movl $0x4, %edi
callq 0x44b4
testl %eax, %eax
je 0x874f
leaq 0xd00e(%rip), %rdi      # 0x15751
movq %r12, %rsi
movl %ebx, %edx
xorl %eax, %eax
callq 0x45a0
testb $0x1, 0xc8(%r12)
jne 0x8762
movq %r12, %r15
jmp 0x8873
movq %r14, 0x28(%rsp)
movq 0x18(%r12), %r14
movq (%r14), %r15
testq %r15, %r15
je 0x8796
leaq 0x28(%r15), %rdi
movq %r13, %rsi
movq %rbp, %rdx
callq 0x3470
testl %eax, %eax
jne 0x8791
cmpq %r12, 0x10(%r15)
je 0x883d
movq (%r15), %r15
jmp 0x876f
xorps %xmm0, %xmm0
movaps %xmm0, 0x40(%rsp)
movaps %xmm0, 0x30(%rsp)
movq 0x98(%r12), %rsi
movaps 0x30(%rsp), %xmm0
movaps 0x40(%rsp), %xmm1
movups %xmm1, 0x10(%rsp)
movups %xmm0, (%rsp)
movq %r14, %rdi
callq 0x88ef
movq %rax, %r15
testq %rax, %rax
je 0x8844
movl 0x20(%r12), %eax
movl %eax, 0x20(%r15)
movq %r12, 0x10(%r15)
movq %r15, %r14
addq $0x28, %r14
movups (%r13), %xmm0
movups %xmm0, 0x28(%r15)
movq 0x80(%r12), %rax
movq %rax, 0x80(%r15)
movq 0xa0(%r12), %rax
movq %rax, 0xa0(%r15)
movq 0x38(%r12), %rax
movq %rax, 0x38(%r15)
movq $0x402, 0xc8(%r15) # imm = 0x402
movq 0x18(%r12), %rdi
movq %r15, %rsi
callq 0x82af
movq %r15, %rdi
xorl %esi, %esi
movl $0x1, %edx
movq %r14, %rcx
callq 0x7a51
movq 0x28(%rsp), %r14
jmp 0x8873
leaq 0xcef4(%rip), %rsi      # 0x1573f
leaq 0xcd58(%rip), %rdx      # 0x155aa
movl $0x4, %edi
callq 0x44b4
testl %eax, %eax
movq 0x28(%rsp), %r14
je 0x8873
leaq 0xceeb(%rip), %rdi      # 0x15757
xorl %eax, %eax
callq 0x45a0
testq %r15, %r15
je 0x8898
movq %r15, %rdi
movq %r14, %rsi
movl %ebx, %edx
movl $0x1, %ecx
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x85c4
movq %r14, %rdi
callq 0x3060
movq 0xc0, %rax
movq 0x10(%rax), %rax
movq 0x58(%rax), %rax
movslq %ebx, %rsi
xorl %edi, %edi
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmpq *%rax
leaq 0xce02(%rip), %rdi      # 0x156ce
leaq 0xccd7(%rip), %rsi      # 0x155aa
leaq 0xce09(%rip), %rcx      # 0x156e3
movl $0xa9a, %edx            # imm = 0xA9A
callq 0x3220