// File: /workspace/github_c_makefile_star2_O2/Carton32[P]quectel-CM/mbim-cm.c
// Function: mbim_set_connect
static int mbim_set_connect(int onoff, int sessionID) {
    MBIM_MESSAGE_HEADER *pRequest = NULL;
    MBIM_COMMAND_DONE_T *pCmdDone = NULL;
    MBIM_SET_CONNECT_T *set_connect = NULL;
    int err;

    mbim_debug("%s(onoff=%d, sessionID=%d)", __func__, onoff, sessionID);
    /* alloc memory then populate APN USERNAME PASSWORD */
    int buflen = mbim_populate_connect_data(&set_connect);
    if (buflen < 0) {
        return ENOMEM;
     }

    set_connect->SessionId = htole32(sessionID);
    if (onoff == 0)
        set_connect->ActivationCommand = htole32(MBIMActivationCommandDeactivate);
    else
        set_connect->ActivationCommand = htole32(MBIMActivationCommandActivate);

    set_connect->Compression = htole32(MBIMCompressionNone);
    set_connect->AuthProtocol = htole32(mbim_auth);
    set_connect->IPType = htole32(mbim_iptype);
    memcpy(set_connect->ContextType.uuid, str2uuid(UUID_MBIMContextTypeInternet), 16);

    pRequest = compose_basic_connect_command(MBIM_CID_CONNECT, MBIM_CID_CMD_TYPE_SET, set_connect, sizeof(MBIM_SET_CONNECT_T) + buflen);
    mbim_free(set_connect);
    err = mbim_send_command(pRequest, &pCmdDone, mbim_default_timeout*10);
    mbim_check_err(err, pRequest, pCmdDone);

    if (le32toh(pCmdDone->InformationBufferLength)) {
        MBIM_CONNECT_T *pInfo = (MBIM_CONNECT_T *)pCmdDone->InformationBuffer;
        ActivationState = le32toh(pInfo->ActivationState);
        mbim_update_state();
    }

    mbim_free(pRequest); mbim_free(pCmdDone);
    return err;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
andq $0x0, 0x10(%rsp)
movl %esi, %r15d
movl %edi, %ebp
movq 0x13ec3(%rip), %rax     # 0x28fb8
movq (%rax), %rbx
callq 0xe343
leaq 0xb3b8(%rip), %rsi      # 0x204bc
leaq 0xb3d2(%rip), %rcx      # 0x204dd
xorl %r14d, %r14d
movq %rbx, %rdi
movq %rax, %rdx
movl %ebp, %r8d
movl %r15d, %r9d
xorl %eax, %eax
callq 0x52c0
leaq 0x14b80(%rip), %r12     # 0x29ca8
movq (%r12), %rbx
testq %rbx, %rbx
je 0x15157
callq 0xe343
leaq 0xb37f(%rip), %rsi      # 0x204bc
leaq 0xb399(%rip), %rcx      # 0x204dd
movq %rbx, %rdi
movq %rax, %rdx
movl %ebp, %r8d
movl %r15d, %r9d
xorl %eax, %eax
callq 0x52c0
movq 0x15dba(%rip), %rdi     # 0x2af18
testq %rdi, %rdi
movl %ebp, 0x1c(%rsp)
movl %r15d, 0x18(%rsp)
movq %rdi, 0x20(%rsp)
je 0x15180
callq 0x5160
testq %rax, %rax
je 0x15180
addl %eax, %eax
movl %eax, %r14d
pushq $0x4
popq %rbp
movl %r14d, %eax
cltd
idivl %ebp
movl %ebp, %r15d
subl %edx, %r15d
testl %edx, %edx
cmovel %edx, %r15d
addl %r14d, %r15d
movq 0x15d81(%rip), %r13     # 0x2af20
testq %r13, %r13
je 0x151b5
movq %r13, %rdi
callq 0x5160
testq %rax, %rax
je 0x151b5
leal (%r15,%rax,2), %r15d
movl %r15d, %eax
cltd
idivl %ebp
movl %ebp, %ebx
subl %edx, %ebx
testl %edx, %edx
cmovel %edx, %ebx
addl %r15d, %ebx
movq 0x15d5a(%rip), %rdi     # 0x2af28
testq %rdi, %rdi
je 0x151e0
callq 0x5160
testq %rax, %rax
je 0x151e0
leal (%rbx,%rax,2), %ebx
movl %ebx, %eax
cltd
idivl %ebp
movl %ebp, %r14d
subl %edx, %r14d
testl %edx, %edx
cmovel %edx, %r14d
addl %ebx, %r14d
movslq %r14d, %rbx
leaq 0x3c(%rbx), %rsi
pushq $0x1
popq %rdi
callq 0x5290
testq %rax, %rax
je 0x153f4
movq %rax, %r15
xorl %r12d, %r12d
movq 0x20(%rsp), %rdi
testq %rdi, %rdi
je 0x1526f
callq 0x5160
testq %rax, %rax
je 0x1526f
addl %eax, %eax
movl %eax, 0xc(%r15)
movl $0x3c, 0x8(%r15)
movq 0x20(%rsp), %r12
movq %r12, %rdi
callq 0x5160
leaq 0x3c(%r15), %rdx
movq %r12, %rdi
movq %rax, %rsi
movq %rbx, %rcx
callq 0x103c0
movq %rax, %rcx
cltd
idivl %ebp
movl %ebp, %r12d
subl %edx, %r12d
testl %edx, %edx
cmovel %edx, %r12d
addl %ecx, %r12d
movq 0x15cb1(%rip), %r13     # 0x2af20
testq %r13, %r13
je 0x152c6
movq %r13, %rdi
callq 0x5160
testq %rax, %rax
je 0x152c6
addl %eax, %eax
movl %eax, 0x14(%r15)
movslq %r12d, %rbx
leal 0x3c(%rbx), %eax
movl %eax, 0x10(%r15)
movq %r13, %rdi
callq 0x5160
leaq (%r15,%rbx), %rdx
addq $0x3c, %rdx
movl %r14d, %ecx
subl %ebx, %ecx
movslq %ecx, %rcx
movq %r13, %rdi
movq %rax, %rsi
callq 0x103c0
movq %rax, %rcx
cltd
idivl %ebp
subl %edx, %ebp
testl %edx, %edx
cmovel %edx, %ebp
addl %ecx, %ebp
movl %ebp, %r12d
movq 0x15c5b(%rip), %rbx     # 0x2af28
testq %rbx, %rbx
je 0x15315
movq %rbx, %rdi
callq 0x5160
testq %rax, %rax
je 0x15315
addl %eax, %eax
movl %eax, 0x1c(%r15)
movslq %r12d, %r12
leal 0x3c(%r12), %eax
movl %eax, 0x18(%r15)
movq %rbx, %rdi
callq 0x5160
leaq (%r15,%r12), %rdx
addq $0x3c, %rdx
movl %r14d, %ecx
subl %r12d, %ecx
movslq %ecx, %rcx
movq %rbx, %rdi
movq %rax, %rsi
callq 0x103c0
testl %r14d, %r14d
js 0x15446
movl 0x18(%rsp), %eax
movl %eax, (%r15)
xorl %eax, %eax
cmpl $0x0, 0x1c(%rsp)
setne %al
movl %eax, 0x4(%r15)
andl $0x0, 0x20(%r15)
movl 0x15bf2(%rip), %eax     # 0x2af30
movl %eax, 0x24(%r15)
movl 0x15bec(%rip), %eax     # 0x2af34
movl %eax, 0x28(%r15)
leaq 0xb19b(%rip), %rdi      # 0x204ee
callq 0x102de
movups 0x159d5(%rip), %xmm0    # 0x2ad34
movups %xmm0, 0x2c(%r15)
addl $0x3c, %r14d
pushq $0xc
popq %rdi
pushq $0x1
popq %rsi
movq %r15, %rdx
movl %r14d, %ecx
callq 0x1022b
movq %rax, %r14
movq %r15, %rdi
callq 0x5040
leaq 0x10(%rsp), %r15
movq %r14, %rdi
movq %r15, %rsi
movl $0x493e0, %edx          # imm = 0x493E0
callq 0x103ea
movl %eax, %ebx
movq (%r15), %r15
movq %r15, %rdi
callq 0x1055f
movl %eax, %ebp
testq %r15, %r15
je 0x1544f
testl %ebx, %ebx
jne 0x1544f
testl %ebp, %ebp
jne 0x1544f
cmpl $0x0, 0x2c(%r15)
je 0x153dc
movl 0x34(%r15), %eax
movl %eax, 0x15b3e(%rip)     # 0x2af10
callq 0x14cde
movq 0x10(%rsp), %r15
movq %r14, %rdi
callq 0x5040
movq %r15, %rdi
callq 0x5040
xorl %r14d, %r14d
jmp 0x15512
movq 0x13bbd(%rip), %rax     # 0x28fb8
movq (%rax), %rbx
callq 0xe343
leaq 0xb109(%rip), %rsi      # 0x20513
movq %rbx, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0x52c0
movq (%r12), %rbx
pushq $0xc
popq %r14
testq %rbx, %rbx
je 0x15512
callq 0xe343
leaq 0xb0df(%rip), %rsi      # 0x20513
movq %rbx, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0x52c0
jmp 0x15512
pushq $0xc
popq %r14
jmp 0x15512
testq %r15, %r15
je 0x15470
xorl %esi, %esi
cmpl $0x0, 0x158d3(%rip)     # 0x2ad30
sete %sil
movq %r15, %rdi
callq 0x10583
movq 0x10(%rsp), %r15
jmp 0x15473
xorl %r15d, %r15d
leaq 0x1482e(%rip), %r12     # 0x29ca8
movq %r14, %rdi
callq 0x5040
testq %r15, %r15
je 0x15495
movq %r15, %rdi
callq 0x5040
andq $0x0, 0x10(%rsp)
movq 0x13b1c(%rip), %rax     # 0x28fb8
movq (%rax), %r14
callq 0xe343
movl %ebp, (%rsp)
leaq 0x9ef3(%rip), %rsi      # 0x1f3a1
leaq 0xb028(%rip), %rcx      # 0x204dd
movq %r14, %rdi
movq %rax, %rdx
movl $0x7fe, %r8d            # imm = 0x7FE
movl %ebx, %r9d
xorl %eax, %eax
callq 0x52c0
movq (%r12), %r14
testq %r14, %r14
je 0x15500
callq 0xe343
movl %ebp, (%rsp)
leaq 0x9ebe(%rip), %rsi      # 0x1f3a1
leaq 0xaff3(%rip), %rcx      # 0x204dd
movq %r14, %rdi
movq %rax, %rdx
movl $0x7fe, %r8d            # imm = 0x7FE
movl %ebx, %r9d
xorl %eax, %eax
callq 0x52c0
testl %ebp, %ebp
movl $0x22b8, %r14d          # imm = 0x22B8
cmovnel %ebp, %r14d
testl %ebx, %ebx
cmovnel %ebx, %r14d
movl %r14d, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq