

signed char scGlobalVariable1 = 15 ;

signed char scGlobalVariable2, scGlobalVariable3, scGlobalVariable4 ;
signed char scGlobalVariable5, scGlobalVariable6, scGlobalVariable7 ;

extern signed char scGlobalVariable8, scGlobalVariableResult ;

void CreateVariableUsage ( void ) ;

void main ( void )
{
    scGlobalVariable2 = 10 ;

    scGlobalVariable3 = 5 ;

    if ( 0 != scGlobalVariable8 )
    {
        /*
          Constant propagation should be performed for the below
          usage of 'scGlobalVariable1' and 'scGlobalVariable3'

          Constant value 15 is to be propagated to 'scGlobalVariable1'
          and constant value 5 is to be propagated to 'scGlobalVariable3'.

          Result of 'scGlobalVariable1 * scGlobalVariable3' (15 * 5)
          should be folded to value 75 which is to be stored in
          'scGlobalVariable4'.
        */
        scGlobalVariable4 = scGlobalVariable1 * scGlobalVariable3 ;

        /*
          Constant propagation should be performed for the below
          usage of 'scGlobalVariable1'

          Constant value 15 is to be propagated to 'scGlobalVariable1'
          which is to be stored in 'scGlobalVariable5'.
        */
        scGlobalVariable5 = scGlobalVariable1 ;
    }
    else
    {
        /*
          Constant propagation should be performed for the below
          usage of 'scGlobalVariable2' and 'scGlobalVariable3'

          Constant value 10 is to be propagated to 'scGlobalVariable2'
          and constant value 5 is to be propagated to 'scGlobalVariable3'.

          Result of 'scGlobalVariable2 + scGlobalVariable3' (10 + 5)
          should be folded to value 15 which is to be stored in
          'scGlobalVariable6'.

        */
        scGlobalVariable6 = scGlobalVariable2 + scGlobalVariable3 ;
    }

    /*
      Constant value 15 is to be propagated to 'scGlobalVariable1'
      and constant value 10 is to be propagated to 'scGlobalVariable2'.

      Result of 'scGlobalVariable1 - scGlobalVariable2' (15 - 10)
      should be folded to value 5 which is to be stored in
      'scGlobalVariable7'.
    */
    scGlobalVariable7 = scGlobalVariable1 - scGlobalVariable2 ;

    CreateVariableUsage () ;
 }

/*
    Some optimizing compiler will eliminate the assignment code of a
    variable when the variable has no further usage after its definition.
    Therefore, to perform complete optimization evaluation, usage of a
    variable has been created in this function.
*/
void CreateVariableUsage ( void )
{
    scGlobalVariableResult = scGlobalVariable2 + scGlobalVariable4 + scGlobalVariable5 + scGlobalVariable6 + scGlobalVariable7 ;
}

