// BEGIN mycpp output #include "gc_heap.h" using gc_heap::Alloc; using gc_heap::kZeroMask; using gc_heap::StackRoots; #include "my_runtime.h" #include "mylib2.h" using gc_heap::NewStr; using gc_heap::NewList; using gc_heap::NewDict; GLOBAL_STR(str0, "fib_recursive(%d) = %d"); GLOBAL_STR(str1, "fib_recursive(%d) = %d"); namespace fib_recursive { // forward declare } // forward declare namespace fib_recursive namespace fib_recursive { // declare int fib_recursive(int n); void run_tests(); void run_benchmarks(); inline Str* fmt0(int a0, int a1) { gBuf.reset(); gBuf.write_const("fib_recursive(", 14); gBuf.format_d(a0); gBuf.write_const(") = ", 4); gBuf.format_d(a1); return gBuf.getvalue(); } inline Str* fmt1(int a0, int a1) { gBuf.reset(); gBuf.write_const("fib_recursive(", 14); gBuf.format_d(a0); gBuf.write_const(") = ", 4); gBuf.format_d(a1); return gBuf.getvalue(); } } // declare namespace fib_recursive namespace fib_recursive { // define int fib_recursive(int n) { if (n == 0) { return 1; } if (n == 1) { return 1; } return (fib_recursive((n - 1)) + fib_recursive((n - 2))); } void run_tests() { int x; int result; x = 33; result = fib_recursive(x); println_stderr(fmt0(x, result)); } void run_benchmarks() { int n; int x; int result; int i; n = 1; x = 33; result = -1; i = 0; while (i < n) { result = fib_recursive(x); i += 1; } println_stderr(fmt1(x, result)); } } // define namespace fib_recursive