// File: /workspace/github_c_makefile_star2_O0/Carton32[P]quectel-CM/QmiWwanCM.c
// Function: QmiWwanSendQMI
static int QmiWwanSendQMI(PQCQMIMSG pRequest) {
    struct pollfd pollfds[]= {{cdc_wdm_fd, POLLOUT, 0}};
    int ret;

    if (cdc_wdm_fd == -1) {
        dbg_time("%s cdc_wdm_fd = -1", __func__);
        return -ENODEV;
    }

    if (pRequest->QMIHdr.QMIType != QMUX_TYPE_CTL) {
        pRequest->QMIHdr.ClientId = qmiclientId[pRequest->QMIHdr.QMIType];
        if (pRequest->QMIHdr.ClientId == 0) {
            dbg_time("QMIType %d has no clientID", pRequest->QMIHdr.QMIType);
            return -ENODEV;
        }

        if (pRequest->QMIHdr.QMIType == QMUX_TYPE_WDS_IPV6)
            pRequest->QMIHdr.QMIType = QMUX_TYPE_WDS;
    }

    do {
        ret = poll(pollfds, sizeof(pollfds)/sizeof(pollfds[0]), 5000);
    } while ((ret < 0) && (errno == EINTR));

    if (pollfds[0].revents & POLLOUT) {
        ssize_t nwrites = le16_to_cpu(pRequest->QMIHdr.Length) + 1;
        ret = write(cdc_wdm_fd, pRequest, nwrites);
        if (ret == nwrites) {
            ret = 0;
        } else {
            dbg_time("%s write=%d, errno: %d (%s)", __func__, ret, errno, strerror(errno));
        }
    } else {
        dbg_time("%s poll=%d, revents = 0x%x, errno: %d (%s)", __func__, ret, pollfds[0].revents, errno, strerror(errno));
    }

    return ret;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xd0, %rsp
movq %rdi, -0x10(%rbp)
movl 0x3196b(%rip), %eax     # 0x372f0
movl %eax, -0x18(%rbp)
movw $0x4, -0x14(%rbp)
movw $0x0, -0x12(%rbp)
cmpl $-0x1, 0x31955(%rip)    # 0x372f0
jne 0x5a18
jmp 0x599f
movq 0x3163a(%rip), %rax     # 0x36fe0
movq (%rax), %rax
movq %rax, -0x30(%rbp)
callq 0x13930
movq -0x30(%rbp), %rdi
movq %rax, %rdx
leaq 0x256f1(%rip), %rsi     # 0x2b0b1
leaq 0x25703(%rip), %rcx     # 0x2b0ca
movb $0x0, %al
callq 0x52c0
leaq 0x32493(%rip), %rax     # 0x37e68
cmpq $0x0, (%rax)
je 0x5a0a
leaq 0x32486(%rip), %rax     # 0x37e68
movq (%rax), %rax
movq %rax, -0x38(%rbp)
callq 0x13930
movq -0x38(%rbp), %rdi
movq %rax, %rdx
leaq 0x256b5(%rip), %rsi     # 0x2b0b1
leaq 0x256c7(%rip), %rcx     # 0x2b0ca
movb $0x0, %al
callq 0x52c0
jmp 0x5a0c
movl $0xffffffed, -0x4(%rbp) # imm = 0xFFFFFFED
jmp 0x5d73
movq -0x10(%rbp), %rax
movzbl 0x4(%rax), %eax
cmpl $0x0, %eax
je 0x5ae5
movq -0x10(%rbp), %rax
movzbl 0x4(%rax), %eax
movl %eax, %ecx
leaq 0x31ac6(%rip), %rax     # 0x37500
movb (%rax,%rcx), %cl
movq -0x10(%rbp), %rax
movb %cl, 0x5(%rax)
movq -0x10(%rbp), %rax
movzbl 0x5(%rax), %eax
cmpl $0x0, %eax
jne 0x5ace
jmp 0x5a53
movq 0x31586(%rip), %rax     # 0x36fe0
movq (%rax), %rax
movq %rax, -0x40(%rbp)
callq 0x13930
movq -0x40(%rbp), %rdi
movq %rax, %rdx
movq -0x10(%rbp), %rax
movzbl 0x4(%rax), %ecx
leaq 0x2565d(%rip), %rsi     # 0x2b0d9
movb $0x0, %al
callq 0x52c0
leaq 0x323de(%rip), %rax     # 0x37e68
cmpq $0x0, (%rax)
je 0x5ac0
leaq 0x323d1(%rip), %rax     # 0x37e68
movq (%rax), %rax
movq %rax, -0x48(%rbp)
callq 0x13930
movq -0x48(%rbp), %rdi
movq %rax, %rdx
movq -0x10(%rbp), %rax
movzbl 0x4(%rax), %ecx
leaq 0x25620(%rip), %rsi     # 0x2b0d9
movb $0x0, %al
callq 0x52c0
jmp 0x5ac2
movl $0xffffffed, -0x4(%rbp) # imm = 0xFFFFFFED
jmp 0x5d73
movq -0x10(%rbp), %rax
movzbl 0x4(%rax), %eax
cmpl $0x11, %eax
jne 0x5ae3
movq -0x10(%rbp), %rax
movb $0x1, 0x4(%rax)
jmp 0x5ae5
jmp 0x5ae7
leaq -0x18(%rbp), %rdi
movl $0x1, %esi
movl $0x1388, %edx           # imm = 0x1388
callq 0x53d0
movl %eax, -0x1c(%rbp)
xorl %eax, %eax
cmpl $0x0, -0x1c(%rbp)
movb %al, -0x49(%rbp)
jge 0x5b16
callq 0x5070
cmpl $0x4, (%rax)
sete %al
movb %al, -0x49(%rbp)
movb -0x49(%rbp), %al
testb $0x1, %al
jne 0x5ae7
movswl -0x12(%rbp), %eax
andl $0x4, %eax
cmpl $0x0, %eax
je 0x5c42
movq -0x10(%rbp), %rax
movzwl 0x1(%rax), %edi
callq 0x13ed0
movzwl %ax, %eax
addl $0x1, %eax
cltq
movq %rax, -0x28(%rbp)
movl 0x317a4(%rip), %edi     # 0x372f0
movq -0x10(%rbp), %rsi
movq -0x28(%rbp), %rdx
callq 0x5100
movl %eax, -0x1c(%rbp)
movslq -0x1c(%rbp), %rax
cmpq -0x28(%rbp), %rax
jne 0x5b72
movl $0x0, -0x1c(%rbp)
jmp 0x5c3d
jmp 0x5b74
movq 0x31465(%rip), %rax     # 0x36fe0
movq (%rax), %rax
movq %rax, -0x68(%rbp)
callq 0x13930
movq %rax, -0x60(%rbp)
movl -0x1c(%rbp), %eax
movl %eax, -0x54(%rbp)
callq 0x5070
movl (%rax), %eax
movl %eax, -0x50(%rbp)
callq 0x5070
movl (%rax), %edi
callq 0x5540
movq -0x68(%rbp), %rdi
movq -0x60(%rbp), %rdx
movl -0x54(%rbp), %r8d
movl -0x50(%rbp), %r9d
leaq 0x2553c(%rip), %rsi     # 0x2b0fa
leaq 0x25505(%rip), %rcx     # 0x2b0ca
movq %rax, (%rsp)
movb $0x0, %al
callq 0x52c0
leaq 0x32291(%rip), %rax     # 0x37e68
cmpq $0x0, (%rax)
je 0x5c39
leaq 0x32284(%rip), %rax     # 0x37e68
movq (%rax), %rax
movq %rax, -0x80(%rbp)
callq 0x13930
movq %rax, -0x78(%rbp)
movl -0x1c(%rbp), %eax
movl %eax, -0x70(%rbp)
callq 0x5070
movl (%rax), %eax
movl %eax, -0x6c(%rbp)
callq 0x5070
movl (%rax), %edi
callq 0x5540
movq -0x80(%rbp), %rdi
movq -0x78(%rbp), %rdx
movl -0x70(%rbp), %r8d
movl -0x6c(%rbp), %r9d
leaq 0x254d3(%rip), %rsi     # 0x2b0fa
leaq 0x2549c(%rip), %rcx     # 0x2b0ca
movq %rax, (%rsp)
movb $0x0, %al
callq 0x52c0
jmp 0x5c3b
jmp 0x5c3d
jmp 0x5d6d
jmp 0x5c44
movq 0x31395(%rip), %rax     # 0x36fe0
movq (%rax), %rax
movq %rax, -0xa0(%rbp)
callq 0x13930
movq %rax, -0x98(%rbp)
movl -0x1c(%rbp), %eax
movl %eax, -0x8c(%rbp)
movswl -0x12(%rbp), %eax
movl %eax, -0x88(%rbp)
callq 0x5070
movl (%rax), %eax
movl %eax, -0x84(%rbp)
callq 0x5070
movl (%rax), %edi
callq 0x5540
movq -0xa0(%rbp), %rdi
movq -0x98(%rbp), %rdx
movl -0x8c(%rbp), %r8d
movl -0x88(%rbp), %r9d
movl -0x84(%rbp), %r10d
leaq 0x25465(%rip), %rsi     # 0x2b11c
leaq 0x2540c(%rip), %rcx     # 0x2b0ca
movl %r10d, (%rsp)
movq %rax, 0x8(%rsp)
movb $0x0, %al
callq 0x52c0
leaq 0x32193(%rip), %rax     # 0x37e68
cmpq $0x0, (%rax)
je 0x5d69
leaq 0x32182(%rip), %rax     # 0x37e68
movq (%rax), %rax
movq %rax, -0xc0(%rbp)
callq 0x13930
movq %rax, -0xb8(%rbp)
movl -0x1c(%rbp), %eax
movl %eax, -0xac(%rbp)
movswl -0x12(%rbp), %eax
movl %eax, -0xa8(%rbp)
callq 0x5070
movl (%rax), %eax
movl %eax, -0xa4(%rbp)
callq 0x5070
movl (%rax), %edi
callq 0x5540
movq -0xc0(%rbp), %rdi
movq -0xb8(%rbp), %rdx
movl -0xac(%rbp), %r8d
movl -0xa8(%rbp), %r9d
movl -0xa4(%rbp), %r10d
leaq 0x253ca(%rip), %rsi     # 0x2b11c
leaq 0x25371(%rip), %rcx     # 0x2b0ca
movl %r10d, (%rsp)
movq %rax, 0x8(%rsp)
movb $0x0, %al
callq 0x52c0
jmp 0x5d6b
jmp 0x5d6d
movl -0x1c(%rbp), %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0xd0, %rsp
popq %rbp
retq
nop