// File: /workspace/github_c_makefile_star2_O2/sfeakes[P]unifi-motion/mongoose.c
// Function: mqtt_handler
static void mqtt_handler(struct mg_connection *nc, int ev,
                         void *ev_data MG_UD_ARG(void *user_data)) {
  struct mbuf *io = &nc->recv_mbuf;
  struct mg_mqtt_message mm;
  memset(&mm, 0, sizeof(mm));

  nc->handler(nc, ev, ev_data MG_UD_ARG(user_data));

  switch (ev) {
    case MG_EV_ACCEPT:
      if (nc->proto_data == NULL) mg_set_protocol_mqtt(nc);
      break;
    case MG_EV_RECV: {
      /* There can be multiple messages in the buffer, process them all. */
      while (1) {
        int len = parse_mqtt(io, &mm);
        if (len < 0) {
          if (len == -1) break; /* not fully buffered */
          /* Protocol error. */
          nc->flags |= MG_F_CLOSE_IMMEDIATELY;
          break;
        }
        nc->handler(nc, MG_MQTT_EVENT_BASE + mm.cmd, &mm MG_UD_ARG(user_data));
        mbuf_remove(io, len);
      }
      break;
    }
    case MG_EV_POLL: {
      struct mg_mqtt_proto_data *pd =
          (struct mg_mqtt_proto_data *) nc->proto_data;
      double now = mg_time();
      if (pd->keep_alive > 0 && pd->last_control_time > 0 &&
          (now - pd->last_control_time) > pd->keep_alive) {
        LOG(LL_DEBUG, ("Send PINGREQ"));
        mg_mqtt_ping(nc);
      }
      break;
    }
  }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xa8, %rsp
movq %rdx, %r14
movl %esi, %ebp
movq %rdi, %rbx
movq %rsp, %rdi
movl $0x98, %edx
xorl %esi, %esi
callq 0x3240
movq %rbx, %rdi
movl %ebp, %esi
movq %r14, %rdx
callq *0x98(%rbx)
testl %ebp, %ebp
je 0x10936
cmpl $0x1, %ebp
je 0x1090f
cmpl $0x3, %ebp
jne 0x109ba
leaq 0x40(%rbx), %r14
movl $0xc8, %r15d
leaq 0x3e2c(%rip), %rbp      # 0x143ac
movq 0x48(%rbx), %rdi
cmpq $0x2, %rdi
jb 0x109ba
movq (%r14), %r8
movzbl (%r8), %eax
movl %eax, %edx
shrl $0x4, %edx
leaq (%r8,%rdi), %rsi
decq %rdi
movb $0x1, %r11b
xorl %ecx, %ecx
xorl %r9d, %r9d
xorl %r10d, %r10d
cmpq %r9, %rdi
je 0x105e4
movzbl 0x1(%r8,%r9), %r12d
movl %r12d, %r11d
andl $0x7f, %r11d
shll %cl, %r11d
movslq %r11d, %r11
leaq (%r10,%r11), %r13
testb %r12b, %r12b
jns 0x105fa
incq %r9
addl $0x7, %ecx
xorl %r11d, %r11d
movq %r13, %r10
cmpq $0x5, %r9
jne 0x105ac
jmp 0x109b3
testb $0x1, %r11b
je 0x109ba
leaq (%rsi,%r10), %r12
movq %r10, %r13
movq %rsi, %rcx
jmp 0x1060b
leaq (%r8,%r9), %rcx
addq $0x2, %rcx
addq %rcx, %r10
addq %r11, %r10
movq %r10, %r12
subq %rcx, %rsi
cmpq %rsi, %r13
ja 0x109ba
movl %edx, (%rsp)
shrl %eax
andl $0x3, %eax
movl %eax, 0x4(%rsp)
decl %edx
cmpl $0x8, %edx
ja 0x10640
movslq (%rbp,%rdx,4), %rdx
addq %rbp, %rdx
jmpq *%rdx
movzwl (%rcx), %eax
rolw $0x8, %ax
movw %ax, 0x32(%rsp)
subq (%r14), %r12
movl %r12d, 0x8(%rsp)
testl %r12d, %r12d
js 0x109ad
movl (%rsp), %esi
addl %r15d, %esi
movq %rbx, %rdi
movq %rsp, %rdx
callq *0x98(%rbx)
andl $0x7fffffff, %r12d      # imm = 0x7FFFFFFF
movq %r14, %rdi
movq %r12, %rsi
callq 0x6845
jmp 0x10580
movzwl (%rcx), %edx
rolw $0x8, %dx
movzwl %dx, %edx
movq %rdx, 0x18(%rsp)
leaq 0x2(%rcx), %rsi
movq %rsi, 0x10(%rsp)
addq %rdx, %rcx
addq $0x2, %rcx
cmpq %r12, %rcx
ja 0x109b3
testl %eax, %eax
je 0x106c6
movq %r12, %rax
subq %rcx, %rax
cmpq $0x2, %rax
jl 0x109b3
movzwl (%rcx), %eax
rolw $0x8, %ax
movw %ax, 0x32(%rsp)
addq $0x2, %rcx
movq %rcx, 0x20(%rsp)
movq %r12, %rax
subq %rcx, %rax
movq %rax, 0x28(%rsp)
jmp 0x10640
movzwl (%rcx), %eax
rolw $0x8, %ax
movzwl %ax, %eax
movq %rax, 0x40(%rsp)
leaq 0x2(%rcx), %rdx
movq %rdx, 0x38(%rsp)
addq %rax, %rcx
addq $0x2, %rcx
leaq -0x4(%r12), %rax
cmpq %rax, %rcx
ja 0x109b3
movb (%rcx), %al
movb %al, 0x34(%rsp)
movb 0x1(%rcx), %al
movb %al, 0x35(%rsp)
movzwl 0x2(%rcx), %edx
rolw $0x8, %dx
movw %dx, 0x36(%rsp)
leaq 0x4(%rcx), %rdx
cmpq %r12, %rdx
jae 0x109b3
movzwl 0x4(%rcx), %edx
rolw $0x8, %dx
movzwl %dx, %edx
movq %rdx, 0x50(%rsp)
leaq 0x6(%rcx), %rsi
movq %rsi, 0x48(%rsp)
addq %rdx, %rcx
addq $0x6, %rcx
cmpq %r12, %rcx
ja 0x109b3
testb $0x4, %al
je 0x107ac
cmpq %r12, %rcx
jae 0x109b3
movzwl (%rcx), %edx
rolw $0x8, %dx
movzwl %dx, %edx
movq %rdx, 0x60(%rsp)
leaq 0x2(%rcx), %rsi
movq %rsi, 0x58(%rsp)
addq %rdx, %rcx
addq $0x2, %rcx
cmpq %r12, %rcx
jae 0x109b3
movzwl (%rcx), %edx
rolw $0x8, %dx
movzwl %dx, %edx
movq %rdx, 0x70(%rsp)
leaq 0x2(%rcx), %rsi
movq %rsi, 0x68(%rsp)
addq %rdx, %rcx
addq $0x2, %rcx
testb %al, %al
jns 0x107db
cmpq %r12, %rcx
jae 0x109b3
movzwl (%rcx), %edx
rolw $0x8, %dx
movzwl %dx, %edx
movq %rdx, 0x80(%rsp)
leaq 0x2(%rcx), %rsi
movq %rsi, 0x78(%rsp)
addq %rdx, %rcx
addq $0x2, %rcx
testb $0x40, %al
je 0x1080d
cmpq %r12, %rcx
jae 0x109b3
movzwl (%rcx), %eax
rolw $0x8, %ax
movzwl %ax, %eax
movq %rax, 0x90(%rsp)
leaq 0x2(%rcx), %rdx
movq %rdx, 0x88(%rsp)
addq %rax, %rcx
addq $0x2, %rcx
cmpq %r12, %rcx
jne 0x109b3
pushq $0x3
popq %rdi
leaq 0x5e09(%rip), %rsi      # 0x16629
leaq 0x3d87(%rip), %rdx      # 0x145ae
callq 0x4227
testl %eax, %eax
je 0x10640
movzbl 0x35(%rsp), %edx
movzwl 0x36(%rsp), %ecx
movl 0x40(%rsp), %r8d
movq 0x38(%rsp), %r9
movl 0x50(%rsp), %eax
movq %rax, 0xa0(%rsp)
movl 0x60(%rsp), %eax
movq %rax, 0x98(%rsp)
movl 0x70(%rsp), %r10d
movl 0x80(%rsp), %r11d
movl 0x90(%rsp), %r15d
leaq 0x5db8(%rip), %rdi      # 0x16634
movl %r13d, %esi
xorl %eax, %eax
pushq 0x88(%rsp)
pushq %r15
movl $0xc8, %r15d
pushq 0x88(%rsp)
pushq %r11
pushq 0x88(%rsp)
pushq %r10
pushq 0x88(%rsp)
pushq 0xd0(%rsp)
pushq 0x88(%rsp)
pushq 0xe8(%rsp)
callq 0x430a
addq $0x50, %rsp
jmp 0x10640
cmpq $0x2, %r13
jl 0x109b3
movb 0x1(%rcx), %al
movb %al, 0x30(%rsp)
jmp 0x10640
cmpq $0x2, %r13
jl 0x109b3
movzwl (%rcx), %eax
rolw $0x8, %ax
movw %ax, 0x32(%rsp)
addq $0x2, %rcx
movq %rcx, 0x20(%rsp)
addq $-0x2, %r13
movq %r13, 0x28(%rsp)
jmp 0x10640
cmpq $0x0, 0x88(%rbx)
jne 0x109ba
movq %rbx, %rdi
addq $0xa8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x104eb
movq 0x88(%rbx), %r14
callq 0x483c
movzwl (%r14), %eax
testw %ax, %ax
je 0x109ba
movsd 0x8(%r14), %xmm1
xorpd %xmm2, %xmm2
ucomisd %xmm2, %xmm1
jbe 0x109ba
subsd %xmm1, %xmm0
movzwl %ax, %eax
cvtsi2sd %eax, %xmm1
ucomisd %xmm1, %xmm0
jbe 0x109ba
leaq 0x5c9c(%rip), %rsi      # 0x1660f
leaq 0x3c34(%rip), %rdx      # 0x145ae
pushq $0x3
popq %rdi
callq 0x4227
testl %eax, %eax
je 0x10994
leaq 0x5c8f(%rip), %rdi      # 0x1661c
xorl %eax, %eax
callq 0x430a
movq %rbx, %rdi
addq $0xa8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x10ff9
cmpl $-0x1, %r12d
je 0x109ba
orb $0x8, 0xc9(%rbx)
addq $0xa8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq