#ifndef COMPILE_H
#include "COMPILE.H"
#endif
#ifdef MEDIA042_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G_F20E_F20J_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
#ifdef MEDIA007_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E
overlay "start"
#endif
#ifdef MEDIA351_G14ED_G20E_G21E
segment "start"
#endif

#ifdef MEDIA128_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G20E_G21E_A20E_A20F_A20G_A21E_A22E_A22G_F20E_F20J_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
BOOLEAN F0429_STARTEND_IsReadSaveHeaderSuccessful(
#ifdef MEDIA009_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G
P0846_pi_Buffer)
#endif
int16_t* P0846_pi_Buffer FINAL_SEPARATOR
{
        REGISTER int16_t* L1323_pi_HeaderData;
#ifdef MEDIA119_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G20E_G21E_A20E_A20F_A20G_A21E_A22E_A22G_P20JA_P20JB_I34E_I34M_P31J
        REGISTER unsigned int16_t L1320_ui_Counter;
#endif
        REGISTER int16_t L1321_i_ExpectedChecksum;
#ifdef MEDIA548_F20E_F20J_X30J_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J
        REGISTER unsigned int16_t L1320_ui_Counter;
#endif
        REGISTER int16_t L1322_i_Checksum;


        if (!F0415_SAVEUTIL_IsReadBytesSuccessful(M774_CAST_PUC(L1323_pi_HeaderData = P0846_pi_Buffer), 512)) {
                return C0_FALSE;
        }
        L1320_ui_Counter = 32;
        L1321_i_ExpectedChecksum = 0;
        /* Compute expected checksum over the first 256 bytes of the header */
        do {
                L1321_i_ExpectedChecksum += *L1323_pi_HeaderData++;
                L1321_i_ExpectedChecksum ^= *L1323_pi_HeaderData++;
                L1321_i_ExpectedChecksum -= *L1323_pi_HeaderData++;
                L1321_i_ExpectedChecksum ^= *L1323_pi_HeaderData++;
        } while (--L1320_ui_Counter);
        /* Deobfuscate the last 256 bytes of the header */
#ifdef MEDIA187_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_G20E_G21E_A20E_A20F_A20G_A21E_A22E_A22G_F20E_F20J_X30J_P20JA_P20JB_I34E_I34M_A36M /* CHANGE7_29_IMPROVEMENT */
        F0417_SAVEUTIL_GetChecksumAndObfuscate(M776_CAST_PUI(L1323_pi_HeaderData), P0846_pi_Buffer[C10_DM_SAVE_HEADER_DECRYPTION_KEY_INDEX], 128);
#endif
#ifdef MEDIA332_S20E_S21E_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J /* CHANGE7_29_IMPROVEMENT */
        F0417_SAVEUTIL_GetChecksumAndObfuscate(M776_CAST_PUI(L1323_pi_HeaderData), P0846_pi_Buffer[C29_CSB_SAVE_HEADER_DECRYPTION_KEY_INDEX], 128);
#endif
        L1322_i_Checksum = 0;
        L1320_ui_Counter = 128;
        do {
                L1322_i_Checksum += *L1323_pi_HeaderData++;
        } while (--L1320_ui_Counter);
        return (L1321_i_ExpectedChecksum == L1322_i_Checksum);
}

BOOLEAN F0430_STARTEND_IsWriteObfuscatedSaveHeaderSuccessful(
#ifdef MEDIA009_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G
P0847_pi_Buffer)
#endif
int16_t* P0847_pi_Buffer FINAL_SEPARATOR
{
        REGISTER int16_t* L1327_pi_HeaderData;
#ifdef MEDIA548_F20E_F20J_X30J_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J
        REGISTER int16_t L1325_i_LastWord;
#endif
        REGISTER unsigned int16_t L1324_ui_Multiple;
#define AL1324_ui_Counter                    L1324_ui_Multiple
#define AL1324_B_IsWriteSaveHeaderSuccessful L1324_ui_Multiple
#ifdef MEDIA119_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G20E_G21E_A20E_A20F_A20G_A21E_A22E_A22G_P20JA_P20JB_I34E_I34M_P31J
        REGISTER int16_t L1325_i_LastWord;
#endif
        REGISTER int16_t L1326_i_Checksum;


        L1326_i_Checksum = 0;
        AL1324_ui_Counter = 128;
        L1327_pi_HeaderData = P0847_pi_Buffer + 128;
        do {
                L1326_i_Checksum += *L1327_pi_HeaderData++;
        } while (--AL1324_ui_Counter);
        AL1324_ui_Counter = 32;
        L1325_i_LastWord = 0;
        L1327_pi_HeaderData = P0847_pi_Buffer;
        for (;;) { /*_Infinite loop_*/
                L1325_i_LastWord += *L1327_pi_HeaderData++ = M006_RANDOM(65536);
                L1325_i_LastWord ^= *L1327_pi_HeaderData++ = M006_RANDOM(65536);
                L1325_i_LastWord -= *L1327_pi_HeaderData++ = M006_RANDOM(65536);
                if (--AL1324_ui_Counter) {
                        L1325_i_LastWord ^= *L1327_pi_HeaderData++ = M006_RANDOM(65536);
                } else {
                        *L1327_pi_HeaderData++ = L1325_i_LastWord ^ L1326_i_Checksum;
                        break;
                }
        }
#ifdef MEDIA187_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_G20E_G21E_A20E_A20F_A20G_A21E_A22E_A22G_F20E_F20J_X30J_P20JA_P20JB_I34E_I34M_A36M /* CHANGE7_29_IMPROVEMENT */
        F0417_SAVEUTIL_GetChecksumAndObfuscate(M776_CAST_PUI(L1327_pi_HeaderData), P0847_pi_Buffer[C10_DM_SAVE_HEADER_DECRYPTION_KEY_INDEX], 128); /* Obfuscate before writing */
#endif
#ifdef MEDIA332_S20E_S21E_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J /* CHANGE7_29_IMPROVEMENT */
        F0417_SAVEUTIL_GetChecksumAndObfuscate(M776_CAST_PUI(L1327_pi_HeaderData), P0847_pi_Buffer[C29_CSB_SAVE_HEADER_DECRYPTION_KEY_INDEX], 128); /* Obfuscate before writing */
#endif
        AL1324_B_IsWriteSaveHeaderSuccessful = F0416_SAVEUTIL_IsWriteBytesSuccessful(M774_CAST_PUC(P0847_pi_Buffer), 512);
#ifdef MEDIA187_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_G20E_G21E_A20E_A20F_A20G_A21E_A22E_A22G_F20E_F20J_X30J_P20JA_P20JB_I34E_I34M_A36M /* CHANGE7_29_IMPROVEMENT */
        F0417_SAVEUTIL_GetChecksumAndObfuscate(M776_CAST_PUI(L1327_pi_HeaderData), P0847_pi_Buffer[C10_DM_SAVE_HEADER_DECRYPTION_KEY_INDEX], 128); /* Deobfuscate after writing */
#endif
#ifdef MEDIA332_S20E_S21E_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J /* CHANGE7_29_IMPROVEMENT */
        F0417_SAVEUTIL_GetChecksumAndObfuscate(M776_CAST_PUI(L1327_pi_HeaderData), P0847_pi_Buffer[C29_CSB_SAVE_HEADER_DECRYPTION_KEY_INDEX], 128); /* Deobfuscate after writing */
#endif
        return AL1324_B_IsWriteSaveHeaderSuccessful;
}
#endif

#ifdef MEDIA009_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G
#include "DARKCOLR.C"
#endif
#endif
