// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0xf0, %rsp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movq %rdx, -0x18(%rbp)
movq -0x8(%rbp), %rax
addq $0x40, %rax
movq %rax, -0x20(%rbp)
xorps %xmm0, %xmm0
movaps %xmm0, -0xf0(%rbp)
movaps %xmm0, -0x40(%rbp)
movaps %xmm0, -0x50(%rbp)
movaps %xmm0, -0x60(%rbp)
movaps %xmm0, -0x70(%rbp)
movaps %xmm0, -0x80(%rbp)
movaps %xmm0, -0x90(%rbp)
movaps %xmm0, -0xa0(%rbp)
movaps %xmm0, -0xb0(%rbp)
movaps %xmm0, -0xc0(%rbp)
movq $0x0, -0x30(%rbp)
movq -0x8(%rbp), %rdi
movq 0x98(%rdi), %rax
movl -0xc(%rbp), %esi
movq -0x18(%rbp), %rdx
callq *%rax
movl -0xc(%rbp), %eax
movl %eax, -0xdc(%rbp)
testl %eax, %eax
je 0x172c6
jmp 0x1720b
movl -0xdc(%rbp), %eax
subl $0x1, %eax
je 0x17228
jmp 0x17218
movl -0xdc(%rbp), %eax
subl $0x3, %eax
je 0x17244
jmp 0x1736b
movq -0x8(%rbp), %rax
cmpq $0x0, 0x88(%rax)
jne 0x1723f
movq -0x8(%rbp), %rdi
callq 0x17120
jmp 0x1736b
jmp 0x17246
movq -0x20(%rbp), %rdi
leaq -0xc0(%rbp), %rsi
callq 0x1cd00
movl %eax, -0xc4(%rbp)
cmpl $0x0, -0xc4(%rbp)
jge 0x1728b
cmpl $-0x1, -0xc4(%rbp)
jne 0x17270
jmp 0x172c1
movq -0x8(%rbp), %rax
movq 0xc8(%rax), %rcx
orq $0x800, %rcx            # imm = 0x800
movq %rcx, 0xc8(%rax)
jmp 0x172c1
movq -0x8(%rbp), %rax
movq 0x98(%rax), %rax
movq -0x8(%rbp), %rdi
movl -0xc0(%rbp), %esi
addl $0xc8, %esi
leaq -0xc0(%rbp), %rdx
callq *%rax
movq -0x20(%rbp), %rdi
movslq -0xc4(%rbp), %rsi
callq 0x89f0
jmp 0x17246
jmp 0x1736b
movq -0x8(%rbp), %rax
movq 0x88(%rax), %rax
movq %rax, -0xd0(%rbp)
callq 0xb6e0
movsd %xmm0, -0xd8(%rbp)
movq -0xd0(%rbp), %rax
movzwl (%rax), %eax
cmpl $0x0, %eax
jle 0x17369
movq -0xd0(%rbp), %rax
movsd 0x8(%rax), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jbe 0x17369
movsd -0xd8(%rbp), %xmm0
movq -0xd0(%rbp), %rax
subsd 0x8(%rax), %xmm0
movq -0xd0(%rbp), %rax
movzwl (%rax), %eax
cvtsi2sd %eax, %xmm1
ucomisd %xmm1, %xmm0
jbe 0x17369
jmp 0x17333
movl $0x3, %edi
leaq 0xa2b7(%rip), %rsi      # 0x215f6
leaq 0x8204(%rip), %rdx      # 0x1f54a
callq 0x4650
cmpl $0x0, %eax
je 0x1735e
leaq 0xa2ac(%rip), %rdi      # 0x21603
movb $0x0, %al
callq 0x47a0
jmp 0x17360
movq -0x8(%rbp), %rdi
callq 0x17e50
jmp 0x1736b
addq $0xf0, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)