#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 */

/* Variables and functions */
int /*<<< orphan*/ snprintf(char *, int, char *, char *, char *, char *, char *,
                            char *, char *);
void pqos_cmt_caption_build(int lwpid, char *buf, int size) {
  if (lwpid == 0)
    snprintf(buf, size, "%6s%15s%11s%11s%21s%11s", "PID", "PROC", "RMA(K)",
             "LMA(K)", "LLC.OCCUPANCY(MB)", "CPU%%");
  else
    snprintf(buf, size, "%6s%15s%11s%11s%21s%11s", "LWP", "PROC", "RMA(K)",
             "LMA(K)", "LLC.OCCUPANCY(MB)", "CPU%%");
}


x86 assembly (clang, -O0):
<pqos_cmt_caption_build>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
cmpl   $0x0,-0x4(%rbp)
jne    117c <pqos_cmt_caption_build+0x6c>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
lea    0xec6(%rip),%rdx
lea    0xed7(%rip),%rcx
lea    0xed4(%rip),%r8
lea    0xed2(%rip),%r9
lea    0xed2(%rip),%r11
lea    0xed2(%rip),%r10
lea    0xedd(%rip),%rax
mov    %r11,(%rsp)
mov    %r10,0x8(%rsp)
mov    %rax,0x10(%rsp)
call   1030 <snprintf@plt>
jmp    11c7 <pqos_cmt_caption_build+0xb7>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
lea    0xe76(%rip),%rdx
lea    0xeb6(%rip),%rcx
lea    0xe84(%rip),%r8
lea    0xe82(%rip),%r9
lea    0xe82(%rip),%r11
lea    0xe82(%rip),%r10
lea    0xe8d(%rip),%rax
mov    %r11,(%rsp)
mov    %r10,0x8(%rsp)
mov    %rax,0x10(%rsp)
call   1030 <snprintf@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<pqos_cmt_caption_build>:
push   %rbx
test   %edi,%edi
lea    0xefe(%rip),%rax
lea    0xf26(%rip),%rcx
cmove  %rax,%rcx
sub    $0x8,%rsp
lea    0xf11(%rip),%r10
lea    0xef8(%rip),%r11
lea    0xeea(%rip),%rbx
lea    0xebb(%rip),%rax
lea    0xed0(%rip),%r8
lea    0xece(%rip),%r9
mov    %rsi,%rdi
mov    %edx,%esi
mov    %rax,%rdx
push   %r10
push   %r11
push   %rbx
call   1030 <snprintf@plt>
add    $0x20,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [24 x i8] c"%6s%15s%11s%11s%21s%11s\00"
@.str.1 = [4 x i8] c"PID\00"
@.str.2 = [5 x i8] c"PROC\00"
@.str.3 = [7 x i8] c"RMA(K)\00"
@.str.4 = [7 x i8] c"LMA(K)\00"
@.str.5 = [18 x i8] c"LLC.OCCUPANCY(MB)\00"
@.str.6 = [6 x i8] c"CPU%%\00"
@.str.7 = [4 x i8] c"LWP\00"
define void @pqos_cmt_caption_build(i32 %0, i8* %1, i32 %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i32
store i32 %0, i32* %4
store i8* %1, i8** %5
store i32 %2, i32* %6
%7 = load i32, i32* %4
%8 = icmp eq i32 %7, 0
br i1 %8, label %9, label %13
9: ; preds = %3
%10 = load i8*, i8** %5
%11 = load i32, i32* %6
%12 = call i32 @snprintf(i8* %10, i32 %11, i8* getelementptr inbounds ([24 x i8], [24 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 ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0))
br label %17
13: ; preds = %3
%14 = load i8*, i8** %5
%15 = load i32, i32* %6
%16 = call i32 @snprintf(i8* %14, i32 %15, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0))
br label %17
17: ; preds = %13, %9
ret void
}

LLVM IR (-O2):
@.str = [24 x i8] c"%6s%15s%11s%11s%21s%11s\00"
@.str.1 = [4 x i8] c"PID\00"
@.str.2 = [5 x i8] c"PROC\00"
@.str.3 = [7 x i8] c"RMA(K)\00"
@.str.4 = [7 x i8] c"LMA(K)\00"
@.str.5 = [18 x i8] c"LLC.OCCUPANCY(MB)\00"
@.str.6 = [6 x i8] c"CPU%%\00"
@.str.7 = [4 x i8] c"LWP\00"
define void @pqos_cmt_caption_build(i32 %0, i8* %1, i32 %2) {
%4 = icmp eq i32 %0, 0
%5 = select i1 %4, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0)
%6 = tail call i32 @snprintf(i8* %1, i32 %2, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i8* %5, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0))
ret void
}