// File: /workspace/github_c_makefile_star2_O3/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 $0xc8, %rsp
movq %rdx, %r14
movl %esi, %ebp
movq %rdi, %rbx
leaq 0x20(%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 0x115e3
cmpl $0x1, %ebp
je 0x1159e
cmpl $0x3, %ebp
jne 0x11685
movq 0x48(%rbx), %rax
cmpq $0x2, %rax
jb 0x11685
leaq 0x40(%rbx), %r11
movq (%r11), %rcx
movq %rcx, 0x8(%rsp)
movzbl (%rcx), %edx
movl %edx, %esi
shrl $0x4, %esi
leaq -0x1(%rax), %rdi
xorl %ecx, %ecx
xorl %r13d, %r13d
xorl %r15d, %r15d
movq 0x8(%rsp), %r8
movzbl 0x1(%r8,%r15), %r8d
movl %r8d, %r14d
andl $0x7f, %r14d
shll %cl, %r14d
movslq %r14d, %r12
leaq (%r12,%r13), %rbp
testb %r8b, %r8b
jns 0x11143
cmpq $0x4, %r15
je 0x1167e
incq %r15
addl $0x7, %ecx
movq %rbp, %r13
cmpq %r15, %rdi
jne 0x11105
jmp 0x11685
subq %r15, %rax
addq $-0x2, %rax
cmpq %rax, %rbp
ja 0x11685
movl %esi, 0x20(%rsp)
shrl %edx
andl $0x3, %edx
movl %edx, 0x24(%rsp)
decl %esi
cmpl $0x8, %esi
movq 0x8(%rsp), %r9
ja 0x11199
leaq (%r9,%r13), %rax
addq %r12, %rax
addq %r15, %rax
addq $0x2, %rax
leaq 0x424b(%rip), %rdi      # 0x153cc
movslq (%rdi,%rsi,4), %rcx
addq %rdi, %rcx
jmpq *%rcx
movzwl 0x2(%r9,%r15), %eax
rolw $0x8, %ax
movw %ax, 0x52(%rsp)
movq (%r11), %rax
movl %r14d, %ecx
subl %eax, %ecx
leal (%r9,%r13), %edx
addl %r15d, %edx
addl %edx, %ecx
addl $0x2, %ecx
movl %ecx, 0x28(%rsp)
js 0x1166c
subq %rax, %r13
addq %r13, %r9
addq %r12, %r9
leaq (%r15,%r9), %rbp
addq $0x2, %rbp
movl 0x20(%rsp), %esi
movl $0xc8, %eax
addl %eax, %esi
movq %rbx, %rdi
leaq 0x20(%rsp), %rdx
movq %r11, %r14
callq *0x98(%rbx)
andl $0x7fffffff, %ebp       # imm = 0x7FFFFFFF
movq %r14, %rdi
movq %rbp, %rsi
callq 0x6af6
movq %r14, %r11
movq 0x48(%rbx), %rax
cmpq $0x2, %rax
jae 0x110e9
jmp 0x11685
leaq (%r9,%r15), %rcx
leaq (%r9,%r15), %rdi
addq $0x4, %rdi
movzwl -0x2(%rdi), %esi
rolw $0x8, %si
movzwl %si, %esi
movq %rsi, 0x38(%rsp)
movq %rdi, 0x30(%rsp)
addq %rsi, %rcx
addq $0x4, %rcx
cmpq %rax, %rcx
ja 0x1167e
testl %edx, %edx
je 0x11272
addq 0x8(%rsp), %rsi
subq %rsi, %rax
subq %r15, %rax
addq $-0x4, %rax
cmpq $0x2, %rax
jl 0x1167e
movzbl (%rcx), %eax
leaq (%r15,%rsi), %rcx
addq $0x6, %rcx
movzbl -0x1(%rcx), %edx
shll $0x8, %eax
orl %edx, %eax
movw %ax, 0x52(%rsp)
movq 0x8(%rsp), %r9
movq %rcx, 0x40(%rsp)
movq %r13, %rax
subq %rcx, %rax
addq %r12, %rax
addq %r9, %rax
addq %r15, %rax
addq $0x2, %rax
movq %rax, 0x48(%rsp)
jmp 0x11199
leaq (%r9,%r15), %r8
leaq (%r9,%r15), %rcx
addq $0x4, %rcx
movzbl -0x2(%rcx), %edx
movzbl -0x1(%rcx), %esi
shll $0x8, %edx
leaq (%rdx,%rsi), %rdi
movq %rdi, 0x60(%rsp)
movq %rcx, 0x58(%rsp)
addq %rdi, %rcx
leaq (%r12,%r13), %r9
addq %r9, %r8
addq $-0x2, %r8
cmpq %r8, %rcx
ja 0x1167e
addq 0x8(%rsp), %rdi
movb (%rcx), %cl
movb %cl, 0x54(%rsp)
leaq (%r15,%rdi), %r8
addq $0x8, %r8
movb -0x3(%r8), %cl
movb %cl, 0x55(%rsp)
movzwl -0x2(%r8), %r9d
rolw $0x8, %r9w
movw %r9w, 0x56(%rsp)
cmpq %rax, %r8
jae 0x1167e
movzbl (%r8), %r9d
addq %r15, %rdi
addq $0xa, %rdi
movzbl -0x1(%rdi), %r8d
shll $0x8, %r9d
leaq (%r9,%r8), %r10
movq %r10, 0x70(%rsp)
movq %rdi, 0x68(%rsp)
leaq (%rdx,%rsi), %rdi
addq %r8, %rdi
addq 0x8(%rsp), %rdi
addq %r9, %rdi
addq %r15, %rdi
addq $0xa, %rdi
cmpq %rax, %rdi
ja 0x1167e
testb $0x4, %cl
movq %r11, 0x18(%rsp)
je 0x1140b
cmpq %rax, %rdi
jae 0x1167e
movzbl (%rdi), %edi
addq %r9, %rdx
leaq (%rsi,%r8), %r10
addq %rdx, %r10
movb %cl, 0x10(%rsp)
movq 0x8(%rsp), %rcx
leaq (%rcx,%r10), %r9
leaq (%r15,%r9), %rcx
addq $0xc, %rcx
movzbl -0x1(%rcx), %r9d
shll $0x8, %edi
leaq (%rdi,%r9), %r11
movq %r11, 0x80(%rsp)
movq %rcx, 0x78(%rsp)
addq %rdi, %r10
movq 0x8(%rsp), %rcx
addq %rcx, %r10
addq %r9, %r10
movb 0x10(%rsp), %cl
addq %r15, %r10
addq $0xc, %r10
cmpq %rax, %r10
jae 0x1167e
movzbl (%r10), %r10d
addq %rsi, %rdx
addq %r8, %rdx
addq %rdi, %rdx
addq %r9, %rdx
movq 0x8(%rsp), %r9
leaq (%r9,%rdx), %rsi
addq %r15, %rsi
addq $0xe, %rsi
movzbl -0x1(%rsi), %edi
shll $0x8, %r10d
leaq (%r10,%rdi), %r8
movq %r8, 0x90(%rsp)
movq %rsi, 0x88(%rsp)
addq %rdi, %rdx
addq %r10, %rdx
addq %r9, %rdx
leaq (%r15,%rdx), %rdi
addq $0xe, %rdi
testb %cl, %cl
jns 0x1143d
cmpq %rax, %rdi
jae 0x1167e
movzwl (%rdi), %edx
rolw $0x8, %dx
movzwl %dx, %edx
movq %rdx, 0xa0(%rsp)
leaq 0x2(%rdi), %rsi
movq %rsi, 0x98(%rsp)
addq %rdx, %rdi
addq $0x2, %rdi
testb $0x40, %cl
je 0x11470
cmpq %rax, %rdi
jae 0x1167e
movzwl (%rdi), %ecx
rolw $0x8, %cx
movzwl %cx, %ecx
movq %rcx, 0xb0(%rsp)
leaq 0x2(%rdi), %rdx
movq %rdx, 0xa8(%rsp)
addq %rcx, %rdi
addq $0x2, %rdi
cmpq %rdi, %rax
jne 0x1167e
movl $0x3, %edi
leaq 0x61c1(%rip), %rsi      # 0x17646
leaq 0x4142(%rip), %rdx      # 0x155ce
callq 0x4447
movq 0x18(%rsp), %r11
testl %eax, %eax
movq 0x8(%rsp), %r9
je 0x11199
movzbl 0x55(%rsp), %edx
movzwl 0x56(%rsp), %ecx
movl 0x60(%rsp), %r8d
movq 0x58(%rsp), %r9
movl 0x70(%rsp), %eax
movq %rax, 0x10(%rsp)
movl 0x80(%rsp), %eax
movq %rax, 0xc0(%rsp)
movl 0x90(%rsp), %eax
movq %rax, 0xb8(%rsp)
movl 0xa0(%rsp), %r11d
movl 0xb0(%rsp), %r10d
leaq 0x615c(%rip), %rdi      # 0x17651
movl %ebp, %esi
xorl %eax, %eax
pushq 0xa8(%rsp)
pushq %r10
pushq 0xa8(%rsp)
pushq %r11
pushq 0xa8(%rsp)
pushq 0xe0(%rsp)
pushq 0xa8(%rsp)
pushq 0xf8(%rsp)
pushq 0xa8(%rsp)
pushq 0x58(%rsp)
callq 0x4539
movq 0x58(%rsp), %r9
movq 0x68(%rsp), %r11
addq $0x50, %rsp
jmp 0x11199
cmpq $0x2, %rbp
jl 0x1167e
movq 0x8(%rsp), %r9
movb 0x3(%r9,%r15), %al
movb %al, 0x50(%rsp)
jmp 0x11199
cmpq $0x2, %rbp
jl 0x1167e
movq 0x8(%rsp), %r9
leaq (%r9,%r15), %rax
addq $0x4, %rax
movzwl -0x2(%rax), %ecx
rolw $0x8, %cx
movw %cx, 0x52(%rsp)
movq %rax, 0x40(%rsp)
addq $-0x2, %rbp
movq %rbp, 0x48(%rsp)
jmp 0x11199
cmpq $0x0, 0x88(%rbx)
jne 0x11685
leaq -0x52e(%rip), %rax      # 0x11085
movq %rax, 0x80(%rbx)
movl $0x1, %edi
movl $0x10, %esi
callq 0x3300
movq %rax, 0x88(%rbx)
leaq 0xc0(%rip), %rax        # 0x11697
movq %rax, 0x90(%rbx)
jmp 0x11685
movq 0x88(%rbx), %r14
callq 0x4aab
movzwl (%r14), %eax
testw %ax, %ax
je 0x11685
movsd 0x8(%r14), %xmm1
xorpd %xmm2, %xmm2
ucomisd %xmm2, %xmm1
jbe 0x11685
subsd %xmm1, %xmm0
movzwl %ax, %eax
xorps %xmm1, %xmm1
cvtsi2sd %eax, %xmm1
ucomisd %xmm1, %xmm0
jbe 0x11685
leaq 0x6005(%rip), %rsi      # 0x1762c
leaq 0x3fa0(%rip), %rdx      # 0x155ce
movl $0x3, %edi
callq 0x4447
testl %eax, %eax
je 0x1164a
leaq 0x5ff6(%rip), %rdi      # 0x17639
xorl %eax, %eax
callq 0x4539
movq %rbx, %rdi
movl $0xc, %esi
xorl %edx, %edx
xorl %ecx, %ecx
addq $0xc8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x11ae1
subl %eax, %r14d
addl %r13d, %r9d
addl %r9d, %r15d
addl %r14d, %r15d
cmpl $-0x3, %r15d
je 0x11685
orb $0x8, 0xc9(%rbx)
addq $0xc8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq