From 830f2bc655ae1a984d8f42df79bb78042b194d8d Mon Sep 17 00:00:00 2001 From: David Malcolm Date: Wed, 23 Mar 2016 00:05:49 -0400 Subject: [PATCH 15/91] FIXME: the test-loop.c source --- test-loop.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 test-loop.c diff --git a/test-loop.c b/test-loop.c new file mode 100644 index 0000000..ebb8aef --- /dev/null +++ b/test-loop.c @@ -0,0 +1,31 @@ +int test_1 (int i, int j, int k) +{ + if (i < j) + return k + 4; + else + return -k; +} + +/* Example showing: + - data structure + - loop + - call to "abort". */ + +struct foo +{ + int count; + float *data; +}; + +float test_2 (struct foo *lhs, struct foo *rhs) +{ + float result = 0.0f; + + if (lhs->count != rhs->count) + __builtin_abort (); + + for (int i = 0; i < lhs->count; i++) + result += lhs->data[i] * rhs->data[i]; + + return result; +} -- 1.8.5.3