LLM4Binary/decompile-bench-makefile huggingface dataset:
// File: /workspace/github_c_makefile_star2_O3/Carton32[P]quectel-CM/QMIThread.c
// Function: QmiThreadSendQMITimeout
int QmiThreadSendQMITimeout(PQCQMIMSG pRequest, PQCQMIMSG *ppResponse, unsigned msecs, const char *funcname) {
    int ret;
    
    if (!pRequest)
        return -EINVAL;

    pthread_mutex_lock(&cm_command_mutex);

    if (ppResponse)
        *ppResponse = NULL;

    dump_qmi(pRequest, le16_to_cpu(pRequest->QMIHdr.Length) + 1);

    s_pRequest = pRequest;
    s_pResponse = NULL;

    ret = qmidev_send(pRequest);

    if (ret == 0) {
        ret = pthread_cond_timeout_np(&cm_command_cond, &cm_command_mutex, msecs);
        if (!ret) {
            if (s_pResponse && ppResponse) {
                *ppResponse = s_pResponse;
            } else {
                if (s_pResponse) {
                    free(s_pResponse);
                    s_pResponse = NULL;
                }
            }
        } else {
            dbg_time("%s message timeout", funcname);
        }
    }

    pthread_mutex_unlock(&cm_command_mutex);

    return ret;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
testq %rdi, %rdi
je 0xa2eb
movq %rcx, %rbx
movl %edx, %r15d
movq %rsi, %r14
movq %rdi, %r12
leaq 0x209bd(%rip), %rdi     # 0x2ac50
callq 0x5560
testq %r14, %r14
je 0xa2a4
movq $0x0, (%r14)
movzwl 0x1(%r12), %edi
callq 0xee73
movzwl %ax, %esi
incl %esi
movq %r12, %rdi
callq 0xa094
movq %r12, 0x20955(%rip)     # 0x2ac18
movq $0x0, 0x20952(%rip) # 0x2ac20
movq %r12, %rdi
callq *0x20951(%rip)          # 0x2ac28
movl %eax, %ebp
testl %eax, %eax
je 0xa2fb
leaq 0x2096c(%rip), %rdi     # 0x2ac50
callq 0x5340
jmp 0xa2f0
movl $0xffffffea, %ebp       # imm = 0xFFFFFFEA
movl %ebp, %eax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
leaq 0x20976(%rip), %rdi     # 0x2ac78
leaq 0x20947(%rip), %rsi     # 0x2ac50
movl %r15d, %edx
callq 0xecc5
testl %eax, %eax
je 0xa36d
movl %eax, %ebp
movq 0x1fca2(%rip), %rax     # 0x29fc0
movq (%rax), %r14
callq 0xea3b
leaq 0x16403(%rip), %rsi     # 0x20730
movq %r14, %rdi
movq %rax, %rdx
movq %rbx, %rcx
xorl %eax, %eax
callq 0x52c0
leaq 0x20964(%rip), %rax     # 0x2aca8
movq (%rax), %r14
testq %r14, %r14
je 0xa2dd
callq 0xea3b
leaq 0x163d8(%rip), %rsi     # 0x20730
movq %r14, %rdi
movq %rax, %rdx
movq %rbx, %rcx
xorl %eax, %eax
callq 0x52c0
jmp 0xa2dd
testq %r14, %r14
sete %al
movq 0x208a6(%rip), %rdi     # 0x2ac20
testq %rdi, %rdi
sete %cl
orb %al, %cl
jne 0xa38e
movq %rdi, (%r14)
xorl %ebp, %ebp
jmp 0xa2dd
xorl %ebp, %ebp
testq %rdi, %rdi
je 0xa2dd
callq 0x5040
movq $0x0, 0x20877(%rip) # 0x2ac20
jmp 0xa2dd
// File: /workspace/github_c_makefile_star2_O3/Carton32[P]quectel-CM/QMIThread.c
// Function: requestEnterSimPin
static int requestEnterSimPin(const char *pPinCode) {
    PQCQMIMSG pRequest;
    PQCQMIMSG pResponse;
    PQMUX_MSG pMUXMsg;
    int err;

    if (s_9x07)
        pRequest = ComposeQMUXMsg(QMUX_TYPE_UIM, QMIUIM_VERIFY_PIN_REQ, UimVerifyPinReqSend, (void *)pPinCode);
    else
        pRequest = ComposeQMUXMsg(QMUX_TYPE_DMS, QMIDMS_UIM_VERIFY_PIN_REQ, DmsUIMVerifyPinReqSend, (void *)pPinCode);
    err = QmiThreadSendQMI(pRequest, &pResponse);
    qmi_rsp_check_and_return();

    free(pResponse);
    return 0;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %rcx
cmpl $0x0, 0x1eebe(%rip)     # 0x2a2f8
je 0xb44f
leaq 0x2b20(%rip), %rdx      # 0xdf63
movl $0xb, %edi
movl $0x26, %esi
jmp 0xb460
leaq 0x2b8d(%rip), %rdx      # 0xdfe3
movl $0x2, %edi
movl $0x28, %esi
callq 0xd9a2
leaq 0x15533(%rip), %rcx     # 0x2099f
movq %rsp, %r14
movq %rax, %rdi
movq %r14, %rsi
movl $0x7530, %edx           # imm = 0x7530
callq 0xa273
movl %eax, %ebx
testl %eax, %eax
sets %al
movq (%r14), %r12
testq %r12, %r12
sete %cl
orb %al, %cl
cmpb $0x1, %cl
jne 0xb4fe
movq 0x1eb23(%rip), %rax     # 0x29fc0
movq (%rax), %r14
callq 0xea3b
leaq 0x152d5(%rip), %rsi     # 0x20781
leaq 0x154ec(%rip), %rcx     # 0x2099f
movq %r14, %rdi
movq %rax, %rdx
movl %ebx, %r8d
xorl %eax, %eax
callq 0x52c0
leaq 0x1f7de(%rip), %rax     # 0x2aca8
movq (%rax), %r14
testq %r14, %r14
je 0xb5be
callq 0xea3b
leaq 0x1529f(%rip), %rsi     # 0x20781
leaq 0x154b6(%rip), %rcx     # 0x2099f
movq %r14, %rdi
movq %rax, %rdx
movl %ebx, %r8d
xorl %eax, %eax
callq 0x52c0
jmp 0xb5be
movzwl 0x10(%r12), %edi
callq 0xee73
testw %ax, %ax
jne 0xb522
movzwl 0x12(%r12), %edi
callq 0xee73
testw %ax, %ax
je 0xb5cc
movzwl 0x12(%r12), %edi
callq 0xee73
movl %eax, %ebx
movq 0x1ea8a(%rip), %rax     # 0x29fc0
movq (%rax), %r14
callq 0xea3b
movq %rax, %r15
movzwl 0x10(%r12), %edi
callq 0xee73
movzwl %ax, %r8d
movzwl %bx, %ebx
leaq 0x15239(%rip), %rsi     # 0x20793
leaq 0x1543e(%rip), %rcx     # 0x2099f
movq %r14, %rdi
movq %r15, %rdx
movl %ebx, %r9d
xorl %eax, %eax
callq 0x52c0
leaq 0x1f730(%rip), %rax     # 0x2aca8
movq (%rax), %r14
testq %r14, %r14
je 0xb5b5
callq 0xea3b
movq %rax, %r15
movzwl 0x10(%r12), %edi
callq 0xee73
movzwl %ax, %r8d
leaq 0x151f5(%rip), %rsi     # 0x20793
leaq 0x153fa(%rip), %rcx     # 0x2099f
movq %r14, %rdi
movq %r15, %rdx
movl %ebx, %r9d
xorl %eax, %eax
callq 0x52c0
movq (%rsp), %rdi
callq 0x5040
movl %ebx, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
movq (%rsp), %rdi
callq 0x5040
xorl %ebx, %ebx
jmp 0xb5be
// File: /workspace/github_c_makefile_star2_O3/Carton32[P]quectel-CM/QMIThread.c
// Function: ComposeQMUXMsg
static PQCQMIMSG ComposeQMUXMsg(UCHAR QMIType, USHORT Type, CUSTOMQMUX customQmuxMsgFunction, void *arg) {
    UCHAR QMIBuf[WDM_DEFAULT_BUFSIZE];
    PQCQMIMSG pRequest = (PQCQMIMSG)QMIBuf;
    int Length;

    memset(QMIBuf, 0x00, sizeof(QMIBuf));
    pRequest->QMIHdr.IFType = USB_CTL_MSG_TYPE_QMI;
    pRequest->QMIHdr.CtlFlags = 0x00;
    pRequest->QMIHdr.QMIType = QMIType;

    pRequest->MUXMsg.QMUXHdr.CtlFlags = QMUX_CTL_FLAG_SINGLE_MSG | QMUX_CTL_FLAG_TYPE_CMD;
    pRequest->MUXMsg.QMUXHdr.TransactionId = cpu_to_le16(GetQMUXTransactionId());
    pRequest->MUXMsg.QMUXMsgHdr.Type = cpu_to_le16(Type);
    if (customQmuxMsgFunction)
        pRequest->MUXMsg.QMUXMsgHdr.Length = cpu_to_le16(customQmuxMsgFunction(&pRequest->MUXMsg, arg) - sizeof(QCQMUX_MSG_HDR));
    else
        pRequest->MUXMsg.QMUXMsgHdr.Length = cpu_to_le16(0x0000);

    pRequest->QMIHdr.Length = cpu_to_le16(le16_to_cpu(pRequest->MUXMsg.QMUXMsgHdr.Length) + sizeof(QCQMUX_MSG_HDR) + sizeof(QCQMUX_HDR)
        + sizeof(QCQMI_HDR) - 1);
    Length = le16_to_cpu(pRequest->QMIHdr.Length) + 1;

    pRequest = (PQCQMIMSG)malloc(Length);
    if (pRequest == NULL) {
        dbg_time("%s fail to malloc", __func__);
    } else {
        memcpy(pRequest, QMIBuf, Length);
    }

    return pRequest;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x100, %rsp            # imm = 0x100
movq %rcx, %r14
movq %rdx, %rbx
movl %esi, %ebp
movl %edi, %r12d
movq %rsp, %r15
movl $0x100, %edx            # imm = 0x100
movq %r15, %rdi
xorl %esi, %esi
callq 0x5200
movb $0x1, (%r15)
movb %r12b, 0x4(%r15)
movl 0x1d254(%rip), %eax     # 0x2ac30
leal 0x1(%rax), %ecx
movl $0xffff, %edx           # imm = 0xFFFF
cmpl %edx, %eax
movl $0x1, %edi
cmovll %ecx, %edi
movl %edi, 0x1d23c(%rip)     # 0x2ac30
andl %edx, %edi
callq 0xee7e
movw %ax, 0x7(%r15)
movl %ebp, %edi
callq 0xee7e
movw %ax, 0x9(%r15)
testq %rbx, %rbx
je 0xda23
leaq 0x6(%rsp), %rdi
movq %r14, %rsi
callq *%rbx
addl $-0x4, %eax
movzwl %ax, %edi
jmp 0xda25
xorl %edi, %edi
callq 0xee7e
movw %ax, 0xb(%rsp)
movzwl %ax, %edi
callq 0xee73
addl $0xc, %eax
movzwl %ax, %edi
callq 0xee7e
movw %ax, 0x1(%rsp)
movzwl %ax, %edi
callq 0xee73
movzwl %ax, %r14d
incq %r14
movq %r14, %rdi
callq 0x5360
movq %rax, %rbx
testq %rax, %rax
je 0xda76
movq %rsp, %rsi
movq %rbx, %rdi
movq %r14, %rdx
callq 0x52f0
jmp 0xdacf
movq 0x1c543(%rip), %rax     # 0x29fc0
movq (%rax), %r14
callq 0xea3b
leaq 0x105c2(%rip), %rsi     # 0x1e04e
leaq 0x12d39(%rip), %rcx     # 0x207cc
movq %r14, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0x52c0
leaq 0x1d201(%rip), %rax     # 0x2aca8
movq (%rax), %r14
testq %r14, %r14
je 0xdacf
callq 0xea3b
leaq 0x10593(%rip), %rsi     # 0x1e04e
leaq 0x12d0a(%rip), %rcx     # 0x207cc
movq %r14, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0x52c0
movq %rbx, %rax
addq $0x100, %rsp            # imm = 0x100
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/Carton32[P]quectel-CM/QMIThread.c
// Function: WdsSetQMUXBindMuxDataPort
static USHORT WdsSetQMUXBindMuxDataPort(PQMUX_MSG pMUXMsg, void *arg) {
    QMAP_SETTING *qmap_settings = (QMAP_SETTING *)arg;

    pMUXMsg->BindMuxDataPortReq.TLVType = 0x10;
    pMUXMsg->BindMuxDataPortReq.TLVLength = cpu_to_le16(0x08);
    pMUXMsg->BindMuxDataPortReq.ep_type = cpu_to_le32(qmap_settings->ep_type);
    pMUXMsg->BindMuxDataPortReq.iface_id = cpu_to_le32(qmap_settings->iface_id);
    pMUXMsg->BindMuxDataPortReq.TLV2Type = 0x11;
    pMUXMsg->BindMuxDataPortReq.TLV2Length = cpu_to_le16(0x01);
    pMUXMsg->BindMuxDataPortReq.MuxId = qmap_settings->MuxId;
    pMUXMsg->BindMuxDataPortReq.TLV3Type = 0x13;
    pMUXMsg->BindMuxDataPortReq.TLV3Length = cpu_to_le16(0x04);
    pMUXMsg->BindMuxDataPortReq.client_type = cpu_to_le32(1); //WDS_CLIENT_TYPE_TETHERED
    
    return sizeof(QMIWDS_BIND_MUX_DATA_PORT_REQ_MSG);
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rsi, %r14
movq %rdi, %rbx
movb $0x10, 0x7(%rdi)
movl $0x8, %edi
callq 0xee7e
movw %ax, 0x8(%rbx)
movl 0x8(%r14), %edi
callq 0xee81
movl %eax, 0xa(%rbx)
movl 0xc(%r14), %edi
callq 0xee81
movl %eax, 0xe(%rbx)
movb $0x11, 0x12(%rbx)
movl $0x1, %edi
callq 0xee7e
movw %ax, 0x13(%rbx)
movb 0x10(%r14), %al
movb %al, 0x15(%rbx)
movb $0x13, 0x16(%rbx)
movl $0x4, %edi
callq 0xee7e
movw %ax, 0x17(%rbx)
movl $0x1, %edi
callq 0xee81
movl %eax, 0x19(%rbx)
movw $0x1a, %ax
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O3/Carton32[P]quectel-CM/QMIThread.c
// Function: WdsSetClientIPFamilyPref
static USHORT WdsSetClientIPFamilyPref(PQMUX_MSG pMUXMsg, void *arg) {
    pMUXMsg->SetClientIpFamilyPrefReq.TLVType = 0x01;
    pMUXMsg->SetClientIpFamilyPrefReq.TLVLength = cpu_to_le16(0x01);
    pMUXMsg->SetClientIpFamilyPrefReq.IpPreference = *((UCHAR *)arg);
    return sizeof(QMIWDS_SET_CLIENT_IP_FAMILY_PREF_REQ_MSG);
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rsi, %rbx
movq %rdi, %r14
movb $0x1, 0x7(%rdi)
movl $0x1, %edi
callq 0xee7e
movw %ax, 0x8(%r14)
movb (%rbx), %al
movb %al, 0xa(%r14)
movw $0x8, %ax
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O3/Carton32[P]quectel-CM/QMIThread.c
// Function: WdaSetLoopBackReq
static USHORT WdaSetLoopBackReq(PQMUX_MSG pMUXMsg, void *arg) {
    (void)arg;
	pMUXMsg->SetLoopBackReq.loopback_state.TLVType  = 0x01;
	pMUXMsg->SetLoopBackReq.loopback_state.TLVLength = cpu_to_le16(1);

	pMUXMsg->SetLoopBackReq.replication_factor.TLVType	= 0x10;
	pMUXMsg->SetLoopBackReq.replication_factor.TLVLength = cpu_to_le16(4);

	return sizeof(QMI_WDA_SET_LOOPBACK_CONFIG_REQ_MSG);
}

// Assembly:
pushq %rbx
movq %rdi, %rbx
movb $0x1, 0x7(%rdi)
movl $0x1, %edi
callq 0xee7e
movw %ax, 0x8(%rbx)
movb $0x10, 0xb(%rbx)
movl $0x4, %edi
callq 0xee7e
movw %ax, 0xc(%rbx)
movw $0xf, %ax
popq %rbx
retq
// File: /workspace/github_c_makefile_star2_O3/Carton32[P]quectel-CM/QMIThread.c
// Function: UimVerifyPinReqSend
static USHORT UimVerifyPinReqSend(PQMUX_MSG pMUXMsg, void *arg)
{
    pMUXMsg->UIMUIMVerifyPinReq.TLVType = 0x01;
    pMUXMsg->UIMUIMVerifyPinReq.TLVLength = cpu_to_le16(0x02);
    pMUXMsg->UIMUIMVerifyPinReq.Session_Type = 0x00;
    pMUXMsg->UIMUIMVerifyPinReq.Aid_Len = 0x00;
    pMUXMsg->UIMUIMVerifyPinReq.TLV2Type = 0x02;
    pMUXMsg->UIMUIMVerifyPinReq.TLV2Length = cpu_to_le16(2 + strlen((const char *)arg));
    pMUXMsg->UIMUIMVerifyPinReq.PINID = 0x01;  //Pin1, not Puk
    pMUXMsg->UIMUIMVerifyPinReq.PINLen= strlen((const char *)arg);
    qstrcpy((char *)&pMUXMsg->UIMUIMVerifyPinReq.PINValue, ((const char *)arg));
    return sizeof(QMIUIM_VERIFY_PIN_REQ_MSG) + (strlen((const char *)arg) - 1);
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
movq %rsi, %rbx
movq %rdi, %r14
movb $0x1, %bpl
movb %bpl, 0x7(%rdi)
movl $0x2, %edi
callq 0xee7e
movw %ax, 0x8(%r14)
movw $0x0, 0xa(%r14)
movb $0x2, 0xc(%r14)
movq %rbx, %rdi
callq 0x5160
addl $0x2, %eax
movzwl %ax, %edi
callq 0xee7e
movw %ax, 0xd(%r14)
movb %bpl, 0xf(%r14)
movq %rbx, %rdi
callq 0x5160
movb %al, 0x10(%r14)
movb (%rbx), %al
movb %al, 0x11(%r14)
testb %al, %al
je 0xdfd3
xorl %eax, %eax
movb 0x1(%rbx,%rax), %cl
movb %cl, 0x12(%r14,%rax)
incq %rax
testb %cl, %cl
jne 0xdfc3
movq %rbx, %rdi
callq 0x5160
addl $0xe, %eax
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/Carton32[P]quectel-CM/QMIThread.c
// Function: DmsUIMVerifyPinReqSend
static USHORT DmsUIMVerifyPinReqSend(PQMUX_MSG pMUXMsg, void *arg) {
    pMUXMsg->UIMVerifyPinReq.TLVType = 0x01;
    pMUXMsg->UIMVerifyPinReq.PINID = 0x01; //Pin1, not Puk
    pMUXMsg->UIMVerifyPinReq.PINLen = strlen((const char *)arg);
    qstrcpy((char *)&pMUXMsg->UIMVerifyPinReq.PINValue, ((const char *)arg));
    pMUXMsg->UIMVerifyPinReq.TLVLength = cpu_to_le16(2 + strlen((const char *)arg));
    return sizeof(QMIDMS_UIM_VERIFY_PIN_REQ_MSG) + (strlen((const char *)arg) - 1);
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rsi, %rbx
movq %rdi, %r14
movb $0x1, %al
movb %al, 0x7(%rdi)
movb %al, 0xa(%rdi)
movq %rsi, %rdi
callq 0x5160
movb %al, 0xb(%r14)
movb (%rbx), %al
movb %al, 0xc(%r14)
testb %al, %al
je 0xe01d
xorl %eax, %eax
movb 0x1(%rbx,%rax), %cl
movb %cl, 0xd(%r14,%rax)
incq %rax
testb %cl, %cl
jne 0xe00d
movq %rbx, %rdi
callq 0x5160
addl $0x2, %eax
movzwl %ax, %edi
callq 0xee7e
movw %ax, 0x8(%r14)
movq %rbx, %rdi
callq 0x5160
addl $0x9, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O3/Carton32[P]quectel-CM/QMIThread.c
// Function: quectel_convert_cdma_mcc_2_ascii_mcc
static void quectel_convert_cdma_mcc_2_ascii_mcc( USHORT *p_mcc, USHORT mcc )
{
  unsigned int d1, d2, d3, buf = mcc + 111;

  if ( mcc == 0x3FF ) // wildcard
  {
    *p_mcc = 3;
  }
  else
  {
    d3 = buf % 10;
    buf = ( d3 == 0 ) ? (buf-10)/10 : buf/10;

    d2 = buf % 10;
    buf = ( d2 == 0 ) ? (buf-10)/10 : buf/10;

    d1 = ( buf == 10 ) ? 0 : buf;

//dbg_time("d1:%d, d2:%d,d3:%d",d1,d2,d3);
    if ( d1<10 && d2<10 && d3<10 )
    {
    *p_mcc = d1*100+d2*10+d3;
#if 0
      *(p_mcc+0) = '0' + d1;
      *(p_mcc+1) = '0' + d2;
      *(p_mcc+2) = '0' + d3;
#endif
    }
    else
    {
      //dbg_time( "invalid digits %d %d %d", d1, d2, d3 );
      *p_mcc = 0;
    }
  }
}

// Assembly:
movw $0x3, %r8w
cmpl $0x3ff, %esi            # imm = 0x3FF
je 0xe537
movzwl %si, %edx
leal 0x6f(%rdx), %ecx
imulq $0x1999999a, %rcx, %rax # imm = 0x1999999A
shrq $0x20, %rax
addl %eax, %eax
leal (%rax,%rax,4), %esi
addl $0x65, %edx
movl %ecx, %eax
subl %esi, %eax
cmovnel %ecx, %edx
imulq $0x1999999a, %rdx, %rsi # imm = 0x1999999A
shrq $0x20, %rsi
imull $0x199a, %esi, %ecx     # imm = 0x199A
shrl $0xf, %ecx
andl $-0x2, %ecx
leal (%rcx,%rcx,4), %r8d
movl %esi, %ecx
subw %r8w, %cx
je 0xe50b
movl %edx, %edx
imulq $0x28f5c29, %rdx, %rdx  # imm = 0x28F5C29
shrq $0x20, %rdx
jmp 0xe51a
addl $-0xa, %esi
movzwl %si, %edx
imull $0xcccd, %edx, %edx     # imm = 0xCCCD
shrl $0x13, %edx
xorl %r8d, %r8d
cmpl $0xa, %edx
cmovel %r8d, %edx
cmpl $0x9, %edx
ja 0xe537
imull $0x64, %edx, %edx
addl %edx, %eax
addl %ecx, %ecx
leal (%rcx,%rcx,4), %r8d
addl %eax, %r8d
movw %r8w, (%rdi)
retq
// File: /workspace/github_c_makefile_star2_O3/Carton32[P]quectel-CM/QMIThread.c
// Function: char2ushort
static USHORT char2ushort(UCHAR str[3]) {
    int i;
    char temp[4];
    USHORT ret= 0;

    memcpy(temp, str, 3);
    temp[3] = '\0';

    for (i = 0; i < 4; i++) {
        if ((UCHAR)temp[i] == 0xFF) {
            temp[i] = '\0';
        }
    }
    ret = (USHORT)atoi(temp);

    return ret;
}

// Assembly:
pushq %rax
movb 0x2(%rdi), %cl
leaq 0x4(%rsp), %rax
movb %cl, 0x2(%rax)
movzwl (%rdi), %ecx
movw %cx, (%rax)
movb $0x0, 0x3(%rax)
movd (%rax), %xmm0
pcmpeqd %xmm1, %xmm1
pcmpeqb %xmm0, %xmm1
pandn %xmm0, %xmm1
movd %xmm1, (%rax)
movq %rax, %rdi
callq 0x54b0
popq %rcx
retq
// File: /workspace/github_c_makefile_star2_O3/Carton32[P]quectel-CM/QMIThread.c
// Function: WdsStopNwInterfaceReq
static USHORT WdsStopNwInterfaceReq(PQMUX_MSG pMUXMsg, void *arg) {
    pMUXMsg->StopNwInterfaceReq.TLVType = 0x01;
    pMUXMsg->StopNwInterfaceReq.TLVLength = cpu_to_le16(0x04);
    if (*((int *)arg) == IpFamilyV4)
        pMUXMsg->StopNwInterfaceReq.Handle =  cpu_to_le32(WdsConnectionIPv4Handle);
    else
        pMUXMsg->StopNwInterfaceReq.Handle =  cpu_to_le32(WdsConnectionIPv6Handle);
    return sizeof(QMIWDS_STOP_NETWORK_INTERFACE_REQ_MSG);
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rsi, %rbx
movq %rdi, %r14
movb $0x1, 0x7(%rdi)
movl $0x4, %edi
callq 0xee7e
movw %ax, 0x8(%r14)
cmpl $0x4, (%rbx)
leaq 0x1c415(%rip), %rax     # 0x2ac3c
leaq 0x1c412(%rip), %rcx     # 0x2ac40
cmoveq %rax, %rcx
movl (%rcx), %edi
callq 0xee81
movl %eax, 0xa(%r14)
movw $0xb, %ax
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O3/Carton32[P]quectel-CM/util.c
// Function: cm_open_dev
int cm_open_dev(const char *dev) {
    int fd;

    fd = open(dev, O_RDWR | O_NONBLOCK | O_NOCTTY);
    if (fd != -1) {
        fcntl(fd, F_SETFL, fcntl(fd,F_GETFL) | O_NONBLOCK);
        fcntl(fd, F_SETFD, FD_CLOEXEC);

        if (!strncmp(dev, "/dev/tty", strlen("/dev/tty")))
        {
            //disable echo on serial ports 
            struct termios  ios;

            memset(&ios, 0, sizeof(ios));
            tcgetattr( fd, &ios );
            cfmakeraw(&ios);
            cfsetispeed(&ios, B115200);
            cfsetospeed(&ios, B115200);
            tcsetattr( fd, TCSANOW, &ios );
            tcflush(fd, TCIOFLUSH);
        }
    } else {
        dbg_time("Failed to open %s, errno: %d (%s)", dev, errno, strerror(errno));
    }

    return fd;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x40, %rsp
movq %rdi, %r14
movl $0x902, %esi            # imm = 0x902
xorl %eax, %eax
callq 0x5440
movl %eax, %ebx
cmpl $-0x1, %eax
je 0xe9af
movl %ebx, %edi
movl $0x3, %esi
xorl %eax, %eax
callq 0x50e0
orl $0x800, %eax            # imm = 0x800
movl %ebx, %edi
movl $0x4, %esi
movl %eax, %edx
xorl %eax, %eax
callq 0x50e0
movl %ebx, %edi
movl $0x2, %esi
movl $0x1, %edx
xorl %eax, %eax
callq 0x50e0
leaq 0x12386(%rip), %rsi     # 0x20cc1
movl $0x8, %edx
movq %r14, %rdi
callq 0x5090
testl %eax, %eax
jne 0xea2c
xorps %xmm0, %xmm0
movq %rsp, %r14
movups %xmm0, 0x2c(%r14)
movaps %xmm0, 0x20(%r14)
movaps %xmm0, 0x10(%r14)
movaps %xmm0, (%r14)
movl %ebx, %edi
movq %r14, %rsi
callq 0x5420
movq %r14, %rdi
callq 0x53a0
movq %r14, %rdi
movl $0x1002, %esi           # imm = 0x1002
callq 0x5480
movq %r14, %rdi
movl $0x1002, %esi           # imm = 0x1002
callq 0x5150
movl %ebx, %edi
xorl %esi, %esi
movq %r14, %rdx
callq 0x5430
movl %ebx, %edi
movl $0x2, %esi
callq 0x5180
jmp 0xea2c
movq 0x1b60a(%rip), %rax     # 0x29fc0
movq (%rax), %r12
callq 0xea3b
callq 0x5070
movq %rax, %r15
movl (%rax), %ebp
movl %ebp, %edi
callq 0x5530
leaq 0x122f4(%rip), %rsi     # 0x20cca
leaq 0x1c2d3(%rip), %rdx     # 0x2acb0
movq %r12, %rdi
movq %r14, %rcx
movl %ebp, %r8d
movq %rax, %r9
xorl %eax, %eax
callq 0x52c0
movq 0x1c2b1(%rip), %r12     # 0x2aca8
testq %r12, %r12
je 0xea2c
callq 0xea3b
movl (%r15), %ebp
movl %ebp, %edi
callq 0x5530
leaq 0x122b8(%rip), %rsi     # 0x20cca
leaq 0x1c297(%rip), %rdx     # 0x2acb0
movq %r12, %rdi
movq %r14, %rcx
movl %ebp, %r8d
movq %rax, %r9
xorl %eax, %eax
callq 0x52c0
movl %ebx, %eax
addq $0x40, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/Carton32[P]quectel-CM/util.c
// Function: pthread_cond_timeout_np
int pthread_cond_timeout_np(pthread_cond_t *cond, pthread_mutex_t * mutex, unsigned msecs) {
    if (msecs != 0) {
        unsigned i;
        unsigned t = msecs/4;
        int ret = 0;

        if (t == 0)
            t = 1;

        for (i = 0; i < msecs; i += t) {
            struct timespec ts;
            setTimespecRelative(&ts, t);
//very old uclibc do not support pthread_condattr_setclock(CLOCK_MONOTONIC)
            ret = pthread_cond_timedwait(cond, mutex, &ts); //to advoid system time change
            if (ret != ETIMEDOUT) {
                if(ret) dbg_time("ret=%d, msecs=%u, t=%u", ret, msecs, t);
                break;
            }
        }

        return ret;
    } else {
        return pthread_cond_wait(cond, mutex);
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %rsi, %r12
movq %rdi, %rbp
testl %edx, %edx
je 0xee19
movl %edx, %r15d
movl %edx, %eax
shrl $0x2, %eax
cmpl $0x4, %edx
movl $0x1, %ecx
cmovael %eax, %ecx
imulq $0x10624dd3, %rcx, %r13 # imm = 0x10624DD3
shrq $0x26, %r13
imull $0x3e8, %r13d, %eax     # imm = 0x3E8
movq %rcx, 0x8(%rsp)
subl %eax, %ecx
imull $0x3e8, %ecx, %eax      # imm = 0x3E8
movq %rax, 0x20(%rsp)
xorl %r14d, %r14d
leaq 0x28(%rsp), %rdi
xorl %esi, %esi
callq 0x51f0
movq 0x28(%rsp), %rax
addq %r13, %rax
movq %rax, 0x10(%rsp)
movq 0x30(%rsp), %rcx
addq 0x20(%rsp), %rcx
imulq $0x3e8, %rcx, %rcx      # imm = 0x3E8
movq %rcx, 0x18(%rsp)
cmpq $0x3b9aca00, %rcx       # imm = 0x3B9ACA00
jb 0xed67
incq %rax
movq %rax, 0x10(%rsp)
addq $-0x3b9aca00, %rcx      # imm = 0xC4653600
movq %rcx, 0x18(%rsp)
movq %rbp, %rbx
movq %rbp, %rdi
movq %r12, %rbp
movq %r12, %rsi
leaq 0x10(%rsp), %rdx
callq 0x5410
cmpl $0x6e, %eax
jne 0xed9a
addl 0x8(%rsp), %r14d
cmpl %r15d, %r14d
movq %rbp, %r12
movq %rbx, %rbp
jb 0xed1b
movl $0x6e, %r12d
jmp 0xee07
movl %eax, %r12d
testl %eax, %eax
je 0xee07
movq 0x1b218(%rip), %rax     # 0x29fc0
movq (%rax), %rbx
callq 0xea3b
leaq 0x11f7b(%rip), %rsi     # 0x20d32
leaq 0x1bef2(%rip), %rdx     # 0x2acb0
movq %rbx, %rdi
movl %r12d, %ecx
movl %r15d, %r8d
movq 0x8(%rsp), %r9
xorl %eax, %eax
callq 0x52c0
movq 0x1bece(%rip), %rbx     # 0x2aca8
testq %rbx, %rbx
je 0xee07
callq 0xea3b
leaq 0x11f47(%rip), %rsi     # 0x20d32
leaq 0x1bebe(%rip), %rdx     # 0x2acb0
movq %rbx, %rdi
movl %r12d, %ecx
movl %r15d, %r8d
movq 0x8(%rsp), %r9
xorl %eax, %eax
callq 0x52c0
movl %r12d, %eax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rbp, %rdi
movq %r12, %rsi
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x5120
// File: /workspace/github_c_makefile_star2_O3/Carton32[P]quectel-CM/util.c
// Function: ql_set_driver_qmap_setting
void ql_set_driver_qmap_setting(PROFILE_T *profile, QMAP_SETTING *qmap_settings) {
    int ifc_ctl_sock;
    struct ifreq ifr;
    int rc;
    int request = 0x89F2;

    ifc_ctl_sock = socket(AF_INET, SOCK_DGRAM, 0);
    if (ifc_ctl_sock <= 0) {
        dbg_time("socket() failed: %s\n", strerror(errno));
        return;
    }
    
    memset(&ifr, 0, sizeof(struct ifreq));
    strncpy(ifr.ifr_name, profile->usbnet_adapter, IFNAMSIZ);
    ifr.ifr_name[IFNAMSIZ - 1] = 0;    
    ifr.ifr_ifru.ifru_data = (void *)qmap_settings;
        
    rc = ioctl(ifc_ctl_sock, request, &ifr);
    if (rc < 0) {
        dbg_time("ioctl(0x%x, qmap_settings) failed: %s, rc=%d", request, strerror(errno), rc);
    }

    close(ifc_ctl_sock);	
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x30, %rsp
movq %rsi, %r14
movq %rdi, %r15
movl $0x2, %edi
movl $0x2, %esi
xorl %edx, %edx
callq 0x55a0
testl %eax, %eax
jle 0xf777
movl %eax, %ebx
xorps %xmm0, %xmm0
leaq 0x8(%rsp), %r12
movups %xmm0, 0x18(%r12)
addq $0xaa, %r15
movl $0x10, %edx
movq %r12, %rdi
movq %r15, %rsi
callq 0x5080
movb $0x0, 0xf(%r12)
movq %r14, 0x10(%r12)
movl $0x89f2, %esi           # imm = 0x89F2
movl %ebx, %edi
movq %r12, %rdx
xorl %eax, %eax
callq 0x5210
testl %eax, %eax
jns 0xf763
movl %eax, %ebp
movq 0x1a8d3(%rip), %rax     # 0x29fc0
movq (%rax), %r15
callq 0xea3b
callq 0x5070
movq %rax, %r14
movl (%rax), %edi
callq 0x5530
leaq 0x1176d(%rip), %rsi     # 0x20e78
leaq 0x1b59e(%rip), %rdx     # 0x2acb0
movq %r15, %rdi
movl $0x89f2, %ecx           # imm = 0x89F2
movq %rax, %r8
movl %ebp, %r9d
xorl %eax, %eax
callq 0x52c0
movq 0x1b57a(%rip), %r15     # 0x2aca8
testq %r15, %r15
je 0xf763
callq 0xea3b
movl (%r14), %edi
callq 0x5530
leaq 0x11731(%rip), %rsi     # 0x20e78
leaq 0x1b562(%rip), %rdx     # 0x2acb0
movq %r15, %rdi
movl $0x89f2, %ecx           # imm = 0x89F2
movq %rax, %r8
movl %ebp, %r9d
xorl %eax, %eax
callq 0x52c0
movl %ebx, %edi
callq 0x5230
addq $0x30, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
movq 0x1a842(%rip), %rax     # 0x29fc0
movq (%rax), %r14
callq 0xea3b
callq 0x5070
movq %rax, %rbx
movl (%rax), %edi
callq 0x5530
leaq 0x1168b(%rip), %rsi     # 0x20e27
leaq 0x1b50d(%rip), %rdx     # 0x2acb0
movq %r14, %rdi
movq %rax, %rcx
xorl %eax, %eax
callq 0x52c0
movq 0x1b4f1(%rip), %r14     # 0x2aca8
testq %r14, %r14
je 0xf76a
callq 0xea3b
movl (%rbx), %edi
callq 0x5530
leaq 0x11658(%rip), %rsi     # 0x20e27
leaq 0x1b4da(%rip), %rdx     # 0x2acb0
movq %r14, %rdi
movq %rax, %rcx
xorl %eax, %eax
addq $0x30, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
jmp 0x52c0
nop
// File: /workspace/github_c_makefile_star2_O3/Carton32[P]quectel-CM/qmap_bridge_mode.c
// Function: ql_fread
static size_t ql_fread(const char *filename, void *buf, size_t size) {
    FILE *fp = fopen(filename , "r");
    size_t n = 0;

    memset(buf, 0x00, size);

    if (fp) {
        n = fread(buf, 1, size, fp);
        if (n <= 0 || n == size) {
            dbg_time("warnning: fail to fread(%s), fread=%zu, buf_size=%zu: (%s)", filename, n, size, strerror(errno));
        }
        fclose(fp);
    }

    return n > 0 ? n : 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rdx, %rbx
movq %rsi, %r13
movq %rdi, %r15
leaq 0x1268b(%rip), %rsi     # 0x22186
callq 0x5470
movq %rax, %r14
xorl %r12d, %r12d
movq %r13, %rdi
xorl %esi, %esi
movq %rbx, %rdx
callq 0x5200
testq %r14, %r14
je 0xfbdc
movl $0x1, %esi
movq %r13, %rdi
movq %rbx, %rdx
movq %r14, %rcx
callq 0x50b0
movq %rax, %r12
testq %rax, %rax
setne %al
cmpq %rbx, %r12
setne %cl
testb %cl, %al
jne 0xfbd4
movq 0x1a473(%rip), %rax     # 0x29fc0
movq (%rax), %rax
movq %rax, 0x10(%rsp)
callq 0xea3b
movq %rax, %rbp
callq 0x5070
movq %rax, %r13
movl (%rax), %edi
callq 0x5530
movq %rax, (%rsp)
leaq 0x114a0(%rip), %rsi     # 0x21017
movq 0x10(%rsp), %rdi
movq %rbp, %rdx
movq %r15, %rcx
movq %r12, %r8
movq %rbx, %r9
xorl %eax, %eax
callq 0x52c0
leaq 0x1b112(%rip), %rax     # 0x2aca8
movq (%rax), %rbp
testq %rbp, %rbp
je 0xfbd4
callq 0xea3b
movq %rax, 0x10(%rsp)
movl (%r13), %edi
callq 0x5530
movq %rax, (%rsp)
leaq 0x1145b(%rip), %rsi     # 0x21017
movq %rbp, %rdi
movq 0x10(%rsp), %rdx
movq %r15, %rcx
movq %r12, %r8
movq %rbx, %r9
xorl %eax, %eax
callq 0x52c0
movq %r14, %rdi
callq 0x5130
movq %r12, %rax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/Carton32[P]quectel-CM/qmap_bridge_mode.c
// Function: ql_fwrite
static size_t ql_fwrite(const char *filename, const void *buf, size_t size) {
    FILE *fp = fopen(filename , "w");
    size_t n = 0;

    if (fp) {
        n = fwrite(buf, 1, size, fp);
        if (n != size) {
            dbg_time("warnning: fail to fwrite(%s), fwrite=%zu, buf_size=%zu: (%s)", filename, n, size, strerror(errno));
        }
        fclose(fp);
    }

    return n > 0 ? n : 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rdx, %rbx
movq %rsi, %r12
movq %rdi, %r15
leaq 0x11a35(%rip), %rsi     # 0x21641
callq 0x5470
testq %rax, %rax
je 0xfce0
movq %rax, %r14
movl $0x1, %esi
movq %r12, %rdi
movq %rbx, %rdx
movq %rax, %rcx
callq 0x5500
cmpq %rbx, %rax
je 0xfcca
movq %rax, %r12
movq 0x1a37d(%rip), %rax     # 0x29fc0
movq (%rax), %rax
movq %rax, 0x10(%rsp)
callq 0xea3b
movq %rax, %rbp
callq 0x5070
movq %rax, %r13
movl (%rax), %edi
callq 0x5530
movq %rax, (%rsp)
leaq 0x113eb(%rip), %rsi     # 0x21058
movq 0x10(%rsp), %rdi
movq %rbp, %rdx
movq %r15, %rcx
movq %r12, %r8
movq %rbx, %r9
xorl %eax, %eax
callq 0x52c0
leaq 0x1b01c(%rip), %rax     # 0x2aca8
movq (%rax), %rbp
testq %rbp, %rbp
je 0xfcca
callq 0xea3b
movq %rax, 0x10(%rsp)
movl (%r13), %edi
callq 0x5530
movq %rax, (%rsp)
leaq 0x113a6(%rip), %rsi     # 0x21058
movq %rbp, %rdi
movq 0x10(%rsp), %rdx
movq %r15, %rcx
movq %r12, %r8
movq %rbx, %r9
xorl %eax, %eax
callq 0x52c0
movq %r14, %rdi
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x5130
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/Carton32[P]quectel-CM/qmap_bridge_mode.c
// Function: ql_driver_type_detect
int ql_driver_type_detect(PROFILE_T *profile) {
    if (qmidev_is_gobinet(profile->qmichannel)) {
        profile->qmi_ops = &gobi_qmidev_ops;
    }
    else {
        profile->qmi_ops = &qmiwwan_qmidev_ops;
    }
    qmidev_send = profile->qmi_ops->send;

    return 0;
}

// Assembly:
pushq %rbx
movq %rdi, %rbx
addq $0x8a, %rdi
leaq 0xec5d(%rip), %rsi      # 0x1eb5a
movl $0xa, %edx
callq 0x5090
leaq 0x186b2(%rip), %rcx     # 0x285c0
leaq 0x186cb(%rip), %rdx     # 0x285e0
leaq 0x10(%rdx), %rsi
testl %eax, %eax
cmovneq %rcx, %rdx
leaq 0x10(%rcx), %rax
movq %rdx, 0x31e(%rbx)
cmoveq %rsi, %rax
movq (%rax), %rax
leaq 0x1acf0(%rip), %rcx     # 0x2ac28
movq %rax, (%rcx)
xorl %eax, %eax
popq %rbx
retq
// File: /workspace/github_c_makefile_star2_O3/Carton32[P]quectel-CM/qmap_bridge_mode.c
// Function: ql_set_driver_bridge_mode
void ql_set_driver_bridge_mode(PROFILE_T *profile) {
    char enable[16];
    char filename[256];

    if(profile->qmap_mode)
        snprintf(filename, sizeof(filename), "/sys/class/net/%s/bridge_mode", profile->qmapnet_adapter);
    else
        snprintf(filename, sizeof(filename), "/sys/class/net/%s/bridge_mode", profile->usbnet_adapter);
    snprintf(enable, sizeof(enable), "%02d\n", profile->enable_bridge);
    ql_fwrite(filename, enable, sizeof(enable));
}

// Assembly:
pushq %r14
pushq %rbx
subq $0x118, %rsp            # imm = 0x118
movq %rdi, %rbx
xorl %eax, %eax
cmpl $0x0, 0x10a(%rdi)
setne %al
shll $0x5, %eax
leaq (%rax,%rdi), %rcx
addq $0xaa, %rcx
leaq 0x10f43(%rip), %rdx     # 0x20eb0
leaq 0x10(%rsp), %r14
movl $0x100, %esi            # imm = 0x100
movq %r14, %rdi
xorl %eax, %eax
callq 0x51c0
movl 0x4c(%rbx), %ecx
leaq 0x11086(%rip), %rdx     # 0x21011
movq %rsp, %rbx
movl $0x10, %esi
movq %rbx, %rdi
xorl %eax, %eax
callq 0x51c0
movl $0x10, %edx
movq %r14, %rdi
movq %rbx, %rsi
callq 0xfbee
addq $0x118, %rsp            # imm = 0x118
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O3/Carton32[P]quectel-CM/mbim-cm.c
// Function: compose_basic_connect_command
static MBIM_MESSAGE_HEADER *compose_basic_connect_command(UINT32 CID, UINT32 CommandType, void *pInformationBuffer, UINT32 InformationBufferLength)
{
    MBIM_COMMAND_MSG_T *pRequest = (MBIM_COMMAND_MSG_T *)mbim_alloc(sizeof(MBIM_COMMAND_MSG_T) + InformationBufferLength);

    if (!pRequest)
        return NULL;

    pRequest->MessageHeader.MessageType = htole32(MBIM_COMMAND_MSG);
    pRequest->MessageHeader.MessageLength = htole32((sizeof(MBIM_COMMAND_MSG_T) + InformationBufferLength));
    pRequest->MessageHeader.TransactionId = htole32(TransactionId++);

    pRequest->FragmentHeader.TotalFragments = htole32(1);
    pRequest->FragmentHeader.CurrentFragment= htole32(0);

    memcpy(pRequest->DeviceServiceId.uuid, str2uuid(UUID_BASIC_CONNECT), 16);

    pRequest->CID = htole32(CID);
    pRequest->CommandType = htole32(CommandType);
    if (InformationBufferLength && pInformationBuffer) {
        pRequest->InformationBufferLength = htole32(InformationBufferLength);
        memcpy(pRequest->InformationBuffer, pInformationBuffer, InformationBufferLength);
    } else {
        pRequest->InformationBufferLength = htole32(0);
    }

    return &pRequest->MessageHeader;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl %ecx, %ebp
movq %rdx, (%rsp)
movl %esi, %r12d
movl %edi, %r13d
movl %ecx, %r14d
leaq 0x30(%r14), %rbx
movq %rbx, %rdi
callq 0x5360
movq %rax, %r15
testq %rax, %rax
je 0x10b1f
movl $0x3, (%r15)
movl %ebx, 0x4(%r15)
movl 0x1984e(%rip), %eax     # 0x2a308
leal 0x1(%rax), %ecx
movl %ecx, 0x19845(%rip)     # 0x2a308
movl %eax, 0x8(%r15)
movq $0x1, 0xc(%r15)
leaq 0x108fc(%rip), %rdi     # 0x213d2
callq 0x10b31
movups 0x1b252(%rip), %xmm0    # 0x2bd34
movups %xmm0, 0x14(%r15)
movl %r13d, 0x24(%r15)
movl %r12d, 0x28(%r15)
testl %ebp, %ebp
sete %al
movq (%rsp), %rsi
testq %rsi, %rsi
sete %cl
orb %al, %cl
jne 0x10b17
movl %ebp, 0x2c(%r15)
movq %r15, %rdi
addq $0x30, %rdi
movq %r14, %rdx
callq 0x52f0
jmp 0x10b1f
movl $0x0, 0x2c(%r15)
movq %r15, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/Carton32[P]quectel-CM/mbim-cm.c
// Function: str2uuid
static const UUID_T * str2uuid(const char *str) {
    static UUID_T uuid;
    UINT32 d[16];
    char tmp[16*2+4+1];
    unsigned i = 0;

    while (str[i]) {
        tmp[i] = tolower(str[i]);
        i++;
    }
    tmp[i] = '\0';

    sscanf(tmp, "%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x",
        &d[0], &d[1], &d[2], &d[3], &d[4], &d[5], &d[6], &d[7],
        &d[8], &d[9], &d[10], &d[11], &d[12], &d[13], &d[14], &d[15]);

    for (i = 0; i < 16; i++) {
        uuid.uuid[i] = d[i]&0xFF;
    }

    return &uuid;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x68, %rsp
movb (%rdi), %bpl
testb %bpl, %bpl
je 0x10b75
movq %rdi, %rbx
callq 0x5570
movq (%rax), %rcx
movl $0x1, %edx
xorl %eax, %eax
movsbq %bpl, %rsi
movb (%rcx,%rsi,4), %sil
movb %sil, 0x40(%rsp,%rax)
movl %edx, %eax
movb (%rbx,%rax), %bpl
incl %edx
testb %bpl, %bpl
jne 0x10b59
jmp 0x10b77
xorl %eax, %eax
movb $0x0, 0x40(%rsp,%rax)
leaq 0x4(%rsp), %rcx
leaq 0x8(%rsp), %r8
leaq 0xc(%rsp), %r9
leaq 0x24(%rsp), %r13
leaq 0x28(%rsp), %rbp
leaq 0x2c(%rsp), %r10
leaq 0x30(%rsp), %r11
leaq 0x34(%rsp), %r14
leaq 0x38(%rsp), %r15
leaq 0x3c(%rsp), %r12
leaq 0x10842(%rip), %rsi     # 0x213f7
xorl %ebx, %ebx
leaq 0x40(%rsp), %rdi
movq %rsp, %rdx
xorl %eax, %eax
pushq %r12
pushq %r15
pushq %r14
pushq %r11
pushq %r10
pushq %rbp
pushq %r13
leaq 0x58(%rsp), %r10
pushq %r10
leaq 0x5c(%rsp), %r10
pushq %r10
leaq 0x60(%rsp), %r10
pushq %r10
leaq 0x64(%rsp), %r10
pushq %r10
leaq 0x68(%rsp), %r10
pushq %r10
callq 0x5390
addq $0x60, %rsp
movdqa 0x106ce(%rip), %xmm0    # 0x212d0
leaq 0x1b12b(%rip), %rax     # 0x2bd34
movdqa (%rsp,%rbx,4), %xmm1
pand %xmm0, %xmm1
packuswb %xmm1, %xmm1
packuswb %xmm1, %xmm1
movd %xmm1, (%rbx,%rax)
addq $0x4, %rbx
cmpq $0x10, %rbx
jne 0x10c09
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/Carton32[P]quectel-CM/mbim-cm.c
// Function: mbim_deinit
static int mbim_close_device(void) {
    MBIM_MESSAGE_HEADER *pRequest = NULL;
    MBIM_CLOSE_DONE_T *pCloseDone = NULL;
    int err = 0;

    mbim_debug("%s()", __func__);
    pRequest = compose_close_command();
    err = mbim_send_command(pRequest, (MBIM_COMMAND_DONE_T **)&pCloseDone, mbim_default_timeout);
    mbim_check_err(err, pRequest, pCloseDone);

    err = le32toh(pCloseDone->Status);
    mbim_free(pRequest); mbim_free(pCloseDone);

    return err;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq $0x0, 0x10(%rsp)
movq 0x17d21(%rip), %r13     # 0x29fc0
movq (%r13), %rbx
callq 0xea3b
leaq 0xff7e(%rip), %rsi      # 0x2222d
leaq 0x100f3(%rip), %rcx     # 0x223a9
movq %rbx, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0x52c0
leaq 0x189de(%rip), %r12     # 0x2aca8
movq (%r12), %rbx
testq %rbx, %rbx
je 0x122f3
callq 0xea3b
leaq 0xff4e(%rip), %rsi      # 0x2222d
leaq 0x100c3(%rip), %rcx     # 0x223a9
movq %rbx, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0x52c0
movl $0xc, %edi
callq 0x5360
movq %rax, %r14
testq %rax, %rax
je 0x12325
movabsq $0xc00000002, %rax      # imm = 0xC00000002
movq %rax, (%r14)
movl 0x17ff0(%rip), %eax     # 0x2a308
leal 0x1(%rax), %ecx
movl %ecx, 0x17fe7(%rip)     # 0x2a308
movl %eax, 0x8(%r14)
leaq 0x10(%rsp), %r15
movq %r14, %rdi
movq %r15, %rsi
movl $0x7530, %edx           # imm = 0x7530
callq 0x10c38
movl %eax, %ebx
movq (%r15), %r15
testq %r15, %r15
je 0x12384
movl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
addl (%r15), %eax
xorl %ebp, %ebp
cmpl $0x3, %eax
ja 0x12364
movl %eax, %eax
leaq 0x104d4(%rip), %rcx     # 0x22830
movq (%rcx,%rax,8), %rax
movl (%r15,%rax), %ebp
movl %ebx, %eax
orl %ebp, %eax
jne 0x12388
testq %r14, %r14
je 0x12377
movq %r14, %rdi
callq 0x5040
movq %r15, %rdi
callq 0x5040
jmp 0x12427
xorl %ebp, %ebp
jmp 0x1239d
xorl %esi, %esi
cmpl $0x0, 0x1999f(%rip)     # 0x2bd30
sete %sil
movq %r15, %rdi
callq 0x10dbe
testq %r14, %r14
je 0x123aa
movq %r14, %rdi
callq 0x5040
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x123c2
callq 0x5040
movq $0x0, 0x10(%rsp)
movq (%r13), %r14
callq 0xea3b
movl %ebp, (%rsp)
leaq 0xefb0(%rip), %rsi      # 0x21385
leaq 0xffcd(%rip), %rcx      # 0x223a9
movq %r14, %rdi
movq %rax, %rdx
movl $0x6af, %r8d            # imm = 0x6AF
movl %ebx, %r9d
xorl %eax, %eax
callq 0x52c0
movq (%r12), %r14
testq %r14, %r14
je 0x12427
callq 0xea3b
movl %ebp, (%rsp)
leaq 0xef7b(%rip), %rsi      # 0x21385
leaq 0xff98(%rip), %rcx      # 0x223a9
movq %r14, %rdi
movq %rax, %rdx
movl $0x6af, %r8d            # imm = 0x6AF
movl %ebx, %r9d
xorl %eax, %eax
callq 0x52c0
movl 0x17ed3(%rip), %edi     # 0x2a300
cmpl $-0x1, %edi
je 0x12442
callq 0x5230
movl 0x17ec7(%rip), %edi     # 0x2a304
callq 0x5230
xorl %eax, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/Carton32[P]quectel-CM/mbim-cm.c
// Function: requestSetupDataCall
static int requestSetupDataCall(PROFILE_T *profile, int curIpFamily) {
    int retval;

    (void)curIpFamily;

    if (profile->apn)
        mbim_apn = profile->apn;
    if (profile->user)
        mbim_user = profile->user;
    if (profile->password)
        mbim_passwd = profile->password;
    if (profile->auth)
        mbim_auth = profile->auth;
    if (profile->enable_ipv4)
        mbim_iptype = MBIMContextIPTypeIPv4;
    if (profile->enable_ipv6)
        mbim_iptype = MBIMContextIPTypeIPv6;
    if (profile->enable_ipv4 && profile->enable_ipv6)
        mbim_iptype = MBIMContextIPTypeIPv4AndIPv6;

    retval = mbim_set_connect(1, mbim_sessionID);
    if (retval)
        goto exit;

exit:
    return retval;
}

// Assembly:
movq (%rdi), %rax
testq %rax, %rax
je 0x1343c
movq %rax, 0x18adc(%rip)     # 0x2bf18
movq 0x8(%rdi), %rax
testq %rax, %rax
je 0x1344c
movq %rax, 0x18ad4(%rip)     # 0x2bf20
movq 0x10(%rdi), %rax
testq %rax, %rax
je 0x1345c
movq %rax, 0x18acc(%rip)     # 0x2bf28
movl 0x18(%rdi), %eax
testl %eax, %eax
je 0x13469
movl %eax, 0x18ac7(%rip)     # 0x2bf30
cmpb $0x0, 0x50(%rdi)
movb 0x51(%rdi), %cl
je 0x13480
xorl %eax, %eax
testb %cl, %cl
setne %al
leal (%rax,%rax,2), %eax
incl %eax
jmp 0x13489
movl $0x2, %eax
testb %cl, %cl
je 0x1348f
movl %eax, 0x18aa5(%rip)     # 0x2bf34
movl 0x18a7f(%rip), %esi     # 0x2bf14
movl $0x1, %edi
jmp 0x15ff1
// File: /workspace/github_c_makefile_star2_O3/Carton32[P]quectel-CM/mbim-cm.c
// Function: mbim_dump_signal_state
static void mbim_dump_signal_state(MBIM_SIGNAL_STATE_INFO_T *pInfo, const char *direction)
{
    mbim_debug("%s Rssi = %u", direction, le32toh(pInfo->Rssi));
    mbim_debug("%s ErrorRate = %u", direction, le32toh(pInfo->ErrorRate));
    mbim_debug("%s SignalStrengthInterval = %u", direction, le32toh(pInfo->SignalStrengthInterval));
    mbim_debug("%s RssiThreshold = %u", direction, le32toh(pInfo->RssiThreshold));
    mbim_debug("%s ErrorRateThreshold = %u", direction, le32toh(pInfo->ErrorRateThreshold));
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
movq %rsi, %rbx
movq %rdi, %r14
movq 0x1491f(%rip), %r12     # 0x29fc0
movq (%r12), %r15
callq 0xea3b
movl (%r14), %r8d
leaq 0xcaec(%rip), %rsi      # 0x221a0
movq %r15, %rdi
movq %rax, %rdx
movq %rbx, %rcx
xorl %eax, %eax
callq 0x52c0
leaq 0x155dd(%rip), %r13     # 0x2aca8
movq (%r13), %r15
testq %r15, %r15
je 0x156f3
callq 0xea3b
movl (%r14), %r8d
leaq 0xcabd(%rip), %rsi      # 0x221a0
movq %r15, %rdi
movq %rax, %rdx
movq %rbx, %rcx
xorl %eax, %eax
callq 0x52c0
movq (%r12), %r15
callq 0xea3b
movl 0x4(%r14), %r8d
leaq 0xcaac(%rip), %rsi      # 0x221b3
movq %r15, %rdi
movq %rax, %rdx
movq %rbx, %rcx
xorl %eax, %eax
callq 0x52c0
movq (%r13), %r15
testq %r15, %r15
je 0x15740
callq 0xea3b
movl 0x4(%r14), %r8d
leaq 0xca83(%rip), %rsi      # 0x221b3
movq %r15, %rdi
movq %rax, %rdx
movq %rbx, %rcx
xorl %eax, %eax
callq 0x52c0
movq (%r12), %r15
callq 0xea3b
movl 0x8(%r14), %r8d
leaq 0xca77(%rip), %rsi      # 0x221cb
movq %r15, %rdi
movq %rax, %rdx
movq %rbx, %rcx
xorl %eax, %eax
callq 0x52c0
movq (%r13), %r15
testq %r15, %r15
je 0x1578d
callq 0xea3b
movl 0x8(%r14), %r8d
leaq 0xca4e(%rip), %rsi      # 0x221cb
movq %r15, %rdi
movq %rax, %rdx
movq %rbx, %rcx
xorl %eax, %eax
callq 0x52c0
movq (%r12), %r15
callq 0xea3b
movl 0xc(%r14), %r8d
leaq 0xca4f(%rip), %rsi      # 0x221f0
movq %r15, %rdi
movq %rax, %rdx
movq %rbx, %rcx
xorl %eax, %eax
callq 0x52c0
movq (%r13), %r15
testq %r15, %r15
je 0x157da
callq 0xea3b
movl 0xc(%r14), %r8d
leaq 0xca26(%rip), %rsi      # 0x221f0
movq %r15, %rdi
movq %rax, %rdx
movq %rbx, %rcx
xorl %eax, %eax
callq 0x52c0
movq (%r12), %r15
callq 0xea3b
movl 0x10(%r14), %r8d
leaq 0xca1e(%rip), %rsi      # 0x2220c
movq %r15, %rdi
movq %rax, %rdx
movq %rbx, %rcx
xorl %eax, %eax
callq 0x52c0
movq (%r13), %r15
testq %r15, %r15
je 0x15830
callq 0xea3b
movl 0x10(%r14), %r8d
leaq 0xc9f5(%rip), %rsi      # 0x2220c
movq %r15, %rdi
movq %rax, %rdx
movq %rbx, %rcx
xorl %eax, %eax
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
jmp 0x52c0
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O3/Carton32[P]quectel-CM/mbim-cm.c
// Function: mbim_dump_uuid_cid
static void mbim_dump_uuid_cid(const UUID_T *pUUID, UINT32 CID, const char *direction) {
    size_t idx;
    const char *uuidStr = uuid2str(pUUID);
    const char *cidStr = "unknow";

    for (idx = 0; idx < (sizeof(uuid_cid_string)/sizeof(uuid_cid_string[0])); idx++) {
        if (!strcmp(uuidStr, uuid_cid_string[idx].uuid) && uuid_cid_string[idx].cid == CID) {
            cidStr = uuid_cid_string[idx].name;
        }
    }

    mbim_debug("%s DeviceServiceId = %s (%s)", direction, DeviceServiceId2str(pUUID), uuidStr);
    mbim_debug("%s CID = %s (%u)", direction, cidStr, le32toh(CID));
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdx, (%rsp)
movl %esi, %ebx
movq %rdi, %r12
callq 0x15992
leaq 0xbe2e(%rip), %r15      # 0x21688
movl $0xc, %ebp
leaq 0x13cda(%rip), %r14     # 0x29540
leaq 0x16553(%rip), %r13     # 0x2bdc0
movq -0xc(%rbp,%r14), %rsi
movq %r13, %rdi
callq 0x52a0
testl %eax, %eax
jne 0x1588a
cmpl %ebx, -0x4(%rbp,%r14)
jne 0x1588a
movq (%rbp,%r14), %r15
addq $0x14, %rbp
cmpq $0x37c, %rbp            # imm = 0x37C
jne 0x1586d
movq 0x14722(%rip), %rax     # 0x29fc0
movq (%rax), %r13
callq 0xea3b
movq %rax, %rbp
movq %r12, %rdi
callq 0x15a54
leaq 0xbdd7(%rip), %rsi      # 0x2168f
leaq 0x16501(%rip), %r9      # 0x2bdc0
movq %r13, %rdi
movq %rbp, %rdx
movq (%rsp), %r14
movq %r14, %rcx
movq %rax, %r8
xorl %eax, %eax
callq 0x52c0
leaq 0x153cb(%rip), %rbp     # 0x2aca8
movq (%rbp), %r13
testq %r13, %r13
je 0x1591e
callq 0xea3b
movq %rax, %rbp
movq %r12, %rdi
callq 0x15a54
leaq 0xbd92(%rip), %rsi      # 0x2168f
leaq 0x164bc(%rip), %r9      # 0x2bdc0
movq %r13, %rdi
movq %rbp, %rdx
leaq 0x15397(%rip), %rbp     # 0x2aca8
movq %r14, %rcx
movq %rax, %r8
xorl %eax, %eax
callq 0x52c0
movq 0x1469b(%rip), %rax     # 0x29fc0
movq (%rax), %r12
callq 0xea3b
leaq 0xbd7e(%rip), %rsi      # 0x216b2
movq %r12, %rdi
movq %rax, %rdx
movq %r14, %rcx
movq %r15, %r8
movl %ebx, %r9d
xorl %eax, %eax
callq 0x52c0
movq (%rbp), %r12
testq %r12, %r12
je 0x15983
callq 0xea3b
leaq 0xbd53(%rip), %rsi      # 0x216b2
movq %r12, %rdi
movq %rax, %rdx
movq %r14, %rcx
movq %r15, %r8
movl %ebx, %r9d
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x52c0
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/Carton32[P]quectel-CM/mbim-cm.c
// Function: uuid2str
static const char * uuid2str(const UUID_T *pUUID) {
    static char str[16*2+4+1];
    const UINT8 *d = pUUID->uuid;

    snprintf(str, sizeof(str), "%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x",
        d[0], d[1], d[2], d[3], d[4], d[5], d[6], d[7],
        d[8], d[9], d[10], d[11], d[12], d[13], d[14], d[15]);

    return str;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movzbl (%rdi), %ecx
movzbl 0x1(%rdi), %r8d
movzbl 0x2(%rdi), %r9d
movzbl 0x3(%rdi), %eax
movq %rax, 0x20(%rsp)
movzbl 0x4(%rdi), %eax
movq %rax, 0x18(%rsp)
movzbl 0x5(%rdi), %eax
movq %rax, 0x10(%rsp)
movzbl 0x6(%rdi), %eax
movq %rax, 0x8(%rsp)
movzbl 0x7(%rdi), %eax
movq %rax, (%rsp)
movzbl 0x8(%rdi), %r12d
movzbl 0x9(%rdi), %r13d
movzbl 0xa(%rdi), %ebp
movzbl 0xb(%rdi), %r10d
movzbl 0xc(%rdi), %r11d
movzbl 0xd(%rdi), %ebx
movzbl 0xe(%rdi), %r14d
movzbl 0xf(%rdi), %r15d
subq $0x8, %rsp
leaq 0x163b6(%rip), %rdi     # 0x2bdc0
leaq 0xb9e6(%rip), %rdx      # 0x213f7
movl $0x25, %esi
xorl %eax, %eax
pushq %r15
pushq %r14
pushq %rbx
pushq %r11
pushq %r10
pushq %rbp
pushq %r13
pushq %r12
pushq 0x48(%rsp)
pushq 0x58(%rsp)
pushq 0x68(%rsp)
pushq 0x78(%rsp)
pushq 0x88(%rsp)
callq 0x51c0
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/Carton32[P]quectel-CM/device.c
// Function: dir_get_child
static int dir_get_child(const char *dirname, char *buff, unsigned bufsize, const char *prefix)
{
    struct dirent *entptr = NULL;
    DIR *dirptr;

    buff[0] = 0;

    dirptr = opendir(dirname);
    if (!dirptr)
        return -1;

    while ((entptr = readdir(dirptr))) {
        if (entptr->d_name[0] == '.')
            continue;
        if (prefix && strlen(prefix) && strncmp(entptr->d_name, prefix, strlen(prefix)))
            continue;
        snprintf(buff, bufsize, "%s", entptr->d_name);
        break;
    }
    closedir(dirptr);

    return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movq %rcx, %r15
movl %edx, %ebp
movq %rsi, %r14
movb $0x0, (%rsi)
callq 0x5140
testq %rax, %rax
je 0x17164
movq %rax, %rbx
movq %rax, %rdi
callq 0x5320
testq %rax, %rax
je 0x17183
movq %rax, %r12
cmpb $0x2e, 0x13(%r12)
je 0x17152
addq $0x13, %r12
testq %r15, %r15
je 0x1716d
movq %r15, %rdi
callq 0x5160
testq %rax, %rax
je 0x1716d
movq %r12, %rdi
movq %r15, %rsi
movq %rax, %rdx
callq 0x5090
testl %eax, %eax
je 0x1716d
movq %rbx, %rdi
callq 0x5320
movq %rax, %r12
testq %rax, %rax
jne 0x17122
jmp 0x17183
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
movl %ebp, %esi
leaq 0xbcb7(%rip), %rdx      # 0x22e2d
movq %r14, %rdi
movq %r12, %rcx
xorl %eax, %eax
callq 0x51c0
movq %rbx, %rdi
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
jmp 0x5240