// File: /workspace/github_c_makefile_star2_O0/Carton32[P]quectel-CM/main.c
// Function: quectel_CM
static int quectel_CM(PROFILE_T *profile)
{
    int ret = 0;
    char qmichannel[32+1] = {'\0'};
    char usbnet_adapter[32+1] = {'\0'};

    if (profile->expect_adapter[0])
        strncpy(usbnet_adapter, profile->expect_adapter, sizeof(usbnet_adapter));
    
    if (qmidevice_detect(qmichannel, usbnet_adapter, sizeof(qmichannel), profile)) {
    	profile->hardware_interface = HARDWARE_USB;
    }
    else if (mhidevice_detect(qmichannel, usbnet_adapter, profile)) {
        profile->hardware_interface = HARDWARE_PCIE;
    }
	else if (atdevice_detect(qmichannel, usbnet_adapter, profile)) {
        profile->hardware_interface = HARDWARE_PCIE;
    }
#ifdef CONFIG_QRTR
    else if (1) {
        strcpy(qmichannel, "qrtr");
        strcpy(usbnet_adapter, "rmnet_mhi0");
        profile->hardware_interface = HARDWARE_PCIE;
        profile->software_interface = SOFTWARE_QRTR;
    }
#endif
    else {
        dbg_time("qmidevice_detect failed");
        goto error;
    }

    strncpy(profile->qmichannel, qmichannel, sizeof(profile->qmichannel));
    strncpy(profile->usbnet_adapter, usbnet_adapter, sizeof(profile->usbnet_adapter));
    ql_get_netcard_driver_info(profile->usbnet_adapter);

    if ((profile->hardware_interface == HARDWARE_USB) && profile->usblogfile)
        ql_capture_usbmon_log(profile, profile->usblogfile);

    if (profile->hardware_interface == HARDWARE_USB) {
        profile->software_interface = get_driver_type(profile);
    }
  
    ql_qmap_mode_detect(profile);

    if (profile->software_interface == SOFTWARE_MBIM) {
        dbg_time("Modem works in MBIM mode");
        profile->request_ops = &mbim_request_ops;
        profile->qmi_ops = &mbim_dev_ops;
        ret = qmi_main(profile);
    }
    else if (profile->software_interface == SOFTWARE_QMI) {
        dbg_time("Modem works in QMI mode");
        profile->request_ops = &qmi_request_ops;
        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;
        ret = qmi_main(profile);
    }
    else if (profile->software_interface == SOFTWARE_ECM_RNDIS_NCM) {
        dbg_time("Modem works in ECM_RNDIS_NCM mode");
        profile->request_ops = &atc_request_ops;
        profile->qmi_ops = &atc_dev_ops;
        ret = qmi_main(profile);
    }
#ifdef CONFIG_QRTR
    else if (profile->software_interface == SOFTWARE_QRTR) {
        dbg_time("Modem works in QRTR mode");
        profile->request_ops = &qmi_request_ops;
        profile->qmi_ops = &qrtr_qmidev_ops;
        qmidev_send = profile->qmi_ops->send;
        ret = qmi_main(profile);
    }
#endif
    else {
        dbg_time("unsupport software_interface %d", profile->software_interface);
    }

    ql_stop_usbmon_log(profile);

error:
    return ret;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xb0, %rsp
movq %rdi, -0x8(%rbp)
movl $0x0, -0xc(%rbp)
leaq -0x30(%rbp), %rdi
xorl %esi, %esi
movl $0x21, %edx
callq 0x5200
leaq -0x60(%rbp), %rdi
xorl %esi, %esi
movl $0x21, %edx
callq 0x5200
movq -0x8(%rbp), %rax
cmpb $0x0, 0x62(%rax)
je 0x8e16
leaq -0x60(%rbp), %rdi
movq -0x8(%rbp), %rsi
addq $0x62, %rsi
movl $0x21, %edx
callq 0x5080
leaq -0x30(%rbp), %rdi
leaq -0x60(%rbp), %rsi
movq -0x8(%rbp), %rcx
movl $0x21, %edx
callq 0x207d0
cmpl $0x0, %eax
je 0x8e44
movq -0x8(%rbp), %rax
movl $0x6, 0x1bd(%rax)
jmp 0x8efd
leaq -0x30(%rbp), %rdi
leaq -0x60(%rbp), %rsi
movq -0x8(%rbp), %rdx
callq 0x21ba0
cmpl $0x0, %eax
je 0x8e6d
movq -0x8(%rbp), %rax
movl $0x5, 0x1bd(%rax)
jmp 0x8efb
leaq -0x30(%rbp), %rdi
leaq -0x60(%rbp), %rsi
movq -0x8(%rbp), %rdx
callq 0x21cf0
cmpl $0x0, %eax
je 0x8e93
movq -0x8(%rbp), %rax
movl $0x5, 0x1bd(%rax)
jmp 0x8ef9
jmp 0x8e95
movq 0x2e144(%rip), %rax     # 0x36fe0
movq (%rax), %rax
movq %rax, -0x68(%rbp)
callq 0x13930
movq -0x68(%rbp), %rdi
movq %rax, %rdx
leaq 0x22d7b(%rip), %rsi     # 0x2bc31
movb $0x0, %al
callq 0x52c0
leaq 0x2efa4(%rip), %rax     # 0x37e68
cmpq $0x0, (%rax)
je 0x8ef2
leaq 0x2ef97(%rip), %rax     # 0x37e68
movq (%rax), %rax
movq %rax, -0x70(%rbp)
callq 0x13930
movq -0x70(%rbp), %rdi
movq %rax, %rdx
leaq 0x22d46(%rip), %rsi     # 0x2bc31
movb $0x0, %al
callq 0x52c0
jmp 0x8ef4
jmp 0x927e
jmp 0x8efb
jmp 0x8efd
movq -0x8(%rbp), %rdi
addq $0x8a, %rdi
leaq -0x30(%rbp), %rsi
movl $0x20, %edx
callq 0x5080
movq -0x8(%rbp), %rdi
addq $0xaa, %rdi
leaq -0x60(%rbp), %rsi
movl $0x20, %edx
callq 0x5080
movq -0x8(%rbp), %rdi
addq $0xaa, %rdi
callq 0x22320
movq -0x8(%rbp), %rax
cmpl $0x6, 0x1bd(%rax)
jne 0x8f68
movq -0x8(%rbp), %rax
cmpq $0x0, 0x5a(%rax)
je 0x8f68
movq -0x8(%rbp), %rdi
movq -0x8(%rbp), %rax
movq 0x5a(%rax), %rsi
callq 0x228d0
movq -0x8(%rbp), %rax
cmpl $0x6, 0x1bd(%rax)
jne 0x8f8a
movq -0x8(%rbp), %rdi
callq 0x215e0
movl %eax, %ecx
movq -0x8(%rbp), %rax
movl %ecx, 0x1c1(%rax)
movq -0x8(%rbp), %rdi
callq 0x15bc0
movq -0x8(%rbp), %rax
cmpl $0x2, 0x1c1(%rax)
jne 0x903a
jmp 0x8fa6
movq 0x2e033(%rip), %rax     # 0x36fe0
movq (%rax), %rax
movq %rax, -0x78(%rbp)
callq 0x13930
movq -0x78(%rbp), %rdi
movq %rax, %rdx
leaq 0x22c88(%rip), %rsi     # 0x2bc4f
movb $0x0, %al
callq 0x52c0
leaq 0x2ee93(%rip), %rax     # 0x37e68
cmpq $0x0, (%rax)
je 0x9003
leaq 0x2ee86(%rip), %rax     # 0x37e68
movq (%rax), %rax
movq %rax, -0x80(%rbp)
callq 0x13930
movq -0x80(%rbp), %rdi
movq %rax, %rdx
leaq 0x22c53(%rip), %rsi     # 0x2bc4f
movb $0x0, %al
callq 0x52c0
jmp 0x9005
movq -0x8(%rbp), %rax
leaq 0x2d4b0(%rip), %rcx     # 0x364c0
movq %rcx, 0x326(%rax)
movq -0x8(%rbp), %rax
leaq 0x2d47e(%rip), %rcx     # 0x364a0
movq %rcx, 0x31e(%rax)
movq -0x8(%rbp), %rdi
callq 0x9a80
movl %eax, -0xc(%rbp)
jmp 0x9275
movq -0x8(%rbp), %rax
cmpl $0x1, 0x1c1(%rax)
jne 0x913b
jmp 0x904d
movq 0x2df8c(%rip), %rax     # 0x36fe0
movq (%rax), %rax
movq %rax, -0x88(%rbp)
callq 0x13930
movq -0x88(%rbp), %rdi
movq %rax, %rdx
leaq 0x22bfa(%rip), %rsi     # 0x2bc6e
movb $0x0, %al
callq 0x52c0
leaq 0x2ede6(%rip), %rax     # 0x37e68
cmpq $0x0, (%rax)
je 0x90b6
leaq 0x2edd9(%rip), %rax     # 0x37e68
movq (%rax), %rax
movq %rax, -0x90(%rbp)
callq 0x13930
movq -0x90(%rbp), %rdi
movq %rax, %rdx
leaq 0x22bbf(%rip), %rsi     # 0x2bc6e
movb $0x0, %al
callq 0x52c0
jmp 0x90b8
movq -0x8(%rbp), %rax
leaq 0x2d2dd(%rip), %rcx     # 0x363a0
movq %rcx, 0x326(%rax)
movq -0x8(%rbp), %rdi
addq $0x8a, %rdi
leaq 0x22bb0(%rip), %rsi     # 0x2bc8c
movl $0xa, %edx
callq 0x5090
cmpl $0x0, %eax
jne 0x90ff
movq -0x8(%rbp), %rax
leaq 0x2c58a(%rip), %rcx     # 0x35680
movq %rcx, 0x31e(%rax)
jmp 0x9111
movq -0x8(%rbp), %rax
leaq 0x2c556(%rip), %rcx     # 0x35660
movq %rcx, 0x31e(%rax)
movq -0x8(%rbp), %rax
movq 0x31e(%rax), %rax
movq 0x10(%rax), %rcx
leaq 0x2ecc1(%rip), %rax     # 0x37de8
movq %rcx, (%rax)
movq -0x8(%rbp), %rdi
callq 0x9a80
movl %eax, -0xc(%rbp)
jmp 0x9273
movq -0x8(%rbp), %rax
cmpl $0x3, 0x1c1(%rax)
jne 0x91ee
jmp 0x914e
movq 0x2de8b(%rip), %rax     # 0x36fe0
movq (%rax), %rax
movq %rax, -0x98(%rbp)
callq 0x13930
movq -0x98(%rbp), %rdi
movq %rax, %rdx
leaq 0x22b22(%rip), %rsi     # 0x2bc97
movb $0x0, %al
callq 0x52c0
leaq 0x2ece5(%rip), %rax     # 0x37e68
cmpq $0x0, (%rax)
je 0x91b7
leaq 0x2ecd8(%rip), %rax     # 0x37e68
movq (%rax), %rax
movq %rax, -0xa0(%rbp)
callq 0x13930
movq -0xa0(%rbp), %rdi
movq %rax, %rdx
leaq 0x22ae7(%rip), %rsi     # 0x2bc97
movb $0x0, %al
callq 0x52c0
jmp 0x91b9
movq -0x8(%rbp), %rax
leaq 0x2db5c(%rip), %rcx     # 0x36d20
movq %rcx, 0x326(%rax)
movq -0x8(%rbp), %rax
leaq 0x2db2a(%rip), %rcx     # 0x36d00
movq %rcx, 0x31e(%rax)
movq -0x8(%rbp), %rdi
callq 0x9a80
movl %eax, -0xc(%rbp)
jmp 0x9271
jmp 0x91f0
movq 0x2dde9(%rip), %rax     # 0x36fe0
movq (%rax), %rax
movq %rax, -0xa8(%rbp)
callq 0x13930
movq -0xa8(%rbp), %rdi
movq %rax, %rdx
movq -0x8(%rbp), %rax
movl 0x1c1(%rax), %ecx
leaq 0x22a9e(%rip), %rsi     # 0x2bcbf
movb $0x0, %al
callq 0x52c0
leaq 0x2ec39(%rip), %rax     # 0x37e68
cmpq $0x0, (%rax)
je 0x926d
leaq 0x2ec2c(%rip), %rax     # 0x37e68
movq (%rax), %rax
movq %rax, -0xb0(%rbp)
callq 0x13930
movq -0xb0(%rbp), %rdi
movq %rax, %rdx
movq -0x8(%rbp), %rax
movl 0x1c1(%rax), %ecx
leaq 0x22a59(%rip), %rsi     # 0x2bcbf
movb $0x0, %al
callq 0x52c0
jmp 0x926f
jmp 0x9271
jmp 0x9273
jmp 0x9275
movq -0x8(%rbp), %rdi
callq 0x22e90
movl -0xc(%rbp), %eax
addq $0xb0, %rsp
popq %rbp
retq
nopw (%rax,%rax)