#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 */
scalar_t__ execve(char *, char **, char **);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ printf(char *, char *);
int setpgid(int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ stderr;
void run_the_job(char *filename, char *argv[], char *env[]) {
  int ret = setpgid(0, 0);
  if (ret < 0) {
    fprintf(stderr, "Failed to set group process id\n");
    exit(-1);
  }
  if (execve(argv[0], argv, env) < 0) {
    printf("%s: Command not found.\n", argv[0]);
    exit(0);
  }
}


x86 assembly (clang, -O0):
<run_the_job>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
xor    %esi,%esi
mov    %esi,%edi
call   1060 <setpgid@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jge    1199 <run_the_job+0x49>
mov    0x2e5f(%rip),%rax
mov    (%rax),%edi
lea    0xe76(%rip),%rsi
call   1050 <fprintf@plt>
mov    $0xffffffff,%edi
call   1070 <exit@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
call   1040 <execve@plt>
cmp    $0x0,%rax
jge    11d1 <run_the_job+0x81>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xe5b(%rip),%rdi
call   1030 <printf@plt>
xor    %edi,%edi
call   1070 <exit@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<run_the_job>:
push   %r14
push   %rbx
push   %rax
mov    %rdx,%r14
mov    %rsi,%rbx
xor    %edi,%edi
xor    %esi,%esi
call   1060 <setpgid@plt>
test   %eax,%eax
js     1182 <run_the_job+0x32>
mov    (%rbx),%rdi
mov    %rbx,%rsi
mov    %r14,%rdx
call   1040 <execve@plt>
test   %rax,%rax
js     11a1 <run_the_job+0x51>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret
mov    0x2e57(%rip),%rax
mov    (%rax),%edi
lea    0xe6e(%rip),%rsi
call   1050 <fprintf@plt>
mov    $0xffffffff,%edi
call   1070 <exit@plt>
mov    (%rbx),%rsi
lea    0xe75(%rip),%rdi
call   1030 <printf@plt>
xor    %edi,%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [32 x i8] c"Failed to set group process id\0A\00"
@.str.1 = [24 x i8] c"%s: Command not found.\0A\00"
define void @run_the_job(i8* %0, i8** %1, i8** %2) {
%4 = alloca i8*
%5 = alloca i8**
%6 = alloca i8**
%7 = alloca i32
store i8* %0, i8** %4
store i8** %1, i8*** %5
store i8** %2, i8*** %6
%8 = call i32 @setpgid(i32 0, i32 0)
store i32 %8, i32* %7
%9 = load i32, i32* %7
%10 = icmp slt i32 %9, 0
br i1 %10, label %11, label %15
11: ; preds = %3
%12 = load i32, i32* @stderr
%13 = call i32 @fprintf(i32 %12, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0))
%14 = call i32 @exit(i32 -1)
unreachable
15: ; preds = %3
%16 = load i8**, i8*** %5
%17 = getelementptr inbounds i8*, i8** %16, i64 0
%18 = load i8*, i8** %17
%19 = load i8**, i8*** %5
%20 = load i8**, i8*** %6
%21 = call i64 @execve(i8* %18, i8** %19, i8** %20)
%22 = icmp slt i64 %21, 0
br i1 %22, label %23, label %29
23: ; preds = %15
%24 = load i8**, i8*** %5
%25 = getelementptr inbounds i8*, i8** %24, i64 0
%26 = load i8*, i8** %25
%27 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0), i8* %26)
%28 = call i32 @exit(i32 0)
unreachable
29: ; preds = %15
ret void
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [32 x i8] c"Failed to set group process id\0A\00"
@.str.1 = [24 x i8] c"%s: Command not found.\0A\00"
define void @run_the_job(i8* nocapture readnone %0, i8** %1, i8** %2) {
%4 = tail call i32 @setpgid(i32 0, i32 0)
%5 = icmp slt i32 %4, 0
br i1 %5, label %6, label %10
6: ; preds = %3
%7 = load i32, i32* @stderr
%8 = tail call i32 @fprintf(i32 %7, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0))
%9 = tail call i32 @exit(i32 -1)
unreachable
10: ; preds = %3
%11 = load i8*, i8** %1
%12 = tail call i64 @execve(i8* %11, i8** %1, i8** %2)
%13 = icmp slt i64 %12, 0
br i1 %13, label %14, label %18
14: ; preds = %10
%15 = load i8*, i8** %1
%16 = tail call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0), i8* %15)
%17 = tail call i32 @exit(i32 0)
unreachable
18: ; preds = %10
ret void
}