#include #include #include enum { VALUES = 10_000 }; int values[VALUES], total = 0; thread T { int id; }; void main( T & ) { int sum = 0; void f() { int i = 0; void h( void ) { // nest routine int j = i; // non-local reference void g( void ) { // nest routine i += 1; // non-local reference j += 1; // non-local reference if ( i < 3 ) h(); } // g if ( prng( 6 ) == 0 ) g(); // prevent compiler inlining else h(); i += 1; sum += bsearchl( j, values, VALUES ); // has internal nested compare routine } // h h(); } // f f(); __atomic_fetch_add( &total, sum, __ATOMIC_SEQ_CST ); } int main() { set_seed( 1003 ); for ( i; VALUES ) values[i] = i; { T t[5]; } sout | "total" | total; }