// File: /workspace/github_c_makefile_star2_O0/sfeakes[P]unifi-motion/mongoose.c
// Function: mg_call
MG_INTERNAL void mg_call(struct mg_connection *nc,
                         mg_event_handler_t ev_handler, void *user_data, int ev,
                         void *ev_data) {
  static int nesting_level = 0;
  nesting_level++;
  if (ev_handler == NULL) {
    /*
     * If protocol handler is specified, call it. Otherwise, call user-specified
     * event handler.
     */
    ev_handler = nc->proto_handler ? nc->proto_handler : nc->handler;
  }
  if (ev != MG_EV_POLL) {
    DBG(("%p %s ev=%d ev_data=%p flags=%lu rmbl=%d smbl=%d", nc,
         ev_handler == nc->handler ? "user" : "proto", ev, ev_data, nc->flags,
         (int) nc->recv_mbuf.len, (int) nc->send_mbuf.len));
  }

#if !defined(NO_LIBC) && MG_ENABLE_HEXDUMP
  if (nc->mgr->hexdump_file != NULL && ev != MG_EV_POLL && ev != MG_EV_RECV &&
      ev != MG_EV_SEND /* handled separately */) {
    mg_hexdump_connection(nc, nc->mgr->hexdump_file, NULL, 0, ev);
  }
#endif
  if (ev_handler != NULL) {
    unsigned long flags_before = nc->flags;
    size_t recv_mbuf_before = nc->recv_mbuf.len, recved;
    ev_handler(nc, ev, ev_data MG_UD_ARG(user_data));
    recved = (recv_mbuf_before - nc->recv_mbuf.len);
    /* Prevent user handler from fiddling with system flags. */
    if (ev_handler == nc->handler && nc->flags != flags_before) {
      nc->flags = (flags_before & ~_MG_CALLBACK_MODIFIABLE_FLAGS_MASK) |
                  (nc->flags & _MG_CALLBACK_MODIFIABLE_FLAGS_MASK);
    }
    /* It's important to not double-count recved bytes, and since mg_call can be
     * called recursively (e.g. proto_handler invokes user handler), we keep
     * track of recursion and only report received bytes at the top level. */
    if (nesting_level == 1 && recved > 0 && !(nc->flags & MG_F_UDP)) {
      nc->iface->vtable->recved(nc, recved);
    }
  }
  if (ev != MG_EV_POLL) {
    DBG(("%p after %s flags=%lu rmbl=%d smbl=%d", nc,
         ev_handler == nc->handler ? "user" : "proto", nc->flags,
         (int) nc->recv_mbuf.len, (int) nc->send_mbuf.len));
  }
  nesting_level--;
#if !MG_ENABLE_CALLBACK_USERDATA
  (void) user_data;
#endif
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x60, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movl %ecx, -0x1c(%rbp)
movq %r8, -0x28(%rbp)
movl 0x1cddf(%rip), %eax     # 0x276e0
addl $0x1, %eax
movl %eax, 0x1cdd6(%rip)     # 0x276e0
cmpq $0x0, -0x10(%rbp)
jne 0xa947
movq -0x8(%rbp), %rax
cmpq $0x0, 0x80(%rax)
je 0xa930
movq -0x8(%rbp), %rax
movq 0x80(%rax), %rax
movq %rax, -0x48(%rbp)
jmp 0xa93f
movq -0x8(%rbp), %rax
movq 0x98(%rax), %rax
movq %rax, -0x48(%rbp)
movq -0x48(%rbp), %rax
movq %rax, -0x10(%rbp)
cmpl $0x0, -0x1c(%rbp)
je 0xa9d7
jmp 0xa953
movl $0x4, %edi
leaq 0x157fb(%rip), %rsi     # 0x2015a
leaq 0x14be4(%rip), %rdx     # 0x1f54a
callq 0x4650
cmpl $0x0, %eax
je 0xa9d3
movq -0x8(%rbp), %rsi
movq -0x10(%rbp), %rcx
movq -0x8(%rbp), %rax
movq 0x98(%rax), %rdi
leaq 0x15809(%rip), %rdx     # 0x20193
leaq 0x170af(%rip), %rax     # 0x21a40
cmpq %rdi, %rcx
cmoveq %rax, %rdx
movl -0x1c(%rbp), %ecx
movq -0x28(%rbp), %r8
movq -0x8(%rbp), %rax
movq 0xc8(%rax), %r9
movq -0x8(%rbp), %rax
movq 0x48(%rax), %rax
movl %eax, %r10d
movq -0x8(%rbp), %rax
movq 0x60(%rax), %rax
leaq 0x1579e(%rip), %rdi     # 0x20162
movl %r10d, (%rsp)
movl %eax, 0x8(%rsp)
movb $0x0, %al
callq 0x47a0
jmp 0xa9d5
jmp 0xa9d7
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rax
cmpq $0x0, 0x8(%rax)
je 0xaa17
cmpl $0x0, -0x1c(%rbp)
je 0xaa17
cmpl $0x3, -0x1c(%rbp)
je 0xaa17
cmpl $0x4, -0x1c(%rbp)
je 0xaa17
movq -0x8(%rbp), %rdi
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rax
movq 0x8(%rax), %rsi
movl -0x1c(%rbp), %r8d
xorl %eax, %eax
movl %eax, %edx
xorl %ecx, %ecx
callq 0xb7f0
cmpq $0x0, -0x10(%rbp)
je 0xaaee
movq -0x8(%rbp), %rax
movq 0xc8(%rax), %rax
movq %rax, -0x30(%rbp)
movq -0x8(%rbp), %rax
movq 0x48(%rax), %rax
movq %rax, -0x38(%rbp)
movq -0x10(%rbp), %rax
movq -0x8(%rbp), %rdi
movl -0x1c(%rbp), %esi
movq -0x28(%rbp), %rdx
callq *%rax
movq -0x38(%rbp), %rax
movq -0x8(%rbp), %rcx
subq 0x48(%rcx), %rax
movq %rax, -0x40(%rbp)
movq -0x10(%rbp), %rax
movq -0x8(%rbp), %rcx
cmpq 0x98(%rcx), %rax
jne 0xaaaa
movq -0x8(%rbp), %rax
movq 0xc8(%rax), %rax
cmpq -0x30(%rbp), %rax
je 0xaaaa
movq -0x30(%rbp), %rcx
andq $-0x3f03d01, %rcx       # imm = 0xFC0FC2FF
movq -0x8(%rbp), %rax
movq 0xc8(%rax), %rax
andq $0x3f03d00, %rax        # imm = 0x3F03D00
orq %rax, %rcx
movq -0x8(%rbp), %rax
movq %rcx, 0xc8(%rax)
cmpl $0x1, 0x1cc2f(%rip)     # 0x276e0
jne 0xaaec
cmpq $0x0, -0x40(%rbp)
jbe 0xaaec
movq -0x8(%rbp), %rax
movq 0xc8(%rax), %rax
andq $0x2, %rax
cmpq $0x0, %rax
jne 0xaaec
movq -0x8(%rbp), %rax
movq 0xc0(%rax), %rax
movq 0x10(%rax), %rax
movq 0x58(%rax), %rax
movq -0x8(%rbp), %rdi
movq -0x40(%rbp), %rsi
callq *%rax
jmp 0xaaee
cmpl $0x0, -0x1c(%rbp)
je 0xab6e
jmp 0xaaf6
movl $0x4, %edi
leaq 0x15658(%rip), %rsi     # 0x2015a
leaq 0x14a41(%rip), %rdx     # 0x1f54a
callq 0x4650
cmpl $0x0, %eax
je 0xab6a
movq -0x8(%rbp), %rsi
movq -0x10(%rbp), %rcx
movq -0x8(%rbp), %rax
movq 0x98(%rax), %rdi
leaq 0x15666(%rip), %rdx     # 0x20193
leaq 0x16f0c(%rip), %rax     # 0x21a40
cmpq %rdi, %rcx
cmoveq %rax, %rdx
movq -0x8(%rbp), %rax
movq 0xc8(%rax), %rcx
movq -0x8(%rbp), %rax
movq 0x48(%rax), %rax
movl %eax, %r8d
movq -0x8(%rbp), %rax
movq 0x60(%rax), %rax
movl %eax, %r9d
leaq 0x15636(%rip), %rdi     # 0x20199
movb $0x0, %al
callq 0x47a0
jmp 0xab6c
jmp 0xab6e
movl 0x1cb6c(%rip), %eax     # 0x276e0
addl $-0x1, %eax
movl %eax, 0x1cb63(%rip)     # 0x276e0
addq $0x60, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)