#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*/ fprintf(int /*<<< orphan*/, char *, char *);
int getpid();
int /*<<< orphan*/ sprintf(char *, char *, int);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ system(char *);
void status(char *p) {
  char buf[1000];
  if (p)
    fprintf(stderr, "%s ", p);
  sprintf(buf, "ps h -otty,pid,pgid,sid,comm %d", getpid());
  system(buf);
}


x86 assembly (clang, -O0):
<status>:
push   %rbp
mov    %rsp,%rbp
sub    $0x400,%rsp
mov    %rdi,-0x8(%rbp)
cmpq   $0x0,-0x8(%rbp)
je     1173 <status+0x33>
mov    0x2e7f(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rdx
lea    0xe92(%rip),%rsi
call   1050 <fprintf@plt>
lea    -0x3f0(%rbp),%rax
mov    %rax,-0x3f8(%rbp)
mov    $0x0,%al
call   1030 <getpid@plt>
mov    -0x3f8(%rbp),%rdi
mov    %eax,%edx
lea    0xe6c(%rip),%rsi
call   1060 <sprintf@plt>
lea    -0x3f0(%rbp),%rdi
call   1040 <system@plt>
add    $0x400,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<status>:
push   %rbx
sub    $0x3f0,%rsp
test   %rdi,%rdi
je     1165 <status+0x25>
mov    %rdi,%rdx
mov    0x2e89(%rip),%rax
mov    (%rax),%edi
lea    0xea0(%rip),%rsi
call   1050 <fprintf@plt>
xor    %eax,%eax
call   1030 <getpid@plt>
lea    0xe91(%rip),%rsi
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    %eax,%edx
call   1060 <sprintf@plt>
mov    %rbx,%rdi
call   1040 <system@plt>
add    $0x3f0,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [4 x i8] c"%s \00"
@.str.1 = [32 x i8] c"ps h -otty,pid,pgid,sid,comm %d\00"
define void @status(i8* %0) {
%2 = alloca i8*
%3 = alloca [1000 x i8]
store i8* %0, i8** %2
%4 = load i8*, i8** %2
%5 = icmp ne i8* %4, null
br i1 %5, label %6, label %10
6: ; preds = %1
%7 = load i32, i32* @stderr
%8 = load i8*, i8** %2
%9 = call i32 @fprintf(i32 %7, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %8)
br label %10
10: ; preds = %6, %1
%11 = getelementptr inbounds [1000 x i8], [1000 x i8]* %3, i64 0, i64 0
%12 = call i32 (...) @getpid()
%13 = call i32 @sprintf(i8* %11, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0), i32 %12)
%14 = getelementptr inbounds [1000 x i8], [1000 x i8]* %3, i64 0, i64 0
%15 = call i32 @system(i8* %14)
ret void
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [4 x i8] c"%s \00"
@.str.1 = [32 x i8] c"ps h -otty,pid,pgid,sid,comm %d\00"
define void @status(i8* %0) {
%2 = alloca [1000 x i8]
%3 = getelementptr inbounds [1000 x i8], [1000 x i8]* %2, i64 0, i64 0
%4 = icmp eq i8* %0, null
br i1 %4, label %8, label %5
5: ; preds = %1
%6 = load i32, i32* @stderr
%7 = tail call i32 @fprintf(i32 %6, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %0)
br label %8
8: ; preds = %5, %1
%9 = tail call i32 (...) @getpid()
%10 = call i32 @sprintf(i8* %3, i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0), i32 %9)
%11 = call i32 @system(i8* %3)
ret void
}