X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=ir%2Fbe%2Ftest%2Ftailrec.c;h=4bac4799e39f7b770c2cc89c22758e97299a1aaf;hb=cf2892b6fe077bad206035c44c68586f956c9e0f;hp=7e77df0e6deb6786c4fee590c4d692e31cc405db;hpb=e4691fe2e5046a9b2ae912e23e92ddcdcd2bb6e9;p=libfirm diff --git a/ir/be/test/tailrec.c b/ir/be/test/tailrec.c index 7e77df0e6..4bac4799e 100644 --- a/ir/be/test/tailrec.c +++ b/ir/be/test/tailrec.c @@ -1,14 +1,11 @@ -static unsigned _fak(unsigned a, unsigned b) -{ - if (a == 0) - return b; - - return _fak(a-1, a*b); -} +#include -static fak(unsigned a) +static unsigned fak(unsigned n) { - return _fak(a, 1); + if (n == 0) + return 1; + + return n * fak(n - 1); } @@ -17,4 +14,6 @@ int main(int argc, char *argv[]) int x = 4; printf("%d! = %d\n", x, fak(x)); + + return 0; }