1/*
2 * Copyright 2016, NICTA
3 *
4 * This software may be distributed and modified according to the terms of
5 * the BSD 2-Clause license. Note that NO WARRANTY is provided.
6 * See "LICENSE_BSD2.txt" for details.
7 *
8 * @TAG(NICTA_BSD)
9 */
10
11/*
12 * LocalVarExtract inserts a return statement after the inner conditional
13 * block [1], because it's not obvious that the block never returns.
14 * This causes PrettyBoundVarNames to barf when trying to find a return
15 * variable name.
16 *
17 * Jira issue VER-591.
18 */
19
20int fact(int n) {
21  int r = 1;
22  for (;; n--) {
23    if (n > 0) {
24      r *= n;
25    } else {
26      if (n == 0) {
27        break;
28      } else {
29        return 0;
30      }
31      /* [1] ... over here */
32    }
33  }
34  return r;
35}
36