// File: /workspace/github_c_makefile_star2_O1/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
leaq 0x10(%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 0x114e2
cmpl $0x1, %ebp
je 0x1149d
cmpl $0x3, %ebp
jne 0x11567
leaq 0x40(%rbx), %r15
movq %r15, 0x8(%rsp)
movq 0x48(%rbx), %r8
movl $0xffffffff, %r13d      # imm = 0xFFFFFFFF
cmpq $0x2, %r8
jb 0x111ab
movq (%r15), %r9
movzbl (%r9), %edx
movl %edx, %edi
shrl $0x4, %edi
leaq 0x1(%r9), %rax
leaq -0x1(%r8), %r11
leaq (%r9,%r8), %r10
decq %r10
leaq (%r9,%r8), %rsi
xorl %ecx, %ecx
xorl %r14d, %r14d
movzbl (%rax), %r15d
movl %r15d, %ebp
andl $0x7f, %ebp
shll %cl, %ebp
movq %r14, %r12
movslq %ebp, %r14
addq %r12, %r14
testb %r15b, %r15b
jns 0x11142
cmpq $0x1c, %rcx
je 0x111a0
incq %rax
addq $0x7, %rcx
decq %r11
jne 0x11111
movq %r10, %rax
jmp 0x11146
leaq 0x1(%rax), %rsi
testb %r15b, %r15b
js 0x111a6
addq %r8, %r9
subq %rsi, %r9
cmpq %r9, %r14
movq 0x8(%rsp), %r15
ja 0x111ab
leaq (%rsi,%r14), %rbp
movl %edi, 0x10(%rsp)
shrl %edx
andl $0x3, %edx
movl %edx, 0x14(%rsp)
decl %edi
cmpl $0x8, %edi
ja 0x11194
leaq 0x4246(%rip), %r8       # 0x153c0
movslq (%r8,%rdi,4), %rcx
addq %r8, %rcx
jmpq *%rcx
movzbl (%rsi), %ecx
shll $0x8, %ecx
movzbl 0x2(%rax), %eax
orl %ecx, %eax
movw %ax, 0x42(%rsp)
subl (%r15), %ebp
movl %ebp, 0x18(%rsp)
movl %ebp, %r13d
jmp 0x111ab
movl $0xfffffffe, %r13d      # imm = 0xFFFFFFFE
movq 0x8(%rsp), %r15
testl %r13d, %r13d
js 0x111d6
movl 0x10(%rsp), %esi
movl $0xc8, %eax
addl %eax, %esi
movq %rbx, %rdi
leaq 0x10(%rsp), %rdx
callq *0x98(%rbx)
movl %r13d, %esi
movq %r15, %rdi
callq 0x6bb8
jmp 0x111e3
cmpl $-0x1, %r13d
je 0x111e3
orb $0x8, 0xc9(%rbx)
testl %r13d, %r13d
jns 0x110d9
jmp 0x11567
movzbl (%rsi), %ecx
shll $0x8, %ecx
movzbl 0x2(%rax), %esi
orq %rcx, %rsi
movq %rsi, 0x28(%rsp)
leaq 0x3(%rax), %rcx
movq %rcx, 0x20(%rsp)
addq %rsi, %rax
addq $0x3, %rax
movl $0xfffffffe, %r13d      # imm = 0xFFFFFFFE
cmpq %rbp, %rax
ja 0x111ab
testl %edx, %edx
je 0x11242
movq %rbp, %rcx
subq %rax, %rcx
cmpq $0x2, %rcx
jl 0x111ab
movzwl (%rax), %ecx
rolw $0x8, %cx
movw %cx, 0x42(%rsp)
addq $0x2, %rax
movq %rax, 0x30(%rsp)
movq %rbp, %rcx
subq %rax, %rcx
movq %rcx, 0x38(%rsp)
jmp 0x11194
movzbl (%rsi), %ecx
shll $0x8, %ecx
movzbl 0x2(%rax), %edx
orq %rcx, %rdx
movq %rdx, 0x50(%rsp)
leaq 0x3(%rax), %rcx
movq %rcx, 0x48(%rsp)
addq %rdx, %rax
addq $0x3, %rax
leaq -0x4(%rbp), %rcx
movl $0xfffffffe, %r13d      # imm = 0xFFFFFFFE
cmpq %rcx, %rax
ja 0x111ab
movb (%rax), %cl
movb %cl, 0x44(%rsp)
movb 0x1(%rax), %cl
movb %cl, 0x45(%rsp)
movzwl 0x2(%rax), %edx
rolw $0x8, %dx
movw %dx, 0x46(%rsp)
leaq 0x4(%rax), %rdx
cmpq %rbp, %rdx
jae 0x111ab
movzwl 0x4(%rax), %edx
rolw $0x8, %dx
movzwl %dx, %edx
movq %rdx, 0x60(%rsp)
leaq 0x6(%rax), %rsi
movq %rsi, 0x58(%rsp)
addq %rdx, %rax
addq $0x6, %rax
cmpq %rbp, %rax
ja 0x111ab
testb $0x4, %cl
je 0x11309
cmpq %rbp, %rax
jae 0x111ab
movzwl (%rax), %edx
rolw $0x8, %dx
movzwl %dx, %edx
movq %rdx, 0x70(%rsp)
leaq 0x2(%rax), %rsi
movq %rsi, 0x68(%rsp)
addq %rdx, %rax
addq $0x2, %rax
testb $0x4, %cl
je 0x11339
cmpq %rbp, %rax
jae 0x111ab
movzwl (%rax), %edx
rolw $0x8, %dx
movzwl %dx, %edx
movq %rdx, 0x80(%rsp)
leaq 0x2(%rax), %rsi
movq %rsi, 0x78(%rsp)
addq %rdx, %rax
addq $0x2, %rax
testb %cl, %cl
jns 0x1136b
cmpq %rbp, %rax
jae 0x111ab
movzwl (%rax), %edx
rolw $0x8, %dx
movzwl %dx, %edx
movq %rdx, 0x90(%rsp)
leaq 0x2(%rax), %rsi
movq %rsi, 0x88(%rsp)
addq %rdx, %rax
addq $0x2, %rax
testb $0x40, %cl
je 0x1139e
cmpq %rbp, %rax
jae 0x111ab
movzwl (%rax), %ecx
rolw $0x8, %cx
movzwl %cx, %ecx
movq %rcx, 0xa0(%rsp)
leaq 0x2(%rax), %rdx
movq %rdx, 0x98(%rsp)
addq %rcx, %rax
addq $0x2, %rax
cmpq %rbp, %rax
jne 0x111ab
movl $0x3, %edi
leaq 0x6275(%rip), %rsi      # 0x17628
leaq 0x41f0(%rip), %rdx      # 0x155aa
callq 0x44b4
testl %eax, %eax
je 0x11194
movzbl 0x45(%rsp), %edx
movzwl 0x46(%rsp), %ecx
movl 0x50(%rsp), %r8d
movq 0x48(%rsp), %r9
movl 0x60(%rsp), %r10d
movl 0x70(%rsp), %r11d
movl 0x80(%rsp), %r15d
movl 0x90(%rsp), %r12d
movl 0xa0(%rsp), %r13d
leaq 0x622f(%rip), %rdi      # 0x17633
movl %r14d, %esi
xorl %eax, %eax
pushq 0x98(%rsp)
pushq %r13
pushq 0x98(%rsp)
pushq %r12
pushq 0x98(%rsp)
pushq %r15
movq 0x38(%rsp), %r15
pushq 0x98(%rsp)
pushq %r11
pushq 0x98(%rsp)
pushq %r10
callq 0x45a0
addq $0x50, %rsp
jmp 0x11194
movl $0xfffffffe, %r13d      # imm = 0xFFFFFFFE
cmpq $0x2, %r14
jl 0x111ab
movb 0x2(%rax), %al
movb %al, 0x40(%rsp)
jmp 0x11194
movl $0xfffffffe, %r13d      # imm = 0xFFFFFFFE
cmpq $0x2, %r14
jl 0x111ab
movzbl (%rsi), %ecx
shll $0x8, %ecx
movzbl 0x2(%rax), %edx
orl %ecx, %edx
movw %dx, 0x42(%rsp)
addq $0x3, %rax
movq %rax, 0x30(%rsp)
addq $-0x2, %r14
movq %r14, 0x38(%rsp)
jmp 0x11194
cmpq $0x0, 0x88(%rbx)
jne 0x11567
leaq -0x434(%rip), %rax      # 0x1107e
movq %rax, 0x80(%rbx)
movl $0x1, %edi
movl $0x10, %esi
callq 0x3300
movq %rax, 0x88(%rbx)
leaq 0xa3(%rip), %rax        # 0x11579
movq %rax, 0x90(%rbx)
jmp 0x11567
movq 0x88(%rbx), %r14
callq 0x4b23
movzwl (%r14), %eax
testw %ax, %ax
je 0x11567
movsd 0x8(%r14), %xmm1
xorpd %xmm2, %xmm2
ucomisd %xmm2, %xmm1
jbe 0x11567
subsd %xmm1, %xmm0
movzwl %ax, %eax
xorps %xmm1, %xmm1
cvtsi2sd %eax, %xmm1
ucomisd %xmm1, %xmm0
jbe 0x11567
leaq 0x60ec(%rip), %rsi      # 0x1760e
leaq 0x4081(%rip), %rdx      # 0x155aa
movl $0x3, %edi
callq 0x44b4
testl %eax, %eax
je 0x11545
leaq 0x60dd(%rip), %rdi      # 0x1761b
xorl %eax, %eax
callq 0x45a0
movq %rbx, %rdi
movl $0xc, %esi
xorl %edx, %edx
xorl %ecx, %ecx
addq $0xa8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x117bc
addq $0xa8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq