// File: /workspace/github_c_makefile_star2_O2/connycommy[P]atCmdDevice/src/cellularModem/cellModem.c
// Function: cellModem_SocketGetRecv
cmError_t cellModem_SocketGetRecv(cmData_t *obj, socketData_t *config){  
    cmError_t retVal;
    char bufferRecv[1024]={0};
    char cmd[32]="AT+QIRD=";
    char *ptr = NULL;
    char  buffer[1024] ={0};
    config->msgLen = 0;

    sprintf(buffer,"%d,%d\r",config->connectId, (config->buffRcvLen <= 0 ? CM_BUFFER_LEN_DEF :config->buffRcvLen) );
    ptr  = strcat(cmd,buffer);
    
    retVal = cmSendCmd(obj,cmd , (0 == cellModem_GetatvFormat(obj) ) ? CELLMODEM_CMD_GENERAL_RESPONSE_ATV0 :CELLMODEM_CMD_GENERAL_RESPONSE  ,bufferRecv ,2000); //2 sg
    
    if(CM_OK == retVal){
        ptr = NULL;
        memset(buffer,0,sizeof(buffer));
        if(config->msgRecv != NULL){
            memset((void*)config->msgRecv,0,CM_BUFFER_LEN_DEF); 
        }
        if( (ptr = strstr(bufferRecv,"+QIRD:")) != NULL ){
            if(config != NULL){
                ptr = extractBetween(bufferRecv,' ','\r',buffer,0);
                config->msgLen = (size_t)atoi(buffer);

                if( (config->msgLen > 0) && (config->msgRecv != NULL)){
                    memcpy((void*) config->msgRecv,ptr+2 , config->msgLen);
                }
            }
        }else{
           // retVal = CM_ERR_INVALID_RESPONSE;
        }
    }
    return retVal;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x828, %rsp            # imm = 0x828
movq %rsi, %rbx
movq %rdi, %r15
leaq 0x420(%rsp), %r14
movl $0x400, %ebp            # imm = 0x400
movl $0x400, %edx            # imm = 0x400
movq %r14, %rdi
xorl %esi, %esi
callq 0x10a0
movaps 0x52b7(%rip), %xmm0     # 0x7840
movq %rsp, %r12
movaps %xmm0, 0x10(%r12)
movaps 0x5297(%rip), %xmm0     # 0x7830
movaps %xmm0, (%r12)
leaq 0x20(%rsp), %r13
movl $0x400, %edx            # imm = 0x400
movq %r13, %rdi
xorl %esi, %esi
callq 0x10a0
andq $0x0, 0x38(%rbx)
movl 0x4c(%rbx), %edx
movq 0x40(%rbx), %rcx
testq %rcx, %rcx
cmoveq %rbp, %rcx
leaq 0x4b0b(%rip), %rsi      # 0x70d7
movq %r13, %rdi
xorl %eax, %eax
callq 0x1100
movq %r12, %rdi
movq %r13, %rsi
callq 0x10f0
cmpb $0x0, 0x61(%r15)
leaq 0x55c5(%rip), %rax      # 0x7bb2
leaq 0x573e(%rip), %rdx      # 0x7d32
cmoveq %rax, %rdx
movq %r15, %rdi
movq %r12, %rsi
movq %r14, %rcx
movl $0x7d0, %r8d            # imm = 0x7D0
callq 0x12d0
movl %eax, %ebp
testl %eax, %eax
je 0x2626
movl %ebp, %eax
addq $0x828, %rsp            # imm = 0x828
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x20(%rsp), %rdi
movl $0x400, %edx            # imm = 0x400
xorl %esi, %esi
callq 0x10a0
movq 0x30(%rbx), %rdi
testq %rdi, %rdi
je 0x264c
movl $0x400, %edx            # imm = 0x400
xorl %esi, %esi
callq 0x10a0
leaq 0x4a8b(%rip), %rsi      # 0x70de
leaq 0x420(%rsp), %rdi
callq 0x1110
testq %rax, %rax
je 0x2612
leaq 0x420(%rsp), %rdi
pushq $0x20
popq %rsi
pushq $0xd
popq %rdx
leaq 0x20(%rsp), %r15
movq %r15, %rcx
xorl %r8d, %r8d
callq 0x1694
movq %rax, %r14
movq %r15, %rdi
callq 0x10e0
movslq %eax, %rdx
movq %rdx, 0x38(%rbx)
testl %edx, %edx
je 0x2612
movq 0x30(%rbx), %rdi
testq %rdi, %rdi
je 0x2612
addq $0x2, %r14
movq %r14, %rsi
callq 0x10c0
jmp 0x2612