1#include <string.h>
2#include <stdio.h>
3
4void func_ignore(int a, int b, int c)
5{
6	printf("%d\n", a + b + c);
7}
8
9void func_intptr(int *i)
10{
11	printf("%d\n", *i);
12}
13
14void func_intptr_ret(int *i)
15{
16	*i = 42;
17}
18
19int func_strlen(char* p)
20{
21	strcpy(p, "Hello world");
22	return strlen(p);
23}
24
25int func_arg0(char *p)
26{
27	strcpy(p, "Hello another world!");
28	return strlen(p);
29}
30
31void func_strfixed(char* p)
32{
33	strcpy(p, "Hello world");
34}
35
36void func_string(char* p)
37{
38	printf("%s\n", p);
39}
40
41void func_ppp(int*** ppp)
42{
43	printf("%d\n", ***ppp);
44}
45
46void func_stringp(char** sP)
47{
48	printf("%s\n", *sP);
49}
50
51void func_enum(int x)
52{
53	printf("enum: %d\n", x);
54}
55
56void func_short(short x1, short x2)
57{
58	printf("short: %hd %hd\n", x1, x2);
59}
60
61void func_ushort(unsigned short x1, unsigned short x2)
62{
63	printf("ushort: %hu %hu\n", x1, x2);
64}
65
66float func_float(float f1, float f2)
67{
68	printf("%f %f\n", f1, f2);
69	return f1;
70}
71
72double func_double(double f1, double f2)
73{
74	printf("%f %f\n", f1, f2);
75	return f2;
76}
77
78void func_typedef(int x)
79{
80	printf("typedef'd enum: %d\n", x);
81}
82
83void func_arrayi(int* a, int N)
84{
85    int i;
86    printf("array[int]: ");
87    for (i = 0; i < N; i++)
88	printf("%d ", a[i]);
89    printf("\n");
90}
91
92void func_arrayf(float* a, int N)
93{
94    int i;
95    printf("array[float]: ");
96    for (i = 0; i < N; i++)
97	printf("%f ", a[i]);
98    printf("\n");
99}
100
101struct test_struct {
102    int simple;
103    int alen;
104    int slen;
105    struct { int a; int b; }* array;
106    struct { int a; int b; } seq[3];
107    char* str;
108    char* outer_str;
109};
110
111void func_struct(struct test_struct* x)
112{
113    char buf[100];
114    int i;
115
116    printf("struct: ");
117
118    printf("%d, [", x->simple);
119    for (i = 0; i < x->alen; i++) {
120	printf("%d/%d", x->array[i].a, x->array[i].b);
121	if (i < x->alen - 1)
122	    printf(" ");
123    }
124    printf("] [");
125    for (i = 0; i < 3; i++) {
126	printf("%d/%d", x->seq[i].a, x->seq[i].b);
127	if (i < 2)
128	    printf(" ");
129    }
130    printf("] ");
131
132    strncpy(buf, x->str, x->slen);
133    buf[x->slen] = '\0';
134    printf("%s\n", buf);
135}
136
137void func_work (char *x)
138{
139  *x = 'x';
140}
141
142void func_call (char *x, char* y, void (*cb) (char *))
143{
144  cb (y);
145  *x = (*y)++;
146}
147
148struct S2 {
149	float f;
150	char a;
151	char b;
152};
153
154struct S3 {
155	char a[6];
156	float f;
157};
158
159struct S2
160func_struct_2(int i, struct S3 s3, double d)
161{
162	return (struct S2){ s3.f, s3.a[1], s3.a[2] };
163}
164
165struct S4 {
166	long a;
167	long b;
168	long c;
169	long d;
170};
171
172struct S4
173func_struct_large(struct S4 a, struct S4 b)
174{
175	return (struct S4){ a.a + b.a, a.b + b.b, a.c + b.c, a.d + b.d };
176}
177
178struct S5 {
179	char a;
180	char b;
181	long c;
182	long d;
183};
184
185struct S5
186func_struct_large2(struct S5 a, struct S5 b)
187{
188	return (struct S5){ a.a + b.a, a.b + b.b, a.c + b.c, a.d + b.d };
189}
190
191struct S6 {
192	long a;
193	long b;
194	char c;
195	char d;
196};
197
198struct S6
199func_struct_large3(struct S6 a, struct S6 b)
200{
201	return (struct S6){ a.a + b.a, a.b + b.b, a.c + b.c, a.d + b.d };
202}
203
204void
205func_many_args(int a, int b, long c, double d, char e, int f, float g, char h,
206	       int i, double j, int k, double l, char m, int n, short o, int p,
207	       char q, float r, float s, double t, long u, float v, float w,
208	       float x, float y)
209{
210}
211
212void
213func_lens(int a, long b, short c, long d)
214{
215}
216
217int
218func_bool(int a, int b)
219{
220	return !b;
221}
222
223void
224func_hide(int a, int b, int c, int d, int e, int f)
225{
226}
227
228struct func_hide_struct {
229	int a; int b; int c; int d; int e; int f; int g; int h;
230};
231
232void
233func_hide_struct(struct func_hide_struct s)
234{
235}
236
237long *
238func_short_enums(short values[])
239{
240	static long retvals[4];
241	retvals[0] = values[0];
242	retvals[1] = values[1];
243	retvals[2] = values[2];
244	retvals[3] = values[3];
245	return retvals;
246}
247
248long
249func_negative_enum(short a, unsigned short b, int c, unsigned d,
250		   long e, unsigned long f)
251{
252	return -1;
253}
254
255void
256func_charp_string(char *p)
257{
258}
259
260struct struct_empty {};
261struct struct_size1 { char a; };
262struct struct_size2 { short a; };
263struct struct_size4 { int a; };
264struct struct_size8 { int a; int b; };
265
266struct struct_empty
267func_struct_empty(struct struct_empty e)
268{
269	return e;
270}
271
272struct struct_size1
273func_struct_size1(struct struct_size1 e)
274{
275	return e;
276}
277
278struct struct_size2
279func_struct_size2(struct struct_size2 e)
280{
281	return e;
282}
283
284struct struct_size4
285func_struct_size4(struct struct_size4 e)
286{
287	return e;
288}
289
290struct struct_size8
291func_struct_size8(struct struct_size8 e)
292{
293	return e;
294}
295
296void
297func_printf(char *format, ...)
298{
299}
300
301void
302func_sprintf(char *str, char *format, ...)
303{
304}
305