#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*/ *getenv(char *);
int /*<<< orphan*/ hprf(char *, int, int /*<<< orphan*/ *, int, char *);
int /*<<< orphan*/ memcpy(char *, char *, int);
int /*<<< orphan*/ strcpy(char *, char *);
int strlen(char *);
char *value(char *);
void printhead(int mesg, FILE *f, int threaded) {
  int bsdflags, bsdheadline, sz;
  char *fmt, attrlist[30], *cp;
  bsdflags = value("bsdcompat") != NULL || value("bsdflags") != NULL ||
             getenv("SYSV3") != NULL;
  strcpy(attrlist, bsdflags ? "NU  *HMFATK+-J" : "NUROSPMFATK+-J");
  if ((cp = value("attrlist")) != NULL) {
    sz = strlen(cp);
    if (sz > sizeof attrlist - 1)
      sz = sizeof attrlist - 1;
    memcpy(attrlist, cp, sz);
  }
  bsdheadline = value("bsdcompat") != NULL || value("bsdheadline") != NULL;
  if ((fmt = value("headline")) == NULL)
    fmt = bsdheadline ? "%>%a%m %20f  %16d %3l/%-5o %i%S"
                      : "%>%a%m %18f %16d %4l/%-5o %i%s";
  hprf(fmt, mesg, f, threaded, attrlist);
}


x86 assembly (clang, -O0):
<printhead>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
lea    0xe87(%rip),%rdi
call   1070 <value@plt>
mov    %rax,%rcx
mov    $0x1,%al
cmp    $0x0,%rcx
mov    %al,-0x59(%rbp)
jne    11c4 <printhead+0x64>
lea    0xe73(%rip),%rdi
call   1070 <value@plt>
mov    %rax,%rcx
mov    $0x1,%al
cmp    $0x0,%rcx
mov    %al,-0x59(%rbp)
jne    11c4 <printhead+0x64>
lea    0xe5e(%rip),%rdi
call   1030 <getenv@plt>
cmp    $0x0,%rax
setne  %al
mov    %al,-0x59(%rbp)
mov    -0x59(%rbp),%al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x18(%rbp)
lea    -0x50(%rbp),%rdi
mov    -0x18(%rbp),%ecx
lea    0xe4b(%rip),%rsi
lea    0xe35(%rip),%rax
cmp    $0x0,%ecx
cmovne %rax,%rsi
call   1040 <strcpy@plt>
lea    0xe40(%rip),%rdi
call   1070 <value@plt>
mov    %rax,-0x58(%rbp)
cmp    $0x0,%rax
je     123b <printhead+0xdb>
mov    -0x58(%rbp),%rdi
call   1050 <strlen@plt>
mov    %eax,-0x20(%rbp)
movslq -0x20(%rbp),%rax
cmp    $0x1d,%rax
jbe    122b <printhead+0xcb>
movl   $0x1d,-0x20(%rbp)
lea    -0x50(%rbp),%rdi
mov    -0x58(%rbp),%rsi
mov    -0x20(%rbp),%edx
call   1080 <memcpy@plt>
lea    0xdbe(%rip),%rdi
call   1070 <value@plt>
mov    %rax,%rcx
mov    $0x1,%al
cmp    $0x0,%rcx
mov    %al,-0x5a(%rbp)
jne    126f <printhead+0x10f>
lea    0xde0(%rip),%rdi
call   1070 <value@plt>
cmp    $0x0,%rax
setne  %al
mov    %al,-0x5a(%rbp)
mov    -0x5a(%rbp),%al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x1c(%rbp)
lea    0xdc2(%rip),%rdi
call   1070 <value@plt>
mov    %rax,-0x28(%rbp)
cmp    $0x0,%rax
jne    12b0 <printhead+0x150>
mov    -0x1c(%rbp),%edx
lea    0xdce(%rip),%rax
lea    0xda7(%rip),%rcx
cmp    $0x0,%edx
cmovne %rcx,%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
mov    -0x4(%rbp),%esi
mov    -0x10(%rbp),%rdx
mov    -0x14(%rbp),%ecx
lea    -0x50(%rbp),%r8
call   1060 <hprf@plt>
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<printhead>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x28,%rsp
mov    %edx,%r14d
mov    %rsi,%r15
mov    %edi,%ebp
lea    0xe87(%rip),%rdi
call   1070 <value@plt>
lea    0xe94(%rip),%rbx
test   %rax,%rax
jne    11bc <printhead+0x5c>
lea    0xe79(%rip),%rdi
call   1070 <value@plt>
test   %rax,%rax
jne    11bc <printhead+0x5c>
lea    0xe71(%rip),%rdi
call   1030 <getenv@plt>
test   %rax,%rax
lea    0xe77(%rip),%rax
lea    0xe61(%rip),%rbx
cmove  %rax,%rbx
mov    %rsp,%rdi
mov    %rbx,%rsi
call   1040 <strcpy@plt>
lea    0xe69(%rip),%rdi
call   1070 <value@plt>
test   %rax,%rax
je     11f9 <printhead+0x99>
mov    %rax,%rbx
mov    %rax,%rdi
call   1050 <strlen@plt>
cmp    $0x1d,%eax
mov    $0x1d,%edx
cmovb  %eax,%edx
mov    %rsp,%rdi
mov    %rbx,%rsi
call   1080 <memcpy@plt>
lea    0xe00(%rip),%rdi
call   1070 <value@plt>
test   %rax,%rax
je     1213 <printhead+0xb3>
lea    0xe3b(%rip),%rbx
jmp    1234 <printhead+0xd4>
lea    0xe26(%rip),%rdi
call   1070 <value@plt>
test   %rax,%rax
lea    0xe43(%rip),%rax
lea    0xe1c(%rip),%rbx
cmove  %rax,%rbx
lea    0xe08(%rip),%rdi
call   1070 <value@plt>
test   %rax,%rax
cmovne %rax,%rbx
mov    %rsp,%r8
mov    %rbx,%rdi
mov    %ebp,%esi
mov    %r15,%rdx
mov    %r14d,%ecx
call   1060 <hprf@plt>
add    $0x28,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [10 x i8] c"bsdcompat\00"
@.str.1 = [9 x i8] c"bsdflags\00"
@.str.2 = [6 x i8] c"SYSV3\00"
@.str.3 = [15 x i8] c"NU *HMFATK+-J\00"
@.str.4 = [15 x i8] c"NUROSPMFATK+-J\00"
@.str.5 = [9 x i8] c"attrlist\00"
@.str.6 = [12 x i8] c"bsdheadline\00"
@.str.7 = [9 x i8] c"headline\00"
@.str.8 = [32 x i8] c"%>%a%m %20f %16d %3l/%-5o %i%S\00"
@.str.9 = [31 x i8] c"%>%a%m %18f %16d %4l/%-5o %i%s\00"
define void @printhead(i32 %0, i32* %1, i32 %2) {
%4 = alloca i32
%5 = alloca i32*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i8*
%11 = alloca [30 x i8]
%12 = alloca i8*
store i32 %0, i32* %4
store i32* %1, i32** %5
store i32 %2, i32* %6
%13 = call i8* @value(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
%14 = icmp ne i8* %13, null
br i1 %14, label %21, label %15
15: ; preds = %3
%16 = call i8* @value(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
%17 = icmp ne i8* %16, null
br i1 %17, label %21, label %18
18: ; preds = %15
%19 = call i32* @getenv(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%20 = icmp ne i32* %19, null
br label %21
21: ; preds = %18, %15, %3
%22 = phi i1 [ true, %15 ], [ true, %3 ], [ %20, %18 ]
%23 = zext i1 %22 to i32
store i32 %23, i32* %7
%24 = getelementptr inbounds [30 x i8], [30 x i8]* %11, i64 0, i64 0
%25 = load i32, i32* %7
%26 = icmp ne i32 %25, 0
%27 = zext i1 %26 to i64
%28 = select i1 %26, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0)
%29 = call i32 @strcpy(i8* %24, i8* %28)
%30 = call i8* @value(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0))
store i8* %30, i8** %12
%31 = icmp ne i8* %30, null
br i1 %31, label %32, label %44
32: ; preds = %21
%33 = load i8*, i8** %12
%34 = call i32 @strlen(i8* %33)
store i32 %34, i32* %9
%35 = load i32, i32* %9
%36 = sext i32 %35 to i64
%37 = icmp ugt i64 %36, 29
br i1 %37, label %38, label %39
38: ; preds = %32
store i32 29, i32* %9
br label %39
39: ; preds = %38, %32
%40 = getelementptr inbounds [30 x i8], [30 x i8]* %11, i64 0, i64 0
%41 = load i8*, i8** %12
%42 = load i32, i32* %9
%43 = call i32 @memcpy(i8* %40, i8* %41, i32 %42)
br label %44
44: ; preds = %39, %21
%45 = call i8* @value(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
%46 = icmp ne i8* %45, null
br i1 %46, label %50, label %47
47: ; preds = %44
%48 = call i8* @value(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.6, i64 0, i64 0))
%49 = icmp ne i8* %48, null
br label %50
50: ; preds = %47, %44
%51 = phi i1 [ true, %44 ], [ %49, %47 ]
%52 = zext i1 %51 to i32
store i32 %52, i32* %8
%53 = call i8* @value(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.7, i64 0, i64 0))
store i8* %53, i8** %10
%54 = icmp eq i8* %53, null
br i1 %54, label %55, label %60
55: ; preds = %50
%56 = load i32, i32* %8
%57 = icmp ne i32 %56, 0
%58 = zext i1 %57 to i64
%59 = select i1 %57, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.8, i64 0, i64 0), i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.9, i64 0, i64 0)
store i8* %59, i8** %10
br label %60
60: ; preds = %55, %50
%61 = load i8*, i8** %10
%62 = load i32, i32* %4
%63 = load i32*, i32** %5
%64 = load i32, i32* %6
%65 = getelementptr inbounds [30 x i8], [30 x i8]* %11, i64 0, i64 0
%66 = call i32 @hprf(i8* %61, i32 %62, i32* %63, i32 %64, i8* %65)
ret void
}

LLVM IR (-O2):
@.str = [10 x i8] c"bsdcompat\00"
@.str.1 = [9 x i8] c"bsdflags\00"
@.str.2 = [6 x i8] c"SYSV3\00"
@.str.3 = [15 x i8] c"NU *HMFATK+-J\00"
@.str.4 = [15 x i8] c"NUROSPMFATK+-J\00"
@.str.5 = [9 x i8] c"attrlist\00"
@.str.6 = [12 x i8] c"bsdheadline\00"
@.str.7 = [9 x i8] c"headline\00"
@.str.8 = [32 x i8] c"%>%a%m %20f %16d %3l/%-5o %i%S\00"
@.str.9 = [31 x i8] c"%>%a%m %18f %16d %4l/%-5o %i%s\00"
define void @printhead(i32 %0, i32* %1, i32 %2) {
%4 = alloca [30 x i8]
%5 = getelementptr inbounds [30 x i8], [30 x i8]* %4, i64 0, i64 0
%6 = tail call i8* @value(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
%7 = icmp eq i8* %6, null
br i1 %7, label %8, label %15
8: ; preds = %3
%9 = tail call i8* @value(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
%10 = icmp eq i8* %9, null
br i1 %10, label %11, label %15
11: ; preds = %8
%12 = tail call i32* @getenv(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%13 = icmp eq i32* %12, null
%14 = select i1 %13, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0)
br label %15
15: ; preds = %11, %8, %3
%16 = phi i8* [ getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0), %8 ], [ getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0), %3 ], [ %14, %11 ]
%17 = call i32 @strcpy(i8* %5, i8* %16)
%18 = call i8* @value(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0))
%19 = icmp eq i8* %18, null
br i1 %19, label %25, label %20
20: ; preds = %15
%21 = call i32 @strlen(i8* %18)
%22 = icmp ult i32 %21, 29
%23 = select i1 %22, i32 %21, i32 29
%24 = call i32 @memcpy(i8* %5, i8* %18, i32 %23)
br label %25
25: ; preds = %20, %15
%26 = call i8* @value(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
%27 = icmp eq i8* %26, null
br i1 %27, label %28, label %32
28: ; preds = %25
%29 = call i8* @value(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.6, i64 0, i64 0))
%30 = icmp eq i8* %29, null
%31 = select i1 %30, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.9, i64 0, i64 0), i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.8, i64 0, i64 0)
br label %32
32: ; preds = %28, %25
%33 = phi i8* [ getelementptr inbounds ([32 x i8], [32 x i8]* @.str.8, i64 0, i64 0), %25 ], [ %31, %28 ]
%34 = call i8* @value(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.7, i64 0, i64 0))
%35 = icmp eq i8* %34, null
%36 = select i1 %35, i8* %33, i8* %34
%37 = call i32 @hprf(i8* %36, i32 %0, i32* %1, i32 %2, i8* %5)
ret void
}