LLM4Binary/decompile-bench-makefile huggingface dataset:
// File: /workspace/github_c_makefile_star2_O2/Carton32[P]quectel-CM/main.c
// Function: is_same_linkfile
static int is_same_linkfile(const char *dir, const char *file,  void *argv[])
{
    const char *qmichannel = (const char *)argv[1];
    char linkname[MAX_PATH];
    char filename[MAX_PATH];
    int linksize;

    snprintf(linkname, MAX_PATH, "%s/%s", dir, file);
    linksize = readlink(linkname, filename, MAX_PATH);
    if (linksize <= 0)
        return 0;

    filename[linksize] = 0;
    if (strcmp(filename, qmichannel))
        return 0;

    dbg_time("%s -> %s", linkname, filename);
    return 1;
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
subq $0x200, %rsp            # imm = 0x200
movq %rsi, %r8
movq %rdi, %rcx
movq 0x8(%rdx), %r14
leaq 0x13821(%rip), %rdx     # 0x1ce12
xorl %ebx, %ebx
leaq 0x100(%rsp), %r15
movl $0x100, %esi            # imm = 0x100
movq %r15, %rdi
xorl %eax, %eax
callq 0x51c0
movq %rsp, %rsi
movl $0x100, %edx            # imm = 0x100
movq %r15, %rdi
callq 0x50d0
testl %eax, %eax
jle 0x969a
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
movb $0x0, (%rsp,%rax)
movq %rsp, %rdi
movq %r14, %rsi
callq 0x52a0
testl %eax, %eax
jne 0x969a
movq 0x1f97b(%rip), %rax     # 0x28fb8
movq (%rax), %rbx
callq 0xe343
leaq 0x137cc(%rip), %rsi     # 0x1ce18
leaq 0x100(%rsp), %rcx
movq %rsp, %r8
movq %rbx, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0x52c0
leaq 0x2063d(%rip), %rax     # 0x29ca8
movq (%rax), %r14
pushq $0x1
popq %rbx
testq %r14, %r14
je 0x969a
callq 0xe343
leaq 0x13796(%rip), %rsi     # 0x1ce18
leaq 0x100(%rsp), %rcx
movq %rsp, %r8
movq %r14, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0x52c0
movl %ebx, %eax
addq $0x200, %rsp            # imm = 0x200
popq %rbx
popq %r14
popq %r15
retq
nopl (%rax)
// File: /workspace/github_c_makefile_star2_O2/Carton32[P]quectel-CM/MPQMUX.c
// Function: dump_tlv
void dump_tlv(PQCQMUX_MSG_HDR pQMUXMsgHdr) {
    int TLVFind = 0;
    int i;
    //dbg("QCQMUX_TLV-----------------------------------\n");
    //dbg("{Type,\tLength,\tValue}\n");

    while (1) {
        PQMI_TLV_HDR TLVHdr = GetTLV(pQMUXMsgHdr, 0x1000 + (++TLVFind));
        if (TLVHdr == NULL)
            break;

        //if ((TLVHdr->TLVType == 0x02) && ((USHORT *)(TLVHdr+1))[0])
        {        
            dbg("{%02x,\t%04x,\t", TLVHdr->TLVType, le16_to_cpu(TLVHdr->TLVLength));
            for (i = 0; i < le16_to_cpu(TLVHdr->TLVLength); i++) {
                dbg("%02x ", ((UCHAR *)(TLVHdr+1))[i]);
            }
            dbg("}\n");
        }
    }  // while
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rdi, 0x10(%rsp)
leaq 0x200fa(%rip), %r14     # 0x297c0
leaq 0x137d5(%rip), %r12     # 0x1cea2
xorl %ebx, %ebx
leal 0x1001(%rbx), %esi
movq 0x10(%rsp), %rdi
callq 0x9e14
testq %rax, %rax
je 0x97b0
movq %rax, %rbp
movq %r14, %rdi
callq 0x5160
cmpq $0x3ff, %rax            # imm = 0x3FF
ja 0x9739
leaq (%r14,%rax), %r15
movl $0x400, %r13d           # imm = 0x400
subq %rax, %r13
movq %rbx, 0x8(%rsp)
movzbl (%rbp), %ebx
movzwl 0x1(%rbp), %edi
callq 0xe73e
movzwl %ax, %r8d
movq %r15, %rdi
movq %r13, %rsi
leaq 0x13769(%rip), %rdx     # 0x1ce94
movl %ebx, %ecx
movq 0x8(%rsp), %rbx
xorl %eax, %eax
callq 0x51c0
incl %ebx
movq %rbx, %r13
xorl %ebx, %ebx
movzwl 0x1(%rbp), %edi
callq 0xe73e
movzwl %ax, %r15d
movq %r14, %rdi
callq 0x5160
cmpq %r15, %rbx
jae 0x9782
cmpq $0x3ff, %rax            # imm = 0x3FF
ja 0x977d
leaq (%r14,%rax), %rdi
movl $0x400, %esi            # imm = 0x400
subq %rax, %rsi
movzbl 0x3(%rbp,%rbx), %ecx
movq %r12, %rdx
xorl %eax, %eax
callq 0x51c0
incq %rbx
jmp 0x9740
cmpq $0x3ff, %rax            # imm = 0x3FF
movq %r13, %rbx
ja 0x96cf
leaq (%r14,%rax), %rdi
movl $0x400, %esi            # imm = 0x400
subq %rax, %rsi
leaq 0x13704(%rip), %rdx     # 0x1cea8
xorl %eax, %eax
callq 0x51c0
jmp 0x96cf
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/Carton32[P]quectel-CM/MPQMUX.c
// Function: dump_ctl
void dump_ctl(PQCQMICTL_MSG_HDR CTLHdr) {
    const char *tag;
    
    //dbg("QCQMICTL_MSG--------------------------------------------\n");
    //dbg("CtlFlags:           %02x\t\t%s\n", CTLHdr->CtlFlags, QMI_NAME(qmi_ctl_CtlFlags, CTLHdr->CtlFlags));
   dbg("TransactionId:      %02x\n", CTLHdr->TransactionId);
        switch (CTLHdr->CtlFlags) {
            case QMICTL_FLAG_REQUEST: tag = "_REQ"; break;
            case QMICTL_FLAG_RESPONSE: tag = "_RESP"; break;
            case QMICTL_FLAG_INDICATION: tag = "_IND"; break;
            default: tag = 0; break;
       }
        dbg("QMICTLType:         %04x\t%s\n", le16_to_cpu(CTLHdr->QMICTLType),
        QMUX_NAME(qmux_ctl_QMICTLType, le16_to_cpu(CTLHdr->QMICTLType), tag));     
        dbg("Length:             %04x\n", le16_to_cpu(CTLHdr->Length));

     dump_tlv((PQCQMUX_MSG_HDR)(&CTLHdr->QMICTLType));
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movq %rdi, %rbx
leaq 0x1ffef(%rip), %r14     # 0x297c0
movq %r14, %rdi
callq 0x5160
cmpq $0x3ff, %rax            # imm = 0x3FF
ja 0x9801
addq %rax, %r14
movl $0x400, %esi            # imm = 0x400
subq %rax, %rsi
movzbl 0x1(%rbx), %ecx
leaq 0x136b4(%rip), %rdx     # 0x1ceab
movq %r14, %rdi
xorl %eax, %eax
callq 0x51c0
movzbl (%rbx), %eax
cmpq $0x2, %rax
ja 0x981a
leaq 0x13677(%rip), %rcx     # 0x1ce88
movslq (%rcx,%rax,4), %r14
addq %rcx, %r14
jmp 0x981d
xorl %r14d, %r14d
leaq 0x1ff9c(%rip), %r15     # 0x297c0
movq %r15, %rdi
callq 0x5160
cmpq $0x3ff, %rax            # imm = 0x3FF
ja 0x9883
addq %rax, %r15
movl $0x400, %r12d           # imm = 0x400
subq %rax, %r12
movzwl 0x2(%rbx), %edi
callq 0xe73e
movzwl %ax, %ebp
movzwl 0x2(%rbx), %edi
callq 0xe73e
movzwl %ax, %edx
leaq 0x1dd01(%rip), %rdi     # 0x27560
pushq $0xf
popq %rsi
movq %r14, %rcx
callq 0x98da
leaq 0x13654(%rip), %rdx     # 0x1cec5
movq %r15, %rdi
movq %r12, %rsi
movl %ebp, %ecx
movq %rax, %r8
xorl %eax, %eax
callq 0x51c0
leaq 0x1ff36(%rip), %r14     # 0x297c0
movq %r14, %rdi
callq 0x5160
cmpq $0x3ff, %rax            # imm = 0x3FF
ja 0x98c6
addq %rax, %r14
movl $0x400, %r15d           # imm = 0x400
subq %rax, %r15
movzwl 0x4(%rbx), %edi
callq 0xe73e
movzwl %ax, %ecx
leaq 0x13629(%rip), %rdx     # 0x1cee2
movq %r14, %rdi
movq %r15, %rsi
xorl %eax, %eax
callq 0x51c0
addq $0x2, %rbx
movq %rbx, %rdi
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
jmp 0x96ac
// File: /workspace/github_c_makefile_star2_O2/Carton32[P]quectel-CM/MPQMUX.c
// Function: qmi_name_get
static const char * qmi_name_get(const QMI_NAME_T *table, size_t size, int type, const char *tag) {
    static char unknow[40];
    size_t i;

    if (qmux_CtlFlags == table) {
        if (!strcmp(tag, "_REQ"))
            tag = "_CMD";
        else  if (!strcmp(tag, "_RESP"))
            tag = "_RSP";
    }
    
    for (i = 0; i < size; i++) {
        if (table[i].type == (UINT)type) {
            if (!tag || (strstr(table[i].name, tag)))
                return table[i].name;
        }
    }
    sprintf(unknow, "unknow_%x", type);
    return unknow;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
movq %rcx, %r14
movl %edx, %ebx
movq %rsi, %r15
movq %rdi, %r12
leaq 0x1e93b(%rip), %rax     # 0x28230
cmpq %rax, %rdi
jne 0x9932
leaq 0x13bfd(%rip), %rsi     # 0x1d4fe
movq %r14, %rdi
callq 0x52a0
testl %eax, %eax
je 0x992b
leaq 0x13c08(%rip), %rsi     # 0x1d51c
movq %r14, %rdi
callq 0x52a0
testl %eax, %eax
leaq 0x1365d(%rip), %rax     # 0x1cf82
cmoveq %rax, %r14
jmp 0x9932
leaq 0x13639(%rip), %r14     # 0x1cf6b
addq $0x8, %r12
subq $0x1, %r15
jb 0x9962
cmpl %ebx, -0x8(%r12)
jne 0x995c
movq (%r12), %r13
testq %r14, %r14
je 0x997c
movq %r13, %rdi
movq %r14, %rsi
callq 0x5560
testq %rax, %rax
jne 0x997c
addq $0x10, %r12
jmp 0x9936
leaq 0x20287(%rip), %r13     # 0x29bf0
leaq 0x135df(%rip), %rsi     # 0x1cf4f
movq %r13, %rdi
movl %ebx, %edx
xorl %eax, %eax
callq 0x54f0
movq %r13, %rax
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O2/Carton32[P]quectel-CM/MPQMUX.c
// Function: dump_qmi
void dump_qmi(void *dataBuffer, int dataLen) 
{
    PQCQMI_HDR QMIHdr = (PQCQMI_HDR)dataBuffer;
    PQCQMUX_HDR QMUXHdr = (PQCQMUX_HDR) (QMIHdr + 1);
    PQCQMICTL_MSG_HDR CTLHdr =  (PQCQMICTL_MSG_HDR) (QMIHdr + 1);

    int i;

    if (!debug_qmi)
        return;

    pthread_mutex_lock(&dumpQMIMutex);
    line[0] = 0;
    for (i = 0; i < dataLen; i++) {
        dbg("%02x ", ((unsigned char *)dataBuffer)[i]);
    }
    dbg_time("%s", line);
    line[0] = 0;
    
    //dbg("QCQMI_HDR-----------------------------------------");
    //dbg("IFType:             %02x\t\t%s", QMIHdr->IFType, QMI_NAME(qmi_IFType, QMIHdr->IFType));
    //dbg("Length:             %04x", le16_to_cpu(QMIHdr->Length));
    //dbg("CtlFlags:           %02x\t\t%s", QMIHdr->CtlFlags, QMI_NAME(qmi_CtlFlags, QMIHdr->CtlFlags));
    //dbg("QMIType:            %02x\t\t%s", QMIHdr->QMIType, QMI_NAME(qmi_QMIType, QMIHdr->QMIType));
    //dbg("ClientId:           %02x", QMIHdr->ClientId);

    if (QMIHdr->QMIType == QMUX_TYPE_CTL) {
        dump_ctl(CTLHdr);
    } else {
        dump_qmux(QMIHdr->QMIType, QMUXHdr);
    }
    dbg_time("%s", line);
    pthread_mutex_unlock(&dumpQMIMutex);
}

// Assembly:
leaq 0x1f721(%rip), %rax     # 0x293d0
cmpl $0x0, (%rax)
je 0x9da3
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl %esi, %r15d
movq %rdi, %r14
leaq 0x6(%rdi), %rbx
leaq 0x1feec(%rip), %rdi     # 0x29bc0
callq 0x5570
xorl %eax, %eax
testl %r15d, %r15d
cmovlel %eax, %r15d
movb $0x0, 0x1fad7(%rip)     # 0x297c0
leaq 0x1fad0(%rip), %r12     # 0x297c0
leaq 0x131ab(%rip), %r13     # 0x1cea2
xorl %ebp, %ebp
cmpq %rbp, %r15
je 0x9d2e
movq %r12, %rdi
callq 0x5160
cmpq $0x3ff, %rax            # imm = 0x3FF
ja 0x9d29
leaq (%r12,%rax), %rdi
movl $0x400, %esi            # imm = 0x400
subq %rax, %rsi
movzbl (%r14,%rbp), %ecx
movq %r13, %rdx
xorl %eax, %eax
callq 0x51c0
incq %rbp
jmp 0x9cf9
movq 0x1f283(%rip), %r12     # 0x28fb8
movq (%r12), %r15
callq 0xe343
leaq 0x13201(%rip), %rsi     # 0x1cf46
leaq 0x1fa74(%rip), %rcx     # 0x297c0
movq %r15, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0x52c0
leaq 0x1ff48(%rip), %r13     # 0x29ca8
movq (%r13), %r15
testq %r15, %r15
je 0x9d89
callq 0xe343
leaq 0x131d1(%rip), %rsi     # 0x1cf46
leaq 0x1fa44(%rip), %rcx     # 0x297c0
movq %r15, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0x52c0
movb $0x0, 0x1fa30(%rip)     # 0x297c0
movzbl 0x4(%r14), %edi
testl %edi, %edi
je 0x9da4
movq %rbx, %rsi
callq 0x9989
jmp 0x9dac
retq
movq %rbx, %rdi
callq 0x97bf
movq (%r12), %rbx
callq 0xe343
leaq 0x1318a(%rip), %rsi     # 0x1cf46
leaq 0x1f9fd(%rip), %rcx     # 0x297c0
movq %rbx, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0x52c0
movq (%r13), %rbx
testq %rbx, %rbx
je 0x9df9
callq 0xe343
leaq 0x13161(%rip), %rsi     # 0x1cf46
leaq 0x1f9d4(%rip), %rcx     # 0x297c0
movq %rbx, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0x52c0
leaq 0x1fdc0(%rip), %rdi     # 0x29bc0
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x5340
nop
// File: /workspace/github_c_makefile_star2_O2/Carton32[P]quectel-CM/QMIThread.c
// Function: GetTLV
PQMI_TLV_HDR GetTLV (PQCQMUX_MSG_HDR pQMUXMsgHdr, int TLVType) {
    int TLVFind = 0;
    USHORT Length = le16_to_cpu(pQMUXMsgHdr->Length);
    PQMI_TLV_HDR pTLVHdr = (PQMI_TLV_HDR)(pQMUXMsgHdr + 1);

    while (Length >= sizeof(QMI_TLV_HDR)) {
        TLVFind++;
        if (TLVType > 0x1000) {
            if ((TLVFind + 0x1000) == TLVType)
                return pTLVHdr;
        } else  if (pTLVHdr->TLVType == TLVType) {
            return pTLVHdr;
        }

        Length -= (le16_to_cpu((pTLVHdr->TLVLength)) + sizeof(QMI_TLV_HDR));
        pTLVHdr = (PQMI_TLV_HDR)(((UCHAR *)pTLVHdr) + le16_to_cpu(pTLVHdr->TLVLength) + sizeof(QMI_TLV_HDR));
    }

   return NULL;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movl %esi, %ebp
movq %rdi, %rbx
movzwl 0x2(%rdi), %edi
callq 0xe73e
movl %eax, %r14d
addq $0x4, %rbx
movl $0x1001, %r15d          # imm = 0x1001
cmpw $0x3, %r14w
jb 0x9e7b
cmpl $0x1001, %ebp           # imm = 0x1001
jl 0x9e4c
cmpl %r15d, %ebp
jne 0x9e53
jmp 0x9e7d
movzbl (%rbx), %eax
cmpl %ebp, %eax
je 0x9e7d
movzwl 0x1(%rbx), %edi
callq 0xe73e
subl %eax, %r14d
addl $-0x3, %r14d
movzwl 0x1(%rbx), %edi
callq 0xe73e
movzwl %ax, %eax
addq %rax, %rbx
addq $0x3, %rbx
incl %r15d
jmp 0x9e36
xorl %ebx, %ebx
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/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 0x9efd
movq %rcx, %rbx
movl %edx, %r15d
movq %rsi, %r14
movq %rdi, %r12
leaq 0x1fda5(%rip), %rdi     # 0x29c50
callq 0x5570
testq %r14, %r14
je 0x9eb9
andq $0x0, (%r14)
movzwl 0x1(%r12), %edi
callq 0xe73e
movzwl %ax, %esi
incl %esi
movq %r12, %rdi
callq 0x9ca8
movq %r12, 0x1fd40(%rip)     # 0x29c18
andq $0x0, 0x1fd40(%rip)     # 0x29c20
movq %r12, %rdi
callq *0x1fd3f(%rip)          # 0x29c28
movl %eax, %ebp
testl %eax, %eax
je 0x9f0b
leaq 0x1fd5a(%rip), %rdi     # 0x29c50
callq 0x5340
jmp 0x9f00
pushq $-0x16
popq %rbp
movl %ebp, %eax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
leaq 0x1fd66(%rip), %rdi     # 0x29c78
leaq 0x1fd37(%rip), %rsi     # 0x29c50
movl %r15d, %edx
callq 0xe5ba
testl %eax, %eax
je 0x9f7d
movl %eax, %ebp
movq 0x1f08a(%rip), %rax     # 0x28fb8
movq (%rax), %r14
callq 0xe343
leaq 0x147f3(%rip), %rsi     # 0x1e730
movq %r14, %rdi
movq %rax, %rdx
movq %rbx, %rcx
xorl %eax, %eax
callq 0x52c0
leaq 0x1fd54(%rip), %rax     # 0x29ca8
movq (%rax), %r14
testq %r14, %r14
je 0x9eef
callq 0xe343
leaq 0x147c8(%rip), %rsi     # 0x1e730
movq %r14, %rdi
movq %rax, %rdx
movq %rbx, %rcx
xorl %eax, %eax
callq 0x52c0
jmp 0x9eef
testq %r14, %r14
sete %al
movq 0x1fc96(%rip), %rdi     # 0x29c20
testq %rdi, %rdi
sete %cl
orb %al, %cl
jne 0x9f9e
movq %rdi, (%r14)
xorl %ebp, %ebp
jmp 0x9eef
xorl %ebp, %ebp
testq %rdi, %rdi
je 0x9eef
callq 0x5040
andq $0x0, 0x1fc6a(%rip)     # 0x29c20
jmp 0x9eef
// File: /workspace/github_c_makefile_star2_O2/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, 0x1e15f(%rip)     # 0x292f8
je 0xb1a9
leaq 0x2746(%rip), %rdx      # 0xd8e8
pushq $0xb
popq %rdi
pushq $0x26
jmp 0xb1b5
leaq 0x27a8(%rip), %rdx      # 0xd958
pushq $0x2
popq %rdi
pushq $0x28
popq %rsi
callq 0xd53c
leaq 0x137dd(%rip), %rcx     # 0x1e99f
movq %rsp, %r14
movq %rax, %rdi
movq %r14, %rsi
movl $0x7530, %edx           # imm = 0x7530
callq 0x9e8b
movl %eax, %ebx
testl %eax, %eax
sets %al
movq (%r14), %r12
testq %r12, %r12
sete %cl
orb %al, %cl
cmpb $0x1, %cl
jne 0xb254
movq 0x1ddc5(%rip), %rax     # 0x28fb8
movq (%rax), %r14
callq 0xe343
leaq 0x1357f(%rip), %rsi     # 0x1e781
leaq 0x13796(%rip), %rcx     # 0x1e99f
movq %r14, %rdi
movq %rax, %rdx
movl %ebx, %r8d
xorl %eax, %eax
callq 0x52c0
leaq 0x1ea88(%rip), %rax     # 0x29ca8
movq (%rax), %r14
testq %r14, %r14
je 0xb314
callq 0xe343
leaq 0x13549(%rip), %rsi     # 0x1e781
leaq 0x13760(%rip), %rcx     # 0x1e99f
movq %r14, %rdi
movq %rax, %rdx
movl %ebx, %r8d
xorl %eax, %eax
callq 0x52c0
jmp 0xb314
movzwl 0x10(%r12), %edi
callq 0xe73e
testw %ax, %ax
jne 0xb278
movzwl 0x12(%r12), %edi
callq 0xe73e
testw %ax, %ax
je 0xb322
movzwl 0x12(%r12), %edi
callq 0xe73e
movl %eax, %ebx
movq 0x1dd2c(%rip), %rax     # 0x28fb8
movq (%rax), %r14
callq 0xe343
movq %rax, %r15
movzwl 0x10(%r12), %edi
callq 0xe73e
movzwl %ax, %r8d
movzwl %bx, %ebx
leaq 0x134e3(%rip), %rsi     # 0x1e793
leaq 0x136e8(%rip), %rcx     # 0x1e99f
movq %r14, %rdi
movq %r15, %rdx
movl %ebx, %r9d
xorl %eax, %eax
callq 0x52c0
leaq 0x1e9da(%rip), %rax     # 0x29ca8
movq (%rax), %r14
testq %r14, %r14
je 0xb30b
callq 0xe343
movq %rax, %r15
movzwl 0x10(%r12), %edi
callq 0xe73e
movzwl %ax, %r8d
leaq 0x1349f(%rip), %rsi     # 0x1e793
leaq 0x136a4(%rip), %rcx     # 0x1e99f
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 0xb314
// File: /workspace/github_c_makefile_star2_O2/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 0x1c6ba(%rip), %eax     # 0x29c30
leal 0x1(%rax), %ecx
movl $0xffff, %edx           # imm = 0xFFFF
cmpl %edx, %eax
pushq $0x1
popq %rdi
cmovll %ecx, %edi
movl %edi, 0x1c6a4(%rip)     # 0x29c30
andl %edx, %edi
callq 0xe749
movw %ax, 0x7(%r15)
movl %ebp, %edi
callq 0xe749
movw %ax, 0x9(%r15)
testq %rbx, %rbx
je 0xd5bb
leaq 0x6(%rsp), %rdi
movq %r14, %rsi
callq *%rbx
addl $-0x4, %eax
movzwl %ax, %edi
jmp 0xd5bd
xorl %edi, %edi
callq 0xe749
movw %ax, 0xb(%rsp)
movzwl %ax, %edi
callq 0xe73e
addl $0xc, %eax
movzwl %ax, %edi
callq 0xe749
movw %ax, 0x1(%rsp)
movzwl %ax, %edi
callq 0xe73e
movzwl %ax, %r14d
incq %r14
movq %r14, %rdi
callq 0x5360
movq %rax, %rbx
testq %rax, %rax
je 0xd60e
movq %rsp, %rsi
movq %rbx, %rdi
movq %r14, %rdx
callq 0x52f0
jmp 0xd667
movq 0x1b9a3(%rip), %rax     # 0x28fb8
movq (%rax), %r14
callq 0xe343
leaq 0xea2a(%rip), %rsi      # 0x1c04e
leaq 0x111a1(%rip), %rcx     # 0x1e7cc
movq %r14, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0x52c0
leaq 0x1c669(%rip), %rax     # 0x29ca8
movq (%rax), %r14
testq %r14, %r14
je 0xd667
callq 0xe343
leaq 0xe9fb(%rip), %rsi      # 0x1c04e
leaq 0x11172(%rip), %rcx     # 0x1e7cc
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_O2/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 %rbp
pushq %r14
pushq %rbx
movq %rsi, %r14
movq %rdi, %rbx
movb $0x10, 0x7(%rdi)
pushq $0x8
popq %rdi
callq 0xe749
movw %ax, 0x8(%rbx)
movl 0x8(%r14), %edi
callq 0xe74c
movl %eax, 0xa(%rbx)
movl 0xc(%r14), %edi
callq 0xe74c
movl %eax, 0xe(%rbx)
movb $0x11, 0x12(%rbx)
pushq $0x1
popq %rbp
movl %ebp, %edi
callq 0xe749
movw %ax, 0x13(%rbx)
movb 0x10(%r14), %al
movb %al, 0x15(%rbx)
movb $0x13, 0x16(%rbx)
pushq $0x4
popq %rdi
callq 0xe749
movw %ax, 0x17(%rbx)
movl %ebp, %edi
callq 0xe74c
movl %eax, 0x19(%rbx)
movw $0x1a, %ax
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/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)
pushq $0x1
popq %rdi
callq 0xe749
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_O2/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)
pushq $0x1
popq %rdi
callq 0xe749
movw %ax, 0x8(%rbx)
movb $0x10, 0xb(%rbx)
pushq $0x4
popq %rdi
callq 0xe749
movw %ax, 0xc(%rbx)
movw $0xf, %ax
popq %rbx
retq
// File: /workspace/github_c_makefile_star2_O2/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)
pushq $0x2
popq %rdi
callq 0xe749
movw %ax, 0x8(%r14)
andw $0x0, 0xa(%r14)
movb $0x2, 0xc(%r14)
movq %rbx, %rdi
callq 0x5160
addl $0x2, %eax
movzwl %ax, %edi
callq 0xe749
movw %ax, 0xd(%r14)
movb %bpl, 0xf(%r14)
movq %rbx, %rdi
callq 0x5160
movb %al, 0x10(%r14)
addq $0x11, %r14
movq %r14, %rdi
movq %rbx, %rsi
callq 0xd9ad
movq %rbx, %rdi
callq 0x5160
addl $0xe, %eax
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/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)
leaq 0xc(%r14), %rdi
movq %rbx, %rsi
callq 0xd9ad
movq %rbx, %rdi
callq 0x5160
addl $0x2, %eax
movzwl %ax, %edi
callq 0xe749
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_O2/Carton32[P]quectel-CM/QMIThread.c
// Function: WdsGetProfileSettingsReqSend
static USHORT WdsGetProfileSettingsReqSend(PQMUX_MSG pMUXMsg, void *arg) {
    PROFILE_T *profile = (PROFILE_T *)arg;
    pMUXMsg->GetProfileSettingsReq.Length = cpu_to_le16(sizeof(QMIWDS_GET_PROFILE_SETTINGS_REQ_MSG) - 4);
    pMUXMsg->GetProfileSettingsReq.TLVType = 0x01;
    pMUXMsg->GetProfileSettingsReq.TLVLength = cpu_to_le16(0x02);
    pMUXMsg->GetProfileSettingsReq.ProfileType = 0x00; // 0 ~ 3GPP, 1 ~ 3GPP2
    pMUXMsg->GetProfileSettingsReq.ProfileIndex = profile->pdp;
    return sizeof(QMIWDS_GET_PROFILE_SETTINGS_REQ_MSG);
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rsi, %rbx
movq %rdi, %r14
pushq $0x5
popq %rdi
callq 0xe749
movw %ax, 0x5(%r14)
movb $0x1, 0x7(%r14)
pushq $0x2
popq %rdi
callq 0xe749
movw %ax, 0x8(%r14)
movb $0x0, 0xa(%r14)
movb 0x48(%rbx), %al
movb %al, 0xb(%r14)
movw $0x9, %ax
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O2/Carton32[P]quectel-CM/QMIThread.c
// Function: WdsCreateProfileSettingsReqSend
static USHORT WdsCreateProfileSettingsReqSend(PQMUX_MSG pMUXMsg, void *arg) {
    PROFILE_T *profile = (PROFILE_T *)arg;
    pMUXMsg->CreatetProfileSettingsReq.Length = cpu_to_le16(sizeof(QMIWDS_CREATE_PROFILE_SETTINGS_REQ_MSG) - 4);
    pMUXMsg->CreatetProfileSettingsReq.TLVType = 0x01;
    pMUXMsg->CreatetProfileSettingsReq.TLVLength = cpu_to_le16(0x01);
    pMUXMsg->CreatetProfileSettingsReq.ProfileType = 0x00; // 0 ~ 3GPP, 1 ~ 3GPP2
    pMUXMsg->CreatetProfileSettingsReq.TLV2Type = 0x25;
    pMUXMsg->CreatetProfileSettingsReq.TLV2Length = cpu_to_le16(0x01);
    pMUXMsg->CreatetProfileSettingsReq.pdp_context = profile->pdp; // 0 ~ 3GPP, 1 ~ 3GPP2
    return sizeof(QMIWDS_CREATE_PROFILE_SETTINGS_REQ_MSG);
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
movq %rsi, %rbx
movq %rdi, %r14
pushq $0x8
popq %rdi
callq 0xe749
movw %ax, 0x5(%r14)
movb $0x1, 0x7(%r14)
pushq $0x1
popq %rbp
movl %ebp, %edi
callq 0xe749
movw %ax, 0x8(%r14)
movw $0x2500, 0xa(%r14)      # imm = 0x2500
movl %ebp, %edi
callq 0xe749
movw %ax, 0xc(%r14)
movb 0x48(%rbx), %al
movb %al, 0xe(%r14)
movw $0xc, %ax
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/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, %dx
cmpl $0x3ff, %esi            # imm = 0x3FF
je 0xde3c
movzwl %si, %r8d
leal 0x6f(%r8), %esi
pushq $0xa
popq %r9
movl %esi, %eax
xorl %edx, %edx
divl %r9d
movl %edx, %ecx
addl $0x65, %r8d
testl %edx, %edx
cmovnel %esi, %r8d
movl %r8d, %eax
xorl %edx, %edx
divl %r9d
movl %eax, %r9d
movw $0xa, %r10w
xorl %edx, %edx
divw %r10w
movl %edx, %esi
testw %dx, %dx
je 0xde13
pushq $0x64
popq %r9
movl %r8d, %eax
xorl %edx, %edx
divl %r9d
jmp 0xde23
addl $-0xa, %r9d
movl %r9d, %eax
xorl %edx, %edx
divw %r10w
movzwl %ax, %eax
xorl %edx, %edx
cmpl $0xa, %eax
cmovel %edx, %eax
cmpl $0x9, %eax
ja 0xde3c
imull $0x64, %eax, %eax
imull $0xa, %esi, %edx
addl %edx, %ecx
addl %eax, %ecx
movl %ecx, %edx
movw %dx, (%rdi)
retq
// File: /workspace/github_c_makefile_star2_O2/Carton32[P]quectel-CM/QMIThread.c
// Function: quectel_convert_cdma_mnc_2_ascii_mnc
static void quectel_convert_cdma_mnc_2_ascii_mnc( USHORT *p_mnc, USHORT imsi_11_12)
{
  unsigned int d1, d2, buf = imsi_11_12 + 11;

  if ( imsi_11_12 == 0x7F ) // wildcard
  {
    *p_mnc = 7;
  }
  else
  {
    d2 = buf % 10;
    buf = ( d2 == 0 ) ? (buf-10)/10 : buf/10;

    d1 = ( buf == 10 ) ? 0 : buf;

    if ( d1<10 && d2<10 )
    {
     *p_mnc = d1*10 + d2;
    }
    else
    {
      //dbg_time( "invalid digits %d %d", d1, d2, 0 );
      *p_mnc = 0;
    }
  }
}

// Assembly:
movw $0x7, %r9w
cmpl $0x7f, %esi
je 0xde87
movzwl %si, %esi
leal 0xb(%rsi), %r8d
xorl %r9d, %r9d
pushq $0xa
popq %r10
movl %r8d, %eax
xorl %edx, %edx
divl %r10d
movl %edx, %ecx
incl %esi
testl %edx, %edx
cmovnel %r8d, %esi
movl %esi, %eax
xorl %edx, %edx
divl %r10d
addl $-0x64, %esi
cmpl $0xa, %esi
cmovbl %r9d, %eax
cmpl $0x9, %eax
ja 0xde87
imull $0xa, %eax, %r9d
addl %ecx, %r9d
movw %r9w, (%rdi)
retq
// File: /workspace/github_c_makefile_star2_O2/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), %al
movb %al, 0x6(%rsp)
movzwl (%rdi), %eax
movw %ax, 0x4(%rsp)
movb $0x0, 0x7(%rsp)
xorl %eax, %eax
xorl %ecx, %ecx
cmpq $0x4, %rcx
je 0xdebf
movzbl 0x4(%rsp,%rcx), %edx
cmpb $-0x1, %dl
cmovel %eax, %edx
movb %dl, 0x4(%rsp,%rcx)
incq %rcx
jmp 0xdea5
leaq 0x4(%rsp), %rdi
callq 0x54c0
popq %rcx
retq
// File: /workspace/github_c_makefile_star2_O2/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)
pushq $0x4
popq %rdi
callq 0xe749
movw %ax, 0x8(%r14)
cmpl $0x4, (%rbx)
leaq 0x1baf9(%rip), %rax     # 0x29c3c
leaq 0x1baf6(%rip), %rcx     # 0x29c40
cmoveq %rax, %rcx
movl (%rcx), %edi
callq 0xe74c
movl %eax, 0xa(%r14)
movw $0xb, %ax
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O2/Carton32[P]quectel-CM/QMIThread.c
// Function: WdsGetRuntimeSettingReq
static USHORT WdsGetRuntimeSettingReq(PQMUX_MSG pMUXMsg, void *arg)
{
    (void)arg;
    pMUXMsg->GetRuntimeSettingsReq.TLVType = 0x10;
    pMUXMsg->GetRuntimeSettingsReq.TLVLength = cpu_to_le16(0x04);
    // the following mask also applies to IPV6
    pMUXMsg->GetRuntimeSettingsReq.Mask = cpu_to_le32(QMIWDS_GET_RUNTIME_SETTINGS_MASK_IPV4DNS_ADDR |
                                                      QMIWDS_GET_RUNTIME_SETTINGS_MASK_IPV4_ADDR |
                                                      QMIWDS_GET_RUNTIME_SETTINGS_MASK_MTU |
                                                      QMIWDS_GET_RUNTIME_SETTINGS_MASK_IPV4GATEWAY_ADDR) |
                                          QMIWDS_GET_RUNTIME_SETTINGS_MASK_PCSCF_SV_ADDR |
                                          QMIWDS_GET_RUNTIME_SETTINGS_MASK_PCSCF_DOM_NAME;

    return sizeof(QMIWDS_GET_RUNTIME_SETTINGS_REQ_MSG);
}

// Assembly:
pushq %rbx
movq %rdi, %rbx
movb $0x10, 0x7(%rdi)
pushq $0x4
popq %rdi
callq 0xe749
movw %ax, 0x8(%rbx)
movl $0x2310, %edi           # imm = 0x2310
callq 0xe74c
orl $0x4800, %eax           # imm = 0x4800
movl %eax, 0xa(%rbx)
movw $0xb, %ax
popq %rbx
retq
// File: /workspace/github_c_makefile_star2_O2/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 0x5450
movl %eax, %ebx
cmpl $-0x1, %eax
je 0xe2b7
pushq $0x3
popq %rsi
movl %ebx, %edi
xorl %eax, %eax
callq 0x50e0
orl $0x800, %eax            # imm = 0x800
pushq $0x4
popq %rsi
movl %ebx, %edi
movl %eax, %edx
xorl %eax, %eax
callq 0x50e0
pushq $0x2
popq %rsi
pushq $0x1
popq %rdx
movl %ebx, %edi
xorl %eax, %eax
callq 0x50e0
leaq 0x10a90(%rip), %rsi     # 0x1ecd7
pushq $0x8
popq %rdx
movq %r14, %rdi
callq 0x5090
testl %eax, %eax
jne 0xe334
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 0x5430
movq %r14, %rdi
callq 0x53b0
movq %r14, %rdi
movl $0x1002, %esi           # imm = 0x1002
callq 0x5490
movq %r14, %rdi
movl $0x1002, %esi           # imm = 0x1002
callq 0x5150
movl %ebx, %edi
xorl %esi, %esi
movq %r14, %rdx
callq 0x5440
pushq $0x2
popq %rsi
movl %ebx, %edi
callq 0x5180
jmp 0xe334
movq 0x1acfa(%rip), %rax     # 0x28fb8
movq (%rax), %r12
callq 0xe343
callq 0x5070
movq %rax, %r15
movl (%rax), %ebp
movl %ebp, %edi
callq 0x5540
leaq 0x10a02(%rip), %rsi     # 0x1ece0
leaq 0x1b9cb(%rip), %rdx     # 0x29cb0
movq %r12, %rdi
movq %r14, %rcx
movl %ebp, %r8d
movq %rax, %r9
xorl %eax, %eax
callq 0x52c0
movq 0x1b9a9(%rip), %r12     # 0x29ca8
testq %r12, %r12
je 0xe334
callq 0xe343
movl (%r15), %ebp
movl %ebp, %edi
callq 0x5540
leaq 0x109c6(%rip), %rsi     # 0x1ece0
leaq 0x1b98f(%rip), %rdx     # 0x29cb0
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_O2/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 %rdi, %r15
testl %edx, %edx
je 0xe6f7
movl %edx, %r14d
movq %rsi, 0x20(%rsp)
movl %edx, %ecx
shrl $0x2, %ecx
cmpl $0x4, %edx
pushq $0x1
popq %rax
cmovael %ecx, %eax
movl $0x3e8, %ecx            # imm = 0x3E8
movl %eax, 0xc(%rsp)
xorl %edx, %edx
divl %ecx
movl %eax, %r13d
xorl %ebp, %ebp
imull $0x3e8, %edx, %ebx      # imm = 0x3E8
xorl %r12d, %r12d
cmpl %r14d, %ebp
jae 0xe6e5
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 %rbx, %rcx
imulq $0x3e8, %rcx, %rcx      # imm = 0x3E8
movq %rcx, 0x18(%rsp)
cmpq $0x3b9aca00, %rcx       # imm = 0x3B9ACA00
jb 0xe657
incq %rax
movq %rax, 0x10(%rsp)
addq $-0x3b9aca00, %rcx      # imm = 0xC4653600
movq %rcx, 0x18(%rsp)
movq %r15, %rdi
movq 0x20(%rsp), %rsi
leaq 0x10(%rsp), %rdx
callq 0x5420
cmpl $0x6e, %eax
jne 0xe678
addl 0xc(%rsp), %ebp
pushq $0x6e
popq %r12
jmp 0xe604
movl %eax, %r12d
testl %eax, %eax
je 0xe6e5
movq 0x1a932(%rip), %rax     # 0x28fb8
movq (%rax), %rbx
callq 0xe343
leaq 0x106b3(%rip), %rsi     # 0x1ed48
leaq 0x1b614(%rip), %rdx     # 0x29cb0
movq %rbx, %rdi
movl %r12d, %ecx
movl %r14d, %r8d
movl 0xc(%rsp), %r9d
xorl %eax, %eax
callq 0x52c0
movq 0x1b5f0(%rip), %rbx     # 0x29ca8
testq %rbx, %rbx
je 0xe6e5
callq 0xe343
leaq 0x1067f(%rip), %rsi     # 0x1ed48
leaq 0x1b5e0(%rip), %rdx     # 0x29cb0
movq %rbx, %rdi
movl %r12d, %ecx
movl %r14d, %r8d
movl 0xc(%rsp), %r9d
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 %r15, %rdi
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x5120
// File: /workspace/github_c_makefile_star2_O2/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
pushq $0x2
popq %rdi
movl %edi, %esi
xorl %edx, %edx
callq 0x55b0
testl %eax, %eax
jle 0xf005
movl %eax, %ebx
xorps %xmm0, %xmm0
leaq 0x8(%rsp), %r12
movups %xmm0, 0x18(%r12)
addq $0xaa, %r15
pushq $0x10
popq %rdx
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 0xeff1
movl %eax, %ebp
movq 0x1a03d(%rip), %rax     # 0x28fb8
movq (%rax), %r15
callq 0xe343
callq 0x5070
movq %rax, %r14
movl (%rax), %edi
callq 0x5540
leaq 0xfef5(%rip), %rsi      # 0x1ee8e
leaq 0x1ad10(%rip), %rdx     # 0x29cb0
movq %r15, %rdi
movl $0x89f2, %ecx           # imm = 0x89F2
movq %rax, %r8
movl %ebp, %r9d
xorl %eax, %eax
callq 0x52c0
movq 0x1acec(%rip), %r15     # 0x29ca8
testq %r15, %r15
je 0xeff1
callq 0xe343
movl (%r14), %edi
callq 0x5540
leaq 0xfeb9(%rip), %rsi      # 0x1ee8e
leaq 0x1acd4(%rip), %rdx     # 0x29cb0
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 0x19fac(%rip), %rax     # 0x28fb8
movq (%rax), %r14
callq 0xe343
callq 0x5070
movq %rax, %rbx
movl (%rax), %edi
callq 0x5540
leaq 0xfe13(%rip), %rsi      # 0x1ee3d
leaq 0x1ac7f(%rip), %rdx     # 0x29cb0
movq %r14, %rdi
movq %rax, %rcx
xorl %eax, %eax
callq 0x52c0
movq 0x1ac63(%rip), %r14     # 0x29ca8
testq %r14, %r14
je 0xeff8
callq 0xe343
movl (%rbx), %edi
callq 0x5540
leaq 0xfde0(%rip), %rsi      # 0x1ee3d
leaq 0x1ac4c(%rip), %rdx     # 0x29cb0
movq %r14, %rdi
movq %rax, %rcx
xorl %eax, %eax
addq $0x30, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
jmp 0x52c0
nopl (%rax)
// File: /workspace/github_c_makefile_star2_O2/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 0x10e18(%rip), %rsi     # 0x2019b
callq 0x5480
movq %rax, %r14
xorl %r12d, %r12d
movq %r13, %rdi
xorl %esi, %esi
movq %rbx, %rdx
callq 0x5200
testq %r14, %r14
je 0xf462
pushq $0x1
popq %rsi
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 0xf45a
movq 0x19be5(%rip), %rax     # 0x28fb8
movq (%rax), %rax
movq %rax, 0x10(%rsp)
callq 0xe343
movq %rax, %rbp
callq 0x5070
movq %rax, %r13
movl (%rax), %edi
callq 0x5540
movq %rax, (%rsp)
leaq 0xfc32(%rip), %rsi      # 0x1f02f
movq 0x10(%rsp), %rdi
movq %rbp, %rdx
movq %r15, %rcx
movq %r12, %r8
movq %rbx, %r9
xorl %eax, %eax
callq 0x52c0
leaq 0x1a88c(%rip), %rax     # 0x29ca8
movq (%rax), %rbp
testq %rbp, %rbp
je 0xf45a
callq 0xe343
movq %rax, 0x10(%rsp)
movl (%r13), %edi
callq 0x5540
movq %rax, (%rsp)
leaq 0xfbed(%rip), %rsi      # 0x1f02f
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_O2/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 0x101cb(%rip), %rsi     # 0x1f65d
callq 0x5480
testq %rax, %rax
je 0xf564
movq %rax, %r14
pushq $0x1
popq %rsi
movq %r12, %rdi
movq %rbx, %rdx
movq %rax, %rcx
callq 0x5510
cmpq %rbx, %rax
je 0xf54e
movq %rax, %r12
movq 0x19af1(%rip), %rax     # 0x28fb8
movq (%rax), %rax
movq %rax, 0x10(%rsp)
callq 0xe343
movq %rax, %rbp
callq 0x5070
movq %rax, %r13
movl (%rax), %edi
callq 0x5540
movq %rax, (%rsp)
leaq 0xfb7f(%rip), %rsi      # 0x1f070
movq 0x10(%rsp), %rdi
movq %rbp, %rdx
movq %r15, %rcx
movq %r12, %r8
movq %rbx, %r9
xorl %eax, %eax
callq 0x52c0
leaq 0x1a798(%rip), %rax     # 0x29ca8
movq (%rax), %rbp
testq %rbp, %rbp
je 0xf54e
callq 0xe343
movq %rax, 0x10(%rsp)
movl (%r13), %edi
callq 0x5540
movq %rax, (%rsp)
leaq 0xfb3a(%rip), %rsi      # 0x1f070
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_O2/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 0xd3e5(%rip), %rsi      # 0x1cb5a
pushq $0xa
popq %rdx
callq 0x5090
leaq 0x17d9c(%rip), %rcx     # 0x27520
leaq 0x17db5(%rip), %rdx     # 0x27540
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 0x1a47a(%rip), %rcx     # 0x29c28
movq %rax, (%rcx)
xorl %eax, %eax
popq %rbx
retq
// File: /workspace/github_c_makefile_star2_O2/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 %r15
pushq %r14
pushq %rbx
subq $0x110, %rsp            # imm = 0x110
movq %rdi, %rbx
xorl %eax, %eax
cmpl $0x0, 0x10a(%rdi)
setne %al
shll $0x5, %eax
leaq (%rax,%rdi), %rcx
addq $0xaa, %rcx
leaq 0xf6e3(%rip), %rdx      # 0x1eec8
leaq 0x10(%rsp), %r14
movl $0x100, %esi            # imm = 0x100
movq %r14, %rdi
xorl %eax, %eax
callq 0x51c0
movl 0x4c(%rbx), %ecx
leaq 0xf826(%rip), %rdx      # 0x1f029
movq %rsp, %rbx
pushq $0x10
popq %r15
movq %rbx, %rdi
movq %r15, %rsi
xorl %eax, %eax
callq 0x51c0
movq %r14, %rdi
movq %rbx, %rsi
movq %r15, %rdx
callq 0xf474
addq $0x110, %rsp            # imm = 0x110
popq %rbx
popq %r14
popq %r15
retq