static int find_start_code(const uint8_t **pbuf_ptr, const uint8_t *buf_end)

{

    const uint8_t *buf_ptr= *pbuf_ptr;



    buf_ptr++; //gurantees that -1 is within the array

    buf_end -= 2; // gurantees that +2 is within the array



    while (buf_ptr < buf_end) {

        if(*buf_ptr==0){

            while(buf_ptr < buf_end && buf_ptr[1]==0)

                buf_ptr++;



            if(buf_ptr[-1] == 0 && buf_ptr[1] == 1){

                *pbuf_ptr = buf_ptr+3;

                return buf_ptr[2] + 0x100;

            }

        }

        buf_ptr += 2;

    }

    buf_end += 2; //undo the hack above



    *pbuf_ptr = buf_end;

    return -1;

}

static int find_start_code(const uint8_t **pbuf_ptr, const uint8_t *buf_end)

{

    const uint8_t *buf_ptr= *pbuf_ptr;



    buf_ptr++; 

    buf_end -= 2; 



    while (buf_ptr < buf_end) {

        if(*buf_ptr==0){

            while(buf_ptr < buf_end && buf_ptr[1]==0)

                buf_ptr++;



            if(buf_ptr[-1] == 0 && buf_ptr[1] == 1){

                *pbuf_ptr = buf_ptr+3;

                return buf_ptr[2] + 0x100;

            }

        }

        buf_ptr += 2;

    }

    buf_end += 2; 



    *pbuf_ptr = buf_end;

    return -1;

}

static int FUNC_0(const uint8_t **VAR_0, const uint8_t *VAR_1)

{

    const uint8_t *VAR_2= *VAR_0;



    VAR_2++; 

    VAR_1 -= 2; 



    while (VAR_2 < VAR_1) {

        if(*VAR_2==0){

            while(VAR_2 < VAR_1 && VAR_2[1]==0)

                VAR_2++;



            if(VAR_2[-1] == 0 && VAR_2[1] == 1){

                *VAR_0 = VAR_2+3;

                return VAR_2[2] + 0x100;

            }

        }

        VAR_2 += 2;

    }

    VAR_1 += 2; 



    *VAR_0 = VAR_1;

    return -1;

}

static int FUNC_0(const uint8_t **VAR_0, const uint8_t *VAR_1)
{ const uint8_t *VAR_2= *VAR_0; VAR_2++; VAR_1 -= 2; while (VAR_2 < VAR_1) { if(*VAR_2==0){ while(VAR_2 < VAR_1 && VAR_2[1]==0)
VAR_2++; if(VAR_2[-1] == 0 && VAR_2[1] == 1){ *VAR_0 = VAR_2+3; return VAR_2[2] + 0x100; } } VAR_2 += 2; } VAR_1 += 2; *VAR_0 = VAR_1; return -1; }