#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 *, int);
scalar_t__ strlen(char *);
void write_header(FILE *out, char *v, char *sv, char *p) {
  fprintf(
      out,
      "/*\n *	System info shared with user space\n */\nstruct sysinfoblk {\n "
      " uint8_t infosize;		/* For expandability */\n  uint8_t "
      "banks;		/* Banks in our 64K (and thus pagesize) */\n  uint8_t "
      "max_open;\n  uint8_t nproc;		/* Number of processes */\n  "
      "uint16_t ticks;		/* Tick rate in HZ */\n  uint16_t memk;	"
      "	/* Memory in KB */\n  uint16_t usedk;		/* Used memory in KB "
      "*/\n  uint16_t config;		/* Config flag mask */\n#define "
      "CONF_PROFIL		1\n#define CONF_NET		2	/* "
      "Hah.. 8) */\n#define CONF_LEVEL_2		4\n  uint16_t "
      "loadavg[3];\n  uint16_t swapk;\n  uint16_t swapusedk;\n  uint8_t "
      "cputype;		/* CPU type information */\n  uint8_t cpu[3];	"
      "	/* CPU type specific data */\n  uint16_t spare[8];\n  char "
      "uname[%d];\n};\n\n",
      (int)(strlen(v) + strlen(sv) + strlen(p) + 9));
}


x86 assembly (clang, -O0):
<write_header>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %rax,-0x38(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <strlen@plt>
mov    %rax,%rcx
mov    -0x38(%rbp),%rax
add    %rcx,%rax
mov    %rax,-0x28(%rbp)
mov    -0x20(%rbp),%rdi
call   1030 <strlen@plt>
mov    -0x30(%rbp),%rdi
mov    %rax,%rcx
mov    -0x28(%rbp),%rax
add    %rcx,%rax
add    $0x9,%rax
mov    %eax,%edx
lea    0xe78(%rip),%rsi
call   1040 <fprintf@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<write_header>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rcx,%r14
mov    %rdx,%rbx
mov    %rdi,%r15
mov    %rsi,%rdi
call   1030 <strlen@plt>
mov    %rax,%r12
mov    %rbx,%rdi
call   1030 <strlen@plt>
mov    %rax,%rbx
add    %r12d,%ebx
mov    %r14,%rdi
call   1030 <strlen@plt>
lea    (%rax,%rbx,1),%edx
add    $0x9,%edx
lea    0xea1(%rip),%rsi
mov    %r15,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
jmp    1040 <fprintf@plt>

LLVM IR (-O0):
@.str = [683 x i8] c"/*\0A *\09System info shared with user space\0A */\0Astruct sysinfoblk {\0A uint8_t infosize;\09\09/* For expandability */\0A uint8_t banks;\09\09/* Banks in our 64K (and thus pagesize) */\0A uint8_t max_open;\0A uint8_t nproc;\09\09/* Number of processes */\0A uint16_t ticks;\09\09/* Tick rate in HZ */\0A uint16_t memk;\09\09/* Memory in KB */\0A uint16_t usedk;\09\09/* Used memory in KB */\0A uint16_t config;\09\09/* Config flag mask */\0A#define CONF_PROFIL\09\091\0A#define CONF_NET\09\092\09/* Hah.. 8) */\0A#define CONF_LEVEL_2\09\094\0A uint16_t loadavg[3];\0A uint16_t swapk;\0A uint16_t swapusedk;\0A uint8_t cputype;\09\09/* CPU type information */\0A uint8_t cpu[3];\09\09/* CPU type specific data */\0A uint16_t spare[8];\0A char uname[%d];\0A};\0A\0A\00"
define void @write_header(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 = call i64 @strlen(i8* %10)
%12 = load i8*, i8** %7
%13 = call i64 @strlen(i8* %12)
%14 = add nsw i64 %11, %13
%15 = load i8*, i8** %8
%16 = call i64 @strlen(i8* %15)
%17 = add nsw i64 %14, %16
%18 = add nsw i64 %17, 9
%19 = trunc i64 %18 to i32
%20 = call i32 @fprintf(i32* %9, i8* getelementptr inbounds ([683 x i8], [683 x i8]* @.str, i64 0, i64 0), i32 %19)
ret void
}

LLVM IR (-O2):
@.str = [683 x i8] c"/*\0A *\09System info shared with user space\0A */\0Astruct sysinfoblk {\0A uint8_t infosize;\09\09/* For expandability */\0A uint8_t banks;\09\09/* Banks in our 64K (and thus pagesize) */\0A uint8_t max_open;\0A uint8_t nproc;\09\09/* Number of processes */\0A uint16_t ticks;\09\09/* Tick rate in HZ */\0A uint16_t memk;\09\09/* Memory in KB */\0A uint16_t usedk;\09\09/* Used memory in KB */\0A uint16_t config;\09\09/* Config flag mask */\0A#define CONF_PROFIL\09\091\0A#define CONF_NET\09\092\09/* Hah.. 8) */\0A#define CONF_LEVEL_2\09\094\0A uint16_t loadavg[3];\0A uint16_t swapk;\0A uint16_t swapusedk;\0A uint8_t cputype;\09\09/* CPU type information */\0A uint8_t cpu[3];\09\09/* CPU type specific data */\0A uint16_t spare[8];\0A char uname[%d];\0A};\0A\0A\00"
define void @write_header(i32* nocapture %0, i8* nocapture %1, i8* nocapture %2, i8* nocapture %3) {
%5 = tail call i64 @strlen(i8* dereferenceable(1) %1)
%6 = tail call i64 @strlen(i8* dereferenceable(1) %2)
%7 = add nsw i64 %6, %5
%8 = tail call i64 @strlen(i8* dereferenceable(1) %3)
%9 = add nsw i64 %7, %8
%10 = trunc i64 %9 to i32
%11 = add i32 %10, 9
%12 = tail call i32 @fprintf(i32* %0, i8* getelementptr inbounds ([683 x i8], [683 x i8]* @.str, i64 0, i64 0), i32 %11)
ret void
}