// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x140, %rsp            # imm = 0x140
movw %si, %ax
movb %dil, %sil
movb %sil, -0x1(%rbp)
movw %ax, -0x4(%rbp)
movq %rdx, -0x10(%rbp)
movq %rcx, -0x18(%rbp)
leaq -0x120(%rbp), %rax
movq %rax, -0x128(%rbp)
leaq -0x120(%rbp), %rdi
xorl %esi, %esi
movl $0x100, %edx            # imm = 0x100
callq 0x5200
movq -0x128(%rbp), %rax
movb $0x1, (%rax)
movq -0x128(%rbp), %rax
movb $0x0, 0x3(%rax)
movb -0x1(%rbp), %cl
movq -0x128(%rbp), %rax
movb %cl, 0x4(%rax)
movq -0x128(%rbp), %rax
movb $0x0, 0x6(%rax)
callq 0x113f0
movzwl %ax, %edi
callq 0x13ff0
movw %ax, %cx
movq -0x128(%rbp), %rax
movw %cx, 0x7(%rax)
movzwl -0x4(%rbp), %edi
callq 0x13ff0
movw %ax, %cx
movq -0x128(%rbp), %rax
movw %cx, 0x9(%rax)
cmpq $0x0, -0x10(%rbp)
je 0x1124c
movq -0x10(%rbp), %rax
movq -0x128(%rbp), %rdi
addq $0x6, %rdi
movq -0x18(%rbp), %rsi
callq *%rax
movzwl %ax, %eax
subq $0x4, %rax
movzwl %ax, %edi
callq 0x13ff0
movw %ax, %cx
movq -0x128(%rbp), %rax
movw %cx, 0xb(%rax)
jmp 0x11261
xorl %edi, %edi
callq 0x13ff0
movw %ax, %cx
movq -0x128(%rbp), %rax
movw %cx, 0xb(%rax)
movq -0x128(%rbp), %rax
movzwl 0xb(%rax), %edi
callq 0x13ed0
movzwl %ax, %eax
addq $0x4, %rax
addq $0x3, %rax
addq $0x6, %rax
subq $0x1, %rax
movzwl %ax, %edi
callq 0x13ff0
movw %ax, %cx
movq -0x128(%rbp), %rax
movw %cx, 0x1(%rax)
movq -0x128(%rbp), %rax
movzwl 0x1(%rax), %edi
callq 0x13ed0
movzwl %ax, %eax
addl $0x1, %eax
movl %eax, -0x12c(%rbp)
movslq -0x12c(%rbp), %rdi
callq 0x5370
movq %rax, -0x128(%rbp)
cmpq $0x0, -0x128(%rbp)
jne 0x11350
jmp 0x112d5
movq 0x25d04(%rip), %rax     # 0x36fe0
movq (%rax), %rax
movq %rax, -0x138(%rbp)
callq 0x13930
movq -0x138(%rbp), %rdi
movq %rax, %rdx
leaq 0x19d8e(%rip), %rsi     # 0x2b08a
leaq 0x1c6a9(%rip), %rcx     # 0x2d9ac
movb $0x0, %al
callq 0x52c0
leaq 0x26b57(%rip), %rax     # 0x37e68
cmpq $0x0, (%rax)
je 0x1134c
leaq 0x26b4a(%rip), %rax     # 0x37e68
movq (%rax), %rax
movq %rax, -0x140(%rbp)
callq 0x13930
movq -0x140(%rbp), %rdi
movq %rax, %rdx
leaq 0x19d4c(%rip), %rsi     # 0x2b08a
leaq 0x1c667(%rip), %rcx     # 0x2d9ac
movb $0x0, %al
callq 0x52c0
jmp 0x1134e
jmp 0x1136a
movq -0x128(%rbp), %rdi
leaq -0x120(%rbp), %rsi
movslq -0x12c(%rbp), %rdx
callq 0x52f0
movq -0x128(%rbp), %rax
addq $0x140, %rsp            # imm = 0x140
popq %rbp
retq
nopw (%rax,%rax)