#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;

/* Variables and functions */
int /*<<< orphan*/ execl(char *, char *, char *, char const *,
                         int /*<<< orphan*/ *);
int /*<<< orphan*/ exit(int);
scalar_t__ fork();
int /*<<< orphan*/ log_err(char *);
void run_command(const char *command) {
  pid_t pID = fork();
  if (pID == 0) {
    execl("/bin/sh", "/bin/sh", "-c", command, NULL);
    exit(-1);
  } else if (pID < 0) {
    log_err("Failed to fork process!\n");
  }
}


x86 assembly (clang, -O0):
<run_command>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    $0x0,%al
call   1060 <fork@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    118b <run_command+0x4b>
mov    -0x8(%rbp),%rcx
lea    0xe93(%rip),%rsi
lea    0xe94(%rip),%rdx
xor    %eax,%eax
mov    %eax,%r8d
mov    %rsi,%rdi
call   1040 <execl@plt>
mov    $0xffffffff,%edi
call   1030 <exit@plt>
cmpq   $0x0,-0x10(%rbp)
jge    11a2 <run_command+0x62>
lea    0xe6e(%rip),%rdi
call   1050 <log_err@plt>
jmp    11a7 <run_command+0x67>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<run_command>:
push   %rbx
mov    %rdi,%rbx
xor    %eax,%eax
call   1060 <fork@plt>
test   %rax,%rax
je     1161 <run_command+0x21>
js     1154 <run_command+0x14>
pop    %rbx
ret
lea    0xeb0(%rip),%rdi
pop    %rbx
jmp    1050 <log_err@plt>
lea    0xe98(%rip),%rdi
lea    0xe99(%rip),%rdx
mov    %rdi,%rsi
mov    %rbx,%rcx
xor    %r8d,%r8d
call   1040 <execl@plt>
mov    $0xffffffff,%edi
call   1030 <exit@plt>

LLVM IR (-O0):
@.str = [8 x i8] c"/bin/sh\00"
@.str.1 = [3 x i8] c"-c\00"
@.str.2 = [25 x i8] c"Failed to fork process!\0A\00"
define void @run_command(i8* %0) {
%2 = alloca i8*
%3 = alloca i64
store i8* %0, i8** %2
%4 = call i64 (...) @fork()
store i64 %4, i64* %3
%5 = load i64, i64* %3
%6 = icmp eq i64 %5, 0
br i1 %6, label %7, label %11
7: ; preds = %1
%8 = load i8*, i8** %2
%9 = call i32 @execl(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %8, i32* null)
%10 = call i32 @exit(i32 -1)
unreachable
11: ; preds = %1
%12 = load i64, i64* %3
%13 = icmp slt i64 %12, 0
br i1 %13, label %14, label %16
14: ; preds = %11
%15 = call i32 @log_err(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0))
br label %16
16: ; preds = %14, %11
br label %17
17: ; preds = %16
ret void
}

LLVM IR (-O2):
@.str = [8 x i8] c"/bin/sh\00"
@.str.1 = [3 x i8] c"-c\00"
@.str.2 = [25 x i8] c"Failed to fork process!\0A\00"
define void @run_command(i8* %0) {
%2 = tail call i64 (...) @fork()
%3 = icmp eq i64 %2, 0
br i1 %3, label %4, label %7
4: ; preds = %1
%5 = tail call i32 @execl(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %0, i32* null)
%6 = tail call i32 @exit(i32 -1)
unreachable
7: ; preds = %1
%8 = icmp slt i64 %2, 0
br i1 %8, label %9, label %11
9: ; preds = %7
%10 = tail call i32 @log_err(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0))
br label %11
11: ; preds = %7, %9
ret void
}