#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*/ memset(char *, int /*<<< orphan*/, int);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ run_command(char *, char *);
int /*<<< orphan*/ sprintf(char *, char *, int);
int getcommand(int pid, char *result) {
  char command[81];
  memset(command, 0, 81);
  sprintf(command, "ps -p %d -o command=", pid);
  run_command(command, result);
  printf("result : %s", result);
}


x86 assembly (clang, -O0):
<getcommand>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x70(%rbp),%rdi
xor    %esi,%esi
mov    $0x51,%edx
call   1040 <memset@plt>
lea    -0x70(%rbp),%rdi
mov    -0x8(%rbp),%edx
lea    0xe93(%rip),%rsi
call   1060 <sprintf@plt>
lea    -0x70(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1050 <run_command@plt>
mov    -0x10(%rbp),%rsi
lea    0xe8b(%rip),%rdi
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getcommand>:
push   %rbp
push   %r14
push   %rbx
sub    $0x60,%rsp
mov    %rsi,%rbx
mov    %edi,%ebp
mov    %rsp,%r14
mov    %r14,%rdi
xor    %esi,%esi
mov    $0x51,%edx
call   1040 <memset@plt>
lea    0xe9a(%rip),%rsi
mov    %r14,%rdi
mov    %ebp,%edx
call   1060 <sprintf@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1050 <run_command@plt>
lea    0xe93(%rip),%rdi
mov    %rbx,%rsi
call   1030 <printf@plt>
add    $0x60,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [21 x i8] c"ps -p %d -o command=\00"
@.str.1 = [12 x i8] c"result : %s\00"
define i32 @getcommand(i32 %0, i8* %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8*
%6 = alloca [81 x i8]
store i32 %0, i32* %4
store i8* %1, i8** %5
%7 = getelementptr inbounds [81 x i8], [81 x i8]* %6, i64 0, i64 0
%8 = call i32 @memset(i8* %7, i32 0, i32 81)
%9 = getelementptr inbounds [81 x i8], [81 x i8]* %6, i64 0, i64 0
%10 = load i32, i32* %4
%11 = call i32 @sprintf(i8* %9, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i32 %10)
%12 = getelementptr inbounds [81 x i8], [81 x i8]* %6, i64 0, i64 0
%13 = load i8*, i8** %5
%14 = call i32 @run_command(i8* %12, i8* %13)
%15 = load i8*, i8** %5
%16 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i8* %15)
%17 = load i32, i32* %3
ret i32 %17
}

LLVM IR (-O2):
@.str = [21 x i8] c"ps -p %d -o command=\00"
@.str.1 = [12 x i8] c"result : %s\00"
define i32 @getcommand(i32 %0, i8* %1) {
%3 = alloca [81 x i8]
%4 = getelementptr inbounds [81 x i8], [81 x i8]* %3, i64 0, i64 0
%5 = call i32 @memset(i8* %4, i32 0, i32 81)
%6 = call i32 @sprintf(i8* %4, i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i32 %0)
%7 = call i32 @run_command(i8* %4, i8* %1)
%8 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i8* %1)
ret i32 undef
}