LLM4Binary/decompile-bench-makefile huggingface dataset:
// File: /workspace/github_c_makefile_star2_O1/Carton32[P]quectel-CM/qmap_bridge_mode.c
// Function: ql_set_driver_bridge_mode
void ql_set_driver_bridge_mode(PROFILE_T *profile) {
    char enable[16];
    char filename[256];

    if(profile->qmap_mode)
        snprintf(filename, sizeof(filename), "/sys/class/net/%s/bridge_mode", profile->qmapnet_adapter);
    else
        snprintf(filename, sizeof(filename), "/sys/class/net/%s/bridge_mode", profile->usbnet_adapter);
    snprintf(enable, sizeof(enable), "%02d\n", profile->enable_bridge);
    ql_fwrite(filename, enable, sizeof(enable));
}

// Assembly:
pushq %r14
pushq %rbx
subq $0x118, %rsp            # imm = 0x118
movq %rdi, %rbx
xorl %eax, %eax
cmpl $0x0, 0x10a(%rdi)
setne %al
shll $0x5, %eax
leaq (%rax,%rdi), %rcx
addq $0xaa, %rcx
leaq 0x10e1b(%rip), %rdx     # 0x20eb4
leaq 0x10(%rsp), %r14
movl $0x100, %esi            # imm = 0x100
movq %r14, %rdi
xorl %eax, %eax
callq 0x51c0
movl 0x4c(%rbx), %ecx
leaq 0x10f5e(%rip), %rdx     # 0x21015
movq %rsp, %rbx
movl $0x10, %esi
movq %rbx, %rdi
xorl %eax, %eax
callq 0x51c0
movl $0x10, %edx
movq %r14, %rdi
movq %rbx, %rsi
callq 0xfd1a
addq $0x118, %rsp            # imm = 0x118
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O1/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, %r15d
leaq 0x30(%r15), %r14
movq %r14, %rdi
callq 0x5360
testq %rax, %rax
je 0x10bfe
movq %rax, %rbx
movl $0x3, (%rax)
movl %r14d, 0x4(%rax)
movl 0x19764(%rip), %eax     # 0x2a308
leal 0x1(%rax), %ecx
movl %ecx, 0x1975b(%rip)     # 0x2a308
movl %eax, 0x8(%rbx)
movq $0x1, 0xc(%rbx)
leaq 0x107eb(%rip), %rdi     # 0x213aa
callq 0x10c1b
movups 0x1b169(%rip), %xmm0    # 0x2bd34
movups %xmm0, 0x14(%rbx)
movl %r13d, 0x24(%rbx)
movl %r12d, 0x28(%rbx)
testl %ebp, %ebp
sete %al
movq (%rsp), %rsi
testq %rsi, %rsi
sete %cl
orb %al, %cl
jne 0x10c02
movl %ebp, 0x2c(%rbx)
movq %rbx, %rdi
addq $0x30, %rdi
movq %r15, %rdx
callq 0x52f0
jmp 0x10c09
xorl %ebx, %ebx
jmp 0x10c09
movl $0x0, 0x2c(%rbx)
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/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
movb (%rdi), %bpl
testb %bpl, %bpl
je 0x10c5f
movq %rdi, %rbx
callq 0x5570
movq (%rax), %rcx
movl $0x1, %edx
xorl %eax, %eax
movsbq %bpl, %rsi
movb (%rcx,%rsi,4), %sil
movb %sil, 0x40(%rsp,%rax)
movl %edx, %eax
movb (%rbx,%rax), %bpl
incl %edx
testb %bpl, %bpl
jne 0x10c43
jmp 0x10c61
xorl %eax, %eax
movb $0x0, 0x40(%rsp,%rax)
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 0x10730(%rip), %rsi     # 0x213cf
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 0x1b049(%rip), %rax     # 0x2bd34
movb (%rsp,%rbx,4), %cl
movb %cl, (%rbx,%rax)
incq %rbx
cmpq $0x10, %rbx
jne 0x10ceb
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/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
movq $0x0, 0x10(%rsp)
movq 0x17bf7(%rip), %r12     # 0x29fc0
movq (%r12), %rbx
callq 0xeb2f
leaq 0xfe2c(%rip), %rsi      # 0x22205
leaq 0xffa1(%rip), %rcx      # 0x22381
movq %rbx, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0x52c0
leaq 0x188b4(%rip), %rax     # 0x2aca8
movq (%rax), %rbx
testq %rbx, %rbx
je 0x1241c
callq 0xeb2f
leaq 0xfdfd(%rip), %rsi      # 0x22205
leaq 0xff72(%rip), %rcx      # 0x22381
movq %rbx, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0x52c0
movl $0xc, %edi
callq 0x5360
xorl %r13d, %r13d
testq %rax, %rax
je 0x12452
movq %rax, %rbx
movabsq $0xc00000002, %rax      # imm = 0xC00000002
movq %rax, (%rbx)
movl 0x17ec4(%rip), %eax     # 0x2a308
leal 0x1(%rax), %ecx
movl %ecx, 0x17ebb(%rip)     # 0x2a308
movl %eax, 0x8(%rbx)
jmp 0x12454
xorl %ebx, %ebx
leaq 0x10(%rsp), %r14
movq %rbx, %rdi
movq %r14, %rsi
movl $0x7530, %edx           # imm = 0x7530
callq 0x10d09
movl %eax, %ebp
movq (%r14), %rdi
testq %rdi, %rdi
je 0x12490
movl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
addl (%rdi), %eax
cmpl $0x3, %eax
ja 0x12490
movl %eax, %eax
leaq 0x10380(%rip), %rcx     # 0x22808
movq (%rcx,%rax,8), %rax
movl (%rdi,%rax), %r13d
movl %ebp, %eax
orl %r13d, %eax
sete %al
testq %rdi, %rdi
setne %r15b
andb %al, %r15b
jne 0x12555
testq %rdi, %rdi
je 0x124bf
xorl %esi, %esi
cmpl $0x0, 0x1987a(%rip)     # 0x2bd30
sete %sil
callq 0x10e8f
testq %rbx, %rbx
je 0x124cc
movq %rbx, %rdi
callq 0x5040
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x124e4
callq 0x5040
movq $0x0, 0x10(%rsp)
movq (%r12), %r14
callq 0xeb2f
movl %r13d, (%rsp)
leaq 0xee65(%rip), %rsi      # 0x2135d
leaq 0xfe82(%rip), %rcx      # 0x22381
xorl %ebx, %ebx
movq %r14, %rdi
movq %rax, %rdx
movl $0x6af, %r8d            # imm = 0x6AF
movl %ebp, %r9d
xorl %eax, %eax
callq 0x52c0
leaq 0x1878a(%rip), %rax     # 0x2aca8
movq (%rax), %r14
testq %r14, %r14
je 0x12555
callq 0xeb2f
movl %r13d, (%rsp)
leaq 0xee27(%rip), %rsi      # 0x2135d
leaq 0xfe44(%rip), %rcx      # 0x22381
xorl %ebx, %ebx
movq %r14, %rdi
movq %rax, %rdx
movl $0x6af, %r8d            # imm = 0x6AF
movl %ebp, %r9d
xorl %eax, %eax
callq 0x52c0
testb %r15b, %r15b
je 0x1257f
testq %rbx, %rbx
je 0x12567
movq %rbx, %rdi
callq 0x5040
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x1257f
callq 0x5040
movq $0x0, 0x10(%rsp)
movl 0x17d7b(%rip), %edi     # 0x2a300
cmpl $-0x1, %edi
je 0x1259a
callq 0x5230
movl 0x17d6f(%rip), %edi     # 0x2a304
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_O1/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 0x13624
movq %rax, 0x188f4(%rip)     # 0x2bf18
movq 0x8(%rdi), %rax
testq %rax, %rax
je 0x13634
movq %rax, 0x188ec(%rip)     # 0x2bf20
movq 0x10(%rdi), %rax
testq %rax, %rax
je 0x13644
movq %rax, 0x188e4(%rip)     # 0x2bf28
movl 0x18(%rdi), %eax
testl %eax, %eax
je 0x13651
movl %eax, 0x188df(%rip)     # 0x2bf30
movb 0x50(%rdi), %al
testb %al, %al
je 0x13662
movl $0x1, 0x188d2(%rip)     # 0x2bf34
cmpb $0x0, 0x51(%rdi)
je 0x1367c
xorl %ecx, %ecx
testb %al, %al
setne %cl
leal 0x2(,%rcx,2), %eax
movl %eax, 0x188b8(%rip)     # 0x2bf34
movl 0x18892(%rip), %esi     # 0x2bf14
movl $0x1, %edi
jmp 0x161b4
// File: /workspace/github_c_makefile_star2_O1/Carton32[P]quectel-CM/mbim-cm.c
// Function: mbim_dump_signal_state
static void mbim_dump_signal_state(MBIM_SIGNAL_STATE_INFO_T *pInfo, const char *direction)
{
    mbim_debug("%s Rssi = %u", direction, le32toh(pInfo->Rssi));
    mbim_debug("%s ErrorRate = %u", direction, le32toh(pInfo->ErrorRate));
    mbim_debug("%s SignalStrengthInterval = %u", direction, le32toh(pInfo->SignalStrengthInterval));
    mbim_debug("%s RssiThreshold = %u", direction, le32toh(pInfo->RssiThreshold));
    mbim_debug("%s ErrorRateThreshold = %u", direction, le32toh(pInfo->ErrorRateThreshold));
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
movq %rsi, %rbx
movq %rdi, %r14
movq 0x1475c(%rip), %r12     # 0x29fc0
movq (%r12), %r15
callq 0xeb2f
movl (%r14), %r8d
leaq 0xc901(%rip), %rsi      # 0x22178
movq %r15, %rdi
movq %rax, %rdx
movq %rbx, %rcx
xorl %eax, %eax
callq 0x52c0
leaq 0x1541a(%rip), %r13     # 0x2aca8
movq (%r13), %r15
testq %r15, %r15
je 0x158b6
callq 0xeb2f
movl (%r14), %r8d
leaq 0xc8d2(%rip), %rsi      # 0x22178
movq %r15, %rdi
movq %rax, %rdx
movq %rbx, %rcx
xorl %eax, %eax
callq 0x52c0
movq (%r12), %r15
callq 0xeb2f
movl 0x4(%r14), %r8d
leaq 0xc8c1(%rip), %rsi      # 0x2218b
movq %r15, %rdi
movq %rax, %rdx
movq %rbx, %rcx
xorl %eax, %eax
callq 0x52c0
movq (%r13), %r15
testq %r15, %r15
je 0x15903
callq 0xeb2f
movl 0x4(%r14), %r8d
leaq 0xc898(%rip), %rsi      # 0x2218b
movq %r15, %rdi
movq %rax, %rdx
movq %rbx, %rcx
xorl %eax, %eax
callq 0x52c0
movq (%r12), %r15
callq 0xeb2f
movl 0x8(%r14), %r8d
leaq 0xc88c(%rip), %rsi      # 0x221a3
movq %r15, %rdi
movq %rax, %rdx
movq %rbx, %rcx
xorl %eax, %eax
callq 0x52c0
movq (%r13), %r15
testq %r15, %r15
je 0x15950
callq 0xeb2f
movl 0x8(%r14), %r8d
leaq 0xc863(%rip), %rsi      # 0x221a3
movq %r15, %rdi
movq %rax, %rdx
movq %rbx, %rcx
xorl %eax, %eax
callq 0x52c0
movq (%r12), %r15
callq 0xeb2f
movl 0xc(%r14), %r8d
leaq 0xc864(%rip), %rsi      # 0x221c8
movq %r15, %rdi
movq %rax, %rdx
movq %rbx, %rcx
xorl %eax, %eax
callq 0x52c0
movq (%r13), %r15
testq %r15, %r15
je 0x1599d
callq 0xeb2f
movl 0xc(%r14), %r8d
leaq 0xc83b(%rip), %rsi      # 0x221c8
movq %r15, %rdi
movq %rax, %rdx
movq %rbx, %rcx
xorl %eax, %eax
callq 0x52c0
movq (%r12), %r15
callq 0xeb2f
movl 0x10(%r14), %r8d
leaq 0xc833(%rip), %rsi      # 0x221e4
movq %r15, %rdi
movq %rax, %rdx
movq %rbx, %rcx
xorl %eax, %eax
callq 0x52c0
movq (%r13), %r15
testq %r15, %r15
je 0x159f3
callq 0xeb2f
movl 0x10(%r14), %r8d
leaq 0xc80a(%rip), %rsi      # 0x221e4
movq %r15, %rdi
movq %rax, %rdx
movq %rbx, %rcx
xorl %eax, %eax
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
jmp 0x52c0
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O1/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 0x15b55
leaq 0xbc43(%rip), %r15      # 0x21660
movl $0xc, %ebp
leaq 0x13b17(%rip), %r14     # 0x29540
leaq 0x16390(%rip), %r13     # 0x2bdc0
movq -0xc(%rbp,%r14), %rsi
movq %r13, %rdi
callq 0x52a0
testl %eax, %eax
jne 0x15a4d
cmpl %ebx, -0x4(%rbp,%r14)
jne 0x15a4d
movq (%rbp,%r14), %r15
addq $0x14, %rbp
cmpq $0x37c, %rbp            # imm = 0x37C
jne 0x15a30
movq 0x1455f(%rip), %rax     # 0x29fc0
movq (%rax), %r13
callq 0xeb2f
movq %rax, %rbp
movq %r12, %rdi
callq 0x15c17
leaq 0xbbec(%rip), %rsi      # 0x21667
leaq 0x1633e(%rip), %r9      # 0x2bdc0
movq %r13, %rdi
movq %rbp, %rdx
movq (%rsp), %r14
movq %r14, %rcx
movq %rax, %r8
xorl %eax, %eax
callq 0x52c0
leaq 0x15208(%rip), %rbp     # 0x2aca8
movq (%rbp), %r13
testq %r13, %r13
je 0x15ae1
callq 0xeb2f
movq %rax, %rbp
movq %r12, %rdi
callq 0x15c17
leaq 0xbba7(%rip), %rsi      # 0x21667
leaq 0x162f9(%rip), %r9      # 0x2bdc0
movq %r13, %rdi
movq %rbp, %rdx
leaq 0x151d4(%rip), %rbp     # 0x2aca8
movq %r14, %rcx
movq %rax, %r8
xorl %eax, %eax
callq 0x52c0
movq 0x144d8(%rip), %rax     # 0x29fc0
movq (%rax), %r12
callq 0xeb2f
leaq 0xbb93(%rip), %rsi      # 0x2168a
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 0x15b46
callq 0xeb2f
leaq 0xbb68(%rip), %rsi      # 0x2168a
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_O1/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 0x161f3(%rip), %rdi     # 0x2bdc0
leaq 0xb7fb(%rip), %rdx      # 0x213cf
movl $0x25, %esi
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_O1/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 0x17396
movq %rax, %rbx
movq %rax, %rdi
callq 0x5320
testq %rax, %rax
je 0x173b5
movq %rax, %r12
cmpb $0x2e, 0x13(%r12)
je 0x17384
addq $0x13, %r12
testq %r15, %r15
je 0x1739f
movq %r15, %rdi
callq 0x5160
testq %rax, %rax
je 0x1739f
movq %r12, %rdi
movq %r15, %rsi
movq %rax, %rdx
callq 0x5090
testl %eax, %eax
je 0x1739f
movq %rbx, %rdi
callq 0x5320
movq %rax, %r12
testq %rax, %rax
jne 0x17354
jmp 0x173b5
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
movl %ebp, %esi
leaq 0xba65(%rip), %rdx      # 0x22e0d
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
// File: /workspace/github_c_makefile_star2_O1/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 0x17683
movq %rdi, %rbx
cmpl $0xe0, %eax
je 0x175ed
cmpl $0x2, %eax
jne 0x17608
movl 0x1e1(%rbx), %eax
cmpl $0x6, %eax
je 0x175e3
cmpl $0xe, %eax
je 0x1768f
cmpl $0xd, %eax
jne 0x17608
movl $0x3, %ebp
jmp 0x17688
cmpl $0x1, 0x1e1(%rbx)
jne 0x17608
movl $0x3, %ebp
cmpl $0x3, 0x1e5(%rbx)
je 0x17688
movq 0x129b1(%rip), %rax     # 0x29fc0
movq (%rax), %r14
callq 0xeb2f
movl 0x1dd(%rbx), %r8d
movl 0x1e1(%rbx), %r9d
leaq 0xb442(%rip), %rsi      # 0x22a6e
leaq 0xb475(%rip), %rcx      # 0x22aa8
xorl %ebp, %ebp
movq %r14, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0x52c0
leaq 0x1365f(%rip), %rax     # 0x2aca8
movq (%rax), %r14
testq %r14, %r14
je 0x17688
callq 0xeb2f
movl 0x1dd(%rbx), %r8d
movl 0x1e1(%rbx), %r9d
leaq 0xb403(%rip), %rsi      # 0x22a6e
leaq 0xb436(%rip), %rcx      # 0x22aa8
xorl %ebp, %ebp
movq %r14, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0x52c0
jmp 0x17688
movl $0x1, %ebp
movl %ebp, %eax
popq %rbx
popq %r14
popq %rbp
retq
movl $0x2, %ebp
jmp 0x17688
// File: /workspace/github_c_makefile_star2_O1/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 0xb326(%rip), %rdi      # 0x229d3
xorl %esi, %esi
callq 0x5450
testl %eax, %eax
je 0x17722
leaq 0xb32d(%rip), %rdi      # 0x229ec
xorl %ebp, %ebp
xorl %esi, %esi
callq 0x5450
testl %eax, %eax
je 0x17738
movq 0x128ed(%rip), %rax     # 0x29fc0
movq (%rax), %rbx
callq 0xeb2f
leaq 0x741f(%rip), %rsi      # 0x1eb01
movq %rbx, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0x52c0
leaq 0x135b2(%rip), %rax     # 0x2aca8
movq (%rax), %rbx
testq %rbx, %rbx
je 0x177c4
callq 0xeb2f
leaq 0x73f3(%rip), %rsi      # 0x1eb01
xorl %ebp, %ebp
movq %rbx, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0x52c0
jmp 0x177c4
movabsq $0x69686d5f65696370, %rax # imm = 0x69686D5F65696370
movq %rax, (%r15)
movw $0x30, 0x8(%r15)
jmp 0x1774d
movabsq $0x686d5f74656e6d72, %rax # imm = 0x686D5F74656E6D72
movq %rax, (%r15)
movl $0x306968, 0x7(%r15)    # imm = 0x306968
leaq 0xb2b2(%rip), %rdi      # 0x22a06
xorl %ebp, %ebp
xorl %esi, %esi
callq 0x5450
testl %eax, %eax
je 0x1779a
leaq 0xb2ac(%rip), %rdi      # 0x22a14
xorl %esi, %esi
callq 0x5450
testl %eax, %eax
jne 0x177c4
movabsq $0x30494d515f6968, %rax # imm = 0x30494D515F6968
movq %rax, 0x6(%r14)
movabsq $0x69686d2f7665642f, %rax # imm = 0x69686D2F7665642F
movq %rax, (%r14)
movl $0x1, 0x1c1(%rbx)
jmp 0x177bf
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_O1/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 0xb239(%rip), %rdi      # 0x22a22
xorl %ebx, %ebx
xorl %esi, %esi
callq 0x5450
testl %eax, %eax
je 0x17849
movq 0x127c3(%rip), %rax     # 0x29fc0
movq (%rax), %r14
callq 0xeb2f
leaq 0xb236(%rip), %rsi      # 0x22a42
movq %r14, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0x52c0
leaq 0x13488(%rip), %rax     # 0x2aca8
movq (%rax), %r14
testq %r14, %r14
je 0x178c7
callq 0xeb2f
leaq 0xb20a(%rip), %rsi      # 0x22a42
xorl %ebx, %ebx
movq %r14, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0x52c0
jmp 0x178c7
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 0xb931(%rip), %rdx      # 0x231a6
leaq 0xb1c1(%rip), %rcx      # 0x22a3d
xorl %ebx, %ebx
movl $0x20, %esi
xorl %eax, %eax
callq 0x51c0
leaq 0xb1ce(%rip), %rdi      # 0x22a5f
xorl %esi, %esi
callq 0x5450
testl %eax, %eax
jne 0x178c7
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_O1/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 0x126bd(%rip), %rax     # 0x29fc0
movq (%rax), %r15
callq 0xeb2f
testl %r14d, %r14d
js 0x17972
leaq 0x8(%rsp), %r14
leaq 0xb201(%rip), %rsi      # 0x22b1d
leaq 0xb1dd(%rip), %rcx      # 0x22b00
movq %r15, %rdi
movq %rax, %rdx
movl %ebp, %r8d
movq %r14, %r9
xorl %eax, %eax
callq 0x52c0
leaq 0x1336b(%rip), %rax     # 0x2aca8
movq (%rax), %r15
movl $0x1, %ebx
testq %r15, %r15
je 0x179be
callq 0xeb2f
leaq 0xb1c7(%rip), %rsi      # 0x22b1d
leaq 0xb1a3(%rip), %rcx      # 0x22b00
movq %r15, %rdi
movq %rax, %rdx
movl %ebp, %r8d
movq %r14, %r9
xorl %eax, %eax
callq 0x52c0
jmp 0x179be
leaq 0xb13f(%rip), %rsi      # 0x22ab8
leaq 0xb180(%rip), %rcx      # 0x22b00
movq %r15, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0x52c0
leaq 0x13314(%rip), %rax     # 0x2aca8
movq (%rax), %r14
testq %r14, %r14
je 0x179be
callq 0xeb2f
leaq 0xb110(%rip), %rsi      # 0x22ab8
leaq 0xb151(%rip), %rcx      # 0x22b00
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_O1/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 0x125c1(%rip), %rax     # 0x29fc0
movq (%rax), %rbx
callq 0xeb2f
testl %ebp, %ebp
js 0x17a43
leaq 0xb17e(%rip), %rsi      # 0x22b90
leaq 0xb15c(%rip), %rcx      # 0x22b75
movq %rbx, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0x52c0
leaq 0x1327b(%rip), %rax     # 0x2aca8
movq (%rax), %rbx
testq %rbx, %rbx
je 0x17a8d
callq 0xeb2f
leaq 0xb14f(%rip), %rsi      # 0x22b90
jmp 0x17a79
leaq 0xb106(%rip), %rsi      # 0x22b50
leaq 0xb124(%rip), %rcx      # 0x22b75
movq %rbx, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0x52c0
leaq 0x13243(%rip), %rax     # 0x2aca8
movq (%rax), %rbx
testq %rbx, %rbx
je 0x17a8d
callq 0xeb2f
leaq 0xb0d7(%rip), %rsi      # 0x22b50
leaq 0xb0f5(%rip), %rcx      # 0x22b75
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_O1/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 0x124fb(%rip), %rax     # 0x29fc0
movq (%rax), %rbx
callq 0xeb2f
testl %ebp, %ebp
js 0x17b09
leaq 0xb0b8(%rip), %rsi      # 0x22b90
leaq 0xb0d7(%rip), %rcx      # 0x22bb6
movq %rbx, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0x52c0
leaq 0x131b5(%rip), %rax     # 0x2aca8
movq (%rax), %rbx
testq %rbx, %rbx
je 0x17b53
callq 0xeb2f
leaq 0xb089(%rip), %rsi      # 0x22b90
jmp 0x17b3f
leaq 0xb040(%rip), %rsi      # 0x22b50
leaq 0xb09f(%rip), %rcx      # 0x22bb6
movq %rbx, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0x52c0
leaq 0x1317d(%rip), %rax     # 0x2aca8
movq (%rax), %rbx
testq %rbx, %rbx
je 0x17b53
callq 0xeb2f
leaq 0xb011(%rip), %rsi      # 0x22b50
leaq 0xb070(%rip), %rcx      # 0x22bb6
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_O1/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 0xb02b(%rip), %rdx      # 0x22bd1
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 0x17bed
movl %eax, %ebp
movl %eax, %edi
movl $0x4, %esi
callq 0x179ce
movl %ebp, %edi
movl $0x4, %esi
callq 0x17a94
movl %ebp, %edi
callq 0x5230
jmp 0x17c51
movq 0x123cc(%rip), %rax     # 0x29fc0
movq (%rax), %rbx
callq 0xeb2f
leaq 0xafe5(%rip), %rsi      # 0x22be8
leaq 0xaff7(%rip), %rcx      # 0x22c01
movq %rsp, %r8
movq %rbx, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0x52c0
leaq 0x13087(%rip), %rax     # 0x2aca8
movq (%rax), %r14
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
testq %r14, %r14
je 0x17c51
callq 0xeb2f
leaq 0xafae(%rip), %rsi      # 0x22be8
leaq 0xafc0(%rip), %rcx      # 0x22c01
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_O1/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 0xeb2f
movq %rax, %rdi
callq 0x5160
movq %rax, %r14
leaq 0x1(%rax), %r15
movl 0x1cd(%rbx), %ecx
movl 0x1d1(%rbx), %r8d
leaq 0xabfb(%rip), %rdx      # 0x22f36
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 0x183d7
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 0x18360
callq 0xeb2f
movl $0x120, %esi            # imm = 0x120
movq %rbp, %rdi
leaq 0xaa67(%rip), %rdx      # 0x22e0d
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 0x18360
cmpl $-0x1, %eax
jne 0x183ea
callq 0x5070
cmpl $0x4, (%rax)
je 0x18360
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_O1/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 0x18411
callq 0x5230
movq 0x20d(%rbx), %rdi
testq %rdi, %rdi
je 0x18423
popq %rbx
jmp 0x5130
popq %rbx
retq
// File: /workspace/github_c_makefile_star2_O1/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 0x9d03(%rip), %rsi      # 0x2215e
callq 0x5470
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
testq %rax, %rax
je 0x18526
movq %rax, %r15
leaq 0x10(%rsp), %r12
movq %r12, %rdi
movl $0x21, %esi
movq %rax, %rdx
callq 0x5270
testq %rax, %rax
je 0x1851e
movq %r15, %rdi
callq 0x5130
leaq 0x8(%rsp), %r13
movq %r12, %rdi
movq %r13, %rsi
movl %r14d, %edx
callq 0x52e0
cmpq %r12, (%r13)
je 0x1851e
movq %rax, %r14
leaq 0x11f16(%rip), %rax     # 0x2a3d0
cmpl $0x0, (%rax)
je 0x18519
movslq %r14d, %r15
movq 0x11af7(%rip), %rax     # 0x29fc0
movq (%rax), %r12
callq 0xeb2f
leaq 0xa960(%rip), %rsi      # 0x22e38
movq %r12, %rdi
movq %rax, %rdx
movq %rbx, %rcx
movq %r15, %r8
xorl %eax, %eax
callq 0x52c0
leaq 0x127b6(%rip), %rax     # 0x2aca8
movq (%rax), %r12
testq %r12, %r12
je 0x18519
callq 0xeb2f
leaq 0xa932(%rip), %rsi      # 0x22e38
movq %r12, %rdi
movq %rax, %rdx
movq %rbx, %rcx
movq %r15, %r8
xorl %eax, %eax
callq 0x52c0
movl %r14d, %ebp
jmp 0x18526
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_O1/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 $0x198, %rsp            # imm = 0x198
movq %rsi, %rbx
xorps %xmm0, %xmm0
movaps %xmm0, 0x180(%rsp)
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)
leaq 0x9bc9(%rip), %rsi      # 0x2215e
callq 0x5470
testq %rax, %rax
je 0x1869d
movq %rax, %r14
leaq 0x110(%rsp), %r15
leaq 0x90(%rsp), %r13
leaq 0x10(%rsp), %rbp
movq %r15, %rdi
movl $0x7f, %esi
movq %r14, %rdx
callq 0x5270
testq %rax, %rax
je 0x18695
xorps %xmm0, %xmm0
movaps %xmm0, 0x100(%rsp)
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)
movq %r15, %rdi
leaq 0xa8dd(%rip), %rsi      # 0x22f29
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
movl %eax, %r12d
testl %eax, %eax
jne 0x1868a
movq %r14, %rdi
callq 0x5130
movq %rbp, %rdi
callq 0x54b0
movl %eax, 0xc(%rsp)
testl %r12d, %r12d
jne 0x185bb
jmp 0x186a5
movq %r14, %rdi
callq 0x5130
movl $0xffffffff, 0xc(%rsp)  # imm = 0xFFFFFFFF
movl 0xc(%rsp), %eax
addq $0x198, %rsp            # imm = 0x198
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop
// File: /workspace/github_c_makefile_star2_O1/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 0xa2e4(%rip), %rdi      # 0x23074
leaq 0xa1c9(%rip), %rsi      # 0x22f60
movq %rbx, %rdx
callq 0x1b498
testl %eax, %eax
setne %al
movq (%rbx), %rbx
testq %rbx, %rbx
sete %cl
orb %al, %cl
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
jne 0x18dea
cmpq $0x0, 0x8(%rbx)
je 0x18dea
cmpl $0x0, (%rbx)
je 0x18dea
movq 0x10(%rbx), %rax
testq %rax, %rax
je 0x18dea
movq 0x8(%rax), %rsi
testq %rsi, %rsi
je 0x18dea
addq $0x216, %r14            # imm = 0x216
movl $0x40, %edx
movq %r14, %rdi
callq 0x5080
xorl %ebp, %ebp
testq %rbx, %rbx
je 0x18e00
movq %rbx, %rdi
callq 0x1b2da
movq $0x0, 0x8(%rsp)
movl %ebp, %eax
addq $0x10, %rsp
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/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 0xa12a(%rip), %rsi      # 0x230a7
movq %rbx, %rdi
xorl %eax, %eax
callq 0x53b0
movq (%rbx), %rdi
xorl %esi, %esi
callq 0x1b323
movq (%rbx), %rdi
testq %rdi, %rdi
je 0x18fa7
callq 0x5040
movq $0x0, 0x8(%rsp)
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
addq $0x10, %rsp
popq %rbx
retq
// File: /workspace/github_c_makefile_star2_O1/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 0x93d6(%rip), %rax      # 0x232ab
leaq 0x93e5(%rip), %rsi      # 0x232c1
cmpb $0x0, 0x12059(%rip)     # 0x2bf3c
cmovneq %rax, %rsi
movq %rbx, %rdi
xorl %ecx, %ecx
xorl %eax, %eax
callq 0x53b0
movq (%rbx), %rdi
xorl %esi, %esi
callq 0x1b323
movq (%rbx), %rdi
testq %rdi, %rdi
je 0x19f13
callq 0x5040
movq $0x0, 0x8(%rsp)
xorl %eax, %eax
addq $0x10, %rsp
popq %rbx
retq
// File: /workspace/github_c_makefile_star2_O1/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 0x8cf0(%rip), %rdi      # 0x233d8
leaq 0x8cf2(%rip), %rsi      # 0x233e1
movq %rbx, %rdx
callq 0x1b3c6
testl %eax, %eax
setne %cl
movq (%rbx), %rax
testq %rax, %rax
sete %dl
orb %cl, %dl
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
jne 0x1a7d8
cmpq $0x0, 0x8(%rax)
je 0x1a7d8
cmpl $0x0, (%rax)
je 0x1a7d8
movq 0x10(%rax), %rax
testq %rax, %rax
je 0x1a7d8
movq 0x8(%rax), %rdi
testq %rdi, %rdi
je 0x1a7d8
leaq 0x86c6(%rip), %rsi      # 0x22e0d
leaq 0x8(%rsp), %r14
movq %r14, %rdx
xorl %eax, %eax
callq 0x1be91
cmpl $0x1, %eax
sete %cl
movq (%r14), %rax
testq %rax, %rax
setne %dl
andb %cl, %dl
cmpb $0x1, %dl
jne 0x1a7d8
cmpb $0x0, (%rax)
je 0x1a7d8
movq 0xf848(%rip), %rax      # 0x29fc0
movq (%rax), %r14
callq 0xeb2f
movq 0x8(%rsp), %r8
leaq 0x6038(%rip), %rsi      # 0x207c4
leaq 0x8c56(%rip), %rcx      # 0x233e9
xorl %ebx, %ebx
movq %r14, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0x52c0
leaq 0x104ff(%rip), %rax     # 0x2aca8
movq (%rax), %r14
testq %r14, %r14
je 0x1a7d8
callq 0xeb2f
movq 0x8(%rsp), %r8
leaq 0x6002(%rip), %rsi      # 0x207c4
leaq 0x8c20(%rip), %rcx      # 0x233e9
xorl %ebx, %ebx
movq %r14, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0x52c0
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x1a7f0
callq 0x1b2da
movq $0x0, 0x10(%rsp)
movl %ebx, %eax
addq $0x18, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O1/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 0x8be3(%rip), %rdi      # 0x233f9
movq %rbx, %rsi
callq 0x1b40d
testl %eax, %eax
setne %cl
movq (%rbx), %rax
testq %rax, %rax
sete %dl
orb %cl, %dl
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
jne 0x1a8ba
cmpq $0x0, 0x8(%rax)
je 0x1a8ba
cmpl $0x0, (%rax)
je 0x1a8ba
movq 0x10(%rax), %rax
testq %rax, %rax
je 0x1a8ba
movq 0x8(%rax), %r14
testq %r14, %r14
je 0x1a8ba
movq 0xf762(%rip), %rax      # 0x29fc0
movq (%rax), %r15
callq 0xeb2f
leaq 0x5f57(%rip), %rsi      # 0x207c4
leaq 0x8b8d(%rip), %rcx      # 0x23401
xorl %ebx, %ebx
movq %r15, %rdi
movq %rax, %rdx
movq %r14, %r8
xorl %eax, %eax
callq 0x52c0
leaq 0x1041b(%rip), %rax     # 0x2aca8
movq (%rax), %r15
testq %r15, %r15
je 0x1a8ba
callq 0xeb2f
leaq 0x5f23(%rip), %rsi      # 0x207c4
leaq 0x8b59(%rip), %rcx      # 0x23401
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 0x1a8d2
callq 0x1b2da
movq $0x0, 0x8(%rsp)
movl %ebx, %eax
addq $0x10, %rsp
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O1/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 0x8700(%rip), %rsi      # 0x22fec
callq 0x1abfc
movl $0x1005, %ebx           # imm = 0x1005
testl %eax, %eax
jne 0x1a938
leaq 0x8748(%rip), %rsi      # 0x23049
movq %r14, %rdi
callq 0x1abfc
movl $0x1004, %ebx           # imm = 0x1004
testl %eax, %eax
jne 0x1a938
leaq 0x8738(%rip), %rsi      # 0x23051
movq %r14, %rdi
callq 0x1abfc
testl %eax, %eax
jne 0x1a938
leaq 0x872d(%rip), %rsi      # 0x23059
movq %r14, %rdi
callq 0x1abfc
testl %eax, %eax
je 0x1a946
movl %ebx, %edi
addq $0x8, %rsp
popq %rbx
popq %r14
jmp 0x7444
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O1/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 0x1ac1b
incq %rdi
movb (%rsi), %cl
testb %cl, %cl
je 0x1ac1b
cmpb %cl, %al
jne 0x1ac24
incq %rsi
movb (%rdi), %al
incq %rdi
testb %al, %al
jne 0x1ac05
xorl %eax, %eax
cmpb $0x0, (%rsi)
sete %al
retq
xorl %eax, %eax
retq