I think you're trying to complicate something that is really simple!
const uint8_t pinLED = 13;
byte incoming_IR_data;
bool check_IR()
{
// Some code that checks IR and stores data from Infrared to
// incoming_IR_data variable
if ( incoming_IR_data == 12524 )
{
return false;
}
}
bool task_2()
{
bool result;
result = check_IR();
if ( ! result )
{
return result;
}
...
return true;
}
bool task_1()
{
bool result;
result = check_IR();
if ( ! result )
{
return result;
}
...
return true;
}
bool task_0()
{
bool result;
result = check_IR();
if ( ! result )
{
return result;
}
...
return true;
}
void loop()
{
start:
if ( false == task_0() ) return;
if ( false == task_1() ) return;
if ( false == task_2() ) return;
}
void setup()
{
pinMode(pinLED, OUTPUT);
}