// File: /workspace/github_c_makefile_star2_O0/Carton32[P]quectel-CM/QmiWwanCM.c
// Function: ComposeQCTLMsg
static PQCQMIMSG ComposeQCTLMsg(USHORT QMICTLType, CUSTOMQCTL customQctlMsgFunction, void *arg) {
    UCHAR QMIBuf[WDM_DEFAULT_BUFSIZE];
    PQCQMIMSG pRequest = (PQCQMIMSG)QMIBuf;
    int Length;

    pRequest->QMIHdr.IFType   = USB_CTL_MSG_TYPE_QMI;
    pRequest->QMIHdr.CtlFlags = 0x00;
    pRequest->QMIHdr.QMIType  = QMUX_TYPE_CTL;
    pRequest->QMIHdr.ClientId= 0x00;

    pRequest->CTLMsg.QMICTLMsgHdr.CtlFlags = QMICTL_FLAG_REQUEST;
    pRequest->CTLMsg.QMICTLMsgHdr.TransactionId = GetQCTLTransactionId();
    pRequest->CTLMsg.QMICTLMsgHdr.QMICTLType = cpu_to_le16(QMICTLType);
    if (customQctlMsgFunction)
        pRequest->CTLMsg.QMICTLMsgHdr.Length = cpu_to_le16(customQctlMsgFunction(&pRequest->CTLMsg, arg) - sizeof(QCQMICTL_MSG_HDR));
    else
        pRequest->CTLMsg.QMICTLMsgHdr.Length = cpu_to_le16(0x0000);

    pRequest->QMIHdr.Length = cpu_to_le16(le16_to_cpu(pRequest->CTLMsg.QMICTLMsgHdr.Length) + sizeof(QCQMICTL_MSG_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 %di, %ax
movw %ax, -0x2(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
leaq -0x120(%rbp), %rax
movq %rax, -0x128(%rbp)
movq -0x128(%rbp), %rax
movb $0x1, (%rax)
movq -0x128(%rbp), %rax
movb $0x0, 0x3(%rax)
movq -0x128(%rbp), %rax
movb $0x0, 0x4(%rax)
movq -0x128(%rbp), %rax
movb $0x0, 0x5(%rax)
movq -0x128(%rbp), %rax
movb $0x0, 0x6(%rax)
callq 0x6f20
movb %al, %cl
movq -0x128(%rbp), %rax
movb %cl, 0x7(%rax)
movzwl -0x2(%rbp), %edi
callq 0x13ff0
movw %ax, %cx
movq -0x128(%rbp), %rax
movw %cx, 0x8(%rax)
cmpq $0x0, -0x10(%rbp)
je 0x6d31
movq -0x10(%rbp), %rax
movq -0x128(%rbp), %rdi
addq $0x6, %rdi
movq -0x18(%rbp), %rsi
callq *%rax
movzwl %ax, %eax
subq $0x6, %rax
movzwl %ax, %edi
callq 0x13ff0
movw %ax, %cx
movq -0x128(%rbp), %rax
movw %cx, 0xa(%rax)
jmp 0x6d46
xorl %edi, %edi
callq 0x13ff0
movw %ax, %cx
movq -0x128(%rbp), %rax
movw %cx, 0xa(%rax)
movq -0x128(%rbp), %rax
movzwl 0xa(%rax), %edi
callq 0x13ed0
movzwl %ax, %eax
addq $0x6, %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 0x6e31
jmp 0x6db6
movq 0x30223(%rip), %rax     # 0x36fe0
movq (%rax), %rax
movq %rax, -0x138(%rbp)
callq 0x13930
movq -0x138(%rbp), %rdi
movq %rax, %rdx
leaq 0x242ad(%rip), %rsi     # 0x2b08a
leaq 0x242be(%rip), %rcx     # 0x2b0a2
movb $0x0, %al
callq 0x52c0
leaq 0x31076(%rip), %rax     # 0x37e68
cmpq $0x0, (%rax)
je 0x6e2d
leaq 0x31069(%rip), %rax     # 0x37e68
movq (%rax), %rax
movq %rax, -0x140(%rbp)
callq 0x13930
movq -0x140(%rbp), %rdi
movq %rax, %rdx
leaq 0x2426b(%rip), %rsi     # 0x2b08a
leaq 0x2427c(%rip), %rcx     # 0x2b0a2
movb $0x0, %al
callq 0x52c0
jmp 0x6e2f
jmp 0x6e4b
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
nopl (%rax,%rax)