#ifndef COMPILE_H
#include "COMPILE.H"
#endif
#ifdef MEDIA009_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G
#ifndef NOCOPYPROTECTION
#ifdef MEDIA007_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E
overlay "main"
#endif
#ifdef MEDIA351_G14ED_G20E_G21E
segment "user"
#endif

#ifdef MEDIA137_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G
int16_t F0079_CPSC_GetChecksumAdd(
P0095_pfv_Function)
void (*P0095_pfv_Function)() FINAL_SEPARATOR
{
#ifdef MEDIA007_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E
        asm {
                        movea.l P0095_pfv_Function(A6),A0
                        cmpi.w  #0x4EF9,(A0)
                        bne.s   T0079001                        /* If A0 is not the address of a jmp instruction ($4EF9) from the jumptable */
                        movea.l 2(A0),A0                        /* Replace A0 by the target address of the jmp */
                T0079001:
                        moveq   #100,D0
                        move.l  #0x4E5E4E75,D1                  /* These are the bytes for instructions unlk A6 / rts which mark the end of the function */
                T0079002_Loop:
                        add.w   (A0)+,D0                        /* Add word values from start of the function */
                        cmp.l   (A0),D1
                        bne.s   T0079002_Loop                   /* Continue adding words until the end of the function is reached */
        }
#endif
#ifdef MEDIA413_A20ED_A20E_A20F_A20G_A21E_A22E_A22G
        #asm
                        movea.l 8(A5),A0        ; P0095_pfv_Function
                        cmpi.w  #$4EF9,(A0)
                        bne.s   T0079001
                        movea.l 2(A0),A0
                T0079001:
                        moveq   #100,D0
                        move.l  #$4E5D4E75,D1
                T0079002_Loop:
                        add.w   (A0)+,D0
                        cmp.l   (A0),D1
                        bne.s   T0079002_Loop
        #endasm
#endif
}
#endif
#ifdef MEDIA351_G14ED_G20E_G21E
int16_t F0079_CPSC_GetChecksumAdd(
P0095_pfv_Function, P6047_pui_BytesToSkip)
unsigned char*    P0095_pfv_Function    SEPARATOR
unsigned int16_t* P6047_pui_BytesToSkip FINAL_SEPARATOR
{
        unsigned int16_t L6213_;
        unsigned int16_t L6214_ui_Checksum;
        unsigned int16_t L6215_ui_Offset;


        L6213_ = *P6047_pui_BytesToSkip++;
        L6214_ui_Checksum = L6215_ui_Offset = 0;
        do {
                if (*P6047_pui_BytesToSkip == L6215_ui_Offset) { /* If an offset where bytes should be excluded from the checksum was reached */
                        P6047_pui_BytesToSkip++;
                        L6215_ui_Offset += *P6047_pui_BytesToSkip++; /* Skip the appropriate number of bytes */
                } else {
                        L6214_ui_Checksum += P0095_pfv_Function[L6215_ui_Offset++];
                }
        } while (L6215_ui_Offset < L6213_);
        L6214_ui_Checksum += 100;
        return L6214_ui_Checksum;
}
#endif
#endif
#endif
