// File: /workspace/github_c_makefile_star2_O3/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
movl %esi, %r12d
movl %edi, %r15d
movq $0x0, 0x10(%rsp)
movq 0x13fab(%rip), %rax     # 0x29fc0
movq (%rax), %rbx
callq 0xea3b
leaq 0xc483(%rip), %rsi      # 0x224a7
leaq 0xc49d(%rip), %rcx      # 0x224c8
xorl %r14d, %r14d
movq %rbx, %rdi
movq %rax, %rdx
movl %r15d, %r8d
movl %r12d, %r9d
xorl %eax, %eax
callq 0x52c0
leaq 0x14c60(%rip), %rbp     # 0x2aca8
movq (%rbp), %rbx
testq %rbx, %rbx
je 0x16077
callq 0xea3b
leaq 0xc44a(%rip), %rsi      # 0x224a7
leaq 0xc464(%rip), %rcx      # 0x224c8
movq %rbx, %rdi
movq %rax, %rdx
movl %r15d, %r8d
movl %r12d, %r9d
xorl %eax, %eax
callq 0x52c0
movq 0x15e9a(%rip), %rbx     # 0x2bf18
testq %rbx, %rbx
movl %r15d, 0x1c(%rsp)
movl %r12d, 0x18(%rsp)
je 0x1609f
movq %rbx, %rdi
callq 0x5160
testq %rax, %rax
je 0x1609f
addl %eax, %eax
movl %eax, %r14d
leal 0x3(%r14), %eax
testl %r14d, %r14d
cmovnsl %r14d, %eax
andl $-0x4, %eax
movl %r14d, %ecx
subl %eax, %ecx
movl $0x4, %r15d
subl %ecx, %r15d
testl %ecx, %ecx
cmovel %ecx, %r15d
movl $0x4, %r12d
addl %r14d, %r15d
movq 0x15e4f(%rip), %r13     # 0x2bf20
testq %r13, %r13
je 0x160e7
movq %r13, %rdi
callq 0x5160
testq %rax, %rax
je 0x160e7
leal (%r15,%rax,2), %r15d
leal 0x3(%r15), %eax
testl %r15d, %r15d
cmovnsl %r15d, %eax
andl $-0x4, %eax
movl %r15d, %ecx
subl %eax, %ecx
subl %ecx, %r12d
testl %ecx, %ecx
cmovel %ecx, %r12d
addl %r15d, %r12d
movq 0x15e1b(%rip), %r14     # 0x2bf28
testq %r14, %r14
movq %r14, 0x20(%rsp)
je 0x16128
movq %r14, %rdi
callq 0x5160
testq %rax, %rax
je 0x16128
leal (%r12,%rax,2), %r12d
leal 0x3(%r12), %eax
testl %r12d, %r12d
cmovnsl %r12d, %eax
andl $-0x4, %eax
movl %r12d, %ecx
subl %eax, %ecx
movl $0x4, %r15d
subl %ecx, %r15d
testl %ecx, %ecx
cmovel %ecx, %r15d
addl %r12d, %r15d
movslq %r15d, %r14
leaq 0x3c(%r14), %rsi
movl $0x1, %edi
callq 0x5290
testq %rax, %rax
je 0x161c7
movq %rax, %r12
xorl %ebp, %ebp
testq %rbx, %rbx
je 0x1623f
movq %rbx, %rdi
callq 0x5160
testq %rax, %rax
je 0x1623f
addl %eax, %eax
movl %eax, 0xc(%r12)
movl $0x3c, 0x8(%r12)
movq %rbx, %rdi
callq 0x5160
shrq %r14
cmpq %rax, %r14
cmovaeq %rax, %r14
testq %r14, %r14
je 0x1621a
xorl %eax, %eax
movb (%rbx,%rax), %cl
movb %cl, 0x3c(%r12,%rax,2)
movb $0x0, 0x3d(%r12,%rax,2)
incq %rax
cmpq %rax, %r14
jne 0x161ac
addl %r14d, %r14d
jmp 0x1621d
movq 0x13df2(%rip), %rax     # 0x29fc0
movq (%rax), %rbx
callq 0xea3b
leaq 0xc321(%rip), %rsi      # 0x224fe
movq %rbx, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0x52c0
movq (%rbp), %r14
movl $0xc, %ebx
testq %r14, %r14
je 0x1650d
callq 0xea3b
leaq 0xc2f6(%rip), %rsi      # 0x224fe
movq %r14, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0x52c0
jmp 0x1650d
xorl %r14d, %r14d
leal 0x3(%r14), %eax
testl %r14d, %r14d
cmovnsl %r14d, %eax
andl $-0x4, %eax
movl %r14d, %ecx
subl %eax, %ecx
movl $0x4, %ebp
subl %ecx, %ebp
testl %ecx, %ecx
cmovel %ecx, %ebp
addl %r14d, %ebp
testq %r13, %r13
je 0x162aa
movq %r13, %rdi
callq 0x5160
testq %rax, %rax
movq 0x20(%rsp), %rbx
je 0x162d0
addl %eax, %eax
movl %eax, 0x14(%r12)
leal 0x3c(%rbp), %eax
movl %eax, 0x10(%r12)
movq %r13, %rdi
callq 0x5160
movl %r15d, %ecx
subl %ebp, %ecx
movslq %ecx, %rcx
shrq %rcx
cmpq %rax, %rcx
cmovaeq %rax, %rcx
testq %rcx, %rcx
je 0x162b1
movslq %ebp, %rax
addq %r12, %rax
addq $0x3c, %rax
xorl %edx, %edx
movb (%r13,%rdx), %sil
movb %sil, (%rax,%rdx,2)
movb $0x0, 0x1(%rax,%rdx,2)
incq %rdx
cmpq %rdx, %rcx
jne 0x16290
addl %ecx, %ecx
jmp 0x162b3
movq 0x20(%rsp), %rbx
jmp 0x162d0
xorl %ecx, %ecx
leal 0x3(%rcx), %eax
testl %ecx, %ecx
cmovnsl %ecx, %eax
andl $-0x4, %eax
movl %ecx, %edx
subl %eax, %edx
movl $0x4, %ebp
subl %edx, %ebp
testl %edx, %edx
cmovel %edx, %ebp
addl %ecx, %ebp
testq %rbx, %rbx
je 0x16331
movq %rbx, %rdi
callq 0x5160
testq %rax, %rax
je 0x16331
addl %eax, %eax
movl %eax, 0x1c(%r12)
leal 0x3c(%rbp), %eax
movl %eax, 0x18(%r12)
movq %rbx, %rdi
callq 0x5160
movl %r15d, %ecx
subl %ebp, %ecx
movslq %ecx, %rcx
shrq %rcx
cmpq %rax, %rcx
cmovaeq %rax, %rcx
testq %rcx, %rcx
je 0x16331
movslq %ebp, %rax
addq %r12, %rax
addq $0x3c, %rax
xorl %edx, %edx
movb (%rbx,%rdx), %sil
movb %sil, (%rax,%rdx,2)
movb $0x0, 0x1(%rax,%rdx,2)
incq %rdx
cmpq %rdx, %rcx
jne 0x1631c
testl %r15d, %r15d
js 0x16434
movl 0x18(%rsp), %eax
movl %eax, (%r12)
xorl %eax, %eax
cmpl $0x0, 0x1c(%rsp)
setne %al
movl %eax, 0x4(%r12)
movl $0x0, 0x20(%r12)
movl 0x15bd0(%rip), %eax     # 0x2bf30
movl %eax, 0x24(%r12)
movl 0x15bc9(%rip), %eax     # 0x2bf34
movl %eax, 0x28(%r12)
leaq 0xc162(%rip), %rdi      # 0x224d9
callq 0x10b31
movups 0x159b1(%rip), %xmm0    # 0x2bd34
movups %xmm0, 0x2c(%r12)
addl $0x3c, %r15d
movl $0xc, %edi
movl $0x1, %esi
movq %r12, %rdx
movl %r15d, %ecx
callq 0x10a7b
movq %rax, %r14
movq %r12, %rdi
callq 0x5040
leaq 0x10(%rsp), %r15
movq %r14, %rdi
movq %r15, %rsi
movl $0x493e0, %edx          # imm = 0x493E0
callq 0x10c38
movl %eax, %ebx
movq (%r15), %rdi
testq %rdi, %rdi
je 0x1643e
movl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
addl (%rdi), %eax
xorl %r15d, %r15d
cmpl $0x3, %eax
ja 0x163ec
movl %eax, %eax
leaq 0xc44c(%rip), %rcx      # 0x22830
movq (%rcx,%rax,8), %rax
movl (%rdi,%rax), %r15d
testl %ebx, %ebx
sete %bpl
movl %ebx, %eax
orl %r15d, %eax
jne 0x1644f
cmpl $0x0, 0x2c(%rdi)
je 0x1640d
movl 0x34(%rdi), %eax
movl %eax, 0x15b08(%rip)     # 0x2bf10
callq 0x15a9f
testq %r14, %r14
je 0x1641a
movq %r14, %rdi
callq 0x5040
movq 0x10(%rsp), %rdi
xorl %ebx, %ebx
testq %rdi, %rdi
je 0x1650d
callq 0x5040
jmp 0x1650d
movl $0xc, %ebx
jmp 0x1650d
testl %ebx, %ebx
sete %bpl
movl $0x22b8, %r12d          # imm = 0x22B8
xorl %r15d, %r15d
jmp 0x1646e
xorl %esi, %esi
cmpl $0x0, 0x158d8(%rip)     # 0x2bd30
sete %sil
callq 0x10dbe
testl %r15d, %r15d
movl $0x22b8, %r12d          # imm = 0x22B8
cmovnel %r15d, %r12d
testq %r14, %r14
je 0x1647b
movq %r14, %rdi
callq 0x5040
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x16493
callq 0x5040
movq $0x0, 0x10(%rsp)
movq 0x13b26(%rip), %rax     # 0x29fc0
movq (%rax), %r14
callq 0xea3b
movl %r15d, (%rsp)
leaq 0xaed8(%rip), %rsi      # 0x21385
leaq 0xc014(%rip), %rcx      # 0x224c8
movq %r14, %rdi
movq %rax, %rdx
movl $0x7fe, %r8d            # imm = 0x7FE
movl %ebx, %r9d
xorl %eax, %eax
callq 0x52c0
leaq 0x147d7(%rip), %rax     # 0x2aca8
movq (%rax), %r14
testq %r14, %r14
je 0x16506
callq 0xea3b
movl %r15d, (%rsp)
leaq 0xae9c(%rip), %rsi      # 0x21385
leaq 0xbfd8(%rip), %rcx      # 0x224c8
movq %r14, %rdi
movq %rax, %rdx
movl $0x7fe, %r8d            # imm = 0x7FE
movl %ebx, %r9d
xorl %eax, %eax
callq 0x52c0
testb %bpl, %bpl
cmovnel %r12d, %ebx
movl %ebx, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop