// File: /workspace/github_c_makefile_star2_O1/back1127[P]linkedge-thing-access-websocket_client_sdk/sdk/ali_ws/ws_client_callback.c
// Function: callback_dumb_increment
int callback_dumb_increment(struct lws *wsi, enum lws_callback_reasons reason,
			void *user, void *in, size_t len)
{
    wsc_recv_tmpInfo* tmp = (wsc_recv_tmpInfo*)user;
    
    switch (reason) {
        case LWS_CALLBACK_CLIENT_ESTABLISHED:
            if(g_cbs && g_cbs->p_cb_establish)
                g_cbs->p_cb_establish(g_cbs->usr_cb_establish);
            break;
        case LWS_CALLBACK_CLIENT_WRITEABLE:
            client_buf_mgmt_pop(cb_pop_msg, (void *)wsi);
            break;
        case LWS_CALLBACK_CLIENT_RECEIVE:
           if (lws_is_final_fragment(wsi))
            {
                tmp->totalLen += recvframeAppend(wsi,(void **)&tmp->appendBuffer,in,tmp->totalLen,len);
                        
                if(g_cbs && g_cbs->p_cb_recv)
                {
                    g_cbs->p_cb_recv(tmp->appendBuffer, tmp->totalLen, g_cbs->usr_cb_recv);
                }
                if(tmp->appendBuffer != NULL){
                    free(tmp->appendBuffer);
                    tmp->appendBuffer = NULL;
                } 
                tmp->totalLen = 0;
            }
            else
            {
                tmp->totalLen += recvframeAppend(wsi,(void **)&tmp->appendBuffer,in,tmp->totalLen,len);
            }
            break;
        case LWS_CALLBACK_CLIENT_CONNECTION_ERROR:
            if(g_cbs && g_cbs->p_cb_close)
                g_cbs->p_cb_close(g_cbs->usr_cb_close);
            g_wsi = NULL;
            break;
        case LWS_CALLBACK_CLOSED:
            if(g_cbs && g_cbs->p_cb_close)
                g_cbs->p_cb_close(g_cbs->usr_cb_close);
            g_wsi = NULL; 
            buf_mgmt_client_clear_msg();
            return -1;
        default:
            break;
    }

	return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
xorl %ebx, %ebx
decl %esi
cmpl $0x9, %esi
ja 0x657d
movq %rcx, %r12
movq %rdi, %r13
leaq 0x50a5(%rip), %rax      # 0xb4fc
movslq (%rax,%rsi,4), %rcx
addq %rax, %rcx
jmpq *%rcx
movq 0x8b39(%rip), %rax      # 0xefa0
movq (%rax), %rax
testq %rax, %rax
je 0x647e
movq 0x10(%rax), %rcx
testq %rcx, %rcx
je 0x647e
movq 0x18(%rax), %rdi
callq *%rcx
movq 0x8ae3(%rip), %rax      # 0xef68
movq $0x0, (%rax)
jmp 0x657d
movq 0x8b08(%rip), %rax      # 0xefa0
movq (%rax), %rax
testq %rax, %rax
je 0x64af
movq 0x10(%rax), %rcx
testq %rcx, %rcx
je 0x64af
movq 0x18(%rax), %rdi
callq *%rcx
movq 0x8ab2(%rip), %rax      # 0xef68
movq $0x0, (%rax)
xorl %eax, %eax
callq 0x42f0
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
jmp 0x657d
movq 0x8acb(%rip), %rax      # 0xefa0
movq (%rax), %rax
testq %rax, %rax
je 0x657d
movq (%rax), %rcx
testq %rcx, %rcx
je 0x657d
movq 0x8(%rax), %rdi
callq *%rcx
jmp 0x657d
movq %r8, %r15
movq %rdx, %r14
movq %r13, %rdi
callq 0x4050
movl %eax, -0x2c(%rbp)
movq 0x8(%r14), %rcx
movq %r13, %rdi
movq %r14, %rsi
movq %r12, %rdx
movq %r15, %r8
callq 0x658e
movslq %eax, %rsi
addq 0x8(%r14), %rsi
movq %rsi, 0x8(%r14)
cmpl $0x0, -0x2c(%rbp)
je 0x657d
movq 0x8a6a(%rip), %rax      # 0xefa0
movq (%rax), %rax
testq %rax, %rax
je 0x6550
movq 0x20(%rax), %rcx
testq %rcx, %rcx
je 0x6550
movq (%r14), %rdi
movq 0x28(%rax), %rdx
callq *%rcx
movq (%r14), %rdi
testq %rdi, %rdi
je 0x6564
callq 0x46b0
movq $0x0, (%r14)
movq $0x0, 0x8(%r14)
jmp 0x657d
movq 0x8a3b(%rip), %rdi      # 0xefb0
movq %r13, %rsi
callq 0x4480
movl %ebx, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq