#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*/ SIGKILL;
scalar_t__ execvp(char *, char **);
scalar_t__ fork();
int /*<<< orphan*/ kill(scalar_t__, int /*<<< orphan*/);
pid_t runBackground(char **args) {
  pid_t pid;
  pid = fork();
  if (pid < 0) {
    kill(pid, SIGKILL);
    return 0;
  } else if (pid == 0) {
    if (execvp(*args, args) < 0)
      return 0;
  }
  return pid;
}


x86 assembly (clang, -O0):
<runBackground>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    $0x0,%al
call   1050 <fork@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jge    1171 <runBackground+0x41>
mov    -0x18(%rbp),%rdi
mov    0x2e83(%rip),%rax
mov    (%rax),%esi
call   1030 <kill@plt>
movq   $0x0,-0x8(%rbp)
jmp    11b5 <runBackground+0x85>
cmpq   $0x0,-0x18(%rbp)
jne    11a8 <runBackground+0x78>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
mov    -0x10(%rbp),%rsi
call   1040 <execvp@plt>
cmp    $0x0,%rax
jge    11a3 <runBackground+0x73>
movq   $0x0,-0x8(%rbp)
jmp    11b5 <runBackground+0x85>
jmp    11a8 <runBackground+0x78>
jmp    11ad <runBackground+0x7d>
mov    -0x18(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<runBackground>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
xor    %eax,%eax
call   1050 <fork@plt>
mov    %rax,%rbx
test   %rax,%rax
js     115a <runBackground+0x2a>
jne    116d <runBackground+0x3d>
mov    (%r14),%rdi
mov    %r14,%rsi
call   1040 <execvp@plt>
test   %rax,%rax
jns    116d <runBackground+0x3d>
jmp    116b <runBackground+0x3b>
mov    0x2e7f(%rip),%rax
mov    (%rax),%esi
mov    %rbx,%rdi
call   1030 <kill@plt>
xor    %ebx,%ebx
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@SIGKILL = global i32 0
define i64 @runBackground(i8** %0) {
%2 = alloca i64
%3 = alloca i8**
%4 = alloca i64
store i8** %0, i8*** %3
%5 = call i64 (...) @fork()
store i64 %5, i64* %4
%6 = load i64, i64* %4
%7 = icmp slt i64 %6, 0
br i1 %7, label %8, label %12
8: ; preds = %1
%9 = load i64, i64* %4
%10 = load i32, i32* @SIGKILL
%11 = call i32 @kill(i64 %9, i32 %10)
store i64 0, i64* %2
br label %26
12: ; preds = %1
%13 = load i64, i64* %4
%14 = icmp eq i64 %13, 0
br i1 %14, label %15, label %23
15: ; preds = %12
%16 = load i8**, i8*** %3
%17 = load i8*, i8** %16
%18 = load i8**, i8*** %3
%19 = call i64 @execvp(i8* %17, i8** %18)
%20 = icmp slt i64 %19, 0
br i1 %20, label %21, label %22
21: ; preds = %15
store i64 0, i64* %2
br label %26
22: ; preds = %15
br label %23
23: ; preds = %22, %12
br label %24
24: ; preds = %23
%25 = load i64, i64* %4
store i64 %25, i64* %2
br label %26
26: ; preds = %24, %21, %8
%27 = load i64, i64* %2
ret i64 %27
}

LLVM IR (-O2):
@SIGKILL = global i32 0
define i64 @runBackground(i8** %0) {
%2 = tail call i64 (...) @fork()
%3 = icmp slt i64 %2, 0
br i1 %3, label %4, label %7
4: ; preds = %1
%5 = load i32, i32* @SIGKILL
%6 = tail call i32 @kill(i64 %2, i32 %5)
br label %14
7: ; preds = %1
%8 = icmp eq i64 %2, 0
br i1 %8, label %9, label %13
9: ; preds = %7
%10 = load i8*, i8** %0
%11 = tail call i64 @execvp(i8* %10, i8** %0)
%12 = icmp slt i64 %11, 0
br i1 %12, label %14, label %13
13: ; preds = %7, %9
br label %14
14: ; preds = %9, %13, %4
%15 = phi i64 [ 0, %4 ], [ %2, %13 ], [ 0, %9 ]
ret i64 %15
}