// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x80, %rsp
movl %edi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movq $0x0, -0x18(%rbp)
movq $0x0, -0x20(%rbp)
movq $0x0, -0x28(%rbp)
movq 0x191f0(%rip), %rax     # 0x36fe0
movq (%rax), %rax
movq %rax, -0x48(%rbp)
callq 0x13930
movq -0x48(%rbp), %rdi
movq %rax, %rdx
movl -0x8(%rbp), %r8d
movl -0xc(%rbp), %r9d
leaq 0x118f6(%rip), %rsi     # 0x2f708
leaq 0x11910(%rip), %rcx     # 0x2f729
movb $0x0, %al
callq 0x52c0
leaq 0x1a041(%rip), %rax     # 0x37e68
cmpq $0x0, (%rax)
je 0x1de64
leaq 0x1a034(%rip), %rax     # 0x37e68
movq (%rax), %rax
movq %rax, -0x50(%rbp)
callq 0x13930
movq -0x50(%rbp), %rdi
movq %rax, %rdx
movl -0x8(%rbp), %r8d
movl -0xc(%rbp), %r9d
leaq 0x118b2(%rip), %rsi     # 0x2f708
leaq 0x118cc(%rip), %rcx     # 0x2f729
movb $0x0, %al
callq 0x52c0
jmp 0x1de66
leaq -0x28(%rbp), %rdi
callq 0x1e140
movl %eax, -0x30(%rbp)
cmpl $0x0, -0x30(%rbp)
jge 0x1de84
movl $0xc, -0x4(%rbp)
jmp 0x1e131
movl -0xc(%rbp), %edi
callq 0x191c0
movl %eax, %ecx
movq -0x28(%rbp), %rax
movl %ecx, (%rax)
cmpl $0x0, -0x8(%rbp)
jne 0x1deac
xorl %edi, %edi
callq 0x191c0
movl %eax, %ecx
movq -0x28(%rbp), %rax
movl %ecx, 0x4(%rax)
jmp 0x1debf
movl $0x1, %edi
callq 0x191c0
movl %eax, %ecx
movq -0x28(%rbp), %rax
movl %ecx, 0x4(%rax)
xorl %edi, %edi
callq 0x191c0
movl %eax, %ecx
movq -0x28(%rbp), %rax
movl %ecx, 0x20(%rax)
movl 0x1b22b(%rip), %edi     # 0x39100
callq 0x191c0
movl %eax, %ecx
movq -0x28(%rbp), %rax
movl %ecx, 0x24(%rax)
movl 0x1b21b(%rip), %edi     # 0x39104
callq 0x191c0
movl %eax, %ecx
movq -0x28(%rbp), %rax
movl %ecx, 0x28(%rax)
movq -0x28(%rbp), %rax
movq %rax, -0x58(%rbp)
leaq 0x11834(%rip), %rdi     # 0x2f73a
callq 0x17000
movq %rax, %rcx
movq -0x58(%rbp), %rax
movq (%rcx), %rdx
movq %rdx, 0x2c(%rax)
movq 0x8(%rcx), %rcx
movq %rcx, 0x34(%rax)
movq -0x28(%rbp), %rdx
movslq -0x30(%rbp), %rax
addq $0x3c, %rax
movl %eax, %ecx
movl $0xc, %edi
movl $0x1, %esi
callq 0x16eb0
movq %rax, -0x18(%rbp)
cmpq $0x0, -0x28(%rbp)
je 0x1df5a
movq -0x28(%rbp), %rdi
callq 0x5040
movq $0x0, -0x28(%rbp)
jmp 0x1df5c
movq -0x18(%rbp), %rdi
imull $0xa, 0x194b9(%rip), %edx # 0x37420
leaq -0x20(%rbp), %rsi
callq 0x17270
movl %eax, -0x2c(%rbp)
cmpq $0x0, -0x20(%rbp)
je 0x1df84
movq -0x20(%rbp), %rax
movq %rax, -0x60(%rbp)
jmp 0x1df8c
xorl %eax, %eax
movq %rax, -0x60(%rbp)
jmp 0x1df8c
movq -0x60(%rbp), %rdi
callq 0x17480
movl %eax, -0x34(%rbp)
cmpl $0x0, -0x2c(%rbp)
jne 0x1dfaf
cmpl $0x0, -0x34(%rbp)
jne 0x1dfaf
cmpq $0x0, -0x20(%rbp)
jne 0x1e0bd
cmpq $0x0, -0x20(%rbp)
je 0x1dfce
movq -0x20(%rbp), %rdi
cmpl $0x0, 0x1af2f(%rip)     # 0x38ef0
sete %al
andb $0x1, %al
movzbl %al, %esi
callq 0x17560
jmp 0x1dfd0
cmpq $0x0, -0x18(%rbp)
je 0x1dfe8
movq -0x18(%rbp), %rdi
callq 0x5040
movq $0x0, -0x18(%rbp)
jmp 0x1dfea
jmp 0x1dfec
cmpq $0x0, -0x20(%rbp)
je 0x1e004
movq -0x20(%rbp), %rdi
callq 0x5040
movq $0x0, -0x20(%rbp)
jmp 0x1e006
jmp 0x1e008
movq 0x18fd1(%rip), %rax     # 0x36fe0
movq (%rax), %rax
movq %rax, -0x68(%rbp)
callq 0x13930
movq -0x68(%rbp), %rdi
movq %rax, %rdx
movl -0x2c(%rbp), %r9d
movl -0x34(%rbp), %eax
leaq 0x105bd(%rip), %rsi     # 0x2e5ed
leaq 0x116f2(%rip), %rcx     # 0x2f729
movl $0x7fe, %r8d            # imm = 0x7FE
movl %eax, (%rsp)
movb $0x0, %al
callq 0x52c0
leaq 0x19e1a(%rip), %rax     # 0x37e68
cmpq $0x0, (%rax)
je 0x1e093
leaq 0x19e0d(%rip), %rax     # 0x37e68
movq (%rax), %rax
movq %rax, -0x70(%rbp)
callq 0x13930
movq -0x70(%rbp), %rdi
movq %rax, %rdx
movl -0x2c(%rbp), %r9d
movl -0x34(%rbp), %eax
leaq 0x10571(%rip), %rsi     # 0x2e5ed
leaq 0x116a6(%rip), %rcx     # 0x2f729
movl $0x7fe, %r8d            # imm = 0x7FE
movl %eax, (%rsp)
movb $0x0, %al
callq 0x52c0
jmp 0x1e095
cmpl $0x0, -0x2c(%rbp)
je 0x1e0a6
movl -0x2c(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x1e131
cmpl $0x0, -0x34(%rbp)
je 0x1e0b4
movl -0x34(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x1e131
movl $0x22b8, -0x4(%rbp)     # imm = 0x22B8
jmp 0x1e131
jmp 0x1e0bf
movq -0x20(%rbp), %rax
movl 0x2c(%rax), %edi
callq 0x191c0
cmpl $0x0, %eax
je 0x1e0f3
movq -0x20(%rbp), %rax
addq $0x30, %rax
movq %rax, -0x40(%rbp)
movq -0x40(%rbp), %rax
movl 0x4(%rax), %edi
callq 0x191c0
movl %eax, 0x1aff2(%rip)     # 0x390e0
callq 0x1bd30
jmp 0x1e0f5
cmpq $0x0, -0x18(%rbp)
je 0x1e10d
movq -0x18(%rbp), %rdi
callq 0x5040
movq $0x0, -0x18(%rbp)
jmp 0x1e10f
jmp 0x1e111
cmpq $0x0, -0x20(%rbp)
je 0x1e129
movq -0x20(%rbp), %rdi
callq 0x5040
movq $0x0, -0x20(%rbp)
jmp 0x1e12b
movl -0x2c(%rbp), %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x80, %rsp
popq %rbp
retq
nopl (%rax)