// File: /workspace/github_c_makefile_star2_O3/Carton32[P]quectel-CM/mbim-cm.c
// Function: requestRegistrationState
static int requestRegistrationState(UCHAR *pPSAttachedState) {
    int retval;

    *pPSAttachedState = 0;
    retval = mbim_register_state_query();
    if (retval)
        goto exit;
    mbim_update_state();

    switch (RegisterState) {
        case MBIMRegisterStateUnknown: *pPSAttachedState = 0; break;
        case MBIMRegisterStateDeregistered: *pPSAttachedState = 0; break;
        case MBIMRegisterStateSearching: *pPSAttachedState = 0; break;
        case MBIMRegisterStateHome: *pPSAttachedState = 1; break;
        case MBIMRegisterStateRoaming: *pPSAttachedState = 1; break;
        case MBIMRegisterStatePartner: *pPSAttachedState = 0; break;
        case MBIMRegisterStateDenied: *pPSAttachedState = 0; break;
        default: *pPSAttachedState = 0; break;
    }

    if (*pPSAttachedState == 0)
        goto exit;

    retval =  mbim_packet_service_query();
    if (retval)
        goto exit;

    switch (PacketServiceState) {
        case MBIMPacketServiceStateUnknown: *pPSAttachedState = 0; break;
        case MBIMPacketServiceStateAttaching: *pPSAttachedState = 0; break;
        case MBIMPacketServiceStateAttached: *pPSAttachedState = 1; break;
        case MBIMPacketServiceStateDetaching: *pPSAttachedState = 0; break;
        case MBIMPacketServiceStateDetached: *pPSAttachedState = 0; break;
        default: *pPSAttachedState = 0; break;
    }

    if (*pPSAttachedState == 0)
        mbim_packet_service_set(MBIMPacketServiceActionAttach);

exit:
    return retval;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rdi, %rbx
movb $0x0, (%rdi)
movq $0x0, 0x8(%rsp)
movq 0x171e5(%rip), %rax     # 0x29fc0
movq (%rax), %r14
callq 0xea3b
leaq 0xf443(%rip), %rsi      # 0x2222d
leaq 0xf64e(%rip), %rcx      # 0x2243f
movq %r14, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0x52c0
leaq 0x17ea3(%rip), %rax     # 0x2aca8
movq (%rax), %r14
testq %r14, %r14
je 0x12e2d
callq 0xea3b
leaq 0xf414(%rip), %rsi      # 0x2222d
leaq 0xf61f(%rip), %rcx      # 0x2243f
movq %r14, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0x52c0
xorl %r12d, %r12d
movl $0x9, %edi
xorl %esi, %esi
xorl %edx, %edx
xorl %ecx, %ecx
callq 0x10a7b
movq %rax, %r14
leaq 0x8(%rsp), %r15
movq %rax, %rdi
movq %r15, %rsi
movl $0x7530, %edx           # imm = 0x7530
callq 0x10c38
movl %eax, %ebp
movq (%r15), %rdi
testq %rdi, %rdi
je 0x12ec5
movl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
addl (%rdi), %eax
cmpl $0x3, %eax
ja 0x12e7f
movl %eax, %eax
leaq 0xf9b9(%rip), %rcx      # 0x22830
movq (%rcx,%rax,8), %rax
movl (%rdi,%rax), %r12d
testl %ebp, %ebp
sete %r15b
movl %ebp, %eax
orl %r12d, %eax
jne 0x12ed6
cmpl $0x0, 0x2c(%rdi)
je 0x12ea0
movl 0x34(%rdi), %eax
movl %eax, 0x19065(%rip)     # 0x2bf00
callq 0x15a9f
testq %r14, %r14
je 0x12ead
movq %r14, %rdi
callq 0x5040
movq 0x8(%rsp), %rdi
testq %rdi, %rdi
je 0x12f98
callq 0x5040
jmp 0x12f98
testl %ebp, %ebp
sete %r15b
movl $0x22b8, %r13d          # imm = 0x22B8
xorl %r12d, %r12d
jmp 0x12ef5
xorl %esi, %esi
cmpl $0x0, 0x18e51(%rip)     # 0x2bd30
sete %sil
callq 0x10dbe
testl %r12d, %r12d
movl $0x22b8, %r13d          # imm = 0x22B8
cmovnel %r12d, %r13d
testq %r14, %r14
je 0x12f02
movq %r14, %rdi
callq 0x5040
movq 0x8(%rsp), %rdi
testq %rdi, %rdi
je 0x12f1a
callq 0x5040
movq $0x0, 0x8(%rsp)
movq 0x1709f(%rip), %rax     # 0x29fc0
movq (%rax), %r14
callq 0xea3b
movl %r12d, (%rsp)
leaq 0xe451(%rip), %rsi      # 0x21385
leaq 0xf504(%rip), %rcx      # 0x2243f
movq %r14, %rdi
movq %rax, %rdx
movl $0x781, %r8d            # imm = 0x781
movl %ebp, %r9d
xorl %eax, %eax
callq 0x52c0
leaq 0x17d50(%rip), %rax     # 0x2aca8
movq (%rax), %r14
testq %r14, %r14
je 0x12f8d
callq 0xea3b
movl %r12d, (%rsp)
leaq 0xe415(%rip), %rsi      # 0x21385
leaq 0xf4c8(%rip), %rcx      # 0x2243f
movq %r14, %rdi
movq %rax, %rdx
movl $0x781, %r8d            # imm = 0x781
movl %ebp, %r9d
xorl %eax, %eax
callq 0x52c0
testb %r15b, %r15b
cmovnel %r13d, %ebp
testl %ebp, %ebp
jne 0x12fbe
callq 0x15a9f
movl 0x18f5d(%rip), %eax     # 0x2bf00
cmpq $0x6, %rax
ja 0x12fb9
leaq 0xe378(%rip), %rcx      # 0x21328
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movb $0x0, (%rbx)
xorl %ebp, %ebp
movl %ebp, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movb $0x1, (%rbx)
movq $0x0, 0x8(%rsp)
movq 0x16fde(%rip), %rax     # 0x29fc0
movq (%rax), %r14
callq 0xea3b
leaq 0xf23c(%rip), %rsi      # 0x2222d
leaq 0xf461(%rip), %rcx      # 0x22459
movq %r14, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0x52c0
leaq 0x17c9c(%rip), %rax     # 0x2aca8
movq (%rax), %r14
testq %r14, %r14
je 0x13034
callq 0xea3b
leaq 0xf20d(%rip), %rsi      # 0x2222d
leaq 0xf432(%rip), %rcx      # 0x22459
movq %r14, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0x52c0
xorl %r12d, %r12d
movl $0xa, %edi
xorl %esi, %esi
xorl %edx, %edx
xorl %ecx, %ecx
callq 0x10a7b
movq %rax, %r14
leaq 0x8(%rsp), %r15
movq %rax, %rdi
movq %r15, %rsi
movl $0x7530, %edx           # imm = 0x7530
callq 0x10c38
movl %eax, %ebp
movq (%r15), %rdi
testq %rdi, %rdi
je 0x13102
movl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
addl (%rdi), %eax
cmpl $0x3, %eax
ja 0x1308a
movl %eax, %eax
leaq 0xf7ae(%rip), %rcx      # 0x22830
movq (%rcx,%rax,8), %rax
movl (%rdi,%rax), %r12d
testl %ebp, %ebp
sete %r15b
movl %ebp, %eax
orl %r12d, %eax
jne 0x13113
cmpl $0x0, 0x2c(%rdi)
je 0x13248
movl 0x34(%rdi), %eax
movl %eax, 0x18e5e(%rip)     # 0x2bf08
callq 0x15a9f
movq 0x8(%rsp), %r13
cmpl $0x20, 0x2c(%r13)
jne 0x13248
movq 0x16efa(%rip), %rax     # 0x29fc0
movq (%rax), %r15
callq 0xea3b
movl 0x38(%r13), %esi
movl $0x4, %edx
leaq 0x169e2(%rip), %r12     # 0x29ac0
leaq 0xe557(%rip), %rcx      # 0x2163c
cmpl %esi, -0x4(%rdx,%r12)
je 0x131de
addq $0xc, %rdx
cmpq $0xd0, %rdx
jne 0x130e5
jmp 0x131e2
testl %ebp, %ebp
sete %r15b
movl $0x22b8, %r13d          # imm = 0x22B8
xorl %r12d, %r12d
jmp 0x13132
xorl %esi, %esi
cmpl $0x0, 0x18c14(%rip)     # 0x2bd30
sete %sil
callq 0x10dbe
testl %r12d, %r12d
movl $0x22b8, %r13d          # imm = 0x22B8
cmovnel %r12d, %r13d
testq %r14, %r14
je 0x1313f
movq %r14, %rdi
callq 0x5040
movq 0x8(%rsp), %rdi
testq %rdi, %rdi
je 0x13157
callq 0x5040
movq $0x0, 0x8(%rsp)
movq 0x16e62(%rip), %rax     # 0x29fc0
movq (%rax), %r14
callq 0xea3b
movl %r12d, (%rsp)
leaq 0xe214(%rip), %rsi      # 0x21385
leaq 0xf2e1(%rip), %rcx      # 0x22459
movq %r14, %rdi
movq %rax, %rdx
movl $0x794, %r8d            # imm = 0x794
movl %ebp, %r9d
xorl %eax, %eax
callq 0x52c0
leaq 0x17b13(%rip), %rax     # 0x2aca8
movq (%rax), %r14
testq %r14, %r14
je 0x131ca
callq 0xea3b
movl %r12d, (%rsp)
leaq 0xe1d8(%rip), %rsi      # 0x21385
leaq 0xf2a5(%rip), %rcx      # 0x22459
movq %r14, %rdi
movq %rax, %rdx
movl $0x794, %r8d            # imm = 0x794
movl %ebp, %r9d
xorl %eax, %eax
callq 0x52c0
testb %r15b, %r15b
cmovnel %r13d, %ebp
testl %ebp, %ebp
jne 0x12fbe
jmp 0x13264
movq (%rdx,%r12), %rcx
leaq 0xf28a(%rip), %rsi      # 0x22473
movq %r15, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0x52c0
leaq 0x17aab(%rip), %rax     # 0x2aca8
movq (%rax), %r15
testq %r15, %r15
je 0x13248
callq 0xea3b
movl 0x38(%r13), %esi
movl $0x4, %edx
leaq 0xe422(%rip), %rcx      # 0x2163c
cmpl %esi, -0x4(%rdx,%r12)
je 0x13230
addq $0xc, %rdx
cmpq $0xd0, %rdx
jne 0x1321a
jmp 0x13234
movq (%rdx,%r12), %rcx
leaq 0xf238(%rip), %rsi      # 0x22473
movq %r15, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0x52c0
testq %r14, %r14
je 0x13255
movq %r14, %rdi
callq 0x5040
movq 0x8(%rsp), %rdi
testq %rdi, %rdi
je 0x13264
callq 0x5040
cmpl $0x2, 0x18c9d(%rip)     # 0x2bf08
jne 0x13275
movb $0x1, (%rbx)
jmp 0x12fbc
movb $0x0, (%rbx)
movq $0x0, 0x8(%rsp)
movl $0x0, 0x14(%rsp)
movq 0x16d30(%rip), %rax     # 0x29fc0
movq (%rax), %rbx
callq 0xea3b
leaq 0xef8e(%rip), %rsi      # 0x2222d
leaq 0xf1e9(%rip), %rcx      # 0x2248f
xorl %ebp, %ebp
movq %rbx, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0x52c0
leaq 0x179ec(%rip), %rax     # 0x2aca8
movq (%rax), %rbx
testq %rbx, %rbx
je 0x132e4
callq 0xea3b
leaq 0xef5d(%rip), %rsi      # 0x2222d
leaq 0xf1b8(%rip), %rcx      # 0x2248f
movq %rbx, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0x52c0
leaq 0x14(%rsp), %rdx
movl $0xa, %edi
movl $0x1, %esi
movl $0x4, %ecx
callq 0x10a7b
movq %rax, %r14
leaq 0x8(%rsp), %r15
movq %rax, %rdi
movq %r15, %rsi
movl $0x7530, %edx           # imm = 0x7530
callq 0x10c38
movl %eax, %ebx
movq (%r15), %rdi
testq %rdi, %rdi
je 0x1338e
movl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
addl (%rdi), %eax
xorl %ebp, %ebp
cmpl $0x3, %eax
ja 0x1333d
movl %eax, %eax
leaq 0xf4fa(%rip), %rcx      # 0x22830
movq (%rcx,%rax,8), %rax
movl (%rdi,%rax), %ebp
movl %ebx, %eax
orl %ebp, %eax
jne 0x1337c
cmpl $0x0, 0x2c(%rdi)
je 0x13357
movl 0x34(%rdi), %eax
movl %eax, 0x18bb6(%rip)     # 0x2bf08
callq 0x15a9f
testq %r14, %r14
je 0x13364
movq %r14, %rdi
callq 0x5040
movq 0x8(%rsp), %rdi
testq %rdi, %rdi
je 0x12fbc
callq 0x5040
jmp 0x12fbc
xorl %esi, %esi
cmpl $0x0, 0x189ab(%rip)     # 0x2bd30
sete %sil
callq 0x10dbe
testq %r14, %r14
je 0x1339b
movq %r14, %rdi
callq 0x5040
movq 0x8(%rsp), %rdi
testq %rdi, %rdi
je 0x133b3
callq 0x5040
movq $0x0, 0x8(%rsp)
movq 0x16c06(%rip), %rax     # 0x29fc0
movq (%rax), %r14
callq 0xea3b
movl %ebp, (%rsp)
leaq 0xdfb9(%rip), %rsi      # 0x21385
leaq 0xf0bc(%rip), %rcx      # 0x2248f
movq %r14, %rdi
movq %rax, %rdx
movl $0x7ad, %r8d            # imm = 0x7AD
movl %ebx, %r9d
xorl %eax, %eax
callq 0x52c0
leaq 0x178b8(%rip), %rax     # 0x2aca8
movq (%rax), %r14
testq %r14, %r14
je 0x12fbc
callq 0xea3b
movl %ebp, (%rsp)
leaq 0xdf7a(%rip), %rsi      # 0x21385
leaq 0xf07d(%rip), %rcx      # 0x2248f
movq %r14, %rdi
movq %rax, %rdx
movl $0x7ad, %r8d            # imm = 0x7AD
movl %ebx, %r9d
xorl %eax, %eax
callq 0x52c0
jmp 0x12fbc