#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*/ printf(char *, char *, ...);
int /*<<< orphan*/ runcmd(char *, char *);
int main(int argc, char *argv[]) {
  char *command = NULL;
  char cmdOutput[255];
  if (argc > 1) {
    command = argv[1];
    runcmd(command, cmdOutput);
    printf("The output of %s is: %s\n", command, cmdOutput);
  } else {
    command = "whoami";
    runcmd(command, cmdOutput);
    printf("The output of whoami is: %s\n", cmdOutput);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x120,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
cmpl   $0x1,-0x8(%rbp)
jle    1185 <main+0x65>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
lea    -0x120(%rbp),%rsi
call   1030 <runcmd@plt>
mov    -0x18(%rbp),%rsi
lea    -0x120(%rbp),%rdx
lea    0xe87(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    11b5 <main+0x95>
lea    0xe8d(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
lea    -0x120(%rbp),%rsi
call   1030 <runcmd@plt>
lea    -0x120(%rbp),%rsi
lea    0xe72(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x120,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x108,%rsp
cmp    $0x2,%edi
jl     1157 <main+0x37>
mov    0x8(%rsi),%rbx
mov    %rsp,%r14
mov    %rbx,%rdi
mov    %r14,%rsi
call   1030 <runcmd@plt>
lea    0xeb8(%rip),%rdi
mov    %rbx,%rsi
mov    %r14,%rdx
xor    %eax,%eax
call   1040 <printf@plt>
jmp    117a <main+0x5a>
lea    0xebb(%rip),%rdi
mov    %rsp,%rbx
mov    %rbx,%rsi
call   1030 <runcmd@plt>
lea    0xeb0(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x108,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [25 x i8] c"The output of %s is: %s\0A\00"
@.str.1 = [7 x i8] c"whoami\00"
@.str.2 = [29 x i8] c"The output of whoami is: %s\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca [255 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i8* null, i8** %6
%8 = load i32, i32* %4
%9 = icmp sgt i32 %8, 1
br i1 %9, label %10, label %20
10: ; preds = %2
%11 = load i8**, i8*** %5
%12 = getelementptr inbounds i8*, i8** %11, i64 1
%13 = load i8*, i8** %12
store i8* %13, i8** %6
%14 = load i8*, i8** %6
%15 = getelementptr inbounds [255 x i8], [255 x i8]* %7, i64 0, i64 0
%16 = call i32 @runcmd(i8* %14, i8* %15)
%17 = load i8*, i8** %6
%18 = getelementptr inbounds [255 x i8], [255 x i8]* %7, i64 0, i64 0
%19 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i8* %17, i8* %18)
br label %26
20: ; preds = %2
store i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i8** %6
%21 = load i8*, i8** %6
%22 = getelementptr inbounds [255 x i8], [255 x i8]* %7, i64 0, i64 0
%23 = call i32 @runcmd(i8* %21, i8* %22)
%24 = getelementptr inbounds [255 x i8], [255 x i8]* %7, i64 0, i64 0
%25 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0), i8* %24)
br label %26
26: ; preds = %20, %10
ret i32 0
}

LLVM IR (-O2):
@.str = [25 x i8] c"The output of %s is: %s\0A\00"
@.str.1 = [7 x i8] c"whoami\00"
@.str.2 = [29 x i8] c"The output of whoami is: %s\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [255 x i8]
%4 = getelementptr inbounds [255 x i8], [255 x i8]* %3, i64 0, i64 0
%5 = icmp sgt i32 %0, 1
br i1 %5, label %6, label %11
6: ; preds = %2
%7 = getelementptr inbounds i8*, i8** %1, i64 1
%8 = load i8*, i8** %7
%9 = call i32 @runcmd(i8* %8, i8* %4)
%10 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i8* %8, i8* %4)
br label %14
11: ; preds = %2
%12 = call i32 @runcmd(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i8* %4)
%13 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0), i8* %4)
br label %14
14: ; preds = %11, %6
ret i32 0
}