// File: /workspace/github_c_makefile_star2_O3/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rcx, %r15
movl %edx, %ebp
movq %rsi, %r14
movq %rdi, %rbx
incl 0x16c8b(%rip)           # 0x1e620
testq %rsi, %rsi
jne 0x79ad
movq 0x80(%rbx), %r14
testq %r14, %r14
jne 0x79ad
movq 0x98(%rbx), %r14
testl %ebp, %ebp
je 0x7a13
leaq 0xe820(%rip), %rsi      # 0x161d8
leaq 0xdc0f(%rip), %rdx      # 0x155ce
movl $0x4, %edi
callq 0x4447
testl %eax, %eax
je 0x7a13
cmpq 0x98(%rbx), %r14
leaq 0x1009b(%rip), %rax     # 0x17a76
leaq 0xe82f(%rip), %rdx      # 0x16211
cmoveq %rax, %rdx
movq 0xc8(%rbx), %r9
movl 0x48(%rbx), %r10d
movl 0x60(%rbx), %r11d
leaq 0xe7e4(%rip), %rdi      # 0x161e0
movq %rbx, %rsi
movl %ebp, %ecx
movq %r15, %r8
xorl %eax, %eax
pushq %r11
pushq %r10
callq 0x4539
addq $0x10, %rsp
movq 0x18(%rbx), %rax
movq 0x8(%rax), %rsi
testq %rsi, %rsi
je 0x7a3e
cmpl $0x4, %ebp
ja 0x7a2f
movl $0x19, %eax
btl %ebp, %eax
jb 0x7a3e
movq %rbx, %rdi
xorl %edx, %edx
xorl %ecx, %ecx
movl %ebp, %r8d
callq 0x82fd
testq %r14, %r14
je 0x7ac0
movq 0x48(%rbx), %r12
movq 0xc8(%rbx), %r13
movq %rbx, %rdi
movl %ebp, %esi
movq %r15, %rdx
callq *%r14
movq 0x48(%rbx), %rax
cmpq 0x98(%rbx), %r14
jne 0x7a89
movq 0xc8(%rbx), %rcx
cmpq %r13, %rcx
je 0x7a89
andq $-0x3f03d01, %r13       # imm = 0xFC0FC2FF
andl $0x3f03d00, %ecx        # imm = 0x3F03D00
orq %r13, %rcx
movq %rcx, 0xc8(%rbx)
cmpl $0x1, 0x16b90(%rip)     # 0x1e620
sete %cl
cmpq %rax, %r12
setne %dl
andb %cl, %dl
cmpb $0x1, %dl
jne 0x7ac0
testb $0x2, 0xc8(%rbx)
jne 0x7ac0
subq %rax, %r12
movq 0xc0(%rbx), %rax
movq 0x10(%rax), %rax
movq %rbx, %rdi
movq %r12, %rsi
callq *0x58(%rax)
testl %ebp, %ebp
je 0x7b19
leaq 0xe70d(%rip), %rsi      # 0x161d8
leaq 0xdafc(%rip), %rdx      # 0x155ce
movl $0x4, %edi
callq 0x4447
testl %eax, %eax
je 0x7b19
cmpq 0x98(%rbx), %r14
leaq 0xff88(%rip), %rax      # 0x17a76
leaq 0xe71c(%rip), %rdx      # 0x16211
cmoveq %rax, %rdx
movq 0xc8(%rbx), %rcx
movl 0x48(%rbx), %r8d
movl 0x60(%rbx), %r9d
leaq 0xe708(%rip), %rdi      # 0x16217
movq %rbx, %rsi
xorl %eax, %eax
callq 0x4539
decl 0x16b01(%rip)           # 0x1e620
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq