// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x70, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
movq %rcx, -0x20(%rbp)
movq %r8, -0x28(%rbp)
movq -0x8(%rbp), %rax
movq 0xc8(%rax), %rax
andq $0x2, %rax
cmpq $0x0, %rax
je 0xbc22
jmp 0xbc41
leaq 0x13a45(%rip), %rdi     # 0x1f66e
leaq 0x1391a(%rip), %rsi     # 0x1f54a
movl $0xa9a, %edx            # imm = 0xA9A
leaq 0x13a47(%rip), %rcx     # 0x1f683
callq 0x3230
jmp 0xbc43
movl $0x4, %edi
leaq 0x13a90(%rip), %rsi     # 0x1f6df
leaq 0x138f4(%rip), %rdx     # 0x1f54a
callq 0x4650
cmpl $0x0, %eax
je 0xbc75
movq -0x8(%rbp), %rsi
movl -0x14(%rbp), %edx
leaq 0x13a83(%rip), %rdi     # 0x1f6f1
movb $0x0, %al
callq 0x47a0
jmp 0xbc77
movq -0x8(%rbp), %rax
movq 0xc8(%rax), %rax
andq $0x1, %rax
cmpq $0x0, %rax
je 0xbe61
movq -0x8(%rbp), %rax
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rax
movq 0x18(%rax), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0xbeb0
movq %rax, -0x8(%rbp)
cmpq $0x0, -0x8(%rbp)
je 0xbcf7
movq -0x8(%rbp), %rdi
addq $0x28, %rdi
movq -0x20(%rbp), %rsi
movq -0x28(%rbp), %rdx
callq 0x3300
cmpl $0x0, %eax
jne 0xbcde
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rax
cmpq -0x30(%rbp), %rax
jne 0xbcde
jmp 0xbcf7
jmp 0xbce0
movq -0x30(%rbp), %rax
movq 0x18(%rax), %rdi
movq -0x8(%rbp), %rsi
callq 0xbeb0
movq %rax, -0x8(%rbp)
jmp 0xbcad
cmpq $0x0, -0x8(%rbp)
jne 0xbe5f
leaq -0x50(%rbp), %rdi
xorl %esi, %esi
movl $0x20, %edx
callq 0x3260
movq -0x30(%rbp), %rax
movq 0x18(%rax), %rdi
movq -0x30(%rbp), %rax
movq 0x98(%rax), %rsi
leaq -0x50(%rbp), %rax
movq (%rax), %rcx
movq %rcx, (%rsp)
movq 0x8(%rax), %rcx
movq %rcx, 0x8(%rsp)
movq 0x10(%rax), %rcx
movq %rcx, 0x10(%rsp)
movq 0x18(%rax), %rax
movq %rax, 0x18(%rsp)
callq 0xbef0
movq %rax, -0x8(%rbp)
cmpq $0x0, -0x8(%rbp)
je 0xbe2c
movq -0x30(%rbp), %rax
movl 0x20(%rax), %ecx
movq -0x8(%rbp), %rax
movl %ecx, 0x20(%rax)
movq -0x30(%rbp), %rcx
movq -0x8(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0x8(%rbp), %rax
movq -0x20(%rbp), %rcx
movq (%rcx), %rdx
movq %rdx, 0x28(%rax)
movq 0x8(%rcx), %rcx
movq %rcx, 0x30(%rax)
movq -0x30(%rbp), %rax
movq 0x80(%rax), %rcx
movq -0x8(%rbp), %rax
movq %rcx, 0x80(%rax)
movq -0x30(%rbp), %rax
movq 0xa0(%rax), %rcx
movq -0x8(%rbp), %rax
movq %rcx, 0xa0(%rax)
movq -0x30(%rbp), %rax
movq 0x38(%rax), %rcx
movq -0x8(%rbp), %rax
movq %rcx, 0x38(%rax)
movq -0x8(%rbp), %rax
movq $0x2, 0xc8(%rax)
movq -0x8(%rbp), %rax
movq 0xc8(%rax), %rcx
orq $0x400, %rcx            # imm = 0x400
movq %rcx, 0xc8(%rax)
movq -0x30(%rbp), %rax
movq 0x18(%rax), %rdi
movq -0x8(%rbp), %rsi
callq 0xb5c0
movq -0x8(%rbp), %rdi
movq -0x8(%rbp), %rax
movq 0xa0(%rax), %rdx
movq -0x8(%rbp), %r8
addq $0x28, %r8
xorl %eax, %eax
movl %eax, %esi
movl $0x1, %ecx
callq 0xa8e0
jmp 0xbe5d
jmp 0xbe2e
movl $0x4, %edi
leaq 0x138a5(%rip), %rsi     # 0x1f6df
leaq 0x13709(%rip), %rdx     # 0x1f54a
callq 0x4650
cmpl $0x0, %eax
je 0xbe59
leaq 0x138a5(%rip), %rdi     # 0x1f6f7
movb $0x0, %al
callq 0x47a0
jmp 0xbe5b
jmp 0xbe5d
jmp 0xbe5f
jmp 0xbe61
cmpq $0x0, -0x8(%rbp)
je 0xbe7f
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movl -0x14(%rbp), %edx
movl $0x1, %ecx
callq 0xba40
jmp 0xbea5
movq -0x10(%rbp), %rdi
callq 0x3050
movq -0x8(%rbp), %rax
movq 0xc0(%rax), %rax
movq 0x10(%rax), %rax
movq 0x58(%rax), %rax
movq -0x8(%rbp), %rdi
movslq -0x14(%rbp), %rsi
callq *%rax
addq $0x70, %rsp
popq %rbp
retq
nopl (%rax,%rax)