// File: /workspace/github_c_makefile_star2_O0/sszllzss[P]webSocket_Libevent_ThreadPool/ev_websocket.c
// Function: webSocket_getInLen(unsigned char*, unsigned int)
int webSocket_getInLen(unsigned char *data, unsigned int dataLen)
{
    char Mask = 0;
    int ret = 0;
    unsigned int  len = 0, dataStart = 2;
    if(dataLen < 2)
        return WCT_ERR;

    ret = webSocket_getInType(data);
    if(ret == WCT_ERR) 
        return WCT_ERR;
    //
    if((data[1] & 0x80) == 0x80)
    {
        Mask = 1;
    }
    else
    {
        Mask = 0;
    }
    //
    len = data[1] & 0x7F;
    //
    if(len == 126)
    {
        if(dataLen < 4)
            return WCT_ERR;
        len = data[2];
        len = (len << 8) + data[3];
        if(Mask)
        {
            dataStart = 8;
        }
        else
            dataStart = 4;
    }
    else if(len == 127)
    {
        if(dataLen < 10)
            return WCT_ERR;
        if(data[2] != 0 || data[3] != 0 || data[4] != 0 || data[5] != 0)    // 使用8个字节存储长度时, 前4位必须为0, 装不下那么多数据...
            return WCT_ERR;
        len = data[6];
        len = (len << 8) + data[7];
        len = (len << 8) + data[8];
        len = (len << 8) + data[9];
        if(Mask)
        {
            dataStart = 14;
        }
        else
            dataStart = 10;
    }
    else
    {
        if(Mask)
        {
            dataStart = 6;
        }
        else
            dataStart = 2;
    }
    return len + dataStart;

}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movb $0x0, -0x15(%rbp)
movl $0x0, -0x1c(%rbp)
movl $0x0, -0x20(%rbp)
movl $0x2, -0x24(%rbp)
cmpl $0x2, -0x14(%rbp)
jae 0x598a
movl $0xfffffffe, -0x4(%rbp) # imm = 0xFFFFFFFE
jmp 0x5afd
movq -0x10(%rbp), %rdi
callq 0x5890
movl %eax, -0x1c(%rbp)
cmpl $-0x2, -0x1c(%rbp)
jne 0x59a8
movl $0xfffffffe, -0x4(%rbp) # imm = 0xFFFFFFFE
jmp 0x5afd
movq -0x10(%rbp), %rax
movzbl 0x1(%rax), %eax
andl $0x80, %eax
cmpl $0x80, %eax
jne 0x59c2
movb $0x1, -0x15(%rbp)
jmp 0x59c6
movb $0x0, -0x15(%rbp)
movq -0x10(%rbp), %rax
movzbl 0x1(%rax), %eax
andl $0x7f, %eax
movl %eax, -0x20(%rbp)
cmpl $0x7e, -0x20(%rbp)
jne 0x5a25
cmpl $0x4, -0x14(%rbp)
jae 0x59ec
movl $0xfffffffe, -0x4(%rbp) # imm = 0xFFFFFFFE
jmp 0x5afd
movq -0x10(%rbp), %rax
movzbl 0x2(%rax), %eax
movl %eax, -0x20(%rbp)
movl -0x20(%rbp), %eax
shll $0x8, %eax
movq -0x10(%rbp), %rcx
movzbl 0x3(%rcx), %ecx
addl %ecx, %eax
movl %eax, -0x20(%rbp)
cmpb $0x0, -0x15(%rbp)
je 0x5a19
movl $0x8, -0x24(%rbp)
jmp 0x5a20
movl $0x4, -0x24(%rbp)
jmp 0x5af4
cmpl $0x7f, -0x20(%rbp)
jne 0x5ada
cmpl $0xa, -0x14(%rbp)
jae 0x5a41
movl $0xfffffffe, -0x4(%rbp) # imm = 0xFFFFFFFE
jmp 0x5afd
movq -0x10(%rbp), %rax
movzbl 0x2(%rax), %eax
cmpl $0x0, %eax
jne 0x5a75
movq -0x10(%rbp), %rax
movzbl 0x3(%rax), %eax
cmpl $0x0, %eax
jne 0x5a75
movq -0x10(%rbp), %rax
movzbl 0x4(%rax), %eax
cmpl $0x0, %eax
jne 0x5a75
movq -0x10(%rbp), %rax
movzbl 0x5(%rax), %eax
cmpl $0x0, %eax
je 0x5a7e
movl $0xfffffffe, -0x4(%rbp) # imm = 0xFFFFFFFE
jmp 0x5afd
movq -0x10(%rbp), %rax
movzbl 0x6(%rax), %eax
movl %eax, -0x20(%rbp)
movl -0x20(%rbp), %eax
shll $0x8, %eax
movq -0x10(%rbp), %rcx
movzbl 0x7(%rcx), %ecx
addl %ecx, %eax
movl %eax, -0x20(%rbp)
movl -0x20(%rbp), %eax
shll $0x8, %eax
movq -0x10(%rbp), %rcx
movzbl 0x8(%rcx), %ecx
addl %ecx, %eax
movl %eax, -0x20(%rbp)
movl -0x20(%rbp), %eax
shll $0x8, %eax
movq -0x10(%rbp), %rcx
movzbl 0x9(%rcx), %ecx
addl %ecx, %eax
movl %eax, -0x20(%rbp)
cmpb $0x0, -0x15(%rbp)
je 0x5ad1
movl $0xe, -0x24(%rbp)
jmp 0x5ad8
movl $0xa, -0x24(%rbp)
jmp 0x5af2
cmpb $0x0, -0x15(%rbp)
je 0x5ae9
movl $0x6, -0x24(%rbp)
jmp 0x5af0
movl $0x2, -0x24(%rbp)
jmp 0x5af2
jmp 0x5af4
movl -0x20(%rbp), %eax
addl -0x24(%rbp), %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x30, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)