// File: /workspace/github_c_makefile_star2_O2/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 0x82ec
movq %r8, %rbp
movq %rcx, %r12
movl %edx, %ebx
movq %rsi, %r14
movq %rdi, %r15
leaq 0xc5dc(%rip), %rsi      # 0x14743
leaq 0xc440(%rip), %rdx      # 0x145ae
pushq $0x4
popq %rdi
callq 0x4227
testl %eax, %eax
je 0x818d
leaq 0xc5d4(%rip), %rdi      # 0x14755
movq %r15, %rsi
movl %ebx, %edx
xorl %eax, %eax
callq 0x430a
movq %r14, 0x28(%rsp)
testb $0x1, 0xc8(%r15)
jne 0x81a4
movq %r15, %r13
jmp 0x8275
movq 0x18(%r15), %r14
movq %r14, %r13
movq (%r13), %r13
testq %r13, %r13
je 0x81d2
leaq 0x28(%r13), %rdi
movq %r12, %rsi
movq %rbp, %rdx
callq 0x3470
testl %eax, %eax
jne 0x81ab
cmpq %r15, 0x10(%r13)
jne 0x81ab
jmp 0x8275
xorps %xmm0, %xmm0
movaps %xmm0, 0x40(%rsp)
movaps %xmm0, 0x30(%rsp)
movq 0x98(%r15), %rsi
movaps 0x30(%rsp), %xmm0
movaps 0x40(%rsp), %xmm1
movups %xmm1, 0x10(%rsp)
movups %xmm0, (%rsp)
movq %r14, %rdi
callq 0x8316
testq %rax, %rax
je 0x8295
movq %rax, %r13
movl 0x20(%r15), %eax
movl %eax, 0x20(%r13)
movq %r15, 0x10(%r13)
movq %r13, %r14
addq $0x28, %r14
movups (%r12), %xmm0
movups %xmm0, 0x28(%r13)
movq 0x80(%r15), %rax
movq %rax, 0x80(%r13)
movq 0xa0(%r15), %rax
movq %rax, 0xa0(%r13)
movq 0x38(%r15), %rax
movq %rax, 0x38(%r13)
movq $0x402, 0xc8(%r13) # imm = 0x402
movq 0x18(%r15), %rdi
movq %r13, %rsi
callq 0x7da5
pushq $0x1
popq %rdx
movq %r13, %rdi
xorl %esi, %esi
movq %r14, %rcx
callq 0x75bd
pushq $0x1
popq %rcx
movq %r13, %rdi
movq 0x28(%rsp), %rsi
movl %ebx, %edx
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x8010
leaq 0xc4a7(%rip), %rsi      # 0x14743
leaq 0xc30b(%rip), %rdx      # 0x145ae
pushq $0x4
popq %rdi
callq 0x4227
testl %eax, %eax
je 0x82bd
leaq 0xc4a5(%rip), %rdi      # 0x1475b
xorl %eax, %eax
callq 0x430a
movq 0x28(%rsp), %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 0xc3df(%rip), %rdi      # 0x146d2
leaq 0xc2b4(%rip), %rsi      # 0x145ae
leaq 0xc3e6(%rip), %rcx      # 0x146e7
movl $0xa9a, %edx            # imm = 0xA9A
callq 0x3220