#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, char *, char *,
                           char *);
void write_body(FILE *out, char *v, char *sv, char *p) {
  fprintf(out,
          "#include \"kernel.h\"\n#include \"version.h\"\n/* Format is "
          "version/sysname/release/system */\n/* pack version first so we can "
          "use uname_str as a printf target */\nstruct sysinfoblk sysinfo = "
          "{\n	sizeof(struct sysinfoblk),\n	CONFIG_BANKS,\n	"
          "UFTSIZE,\n	PTABSIZE,\n	TICKSPERSEC,\n	0,\n	0,\n#ifdef "
          "CONFIG_PROFIL\n	CONF_PROFIL |\n#endif\n#ifdef "
          "CONFIG_LEVEL_2\n	CONF_LEVEL_2 |\n#endif\n	0,\n	{0, 0, "
          "0},\n	0,\n	0,\n	0,\n	{0, 0, 0},\n	{0, 0, 0, 0, "
          "0, 0, 0, 0},\n	/* Quoting to work around cc65 bug */\n	"
          "\"%s\\0\"\"Fuzix\\0\"\"%s\\0\"\"%s\"\n};\n\n",
          v, sv, p);
}


x86 assembly (clang, -O0):
<write_body>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    -0x18(%rbp),%rcx
mov    -0x20(%rbp),%r8
lea    0xec1(%rip),%rsi
call   1030 <fprintf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<write_body>:
mov    %rcx,%r8
mov    %rdx,%rcx
mov    %rsi,%rdx
lea    0xee0(%rip),%rsi
jmp    1030 <fprintf@plt>

LLVM IR (-O0):
@.str = [498 x i8] c"#include \22kernel.h\22\0A#include \22version.h\22\0A/* Format is version/sysname/release/system */\0A/* pack version first so we can use uname_str as a printf target */\0Astruct sysinfoblk sysinfo = {\0A\09sizeof(struct sysinfoblk),\0A\09CONFIG_BANKS,\0A\09UFTSIZE,\0A\09PTABSIZE,\0A\09TICKSPERSEC,\0A\090,\0A\090,\0A#ifdef CONFIG_PROFIL\0A\09CONF_PROFIL |\0A#endif\0A#ifdef CONFIG_LEVEL_2\0A\09CONF_LEVEL_2 |\0A#endif\0A\090,\0A\09{0, 0, 0},\0A\090,\0A\090,\0A\090,\0A\09{0, 0, 0},\0A\09{0, 0, 0, 0, 0, 0, 0, 0},\0A\09/* Quoting to work around cc65 bug */\0A\09\22%s\\0\22\22Fuzix\\0\22\22%s\\0\22\22%s\22\0A};\0A\0A\00"
define void @write_body(i32* %0, i8* %1, i8* %2, i8* %3) {
%5 = alloca i32*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
store i32* %0, i32** %5
store i8* %1, i8** %6
store i8* %2, i8** %7
store i8* %3, i8** %8
%9 = load i32*, i32** %5
%10 = load i8*, i8** %6
%11 = load i8*, i8** %7
%12 = load i8*, i8** %8
%13 = call i32 @fprintf(i32* %9, i8* getelementptr inbounds ([498 x i8], [498 x i8]* @.str, i64 0, i64 0), i8* %10, i8* %11, i8* %12)
ret void
}

LLVM IR (-O2):
@.str = [498 x i8] c"#include \22kernel.h\22\0A#include \22version.h\22\0A/* Format is version/sysname/release/system */\0A/* pack version first so we can use uname_str as a printf target */\0Astruct sysinfoblk sysinfo = {\0A\09sizeof(struct sysinfoblk),\0A\09CONFIG_BANKS,\0A\09UFTSIZE,\0A\09PTABSIZE,\0A\09TICKSPERSEC,\0A\090,\0A\090,\0A#ifdef CONFIG_PROFIL\0A\09CONF_PROFIL |\0A#endif\0A#ifdef CONFIG_LEVEL_2\0A\09CONF_LEVEL_2 |\0A#endif\0A\090,\0A\09{0, 0, 0},\0A\090,\0A\090,\0A\090,\0A\09{0, 0, 0},\0A\09{0, 0, 0, 0, 0, 0, 0, 0},\0A\09/* Quoting to work around cc65 bug */\0A\09\22%s\\0\22\22Fuzix\\0\22\22%s\\0\22\22%s\22\0A};\0A\0A\00"
define void @write_body(i32* nocapture %0, i8* %1, i8* %2, i8* %3) {
%5 = tail call i32 @fprintf(i32* %0, i8* getelementptr inbounds ([498 x i8], [498 x i8]* @.str, i64 0, i64 0), i8* %1, i8* %2, i8* %3)
ret void
}