// File: /workspace/github_c_makefile_star2_O2/connycommy[P]atCmdDevice/src/cellularModem/cellModem.c
// Function: cellModem_UrcGetDataIncomingConnection
cmError_t cellModem_UrcGetDataIncomingConnection(cmData_t *obj, asynEventIncomingConn_t *getDataIncomingConn){
    cmError_t retVal= CM_FAIL;
    char bufferRecv[CM_BUFFER_LEN_DEF] = {0};
    char *ptr;
    char bufferAux[128] = {0};

    if(cmIsAsyncEvent(obj)){
        ptr = cmGetBufferAsyncEvent(obj);
        memcpy(bufferRecv, ptr, strlen(ptr));        
        
        if( (ptr = strstr(bufferRecv,": \"incoming\"")) != NULL ){
            ptr = extractBetween(bufferRecv,',',',', bufferAux, 0);
            getDataIncomingConn->info.connectId = atoi(bufferAux);

            memset((void*)bufferAux,0,sizeof(bufferAux));
            ptr = extractBetween(ptr,',',',', bufferAux, 0);
            getDataIncomingConn->serverId = atoi(bufferAux);


            ptr = extractBetween(ptr,'"','"', getDataIncomingConn->remoteIp, 0);
            
            memset((void*)bufferAux,0,sizeof(bufferAux));
            ptr = extractBetween(ptr,',','\r', bufferAux, 0);
            getDataIncomingConn->remotePort = (uint16_t)atoi(bufferAux);
            
            retVal = CM_OK;
        }else{
            retVal = CM_ERR_INVALID_RESPONSE;
        }
    }
    return retVal;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x480, %rsp            # imm = 0x480
movq %rsi, %rbx
movq %rdi, %r14
leaq 0x80(%rsp), %rdi
movl $0x400, %edx            # imm = 0x400
xorl %esi, %esi
callq 0x10a0
xorps %xmm0, %xmm0
movaps %xmm0, 0x70(%rsp)
movaps %xmm0, 0x60(%rsp)
movaps %xmm0, 0x50(%rsp)
movaps %xmm0, 0x40(%rsp)
movaps %xmm0, 0x30(%rsp)
movaps %xmm0, 0x20(%rsp)
movaps %xmm0, 0x10(%rsp)
movaps %xmm0, (%rsp)
movq %r14, %rdi
callq 0x1552
testb %al, %al
je 0x2978
movq %r14, %rdi
callq 0x1560
movq %rax, %r14
movq %rax, %rdi
callq 0x1070
leaq 0x80(%rsp), %r15
movq %r15, %rdi
movq %r14, %rsi
movq %rax, %rdx
callq 0x10c0
leaq 0x4864(%rip), %rsi      # 0x70ef
movq %r15, %rdi
callq 0x1110
testq %rax, %rax
je 0x297c
leaq 0x80(%rsp), %rdi
pushq $0x2c
popq %r15
movq %rsp, %r14
xorl %ebp, %ebp
movl %r15d, %esi
movl %r15d, %edx
movq %r14, %rcx
xorl %r8d, %r8d
callq 0x1694
movq %rax, %r12
movq %r14, %rdi
callq 0x10e0
movl %eax, 0x4(%rbx)
xorps %xmm0, %xmm0
movaps %xmm0, (%r14)
movaps %xmm0, 0x10(%r14)
movaps %xmm0, 0x20(%r14)
movaps %xmm0, 0x30(%r14)
movaps %xmm0, 0x40(%r14)
movaps %xmm0, 0x50(%r14)
movaps %xmm0, 0x60(%r14)
movaps %xmm0, 0x70(%r14)
movq %r12, %rdi
movl %r15d, %esi
movl %r15d, %edx
movq %r14, %rcx
xorl %r8d, %r8d
callq 0x1694
movq %rax, %r12
movq %r14, %rdi
callq 0x10e0
movl %eax, 0x8(%rbx)
leaq 0xc(%rbx), %rcx
pushq $0x22
popq %rdx
movq %r12, %rdi
movl %edx, %esi
xorl %r8d, %r8d
callq 0x1694
xorps %xmm0, %xmm0
movaps %xmm0, (%r14)
movaps %xmm0, 0x10(%r14)
movaps %xmm0, 0x20(%r14)
movaps %xmm0, 0x30(%r14)
movaps %xmm0, 0x40(%r14)
movaps %xmm0, 0x50(%r14)
movaps %xmm0, 0x60(%r14)
movaps %xmm0, 0x70(%r14)
pushq $0xd
popq %rdx
movq %rax, %rdi
movl %r15d, %esi
movq %r14, %rcx
xorl %r8d, %r8d
callq 0x1694
movq %r14, %rdi
callq 0x10e0
movw %ax, 0x1c(%rbx)
jmp 0x297f
pushq $-0x1
jmp 0x297e
pushq $0x3
popq %rbp
movl %ebp, %eax
addq $0x480, %rsp            # imm = 0x480
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq