// File: /workspace/github_c_makefile_star2_O0/Carton32[P]quectel-CM/QMIThread.c
// Function: requestRegistrationState2
static int requestRegistrationState2(UCHAR *pPSAttachedState) {
    PQCQMIMSG pRequest;
    PQCQMIMSG pResponse;
    PQMUX_MSG pMUXMsg;
    int err;
    USHORT MobileCountryCode = 0;
    USHORT MobileNetworkCode = 0;
    const char *pDataCapStr = "UNKNOW";
    LONG remainingLen;
    PSERVICE_STATUS_INFO pServiceStatusInfo;
    int is_lte = 0;
    PCDMA_SYSTEM_INFO pCdmaSystemInfo;
    PHDR_SYSTEM_INFO pHdrSystemInfo;
    PGSM_SYSTEM_INFO pGsmSystemInfo;
    PWCDMA_SYSTEM_INFO pWcdmaSystemInfo;
    PLTE_SYSTEM_INFO pLteSystemInfo;
    PTDSCDMA_SYSTEM_INFO pTdscdmaSystemInfo;
    PNR5G_SYSTEM_INFO pNr5gSystemInfo;
    UCHAR DeviceClass = 0;
    ULONG DataCapList = 0;
    
    /*  Additional LTE System Info - Availability of Dual connectivity of E-UTRA with NR5G */
    uint8_t endc_available_valid = 0;  /**< Must be set to true if endc_available is being passed */
    uint8_t endc_available = 0x00;
    /**<  
       Upper layer indication in LTE SIB2. Values: \n
       - 0x00 -- 5G Not available \n
       - 0x01 -- 5G Available
       
    */
    /*  Additional LTE System Info - DCNR restriction Info */
    uint8_t restrict_dcnr_valid = 0;  /**< Must be set to true if restrict_dcnr is being passed */
    uint8_t restrict_dcnr = 0x01;
    /**<  
       DCNR restriction in NAS attach/TAU accept. Values: \n
       - 0x00 -- Not restricted \n
       - 0x01 -- Restricted
    */

    *pPSAttachedState = 0;
    pRequest = ComposeQMUXMsg(QMUX_TYPE_NAS, QMINAS_GET_SYS_INFO_REQ, NULL, NULL);
    err = QmiThreadSendQMI(pRequest, &pResponse);
    qmi_rsp_check_and_return();

    pServiceStatusInfo = (PSERVICE_STATUS_INFO)(((PCHAR)&pMUXMsg->GetSysInfoResp) + QCQMUX_MSG_HDR_SIZE);
    remainingLen = le16_to_cpu(pMUXMsg->GetSysInfoResp.Length);

    s_is_cdma = 0;
    s_5g_type = WWAN_DATA_CLASS_NONE;
    s_hdr_personality = 0;
    while (remainingLen > 0) {
        switch (pServiceStatusInfo->TLVType) {
        case 0x10: // CDMA
            if (pServiceStatusInfo->SrvStatus == 0x02) {
                DataCapList = WWAN_DATA_CLASS_1XRTT|
                              WWAN_DATA_CLASS_1XEVDO|
                              WWAN_DATA_CLASS_1XEVDO_REVA|
                              WWAN_DATA_CLASS_1XEVDV|
                              WWAN_DATA_CLASS_1XEVDO_REVB;
                DeviceClass = DEVICE_CLASS_CDMA;
                s_is_cdma = (0 == is_lte);
            }
            break;
        case 0x11: // HDR
            if (pServiceStatusInfo->SrvStatus == 0x02) {
                DataCapList = WWAN_DATA_CLASS_3XRTT|
                              WWAN_DATA_CLASS_UMB;
                DeviceClass = DEVICE_CLASS_CDMA;
                s_is_cdma = (0 == is_lte);
            }
            break;
        case 0x12: // GSM
            if (pServiceStatusInfo->SrvStatus == 0x02) {
                DataCapList = WWAN_DATA_CLASS_GPRS|
                              WWAN_DATA_CLASS_EDGE;
                DeviceClass = DEVICE_CLASS_GSM;
            }
            break;
        case 0x13: // WCDMA
            if (pServiceStatusInfo->SrvStatus == 0x02) {
                DataCapList = WWAN_DATA_CLASS_UMTS;
                DeviceClass = DEVICE_CLASS_GSM;
            }
            break;
        case 0x14: // LTE
            if (pServiceStatusInfo->SrvStatus == 0x02) {
                DataCapList = WWAN_DATA_CLASS_LTE;
                DeviceClass = DEVICE_CLASS_GSM;
                is_lte = 1;
                s_is_cdma = 0;
            }
            break;
        case 0x4A: // NR5G Service Status Info
            if (pServiceStatusInfo->SrvStatus == NAS_SYS_SRV_STATUS_SRV_V01) {
                DataCapList |= WWAN_DATA_CLASS_5G_SA;
                DeviceClass = DEVICE_CLASS_GSM;
                is_lte = 1;
                s_is_cdma = 0;
            }
            break;
        case 0x4B: // NR5G System Info
            pNr5gSystemInfo = (PNR5G_SYSTEM_INFO)pServiceStatusInfo;
            if (pNr5gSystemInfo->srv_domain_valid == 0x01) {
                if (pNr5gSystemInfo->srv_domain & SYS_SRV_DOMAIN_PS_ONLY_V01) {
                    *pPSAttachedState = 1;
                }
            }

            if (pNr5gSystemInfo->network_id_valid == 0x01) {
                MobileCountryCode = (USHORT)char2ushort(pNr5gSystemInfo->MCC);
                MobileNetworkCode = (USHORT)char2ushort(pNr5gSystemInfo->MNC);
            }
            break;
        case 0x4E: //Additional LTE System Info - Availability of Dual Connectivity of E-UTRA with NR5G
            endc_available_valid = 1;
            endc_available = pServiceStatusInfo->SrvStatus;
            break;
            
        case 0x4F: //Additional LTE System Info - DCNR restriction Info
            restrict_dcnr_valid = 1;
            restrict_dcnr = pServiceStatusInfo->SrvStatus;
            break;

        case 0x24: // TDSCDMA
            if (pServiceStatusInfo->SrvStatus == 0x02) {
                pDataCapStr = "TD-SCDMA";
            }
            break;
        case 0x15: // CDMA
            // CDMA_SYSTEM_INFO
            pCdmaSystemInfo = (PCDMA_SYSTEM_INFO)pServiceStatusInfo;
            if (pCdmaSystemInfo->SrvDomainValid == 0x01) {
                if (pCdmaSystemInfo->SrvDomain & 0x02) {
                    *pPSAttachedState = 1;
                    s_is_cdma = (0 == is_lte);
                }
            }
#if 0
            if (pCdmaSystemInfo->SrvCapabilityValid == 0x01) {
                *pPSAttachedState = 0;
                if (pCdmaSystemInfo->SrvCapability & 0x02) {
                    *pPSAttachedState = 1;
                    s_is_cdma = (0 == is_lte);
                }
            }
#endif
            if (pCdmaSystemInfo->NetworkIdValid == 0x01) {
                MobileCountryCode = (USHORT)char2ushort(pCdmaSystemInfo->MCC);
                MobileNetworkCode = (USHORT)char2ushort(pCdmaSystemInfo->MNC);
            }
            break;
        case 0x16: // HDR
            // HDR_SYSTEM_INFO
            pHdrSystemInfo = (PHDR_SYSTEM_INFO)pServiceStatusInfo;
            if (pHdrSystemInfo->SrvDomainValid == 0x01) {
                if (pHdrSystemInfo->SrvDomain & 0x02) {
                    *pPSAttachedState = 1;
                    s_is_cdma = (0 == is_lte);
                }
            }
#if 0
            if (pHdrSystemInfo->SrvCapabilityValid == 0x01) {
                *pPSAttachedState = 0;
                if (pHdrSystemInfo->SrvCapability & 0x02) {
                    *pPSAttachedState = 1;
                    s_is_cdma = (0 == is_lte);
                }
            }
#endif
            if (*pPSAttachedState && pHdrSystemInfo->HdrPersonalityValid == 0x01) {
                if (pHdrSystemInfo->HdrPersonality == 0x03)
                    s_hdr_personality = 0x02;
                //else if (pHdrSystemInfo->HdrPersonality == 0x02)
                //    s_hdr_personality = 0x01;
            }
            USHORT cmda_mcc = 0, cdma_mnc = 0;
            if(!requestGetHomeNetwork(&cmda_mcc, &cdma_mnc,NULL, NULL) && cmda_mcc) {
                quectel_convert_cdma_mcc_2_ascii_mcc(&MobileCountryCode, cmda_mcc);
                quectel_convert_cdma_mnc_2_ascii_mnc(&MobileNetworkCode, cdma_mnc);
            }
            break;
        case 0x17: // GSM
            // GSM_SYSTEM_INFO
            pGsmSystemInfo = (PGSM_SYSTEM_INFO)pServiceStatusInfo;
            if (pGsmSystemInfo->SrvDomainValid == 0x01) {
                if (pGsmSystemInfo->SrvDomain & 0x02) {
                    *pPSAttachedState = 1;
                }
            }
#if 0
            if (pGsmSystemInfo->SrvCapabilityValid == 0x01) {
                *pPSAttachedState = 0;
                if (pGsmSystemInfo->SrvCapability & 0x02) {
                    *pPSAttachedState = 1;
                }
            }
#endif
            if (pGsmSystemInfo->NetworkIdValid == 0x01) {
                MobileCountryCode = (USHORT)char2ushort(pGsmSystemInfo->MCC);
                MobileNetworkCode = (USHORT)char2ushort(pGsmSystemInfo->MNC);
            }
            break;
        case 0x18: // WCDMA
            // WCDMA_SYSTEM_INFO
            pWcdmaSystemInfo = (PWCDMA_SYSTEM_INFO)pServiceStatusInfo;
            if (pWcdmaSystemInfo->SrvDomainValid == 0x01) {
                if (pWcdmaSystemInfo->SrvDomain & 0x02) {
                    *pPSAttachedState = 1;
                }
            }
#if 0
            if (pWcdmaSystemInfo->SrvCapabilityValid == 0x01) {
                *pPSAttachedState = 0;
                if (pWcdmaSystemInfo->SrvCapability & 0x02) {
                    *pPSAttachedState = 1;
                }
            }
#endif
            if (pWcdmaSystemInfo->NetworkIdValid == 0x01) {
                MobileCountryCode = (USHORT)char2ushort(pWcdmaSystemInfo->MCC);
                MobileNetworkCode = (USHORT)char2ushort(pWcdmaSystemInfo->MNC);
            }
            break;
        case 0x19: // LTE_SYSTEM_INFO
            // LTE_SYSTEM_INFO
            pLteSystemInfo = (PLTE_SYSTEM_INFO)pServiceStatusInfo;
            if (pLteSystemInfo->SrvDomainValid == 0x01) {
                if (pLteSystemInfo->SrvDomain & 0x02) {
                    *pPSAttachedState = 1;
                    is_lte = 1;
                    s_is_cdma = 0;
                }
            }
#if 0
            if (pLteSystemInfo->SrvCapabilityValid == 0x01) {
                *pPSAttachedState = 0;
                if (pLteSystemInfo->SrvCapability & 0x02) {
                    *pPSAttachedState = 1;
                    is_lte = 1;
                    s_is_cdma = 0;
                }
            }
#endif
            if (pLteSystemInfo->NetworkIdValid == 0x01) {
                MobileCountryCode = (USHORT)char2ushort(pLteSystemInfo->MCC);
                MobileNetworkCode = (USHORT)char2ushort(pLteSystemInfo->MNC);
            }
            break;
        case 0x25: // TDSCDMA
            // TDSCDMA_SYSTEM_INFO
            pTdscdmaSystemInfo = (PTDSCDMA_SYSTEM_INFO)pServiceStatusInfo;
            if (pTdscdmaSystemInfo->SrvDomainValid == 0x01) {
                if (pTdscdmaSystemInfo->SrvDomain & 0x02) {
                    *pPSAttachedState = 1;
                }
            }
#if 0
            if (pTdscdmaSystemInfo->SrvCapabilityValid == 0x01) {
                *pPSAttachedState = 0;
                if (pTdscdmaSystemInfo->SrvCapability & 0x02) {
                    *pPSAttachedState = 1;
                }
            }
#endif
            if (pTdscdmaSystemInfo->NetworkIdValid == 0x01) {
                MobileCountryCode = (USHORT)char2ushort(pTdscdmaSystemInfo->MCC);
                MobileNetworkCode = (USHORT)char2ushort(pTdscdmaSystemInfo->MNC);
            }
            break;
        default:
            break;
        } /* switch (pServiceStatusInfo->TLYType) */

        remainingLen -= (le16_to_cpu(pServiceStatusInfo->TLVLength) + 3);
        pServiceStatusInfo = (PSERVICE_STATUS_INFO)((PCHAR)&pServiceStatusInfo->TLVLength + le16_to_cpu(pServiceStatusInfo->TLVLength) + sizeof(USHORT));
    } /* while (remainingLen > 0) */

    if (DataCapList & WWAN_DATA_CLASS_LTE) {
        if (endc_available_valid && restrict_dcnr_valid) {
            if (endc_available && !restrict_dcnr) {
                DataCapList |= WWAN_DATA_CLASS_5G_NSA;
            }
        }
    }

    if (DeviceClass == DEVICE_CLASS_CDMA) {
        if (s_hdr_personality == 2) {
            pDataCapStr = s_hdr_personality == 2 ? "eHRPD" : "HRPD";
        } else if (DataCapList & WWAN_DATA_CLASS_1XEVDO_REVB) {
            pDataCapStr = wwan_data_class2str(WWAN_DATA_CLASS_1XEVDO_REVB);
        } else if (DataCapList & WWAN_DATA_CLASS_1XEVDO_REVA) {
            pDataCapStr = wwan_data_class2str(WWAN_DATA_CLASS_1XEVDO_REVA);
        } else if (DataCapList & WWAN_DATA_CLASS_1XEVDO) {
            pDataCapStr = wwan_data_class2str(WWAN_DATA_CLASS_1XEVDO);
        } else if (DataCapList & WWAN_DATA_CLASS_1XRTT) {
            pDataCapStr = wwan_data_class2str(WWAN_DATA_CLASS_1XRTT);
        } else if (DataCapList & WWAN_DATA_CLASS_3XRTT) {
            pDataCapStr = wwan_data_class2str(WWAN_DATA_CLASS_3XRTT);
        } else if (DataCapList & WWAN_DATA_CLASS_UMB) {
            pDataCapStr = wwan_data_class2str(WWAN_DATA_CLASS_UMB);
        }
    } else {
        if (DataCapList & WWAN_DATA_CLASS_5G_SA) {
            s_5g_type = WWAN_DATA_CLASS_5G_SA;
            pDataCapStr = wwan_data_class2str(WWAN_DATA_CLASS_5G_SA);
        } else if (DataCapList & WWAN_DATA_CLASS_5G_NSA) {
            s_5g_type = WWAN_DATA_CLASS_5G_NSA;
            pDataCapStr = wwan_data_class2str(WWAN_DATA_CLASS_5G_NSA);
        } else if (DataCapList & WWAN_DATA_CLASS_LTE) {
            pDataCapStr = wwan_data_class2str(WWAN_DATA_CLASS_LTE);
        } else if ((DataCapList & WWAN_DATA_CLASS_HSDPA) && (DataCapList & WWAN_DATA_CLASS_HSUPA)) {
            pDataCapStr = "HSDPA_HSUPA";
        } else if (DataCapList & WWAN_DATA_CLASS_HSDPA) {
            pDataCapStr = wwan_data_class2str(WWAN_DATA_CLASS_HSDPA);
        } else if (DataCapList & WWAN_DATA_CLASS_HSUPA) {
            pDataCapStr = wwan_data_class2str(WWAN_DATA_CLASS_HSUPA);
        } else if (DataCapList & WWAN_DATA_CLASS_UMTS) {
            pDataCapStr = wwan_data_class2str(WWAN_DATA_CLASS_UMTS);
        } else if (DataCapList & WWAN_DATA_CLASS_EDGE) {
            pDataCapStr = wwan_data_class2str(WWAN_DATA_CLASS_EDGE);
        } else if (DataCapList & WWAN_DATA_CLASS_GPRS) {
            pDataCapStr = wwan_data_class2str(WWAN_DATA_CLASS_GPRS);
        }
    }

    dbg_time("%s MCC: %d, MNC: %d, PS: %s, DataCap: %s", __func__,
        MobileCountryCode, MobileNetworkCode, (*pPSAttachedState == 1) ? "Attached" : "Detached" , pDataCapStr);

    free(pResponse);

    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x100, %rsp            # imm = 0x100
movq %rdi, -0x10(%rbp)
movw $0x0, -0x2e(%rbp)
movw $0x0, -0x30(%rbp)
leaq 0x1bb19(%rip), %rax     # 0x2dc0b
movq %rax, -0x38(%rbp)
movl $0x0, -0x4c(%rbp)
movb $0x0, -0x89(%rbp)
movl $0x0, -0x90(%rbp)
movb $0x0, -0x91(%rbp)
movb $0x0, -0x92(%rbp)
movb $0x0, -0x93(%rbp)
movb $0x1, -0x94(%rbp)
movq -0x10(%rbp), %rax
movb $0x0, (%rax)
movl $0x3, %edi
movl $0x4d, %esi
xorl %eax, %eax
movl %eax, %ecx
movq %rcx, %rdx
callq 0x11170
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rdi
leaq -0x20(%rbp), %rsi
movl $0x7530, %edx           # imm = 0x7530
leaq 0x1bb5a(%rip), %rcx     # 0x2dcb9
callq 0xc670
movl %eax, -0x2c(%rbp)
cmpl $0x0, -0x2c(%rbp)
jl 0x12178
cmpq $0x0, -0x20(%rbp)
jne 0x12206
jmp 0x1217a
movq 0x24e5f(%rip), %rax     # 0x36fe0
movq (%rax), %rax
movq %rax, -0xa8(%rbp)
callq 0x13930
movq -0xa8(%rbp), %rdi
movq %rax, %rdx
movl -0x2c(%rbp), %r8d
leaq 0x1b7bc(%rip), %rsi     # 0x2d961
leaq 0x1bb0d(%rip), %rcx     # 0x2dcb9
movb $0x0, %al
callq 0x52c0
leaq 0x25cae(%rip), %rax     # 0x37e68
cmpq $0x0, (%rax)
je 0x121f9
leaq 0x25ca1(%rip), %rax     # 0x37e68
movq (%rax), %rax
movq %rax, -0xb0(%rbp)
callq 0x13930
movq -0xb0(%rbp), %rdi
movq %rax, %rdx
movl -0x2c(%rbp), %r8d
leaq 0x1b776(%rip), %rsi     # 0x2d961
leaq 0x1bac7(%rip), %rcx     # 0x2dcb9
movb $0x0, %al
callq 0x52c0
jmp 0x121fb
movl -0x2c(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x12c6b
movq -0x20(%rbp), %rax
addq $0x6, %rax
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rax
movzwl 0xa(%rax), %edi
callq 0x13ed0
movzwl %ax, %eax
cmpl $0x0, %eax
jne 0x12240
movq -0x28(%rbp), %rax
movzwl 0xc(%rax), %edi
callq 0x13ed0
movzwl %ax, %eax
cmpl $0x0, %eax
je 0x1232d
movq -0x28(%rbp), %rax
movzwl 0xc(%rax), %edi
callq 0x13ed0
movw %ax, -0x96(%rbp)
movq 0x24d85(%rip), %rax     # 0x36fe0
movq (%rax), %rax
movq %rax, -0xc0(%rbp)
callq 0x13930
movq %rax, -0xb8(%rbp)
movq -0x28(%rbp), %rax
movzwl 0xa(%rax), %edi
callq 0x13ed0
movq -0xc0(%rbp), %rdi
movq -0xb8(%rbp), %rdx
movzwl %ax, %r8d
movzwl -0x96(%rbp), %r9d
leaq 0x1b6d4(%rip), %rsi     # 0x2d973
leaq 0x1ba13(%rip), %rcx     # 0x2dcb9
movb $0x0, %al
callq 0x52c0
leaq 0x25bb4(%rip), %rax     # 0x37e68
cmpq $0x0, (%rax)
je 0x12313
leaq 0x25ba7(%rip), %rax     # 0x37e68
movq (%rax), %rax
movq %rax, -0xd0(%rbp)
callq 0x13930
movq %rax, -0xc8(%rbp)
movq -0x28(%rbp), %rax
movzwl 0xa(%rax), %edi
callq 0x13ed0
movq -0xd0(%rbp), %rdi
movq -0xc8(%rbp), %rdx
movzwl %ax, %r8d
movzwl -0x96(%rbp), %r9d
leaq 0x1b66e(%rip), %rsi     # 0x2d973
leaq 0x1b9ad(%rip), %rcx     # 0x2dcb9
movb $0x0, %al
callq 0x52c0
jmp 0x12315
movq -0x20(%rbp), %rdi
callq 0x5040
movzwl -0x96(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x12c6b
jmp 0x1232f
movq -0x28(%rbp), %rax
addq $0x3, %rax
addq $0x4, %rax
movq %rax, -0x48(%rbp)
movq -0x28(%rbp), %rax
movzwl 0x5(%rax), %edi
callq 0x13ed0
movzwl %ax, %eax
movq %rax, -0x40(%rbp)
movl $0x0, 0x25a97(%rip)     # 0x37df4
movl $0x0, 0x25a95(%rip)     # 0x37dfc
movl $0x0, 0x25a87(%rip)     # 0x37df8
cmpq $0x0, -0x40(%rbp)
jle 0x128cf
movq -0x48(%rbp), %rax
movzbl (%rax), %eax
addl $-0x10, %eax
movl %eax, %ecx
movq %rcx, -0xd8(%rbp)
subl $0x3f, %eax
ja 0x12870
movq -0xd8(%rbp), %rax
leaq 0x1b46a(%rip), %rcx     # 0x2d810
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq -0x48(%rbp), %rax
movzbl 0x3(%rax), %eax
cmpl $0x2, %eax
jne 0x123e0
movl $0x2f0000, -0x90(%rbp)  # imm = 0x2F0000
movb $0x1, -0x89(%rbp)
xorl %eax, %eax
cmpl -0x4c(%rbp), %eax
sete %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, 0x25a14(%rip)     # 0x37df4
jmp 0x12872
movq -0x48(%rbp), %rax
movzbl 0x3(%rax), %eax
cmpl $0x2, %eax
jne 0x12416
movl $0x500000, -0x90(%rbp)  # imm = 0x500000
movb $0x1, -0x89(%rbp)
xorl %eax, %eax
cmpl -0x4c(%rbp), %eax
sete %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, 0x259de(%rip)     # 0x37df4
jmp 0x12872
movq -0x48(%rbp), %rax
movzbl 0x3(%rax), %eax
cmpl $0x2, %eax
jne 0x12439
movl $0x3, -0x90(%rbp)
movb $0x2, -0x89(%rbp)
jmp 0x12872
movq -0x48(%rbp), %rax
movzbl 0x3(%rax), %eax
cmpl $0x2, %eax
jne 0x1245c
movl $0x4, -0x90(%rbp)
movb $0x2, -0x89(%rbp)
jmp 0x12872
movq -0x48(%rbp), %rax
movzbl 0x3(%rax), %eax
cmpl $0x2, %eax
jne 0x12490
movl $0x20, -0x90(%rbp)
movb $0x2, -0x89(%rbp)
movl $0x1, -0x4c(%rbp)
movl $0x0, 0x25964(%rip)     # 0x37df4
jmp 0x12872
movq -0x48(%rbp), %rax
movzbl 0x3(%rax), %eax
cmpl $0x2, %eax
jne 0x124cb
movl -0x90(%rbp), %eax
orl $0x80, %eax
movl %eax, -0x90(%rbp)
movb $0x2, -0x89(%rbp)
movl $0x1, -0x4c(%rbp)
movl $0x0, 0x25929(%rip)     # 0x37df4
jmp 0x12872
movq -0x48(%rbp), %rax
movq %rax, -0x88(%rbp)
movq -0x88(%rbp), %rax
movzbl 0x3(%rax), %eax
cmpl $0x1, %eax
jne 0x12507
movq -0x88(%rbp), %rax
movzbl 0x4(%rax), %eax
andl $0x2, %eax
cmpl $0x0, %eax
je 0x12505
movq -0x10(%rbp), %rax
movb $0x1, (%rax)
jmp 0x12507
movq -0x88(%rbp), %rax
movzbl 0x16(%rax), %eax
cmpl $0x1, %eax
jne 0x1253f
movq -0x88(%rbp), %rdi
addq $0x17, %rdi
callq 0x13110
movw %ax, -0x2e(%rbp)
movq -0x88(%rbp), %rdi
addq $0x1a, %rdi
callq 0x13110
movw %ax, -0x30(%rbp)
jmp 0x12872
movb $0x1, -0x91(%rbp)
movq -0x48(%rbp), %rax
movb 0x3(%rax), %al
movb %al, -0x92(%rbp)
jmp 0x12872
movb $0x1, -0x93(%rbp)
movq -0x48(%rbp), %rax
movb 0x3(%rax), %al
movb %al, -0x94(%rbp)
jmp 0x12872
movq -0x48(%rbp), %rax
movzbl 0x3(%rax), %eax
cmpl $0x2, %eax
jne 0x1258e
leaq 0x1b6df(%rip), %rax     # 0x2dc69
movq %rax, -0x38(%rbp)
jmp 0x12872
movq -0x48(%rbp), %rax
movq %rax, -0x58(%rbp)
movq -0x58(%rbp), %rax
movzbl 0x3(%rax), %eax
cmpl $0x1, %eax
jne 0x125d4
movq -0x58(%rbp), %rax
movzbl 0x4(%rax), %eax
andl $0x2, %eax
cmpl $0x0, %eax
je 0x125d2
movq -0x10(%rbp), %rax
movb $0x1, (%rax)
xorl %eax, %eax
cmpl -0x4c(%rbp), %eax
sete %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, 0x25822(%rip)     # 0x37df4
jmp 0x125d4
movq -0x58(%rbp), %rax
movzbl 0x26(%rax), %eax
cmpl $0x1, %eax
jne 0x12603
movq -0x58(%rbp), %rdi
addq $0x27, %rdi
callq 0x13110
movw %ax, -0x2e(%rbp)
movq -0x58(%rbp), %rdi
addq $0x2a, %rdi
callq 0x13110
movw %ax, -0x30(%rbp)
jmp 0x12872
movq -0x48(%rbp), %rax
movq %rax, -0x60(%rbp)
movq -0x60(%rbp), %rax
movzbl 0x3(%rax), %eax
cmpl $0x1, %eax
jne 0x12649
movq -0x60(%rbp), %rax
movzbl 0x4(%rax), %eax
andl $0x2, %eax
cmpl $0x0, %eax
je 0x12647
movq -0x10(%rbp), %rax
movb $0x1, (%rax)
xorl %eax, %eax
cmpl -0x4c(%rbp), %eax
sete %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, 0x257ad(%rip)     # 0x37df4
jmp 0x12649
movq -0x10(%rbp), %rax
movzbl (%rax), %eax
cmpl $0x0, %eax
je 0x1267b
movq -0x60(%rbp), %rax
movzbl 0xd(%rax), %eax
cmpl $0x1, %eax
jne 0x1267b
movq -0x60(%rbp), %rax
movzbl 0xe(%rax), %eax
cmpl $0x3, %eax
jne 0x12679
movl $0x2, 0x2577f(%rip)     # 0x37df8
jmp 0x1267b
movw $0x0, -0x98(%rbp)
movw $0x0, -0x9a(%rbp)
leaq -0x98(%rbp), %rdi
leaq -0x9a(%rbp), %rsi
xorl %eax, %eax
movl %eax, %ecx
movq %rcx, %rdx
callq 0x12c80
cmpl $0x0, %eax
jne 0x126d8
movzwl -0x98(%rbp), %eax
cmpl $0x0, %eax
je 0x126d8
leaq -0x2e(%rbp), %rdi
movzwl -0x98(%rbp), %esi
callq 0x12f50
leaq -0x30(%rbp), %rdi
movzwl -0x9a(%rbp), %esi
callq 0x13050
jmp 0x12872
movq -0x48(%rbp), %rax
movq %rax, -0x68(%rbp)
movq -0x68(%rbp), %rax
movzbl 0x3(%rax), %eax
cmpl $0x1, %eax
jne 0x1270b
movq -0x68(%rbp), %rax
movzbl 0x4(%rax), %eax
andl $0x2, %eax
cmpl $0x0, %eax
je 0x12709
movq -0x10(%rbp), %rax
movb $0x1, (%rax)
jmp 0x1270b
movq -0x68(%rbp), %rax
movzbl 0x16(%rax), %eax
cmpl $0x1, %eax
jne 0x1273a
movq -0x68(%rbp), %rdi
addq $0x17, %rdi
callq 0x13110
movw %ax, -0x2e(%rbp)
movq -0x68(%rbp), %rdi
addq $0x1a, %rdi
callq 0x13110
movw %ax, -0x30(%rbp)
jmp 0x12872
movq -0x48(%rbp), %rax
movq %rax, -0x70(%rbp)
movq -0x70(%rbp), %rax
movzbl 0x3(%rax), %eax
cmpl $0x1, %eax
jne 0x1276d
movq -0x70(%rbp), %rax
movzbl 0x4(%rax), %eax
andl $0x2, %eax
cmpl $0x0, %eax
je 0x1276b
movq -0x10(%rbp), %rax
movb $0x1, (%rax)
jmp 0x1276d
movq -0x70(%rbp), %rax
movzbl 0x16(%rax), %eax
cmpl $0x1, %eax
jne 0x1279c
movq -0x70(%rbp), %rdi
addq $0x17, %rdi
callq 0x13110
movw %ax, -0x2e(%rbp)
movq -0x70(%rbp), %rdi
addq $0x1a, %rdi
callq 0x13110
movw %ax, -0x30(%rbp)
jmp 0x12872
movq -0x48(%rbp), %rax
movq %rax, -0x78(%rbp)
movq -0x78(%rbp), %rax
movzbl 0x3(%rax), %eax
cmpl $0x1, %eax
jne 0x127e0
movq -0x78(%rbp), %rax
movzbl 0x4(%rax), %eax
andl $0x2, %eax
cmpl $0x0, %eax
je 0x127de
movq -0x10(%rbp), %rax
movb $0x1, (%rax)
movl $0x1, -0x4c(%rbp)
movl $0x0, 0x25616(%rip)     # 0x37df4
jmp 0x127e0
movq -0x78(%rbp), %rax
movzbl 0x16(%rax), %eax
cmpl $0x1, %eax
jne 0x1280f
movq -0x78(%rbp), %rdi
addq $0x17, %rdi
callq 0x13110
movw %ax, -0x2e(%rbp)
movq -0x78(%rbp), %rdi
addq $0x1a, %rdi
callq 0x13110
movw %ax, -0x30(%rbp)
jmp 0x12872
movq -0x48(%rbp), %rax
movq %rax, -0x80(%rbp)
movq -0x80(%rbp), %rax
movzbl 0x3(%rax), %eax
cmpl $0x1, %eax
jne 0x1283f
movq -0x80(%rbp), %rax
movzbl 0x4(%rax), %eax
andl $0x2, %eax
cmpl $0x0, %eax
je 0x1283d
movq -0x10(%rbp), %rax
movb $0x1, (%rax)
jmp 0x1283f
movq -0x80(%rbp), %rax
movzbl 0x16(%rax), %eax
cmpl $0x1, %eax
jne 0x1286e
movq -0x80(%rbp), %rdi
addq $0x17, %rdi
callq 0x13110
movw %ax, -0x2e(%rbp)
movq -0x80(%rbp), %rdi
addq $0x1a, %rdi
callq 0x13110
movw %ax, -0x30(%rbp)
jmp 0x12872
jmp 0x12872
movq -0x48(%rbp), %rax
movzwl 0x1(%rax), %edi
callq 0x13ed0
movzwl %ax, %eax
addl $0x3, %eax
movslq %eax, %rcx
movq -0x40(%rbp), %rax
subq %rcx, %rax
movq %rax, -0x40(%rbp)
movq -0x48(%rbp), %rax
addq $0x1, %rax
movq %rax, -0xe0(%rbp)
movq -0x48(%rbp), %rax
movzwl 0x1(%rax), %edi
callq 0x13ed0
movw %ax, %cx
movq -0xe0(%rbp), %rax
movzwl %cx, %ecx
movslq %ecx, %rcx
addq %rcx, %rax
addq $0x2, %rax
movq %rax, -0x48(%rbp)
jmp 0x12371
movl -0x90(%rbp), %eax
andl $0x20, %eax
cmpl $0x0, %eax
je 0x1291d
movzbl -0x91(%rbp), %eax
cmpl $0x0, %eax
je 0x1291b
movzbl -0x93(%rbp), %eax
cmpl $0x0, %eax
je 0x1291b
movzbl -0x92(%rbp), %eax
cmpl $0x0, %eax
je 0x12919
cmpb $0x0, -0x94(%rbp)
jne 0x12919
movl -0x90(%rbp), %eax
orl $0x40, %eax
movl %eax, -0x90(%rbp)
jmp 0x1291b
jmp 0x1291d
movzbl -0x89(%rbp), %eax
cmpl $0x1, %eax
jne 0x12a2f
cmpl $0x2, 0x254c4(%rip)     # 0x37df8
jne 0x1295a
movl 0x254bc(%rip), %edx     # 0x37df8
leaq 0x1b330(%rip), %rax     # 0x2dc73
leaq 0x1b328(%rip), %rcx     # 0x2dc72
cmpl $0x2, %edx
cmoveq %rcx, %rax
movq %rax, -0x38(%rbp)
jmp 0x12a2a
movl -0x90(%rbp), %eax
andl $0x200000, %eax         # imm = 0x200000
cmpl $0x0, %eax
je 0x1297d
movl $0x200000, %edi         # imm = 0x200000
callq 0x13190
movq %rax, -0x38(%rbp)
jmp 0x12a28
movl -0x90(%rbp), %eax
andl $0x40000, %eax          # imm = 0x40000
cmpl $0x0, %eax
je 0x129a0
movl $0x40000, %edi          # imm = 0x40000
callq 0x13190
movq %rax, -0x38(%rbp)
jmp 0x12a26
movl -0x90(%rbp), %eax
andl $0x20000, %eax          # imm = 0x20000
cmpl $0x0, %eax
je 0x129c0
movl $0x20000, %edi          # imm = 0x20000
callq 0x13190
movq %rax, -0x38(%rbp)
jmp 0x12a24
movl -0x90(%rbp), %eax
andl $0x10000, %eax          # imm = 0x10000
cmpl $0x0, %eax
je 0x129e0
movl $0x10000, %edi          # imm = 0x10000
callq 0x13190
movq %rax, -0x38(%rbp)
jmp 0x12a22
movl -0x90(%rbp), %eax
andl $0x100000, %eax         # imm = 0x100000
cmpl $0x0, %eax
je 0x12a00
movl $0x100000, %edi         # imm = 0x100000
callq 0x13190
movq %rax, -0x38(%rbp)
jmp 0x12a20
movl -0x90(%rbp), %eax
andl $0x400000, %eax         # imm = 0x400000
cmpl $0x0, %eax
je 0x12a1e
movl $0x400000, %edi         # imm = 0x400000
callq 0x13190
movq %rax, -0x38(%rbp)
jmp 0x12a20
jmp 0x12a22
jmp 0x12a24
jmp 0x12a26
jmp 0x12a28
jmp 0x12a2a
jmp 0x12b7a
movl -0x90(%rbp), %eax
andl $0x80, %eax
cmpl $0x0, %eax
je 0x12a5c
movl $0x80, 0x253b3(%rip)    # 0x37dfc
movl $0x80, %edi
callq 0x13190
movq %rax, -0x38(%rbp)
jmp 0x12b78
movl -0x90(%rbp), %eax
andl $0x40, %eax
cmpl $0x0, %eax
je 0x12a87
movl $0x40, 0x25388(%rip)    # 0x37dfc
movl $0x40, %edi
callq 0x13190
movq %rax, -0x38(%rbp)
jmp 0x12b76
movl -0x90(%rbp), %eax
andl $0x20, %eax
cmpl $0x0, %eax
je 0x12aa8
movl $0x20, %edi
callq 0x13190
movq %rax, -0x38(%rbp)
jmp 0x12b74
movl -0x90(%rbp), %eax
andl $0x8, %eax
cmpl $0x0, %eax
je 0x12ad4
movl -0x90(%rbp), %eax
andl $0x10, %eax
cmpl $0x0, %eax
je 0x12ad4
leaq 0x1b208(%rip), %rax     # 0x2dcd3
movq %rax, -0x38(%rbp)
jmp 0x12b72
movl -0x90(%rbp), %eax
andl $0x8, %eax
cmpl $0x0, %eax
je 0x12af2
movl $0x8, %edi
callq 0x13190
movq %rax, -0x38(%rbp)
jmp 0x12b70
movl -0x90(%rbp), %eax
andl $0x10, %eax
cmpl $0x0, %eax
je 0x12b10
movl $0x10, %edi
callq 0x13190
movq %rax, -0x38(%rbp)
jmp 0x12b6e
movl -0x90(%rbp), %eax
andl $0x4, %eax
cmpl $0x0, %eax
je 0x12b2e
movl $0x4, %edi
callq 0x13190
movq %rax, -0x38(%rbp)
jmp 0x12b6c
movl -0x90(%rbp), %eax
andl $0x2, %eax
cmpl $0x0, %eax
je 0x12b4c
movl $0x2, %edi
callq 0x13190
movq %rax, -0x38(%rbp)
jmp 0x12b6a
movl -0x90(%rbp), %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0x12b68
movl $0x1, %edi
callq 0x13190
movq %rax, -0x38(%rbp)
jmp 0x12b6a
jmp 0x12b6c
jmp 0x12b6e
jmp 0x12b70
jmp 0x12b72
jmp 0x12b74
jmp 0x12b76
jmp 0x12b78
jmp 0x12b7a
jmp 0x12b7c
movq 0x2445d(%rip), %rax     # 0x36fe0
movq (%rax), %rax
movq %rax, -0xe8(%rbp)
callq 0x13930
movq -0xe8(%rbp), %rdi
movq %rax, %rdx
movzwl -0x2e(%rbp), %r8d
movzwl -0x30(%rbp), %r9d
movq -0x10(%rbp), %rax
movzbl (%rax), %ecx
leaq 0x1b0fc(%rip), %r10     # 0x2dcb0
leaq 0x1b0ec(%rip), %rax     # 0x2dca7
cmpl $0x1, %ecx
cmoveq %rax, %r10
movq -0x38(%rbp), %rax
leaq 0x1b0ab(%rip), %rsi     # 0x2dc78
leaq 0x1b0e5(%rip), %rcx     # 0x2dcb9
movq %r10, (%rsp)
movq %rax, 0x8(%rsp)
movb $0x0, %al
callq 0x52c0
leaq 0x2527d(%rip), %rax     # 0x37e68
cmpq $0x0, (%rax)
je 0x12c59
leaq 0x25270(%rip), %rax     # 0x37e68
movq (%rax), %rax
movq %rax, -0xf0(%rbp)
callq 0x13930
movq -0xf0(%rbp), %rdi
movq %rax, %rdx
movzwl -0x2e(%rbp), %r8d
movzwl -0x30(%rbp), %r9d
movq -0x10(%rbp), %rax
movzbl (%rax), %ecx
leaq 0x1b087(%rip), %r10     # 0x2dcb0
leaq 0x1b077(%rip), %rax     # 0x2dca7
cmpl $0x1, %ecx
cmoveq %rax, %r10
movq -0x38(%rbp), %rax
leaq 0x1b036(%rip), %rsi     # 0x2dc78
leaq 0x1b070(%rip), %rcx     # 0x2dcb9
movq %r10, (%rsp)
movq %rax, 0x8(%rsp)
movb $0x0, %al
callq 0x52c0
jmp 0x12c5b
movq -0x20(%rbp), %rdi
callq 0x5040
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x100, %rsp            # imm = 0x100
popq %rbp
retq
nopw (%rax,%rax)