LLM4Binary/decompile-bench-makefile huggingface dataset:
// File: /workspace/github_c_makefile_star2_O3/Carton32[P]quectel-CM/device.c
// Function: get_driver_type
int get_driver_type(PROFILE_T *profile)
{
    /* QMI_WWAN */
    if (profile->usb_intf.bInterfaceClass == USB_CLASS_VENDOR_SPEC) {
        return SOFTWARE_QMI;
    }
    else if (profile->usb_intf.bInterfaceClass == USB_CLASS_COMM) {
        switch (profile->usb_intf.bInterfaceSubClass) {
            case USB_CDC_SUBCLASS_MBIM:
                return SOFTWARE_MBIM;
            break;
            case USB_CDC_SUBCLASS_ETHERNET:
            case USB_CDC_SUBCLASS_NCM:
                return SOFTWARE_ECM_RNDIS_NCM;
            break;
            default:
            break;
        }
    }
    else if (profile->usb_intf.bInterfaceClass == USB_CLASS_WIRELESS_CONTROLLER) {
        if (profile->usb_intf.bInterfaceSubClass == 1 && profile->usb_intf.bInterfaceProtocol == 3)
            return SOFTWARE_ECM_RNDIS_NCM;
    }

    dbg_time("%s unknow bInterfaceClass=%d, bInterfaceSubClass=%d", __func__,
        profile->usb_intf.bInterfaceClass, profile->usb_intf.bInterfaceSubClass);
    return DRV_INVALID;
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
movl 0x1dd(%rdi), %eax
cmpl $0xff, %eax
je 0x17451
movq %rdi, %rbx
cmpl $0xe0, %eax
je 0x173bb
cmpl $0x2, %eax
jne 0x173d6
movl 0x1e1(%rbx), %eax
cmpl $0x6, %eax
je 0x173b1
cmpl $0xe, %eax
je 0x1745d
cmpl $0xd, %eax
jne 0x173d6
movl $0x3, %ebp
jmp 0x17456
cmpl $0x1, 0x1e1(%rbx)
jne 0x173d6
movl $0x3, %ebp
cmpl $0x3, 0x1e5(%rbx)
je 0x17456
movq 0x12be3(%rip), %rax     # 0x29fc0
movq (%rax), %r14
callq 0xea3b
movl 0x1dd(%rbx), %r8d
movl 0x1e1(%rbx), %r9d
leaq 0xb694(%rip), %rsi      # 0x22a8e
leaq 0xb6c7(%rip), %rcx      # 0x22ac8
xorl %ebp, %ebp
movq %r14, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0x52c0
leaq 0x13891(%rip), %rax     # 0x2aca8
movq (%rax), %r14
testq %r14, %r14
je 0x17456
callq 0xea3b
movl 0x1dd(%rbx), %r8d
movl 0x1e1(%rbx), %r9d
leaq 0xb655(%rip), %rsi      # 0x22a8e
leaq 0xb688(%rip), %rcx      # 0x22ac8
xorl %ebp, %ebp
movq %r14, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0x52c0
jmp 0x17456
movl $0x1, %ebp
movl %ebp, %eax
popq %rbx
popq %r14
popq %rbp
retq
movl $0x2, %ebp
jmp 0x17456
// File: /workspace/github_c_makefile_star2_O3/Carton32[P]quectel-CM/device.c
// Function: mhidevice_detect
int mhidevice_detect(char *qmichannel, char *usbnet_adapter, PROFILE_T *profile) {
    if (!access("/sys/class/net/pcie_mhi0", F_OK))
        strcpy(usbnet_adapter, "pcie_mhi0");
    else if (!access("/sys/class/net/rmnet_mhi0", F_OK))
        strcpy(usbnet_adapter, "rmnet_mhi0");
    else {
        dbg_time("qmidevice_detect failed");
        goto error;
    }

    if (!access("/dev/mhi_MBIM", F_OK)) {
        strcpy(qmichannel, "/dev/mhi_MBIM");
        profile->software_interface = SOFTWARE_MBIM;
    }
    else if (!access("/dev/mhi_QMI0", F_OK)) {
        strcpy(qmichannel, "/dev/mhi_QMI0");
        profile->software_interface = SOFTWARE_QMI;
    }
    else {
        goto error;
    }

    return 1;
error:
    return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movq %rdx, %rbx
movq %rsi, %r15
movq %rdi, %r14
leaq 0xb578(%rip), %rdi      # 0x229f3
xorl %esi, %esi
callq 0x5450
testl %eax, %eax
je 0x174f0
leaq 0xb57f(%rip), %rdi      # 0x22a0c
xorl %ebp, %ebp
xorl %esi, %esi
callq 0x5450
testl %eax, %eax
je 0x17506
movq 0x12b1f(%rip), %rax     # 0x29fc0
movq (%rax), %rbx
callq 0xea3b
leaq 0x764f(%rip), %rsi      # 0x1eaff
movq %rbx, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0x52c0
leaq 0x137e4(%rip), %rax     # 0x2aca8
movq (%rax), %rbx
testq %rbx, %rbx
je 0x17592
callq 0xea3b
leaq 0x7623(%rip), %rsi      # 0x1eaff
xorl %ebp, %ebp
movq %rbx, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0x52c0
jmp 0x17592
movabsq $0x69686d5f65696370, %rax # imm = 0x69686D5F65696370
movq %rax, (%r15)
movw $0x30, 0x8(%r15)
jmp 0x1751b
movabsq $0x686d5f74656e6d72, %rax # imm = 0x686D5F74656E6D72
movq %rax, (%r15)
movl $0x306968, 0x7(%r15)    # imm = 0x306968
leaq 0xb504(%rip), %rdi      # 0x22a26
xorl %ebp, %ebp
xorl %esi, %esi
callq 0x5450
testl %eax, %eax
je 0x17568
leaq 0xb4fe(%rip), %rdi      # 0x22a34
xorl %esi, %esi
callq 0x5450
testl %eax, %eax
jne 0x17592
movabsq $0x30494d515f6968, %rax # imm = 0x30494D515F6968
movq %rax, 0x6(%r14)
movabsq $0x69686d2f7665642f, %rax # imm = 0x69686D2F7665642F
movq %rax, (%r14)
movl $0x1, 0x1c1(%rbx)
jmp 0x1758d
movabsq $0x4d49424d5f6968, %rax # imm = 0x4D49424D5F6968
movq %rax, 0x6(%r14)
movabsq $0x69686d2f7665642f, %rax # imm = 0x69686D2F7665642F
movq %rax, (%r14)
movl $0x2, 0x1c1(%rbx)
movl $0x1, %ebp
movl %ebp, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/Carton32[P]quectel-CM/device.c
// Function: atdevice_detect
int atdevice_detect(char *atchannel, char *usbnet_adapter, PROFILE_T *profile) {
    if (!access("/sys/class/net/sipa_dummy0", F_OK)) {
		strcpy(usbnet_adapter, "sipa_dummy0");
		snprintf(profile->qmapnet_adapter, sizeof(profile->qmapnet_adapter), "%s%d", "pcie", profile->pdp - 1);
    }
	else {
        dbg_time("atdevice_detect failed");
        goto error;
    }

    if (!access("/dev/stty_nr31", F_OK)) {
        strcpy(atchannel, "/dev/stty_nr31");
        profile->software_interface = SOFTWARE_ECM_RNDIS_NCM;
    }
    else {
        goto error;
    }

    return 1;
error:
    return 0;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
movq %rdx, %r14
movq %rsi, %r12
movq %rdi, %r15
leaq 0xb48b(%rip), %rdi      # 0x22a42
xorl %ebx, %ebx
xorl %esi, %esi
callq 0x5450
testl %eax, %eax
je 0x17617
movq 0x129f5(%rip), %rax     # 0x29fc0
movq (%rax), %r14
callq 0xea3b
leaq 0xb488(%rip), %rsi      # 0x22a62
movq %r14, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0x52c0
leaq 0x136ba(%rip), %rax     # 0x2aca8
movq (%rax), %r14
testq %r14, %r14
je 0x17695
callq 0xea3b
leaq 0xb45c(%rip), %rsi      # 0x22a62
xorl %ebx, %ebx
movq %r14, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0x52c0
jmp 0x17695
movabsq $0x6d75645f61706973, %rax # imm = 0x6D75645F61706973
movq %rax, (%r12)
movl $0x30796d, 0x8(%r12)    # imm = 0x30796D
leaq 0xca(%r14), %rdi
movl 0x48(%r14), %r8d
decl %r8d
leaq 0xbb83(%rip), %rdx      # 0x231c6
leaq 0xb413(%rip), %rcx      # 0x22a5d
xorl %ebx, %ebx
movl $0x20, %esi
xorl %eax, %eax
callq 0x51c0
leaq 0xb420(%rip), %rdi      # 0x22a7f
xorl %esi, %esi
callq 0x5450
testl %eax, %eax
jne 0x17695
movabsq $0x3133726e5f7974, %rax # imm = 0x3133726E5F7974
movq %rax, 0x7(%r15)
movabsq $0x7474732f7665642f, %rax # imm = 0x7474732F7665642F
movq %rax, (%r15)
movl $0x3, 0x1c1(%r14)
movl $0x1, %ebx
movl %ebx, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O3/Carton32[P]quectel-CM/device.c
// Function: usbfs_is_kernel_driver_alive
int usbfs_is_kernel_driver_alive(int fd, int ifnum)
{
    struct usbfs_getdriver getdrv;
    getdrv.interface = ifnum;
    if (ioctl(fd, USBDEVFS_GETDRIVER, &getdrv) < 0) {
        dbg_time("%s ioctl USBDEVFS_GETDRIVER failed, kernel driver may be inactive", __func__);
        return 0;
    }
    dbg_time("%s find interface %d has match the driver %s", __func__, ifnum, getdrv.driver);
    return 1;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
subq $0x108, %rsp            # imm = 0x108
movl %esi, %ebp
leaq 0x4(%rsp), %rdx
movl %esi, (%rdx)
xorl %ebx, %ebx
movl $0x41045508, %esi       # imm = 0x41045508
xorl %eax, %eax
callq 0x5210
movl %eax, %r14d
movq 0x128ef(%rip), %rax     # 0x29fc0
movq (%rax), %r15
callq 0xea3b
testl %r14d, %r14d
js 0x17740
leaq 0x8(%rsp), %r14
leaq 0xb453(%rip), %rsi      # 0x22b3d
leaq 0xb42f(%rip), %rcx      # 0x22b20
movq %r15, %rdi
movq %rax, %rdx
movl %ebp, %r8d
movq %r14, %r9
xorl %eax, %eax
callq 0x52c0
leaq 0x1359d(%rip), %rax     # 0x2aca8
movq (%rax), %r15
movl $0x1, %ebx
testq %r15, %r15
je 0x1778c
callq 0xea3b
leaq 0xb419(%rip), %rsi      # 0x22b3d
leaq 0xb3f5(%rip), %rcx      # 0x22b20
movq %r15, %rdi
movq %rax, %rdx
movl %ebp, %r8d
movq %r14, %r9
xorl %eax, %eax
callq 0x52c0
jmp 0x1778c
leaq 0xb391(%rip), %rsi      # 0x22ad8
leaq 0xb3d2(%rip), %rcx      # 0x22b20
movq %r15, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0x52c0
leaq 0x13546(%rip), %rax     # 0x2aca8
movq (%rax), %r14
testq %r14, %r14
je 0x1778c
callq 0xea3b
leaq 0xb362(%rip), %rsi      # 0x22ad8
leaq 0xb3a3(%rip), %rcx      # 0x22b20
xorl %ebx, %ebx
movq %r14, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0x52c0
movl %ebx, %eax
addq $0x108, %rsp            # imm = 0x108
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/Carton32[P]quectel-CM/device.c
// Function: usbfs_detach_kernel_driver
void usbfs_detach_kernel_driver(int fd, int ifnum)
{
    struct usbfs_ioctl operate;
    operate.data = NULL;
    operate.ifno = ifnum;
    operate.ioctl_code = IOCTL_USBFS_DISCONNECT;
    if (ioctl(fd, USBDEVFS_IOCTL, &operate) < 0) {
        dbg_time("%s detach kernel driver failed", __func__);
    } else {
        dbg_time("%s detach kernel driver success", __func__);
    }
}

// Assembly:
pushq %rbp
pushq %rbx
subq $0x18, %rsp
leaq 0x8(%rsp), %rdx
movq $0x0, 0x8(%rdx)
movl %esi, (%rdx)
movl $0x5516, 0x4(%rdx)      # imm = 0x5516
movl $0xc0105512, %esi       # imm = 0xC0105512
xorl %eax, %eax
callq 0x5210
movl %eax, %ebp
movq 0x127f3(%rip), %rax     # 0x29fc0
movq (%rax), %rbx
callq 0xea3b
testl %ebp, %ebp
js 0x17811
leaq 0xb3d0(%rip), %rsi      # 0x22bb0
leaq 0xb3ae(%rip), %rcx      # 0x22b95
movq %rbx, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0x52c0
leaq 0x134ad(%rip), %rax     # 0x2aca8
movq (%rax), %rbx
testq %rbx, %rbx
je 0x1785b
callq 0xea3b
leaq 0xb3a1(%rip), %rsi      # 0x22bb0
jmp 0x17847
leaq 0xb358(%rip), %rsi      # 0x22b70
leaq 0xb376(%rip), %rcx      # 0x22b95
movq %rbx, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0x52c0
leaq 0x13475(%rip), %rax     # 0x2aca8
movq (%rax), %rbx
testq %rbx, %rbx
je 0x1785b
callq 0xea3b
leaq 0xb329(%rip), %rsi      # 0x22b70
leaq 0xb347(%rip), %rcx      # 0x22b95
movq %rbx, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0x52c0
addq $0x18, %rsp
popq %rbx
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/Carton32[P]quectel-CM/device.c
// Function: usbfs_attach_kernel_driver
void usbfs_attach_kernel_driver(int fd, int ifnum)
{
    struct usbfs_ioctl operate;
    operate.data = NULL;
    operate.ifno = ifnum;
    operate.ioctl_code = IOCTL_USBFS_CONNECT;
    if (ioctl(fd, USBDEVFS_IOCTL, &operate) < 0) {
        dbg_time("%s detach kernel driver failed", __func__);
    } else {
        dbg_time("%s detach kernel driver success", __func__);
    }
}

// Assembly:
pushq %rbp
pushq %rbx
subq $0x18, %rsp
leaq 0x8(%rsp), %rdx
movq $0x0, 0x8(%rdx)
movl %esi, (%rdx)
movl $0x5517, 0x4(%rdx)      # imm = 0x5517
movl $0xc0105512, %esi       # imm = 0xC0105512
xorl %eax, %eax
callq 0x5210
movl %eax, %ebp
movq 0x1272d(%rip), %rax     # 0x29fc0
movq (%rax), %rbx
callq 0xea3b
testl %ebp, %ebp
js 0x178d7
leaq 0xb30a(%rip), %rsi      # 0x22bb0
leaq 0xb329(%rip), %rcx      # 0x22bd6
movq %rbx, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0x52c0
leaq 0x133e7(%rip), %rax     # 0x2aca8
movq (%rax), %rbx
testq %rbx, %rbx
je 0x17921
callq 0xea3b
leaq 0xb2db(%rip), %rsi      # 0x22bb0
jmp 0x1790d
leaq 0xb292(%rip), %rsi      # 0x22b70
leaq 0xb2f1(%rip), %rcx      # 0x22bd6
movq %rbx, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0x52c0
leaq 0x133af(%rip), %rax     # 0x2aca8
movq (%rax), %rbx
testq %rbx, %rbx
je 0x17921
callq 0xea3b
leaq 0xb263(%rip), %rsi      # 0x22b70
leaq 0xb2c2(%rip), %rcx      # 0x22bd6
movq %rbx, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0x52c0
addq $0x18, %rsp
popq %rbx
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/Carton32[P]quectel-CM/device.c
// Function: reattach_driver
int reattach_driver(PROFILE_T *profile)
{
    int ifnum = 4;
    int fd;
    char devpath[128] = {'\0'};
    snprintf(devpath, sizeof(devpath), "/dev/bus/usb/%03d/%03d", profile->usb_dev.busnum, profile->usb_dev.devnum);
    fd = open(devpath, O_RDWR | O_NOCTTY);
    if (fd < 0)
    {
        dbg_time("%s fail to open %s", __func__, devpath);
        return -1;
    }
    usbfs_detach_kernel_driver(fd, ifnum);
    usbfs_attach_kernel_driver(fd, ifnum);
    close(fd);
    return 0;
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
subq $0x80, %rsp
xorps %xmm0, %xmm0
movq %rsp, %r14
movaps %xmm0, 0x70(%r14)
movaps %xmm0, 0x60(%r14)
movaps %xmm0, 0x50(%r14)
movaps %xmm0, 0x40(%r14)
movaps %xmm0, 0x30(%r14)
movaps %xmm0, 0x20(%r14)
movaps %xmm0, 0x10(%r14)
movaps %xmm0, (%r14)
movl 0x1cd(%rdi), %ecx
movl 0x1d1(%rdi), %r8d
leaq 0xb27d(%rip), %rdx      # 0x22bf1
xorl %ebx, %ebx
movl $0x80, %esi
movq %r14, %rdi
xorl %eax, %eax
callq 0x51c0
movq %r14, %rdi
movl $0x102, %esi            # imm = 0x102
xorl %eax, %eax
callq 0x5440
testl %eax, %eax
js 0x179bb
movl %eax, %ebp
movl %eax, %edi
movl $0x4, %esi
callq 0x1779c
movl %ebp, %edi
movl $0x4, %esi
callq 0x17862
movl %ebp, %edi
callq 0x5230
jmp 0x17a1f
movq 0x125fe(%rip), %rax     # 0x29fc0
movq (%rax), %rbx
callq 0xea3b
leaq 0xb237(%rip), %rsi      # 0x22c08
leaq 0xb249(%rip), %rcx      # 0x22c21
movq %rsp, %r8
movq %rbx, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0x52c0
leaq 0x132b9(%rip), %rax     # 0x2aca8
movq (%rax), %r14
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
testq %r14, %r14
je 0x17a1f
callq 0xea3b
leaq 0xb200(%rip), %rsi      # 0x22c08
leaq 0xb212(%rip), %rcx      # 0x22c21
movq %rsp, %r8
movq %r14, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0x52c0
movl %ebx, %eax
addq $0x80, %rsp
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/Carton32[P]quectel-CM/device.c
// Function: catch_log
static void *catch_log(void *arg)
{
    PROFILE_T *profile = (PROFILE_T *)arg;
    int nreads = 0;
    char tbuff[256+32];
    char filter[32];
    size_t tsize = strlen(get_time()) + 1;

    snprintf(filter, sizeof(filter), ":%d:%03d:", profile->usb_dev.busnum, profile->usb_dev.devnum);

    while(1) {
        nreads = read(profile->usbmon_fd, tbuff + tsize, sizeof(tbuff) - tsize - 1);
        if (nreads <= 0) {
            if (nreads == -1 && errno == EINTR)
                continue;
            break;
        }

        tbuff[tsize+nreads] = '\0';   // printf("%s", buff);

        if (!strstr(tbuff+tsize, filter))
            continue;

        snprintf(tbuff, sizeof(tbuff), "%s", get_time());
        tbuff[tsize-1] = ' ';

        fwrite(tbuff, strlen(tbuff), 1, profile->usbmon_logfile_fp);
    }

    return NULL;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x148, %rsp            # imm = 0x148
movq %rdi, %rbx
callq 0xea3b
movq %rax, %rdi
callq 0x5160
movq %rax, %r14
leaq 0x1(%rax), %r15
movl 0x1cd(%rbx), %ecx
movl 0x1d1(%rbx), %r8d
leaq 0xae4d(%rip), %rdx      # 0x22f56
movq %rsp, %rdi
movl $0x20, %esi
xorl %eax, %eax
callq 0x51c0
leaq (%rsp,%r14), %r12
addq $0x21, %r12
movl $0x11e, %r13d           # imm = 0x11E
subq %r14, %r13
leaq 0x20(%rsp), %rbp
movl 0x209(%rbx), %edi
movq %r12, %rsi
movq %r13, %rdx
callq 0x5250
testl %eax, %eax
jle 0x181a5
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
addq %r15, %rax
movb $0x0, 0x20(%rsp,%rax)
movq %r12, %rdi
movq %rsp, %rsi
callq 0x5550
testq %rax, %rax
je 0x1812e
callq 0xea3b
movl $0x120, %esi            # imm = 0x120
movq %rbp, %rdi
leaq 0xacb9(%rip), %rdx      # 0x22e2d
movq %rax, %rcx
xorl %eax, %eax
callq 0x51c0
movb $0x20, 0x20(%rsp,%r14)
movq %rbp, %rdi
callq 0x5160
movq 0x20d(%rbx), %rcx
movl $0x1, %edx
movq %rbp, %rdi
movq %rax, %rsi
callq 0x5500
jmp 0x1812e
cmpl $-0x1, %eax
jne 0x181b8
callq 0x5070
cmpl $0x4, (%rax)
je 0x1812e
xorl %eax, %eax
addq $0x148, %rsp            # imm = 0x148
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/Carton32[P]quectel-CM/device.c
// Function: ql_stop_usbmon_log
void ql_stop_usbmon_log(PROFILE_T *profile) {
    if (profile->usbmon_fd > 0)
        close(profile->usbmon_fd);
    if (profile->usbmon_logfile_fp)
        fclose(profile->usbmon_logfile_fp);
}

// Assembly:
pushq %rbx
movq %rdi, %rbx
movl 0x209(%rdi), %edi
testl %edi, %edi
jle 0x181df
callq 0x5230
movq 0x20d(%rbx), %rdi
testq %rdi, %rdi
je 0x181f1
popq %rbx
jmp 0x5130
popq %rbx
retq
// File: /workspace/github_c_makefile_star2_O3/Carton32[P]quectel-CM/device.c
// Function: file_get_value
static int file_get_value(const char *fname, int base)
{
    FILE *fp = NULL;
    long num;
    char buff[32 + 1] = {'\0'};
    char *endptr = NULL;

    fp = fopen(fname, "r");
    if (!fp) goto error;
    if (fgets(buff, sizeof(buff), fp) == NULL)
        goto error;
    fclose(fp);

    num = (int)strtol(buff, &endptr, base);
    if (errno == ERANGE && (num == LONG_MAX || num == LONG_MIN))
        goto error;
    /* if there is no digit in buff */
    if (endptr == buff)
        goto error;

    if (debug_qmi)
        dbg_time("(%s) = %lx", fname, num);
    return (int)num;

error:
    if (fp) fclose(fp);
    return CM_INVALID_VAL;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movl %esi, %r14d
movq %rdi, %rbx
xorps %xmm0, %xmm0
movaps %xmm0, 0x20(%rsp)
movaps %xmm0, 0x10(%rsp)
movb $0x0, 0x30(%rsp)
movq $0x0, 0x8(%rsp)
leaq 0x9f5d(%rip), %rsi      # 0x22186
callq 0x5470
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
testq %rax, %rax
je 0x182f4
movq %rax, %r15
leaq 0x10(%rsp), %r12
movq %r12, %rdi
movl $0x21, %esi
movq %rax, %rdx
callq 0x5270
testq %rax, %rax
je 0x182ec
movq %r15, %rdi
callq 0x5130
leaq 0x8(%rsp), %r13
movq %r12, %rdi
movq %r13, %rsi
movl %r14d, %edx
callq 0x52e0
cmpq %r12, (%r13)
je 0x182ec
movq %rax, %r14
leaq 0x12148(%rip), %rax     # 0x2a3d0
cmpl $0x0, (%rax)
je 0x182e7
movslq %r14d, %r15
movq 0x11d29(%rip), %rax     # 0x29fc0
movq (%rax), %r12
callq 0xea3b
leaq 0xabb2(%rip), %rsi      # 0x22e58
movq %r12, %rdi
movq %rax, %rdx
movq %rbx, %rcx
movq %r15, %r8
xorl %eax, %eax
callq 0x52c0
leaq 0x129e8(%rip), %rax     # 0x2aca8
movq (%rax), %r12
testq %r12, %r12
je 0x182e7
callq 0xea3b
leaq 0xab84(%rip), %rsi      # 0x22e58
movq %r12, %rdi
movq %rax, %rdx
movq %rbx, %rcx
movq %r15, %r8
xorl %eax, %eax
callq 0x52c0
movl %r14d, %ebp
jmp 0x182f4
movq %r15, %rdi
callq 0x5130
movl %ebp, %eax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/Carton32[P]quectel-CM/device.c
// Function: conf_get_val
static int conf_get_val(const char *fname, const char *key)
{
    char buff[128] = {'\0'};
    FILE *fp = fopen(fname, "r");
    if (!fp)
        return CM_INVALID_VAL;

    while (fgets(buff, sizeof(buff)-1, fp)) {
        char prefix[128] = {'\0'};
        char tail[128] = {'\0'};
        /* To eliminate cppcheck warnning: Assume string length is no more than 15 */
        sscanf(buff, "%15[^=]=%15s", prefix, tail);
        if (!strncasecmp(prefix, key, strlen(key))) {
            fclose(fp);
            return atoi(tail);
        }
    }

    fclose(fp);
    return CM_INVALID_VAL;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x188, %rsp            # imm = 0x188
movq %rsi, %rbx
xorps %xmm0, %xmm0
movaps %xmm0, 0xf0(%rsp)
movaps %xmm0, 0xe0(%rsp)
movaps %xmm0, 0xd0(%rsp)
movaps %xmm0, 0xc0(%rsp)
movaps %xmm0, 0xb0(%rsp)
movaps %xmm0, 0xa0(%rsp)
movaps %xmm0, 0x90(%rsp)
movaps %xmm0, 0x80(%rsp)
leaq 0x9e23(%rip), %rsi      # 0x22186
callq 0x5470
movq %rax, %r14
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
testq %r14, %r14
je 0x18480
leaq 0x80(%rsp), %rdi
movl $0x7f, %esi
movq %r14, %rdx
callq 0x5270
testq %rax, %rax
je 0x18461
leaq 0xabab(%rip), %r15      # 0x22f49
leaq 0x80(%rsp), %r12
leaq 0x100(%rsp), %r13
movq %rsp, %rbp
xorps %xmm0, %xmm0
movaps %xmm0, 0x170(%rsp)
movaps %xmm0, 0x160(%rsp)
movaps %xmm0, 0x150(%rsp)
movaps %xmm0, 0x140(%rsp)
movaps %xmm0, 0x130(%rsp)
movaps %xmm0, 0x120(%rsp)
movaps %xmm0, 0x110(%rsp)
movaps %xmm0, 0x100(%rsp)
movaps %xmm0, 0x70(%rsp)
movaps %xmm0, 0x60(%rsp)
movaps %xmm0, 0x50(%rsp)
movaps %xmm0, 0x40(%rsp)
movaps %xmm0, 0x30(%rsp)
movaps %xmm0, 0x20(%rsp)
movaps %xmm0, 0x10(%rsp)
movaps %xmm0, (%rsp)
movq %r12, %rdi
movq %r15, %rsi
movq %r13, %rdx
movq %rbp, %rcx
xorl %eax, %eax
callq 0x5390
movq %rbx, %rdi
callq 0x5160
movq %r13, %rdi
movq %rbx, %rsi
movq %rax, %rdx
callq 0x5370
testl %eax, %eax
je 0x18470
movq %r12, %rdi
movl $0x7f, %esi
movq %r14, %rdx
callq 0x5270
testq %rax, %rax
jne 0x183b1
movq %r14, %rdi
callq 0x5130
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
jmp 0x18480
movq %r14, %rdi
callq 0x5130
movq %rsp, %rdi
callq 0x54b0
addq $0x188, %rsp            # imm = 0x188
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop
// File: /workspace/github_c_makefile_star2_O3/Carton32[P]quectel-CM/atc.c
// Function: requestBaseBandVersion
static int requestBaseBandVersion(PROFILE_T *profile) {
    int retVal = -1;
    int err;
    ATResponse *p_response = NULL;

    (void)profile;

    err = at_send_command_multiline("AT+CGMR", "\0", &p_response);
    if (at_response_error(err, p_response))
        goto exit;

    if (p_response->p_intermediates && p_response->p_intermediates->line) {
        strncpy(profile->BaseBandVersion, p_response->p_intermediates->line, sizeof(profile->BaseBandVersion));
        retVal = 0;
    }

exit:
    safe_at_response_free(p_response);
    return retVal;
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
subq $0x10, %rsp
movq %rdi, %r14
leaq 0x8(%rsp), %rbx
movq $0x0, (%rbx)
leaq 0xa570(%rip), %rdi      # 0x23094
leaq 0xa455(%rip), %rsi      # 0x22f80
movq %rbx, %rdx
callq 0x1b08f
testl %eax, %eax
setne %al
movq (%rbx), %rbx
testq %rbx, %rbx
sete %cl
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
orb %al, %cl
je 0x18b51
testq %rbx, %rbx
jne 0x18b85
jmp 0x18b8d
cmpq $0x0, 0x8(%rbx)
je 0x18b85
cmpl $0x0, (%rbx)
je 0x18b85
movq 0x10(%rbx), %rax
testq %rax, %rax
je 0x18b85
movq 0x8(%rax), %rsi
testq %rsi, %rsi
je 0x18b85
addq $0x216, %r14            # imm = 0x216
movl $0x40, %edx
movq %r14, %rdi
callq 0x5080
xorl %ebp, %ebp
movq %rbx, %rdi
callq 0x1aeb5
movl %ebp, %eax
addq $0x10, %rsp
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/Carton32[P]quectel-CM/atc.c
// Function: requestEnterSimPin
static int requestEnterSimPin(const char *pPinCode) {
    int retVal = -1;
    int err;
    ATResponse *p_response = NULL;
    char *cmd = NULL;

    asprintf(&cmd, "AT+CPIN=%s", pPinCode);
    err = at_send_command(cmd, NULL);
    safe_free(cmd);

    if (!at_response_error(err, p_response)) {
        retVal = 0;
    }

    safe_at_response_free(p_response);
    return retVal;
}

// Assembly:
pushq %rbx
subq $0x10, %rsp
movq %rdi, %rdx
leaq 0x8(%rsp), %rbx
movq $0x0, (%rbx)
leaq 0xa3c6(%rip), %rsi      # 0x230c7
movq %rbx, %rdi
xorl %eax, %eax
callq 0x53b0
movq (%rbx), %rdi
xorl %esi, %esi
callq 0x1aefe
movq (%rbx), %rdi
testq %rdi, %rdi
je 0x18d22
callq 0x5040
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
addq $0x10, %rsp
popq %rbx
retq
// File: /workspace/github_c_makefile_star2_O3/Carton32[P]quectel-CM/atc.c
// Function: requestDeactivateDefaultPDP
static int requestDeactivateDefaultPDP(PROFILE_T *profile, int curIpFamily) {
    char *cmd = NULL;
    int pdp = profile->pdp;

    (void)curIpFamily;

    if (asr_style_atc)
        asprintf(&cmd, "AT+QNETDEVCTL=0,%d,%d", pdp, 0);
    else
        asprintf(&cmd, "AT+QNETDEVCTL=%d,0,%d", pdp, 0);
    at_send_command(cmd, NULL);
    safe_free(cmd);

    //dbg_time("%s err=%d", __func__, err);
    return 0;
}

// Assembly:
pushq %rbx
subq $0x10, %rsp
leaq 0x8(%rsp), %rbx
movq $0x0, (%rbx)
movl 0x48(%rdi), %edx
leaq 0x96a4(%rip), %rax      # 0x232cb
leaq 0x96b3(%rip), %rsi      # 0x232e1
cmpb $0x0, 0x12307(%rip)     # 0x2bf3c
cmovneq %rax, %rsi
movq %rbx, %rdi
xorl %ecx, %ecx
xorl %eax, %eax
callq 0x53b0
movq (%rbx), %rdi
xorl %esi, %esi
callq 0x1aefe
movq (%rbx), %rdi
testq %rdi, %rdi
je 0x19c5c
callq 0x5040
xorl %eax, %eax
addq $0x10, %rsp
popq %rbx
retq
// File: /workspace/github_c_makefile_star2_O3/Carton32[P]quectel-CM/atc.c
// Function: requestGetICCID
static int requestGetICCID(void) {
    int retVal = -1;
    int err;
    ATResponse *p_response = NULL;
    char *iccid;

    err = at_send_command_singleline("AT+QCCID", "+QCCID:", &p_response);
    if (at_response_error(err, p_response)) goto _error;
    if (!p_response->p_intermediates || !p_response->p_intermediates->line) goto _error;

    err = at_tok_scanf(p_response->p_intermediates->line, "%s", &iccid);
    if (err != 1) goto _error;

    if (iccid && iccid[0]) {
        dbg_time("%s %s", __func__, iccid);
        retVal = 0;
    }

_error:
    safe_at_response_free(p_response);
    return retVal;
}

// Assembly:
pushq %r14
pushq %rbx
subq $0x18, %rsp
leaq 0x10(%rsp), %rbx
movq $0x0, (%rbx)
leaq 0x8f7b(%rip), %rdi      # 0x233f8
leaq 0x8f7d(%rip), %rsi      # 0x23401
movq %rbx, %rdx
callq 0x1afa9
testl %eax, %eax
setne %al
movq (%rbx), %rdi
testq %rdi, %rdi
sete %cl
orb %al, %cl
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
jne 0x1a572
cmpq $0x0, 0x8(%rdi)
je 0x1a56d
cmpl $0x0, (%rdi)
je 0x1a56d
movq 0x10(%rdi), %rax
testq %rax, %rax
je 0x1a56d
movq 0x8(%rax), %rdi
testq %rdi, %rdi
je 0x1a56d
leaq 0x8951(%rip), %rsi      # 0x22e2d
leaq 0x8(%rsp), %r14
movq %r14, %rdx
xorl %eax, %eax
callq 0x1bb39
cmpl $0x1, %eax
sete %cl
movq (%r14), %rax
testq %rax, %rax
setne %dl
andb %cl, %dl
cmpb $0x1, %dl
jne 0x1a56d
cmpb $0x0, (%rax)
je 0x1a56d
movq 0xfab3(%rip), %rax      # 0x29fc0
movq (%rax), %r14
callq 0xea3b
movq 0x8(%rsp), %r8
leaq 0x629f(%rip), %rsi      # 0x207c0
leaq 0x8ee1(%rip), %rcx      # 0x23409
xorl %ebx, %ebx
movq %r14, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0x52c0
leaq 0x1076a(%rip), %rax     # 0x2aca8
movq (%rax), %r14
testq %r14, %r14
je 0x1a56d
callq 0xea3b
movq 0x8(%rsp), %r8
leaq 0x6269(%rip), %rsi      # 0x207c0
leaq 0x8eab(%rip), %rcx      # 0x23409
xorl %ebx, %ebx
movq %r14, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0x52c0
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x1a57c
callq 0x1aeb5
movl %ebx, %eax
addq $0x18, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O3/Carton32[P]quectel-CM/atc.c
// Function: requestGetIMSI
static int requestGetIMSI(void) {
    int retVal = -1;
    int err;
    ATResponse *p_response = NULL;
    char *imsi;

    err = at_send_command_numeric("AT+CIMI", &p_response);
    if (at_response_error(err, p_response)) goto _error;
    if (!p_response->p_intermediates || !p_response->p_intermediates->line) goto _error;

    imsi = p_response->p_intermediates->line;
    if (imsi) {
        dbg_time("%s %s", __func__, imsi);
        retVal = 0;
    }

_error:
    safe_at_response_free(p_response);
    return retVal;
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
subq $0x10, %rsp
leaq 0x8(%rsp), %rbx
movq $0x0, (%rbx)
leaq 0x8e77(%rip), %rdi      # 0x23419
movq %rbx, %rsi
callq 0x1aff9
testl %eax, %eax
setne %al
movq (%rbx), %rdi
testq %rdi, %rdi
sete %cl
orb %al, %cl
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
jne 0x1a64b
cmpq $0x0, 0x8(%rdi)
je 0x1a646
cmpl $0x0, (%rdi)
je 0x1a646
movq 0x10(%rdi), %rax
testq %rax, %rax
je 0x1a646
movq 0x8(%rax), %r14
testq %r14, %r14
je 0x1a646
movq 0xf9d6(%rip), %rax      # 0x29fc0
movq (%rax), %r15
callq 0xea3b
leaq 0x61c7(%rip), %rsi      # 0x207c0
leaq 0x8e21(%rip), %rcx      # 0x23421
xorl %ebx, %ebx
movq %r15, %rdi
movq %rax, %rdx
movq %r14, %r8
xorl %eax, %eax
callq 0x52c0
leaq 0x1068f(%rip), %rax     # 0x2aca8
movq (%rax), %r15
testq %r15, %r15
je 0x1a646
callq 0xea3b
leaq 0x6193(%rip), %rsi      # 0x207c0
leaq 0x8ded(%rip), %rcx      # 0x23421
xorl %ebx, %ebx
movq %r15, %rdi
movq %rax, %rdx
movq %r14, %r8
xorl %eax, %eax
callq 0x52c0
movq 0x8(%rsp), %rdi
testq %rdi, %rdi
je 0x1a655
callq 0x1aeb5
movl %ebx, %eax
addq $0x10, %rsp
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O3/Carton32[P]quectel-CM/atc.c
// Function: onUnsolicited
static void onUnsolicited (const char *s, const char *sms_pdu)
{
    (void)sms_pdu;

    if (strStartsWith(s, "+QNETDEVSTATUS:")) {
        qmidevice_send_event_to_main(RIL_UNSOL_DATA_CALL_LIST_CHANGED);
    }
    else if (strStartsWith(s, "+CGREG:")
        || strStartsWith(s, "+CEREG:")
        || strStartsWith(s, "+C5GREG:")) {
        qmidevice_send_event_to_main(RIL_UNSOL_RESPONSE_VOICE_NETWORK_STATE_CHANGED);
    }
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %r14
leaq 0x899d(%rip), %rsi      # 0x2300c
callq 0x1a978
movl $0x1005, %ebx           # imm = 0x1005
testl %eax, %eax
jne 0x1a6bb
leaq 0x89e5(%rip), %rsi      # 0x23069
movq %r14, %rdi
callq 0x1a978
movl $0x1004, %ebx           # imm = 0x1004
testl %eax, %eax
jne 0x1a6bb
leaq 0x89d5(%rip), %rsi      # 0x23071
movq %r14, %rdi
callq 0x1a978
testl %eax, %eax
jne 0x1a6bb
leaq 0x89ca(%rip), %rsi      # 0x23079
movq %r14, %rdi
callq 0x1a978
testl %eax, %eax
je 0x1a6c9
movl %ebx, %edi
addq $0x8, %rsp
popq %rbx
popq %r14
jmp 0x7354
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O3/Carton32[P]quectel-CM/atchannel.c
// Function: strStartsWith
int strStartsWith(const char *line, const char *prefix)
{
    for ( ; *line != '\0' && *prefix != '\0' ; line++, prefix++) {
        if (*line != *prefix) {
            return 0;
        }
    }

    return *prefix == '\0';
}

// Assembly:
movb (%rdi), %al
testb %al, %al
je 0x1a997
incq %rdi
movb (%rsi), %cl
testb %cl, %cl
je 0x1a997
cmpb %cl, %al
jne 0x1a9a0
incq %rsi
movb (%rdi), %al
incq %rdi
testb %al, %al
jne 0x1a981
xorl %eax, %eax
cmpb $0x0, (%rsi)
sete %al
retq
xorl %eax, %eax
retq
// File: /workspace/github_c_makefile_star2_O3/Carton32[P]quectel-CM/atchannel.c
// Function: at_open
int at_open(int fd, ATUnsolHandler h)
{
    int ret;
    pthread_attr_t attr;

    s_fd = fd;
    s_unsolHandler = h;
    s_readerClosed = 0;

    s_responsePrefix = NULL;
    s_smsPDU = NULL;
    sp_response = NULL;
    
    pthread_attr_init (&attr);
    pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);

    ret = pthread_create(&s_tid_reader, &attr, readerLoop, NULL);

    if (ret < 0) {
        LOGE("readerLoop create fail!");
        perror ("pthread_create\n");
        return -1;
    }

    return 0;
}

// Assembly:
pushq %r14
pushq %rbx
subq $0x38, %rsp
movl %edi, 0xf960(%rip)      # 0x2a310
movq %rsi, 0x11599(%rip)     # 0x2bf50
movb $0x0, 0x1159a(%rip)     # 0x2bf58
xorl %ebx, %ebx
movq %rbx, 0x11599(%rip)     # 0x2bf60
movq %rbx, 0x1159a(%rip)     # 0x2bf68
movq %rbx, 0x1159b(%rip)     # 0x2bf70
movq %rsp, %r14
movq %r14, %rdi
callq 0x5260
movq %r14, %rdi
movl $0x1, %esi
callq 0x5330
leaq 0x11584(%rip), %rdi     # 0x2bf78
leaq 0x24(%rip), %rdx        # 0x1aa1f
movq %r14, %rsi
xorl %ecx, %ecx
callq 0x53d0
testl %eax, %eax
js 0x1aa13
movl %ebx, %eax
addq $0x38, %rsp
popq %rbx
popq %r14
retq
callq 0x55c0
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
jmp 0x1aa09
// File: /workspace/github_c_makefile_star2_O3/Carton32[P]quectel-CM/atchannel.c
// Function: at_close
void at_close()
{
    dbg_time("at_close");
    if (s_fd >= 0) {
        close(s_fd);
    }
    s_fd = -1;

    pthread_mutex_lock(&cm_command_mutex);

    s_readerClosed = 1;

    pthread_cond_signal(&cm_command_cond);

    pthread_mutex_unlock(&cm_command_mutex);

    /* the reader thread should eventually die */
}

// Assembly:
pushq %rbx
movq 0xf193(%rip), %rax      # 0x29fc0
movq (%rax), %rbx
callq 0xea3b
leaq 0x8632(%rip), %rsi      # 0x2346e
movq %rbx, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0x52c0
leaq 0xfe58(%rip), %rax      # 0x2aca8
movq (%rax), %rbx
testq %rbx, %rbx
je 0x1ae71
callq 0xea3b
leaq 0x860a(%rip), %rsi      # 0x2346e
movq %rbx, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0x52c0
movl 0xf499(%rip), %edi      # 0x2a310
testl %edi, %edi
js 0x1ae80
callq 0x5230
movl $0xffffffff, 0xf486(%rip) # imm = 0xFFFFFFFF
leaq 0xfdbf(%rip), %rbx      # 0x2ac50
movq %rbx, %rdi
callq 0x5560
movb $0x1, 0x110b8(%rip)     # 0x2bf58
leaq 0xfdd1(%rip), %rdi      # 0x2ac78
callq 0x5280
movq %rbx, %rdi
popq %rbx
jmp 0x5340
// File: /workspace/github_c_makefile_star2_O3/Carton32[P]quectel-CM/atchannel.c
// Function: at_response_free
void at_response_free(ATResponse *p_response)
{
    ATLine *p_line;

    if (p_response == NULL) return;

    p_line = p_response->p_intermediates;

    while (p_line != NULL) {
        ATLine *p_toFree;

        p_toFree = p_line;
        p_line = p_line->p_next;

        free(p_toFree->line);
        free(p_toFree);
    }

    free (p_response->finalResponse);
    free (p_response);
}

// Assembly:
testq %rdi, %rdi
je 0x1aefd
pushq %r15
pushq %r14
pushq %rbx
movq %rdi, %rbx
movq 0x10(%rdi), %r14
testq %r14, %r14
je 0x1aee7
movq (%r14), %r15
movq 0x8(%r14), %rdi
callq 0x5040
movq %r14, %rdi
callq 0x5040
movq %r15, %r14
testq %r15, %r15
jne 0x1aecb
movq 0x8(%rbx), %rdi
callq 0x5040
movq %rbx, %rdi
popq %rbx
popq %r14
popq %r15
jmp 0x5040
retq
// File: /workspace/github_c_makefile_star2_O3/Carton32[P]quectel-CM/atchannel.c
// Function: at_send_command_full
static int at_send_command_full (const char *command, ATCommandType type,
                    const char *responsePrefix, const char *smspdu,
                    long long timeoutMsec, ATResponse **pp_outResponse)
{
    int err;

    if (0 != pthread_equal(s_tid_reader, pthread_self())) {
        /* cannot be called from reader thread */
        return AT_ERROR_INVALID_THREAD;
    }

    pthread_mutex_lock(&cm_command_mutex);

    err = at_send_command_full_nolock(command, type,
                    responsePrefix, smspdu,
                    timeoutMsec, pp_outResponse);

    pthread_mutex_unlock(&cm_command_mutex);

    if (err == AT_ERROR_TIMEOUT && s_onTimeout != NULL) {
        s_onTimeout();
    }

    return err;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %r8, %rbx
movq %rcx, %r14
movq %rdx, %r15
movl %esi, %ebp
movq %rdi, %r12
movq 0x1104f(%rip), %r13     # 0x2bf78
callq 0x5400
movq %r13, %rdi
movq %rax, %rsi
callq 0x53f0
movl $0xfffffffb, %r13d      # imm = 0xFFFFFFFB
testl %eax, %eax
jne 0x1af97
leaq 0xfd06(%rip), %rdi      # 0x2ac50
callq 0x5560
movq %r12, %rdi
movl %ebp, %esi
movq %r15, %rdx
movq %r14, %rcx
xorl %r8d, %r8d
movq %rbx, %r9
callq 0x1b179
movl %eax, %r13d
leaq 0xfce1(%rip), %rdi      # 0x2ac50
callq 0x5340
cmpl $-0x4, %r13d
sete %cl
movq 0x1100e(%rip), %rax     # 0x2bf90
testq %rax, %rax
setne %dl
andb %cl, %dl
cmpb $0x1, %dl
jne 0x1af97
callq *%rax
movl $0xfffffffc, %r13d      # imm = 0xFFFFFFFC
movl %r13d, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/Carton32[P]quectel-CM/atchannel.c
// Function: at_send_command_singleline
int at_send_command_singleline (const char *command,
                                const char *responsePrefix,
                                 ATResponse **pp_outResponse)
{
    int err;

    err = at_send_command_full (command, SINGLELINE, responsePrefix,
                                    NULL, 0, pp_outResponse);

    if (err == 0 && pp_outResponse != NULL
        && (*pp_outResponse)->success > 0
        && (*pp_outResponse)->p_intermediates == NULL
    ) {
        /* successful command must have an intermediate response */
        at_response_free(*pp_outResponse);
        *pp_outResponse = NULL;
        return AT_ERROR_INVALID_RESPONSE;
    }

    return err;
}

// Assembly:
pushq %rbx
movq %rdx, %rbx
movq %rsi, %rdx
movl $0x2, %esi
xorl %ecx, %ecx
movq %rbx, %r8
callq 0x1af09
testl %eax, %eax
setne %cl
testq %rbx, %rbx
sete %dl
orb %cl, %dl
jne 0x1aff7
movq (%rbx), %rdi
cmpl $0x0, (%rdi)
jle 0x1aff5
cmpq $0x0, 0x10(%rdi)
movl $0x0, %eax
jne 0x1aff7
callq 0x1aeb5
movq $0x0, (%rbx)
movl $0xfffffffa, %eax       # imm = 0xFFFFFFFA
jmp 0x1aff7
xorl %eax, %eax
popq %rbx
retq
// File: /workspace/github_c_makefile_star2_O3/Carton32[P]quectel-CM/atchannel.c
// Function: at_send_command_numeric
int at_send_command_numeric (const char *command,
                                 ATResponse **pp_outResponse)
{
    int err;

    err = at_send_command_full (command, NUMERIC, NULL,
                                    NULL, 0, pp_outResponse);

    if (err == 0 && pp_outResponse != NULL
        && (*pp_outResponse)->success > 0
        && (*pp_outResponse)->p_intermediates == NULL
    ) {
        /* successful command must have an intermediate response */
        at_response_free(*pp_outResponse);
        *pp_outResponse = NULL;
        return AT_ERROR_INVALID_RESPONSE;
    }

    return err;
}

// Assembly:
pushq %rbx
movq %rsi, %rbx
movl $0x1, %esi
xorl %edx, %edx
xorl %ecx, %ecx
movq %rbx, %r8
callq 0x1af09
testl %eax, %eax
setne %cl
testq %rbx, %rbx
sete %dl
orb %cl, %dl
jne 0x1b046
movq (%rbx), %rdi
cmpl $0x0, (%rdi)
jle 0x1b044
cmpq $0x0, 0x10(%rdi)
movl $0x0, %eax
jne 0x1b046
callq 0x1aeb5
movq $0x0, (%rbx)
movl $0xfffffffa, %eax       # imm = 0xFFFFFFFA
jmp 0x1b046
xorl %eax, %eax
popq %rbx
retq
// File: /workspace/github_c_makefile_star2_O3/Carton32[P]quectel-CM/atchannel.c
// Function: at_send_command_sms
int at_send_command_sms (const char *command,
                                const char *pdu,
                                const char *responsePrefix,
                                 ATResponse **pp_outResponse)
{
    int err;

    err = at_send_command_full (command, SINGLELINE, responsePrefix,
                                    pdu, 0, pp_outResponse);

    if (err == 0 && pp_outResponse != NULL
        && (*pp_outResponse)->success > 0
        && (*pp_outResponse)->p_intermediates == NULL
    ) {
        /* successful command must have an intermediate response */
        at_response_free(*pp_outResponse);
        *pp_outResponse = NULL;
        return AT_ERROR_INVALID_RESPONSE;
    }

    return err;
}

// Assembly:
pushq %rbx
movq %rcx, %rbx
movq %rsi, %rcx
movl $0x2, %esi
movq %rbx, %r8
callq 0x1af09
testl %eax, %eax
setne %cl
testq %rbx, %rbx
sete %dl
orb %cl, %dl
jne 0x1b08d
movq (%rbx), %rdi
xorl %eax, %eax
cmpl $0x0, (%rdi)
jle 0x1b08d
cmpq $0x0, 0x10(%rdi)
jne 0x1b08d
callq 0x1aeb5
movq $0x0, (%rbx)
movl $0xfffffffa, %eax       # imm = 0xFFFFFFFA
popq %rbx
retq
// File: /workspace/github_c_makefile_star2_O3/Carton32[P]quectel-CM/atchannel.c
// Function: at_handshake
int at_handshake()
{
    int i;
    int err = 0;

    if (0 != pthread_equal(s_tid_reader, pthread_self())) {
        /* cannot be called from reader thread */
        return AT_ERROR_INVALID_THREAD;
    }

    pthread_mutex_lock(&cm_command_mutex);

    for (i = 0 ; i < HANDSHAKE_RETRY_COUNT ; i++) {
        /* some stacks start with verbose off */
        err = at_send_command_full_nolock ("ATE0Q0V1", NO_RESULT,
                    NULL, NULL, HANDSHAKE_TIMEOUT_MSEC, NULL);

        if (err == 0) {
            break;
        }
    }

    pthread_mutex_unlock(&cm_command_mutex);

    if (err == 0) {
        /* pause for a bit to let the input buffer drain any unmatched OK's
           (they will appear as extraneous unsolicited responses) */

        sleepMsec(HANDSHAKE_TIMEOUT_MSEC);
    }

    return err;
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
subq $0x10, %rsp
movq 0x10ea9(%rip), %rbx     # 0x2bf78
callq 0x5400
movq %rbx, %rdi
movq %rax, %rsi
callq 0x53f0
movl $0xfffffffb, %ebp       # imm = 0xFFFFFFFB
testl %eax, %eax
jne 0x1b16e
leaq 0xfb5d(%rip), %rdi      # 0x2ac50
callq 0x5560
movl $0x8, %r14d
leaq 0x8378(%rip), %rbx      # 0x2347d
movl $0x3e8, %r8d            # imm = 0x3E8
movq %rbx, %rdi
xorl %esi, %esi
xorl %edx, %edx
xorl %ecx, %ecx
xorl %r9d, %r9d
callq 0x1b179
testl %eax, %eax
je 0x1b135
movl %eax, %ebp
decl %r14d
jne 0x1b105
leaq 0xfb22(%rip), %rdi      # 0x2ac50
callq 0x5340
jmp 0x1b16e
leaq 0xfb14(%rip), %rdi      # 0x2ac50
callq 0x5340
movq %rsp, %rbx
movq $0x1, (%rbx)
movq $0x0, 0x8(%rbx)
movq %rbx, %rdi
movq %rbx, %rsi
callq 0x51d0
testl %eax, %eax
jns 0x1b16c
callq 0x5070
cmpl $0x4, (%rax)
je 0x1b153
xorl %ebp, %ebp
movl %ebp, %eax
addq $0x10, %rsp
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/Carton32[P]quectel-CM/atchannel.c
// Function: at_get_cme_error
AT_CME_Error at_get_cme_error(const ATResponse *p_response)
{
    int ret;
    int err;
    char *p_cur;

    if (p_response == NULL)
        return CME_ERROR_NON_CME;

    if (p_response->success > 0) {
        return CME_SUCCESS;
    }

    if (p_response->finalResponse == NULL
        || !strStartsWith(p_response->finalResponse, "+CME ERROR:")
    ) {
        return CME_ERROR_NON_CME;
    }

    p_cur = p_response->finalResponse;
    err = at_tok_start(&p_cur);

    if (err < 0) {
        return CME_ERROR_NON_CME;
    }

    err = at_tok_nextint(&p_cur, &ret);

    if (err < 0) {
        return CME_ERROR_NON_CME;
    }

    return (AT_CME_Error) ret;
}

// Assembly:
testq %rdi, %rdi
je 0x1b480
xorl %eax, %eax
cmpl $0x0, (%rdi)
jle 0x1b43a
retq
movq 0x8(%rdi), %rax
testq %rax, %rax
je 0x1b480
subq $0x18, %rsp
movb (%rax), %sil
testb %sil, %sil
je 0x1b486
xorl %edx, %edx
leaq 0x8039(%rip), %rcx      # 0x23491
leaq 0x8027(%rip), %rdi      # 0x23486
cmpq $0xb, %rdx
je 0x1b48d
cmpb (%rdx,%rdi), %sil
jne 0x1b492
movb 0x1(%rax,%rdx), %sil
incq %rdx
testb %sil, %sil
jne 0x1b45f
addq %rdx, %rdi
movq %rdi, %rcx
jmp 0x1b48d
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
retq
leaq 0x7ff9(%rip), %rcx      # 0x23486
cmpb $0x0, (%rcx)
je 0x1b49c
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
addq $0x18, %rsp
retq
leaq 0x10(%rsp), %rdi
movq %rax, (%rdi)
callq 0x1b96c
movl %eax, %ecx
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
testl %ecx, %ecx
js 0x1b497
leaq 0x10(%rsp), %rdi
leaq 0xc(%rsp), %rsi
callq 0x1b9a4
movl %eax, %ecx
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
testl %ecx, %ecx
js 0x1b497
movl 0xc(%rsp), %eax
jmp 0x1b497
// File: /workspace/github_c_makefile_star2_O3/Carton32[P]quectel-CM/atchannel.c
// Function: writeCtrlZ
static int writeCtrlZ (const char *s)
{
    size_t cur = 0;
    size_t len = strlen(s);
    ssize_t written;

    if (s_fd < 0 || s_readerClosed > 0) {
        return AT_ERROR_CHANNEL_CLOSED;
    }

    LOGD("AT> %s^Z", s);

    AT_DUMP( ">* ", s, strlen(s) );

    /* the main string */
    while (cur < len) {
        do {
            written = write (s_fd, s + cur, len - cur);
        } while (written < 0 && errno == EINTR);

        if (written < 0) {
            return AT_ERROR_GENERIC;
        }

        cur += written;
    }

    /* the ^Z  */

    do {
        written = write (s_fd, "\032" , 1);
    } while ((written < 0 && errno == EINTR) || (written == 0));

    if (written < 0) {
        return AT_ERROR_GENERIC;
    }

    return 0;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
movq %rdi, %rbx
callq 0x5160
cmpl $0x0, 0xeaba(%rip)      # 0x2a310
js 0x1b926
testb $0x1, 0x106f5(%rip)     # 0x2bf58
jne 0x1b926
movq %rax, %r14
movq 0xe74d(%rip), %rax      # 0x29fc0
movq (%rax), %r15
callq 0xea3b
leaq 0x7cf8(%rip), %rsi      # 0x2357a
movq %r15, %rdi
movq %rax, %rdx
movq %rbx, %rcx
xorl %eax, %eax
callq 0x52c0
leaq 0xf40f(%rip), %rax      # 0x2aca8
movq (%rax), %r15
testq %r15, %r15
je 0x1b8bd
callq 0xea3b
leaq 0x7ccd(%rip), %rsi      # 0x2357a
movq %r15, %rdi
movq %rax, %rdx
movq %rbx, %rcx
xorl %eax, %eax
callq 0x52c0
testq %r14, %r14
je 0x1b8f9
xorl %r13d, %r13d
leaq (%rbx,%r13), %r15
movq %r14, %r12
subq %r13, %r12
movl 0xea3b(%rip), %edi      # 0x2a310
movq %r15, %rsi
movq %r12, %rdx
callq 0x5100
testq %rax, %rax
jns 0x1b8f1
callq 0x5070
cmpl $0x4, (%rax)
je 0x1b8cf
jmp 0x1b926
addq %rax, %r13
cmpq %r14, %r13
jb 0x1b8c5
leaq 0x7c89(%rip), %rbx      # 0x23589
movl 0xea0a(%rip), %edi      # 0x2a310
movl $0x1, %edx
movq %rbx, %rsi
callq 0x5100
testq %rax, %rax
js 0x1b91c
je 0x1b900
jmp 0x1b926
callq 0x5070
cmpl $0x4, (%rax)
je 0x1b900
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O3/Carton32[P]quectel-CM/atchannel.c
// Function: addIntermediate
static void addIntermediate(const char *line)
{
    ATLine *p_new;

    p_new = (ATLine  *) malloc(sizeof(ATLine));

    p_new->line = strdup(line);

    /* note: this adds to the head of the list, so the list
       will be in reverse order of lines received. the order is flipped
       again before passing on to the command issuer */
    p_new->p_next = sp_response->p_intermediates;
    sp_response->p_intermediates = p_new;
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %rbx
movl $0x10, %edi
callq 0x5360
movq %rax, %r14
movq %rbx, %rdi
callq 0x5520
movq %rax, 0x8(%r14)
movq 0x10619(%rip), %rax     # 0x2bf70
movq 0x10(%rax), %rcx
movq %rcx, (%r14)
movq %r14, 0x10(%rax)
addq $0x8, %rsp
popq %rbx
popq %r14
retq
nop
// File: /workspace/github_c_makefile_star2_O3/Carton32[P]quectel-CM/at_tok.c
// Function: at_tok_start
int at_tok_start(char **p_cur)
{
    if (*p_cur == NULL) {
        return -1;
    }

    // skip prefix
    // consume "^[^:]:"

    *p_cur = strchr(*p_cur, ':');

    if (*p_cur == NULL) {
        return -1;
    }

    (*p_cur)++;

    return 0;
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %r14
movq (%rdi), %rdi
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
testq %rdi, %rdi
je 0x1b99a
movl $0x3a, %esi
callq 0x5190
movq %rax, (%r14)
testq %rax, %rax
je 0x1b99a
incq %rax
movq %rax, (%r14)
xorl %ebx, %ebx
movl %ebx, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O3/Carton32[P]quectel-CM/at_tok.c
// Function: at_tok_nextint_base
static int at_tok_nextint_base(char **p_cur, int *p_out, int base, int  uns)
{
    char *ret;

    if (*p_cur == NULL) {
        return -1;
    }

    ret = nextTok(p_cur);

    if (ret == NULL) {
        return -1;
    } else {
        long l;
        char *end;

        if (uns)
            l = strtoul(ret, &end, base);
        else
            l = strtol(ret, &end, base);

        *p_out = (int)l;

        if (end == ret) {
            return -1;
        }
    }

    return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x10, %rsp
movl $0xffffffff, %r15d      # imm = 0xFFFFFFFF
cmpq $0x0, (%rdi)
je 0x1ba06
movl %ecx, %r12d
movl %edx, %ebp
movq %rsi, %rbx
callq 0x1ba7a
testq %rax, %rax
je 0x1ba06
movq %rax, %r14
leaq 0x8(%rsp), %rsi
movq %rax, %rdi
movl %ebp, %edx
testl %r12d, %r12d
je 0x1b9f0
callq 0x54a0
jmp 0x1b9f5
callq 0x52e0
movl %eax, (%rbx)
xorl %r15d, %r15d
cmpq %r14, 0x8(%rsp)
sete %r15b
negl %r15d
movl %r15d, %eax
addq $0x10, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/Carton32[P]quectel-CM/at_tok.c
// Function: at_tok_nextbool
int at_tok_nextbool(char **p_cur, char *p_out)
{
    int ret;
    int result;

    ret = at_tok_nextint(p_cur, &result);

    if (ret < 0) {
        return -1;
    }

    // booleans should be 0 or 1
    if (!(result == 0 || result == 1)) {
        return -1;
    }

    if (p_out != NULL) {
        *p_out = (char)result;
    }

    return ret;
}

// Assembly:
pushq %rbx
subq $0x10, %rsp
movq %rsi, %rbx
leaq 0xc(%rsp), %rsi
movl $0xa, %edx
xorl %ecx, %ecx
callq 0x1b9ad
movl %eax, %ecx
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
testl %ecx, %ecx
js 0x1ba58
movl 0xc(%rsp), %ecx
cmpl $0x1, %ecx
ja 0x1ba58
xorl %eax, %eax
testq %rbx, %rbx
je 0x1ba58
movb %cl, (%rbx)
addq $0x10, %rsp
popq %rbx
retq
// File: /workspace/github_c_makefile_star2_O3/Carton32[P]quectel-CM/at_tok.c
// Function: at_tok_count
int at_tok_count(const char *in_line)
{
    int commas = 0;
    const char *p;

    if (!in_line)
        return 0;

    for (p = in_line; *p != '\0' ; p++) {
        if (*p == ',') commas++;
    }

    return commas;
}

// Assembly:
xorl %eax, %eax
testq %rdi, %rdi
je 0x1bb38
movzbl (%rdi), %ecx
cmpl $0x2c, %ecx
je 0x1bb31
testl %ecx, %ecx
jne 0x1bb33
jmp 0x1bb38
incl %eax
incq %rdi
jmp 0x1bb23
retq