Upstream version 9.38.198.0
[platform/framework/web/crosswalk.git] / src / native_client / tests / barebones / barebones_fib.c
1 /*
2  * Copyright 2010 The Native Client Authors. All rights reserved.
3  * Use of this source code is governed by a BSD-style license that can be
4  * found in the LICENSE file.
5  */
6
7 /*
8  * NaCl test for super simple program not using newlib
9  */
10
11 #include "barebones.h"
12
13 /* fib(9) == 55 */
14 /* NOTE: must not be const to prevent llvm optimizations */
15 int startval = 9;
16
17
18 static int fib(int val) {
19   if (val <= 1) {
20     return 1;
21   } else {
22     return fib(val - 1) + fib(val - 2);
23   }
24 }
25
26
27 int main(void) {
28   NACL_SYSCALL(exit)(fib(startval));
29   /* UNREACHABLE */
30   return 0;
31 }