// File: /workspace/github_c_makefile_star2_O3/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 0x877b
movq %r8, %r13
movq %rcx, %r12
movl %edx, %ebx
movq %rsi, %r15
movq %rdi, %r14
leaq 0xd17c(%rip), %rsi      # 0x15763
leaq 0xcfe0(%rip), %rdx      # 0x155ce
movl $0x4, %edi
callq 0x4447
testl %eax, %eax
je 0x860f
leaq 0xd172(%rip), %rdi      # 0x15775
movq %r14, %rsi
movl %ebx, %edx
xorl %eax, %eax
callq 0x4539
testb $0x1, 0xc8(%r14)
je 0x875b
movq %r15, 0x28(%rsp)
movq 0x18(%r14), %rbp
movq (%rbp), %r15
testq %r15, %r15
je 0x8651
leaq 0x28(%r15), %rdi
movq %r12, %rsi
movq %r13, %rdx
callq 0x3470
testl %eax, %eax
jne 0x864c
cmpq %r14, 0x10(%r15)
je 0x8753
movq (%r15), %r15
jmp 0x862a
xorps %xmm0, %xmm0
movaps %xmm0, 0x40(%rsp)
movaps %xmm0, 0x30(%rsp)
movq 0x98(%r14), %rsi
movaps 0x30(%rsp), %xmm0
movaps 0x40(%rsp), %xmm1
movups %xmm1, 0x10(%rsp)
movups %xmm0, (%rsp)
movq %rbp, %rdi
callq 0x87a5
testq %rax, %rax
movq 0x28(%rsp), %r15
je 0x86fc
movq %rax, %r13
movl 0x20(%r14), %eax
movl %eax, 0x20(%r13)
movq %r14, 0x10(%r13)
movq %r13, %rbp
addq $0x28, %rbp
movups (%r12), %xmm0
movups %xmm0, 0x28(%r13)
movq 0x80(%r14), %rax
movq %rax, 0x80(%r13)
movq 0xa0(%r14), %rax
movq %rax, 0xa0(%r13)
movq 0x38(%r14), %rax
movq %rax, 0x38(%r13)
movq $0x402, 0xc8(%r13) # imm = 0x402
movq 0x18(%r14), %rdi
movq %r13, %rsi
callq 0x81bd
movq %r13, %rdi
xorl %esi, %esi
movl $0x1, %edx
movq %rbp, %rcx
callq 0x7979
movq %r13, %r14
jmp 0x875b
leaq 0xd060(%rip), %rsi      # 0x15763
leaq 0xcec4(%rip), %rdx      # 0x155ce
movl $0x4, %edi
callq 0x4447
testl %eax, %eax
je 0x8726
leaq 0xd05c(%rip), %rdi      # 0x1577b
xorl %eax, %eax
callq 0x4539
movq %r15, %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
movq %r15, %r14
movq 0x28(%rsp), %r15
movq %r14, %rdi
movq %r15, %rsi
movl %ebx, %edx
movl $0x1, %ecx
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x8488
leaq 0xcf70(%rip), %rdi      # 0x156f2
leaq 0xce45(%rip), %rsi      # 0x155ce
leaq 0xcf77(%rip), %rcx      # 0x15707
movl $0xa9a, %edx            # imm = 0xA9A
callq 0x3220