// File: /workspace/github_c_makefile_star2_O0/Carton32[P]quectel-CM/GobiNetCM.c
// Function: GobiNetGetClientID
static int GobiNetGetClientID(const char *qcqmi, UCHAR QMIType) {
    int ClientId;
    ClientId = cm_open_dev(qcqmi);
    if (ClientId == -1) {
        dbg_time("failed to open %s, errno: %d (%s)", qcqmi, errno, strerror(errno));
        return -1;
    }

    if (ioctl(ClientId, IOCTL_QMI_GET_SERVICE_FILE, QMIType) != 0) {
        dbg_time("failed to get ClientID for 0x%02x errno: %d (%s)", QMIType, errno, strerror(errno));
        close(ClientId);
        ClientId = 0;
    }

    switch (QMIType) {
        case QMUX_TYPE_WDS: dbg_time("Get clientWDS = %d", ClientId); break;
        case QMUX_TYPE_DMS: dbg_time("Get clientDMS = %d", ClientId); break;
        case QMUX_TYPE_NAS: dbg_time("Get clientNAS = %d", ClientId); break;
        case QMUX_TYPE_QOS: dbg_time("Get clientQOS = %d", ClientId); break;
        case QMUX_TYPE_WMS: dbg_time("Get clientWMS = %d", ClientId); break;
        case QMUX_TYPE_PDS: dbg_time("Get clientPDS = %d", ClientId); break;
        case QMUX_TYPE_UIM: dbg_time("Get clientUIM = %d", ClientId); break;
        case QMUX_TYPE_WDS_ADMIN: dbg_time("Get clientWDA = %d", ClientId);
        break;
        default: break;
    }

    return ClientId;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x110, %rsp            # imm = 0x110
movb %sil, %al
movq %rdi, -0x10(%rbp)
movb %al, -0x11(%rbp)
movq -0x10(%rbp), %rdi
callq 0x13770
movl %eax, -0x18(%rbp)
cmpl $-0x1, -0x18(%rbp)
jne 0x7d54
jmp 0x7c8d
movq 0x2f34c(%rip), %rax     # 0x36fe0
movq (%rax), %rax
movq %rax, -0x38(%rbp)
callq 0x13930
movq %rax, -0x30(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x28(%rbp)
callq 0x5070
movl (%rax), %eax
movl %eax, -0x1c(%rbp)
callq 0x5070
movl (%rax), %edi
callq 0x5540
movq -0x38(%rbp), %rdi
movq -0x30(%rbp), %rdx
movq -0x28(%rbp), %rcx
movl -0x1c(%rbp), %r8d
movq %rax, %r9
leaq 0x23757(%rip), %rsi     # 0x2b433
movb $0x0, %al
callq 0x52c0
leaq 0x3017e(%rip), %rax     # 0x37e68
cmpq $0x0, (%rax)
je 0x7d46
leaq 0x30171(%rip), %rax     # 0x37e68
movq (%rax), %rax
movq %rax, -0x58(%rbp)
callq 0x13930
movq %rax, -0x50(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x48(%rbp)
callq 0x5070
movl (%rax), %eax
movl %eax, -0x3c(%rbp)
callq 0x5070
movl (%rax), %edi
callq 0x5540
movq -0x58(%rbp), %rdi
movq -0x50(%rbp), %rdx
movq -0x48(%rbp), %rcx
movl -0x3c(%rbp), %r8d
movq %rax, %r9
leaq 0x236f4(%rip), %rsi     # 0x2b433
movb $0x0, %al
callq 0x52c0
jmp 0x7d48
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x822f
movl -0x18(%rbp), %edi
movzbl -0x11(%rbp), %edx
movl $0x8be1, %esi           # imm = 0x8BE1
movb $0x0, %al
callq 0x5210
cmpl $0x0, %eax
je 0x7e3e
jmp 0x7d72
movq 0x2f267(%rip), %rax     # 0x36fe0
movq (%rax), %rax
movq %rax, -0x70(%rbp)
callq 0x13930
movq %rax, -0x68(%rbp)
movzbl -0x11(%rbp), %eax
movl %eax, -0x60(%rbp)
callq 0x5070
movl (%rax), %eax
movl %eax, -0x5c(%rbp)
callq 0x5070
movl (%rax), %edi
callq 0x5540
movq -0x70(%rbp), %rdi
movq -0x68(%rbp), %rdx
movl -0x60(%rbp), %ecx
movl -0x5c(%rbp), %r8d
movq %rax, %r9
leaq 0x2369c(%rip), %rsi     # 0x2b45b
movb $0x0, %al
callq 0x52c0
leaq 0x3009b(%rip), %rax     # 0x37e68
cmpq $0x0, (%rax)
je 0x7e2d
leaq 0x3008e(%rip), %rax     # 0x37e68
movq (%rax), %rax
movq %rax, -0x88(%rbp)
callq 0x13930
movq %rax, -0x80(%rbp)
movzbl -0x11(%rbp), %eax
movl %eax, -0x78(%rbp)
callq 0x5070
movl (%rax), %eax
movl %eax, -0x74(%rbp)
callq 0x5070
movl (%rax), %edi
callq 0x5540
movq -0x88(%rbp), %rdi
movq -0x80(%rbp), %rdx
movl -0x78(%rbp), %ecx
movl -0x74(%rbp), %r8d
movq %rax, %r9
leaq 0x23635(%rip), %rsi     # 0x2b45b
movb $0x0, %al
callq 0x52c0
jmp 0x7e2f
movl -0x18(%rbp), %edi
callq 0x5230
movl $0x0, -0x18(%rbp)
movzbl -0x11(%rbp), %eax
decl %eax
movl %eax, %ecx
movq %rcx, -0x90(%rbp)
subl $0x19, %eax
ja 0x8227
movq -0x90(%rbp), %rax
leaq 0x23500(%rip), %rcx     # 0x2b364
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
jmp 0x7e6f
movq 0x2f16a(%rip), %rax     # 0x36fe0
movq (%rax), %rax
movq %rax, -0x98(%rbp)
callq 0x13930
movq -0x98(%rbp), %rdi
movq %rax, %rdx
movl -0x18(%rbp), %ecx
leaq 0x233ec(%rip), %rsi     # 0x2b285
movb $0x0, %al
callq 0x52c0
leaq 0x2ffc1(%rip), %rax     # 0x37e68
cmpq $0x0, (%rax)
je 0x7ede
leaq 0x2ffb4(%rip), %rax     # 0x37e68
movq (%rax), %rax
movq %rax, -0xa0(%rbp)
callq 0x13930
movq -0xa0(%rbp), %rdi
movq %rax, %rdx
movl -0x18(%rbp), %ecx
leaq 0x233ae(%rip), %rsi     # 0x2b285
movb $0x0, %al
callq 0x52c0
jmp 0x7ee0
jmp 0x8229
jmp 0x7ee7
movq 0x2f0f2(%rip), %rax     # 0x36fe0
movq (%rax), %rax
movq %rax, -0xa8(%rbp)
callq 0x13930
movq -0xa8(%rbp), %rdi
movq %rax, %rdx
movl -0x18(%rbp), %ecx
leaq 0x2338d(%rip), %rsi     # 0x2b29e
movb $0x0, %al
callq 0x52c0
leaq 0x2ff49(%rip), %rax     # 0x37e68
cmpq $0x0, (%rax)
je 0x7f56
leaq 0x2ff3c(%rip), %rax     # 0x37e68
movq (%rax), %rax
movq %rax, -0xb0(%rbp)
callq 0x13930
movq -0xb0(%rbp), %rdi
movq %rax, %rdx
movl -0x18(%rbp), %ecx
leaq 0x2334f(%rip), %rsi     # 0x2b29e
movb $0x0, %al
callq 0x52c0
jmp 0x7f58
jmp 0x8229
jmp 0x7f5f
movq 0x2f07a(%rip), %rax     # 0x36fe0
movq (%rax), %rax
movq %rax, -0xb8(%rbp)
callq 0x13930
movq -0xb8(%rbp), %rdi
movq %rax, %rdx
movl -0x18(%rbp), %ecx
leaq 0x2332e(%rip), %rsi     # 0x2b2b7
movb $0x0, %al
callq 0x52c0
leaq 0x2fed1(%rip), %rax     # 0x37e68
cmpq $0x0, (%rax)
je 0x7fce
leaq 0x2fec4(%rip), %rax     # 0x37e68
movq (%rax), %rax
movq %rax, -0xc0(%rbp)
callq 0x13930
movq -0xc0(%rbp), %rdi
movq %rax, %rdx
movl -0x18(%rbp), %ecx
leaq 0x232f0(%rip), %rsi     # 0x2b2b7
movb $0x0, %al
callq 0x52c0
jmp 0x7fd0
jmp 0x8229
jmp 0x7fd7
movq 0x2f002(%rip), %rax     # 0x36fe0
movq (%rax), %rax
movq %rax, -0xc8(%rbp)
callq 0x13930
movq -0xc8(%rbp), %rdi
movq %rax, %rdx
movl -0x18(%rbp), %ecx
leaq 0x232cf(%rip), %rsi     # 0x2b2d0
movb $0x0, %al
callq 0x52c0
leaq 0x2fe59(%rip), %rax     # 0x37e68
cmpq $0x0, (%rax)
je 0x8046
leaq 0x2fe4c(%rip), %rax     # 0x37e68
movq (%rax), %rax
movq %rax, -0xd0(%rbp)
callq 0x13930
movq -0xd0(%rbp), %rdi
movq %rax, %rdx
movl -0x18(%rbp), %ecx
leaq 0x23291(%rip), %rsi     # 0x2b2d0
movb $0x0, %al
callq 0x52c0
jmp 0x8048
jmp 0x8229
jmp 0x804f
movq 0x2ef8a(%rip), %rax     # 0x36fe0
movq (%rax), %rax
movq %rax, -0xd8(%rbp)
callq 0x13930
movq -0xd8(%rbp), %rdi
movq %rax, %rdx
movl -0x18(%rbp), %ecx
leaq 0x23270(%rip), %rsi     # 0x2b2e9
movb $0x0, %al
callq 0x52c0
leaq 0x2fde1(%rip), %rax     # 0x37e68
cmpq $0x0, (%rax)
je 0x80be
leaq 0x2fdd4(%rip), %rax     # 0x37e68
movq (%rax), %rax
movq %rax, -0xe0(%rbp)
callq 0x13930
movq -0xe0(%rbp), %rdi
movq %rax, %rdx
movl -0x18(%rbp), %ecx
leaq 0x23232(%rip), %rsi     # 0x2b2e9
movb $0x0, %al
callq 0x52c0
jmp 0x80c0
jmp 0x8229
jmp 0x80c7
movq 0x2ef12(%rip), %rax     # 0x36fe0
movq (%rax), %rax
movq %rax, -0xe8(%rbp)
callq 0x13930
movq -0xe8(%rbp), %rdi
movq %rax, %rdx
movl -0x18(%rbp), %ecx
leaq 0x23211(%rip), %rsi     # 0x2b302
movb $0x0, %al
callq 0x52c0
leaq 0x2fd69(%rip), %rax     # 0x37e68
cmpq $0x0, (%rax)
je 0x8136
leaq 0x2fd5c(%rip), %rax     # 0x37e68
movq (%rax), %rax
movq %rax, -0xf0(%rbp)
callq 0x13930
movq -0xf0(%rbp), %rdi
movq %rax, %rdx
movl -0x18(%rbp), %ecx
leaq 0x231d3(%rip), %rsi     # 0x2b302
movb $0x0, %al
callq 0x52c0
jmp 0x8138
jmp 0x8229
jmp 0x813f
movq 0x2ee9a(%rip), %rax     # 0x36fe0
movq (%rax), %rax
movq %rax, -0xf8(%rbp)
callq 0x13930
movq -0xf8(%rbp), %rdi
movq %rax, %rdx
movl -0x18(%rbp), %ecx
leaq 0x231b2(%rip), %rsi     # 0x2b31b
movb $0x0, %al
callq 0x52c0
leaq 0x2fcf1(%rip), %rax     # 0x37e68
cmpq $0x0, (%rax)
je 0x81ae
leaq 0x2fce4(%rip), %rax     # 0x37e68
movq (%rax), %rax
movq %rax, -0x100(%rbp)
callq 0x13930
movq -0x100(%rbp), %rdi
movq %rax, %rdx
movl -0x18(%rbp), %ecx
leaq 0x23174(%rip), %rsi     # 0x2b31b
movb $0x0, %al
callq 0x52c0
jmp 0x81b0
jmp 0x8229
jmp 0x81b4
movq 0x2ee25(%rip), %rax     # 0x36fe0
movq (%rax), %rax
movq %rax, -0x108(%rbp)
callq 0x13930
movq -0x108(%rbp), %rdi
movq %rax, %rdx
movl -0x18(%rbp), %ecx
leaq 0x23156(%rip), %rsi     # 0x2b334
movb $0x0, %al
callq 0x52c0
leaq 0x2fc7c(%rip), %rax     # 0x37e68
cmpq $0x0, (%rax)
je 0x8223
leaq 0x2fc6f(%rip), %rax     # 0x37e68
movq (%rax), %rax
movq %rax, -0x110(%rbp)
callq 0x13930
movq -0x110(%rbp), %rdi
movq %rax, %rdx
movl -0x18(%rbp), %ecx
leaq 0x23118(%rip), %rsi     # 0x2b334
movb $0x0, %al
callq 0x52c0
jmp 0x8225
jmp 0x8229
jmp 0x8229
movl -0x18(%rbp), %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x110, %rsp            # imm = 0x110
popq %rbp
retq
nopl (%rax,%rax)