// File: /workspace/github_c_makefile_star2_O1/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, %r14d
movl %edi, %ebp
movq $0x0, 0x8(%rsp)
movq 0x13de9(%rip), %rax     # 0x29fc0
movq (%rax), %rbx
callq 0xeb2f
leaq 0xc299(%rip), %rsi      # 0x2247f
leaq 0xc2b3(%rip), %rcx      # 0x224a0
xorl %r15d, %r15d
movq %rbx, %rdi
movq %rax, %rdx
movl %ebp, %r8d
movl %r14d, %r9d
xorl %eax, %eax
callq 0x52c0
leaq 0x14a9e(%rip), %rax     # 0x2aca8
movq (%rax), %rbx
testq %rbx, %rbx
je 0x16238
callq 0xeb2f
leaq 0xc261(%rip), %rsi      # 0x2247f
leaq 0xc27b(%rip), %rcx      # 0x224a0
movq %rbx, %rdi
movq %rax, %rdx
movl %ebp, %r8d
movl %r14d, %r9d
xorl %eax, %eax
callq 0x52c0
movq 0x15cd9(%rip), %rbx     # 0x2bf18
testq %rbx, %rbx
movl %ebp, 0x14(%rsp)
movl %r14d, 0x10(%rsp)
je 0x1625f
movq %rbx, %rdi
callq 0x5160
testq %rax, %rax
je 0x1625f
addl %eax, %eax
movl %eax, %r15d
leal 0x3(%r15), %eax
testl %r15d, %r15d
cmovnsl %r15d, %eax
andl $-0x4, %eax
movl %r15d, %ecx
subl %eax, %ecx
movl $0x4, %r12d
subl %ecx, %r12d
testl %ecx, %ecx
cmovel %ecx, %r12d
movl $0x4, %r14d
addl %r15d, %r12d
movq 0x15c8f(%rip), %r13     # 0x2bf20
testq %r13, %r13
je 0x162a7
movq %r13, %rdi
callq 0x5160
testq %rax, %rax
je 0x162a7
leal (%r12,%rax,2), %r12d
leal 0x3(%r12), %eax
testl %r12d, %r12d
cmovnsl %r12d, %eax
andl $-0x4, %eax
movl %r12d, %ecx
subl %eax, %ecx
subl %ecx, %r14d
testl %ecx, %ecx
cmovel %ecx, %r14d
addl %r12d, %r14d
movq 0x15c5a(%rip), %r15     # 0x2bf28
testq %r15, %r15
movq %r15, 0x18(%rsp)
movq %r13, 0x20(%rsp)
je 0x162ee
movq %r15, %rdi
callq 0x5160
testq %rax, %rax
je 0x162ee
leal (%r14,%rax,2), %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
addl %r14d, %r15d
movslq %r15d, %r13
leaq 0x3c(%r13), %rbp
movq %rbp, %rdi
callq 0x5360
movq %rax, %r14
testq %rax, %rax
je 0x16396
xorl %r12d, %r12d
movq %r14, %rdi
xorl %esi, %esi
movq %rbp, %rdx
callq 0x5200
testq %rbx, %rbx
je 0x16418
movq %rbx, %rdi
callq 0x5160
testq %rax, %rax
je 0x16418
addl %eax, %eax
movl %eax, 0xc(%r14)
movl $0x3c, 0x8(%r14)
movq %rbx, %rdi
callq 0x5160
shrq %r13
cmpq %rax, %r13
cmovaeq %rax, %r13
testq %r13, %r13
je 0x163f0
xorl %eax, %eax
movb (%rbx,%rax), %cl
movb %cl, 0x3c(%r14,%rax,2)
movb $0x0, 0x3d(%r14,%rax,2)
incq %rax
cmpq %rax, %r13
jne 0x1637b
addl %r13d, %r13d
jmp 0x163f3
movq 0x13c23(%rip), %rax     # 0x29fc0
movq (%rax), %rbx
callq 0xeb2f
leaq 0xc12a(%rip), %rsi      # 0x224d6
movq %rbx, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0x52c0
leaq 0x148e8(%rip), %rax     # 0x2aca8
movq (%rax), %rbx
movl $0xffffffff, %r15d      # imm = 0xFFFFFFFF
testq %rbx, %rbx
je 0x16515
callq 0xeb2f
leaq 0xc0f8(%rip), %rsi      # 0x224d6
movq %rbx, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0x52c0
jmp 0x16515
xorl %r13d, %r13d
leal 0x3(%r13), %eax
testl %r13d, %r13d
cmovnsl %r13d, %eax
andl $-0x4, %eax
movl %r13d, %ecx
subl %eax, %ecx
movl $0x4, %r12d
subl %ecx, %r12d
testl %ecx, %ecx
cmovel %ecx, %r12d
addl %r13d, %r12d
movq 0x20(%rsp), %r13
testq %r13, %r13
je 0x16489
movq %r13, %rdi
callq 0x5160
testq %rax, %rax
movq 0x18(%rsp), %rbx
je 0x164b3
addl %eax, %eax
movl %eax, 0x14(%r14)
leal 0x3c(%r12), %eax
movl %eax, 0x10(%r14)
movq %r13, %rdi
callq 0x5160
movl %r15d, %ecx
subl %r12d, %ecx
movslq %ecx, %rcx
shrq %rcx
cmpq %rax, %rcx
cmovaeq %rax, %rcx
testq %rcx, %rcx
je 0x16490
movslq %r12d, %rax
addq %r14, %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 0x1646f
addl %ecx, %ecx
jmp 0x16492
movq 0x18(%rsp), %rbx
jmp 0x164b3
xorl %ecx, %ecx
leal 0x3(%rcx), %eax
testl %ecx, %ecx
cmovnsl %ecx, %eax
andl $-0x4, %eax
movl %ecx, %edx
subl %eax, %edx
movl $0x4, %r12d
subl %edx, %r12d
testl %edx, %edx
cmovel %edx, %r12d
addl %ecx, %r12d
testq %rbx, %rbx
je 0x16515
movq %rbx, %rdi
callq 0x5160
testq %rax, %rax
je 0x16515
addl %eax, %eax
movl %eax, 0x1c(%r14)
leal 0x3c(%r12), %eax
movl %eax, 0x18(%r14)
movq %rbx, %rdi
callq 0x5160
movl %r15d, %ecx
subl %r12d, %ecx
movslq %ecx, %rcx
shrq %rcx
cmpq %rax, %rcx
cmovaeq %rax, %rcx
testq %rcx, %rcx
je 0x16515
movslq %r12d, %rax
addq %r14, %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 0x16500
testl %r15d, %r15d
js 0x165e0
movl 0x10(%rsp), %eax
movl %eax, (%r14)
xorl %eax, %eax
cmpl $0x0, 0x14(%rsp)
setne %al
movl %eax, 0x4(%r14)
movl $0x0, 0x20(%r14)
movl 0x159ef(%rip), %eax     # 0x2bf30
movl %eax, 0x24(%r14)
movl 0x159e9(%rip), %eax     # 0x2bf34
movl %eax, 0x28(%r14)
leaq 0xbf5b(%rip), %rdi      # 0x224b1
callq 0x10c1b
movups 0x157d2(%rip), %xmm0    # 0x2bd34
movups %xmm0, 0x2c(%r14)
addl $0x3c, %r15d
movl $0xc, %edi
movl $0x1, %esi
movq %r14, %rdx
movl %r15d, %ecx
callq 0x10b66
movq %rax, %r15
movq %r14, %rdi
callq 0x5040
leaq 0x8(%rsp), %r14
movq %r15, %rdi
movq %r14, %rsi
movl $0x493e0, %edx          # imm = 0x493E0
callq 0x10d09
movl %eax, %ebx
movq (%r14), %rdi
xorl %ebp, %ebp
testq %rdi, %rdi
je 0x165c8
movl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
addl (%rdi), %eax
cmpl $0x3, %eax
ja 0x165c8
movl %eax, %eax
leaq 0xc247(%rip), %rcx      # 0x22808
movq (%rcx,%rax,8), %rax
movl (%rdi,%rax), %ebp
movl %ebx, %eax
orl %ebp, %eax
sete %al
testq %rdi, %rdi
setne %r12b
andb %al, %r12b
je 0x165ea
jmp 0x166a9
movl $0xc, %eax
jmp 0x166ee
testq %rdi, %rdi
je 0x16601
xorl %esi, %esi
cmpl $0x0, 0x15738(%rip)     # 0x2bd30
sete %sil
callq 0x10e8f
testq %r15, %r15
je 0x1660e
movq %r15, %rdi
callq 0x5040
movq 0x8(%rsp), %rdi
testq %rdi, %rdi
je 0x16626
callq 0x5040
movq $0x0, 0x8(%rsp)
movq 0x13993(%rip), %rax     # 0x29fc0
movq (%rax), %r14
callq 0xeb2f
movl %ebp, (%rsp)
leaq 0xad1e(%rip), %rsi      # 0x2135d
leaq 0xbe5a(%rip), %rcx      # 0x224a0
movq %r14, %rdi
movq %rax, %rdx
movl $0x7fe, %r8d            # imm = 0x7FE
movl %ebx, %r9d
xorl %eax, %eax
callq 0x52c0
leaq 0x14645(%rip), %rax     # 0x2aca8
movq (%rax), %r14
testq %r14, %r14
je 0x16697
callq 0xeb2f
movl %ebp, (%rsp)
leaq 0xace3(%rip), %rsi      # 0x2135d
leaq 0xbe1f(%rip), %rcx      # 0x224a0
movq %r14, %rdi
movq %rax, %rdx
movl $0x7fe, %r8d            # imm = 0x7FE
movl %ebx, %r9d
xorl %eax, %eax
callq 0x52c0
testl %ebp, %ebp
movl $0x22b8, %eax           # imm = 0x22B8
cmovnel %ebp, %eax
testl %ebx, %ebx
cmovnel %ebx, %eax
xorl %r15d, %r15d
testb %r12b, %r12b
je 0x166ee
movq 0x8(%rsp), %rax
cmpl $0x0, 0x2c(%rax)
je 0x166c7
movl 0x34(%rax), %eax
movl %eax, 0x1584e(%rip)     # 0x2bf10
callq 0x15c62
testq %r15, %r15
je 0x166d4
movq %r15, %rdi
callq 0x5040
movq 0x8(%rsp), %rdi
testq %rdi, %rdi
je 0x166ec
callq 0x5040
movq $0x0, 0x8(%rsp)
movl %ebx, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nopl (%rax)