char *get_header(void) {
  char *rv;
  if (asprintf(&rv, "%-5.5s %-9.9s %-8.8s %-8.8s %-5.5s %-4.4s %-9.9s %s",
               "PID", "User", "RES(KiB)", "SHR(KiB)", "CPU%", "Prcs", "Uptime",
               "Command") == -1)
    do {
      char msgout[500];
      sprintf(msgout, "Error %s:%s(%d)", "asprintf", __FUNCTION__, 36);
      perror(msgout);
      exit(1);
    } while (0);
  return rv;
}


x86 assembly (clang, -O0):
<get_header>:
push   %rbp
mov    %rsp,%rbp
push   %rbx
sub    $0x228,%rsp
lea    -0x10(%rbp),%rdi
lea    0xea9(%rip),%rsi
lea    0xed6(%rip),%rdx
lea    0xed3(%rip),%rcx
lea    0xed1(%rip),%r8
lea    0xed3(%rip),%r9
lea    0xed5(%rip),%rbx
lea    0xed3(%rip),%r11
lea    0xed1(%rip),%r10
lea    0xed1(%rip),%rax
mov    %rbx,(%rsp)
mov    %r11,0x8(%rsp)
mov    %r10,0x10(%rsp)
mov    %rax,0x18(%rsp)
mov    $0x0,%al
call   1030 <asprintf@plt>
cmp    $0xffffffff,%eax
jne    11f8 <get_header+0xb8>
jmp    11b7 <get_header+0x77>
lea    -0x210(%rbp),%rdi
lea    0xea3(%rip),%rsi
lea    0xeac(%rip),%rdx
lea    0xeae(%rip),%rcx
mov    $0x24,%r8d
mov    $0x0,%al
call   1050 <sprintf@plt>
lea    -0x210(%rbp),%rdi
mov    $0x0,%al
call   1040 <perror@plt>
mov    $0x1,%edi
call   1060 <exit@plt>
mov    -0x10(%rbp),%rax
add    $0x228,%rsp
pop    %rbx
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_header>:
push   %r14
push   %rbx
sub    $0x208,%rsp
lea    0xf0f(%rip),%rbx
lea    0xf01(%rip),%r10
lea    0xef5(%rip),%r11
lea    0xee9(%rip),%r14
lea    0xe93(%rip),%rsi
lea    0xec0(%rip),%rdx
lea    0xebd(%rip),%rcx
lea    0xebb(%rip),%r8
lea    0xebd(%rip),%r9
lea    0x8(%rsp),%rdi
xor    %eax,%eax
push   %rbx
push   %r10
push   %r11
push   %r14
call   1030 <asprintf@plt>
add    $0x20,%rsp
cmp    $0xffffffff,%eax
je     11b5 <get_header+0x75>
mov    0x8(%rsp),%rax
add    $0x208,%rsp
pop    %rbx
pop    %r14
ret
lea    0xeac(%rip),%rsi
lea    0xeb5(%rip),%rdx
lea    0xeb7(%rip),%rcx
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x24,%r8d
xor    %eax,%eax
call   1050 <sprintf@plt>
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <perror@plt>
mov    $0x1,%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@.str = [52 x i8] c"%-5.5s %-9.9s %-8.8s %-8.8s %-5.5s %-4.4s %-9.9s %s\00"
@.str.1 = [4 x i8] c"PID\00"
@.str.2 = [5 x i8] c"User\00"
@.str.3 = [9 x i8] c"RES(KiB)\00"
@.str.4 = [9 x i8] c"SHR(KiB)\00"
@.str.5 = [5 x i8] c"CPU%\00"
@.str.6 = [5 x i8] c"Prcs\00"
@.str.7 = [7 x i8] c"Uptime\00"
@.str.8 = [8 x i8] c"Command\00"
@.str.9 = [16 x i8] c"Error %s:%s(%d)\00"
@.str.10 = [9 x i8] c"asprintf\00"
@__FUNCTION__.get_header = [11 x i8] c"get_header\00"
define i8* @get_header() {
%1 = alloca i8*
%2 = alloca [500 x i8]
%3 = call i32 (i8**, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, ...) bitcast (i32 (...)* @asprintf to i32 (i8**, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, ...)*)(i8** %1, i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.8, i64 0, i64 0))
%4 = icmp eq i32 %3, -1
br i1 %4, label %5, label %12
5: ; preds = %0
br label %6
6: ; preds = %5
%7 = getelementptr inbounds [500 x i8], [500 x i8]* %2, i64 0, i64 0
%8 = call i32 (i8*, i8*, ...) @sprintf(i8* %7, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.9, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.10, i64 0, i64 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @__FUNCTION__.get_header, i64 0, i64 0), i32 36)
%9 = getelementptr inbounds [500 x i8], [500 x i8]* %2, i64 0, i64 0
%10 = call i32 (i8*, ...) bitcast (i32 (...)* @perror to i32 (i8*, ...)*)(i8* %9)
unreachable
11: ; No predecessors!
br label %12
12: ; preds = %11, %0
%13 = load i8*, i8** %1
ret i8* %13
}

LLVM IR (-O2):
@.str = [52 x i8] c"%-5.5s %-9.9s %-8.8s %-8.8s %-5.5s %-4.4s %-9.9s %s\00"
@.str.1 = [4 x i8] c"PID\00"
@.str.2 = [5 x i8] c"User\00"
@.str.3 = [9 x i8] c"RES(KiB)\00"
@.str.4 = [9 x i8] c"SHR(KiB)\00"
@.str.5 = [5 x i8] c"CPU%\00"
@.str.6 = [5 x i8] c"Prcs\00"
@.str.7 = [7 x i8] c"Uptime\00"
@.str.8 = [8 x i8] c"Command\00"
@.str.9 = [16 x i8] c"Error %s:%s(%d)\00"
@.str.10 = [9 x i8] c"asprintf\00"
@__FUNCTION__.get_header = [11 x i8] c"get_header\00"
define i8* @get_header() {
%1 = alloca i8*
%2 = alloca [500 x i8]
%3 = bitcast i8** %1 to i8*
%4 = call i32 (i8**, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, ...) bitcast (i32 (...)* @asprintf to i32 (i8**, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, ...)*)(i8** %1, i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.8, i64 0, i64 0))
%5 = icmp eq i32 %4, -1
br i1 %5, label %6, label %10
6: ; preds = %0
%7 = getelementptr inbounds [500 x i8], [500 x i8]* %2, i64 0, i64 0
%8 = call i32 (i8*, i8*, ...) @sprintf(i8* %7, i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.9, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.10, i64 0, i64 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @__FUNCTION__.get_header, i64 0, i64 0), i32 36)
%9 = call i32 (i8*, ...) bitcast (i32 (...)* @perror to i32 (i8*, ...)*)(i8* %7)
unreachable
10: ; preds = %0
%11 = load i8*, i8** %1
ret i8* %11
}