// Copyright Contributors to the Open Shading Language project.
// SPDX-License-Identifier: BSD-3-Clause
// https://github.com/AcademySoftwareFoundation/OpenShadingLanguage

shader
cyclic_read_in_loop_v5 (output color rgb = 0)
{
    int farthestIndex = -1;
    float dist = 0.0;
    int flag = int(P[0]);
    while(flag) 
    {
        if (int(P[0]*256)%2 == 0) {
            if(dist > P[0]) {
                dist = (9)*0.1;
                farthestIndex = 9;
                break;
            } else
            {
                break;
            }
        } else 
        {
            // Note that dist is not read by anything after the loop
            // Bug if the assignment to dist is not masked
            dist = 0;
            farthestIndex = 4;
            break;
        }        
    }
    
    rgb = float(farthestIndex)/9.0; 
}
