// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movb $0x0, (%rax)
callq 0x1d560
movl %eax, -0xc(%rbp)
cmpl $0x0, -0xc(%rbp)
je 0x18b16
jmp 0x18c10
callq 0x1bd30
movl 0x205af(%rip), %eax     # 0x390d0
movq %rax, -0x18(%rbp)
subq $0x6, %rax
ja 0x18b7e
movq -0x18(%rbp), %rax
leaq 0x15a22(%rip), %rcx     # 0x2e558
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq -0x8(%rbp), %rax
movb $0x0, (%rax)
jmp 0x18b85
movq -0x8(%rbp), %rax
movb $0x0, (%rax)
jmp 0x18b85
movq -0x8(%rbp), %rax
movb $0x0, (%rax)
jmp 0x18b85
movq -0x8(%rbp), %rax
movb $0x1, (%rax)
jmp 0x18b85
movq -0x8(%rbp), %rax
movb $0x1, (%rax)
jmp 0x18b85
movq -0x8(%rbp), %rax
movb $0x0, (%rax)
jmp 0x18b85
movq -0x8(%rbp), %rax
movb $0x0, (%rax)
jmp 0x18b85
movq -0x8(%rbp), %rax
movb $0x0, (%rax)
movq -0x8(%rbp), %rax
movzbl (%rax), %eax
cmpl $0x0, %eax
jne 0x18b93
jmp 0x18c10
callq 0x1d7e0
movl %eax, -0xc(%rbp)
cmpl $0x0, -0xc(%rbp)
je 0x18ba3
jmp 0x18c10
movl 0x2052f(%rip), %eax     # 0x390d8
movq %rax, -0x20(%rbp)
subq $0x4, %rax
ja 0x18bf4
movq -0x20(%rbp), %rax
leaq 0x159b6(%rip), %rcx     # 0x2e574
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq -0x8(%rbp), %rax
movb $0x0, (%rax)
jmp 0x18bfb
movq -0x8(%rbp), %rax
movb $0x0, (%rax)
jmp 0x18bfb
movq -0x8(%rbp), %rax
movb $0x1, (%rax)
jmp 0x18bfb
movq -0x8(%rbp), %rax
movb $0x0, (%rax)
jmp 0x18bfb
movq -0x8(%rbp), %rax
movb $0x0, (%rax)
jmp 0x18bfb
movq -0x8(%rbp), %rax
movb $0x0, (%rax)
movq -0x8(%rbp), %rax
movzbl (%rax), %eax
cmpl $0x0, %eax
jne 0x18c0e
xorl %edi, %edi
callq 0x1db30
jmp 0x18c10
movl -0xc(%rbp), %eax
addq $0x20, %rsp
popq %rbp
retq
nopl (%rax)