Index: src/libcfa/Makefile.am
===================================================================
--- src/libcfa/Makefile.am	(revision a797e2b1cfe2d1159921fa7cc4522318d04d6709)
+++ src/libcfa/Makefile.am	(revision e67f54c7509e35bc171d113dd722a93bfb7808b5)
@@ -11,6 +11,6 @@
 ## Created On       : Sun May 31 08:54:01 2015
 ## Last Modified By : Peter A. Buhr
-## Last Modified On : Tue Jul  5 20:52:31 2016
-## Update Count     : 185
+## Last Modified On : Fri Jul  8 23:05:11 2016
+## Update Count     : 192
 ###############################################################################
 
@@ -26,5 +26,5 @@
 # create extra forward types/declarations to reduce inclusion of library files
 extras.cf : extras.regx extras.c
-	$(AM_V_GEN)@BACKEND_CC@ -E ${srcdir}/extras.c | grep -f extras.regx > ${srcdir}/extras.cf
+	$(AM_V_GEN)@BACKEND_CC@ @CFA_FLAGS@ -E ${srcdir}/extras.c | grep -f extras.regx > ${srcdir}/extras.cf
 
 # create forward declarations for gcc builtins
@@ -51,7 +51,7 @@
 
 libcfa-prelude.o : libcfa-prelude.c
-	 $(AM_V_GEN)@BACKEND_CC@ -c -o $@ $<
+	 $(AM_V_GEN)@BACKEND_CC@ @CFA_FLAGS@ -c -o $@ $<
 
-CFLAGS = -quiet -g -Wall -Wno-unused-function -B${abs_top_srcdir}/src/driver -XCFA -t  # TEMPORARY: does not build with -O2
+CFLAGS = -quiet -g -Wall -Wno-unused-function @CFA_FLAGS@ -B${abs_top_srcdir}/src/driver -XCFA -t # TEMPORARY: does not build with -O2
 CC = ${abs_top_srcdir}/src/driver/cfa
 
Index: src/libcfa/Makefile.in
===================================================================
--- src/libcfa/Makefile.in	(revision a797e2b1cfe2d1159921fa7cc4522318d04d6709)
+++ src/libcfa/Makefile.in	(revision e67f54c7509e35bc171d113dd722a93bfb7808b5)
@@ -132,8 +132,9 @@
 CFA_BACKEND_CC = @CFA_BACKEND_CC@
 CFA_BINDIR = @CFA_BINDIR@
+CFA_FLAGS = @CFA_FLAGS@
 CFA_INCDIR = @CFA_INCDIR@
 CFA_LIBDIR = @CFA_LIBDIR@
 CFA_PREFIX = @CFA_PREFIX@
-CFLAGS = -quiet -g -Wall -Wno-unused-function -B${abs_top_srcdir}/src/driver -XCFA -t  # TEMPORARY: does not build with -O2
+CFLAGS = -quiet -g -Wall -Wno-unused-function @CFA_FLAGS@ -B${abs_top_srcdir}/src/driver -XCFA -t # TEMPORARY: does not build with -O2
 CPP = @CPP@
 CPPFLAGS = @CPPFLAGS@
@@ -602,5 +603,5 @@
 # create extra forward types/declarations to reduce inclusion of library files
 extras.cf : extras.regx extras.c
-	$(AM_V_GEN)@BACKEND_CC@ -E ${srcdir}/extras.c | grep -f extras.regx > ${srcdir}/extras.cf
+	$(AM_V_GEN)@BACKEND_CC@ @CFA_FLAGS@ -E ${srcdir}/extras.c | grep -f extras.regx > ${srcdir}/extras.cf
 
 # create forward declarations for gcc builtins
@@ -625,5 +626,5 @@
 
 libcfa-prelude.o : libcfa-prelude.c
-	 $(AM_V_GEN)@BACKEND_CC@ -c -o $@ $<
+	 $(AM_V_GEN)@BACKEND_CC@ @CFA_FLAGS@ -c -o $@ $<
 
 # extensionless header files are overridden by -o flag in default makerule => explicitly override default rule to silently do nothing
Index: src/libcfa/extras.c
===================================================================
--- src/libcfa/extras.c	(revision a797e2b1cfe2d1159921fa7cc4522318d04d6709)
+++ src/libcfa/extras.c	(revision e67f54c7509e35bc171d113dd722a93bfb7808b5)
@@ -1,2 +1,3 @@
 #include <stddef.h>
 #include <stdlib.h>
+#include <stdio.h>
Index: src/libcfa/extras.regx
===================================================================
--- src/libcfa/extras.regx	(revision a797e2b1cfe2d1159921fa7cc4522318d04d6709)
+++ src/libcfa/extras.regx	(revision e67f54c7509e35bc171d113dd722a93bfb7808b5)
@@ -1,5 +1,8 @@
-typedef.* size_t
-typedef.* ptrdiff_t
+typedef.* size_t;
+typedef.* ptrdiff_t;
+extern.* abort\(.*\).*
+extern.* atexit\(.*\).*
 extern.* exit\(.*\).*
-extern.* atexit\(.*\).*
-extern.* abort\(.*\).*
+extern.* free\(.*\).*
+extern.*\*malloc\(.*\).*
+extern.* printf\(.*\).*
Index: src/libcfa/limits.c
===================================================================
--- src/libcfa/limits.c	(revision a797e2b1cfe2d1159921fa7cc4522318d04d6709)
+++ src/libcfa/limits.c	(revision e67f54c7509e35bc171d113dd722a93bfb7808b5)
@@ -10,6 +10,6 @@
 // Created On       : Wed Apr  6 18:06:52 2016
 // Last Modified By : Peter A. Buhr
-// Last Modified On : Thu Apr  7 17:18:45 2016
-// Update Count     : 11
+// Last Modified On : Fri Jul  8 13:23:33 2016
+// Update Count     : 14
 // 
 
@@ -20,5 +20,9 @@
 const short int MIN = -32768;
 const int MIN = -2147483648;
+#if __WORDSIZE == 64
 const long int MIN = -9223372036854775807L - 1L;
+#else
+const long int MIN = (int)MIN;
+#endif // M64
 const long long int MIN = -9223372036854775807LL - 1LL;
 
@@ -27,5 +31,9 @@
 const int MAX = 2147483647;
 const unsigned int MAX = 4294967295_U;
+#if __WORDSIZE == 64
 const long int MAX = 9223372036854775807_L;
+#else
+const long int MAX = (int)MAX;
+#endif // M64
 const unsigned long int MAX = 4294967295_U;
 const long long int MAX = 9223372036854775807_LL;
Index: src/libcfa/rational.c
===================================================================
--- src/libcfa/rational.c	(revision a797e2b1cfe2d1159921fa7cc4522318d04d6709)
+++ src/libcfa/rational.c	(revision e67f54c7509e35bc171d113dd722a93bfb7808b5)
@@ -10,6 +10,6 @@
 // Created On       : Wed Apr  6 17:54:28 2016
 // Last Modified By : Peter A. Buhr
-// Last Modified On : Tue Jul  5 18:29:12 2016
-// Update Count     : 26
+// Last Modified On : Sat Jul  9 11:18:04 2016
+// Update Count     : 40
 // 
 
@@ -31,20 +31,20 @@
 // alternative: https://en.wikipedia.org/wiki/Binary_GCD_algorithm
 static long int gcd( long int a, long int b ) {
-    for ( ;; ) {										// Euclid's algorithm
+	for ( ;; ) {										// Euclid's algorithm
 		long int r = a % b;
 	  if ( r == 0 ) break;
 		a = b;
 		b = r;
-    } // for
+	} // for
 	return b;
 } // gcd
 
 static long int simplify( long int *n, long int *d ) {
-    if ( *d == 0 ) {
+	if ( *d == 0 ) {
 		serr | "Invalid rational number construction: denominator cannot be equal to 0." | endl;
 		exit( EXIT_FAILURE );
-    } // exit
-    if ( *d < 0 ) { *d = -*d; *n = -*n; }				// move sign to numerator
-    return gcd( abs( *n ), *d );						// simplify
+	} // exit
+	if ( *d < 0 ) { *d = -*d; *n = -*n; }				// move sign to numerator
+	return gcd( abs( *n ), *d );						// simplify
 } // Rationalnumber::simplify
 
@@ -53,14 +53,14 @@
 
 void ?{}( Rational * r ) {
-    r{ 0, 1 };
+	r{ 0, 1 };
 } // rational
 
 void ?{}( Rational * r, long int n ) {
-    r{ n, 1 };
+	r{ n, 1 };
 } // rational
 
 void ?{}( Rational * r, long int n, long int d ) {
-    long int t = simplify( &n, &d );					// simplify
-    r->numerator = n / t;
+	long int t = simplify( &n, &d );					// simplify
+	r->numerator = n / t;
 	r->denominator = d / t;
 } // rational
@@ -70,25 +70,25 @@
 
 long int numerator( Rational r ) {
-    return r.numerator;
+	return r.numerator;
 } // numerator
 
 long int numerator( Rational r, long int n ) {
-    long int prev = r.numerator;
-    long int t = gcd( abs( n ), r.denominator );		// simplify
-    r.numerator = n / t;
-    r.denominator = r.denominator / t;
-    return prev;
+	long int prev = r.numerator;
+	long int t = gcd( abs( n ), r.denominator );		// simplify
+	r.numerator = n / t;
+	r.denominator = r.denominator / t;
+	return prev;
 } // numerator
 
 long int denominator( Rational r ) {
-    return r.denominator;
+	return r.denominator;
 } // denominator
 
 long int denominator( Rational r, long int d ) {
-    long int prev = r.denominator;
-    long int t = simplify( &r.numerator, &d );			// simplify
-    r.numerator = r.numerator / t;
-    r.denominator = d / t;
-    return prev;
+	long int prev = r.denominator;
+	long int t = simplify( &r.numerator, &d );			// simplify
+	r.numerator = r.numerator / t;
+	r.denominator = d / t;
+	return prev;
 } // denominator
 
@@ -97,25 +97,25 @@
 
 int ?==?( Rational l, Rational r ) {
-    return l.numerator * r.denominator == l.denominator * r.numerator;
+	return l.numerator * r.denominator == l.denominator * r.numerator;
 } // ?==?
 
 int ?!=?( Rational l, Rational r ) {
-    return ! ( l == r );
+	return ! ( l == r );
 } // ?!=?
 
 int ?<?( Rational l, Rational r ) {
-    return l.numerator * r.denominator < l.denominator * r.numerator;
+	return l.numerator * r.denominator < l.denominator * r.numerator;
 } // ?<?
 
 int ?<=?( Rational l, Rational r ) {
-    return l < r || l == r;
+	return l < r || l == r;
 } // ?<=?
 
 int ?>?( Rational l, Rational r ) {
-    return ! ( l <= r );
+	return ! ( l <= r );
 } // ?>?
 
 int ?>=?( Rational l, Rational r ) {
-    return ! ( l < r );
+	return ! ( l < r );
 } // ?>=?
 
@@ -125,39 +125,39 @@
 Rational -?( Rational r ) {
 	Rational t = { -r.numerator, r.denominator };
-    return t;
+	return t;
 } // -?
 
 Rational ?+?( Rational l, Rational r ) {
-    if ( l.denominator == r.denominator ) {				// special case
+	if ( l.denominator == r.denominator ) {				// special case
 		Rational t = { l.numerator + r.numerator, l.denominator };
 		return t;
-    } else {
+	} else {
 		Rational t = { l.numerator * r.denominator + l.denominator * r.numerator, l.denominator * r.denominator };
 		return t;
-    } // if
+	} // if
 } // ?+?
 
 Rational ?-?( Rational l, Rational r ) {
-    if ( l.denominator == r.denominator ) {				// special case
+	if ( l.denominator == r.denominator ) {				// special case
 		Rational t = { l.numerator - r.numerator, l.denominator };
 		return t;
-    } else {
+	} else {
 		Rational t = { l.numerator * r.denominator - l.denominator * r.numerator, l.denominator * r.denominator };
 		return t;
-    } // if
+	} // if
 } // ?-?
 
 Rational ?*?( Rational l, Rational r ) {
-    Rational t = { l.numerator * r.numerator, l.denominator * r.denominator };
+	Rational t = { l.numerator * r.numerator, l.denominator * r.denominator };
 	return t;
 } // ?*?
 
 Rational ?/?( Rational l, Rational r ) {
-    if ( r.numerator < 0 ) {
+	if ( r.numerator < 0 ) {
 		r.numerator = -r.numerator;
 		r.denominator = -r.denominator;
 	} // if
 	Rational t = { l.numerator * r.denominator, l.denominator * r.numerator };
-    return t;
+	return t;
 } // ?/?
 
@@ -169,5 +169,5 @@
 } // widen
 
-// https://rosettacode.org/wiki/Convert_decimal_number_to_rational#C
+// http://www.ics.uci.edu/~eppstein/numth/frap.c
 Rational narrow( double f, long int md ) {
 	if ( md <= 1 ) {									// maximum fractional digits too small?
@@ -176,27 +176,23 @@
 
 	// continued fraction coefficients
-	long int a, h[3] = { 0, 1, 0 }, k[3] = { 1, 0, 0 };
-	long int x, d, n = 1;
-	int i, neg = 0;
- 
-	if ( f < 0 ) { neg = 1; f = -f; }
-	while ( f != floor( f ) ) { n <<= 1; f *= 2; }
-	d = f;
- 
-	// continued fraction and check denominator each step
-	for (i = 0; i < 64; i++) {
-		a = n ? d / n : 0;
-	  if (i && !a) break;
-		x = d; d = n; n = x % n;
-		x = a;
-		if (k[1] * a + k[0] >= md) {
-			x = (md - k[0]) / k[1];
-		  if ( ! (x * 2 >= a || k[1] >= md) ) break;
-			i = 65;
-		} // if
-		h[2] = x * h[1] + h[0]; h[0] = h[1]; h[1] = h[2];
-		k[2] = x * k[1] + k[0]; k[0] = k[1]; k[1] = k[2];
-	} // for
-	return (Rational){ neg ? -h[1] : h[1], k[1] };
+	long int m00 = 1, m11 = 1, m01 = 0, m10 = 0;
+	long int ai, t;
+
+	// find terms until denom gets too big
+	for ( ;; ) {
+		ai = (long int)f;
+	  if ( ! (m10 * ai + m11 <= md) ) break;
+		t = m00 * ai + m01;
+		m01 = m00;
+		m00 = t;
+		t = m10 * ai + m11;
+		m11 = m10;
+		m10 = t;
+		t = (double)ai;
+	  if ( f == t ) break;								// prevent division by zero
+		f = 1 / (f - t);
+	  if ( f > (double)0x7FFFFFFF ) break;				// representation failure
+	} 
+	return (Rational){ m00, m10 };
 } // narrow
 
@@ -207,14 +203,14 @@
 istype * ?|?( istype *is, Rational *r ) {
 	long int t;
-    is | &(r->numerator) | &(r->denominator);
+	is | &(r->numerator) | &(r->denominator);
 	t = simplify( &(r->numerator), &(r->denominator) );
-    r->numerator /= t;
-    r->denominator /= t;
-    return is;
+	r->numerator /= t;
+	r->denominator /= t;
+	return is;
 } // ?|?
 
 forall( dtype ostype | ostream( ostype ) )
 ostype * ?|?( ostype *os, Rational r ) {
-    return os | r.numerator | '/' | r.denominator;
+	return os | r.numerator | '/' | r.denominator;
 } // ?|?
 
