#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 scalar_t__ pid_t;
typedef int /*<<< orphan*/ cmd;

/* Variables and functions */
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ snprintf(char *, int, char *, long);
int system(char *);
void show_pstree(pid_t p) {
  int ret;
  char cmd[1024];
  snprintf(cmd, sizeof(cmd), "echo; echo; pstree -G -c -p %ld; echo; echo",
           (long)p);
  cmd[sizeof(cmd) - 1] = '\0';
  ret = system(cmd);
  if (ret < 0) {
    perror("system");
    exit(104);
  }
}


x86 assembly (clang, -O0):
<show_pstree>:
push   %rbp
mov    %rsp,%rbp
sub    $0x410,%rsp
mov    %rdi,-0x8(%rbp)
lea    -0x410(%rbp),%rdi
mov    -0x8(%rbp),%rcx
mov    $0x400,%esi
lea    0xe9a(%rip),%rdx
call   1040 <snprintf@plt>
movb   $0x0,-0x11(%rbp)
lea    -0x410(%rbp),%rdi
call   1030 <system@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
jge    119e <show_pstree+0x5e>
lea    0xe9d(%rip),%rdi
call   1050 <perror@plt>
mov    $0x68,%edi
call   1060 <exit@plt>
add    $0x410,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<show_pstree>:
push   %rbx
sub    $0x400,%rsp
mov    %rdi,%rcx
lea    0xeae(%rip),%rdx
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    $0x400,%esi
call   1040 <snprintf@plt>
movb   $0x0,0x3ff(%rsp)
mov    %rbx,%rdi
call   1030 <system@plt>
test   %eax,%eax
js     117f <show_pstree+0x3f>
add    $0x400,%rsp
pop    %rbx
ret
lea    0xea6(%rip),%rdi
call   1050 <perror@plt>
mov    $0x68,%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@.str = [44 x i8] c"echo; echo; pstree -G -c -p %ld; echo; echo\00"
@.str.1 = [7 x i8] c"system\00"
define void @show_pstree(i64 %0) {
%2 = alloca i64
%3 = alloca i32
%4 = alloca [1024 x i8]
store i64 %0, i64* %2
%5 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 0
%6 = load i64, i64* %2
%7 = call i32 @snprintf(i8* %5, i32 1024, i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str, i64 0, i64 0), i64 %6)
%8 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 1023
store i8 0, i8* %8
%9 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 0
%10 = call i32 @system(i8* %9)
store i32 %10, i32* %3
%11 = load i32, i32* %3
%12 = icmp slt i32 %11, 0
br i1 %12, label %13, label %16
13: ; preds = %1
%14 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%15 = call i32 @exit(i32 104)
unreachable
16: ; preds = %1
ret void
}

LLVM IR (-O2):
@.str = [44 x i8] c"echo; echo; pstree -G -c -p %ld; echo; echo\00"
@.str.1 = [7 x i8] c"system\00"
define void @show_pstree(i64 %0) {
%2 = alloca [1024 x i8]
%3 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%4 = call i32 @snprintf(i8* %3, i32 1024, i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str, i64 0, i64 0), i64 %0)
%5 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 1023
store i8 0, i8* %5
%6 = call i32 @system(i8* %3)
%7 = icmp slt i32 %6, 0
br i1 %7, label %8, label %11
8: ; preds = %1
%9 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%10 = call i32 @exit(i32 104)
unreachable
11: ; preds = %1
ret void
}