// File: /workspace/github_c_makefile_star2_O0/connycommy[P]atCmdDevice/src/cellularModem/cellModem.c
// Function: cellModem_SocketGetServStatus
cmError_t cellModem_SocketGetServStatus(cmData_t *obj, socketData_t *config){  
    cmError_t retVal;
    char bufferRecv[256];
    char cmd[32]="AT+QISTATE=1,";
    char *ptr = NULL;
    char  buffer[32] ={0};

    sprintf(buffer,"%d\r",config->connectId);
    ptr  = strcat(cmd,buffer);
    retVal = cmSendCmd(obj,cmd , (0 == cellModem_GetatvFormat(obj) ) ? CELLMODEM_CMD_GENERAL_RESPONSE_ATV0 :CELLMODEM_CMD_GENERAL_RESPONSE  ,bufferRecv ,150000); //150 sg
    
    if(CM_OK == retVal){
        ptr = NULL;
        memset(buffer,0,sizeof(buffer));
        if( (ptr = strstr(bufferRecv,"+QISTATE:")) != NULL ){
            if(config != NULL){
                ptr = extractBetween(bufferRecv,' ',',',buffer,0);
                config->connectId = (int)atoi(buffer);
                ptr = extractBetween(bufferRecv,'"','"',buffer,0); // service type
                ptr = extractBetween(ptr,'"','"',config->ipAddres,2);

                if((config->remPort != NULL) || (config->locPort != NULL)){
                    memset((void*)config->remPort,0,sizeof(config->remPort));
                    memset((void*)config->remPort,0,sizeof(config->locPort));
                    ptr = extractBetween(ptr,',',',',config->remPort,0);
                    ptr = extractBetween(ptr,',',',',config->locPort,0); //printf("remPort: %s\n",config->remPort);
                }else{
                    //move pointer
                    ptr = extractBetween(ptr,',',',',NULL,0);
                    ptr = extractBetween(ptr,',',',',NULL,0);
                }
                
                ptr = extractBetween(ptr,',',',',buffer,0);//
                config->state = (int)atoi(buffer); //0: initial 1: opening 2:connected 3:listening 4 : closing
                ptr = extractBetween(ptr,',',',',NULL,0);//
                memset(buffer,0,sizeof(buffer));
                ptr = extractBetween(ptr,',',',',buffer,0);//
                config->serverId = (int)atoi(buffer);
            }
        }else{
            memset((void*)config->remPort,0,sizeof(config->remPort));
            memset((void*)config->locPort,0,sizeof(config->locPort));
            memset((void*)config->ipAddres,0,sizeof(config->ipAddres));
            config->state = 0;
            config->serverId = 0;
        }
    }
    return retVal;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x180, %rsp            # imm = 0x180
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq 0x7446(%rip), %rax      # 0xa830
movq %rax, -0x140(%rbp)
movq 0x7440(%rip), %rax      # 0xa838
movq %rax, -0x138(%rbp)
movq 0x743a(%rip), %rax      # 0xa840
movq %rax, -0x130(%rbp)
movq 0x7434(%rip), %rax      # 0xa848
movq %rax, -0x128(%rbp)
movq $0x0, -0x148(%rbp)
leaq -0x170(%rbp), %rdi
xorl %esi, %esi
movl $0x20, %edx
callq 0x10a0
leaq -0x170(%rbp), %rdi
movq -0x10(%rbp), %rax
movl 0x4c(%rax), %edx
leaq 0x6c8d(%rip), %rsi      # 0xa0db
movb $0x0, %al
callq 0x1100
leaq -0x140(%rbp), %rdi
leaq -0x170(%rbp), %rsi
callq 0x10f0
movq %rax, -0x148(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x180(%rbp)
leaq -0x140(%rbp), %rax
movq %rax, -0x178(%rbp)
movq -0x8(%rbp), %rdi
callq 0x1cf0
movq -0x180(%rbp), %rdi
movq -0x178(%rbp), %rsi
movl %eax, %r8d
xorl %ecx, %ecx
leaq 0x78a7(%rip), %rdx      # 0xad52
leaq 0x7720(%rip), %rax      # 0xabd2
cmpl %r8d, %ecx
cmoveq %rax, %rdx
leaq -0x120(%rbp), %rcx
movl $0x249f0, %r8d          # imm = 0x249F0
callq 0x1390
movl %eax, -0x14(%rbp)
xorl %eax, %eax
cmpl -0x14(%rbp), %eax
jne 0x377c
movq $0x0, -0x148(%rbp)
leaq -0x170(%rbp), %rdi
xorl %esi, %esi
movl $0x20, %edx
callq 0x10a0
leaq -0x120(%rbp), %rdi
leaq 0x6bc9(%rip), %rsi      # 0xa0ce
callq 0x1110
movq %rax, -0x148(%rbp)
cmpq $0x0, %rax
je 0x3728
cmpq $0x0, -0x10(%rbp)
je 0x3726
leaq -0x120(%rbp), %rdi
leaq -0x170(%rbp), %rcx
movl $0x20, %esi
movl $0x2c, %edx
xorl %r8d, %r8d
callq 0x1d10
movq %rax, -0x148(%rbp)
leaq -0x170(%rbp), %rdi
callq 0x10e0
movl %eax, %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x4c(%rax)
leaq -0x120(%rbp), %rdi
leaq -0x170(%rbp), %rcx
movl $0x22, %edx
xorl %r8d, %r8d
movl %edx, %esi
callq 0x1d10
movq %rax, -0x148(%rbp)
movq -0x148(%rbp), %rdi
movq -0x10(%rbp), %rcx
addq $0x5c, %rcx
movl $0x22, %edx
movl $0x2, %r8d
movl %edx, %esi
callq 0x1d10
movq %rax, -0x148(%rbp)
movq -0x10(%rbp), %rax
addq $0x10, %rax
cmpq $0x0, %rax
jne 0x35ca
movq -0x10(%rbp), %rax
addq $0x18, %rax
cmpq $0x0, %rax
je 0x363e
movq -0x10(%rbp), %rdi
addq $0x10, %rdi
xorl %esi, %esi
movl $0x8, %edx
callq 0x10a0
movq -0x10(%rbp), %rdi
addq $0x10, %rdi
xorl %esi, %esi
movl $0x8, %edx
callq 0x10a0
movq -0x148(%rbp), %rdi
movq -0x10(%rbp), %rcx
addq $0x10, %rcx
movl $0x2c, %edx
xorl %r8d, %r8d
movl %edx, %esi
callq 0x1d10
movq %rax, -0x148(%rbp)
movq -0x148(%rbp), %rdi
movq -0x10(%rbp), %rcx
addq $0x18, %rcx
movl $0x2c, %edx
xorl %r8d, %r8d
movl %edx, %esi
callq 0x1d10
movq %rax, -0x148(%rbp)
jmp 0x3680
movq -0x148(%rbp), %rdi
movl $0x2c, %edx
xorl %eax, %eax
movl %eax, %ecx
xorl %r8d, %r8d
movl %edx, %esi
callq 0x1d10
movq %rax, -0x148(%rbp)
movq -0x148(%rbp), %rdi
movl $0x2c, %edx
xorl %eax, %eax
movl %eax, %ecx
xorl %r8d, %r8d
movl %edx, %esi
callq 0x1d10
movq %rax, -0x148(%rbp)
movq -0x148(%rbp), %rdi
leaq -0x170(%rbp), %rcx
movl $0x2c, %edx
xorl %r8d, %r8d
movl %edx, %esi
callq 0x1d10
movq %rax, -0x148(%rbp)
leaq -0x170(%rbp), %rdi
callq 0x10e0
movl %eax, %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x54(%rax)
movq -0x148(%rbp), %rdi
movl $0x2c, %edx
xorl %eax, %eax
movl %eax, %ecx
xorl %r8d, %r8d
movl %edx, %esi
callq 0x1d10
movq %rax, -0x148(%rbp)
leaq -0x170(%rbp), %rdi
xorl %esi, %esi
movl $0x20, %edx
callq 0x10a0
movq -0x148(%rbp), %rdi
leaq -0x170(%rbp), %rcx
movl $0x2c, %edx
xorl %r8d, %r8d
movl %edx, %esi
callq 0x1d10
movq %rax, -0x148(%rbp)
leaq -0x170(%rbp), %rdi
callq 0x10e0
movl %eax, %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x58(%rax)
jmp 0x377a
movq -0x10(%rbp), %rdi
addq $0x10, %rdi
xorl %esi, %esi
movl $0x8, %edx
callq 0x10a0
movq -0x10(%rbp), %rdi
addq $0x18, %rdi
xorl %esi, %esi
movl $0x8, %edx
callq 0x10a0
movq -0x10(%rbp), %rdi
addq $0x5c, %rdi
xorl %esi, %esi
movl $0x10, %edx
callq 0x10a0
movq -0x10(%rbp), %rax
movl $0x0, 0x54(%rax)
movq -0x10(%rbp), %rax
movl $0x0, 0x58(%rax)
jmp 0x377c
movl -0x14(%rbp), %eax
addq $0x180, %rsp            # imm = 0x180
popq %rbp
retq
nopl (%rax,%rax)