#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
int /*<<< orphan*/ write_file(char *, char *, char *);
void generate_make() {
  write_file(
      "Makefile", "Makefile",
      "SRC=$(wildcard *.c)\n\n"
      "CC=cc\n"
      "CFLAGS=\n"
      "LIBS=$(SRC:%.c=test_%.ef)\n"
      "OBJS=# Add objectfiles to be included in testing.\n\n"
      ".PHONY: all clean re\n\n"
      "all: $(LIBS)\n\n"
      "test_%.ef: %.c\n"
      "	@echo \"Building $@ from $<\"\n"
      "	@$(CC) $(CFLAGS) -shared -fPIC -Wl,-soname,$@ -o $@ $< $(OBJS)\n\n"
      "clean:\n"
      "	$(RM) $(LIBS)\n\n");
  write_file("Sample source", "skeleton.c",
             "#include \"epicfail.h\"\n\n"
             "void start()\n"
             "{\n"
             "}\n\n"
             "void stop()\n"
             "{\n"
             "}\n\n"
             "static int test_skeleton()\n"
             "{\n"
             "	return 0; // Success\n"
             "}\n\n"
             "epicfail_case_t manifest[] = {\n"
             "	{ \"Sample test case\", test_skeleton },\n"
             "	{ 0, 0 }, // Final row\n"
             "};\n");
  write_file("Header", "epicfail.h",
             "#define H_CONTENT = \n"
             "#ifndef EPICFAIL_H\n"
             "#define EPICFAIL_H\n"
             "\n"
             "typedef int (*epicfail_func_t) ();\n"
             "typedef struct {\n"
             "	const char *title;\n"
             "	epicfail_func_t call;\n"
             "} epicfail_case_t;\n"
             "\n"
             "#endif\n");
}


x86 assembly (clang, -O0):
<generate_make>:
push   %rbp
mov    %rsp,%rbp
lea    0xee5(%rip),%rsi
lea    0xee7(%rip),%rdx
mov    %rsi,%rdi
call   1030 <write_file@plt>
lea    0xff1(%rip),%rdi
lea    0xff8(%rip),%rsi
lea    0xffc(%rip),%rdx
call   1030 <write_file@plt>
lea    0x10c3(%rip),%rdi
lea    0x10c3(%rip),%rsi
lea    0x10c7(%rip),%rdx
call   1030 <write_file@plt>
pop    %rbp
ret

x86 assembly (clang, -O2):
<generate_make>:
push   %rax
lea    0xee8(%rip),%rdi
lea    0xeea(%rip),%rdx
mov    %rdi,%rsi
call   1030 <write_file@plt>
lea    0xff4(%rip),%rdi
lea    0xffb(%rip),%rsi
lea    0xfff(%rip),%rdx
call   1030 <write_file@plt>
lea    0x10c6(%rip),%rdi
lea    0x10c6(%rip),%rsi
lea    0x10ca(%rip),%rdx
pop    %rax
jmp    1030 <write_file@plt>

LLVM IR (-O0):
@.str = [9 x i8] c"Makefile\00"
@.str.1 = [281 x i8] c"SRC=$(wildcard *.c)\0A\0ACC=cc\0ACFLAGS=\0ALIBS=$(SRC:%.c=test_%.ef)\0AOBJS=# Add objectfiles to be included in testing.\0A\0A.PHONY: all clean re\0A\0Aall: $(LIBS)\0A\0Atest_%.ef: %.c\0A\09@echo \22Building $@ from $<\22\0A\09@$(CC) $(CFLAGS) -shared -fPIC -Wl,-soname,$@ -o $@ $< $(OBJS)\0A\0Aclean:\0A\09$(RM) $(LIBS)\0A\0A\00"
@.str.2 = [14 x i8] c"Sample source\00"
@.str.3 = [11 x i8] c"skeleton.c\00"
@.str.4 = [211 x i8] c"#include \22epicfail.h\22\0A\0Avoid start()\0A{\0A}\0A\0Avoid stop()\0A{\0A}\0A\0Astatic int test_skeleton()\0A{\0A\09return 0; // Success\0A}\0A\0Aepicfail_case_t manifest[] = {\0A\09{ \22Sample test case\22, test_skeleton },\0A\09{ 0, 0 }, // Final row\0A};\0A\00"
@.str.5 = [7 x i8] c"Header\00"
@.str.6 = [11 x i8] c"epicfail.h\00"
@.str.7 = [183 x i8] c"#define H_CONTENT = \0A#ifndef EPICFAIL_H\0A#define EPICFAIL_H\0A\0Atypedef int (*epicfail_func_t) ();\0Atypedef struct {\0A\09const char *title;\0A\09epicfail_func_t call;\0A} epicfail_case_t;\0A\0A#endif\0A\00"
define void @generate_make() {
%1 = call i32 @write_file(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([281 x i8], [281 x i8]* @.str.1, i64 0, i64 0))
%2 = call i32 @write_file(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([211 x i8], [211 x i8]* @.str.4, i64 0, i64 0))
%3 = call i32 @write_file(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([183 x i8], [183 x i8]* @.str.7, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [9 x i8] c"Makefile\00"
@.str.1 = [281 x i8] c"SRC=$(wildcard *.c)\0A\0ACC=cc\0ACFLAGS=\0ALIBS=$(SRC:%.c=test_%.ef)\0AOBJS=# Add objectfiles to be included in testing.\0A\0A.PHONY: all clean re\0A\0Aall: $(LIBS)\0A\0Atest_%.ef: %.c\0A\09@echo \22Building $@ from $<\22\0A\09@$(CC) $(CFLAGS) -shared -fPIC -Wl,-soname,$@ -o $@ $< $(OBJS)\0A\0Aclean:\0A\09$(RM) $(LIBS)\0A\0A\00"
@.str.2 = [14 x i8] c"Sample source\00"
@.str.3 = [11 x i8] c"skeleton.c\00"
@.str.4 = [211 x i8] c"#include \22epicfail.h\22\0A\0Avoid start()\0A{\0A}\0A\0Avoid stop()\0A{\0A}\0A\0Astatic int test_skeleton()\0A{\0A\09return 0; // Success\0A}\0A\0Aepicfail_case_t manifest[] = {\0A\09{ \22Sample test case\22, test_skeleton },\0A\09{ 0, 0 }, // Final row\0A};\0A\00"
@.str.5 = [7 x i8] c"Header\00"
@.str.6 = [11 x i8] c"epicfail.h\00"
@.str.7 = [183 x i8] c"#define H_CONTENT = \0A#ifndef EPICFAIL_H\0A#define EPICFAIL_H\0A\0Atypedef int (*epicfail_func_t) ();\0Atypedef struct {\0A\09const char *title;\0A\09epicfail_func_t call;\0A} epicfail_case_t;\0A\0A#endif\0A\00"
define void @generate_make() {
%1 = tail call i32 @write_file(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([281 x i8], [281 x i8]* @.str.1, i64 0, i64 0))
%2 = tail call i32 @write_file(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([211 x i8], [211 x i8]* @.str.4, i64 0, i64 0))
%3 = tail call i32 @write_file(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([183 x i8], [183 x i8]* @.str.7, i64 0, i64 0))
ret void
}