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

/* Variables and functions */
int BUFSIZ;
int /*<<< orphan*/ exit(int);
scalar_t__ gethostname(char *, int);
int /*<<< orphan*/ printf(char *, ...);
unsigned long time(int /*<<< orphan*/ *);
void print_header() {
  char hostnamebuf[BUFSIZ];
  unsigned long now;
  if (gethostname(hostnamebuf, sizeof(hostnamebuf) - 1) < 0) {
    printf("error getting hostname\n");
    exit(1);
  }
  hostnamebuf[sizeof(hostnamebuf) - 1] = 0;
  now = time((time_t *)0);
  printf("class|host|start_time\n");
  printf("body|%s|%lu\n", hostnamebuf, now);
  printf(
      "MD5|name|inode|mode_as_string|UID|GID|size|atime|mtime|ctime|crtime\n");
  return;
}


x86 assembly (clang, -O0):
<print_header>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    0x2e91(%rip),%rax
mov    (%rax),%eax
mov    %rax,-0x28(%rbp)
mov    %rsp,%rcx
mov    %rcx,-0x8(%rbp)
mov    %rax,%rcx
add    $0xf,%rcx
and    $0xfffffffffffffff0,%rcx
mov    %rsp,%rdi
sub    %rcx,%rdi
mov    %rdi,-0x20(%rbp)
mov    %rdi,%rsp
mov    %rax,-0x10(%rbp)
sub    $0x1,%rax
mov    %eax,%esi
call   1050 <gethostname@plt>
cmp    $0x0,%rax
jge    11a5 <print_header+0x65>
lea    0xe6c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x1,%edi
call   1060 <exit@plt>
mov    -0x20(%rbp),%rax
mov    -0x28(%rbp),%rcx
sub    $0x1,%rcx
movb   $0x0,(%rax,%rcx,1)
xor    %eax,%eax
mov    %eax,%edi
call   1040 <time@plt>
mov    %rax,-0x18(%rbp)
lea    0xe4f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x20(%rbp),%rsi
mov    -0x18(%rbp),%rdx
lea    0xe50(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe4f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%rax
mov    %rax,%rsp
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_header>:
push   %rbp
mov    %rsp,%rbp
push   %r14
push   %rbx
mov    0x2e82(%rip),%rax
mov    (%rax),%ebx
mov    %rsp,%r14
lea    0xf(%rbx),%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r14
mov    %r14,%rsp
add    $0xffffffffffffffff,%rbx
mov    %r14,%rdi
mov    %ebx,%esi
call   1060 <gethostname@plt>
test   %rax,%rax
js     11c8 <print_header+0x78>
movb   $0x0,(%r14,%rbx,1)
xor    %edi,%edi
call   1050 <time@plt>
mov    %rax,%rbx
lea    0xe73(%rip),%rdi
call   1030 <puts@plt>
lea    0xe5a(%rip),%rdi
mov    %r14,%rsi
mov    %rbx,%rdx
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe69(%rip),%rdi
call   1030 <puts@plt>
lea    -0x10(%rbp),%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret
lea    0xe98(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@BUFSIZ = global i32 0
@.str = [24 x i8] c"error getting hostname\0A\00"
@.str.1 = [23 x i8] c"class|host|start_time\0A\00"
@.str.2 = [13 x i8] c"body|%s|%lu\0A\00"
@.str.3 = [69 x i8] c"MD5|name|inode|mode_as_string|UID|GID|size|atime|mtime|ctime|crtime\0A\00"
define void @print_header() {
%1 = alloca i8*
%2 = alloca i64
%3 = alloca i64
%4 = load i32, i32* @BUFSIZ
%5 = zext i32 %4 to i64
%6 = call i8* @llvm.stacksave()
store i8* %6, i8** %1
%7 = alloca i8, i64 %5
store i64 %5, i64* %2
%8 = sub i64 %5, 1
%9 = trunc i64 %8 to i32
%10 = call i64 @gethostname(i8* %7, i32 %9)
%11 = icmp slt i64 %10, 0
br i1 %11, label %12, label %15
12: ; preds = %0
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0))
%14 = call i32 @exit(i32 1)
unreachable
15: ; preds = %0
%16 = sub i64 %5, 1
%17 = getelementptr inbounds i8, i8* %7, i64 %16
store i8 0, i8* %17
%18 = call i64 @time(i32* null)
store i64 %18, i64* %3
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0))
%20 = load i64, i64* %3
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i8* %7, i64 %20)
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([69 x i8], [69 x i8]* @.str.3, i64 0, i64 0))
%23 = load i8*, i8** %1
ret void
}

LLVM IR (-O2):
@BUFSIZ = global i32 0
@.str.2 = [13 x i8] c"body|%s|%lu\0A\00"
@str = [22 x i8] c"class|host|start_time\00"
@str.4 = [68 x i8] c"MD5|name|inode|mode_as_string|UID|GID|size|atime|mtime|ctime|crtime\00"
@str.5 = [23 x i8] c"error getting hostname\00"
define void @print_header() {
%1 = load i32, i32* @BUFSIZ
%2 = zext i32 %1 to i64
%3 = alloca i8, i64 %2
%4 = add nsw i64 %2, -1
%5 = trunc i64 %4 to i32
%6 = call i64 @gethostname(i8* %3, i32 %5)
%7 = icmp slt i64 %6, 0
br i1 %7, label %8, label %11
8: ; preds = %0
%9 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @str.5, i64 0, i64 0))
%10 = call i32 @exit(i32 1)
unreachable
11: ; preds = %0
%12 = getelementptr inbounds i8, i8* %3, i64 %4
store i8 0, i8* %12
%13 = call i64 @time(i32* null)
%14 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str, i64 0, i64 0))
%15 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i8* %3, i64 %13)
%16 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([68 x i8], [68 x i8]* @str.4, i64 0, i64 0))
ret void
}