#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*/ debug(int, char *, ...);
int /*<<< orphan*/ errno;
int /*<<< orphan*/ error(char *, int /*<<< orphan*/);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
scalar_t__ fork();
int /*<<< orphan*/ strerror(int /*<<< orphan*/);
int /*<<< orphan*/ system(char *);
void run(char *cmd) {
  pid_t pid;
  debug(1, "executing command '%s'", cmd);
  if ((pid = fork()) == 0) {
    system(cmd);
    exit(0);
  } else if (pid < 0)
    error("Cannot fork: %s", strerror(errno));
  else
    debug(1, "start process %u", (unsigned int)pid);
}


x86 assembly (clang, -O0):
<run>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdx
mov    $0x1,%edi
lea    0xe84(%rip),%rsi
mov    $0x0,%al
call   1030 <debug@plt>
mov    $0x0,%al
call   1080 <fork@plt>
mov    %rax,-0x10(%rbp)
cmp    $0x0,%rax
jne    11a8 <run+0x48>
mov    -0x8(%rbp),%rdi
call   1040 <system@plt>
xor    %edi,%edi
call   1060 <exit@plt>
cmpq   $0x0,-0x10(%rbp)
jge    11d4 <run+0x74>
mov    0x2e26(%rip),%rax
mov    (%rax),%edi
call   1070 <strerror@plt>
mov    %eax,%esi
lea    0xe4d(%rip),%rdi
call   1050 <error@plt>
jmp    11ed <run+0x8d>
mov    -0x10(%rbp),%rax
mov    %eax,%edx
mov    $0x1,%edi
lea    0xe41(%rip),%rsi
mov    $0x0,%al
call   1030 <debug@plt>
jmp    11f2 <run+0x92>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<run>:
push   %rbx
mov    %rdi,%rbx
lea    0xe95(%rip),%rsi
mov    $0x1,%edi
mov    %rbx,%rdx
xor    %eax,%eax
call   1030 <debug@plt>
xor    %eax,%eax
call   1080 <fork@plt>
test   %rax,%rax
je     11bb <run+0x5b>
js     119e <run+0x3e>
lea    0xe98(%rip),%rsi
mov    $0x1,%edi
mov    %eax,%edx
xor    %eax,%eax
pop    %rbx
jmp    1030 <debug@plt>
mov    0x2e3b(%rip),%rax
mov    (%rax),%edi
call   1070 <strerror@plt>
lea    0xe64(%rip),%rdi
mov    %eax,%esi
pop    %rbx
jmp    1050 <error@plt>
mov    %rbx,%rdi
call   1040 <system@plt>
xor    %edi,%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@.str = [23 x i8] c"executing command '%s'\00"
@.str.1 = [16 x i8] c"Cannot fork: %s\00"
@errno = global i32 0
@.str.2 = [17 x i8] c"start process %u\00"
define void @run(i8* %0) {
%2 = alloca i8*
%3 = alloca i64
store i8* %0, i8** %2
%4 = load i8*, i8** %2
%5 = call i32 (i32, i8*, ...) @debug(i32 1, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i8* %4)
%6 = call i64 (...) @fork()
store i64 %6, i64* %3
%7 = icmp eq i64 %6, 0
br i1 %7, label %8, label %12
8: ; preds = %1
%9 = load i8*, i8** %2
%10 = call i32 @system(i8* %9)
%11 = call i32 @exit(i32 0)
unreachable
12: ; preds = %1
%13 = load i64, i64* %3
%14 = icmp slt i64 %13, 0
br i1 %14, label %15, label %19
15: ; preds = %12
%16 = load i32, i32* @errno
%17 = call i32 @strerror(i32 %16)
%18 = call i32 @error(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i32 %17)
br label %23
19: ; preds = %12
%20 = load i64, i64* %3
%21 = trunc i64 %20 to i32
%22 = call i32 (i32, i8*, ...) @debug(i32 1, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0), i32 %21)
br label %23
23: ; preds = %19, %15
br label %24
24: ; preds = %23
ret void
}

LLVM IR (-O2):
@.str = [23 x i8] c"executing command '%s'\00"
@.str.1 = [16 x i8] c"Cannot fork: %s\00"
@errno = global i32 0
@.str.2 = [17 x i8] c"start process %u\00"
define void @run(i8* %0) {
%2 = tail call i32 (i32, i8*, ...) @debug(i32 1, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i8* %0)
%3 = tail call i64 (...) @fork()
%4 = icmp eq i64 %3, 0
br i1 %4, label %5, label %8
5: ; preds = %1
%6 = tail call i32 @system(i8* %0)
%7 = tail call i32 @exit(i32 0)
unreachable
8: ; preds = %1
%9 = icmp slt i64 %3, 0
br i1 %9, label %10, label %14
10: ; preds = %8
%11 = load i32, i32* @errno
%12 = tail call i32 @strerror(i32 %11)
%13 = tail call i32 @error(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i32 %12)
br label %17
14: ; preds = %8
%15 = trunc i64 %3 to i32
%16 = tail call i32 (i32, i8*, ...) @debug(i32 1, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0), i32 %15)
br label %17
17: ; preds = %10, %14
ret void
}