// File: /workspace/github_c_makefile_star2_O3/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 0x5213(%rip), %xmm0     # 0x7860
movq %rsp, %r12
movaps %xmm0, 0x10(%r12)
movaps 0x51f3(%rip), %xmm0     # 0x7850
movaps %xmm0, (%r12)
leaq 0x20(%rsp), %r13
movl $0x400, %edx            # imm = 0x400
movq %r13, %rdi
xorl %esi, %esi
callq 0x10a0
movq $0x0, 0x38(%rbx)
movl 0x4c(%rbx), %edx
movq 0x40(%rbx), %rcx
testq %rcx, %rcx
cmoveq %rbp, %rcx
leaq 0x4a8c(%rip), %rsi      # 0x711f
movq %r13, %rdi
xorl %eax, %eax
callq 0x1100
movq %r12, %rdi
movq %r13, %rsi
callq 0x10f0
cmpb $0x0, 0x61(%r15)
leaq 0x551e(%rip), %rax      # 0x7bd2
leaq 0x5697(%rip), %rdx      # 0x7d52
cmoveq %rax, %rdx
movq %r15, %rdi
movq %r12, %rsi
movq %r14, %rcx
movl $0x7d0, %r8d            # imm = 0x7D0
callq 0x12cc
movl %eax, %ebp
testl %eax, %eax
je 0x26ed
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 0x2713
movl $0x400, %edx            # imm = 0x400
xorl %esi, %esi
callq 0x10a0
leaq 0x4a0c(%rip), %rsi      # 0x7126
leaq 0x420(%rsp), %rdi
callq 0x1110
testq %rax, %rax
je 0x26d9
leaq 0x420(%rsp), %rdi
leaq 0x20(%rsp), %r15
movl $0x20, %esi
movl $0xd, %edx
movq %r15, %rcx
xorl %r8d, %r8d
callq 0x16cc
movq %rax, %r14
movq %r15, %rdi
callq 0x10e0
movslq %eax, %rdx
movq %rdx, 0x38(%rbx)
testl %edx, %edx
je 0x26d9
movq 0x30(%rbx), %rdi
testq %rdi, %rdi
je 0x26d9
addq $0x2, %r14
movq %r14, %rsi
callq 0x10c0
jmp 0x26d9