LLM4Binary/decompile-bench-makefile huggingface dataset:
// File: /workspace/github_c_makefile_star2_O2/Carton32[P]quectel-CM/mbim-cm.c
// Function: compose_basic_connect_command
static MBIM_MESSAGE_HEADER *compose_basic_connect_command(UINT32 CID, UINT32 CommandType, void *pInformationBuffer, UINT32 InformationBufferLength)
{
    MBIM_COMMAND_MSG_T *pRequest = (MBIM_COMMAND_MSG_T *)mbim_alloc(sizeof(MBIM_COMMAND_MSG_T) + InformationBufferLength);

    if (!pRequest)
        return NULL;

    pRequest->MessageHeader.MessageType = htole32(MBIM_COMMAND_MSG);
    pRequest->MessageHeader.MessageLength = htole32((sizeof(MBIM_COMMAND_MSG_T) + InformationBufferLength));
    pRequest->MessageHeader.TransactionId = htole32(TransactionId++);

    pRequest->FragmentHeader.TotalFragments = htole32(1);
    pRequest->FragmentHeader.CurrentFragment= htole32(0);

    memcpy(pRequest->DeviceServiceId.uuid, str2uuid(UUID_BASIC_CONNECT), 16);

    pRequest->CID = htole32(CID);
    pRequest->CommandType = htole32(CommandType);
    if (InformationBufferLength && pInformationBuffer) {
        pRequest->InformationBufferLength = htole32(InformationBufferLength);
        memcpy(pRequest->InformationBuffer, pInformationBuffer, InformationBufferLength);
    } else {
        pRequest->InformationBufferLength = htole32(0);
    }

    return &pRequest->MessageHeader;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl %ecx, %ebp
movq %rdx, (%rsp)
movl %esi, %r12d
movl %edi, %r13d
movl %ecx, %r14d
leaq 0x30(%r14), %rbx
movq %rbx, %rdi
callq 0x5360
movq %rax, %r15
testq %rax, %rax
je 0x102cc
movl $0x3, (%r15)
movl %ebx, 0x4(%r15)
movl 0x1909e(%rip), %eax     # 0x29308
leal 0x1(%rax), %ecx
movl %ecx, 0x19095(%rip)     # 0x29308
movl %eax, 0x8(%r15)
movq $0x1, 0xc(%r15)
leaq 0xf168(%rip), %rdi      # 0x1f3ee
callq 0x102de
movups 0x1aaa2(%rip), %xmm0    # 0x2ad34
movups %xmm0, 0x14(%r15)
movl %r13d, 0x24(%r15)
movl %r12d, 0x28(%r15)
testl %ebp, %ebp
sete %al
movq (%rsp), %rsi
testq %rsi, %rsi
sete %cl
orb %al, %cl
jne 0x102c7
movl %ebp, 0x2c(%r15)
movq %r15, %rdi
addq $0x30, %rdi
movq %r14, %rdx
callq 0x52f0
jmp 0x102cc
andl $0x0, 0x2c(%r15)
movq %r15, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/Carton32[P]quectel-CM/mbim-cm.c
// Function: str2uuid
static const UUID_T * str2uuid(const char *str) {
    static UUID_T uuid;
    UINT32 d[16];
    char tmp[16*2+4+1];
    unsigned i = 0;

    while (str[i]) {
        tmp[i] = tolower(str[i]);
        i++;
    }
    tmp[i] = '\0';

    sscanf(tmp, "%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x",
        &d[0], &d[1], &d[2], &d[3], &d[4], &d[5], &d[6], &d[7],
        &d[8], &d[9], &d[10], &d[11], &d[12], &d[13], &d[14], &d[15]);

    for (i = 0; i < 16; i++) {
        uuid.uuid[i] = d[i]&0xFF;
    }

    return &uuid;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x68, %rsp
movq %rdi, %rbx
xorl %eax, %eax
movl %eax, %r14d
movsbq (%rbx,%r14), %r15
testq %r15, %r15
je 0x10315
callq 0x5580
movq (%rax), %rax
movb (%rax,%r15,4), %al
movb %al, 0x40(%rsp,%r14)
leal 0x1(%r14), %eax
jmp 0x102f1
movb $0x0, 0x40(%rsp,%r14)
leaq 0x4(%rsp), %rcx
leaq 0x8(%rsp), %r8
leaq 0xc(%rsp), %r9
leaq 0x24(%rsp), %r13
leaq 0x28(%rsp), %rbp
leaq 0x2c(%rsp), %r10
leaq 0x30(%rsp), %r11
leaq 0x34(%rsp), %r14
leaq 0x38(%rsp), %r15
leaq 0x3c(%rsp), %r12
leaq 0xf0bf(%rip), %rsi      # 0x1f413
xorl %ebx, %ebx
leaq 0x40(%rsp), %rdi
movq %rsp, %rdx
xorl %eax, %eax
pushq %r12
pushq %r15
pushq %r14
pushq %r11
pushq %r10
pushq %rbp
pushq %r13
leaq 0x58(%rsp), %r10
pushq %r10
leaq 0x5c(%rsp), %r10
pushq %r10
leaq 0x60(%rsp), %r10
pushq %r10
leaq 0x64(%rsp), %r10
pushq %r10
leaq 0x68(%rsp), %r10
pushq %r10
callq 0x5390
addq $0x60, %rsp
leaq 0x1a994(%rip), %rax     # 0x2ad34
cmpq $0x10, %rbx
je 0x103b1
movb (%rsp,%rbx,4), %cl
movb %cl, (%rbx,%rax)
incq %rbx
jmp 0x103a0
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/Carton32[P]quectel-CM/mbim-cm.c
// Function: char2wchar
static size_t char2wchar(const char *src, size_t src_len, uint8_t *dst, size_t dst_len) {
    size_t i;

    if (src_len > (dst_len/2))
        src_len = (dst_len/2);

    for (i = 0; i < src_len; i++) {
        *dst++ = *src++;
        *dst++ = 0;
    }

    return i*2;
}

// Assembly:
movq %rcx, %rax
shrq %rax
cmpq %rsi, %rax
cmovaeq %rsi, %rax
xorl %ecx, %ecx
cmpq %rcx, %rax
je 0x103e6
movb (%rdi,%rcx), %sil
movb %sil, (%rdx,%rcx,2)
movb $0x0, 0x1(%rdx,%rcx,2)
incq %rcx
jmp 0x103cf
addq %rax, %rax
retq
// File: /workspace/github_c_makefile_star2_O2/Carton32[P]quectel-CM/mbim-cm.c
// Function: mbim_deinit
static int mbim_close_device(void) {
    MBIM_MESSAGE_HEADER *pRequest = NULL;
    MBIM_CLOSE_DONE_T *pCloseDone = NULL;
    int err = 0;

    mbim_debug("%s()", __func__);
    pRequest = compose_close_command();
    err = mbim_send_command(pRequest, (MBIM_COMMAND_DONE_T **)&pCloseDone, mbim_default_timeout);
    mbim_check_err(err, pRequest, pCloseDone);

    err = le32toh(pCloseDone->Status);
    mbim_free(pRequest); mbim_free(pCloseDone);

    return err;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
andq $0x0, 0x10(%rsp)
movq 0x175c7(%rip), %r13     # 0x28fb8
movq (%r13), %rbx
callq 0xe343
leaq 0xe841(%rip), %rsi      # 0x20242
leaq 0xe9b6(%rip), %rcx      # 0x203be
movq %rbx, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0x52c0
leaq 0x1828c(%rip), %r12     # 0x29ca8
movq (%r12), %rbx
testq %rbx, %rbx
je 0x11a45
callq 0xe343
leaq 0xe811(%rip), %rsi      # 0x20242
leaq 0xe986(%rip), %rcx      # 0x203be
movq %rbx, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0x52c0
pushq $0xc
popq %rdi
callq 0x5360
movq %rax, %r14
testq %rax, %rax
je 0x11a75
movabsq $0xc00000002, %rax      # imm = 0xC00000002
movq %rax, (%r14)
movl 0x178a0(%rip), %eax     # 0x29308
leal 0x1(%rax), %ecx
movl %ecx, 0x17897(%rip)     # 0x29308
movl %eax, 0x8(%r14)
leaq 0x10(%rsp), %r15
movq %r14, %rdi
movq %r15, %rsi
movl $0x7530, %edx           # imm = 0x7530
callq 0x103ea
movl %eax, %ebx
movq (%r15), %r15
movq %r15, %rdi
callq 0x1055f
movl %eax, %ebp
testq %r15, %r15
je 0x11abb
testl %ebx, %ebx
jne 0x11abb
testl %ebp, %ebp
jne 0x11abb
movq %r14, %rdi
callq 0x5040
movq %r15, %rdi
callq 0x5040
jmp 0x11b5f
testq %r15, %r15
je 0x11adc
xorl %esi, %esi
cmpl $0x0, 0x19267(%rip)     # 0x2ad30
sete %sil
movq %r15, %rdi
callq 0x10583
movq 0x10(%rsp), %r15
jmp 0x11adf
xorl %r15d, %r15d
movq %r14, %rdi
callq 0x5040
testq %r15, %r15
je 0x11afa
movq %r15, %rdi
callq 0x5040
andq $0x0, 0x10(%rsp)
movq (%r13), %r14
callq 0xe343
movl %ebp, (%rsp)
leaq 0xd894(%rip), %rsi      # 0x1f3a1
leaq 0xe8aa(%rip), %rcx      # 0x203be
movq %r14, %rdi
movq %rax, %rdx
movl $0x6af, %r8d            # imm = 0x6AF
movl %ebx, %r9d
xorl %eax, %eax
callq 0x52c0
movq (%r12), %r14
testq %r14, %r14
je 0x11b5f
callq 0xe343
movl %ebp, (%rsp)
leaq 0xd85f(%rip), %rsi      # 0x1f3a1
leaq 0xe875(%rip), %rcx      # 0x203be
movq %r14, %rdi
movq %rax, %rdx
movl $0x6af, %r8d            # imm = 0x6AF
movl %ebx, %r9d
xorl %eax, %eax
callq 0x52c0
movl 0x1779b(%rip), %edi     # 0x29300
cmpl $-0x1, %edi
je 0x11b7a
callq 0x5230
movl 0x1778f(%rip), %edi     # 0x29304
callq 0x5230
xorl %eax, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/Carton32[P]quectel-CM/mbim-cm.c
// Function: requestSetupDataCall
static int requestSetupDataCall(PROFILE_T *profile, int curIpFamily) {
    int retval;

    (void)curIpFamily;

    if (profile->apn)
        mbim_apn = profile->apn;
    if (profile->user)
        mbim_user = profile->user;
    if (profile->password)
        mbim_passwd = profile->password;
    if (profile->auth)
        mbim_auth = profile->auth;
    if (profile->enable_ipv4)
        mbim_iptype = MBIMContextIPTypeIPv4;
    if (profile->enable_ipv6)
        mbim_iptype = MBIMContextIPTypeIPv6;
    if (profile->enable_ipv4 && profile->enable_ipv6)
        mbim_iptype = MBIMContextIPTypeIPv4AndIPv6;

    retval = mbim_set_connect(1, mbim_sessionID);
    if (retval)
        goto exit;

exit:
    return retval;
}

// Assembly:
movq (%rdi), %rax
testq %rax, %rax
je 0x129b9
movq %rax, 0x1855f(%rip)     # 0x2af18
movq 0x8(%rdi), %rax
testq %rax, %rax
je 0x129c9
movq %rax, 0x18557(%rip)     # 0x2af20
movq 0x10(%rdi), %rax
testq %rax, %rax
je 0x129d9
movq %rax, 0x1854f(%rip)     # 0x2af28
movl 0x18(%rdi), %eax
testl %eax, %eax
je 0x129e6
movl %eax, 0x1854a(%rip)     # 0x2af30
cmpb $0x0, 0x50(%rdi)
movb 0x51(%rdi), %al
je 0x129fd
xorl %ecx, %ecx
testb %al, %al
setne %cl
leal (%rcx,%rcx,2), %eax
incl %eax
jmp 0x12a04
testb %al, %al
je 0x12a0a
pushq $0x2
popq %rax
movl %eax, 0x1852a(%rip)     # 0x2af34
movl 0x18504(%rip), %esi     # 0x2af14
pushq $0x1
popq %rdi
jmp 0x150d5
// File: /workspace/github_c_makefile_star2_O2/Carton32[P]quectel-CM/mbim-cm.c
// Function: mbim_dump_packet_service
static void mbim_dump_packet_service(MBIM_PACKET_SERVICE_INFO_T *pInfo, const char *direction)
{
    mbim_debug("%s NwError = %u", direction, le32toh(pInfo->NwError));
    mbim_debug("%s PacketServiceState = %s", direction, MBIMPacketServiceStateStr(le32toh(pInfo->PacketServiceState)));
    mbim_debug("%s HighestAvailableDataClass = %s", direction, MBIMDataClassStr(le32toh(pInfo->HighestAvailableDataClass)));
    mbim_debug("%s UplinkSpeed = %ld", direction, (long)le64toh(pInfo->UplinkSpeed));
    mbim_debug("%s DownlinkSpeed = %ld", direction, (long)le64toh(pInfo->DownlinkSpeed));
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rsi, %rbx
movq %rdi, %r14
movq 0x14c49(%rip), %r13     # 0x28fb8
movq (%r13), %r15
callq 0xe343
movl (%r14), %r8d
leaq 0xbb6d(%rip), %rsi      # 0x1feef
movq %r15, %rdi
movq %rax, %rdx
movq %rbx, %rcx
xorl %eax, %eax
callq 0x52c0
leaq 0x1590f(%rip), %rbp     # 0x29ca8
movq (%rbp), %r15
testq %r15, %r15
je 0x143c1
callq 0xe343
movl (%r14), %r8d
leaq 0xbb3e(%rip), %rsi      # 0x1feef
movq %r15, %rdi
movq %rax, %rdx
movq %rbx, %rcx
xorl %eax, %eax
callq 0x52c0
movq (%r13), %r15
callq 0xe343
movq %rax, %r12
movl 0x4(%r14), %edi
callq 0x14bea
leaq 0xbc07(%rip), %rsi      # 0x1ffe4
movq %r15, %rdi
movq %r12, %rdx
movq %rbx, %rcx
movq %rax, %r8
xorl %eax, %eax
callq 0x52c0
movq (%rbp), %r15
testq %r15, %r15
je 0x14424
callq 0xe343
movq %rax, %r12
movl 0x4(%r14), %edi
callq 0x14bea
leaq 0xbbd3(%rip), %rsi      # 0x1ffe4
movq %r15, %rdi
movq %r12, %rdx
movq %rbx, %rcx
movq %rax, %r8
xorl %eax, %eax
callq 0x52c0
movq (%r13), %r15
callq 0xe343
movq %rax, %r12
movl 0x8(%r14), %edi
callq 0x14c13
leaq 0xbbc5(%rip), %rsi      # 0x20005
movq %r15, %rdi
movq %r12, %rdx
movq %rbx, %rcx
movq %rax, %r8
xorl %eax, %eax
callq 0x52c0
movq (%rbp), %r15
testq %r15, %r15
je 0x14487
callq 0xe343
movq %rax, %r12
movl 0x8(%r14), %edi
callq 0x14c13
leaq 0xbb91(%rip), %rsi      # 0x20005
movq %r15, %rdi
movq %r12, %rdx
movq %rbx, %rcx
movq %rax, %r8
xorl %eax, %eax
callq 0x52c0
movq (%r13), %r15
callq 0xe343
movq 0xc(%r14), %r8
leaq 0xbb92(%rip), %rsi      # 0x2002d
movq %r15, %rdi
movq %rax, %rdx
movq %rbx, %rcx
xorl %eax, %eax
callq 0x52c0
movq (%rbp), %r15
testq %r15, %r15
je 0x144d4
callq 0xe343
movq 0xc(%r14), %r8
leaq 0xbb69(%rip), %rsi      # 0x2002d
movq %r15, %rdi
movq %rax, %rdx
movq %rbx, %rcx
xorl %eax, %eax
callq 0x52c0
movq (%r13), %r15
callq 0xe343
movq 0x14(%r14), %r8
leaq 0xbb60(%rip), %rsi      # 0x20048
movq %r15, %rdi
movq %rax, %rdx
movq %rbx, %rcx
xorl %eax, %eax
callq 0x52c0
movq (%rbp), %r15
testq %r15, %r15
je 0x1452f
callq 0xe343
movq 0x14(%r14), %r8
leaq 0xbb37(%rip), %rsi      # 0x20048
movq %r15, %rdi
movq %rax, %rdx
movq %rbx, %rcx
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x52c0
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/Carton32[P]quectel-CM/mbim-cm.c
// Function: mbim_dump_uuid_cid
static void mbim_dump_uuid_cid(const UUID_T *pUUID, UINT32 CID, const char *direction) {
    size_t idx;
    const char *uuidStr = uuid2str(pUUID);
    const char *cidStr = "unknow";

    for (idx = 0; idx < (sizeof(uuid_cid_string)/sizeof(uuid_cid_string[0])); idx++) {
        if (!strcmp(uuidStr, uuid_cid_string[idx].uuid) && uuid_cid_string[idx].cid == CID) {
            cidStr = uuid_cid_string[idx].name;
        }
    }

    mbim_debug("%s DeviceServiceId = %s (%s)", direction, DeviceServiceId2str(pUUID), uuidStr);
    mbim_debug("%s CID = %s (%u)", direction, cidStr, le32toh(CID));
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdx, (%rsp)
movl %esi, %ebx
movq %rdi, %r12
callq 0x14a68
leaq 0xad74(%rip), %r15      # 0x1f6a4
pushq $0xc
popq %rbp
leaq 0x13c76(%rip), %r14     # 0x285b0
leaq 0x1647f(%rip), %r13     # 0x2adc0
cmpq $0x37c, %rbp            # imm = 0x37C
je 0x1496d
movq -0xc(%rbp,%r14), %rsi
movq %r13, %rdi
callq 0x52a0
testl %eax, %eax
jne 0x14967
cmpl %ebx, -0x4(%rbp,%r14)
jne 0x14967
movq (%rbp,%r14), %r15
addq $0x14, %rbp
jmp 0x14941
movq 0x14644(%rip), %rax     # 0x28fb8
movq (%rax), %r13
callq 0xe343
movq %rax, %rbp
movq %r12, %rdi
callq 0x14b28
leaq 0xad1d(%rip), %rsi      # 0x1f6ab
leaq 0x1642b(%rip), %r9      # 0x2adc0
movq %r13, %rdi
movq %rbp, %rdx
movq (%rsp), %r14
movq %r14, %rcx
movq %rax, %r8
xorl %eax, %eax
callq 0x52c0
leaq 0x152f5(%rip), %rbp     # 0x29ca8
movq (%rbp), %r13
testq %r13, %r13
je 0x149f4
callq 0xe343
movq %rax, %rbp
movq %r12, %rdi
callq 0x14b28
leaq 0xacd8(%rip), %rsi      # 0x1f6ab
leaq 0x163e6(%rip), %r9      # 0x2adc0
movq %r13, %rdi
movq %rbp, %rdx
leaq 0x152c1(%rip), %rbp     # 0x29ca8
movq %r14, %rcx
movq %rax, %r8
xorl %eax, %eax
callq 0x52c0
movq 0x145bd(%rip), %rax     # 0x28fb8
movq (%rax), %r12
callq 0xe343
leaq 0xacc4(%rip), %rsi      # 0x1f6ce
movq %r12, %rdi
movq %rax, %rdx
movq %r14, %rcx
movq %r15, %r8
movl %ebx, %r9d
xorl %eax, %eax
callq 0x52c0
movq (%rbp), %r12
testq %r12, %r12
je 0x14a59
callq 0xe343
leaq 0xac99(%rip), %rsi      # 0x1f6ce
movq %r12, %rdi
movq %rax, %rdx
movq %r14, %rcx
movq %r15, %r8
movl %ebx, %r9d
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x52c0
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/Carton32[P]quectel-CM/mbim-cm.c
// Function: uuid2str
static const char * uuid2str(const UUID_T *pUUID) {
    static char str[16*2+4+1];
    const UINT8 *d = pUUID->uuid;

    snprintf(str, sizeof(str), "%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x",
        d[0], d[1], d[2], d[3], d[4], d[5], d[6], d[7],
        d[8], d[9], d[10], d[11], d[12], d[13], d[14], d[15]);

    return str;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movzbl (%rdi), %ecx
movzbl 0x1(%rdi), %r8d
movzbl 0x2(%rdi), %r9d
movzbl 0x3(%rdi), %eax
movq %rax, 0x20(%rsp)
movzbl 0x4(%rdi), %eax
movq %rax, 0x18(%rsp)
movzbl 0x5(%rdi), %eax
movq %rax, 0x10(%rsp)
movzbl 0x6(%rdi), %eax
movq %rax, 0x8(%rsp)
movzbl 0x7(%rdi), %eax
movq %rax, (%rsp)
movzbl 0x8(%rdi), %r12d
movzbl 0x9(%rdi), %r13d
movzbl 0xa(%rdi), %ebp
movzbl 0xb(%rdi), %r10d
movzbl 0xc(%rdi), %r11d
movzbl 0xd(%rdi), %ebx
movzbl 0xe(%rdi), %r14d
movzbl 0xf(%rdi), %r15d
subq $0x8, %rsp
leaq 0x162e0(%rip), %rdi     # 0x2adc0
leaq 0xa92c(%rip), %rdx      # 0x1f413
pushq $0x25
popq %rsi
xorl %eax, %eax
pushq %r15
pushq %r14
pushq %rbx
pushq %r11
pushq %r10
pushq %rbp
pushq %r13
pushq %r12
pushq 0x48(%rsp)
pushq 0x58(%rsp)
pushq 0x68(%rsp)
pushq 0x78(%rsp)
pushq 0x88(%rsp)
callq 0x51c0
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/Carton32[P]quectel-CM/mbim-cm.c
// Function: mbim_get_segment
static const char *mbim_get_segment(void *_pMsg, UINT32 offset, UINT32 len)
{
    int idx;
    static char buff[256] = {'\0'};
    UINT8 *pMsg = (UINT8*)_pMsg;

    for (idx = 0; idx < (int)(len/2); idx++)
        buff[idx] = pMsg[offset+idx*2];
    buff[idx] = '\0';
    return buff;
}

// Assembly:
shrl %edx
xorl %eax, %eax
leaq 0x1617f(%rip), %rcx     # 0x2adf0
cmpq %rax, %rdx
je 0x14c89
movl %esi, %r8d
movb (%rdi,%r8), %r8b
movb %r8b, (%rax,%rcx)
incq %rax
addl $0x2, %esi
jmp 0x14c71
movb $0x0, (%rdx,%rcx)
retq
// File: /workspace/github_c_makefile_star2_O2/Carton32[P]quectel-CM/mbim-cm.c
// Function: wchar2char
static void wchar2char(const char *src, size_t src_size, char *dst, size_t dst_len) {
    size_t i;
    
    for (i = 0; i < (dst_len-1) && i < (src_size/2); i++)
        dst[i] = src[i*2];
    dst[i] = 0;
}

// Assembly:
shrq %rsi
cmpq $0x1f, %rsi
pushq $0x1f
popq %rax
cmovbq %rsi, %rax
xorl %ecx, %ecx
cmpq %rcx, %rax
je 0x14fbf
movb (%rdi,%rcx,2), %sil
movb %sil, (%rdx,%rcx)
incq %rcx
jmp 0x14fad
movb $0x0, (%rdx,%rax)
retq
// File: /workspace/github_c_makefile_star2_O2/Carton32[P]quectel-CM/device.c
// Function: dir_get_child
static int dir_get_child(const char *dirname, char *buff, unsigned bufsize, const char *prefix)
{
    struct dirent *entptr = NULL;
    DIR *dirptr;

    buff[0] = 0;

    dirptr = opendir(dirname);
    if (!dirptr)
        return -1;

    while ((entptr = readdir(dirptr))) {
        if (entptr->d_name[0] == '.')
            continue;
        if (prefix && strlen(prefix) && strncmp(entptr->d_name, prefix, strlen(prefix)))
            continue;
        snprintf(buff, bufsize, "%s", entptr->d_name);
        break;
    }
    closedir(dirptr);

    return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movq %rcx, %r15
movl %edx, %ebp
movq %rsi, %r14
movb $0x0, (%rsi)
callq 0x5140
testq %rax, %rax
je 0x160e5
movq %rax, %rbx
movq %rbx, %rdi
callq 0x5320
testq %rax, %rax
je 0x160d5
movq %rax, %r12
cmpb $0x2e, 0x13(%rax)
je 0x16081
addq $0x13, %r12
testq %r15, %r15
je 0x160bf
movq %r15, %rdi
callq 0x5160
testq %rax, %rax
je 0x160bf
movq %r12, %rdi
movq %r15, %rsi
movq %rax, %rdx
callq 0x5090
testl %eax, %eax
jne 0x16081
movl %ebp, %esi
leaq 0xad85(%rip), %rdx      # 0x20e4d
movq %r14, %rdi
movq %r12, %rcx
xorl %eax, %eax
callq 0x51c0
movq %rbx, %rdi
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
jmp 0x5240
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/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 0x16397
movq %rdi, %rbx
cmpl $0xe0, %eax
je 0x16306
cmpl $0x2, %eax
jne 0x1631c
movl 0x1e1(%rbx), %eax
cmpl $0x6, %eax
je 0x16318
cmpl $0xe, %eax
je 0x163a1
cmpl $0xd, %eax
je 0x16318
jmp 0x1631c
cmpl $0x1, 0x1e1(%rbx)
jne 0x1631c
cmpl $0x3, 0x1e5(%rbx)
jne 0x1631c
pushq $0x3
jmp 0x16399
movq 0x12c95(%rip), %rax     # 0x28fb8
movq (%rax), %r14
callq 0xe343
movl 0x1dd(%rbx), %r8d
movl 0x1e1(%rbx), %r9d
leaq 0xa76e(%rip), %rsi      # 0x20aae
leaq 0xa7a1(%rip), %rcx      # 0x20ae8
xorl %ebp, %ebp
movq %r14, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0x52c0
leaq 0x1394b(%rip), %rax     # 0x29ca8
movq (%rax), %r14
testq %r14, %r14
je 0x1639a
callq 0xe343
movl 0x1dd(%rbx), %r8d
movl 0x1e1(%rbx), %r9d
leaq 0xa72f(%rip), %rsi      # 0x20aae
leaq 0xa762(%rip), %rcx      # 0x20ae8
xorl %ebp, %ebp
movq %r14, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0x52c0
jmp 0x1639a
pushq $0x1
popq %rbp
movl %ebp, %eax
popq %rbx
popq %r14
popq %rbp
retq
pushq $0x2
jmp 0x16399
// File: /workspace/github_c_makefile_star2_O2/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 0xa657(%rip), %rdi      # 0x20a13
xorl %esi, %esi
callq 0x5460
testl %eax, %eax
je 0x16431
leaq 0xa65e(%rip), %rdi      # 0x20a2c
xorl %ebp, %ebp
xorl %esi, %esi
callq 0x5460
testl %eax, %eax
je 0x16447
movq 0x12bd6(%rip), %rax     # 0x28fb8
movq (%rax), %rbx
callq 0xe343
leaq 0x670e(%rip), %rsi      # 0x1caff
movq %rbx, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0x52c0
leaq 0x138a3(%rip), %rax     # 0x29ca8
movq (%rax), %rbx
testq %rbx, %rbx
je 0x164d1
callq 0xe343
leaq 0x66e2(%rip), %rsi      # 0x1caff
xorl %ebp, %ebp
movq %rbx, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0x52c0
jmp 0x164d1
movabsq $0x69686d5f65696370, %rax # imm = 0x69686D5F65696370
movq %rax, (%r15)
movw $0x30, 0x8(%r15)
jmp 0x1645c
movabsq $0x686d5f74656e6d72, %rax # imm = 0x686D5F74656E6D72
movq %rax, (%r15)
movl $0x306968, 0x7(%r15)    # imm = 0x306968
leaq 0xa5e3(%rip), %rdi      # 0x20a46
xorl %ebp, %ebp
xorl %esi, %esi
callq 0x5460
testl %eax, %eax
je 0x164a9
leaq 0xa5dd(%rip), %rdi      # 0x20a54
xorl %esi, %esi
callq 0x5460
testl %eax, %eax
jne 0x164d1
movabsq $0x30494d515f6968, %rax # imm = 0x30494D515F6968
movq %rax, 0x6(%r14)
movabsq $0x69686d2f7665642f, %rax # imm = 0x69686D2F7665642F
movq %rax, (%r14)
movl $0x1, 0x1c1(%rbx)
jmp 0x164ce
movabsq $0x4d49424d5f6968, %rax # imm = 0x4D49424D5F6968
movq %rax, 0x6(%r14)
movabsq $0x69686d2f7665642f, %rax # imm = 0x69686D2F7665642F
movq %rax, (%r14)
movl $0x2, 0x1c1(%rbx)
pushq $0x1
popq %rbp
movl %ebp, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/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 0xa56c(%rip), %rdi      # 0x20a62
xorl %ebx, %ebx
xorl %esi, %esi
callq 0x5460
testl %eax, %eax
je 0x16556
movq 0x12aae(%rip), %rax     # 0x28fb8
movq (%rax), %r14
callq 0xe343
leaq 0xa569(%rip), %rsi      # 0x20a82
movq %r14, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0x52c0
leaq 0x1377b(%rip), %rax     # 0x29ca8
movq (%rax), %r14
testq %r14, %r14
je 0x165d0
callq 0xe343
leaq 0xa53d(%rip), %rsi      # 0x20a82
xorl %ebx, %ebx
movq %r14, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0x52c0
jmp 0x165d0
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 0xac64(%rip), %rdx      # 0x211e6
leaq 0xa4f4(%rip), %rcx      # 0x20a7d
xorl %ebx, %ebx
pushq $0x20
popq %rsi
xorl %eax, %eax
callq 0x51c0
leaq 0xa503(%rip), %rdi      # 0x20a9f
xorl %esi, %esi
callq 0x5460
testl %eax, %eax
jne 0x165d0
movabsq $0x3133726e5f7974, %rax # imm = 0x3133726E5F7974
movq %rax, 0x7(%r15)
movabsq $0x7474732f7665642f, %rax # imm = 0x7474732F7665642F
movq %rax, (%r15)
movl $0x3, 0x1c1(%r14)
pushq $0x1
popq %rbx
movl %ebx, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O2/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 0x129ac(%rip), %rax     # 0x28fb8
movq (%rax), %r15
callq 0xe343
testl %r14d, %r14d
js 0x16679
leaq 0x8(%rsp), %r14
leaq 0xa538(%rip), %rsi      # 0x20b5d
leaq 0xa514(%rip), %rcx      # 0x20b40
movq %r15, %rdi
movq %rax, %rdx
movl %ebp, %r8d
movq %r14, %r9
xorl %eax, %eax
callq 0x52c0
leaq 0x13662(%rip), %rax     # 0x29ca8
movq (%rax), %r15
pushq $0x1
popq %rbx
testq %r15, %r15
je 0x166c5
callq 0xe343
leaq 0xa500(%rip), %rsi      # 0x20b5d
leaq 0xa4dc(%rip), %rcx      # 0x20b40
movq %r15, %rdi
movq %rax, %rdx
movl %ebp, %r8d
movq %r14, %r9
xorl %eax, %eax
callq 0x52c0
jmp 0x166c5
leaq 0xa478(%rip), %rsi      # 0x20af8
leaq 0xa4b9(%rip), %rcx      # 0x20b40
movq %r15, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0x52c0
leaq 0x1360d(%rip), %rax     # 0x29ca8
movq (%rax), %r14
testq %r14, %r14
je 0x166c5
callq 0xe343
leaq 0xa449(%rip), %rsi      # 0x20af8
leaq 0xa48a(%rip), %rcx      # 0x20b40
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_O2/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
andq $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 0x128b5(%rip), %rax     # 0x28fb8
movq (%rax), %rbx
callq 0xe343
testl %ebp, %ebp
js 0x16747
leaq 0xa4ba(%rip), %rsi      # 0x20bd0
leaq 0xa498(%rip), %rcx      # 0x20bb5
movq %rbx, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0x52c0
leaq 0x13577(%rip), %rax     # 0x29ca8
movq (%rax), %rbx
testq %rbx, %rbx
je 0x16791
callq 0xe343
leaq 0xa48b(%rip), %rsi      # 0x20bd0
jmp 0x1677d
leaq 0xa442(%rip), %rsi      # 0x20b90
leaq 0xa460(%rip), %rcx      # 0x20bb5
movq %rbx, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0x52c0
leaq 0x1353f(%rip), %rax     # 0x29ca8
movq (%rax), %rbx
testq %rbx, %rbx
je 0x16791
callq 0xe343
leaq 0xa413(%rip), %rsi      # 0x20b90
leaq 0xa431(%rip), %rcx      # 0x20bb5
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_O2/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
andq $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 0x127f2(%rip), %rax     # 0x28fb8
movq (%rax), %rbx
callq 0xe343
testl %ebp, %ebp
js 0x1680a
leaq 0xa3f7(%rip), %rsi      # 0x20bd0
leaq 0xa416(%rip), %rcx      # 0x20bf6
movq %rbx, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0x52c0
leaq 0x134b4(%rip), %rax     # 0x29ca8
movq (%rax), %rbx
testq %rbx, %rbx
je 0x16854
callq 0xe343
leaq 0xa3c8(%rip), %rsi      # 0x20bd0
jmp 0x16840
leaq 0xa37f(%rip), %rsi      # 0x20b90
leaq 0xa3de(%rip), %rcx      # 0x20bf6
movq %rbx, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0x52c0
leaq 0x1347c(%rip), %rax     # 0x29ca8
movq (%rax), %rbx
testq %rbx, %rbx
je 0x16854
callq 0xe343
leaq 0xa350(%rip), %rsi      # 0x20b90
leaq 0xa3af(%rip), %rcx      # 0x20bf6
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_O2/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 0xa36a(%rip), %rdx      # 0x20c11
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 0x5450
testl %eax, %eax
js 0x168ee
movl %eax, %ebp
pushq $0x4
popq %r14
movl %eax, %edi
movl %r14d, %esi
callq 0x166d5
movl %ebp, %edi
movl %r14d, %esi
callq 0x16798
movl %ebp, %edi
callq 0x5230
jmp 0x16950
movq 0x126c3(%rip), %rax     # 0x28fb8
movq (%rax), %rbx
callq 0xe343
leaq 0xa324(%rip), %rsi      # 0x20c28
leaq 0xa336(%rip), %rcx      # 0x20c41
movq %rsp, %r8
movq %rbx, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0x52c0
leaq 0x13386(%rip), %rax     # 0x29ca8
movq (%rax), %r14
pushq $-0x1
popq %rbx
testq %r14, %r14
je 0x16950
callq 0xe343
leaq 0xa2ef(%rip), %rsi      # 0x20c28
leaq 0xa301(%rip), %rcx      # 0x20c41
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_O2/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 0xe343
movq %rax, %rdi
callq 0x5160
movq %rax, %r14
leaq 0x1(%rax), %r15
movl 0x1cd(%rbx), %ecx
movl 0x1d1(%rbx), %r8d
leaq 0x9f61(%rip), %rdx      # 0x20f76
movq %rsp, %rdi
pushq $0x20
popq %rsi
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 0x170ad
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
addq %r15, %rax
movb $0x0, 0x20(%rsp,%rax)
movq %r12, %rdi
movq %rsp, %rsi
callq 0x5560
testq %rax, %rax
je 0x17038
callq 0xe343
movl $0x120, %esi            # imm = 0x120
movq %rbp, %rdi
leaq 0x9dcf(%rip), %rdx      # 0x20e4d
movq %rax, %rcx
xorl %eax, %eax
callq 0x51c0
movb $0x20, 0x20(%rsp,%r14)
movq %rbp, %rdi
callq 0x5160
movq 0x20d(%rbx), %rcx
movq %rbp, %rdi
movq %rax, %rsi
pushq $0x1
popq %rdx
callq 0x5510
jmp 0x17038
cmpl $-0x1, %eax
jne 0x170c0
callq 0x5070
cmpl $0x4, (%rax)
je 0x17038
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_O2/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 0x170e7
callq 0x5230
movq 0x20d(%rbx), %rdi
testq %rdi, %rdi
je 0x170f9
popq %rbx
jmp 0x5130
popq %rbx
retq
// File: /workspace/github_c_makefile_star2_O2/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)
andq $0x0, 0x8(%rsp)
leaq 0x906d(%rip), %rsi      # 0x2019b
callq 0x5480
pushq $-0x1
popq %rbp
testq %rax, %rax
je 0x171f5
movq %rax, %r15
leaq 0x10(%rsp), %r12
pushq $0x21
popq %rsi
movq %r12, %rdi
movq %rax, %rdx
callq 0x5270
testq %rax, %rax
je 0x171ed
movq %r15, %rdi
callq 0x5130
leaq 0x8(%rsp), %r13
movq %r12, %rdi
movq %r13, %rsi
movl %r14d, %edx
callq 0x52e0
cmpq %r12, (%r13)
je 0x171ed
movq %rax, %r14
leaq 0x12247(%rip), %rax     # 0x293d0
cmpl $0x0, (%rax)
je 0x171e8
movslq %r14d, %r15
movq 0x11e20(%rip), %rax     # 0x28fb8
movq (%rax), %r12
callq 0xe343
leaq 0x9cd1(%rip), %rsi      # 0x20e78
movq %r12, %rdi
movq %rax, %rdx
movq %rbx, %rcx
movq %r15, %r8
xorl %eax, %eax
callq 0x52c0
leaq 0x12ae7(%rip), %rax     # 0x29ca8
movq (%rax), %r12
testq %r12, %r12
je 0x171e8
callq 0xe343
leaq 0x9ca3(%rip), %rsi      # 0x20e78
movq %r12, %rdi
movq %rax, %rdx
movq %rbx, %rcx
movq %r15, %r8
xorl %eax, %eax
callq 0x52c0
movl %r14d, %ebp
jmp 0x171f5
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_O2/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, 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)
leaq 0x8f37(%rip), %rsi      # 0x2019b
callq 0x5480
movq %rax, %r14
pushq $-0x1
popq %rax
testq %r14, %r14
je 0x17362
leaq 0x100(%rsp), %r15
pushq $0x7f
popq %r12
leaq 0x80(%rsp), %rbp
movq %rsp, %r13
movq %r15, %rdi
movl %r12d, %esi
movq %r14, %rdx
callq 0x5270
testq %rax, %rax
je 0x17357
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)
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 %r15, %rdi
leaq 0x9c4f(%rip), %rsi      # 0x20f69
movq %rbp, %rdx
movq %r13, %rcx
xorl %eax, %eax
callq 0x5390
movq %rbx, %rdi
callq 0x5160
movq %rbp, %rdi
movq %rbx, %rsi
movq %rax, %rdx
callq 0x5370
testl %eax, %eax
jne 0x1728f
movq %r14, %rdi
callq 0x5130
movq %rsp, %rdi
callq 0x54c0
jmp 0x17362
movq %r14, %rdi
callq 0x5130
pushq $-0x1
popq %rax
addq $0x188, %rsp            # imm = 0x188
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/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
andq $0x0, (%rbx)
leaq 0x96f0(%rip), %rdi      # 0x210b4
leaq 0x95d5(%rip), %rsi      # 0x20fa0
movq %rbx, %rdx
callq 0x19ed7
testl %eax, %eax
setne %al
movq (%rbx), %rbx
testq %rbx, %rbx
sete %cl
pushq $-0x1
popq %rbp
orb %al, %cl
je 0x179ef
testq %rbx, %rbx
jne 0x17a21
jmp 0x17a29
cmpq $0x0, 0x8(%rbx)
je 0x17a21
cmpl $0x0, (%rbx)
je 0x17a21
movq 0x10(%rbx), %rax
testq %rax, %rax
je 0x17a21
movq 0x8(%rax), %rsi
testq %rsi, %rsi
je 0x17a21
addq $0x216, %r14            # imm = 0x216
pushq $0x40
popq %rdx
movq %r14, %rdi
callq 0x5080
xorl %ebp, %ebp
movq %rbx, %rdi
callq 0x19d1e
movl %ebp, %eax
addq $0x10, %rsp
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/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
andq $0x0, (%rbx)
leaq 0x9564(%rip), %rsi      # 0x210e7
movq %rbx, %rdi
xorl %eax, %eax
callq 0x53c0
movq (%rbx), %rdi
xorl %esi, %esi
callq 0x19d64
movq (%rbx), %rdi
callq 0x5040
pushq $-0x1
popq %rax
addq $0x10, %rsp
popq %rbx
retq
// File: /workspace/github_c_makefile_star2_O2/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
andq $0x0, (%rbx)
movl 0x48(%rdi), %edx
leaq 0x88bb(%rip), %rax      # 0x212eb
leaq 0x88ca(%rip), %rsi      # 0x21301
cmpb $0x0, 0x124fe(%rip)     # 0x2af3c
cmovneq %rax, %rsi
movq %rbx, %rdi
xorl %ecx, %ecx
xorl %eax, %eax
callq 0x53c0
movq (%rbx), %rdi
xorl %esi, %esi
callq 0x19d64
movq (%rbx), %rdi
callq 0x5040
xorl %eax, %eax
addq $0x10, %rsp
popq %rbx
retq
// File: /workspace/github_c_makefile_star2_O2/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
andq $0x0, (%rbx)
leaq 0x81cc(%rip), %rdi      # 0x21418
leaq 0x81ce(%rip), %rsi      # 0x21421
movq %rbx, %rdx
callq 0x19e06
testl %eax, %eax
setne %al
movq (%rbx), %rdi
testq %rdi, %rdi
sete %cl
pushq $-0x1
popq %rbx
orb %al, %cl
jne 0x1933f
cmpq $0x0, 0x8(%rdi)
je 0x1933a
cmpl $0x0, (%rdi)
je 0x1933a
movq 0x10(%rdi), %rax
testq %rax, %rax
je 0x1933a
movq 0x8(%rax), %rdi
testq %rdi, %rdi
je 0x1933a
leaq 0x7ba4(%rip), %rsi      # 0x20e4d
leaq 0x8(%rsp), %r14
movq %r14, %rdx
xorl %eax, %eax
callq 0x1a825
cmpl $0x1, %eax
sete %cl
movq (%r14), %rax
testq %rax, %rax
setne %dl
andb %cl, %dl
cmpb $0x1, %dl
jne 0x1933a
cmpb $0x0, (%rax)
je 0x1933a
movq 0xfcde(%rip), %rax      # 0x28fb8
movq (%rax), %r14
callq 0xe343
movq 0x8(%rsp), %r8
leaq 0x54d2(%rip), %rsi      # 0x1e7c0
leaq 0x8134(%rip), %rcx      # 0x21429
xorl %ebx, %ebx
movq %r14, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0x52c0
leaq 0x1099d(%rip), %rax     # 0x29ca8
movq (%rax), %r14
testq %r14, %r14
je 0x1933a
callq 0xe343
movq 0x8(%rsp), %r8
leaq 0x549c(%rip), %rsi      # 0x1e7c0
leaq 0x80fe(%rip), %rcx      # 0x21429
xorl %ebx, %ebx
movq %r14, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0x52c0
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x19349
callq 0x19d1e
movl %ebx, %eax
addq $0x18, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O2/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
andq $0x0, (%rbx)
leaq 0x80cd(%rip), %rdi      # 0x21439
movq %rbx, %rsi
callq 0x19e4f
testl %eax, %eax
setne %al
movq (%rbx), %rdi
testq %rdi, %rdi
sete %cl
pushq $-0x1
popq %rbx
orb %al, %cl
jne 0x19413
cmpq $0x0, 0x8(%rdi)
je 0x1940e
cmpl $0x0, (%rdi)
je 0x1940e
movq 0x10(%rdi), %rax
testq %rax, %rax
je 0x1940e
movq 0x8(%rax), %r14
testq %r14, %r14
je 0x1940e
movq 0xfc06(%rip), %rax      # 0x28fb8
movq (%rax), %r15
callq 0xe343
leaq 0x53ff(%rip), %rsi      # 0x1e7c0
leaq 0x8079(%rip), %rcx      # 0x21441
xorl %ebx, %ebx
movq %r15, %rdi
movq %rax, %rdx
movq %r14, %r8
xorl %eax, %eax
callq 0x52c0
leaq 0x108c7(%rip), %rax     # 0x29ca8
movq (%rax), %r15
testq %r15, %r15
je 0x1940e
callq 0xe343
leaq 0x53cb(%rip), %rsi      # 0x1e7c0
leaq 0x8045(%rip), %rcx      # 0x21441
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 0x1941d
callq 0x19d1e
movl %ebx, %eax
addq $0x10, %rsp
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O2/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 0x7bf5(%rip), %rsi      # 0x2102c
callq 0x1973c
movl $0x1005, %ebx           # imm = 0x1005
testl %eax, %eax
jne 0x19483
leaq 0x7c3d(%rip), %rsi      # 0x21089
movq %r14, %rdi
callq 0x1973c
movl $0x1004, %ebx           # imm = 0x1004
testl %eax, %eax
jne 0x19483
leaq 0x7c2d(%rip), %rsi      # 0x21091
movq %r14, %rdi
callq 0x1973c
testl %eax, %eax
jne 0x19483
leaq 0x7c22(%rip), %rsi      # 0x21099
movq %r14, %rdi
callq 0x1973c
testl %eax, %eax
je 0x19491
movl %ebx, %edi
addq $0x8, %rsp
popq %rbx
popq %r14
jmp 0x7244
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O2/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:
xorl %eax, %eax
movb (%rdi,%rax), %dl
movb (%rsi,%rax), %cl
testb %dl, %dl
je 0x19755
testb %cl, %cl
je 0x19755
cmpb %cl, %dl
jne 0x1975d
incq %rax
jmp 0x1973e
xorl %eax, %eax
testb %cl, %cl
sete %al
retq
xorl %eax, %eax
retq