// File: /workspace/github_c_makefile_star2_O0/Carton32[P]quectel-CM/mbim-cm.c
// Function: mbim_populate_connect_data
static int mbim_populate_connect_data(MBIM_SET_CONNECT_T **connect_req_ptr) {
    int offset;
    int buflen = 0;

    if (mbim_apn && strlen(mbim_apn) > 0) buflen += 2*strlen(mbim_apn) ;
    _align_32(buflen);
    if (mbim_user && strlen(mbim_user) > 0) buflen += 2*strlen(mbim_user);
    _align_32(buflen);
    if (mbim_passwd && strlen(mbim_passwd) > 0) buflen += 2*strlen(mbim_passwd);
    _align_32(buflen);

    *connect_req_ptr = (MBIM_SET_CONNECT_T*)malloc(sizeof(MBIM_SET_CONNECT_T) + buflen);
    if (! *connect_req_ptr) {
        mbim_debug("not enough memory\n");
        return -1;
    }
    memset(*connect_req_ptr, 0, sizeof(MBIM_SET_CONNECT_T) + buflen);

    offset = 0;
    if (mbim_apn && strlen(mbim_apn) > 0) {
        (*connect_req_ptr)->AccessStringSize = htole32(2*strlen(mbim_apn));
        (*connect_req_ptr)->AccessStringOffset = htole32(offset + sizeof(MBIM_SET_CONNECT_T));
        offset = char2wchar(mbim_apn, strlen(mbim_apn), &(*connect_req_ptr)->DataBuffer[offset], buflen - offset);
        _align_32(offset);
    }

    if (mbim_user && strlen(mbim_user) > 0) {
        (*connect_req_ptr)->UserNameSize = htole32(2*strlen(mbim_user));
        (*connect_req_ptr)->UserNameOffset = htole32(offset + sizeof(MBIM_SET_CONNECT_T));
        offset = char2wchar(mbim_user, strlen(mbim_user), &(*connect_req_ptr)->DataBuffer[offset], buflen - offset);
        _align_32(offset);
    }

    if (mbim_passwd && strlen(mbim_passwd) > 0) {
        (*connect_req_ptr)->PasswordSize = htole32(2*strlen(mbim_passwd));
        (*connect_req_ptr)->PasswordOffset = htole32(offset + sizeof(MBIM_SET_CONNECT_T));
        offset = char2wchar(mbim_passwd, strlen(mbim_passwd), &(*connect_req_ptr)->DataBuffer[offset], buflen - offset);
    }

    return buflen;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x60, %rsp
movq %rdi, -0x10(%rbp)
movl $0x0, -0x18(%rbp)
cmpq $0x0, 0x1af8d(%rip)     # 0x390e8
je 0x1e18b
movq 0x1af84(%rip), %rdi     # 0x390e8
callq 0x5160
cmpq $0x0, %rax
jbe 0x1e18b
movq 0x1af72(%rip), %rdi     # 0x390e8
callq 0x5160
movq %rax, %rcx
shlq %rcx
movslq -0x18(%rbp), %rax
addq %rcx, %rax
movl %eax, -0x18(%rbp)
movl -0x18(%rbp), %eax
movl $0x4, %ecx
cltd
idivl %ecx
cmpl $0x0, %edx
je 0x1e1b2
movl -0x18(%rbp), %eax
movl $0x4, %ecx
cltd
idivl %ecx
movl $0x4, %eax
subl %edx, %eax
movl %eax, -0x1c(%rbp)
jmp 0x1e1b9
xorl %eax, %eax
movl %eax, -0x1c(%rbp)
jmp 0x1e1b9
movl -0x1c(%rbp), %eax
addl -0x18(%rbp), %eax
movl %eax, -0x18(%rbp)
cmpq $0x0, 0x1af26(%rip)     # 0x390f0
je 0x1e1fa
movq 0x1af1d(%rip), %rdi     # 0x390f0
callq 0x5160
cmpq $0x0, %rax
jbe 0x1e1fa
movq 0x1af0b(%rip), %rdi     # 0x390f0
callq 0x5160
movq %rax, %rcx
shlq %rcx
movslq -0x18(%rbp), %rax
addq %rcx, %rax
movl %eax, -0x18(%rbp)
movl -0x18(%rbp), %eax
movl $0x4, %ecx
cltd
idivl %ecx
cmpl $0x0, %edx
je 0x1e221
movl -0x18(%rbp), %eax
movl $0x4, %ecx
cltd
idivl %ecx
movl $0x4, %eax
subl %edx, %eax
movl %eax, -0x20(%rbp)
jmp 0x1e228
xorl %eax, %eax
movl %eax, -0x20(%rbp)
jmp 0x1e228
movl -0x20(%rbp), %eax
addl -0x18(%rbp), %eax
movl %eax, -0x18(%rbp)
cmpq $0x0, 0x1aebf(%rip)     # 0x390f8
je 0x1e269
movq 0x1aeb6(%rip), %rdi     # 0x390f8
callq 0x5160
cmpq $0x0, %rax
jbe 0x1e269
movq 0x1aea4(%rip), %rdi     # 0x390f8
callq 0x5160
movq %rax, %rcx
shlq %rcx
movslq -0x18(%rbp), %rax
addq %rcx, %rax
movl %eax, -0x18(%rbp)
movl -0x18(%rbp), %eax
movl $0x4, %ecx
cltd
idivl %ecx
cmpl $0x0, %edx
je 0x1e290
movl -0x18(%rbp), %eax
movl $0x4, %ecx
cltd
idivl %ecx
movl $0x4, %eax
subl %edx, %eax
movl %eax, -0x24(%rbp)
jmp 0x1e297
xorl %eax, %eax
movl %eax, -0x24(%rbp)
jmp 0x1e297
movl -0x24(%rbp), %eax
addl -0x18(%rbp), %eax
movl %eax, -0x18(%rbp)
movslq -0x18(%rbp), %rdi
addq $0x3c, %rdi
callq 0x5370
movq %rax, %rcx
movq -0x10(%rbp), %rax
movq %rcx, (%rax)
movq -0x10(%rbp), %rax
cmpq $0x0, (%rax)
jne 0x1e32e
jmp 0x1e2c3
movq 0x18d16(%rip), %rax     # 0x36fe0
movq (%rax), %rax
movq %rax, -0x30(%rbp)
callq 0x13930
movq -0x30(%rbp), %rdi
movq %rax, %rdx
leaq 0x1147b(%rip), %rsi     # 0x2f75f
movb $0x0, %al
callq 0x52c0
leaq 0x19b76(%rip), %rax     # 0x37e68
cmpq $0x0, (%rax)
je 0x1e320
leaq 0x19b69(%rip), %rax     # 0x37e68
movq (%rax), %rax
movq %rax, -0x38(%rbp)
callq 0x13930
movq -0x38(%rbp), %rdi
movq %rax, %rdx
leaq 0x11446(%rip), %rsi     # 0x2f75f
movb $0x0, %al
callq 0x52c0
jmp 0x1e322
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x1e5a1
movq -0x10(%rbp), %rax
movq (%rax), %rdi
movslq -0x18(%rbp), %rdx
addq $0x3c, %rdx
xorl %esi, %esi
callq 0x5200
movl $0x0, -0x14(%rbp)
cmpq $0x0, 0x1ad95(%rip)     # 0x390e8
je 0x1e424
movq 0x1ad88(%rip), %rdi     # 0x390e8
callq 0x5160
cmpq $0x0, %rax
jbe 0x1e424
movq 0x1ad72(%rip), %rdi     # 0x390e8
callq 0x5160
shlq %rax
movl %eax, %edi
callq 0x191c0
movl %eax, %ecx
movq -0x10(%rbp), %rax
movq (%rax), %rax
movl %ecx, 0xc(%rax)
movslq -0x14(%rbp), %rax
addq $0x3c, %rax
movl %eax, %edi
callq 0x191c0
movl %eax, %ecx
movq -0x10(%rbp), %rax
movq (%rax), %rax
movl %ecx, 0x8(%rax)
movq 0x1ad35(%rip), %rax     # 0x390e8
movq %rax, -0x40(%rbp)
movq 0x1ad2a(%rip), %rdi     # 0x390e8
callq 0x5160
movq -0x40(%rbp), %rdi
movq %rax, %rsi
movq -0x10(%rbp), %rax
movq (%rax), %rdx
addq $0x3c, %rdx
movslq -0x14(%rbp), %rax
addq %rax, %rdx
movl -0x18(%rbp), %eax
subl -0x14(%rbp), %eax
movslq %eax, %rcx
callq 0x171e0
movl %eax, -0x14(%rbp)
movl -0x14(%rbp), %eax
movl $0x4, %ecx
cltd
idivl %ecx
cmpl $0x0, %edx
je 0x1e414
movl -0x14(%rbp), %eax
movl $0x4, %ecx
cltd
idivl %ecx
movl $0x4, %eax
subl %edx, %eax
movl %eax, -0x44(%rbp)
jmp 0x1e41b
xorl %eax, %eax
movl %eax, -0x44(%rbp)
jmp 0x1e41b
movl -0x44(%rbp), %eax
addl -0x14(%rbp), %eax
movl %eax, -0x14(%rbp)
cmpq $0x0, 0x1acc4(%rip)     # 0x390f0
je 0x1e4fd
movq 0x1acb7(%rip), %rdi     # 0x390f0
callq 0x5160
cmpq $0x0, %rax
jbe 0x1e4fd
movq 0x1aca1(%rip), %rdi     # 0x390f0
callq 0x5160
shlq %rax
movl %eax, %edi
callq 0x191c0
movl %eax, %ecx
movq -0x10(%rbp), %rax
movq (%rax), %rax
movl %ecx, 0x14(%rax)
movslq -0x14(%rbp), %rax
addq $0x3c, %rax
movl %eax, %edi
callq 0x191c0
movl %eax, %ecx
movq -0x10(%rbp), %rax
movq (%rax), %rax
movl %ecx, 0x10(%rax)
movq 0x1ac64(%rip), %rax     # 0x390f0
movq %rax, -0x50(%rbp)
movq 0x1ac59(%rip), %rdi     # 0x390f0
callq 0x5160
movq -0x50(%rbp), %rdi
movq %rax, %rsi
movq -0x10(%rbp), %rax
movq (%rax), %rdx
addq $0x3c, %rdx
movslq -0x14(%rbp), %rax
addq %rax, %rdx
movl -0x18(%rbp), %eax
subl -0x14(%rbp), %eax
movslq %eax, %rcx
callq 0x171e0
movl %eax, -0x14(%rbp)
movl -0x14(%rbp), %eax
movl $0x4, %ecx
cltd
idivl %ecx
cmpl $0x0, %edx
je 0x1e4ed
movl -0x14(%rbp), %eax
movl $0x4, %ecx
cltd
idivl %ecx
movl $0x4, %eax
subl %edx, %eax
movl %eax, -0x54(%rbp)
jmp 0x1e4f4
xorl %eax, %eax
movl %eax, -0x54(%rbp)
jmp 0x1e4f4
movl -0x54(%rbp), %eax
addl -0x14(%rbp), %eax
movl %eax, -0x14(%rbp)
cmpq $0x0, 0x1abf3(%rip)     # 0x390f8
je 0x1e59b
movq 0x1abe6(%rip), %rdi     # 0x390f8
callq 0x5160
cmpq $0x0, %rax
jbe 0x1e59b
movq 0x1abd4(%rip), %rdi     # 0x390f8
callq 0x5160
shlq %rax
movl %eax, %edi
callq 0x191c0
movl %eax, %ecx
movq -0x10(%rbp), %rax
movq (%rax), %rax
movl %ecx, 0x1c(%rax)
movslq -0x14(%rbp), %rax
addq $0x3c, %rax
movl %eax, %edi
callq 0x191c0
movl %eax, %ecx
movq -0x10(%rbp), %rax
movq (%rax), %rax
movl %ecx, 0x18(%rax)
movq 0x1ab97(%rip), %rax     # 0x390f8
movq %rax, -0x60(%rbp)
movq 0x1ab8c(%rip), %rdi     # 0x390f8
callq 0x5160
movq -0x60(%rbp), %rdi
movq %rax, %rsi
movq -0x10(%rbp), %rax
movq (%rax), %rdx
addq $0x3c, %rdx
movslq -0x14(%rbp), %rax
addq %rax, %rdx
movl -0x18(%rbp), %eax
subl -0x14(%rbp), %eax
movslq %eax, %rcx
callq 0x171e0
movl %eax, -0x14(%rbp)
movl -0x18(%rbp), %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x60, %rsp
popq %rbp
retq
nopw (%rax,%rax)