#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 *, ...);
scalar_t__ spawn_init_proc(char *, char *, char *, char **);
int main(int argc, char **argv) {
  if (argc < 4) {
    printf("usage: %s <root> <pidfile> <entry point> [<argument>...]\n",
           argv[0]);
    return 1;
  }
  char *root = argv[1];
  char *pid_path = argv[2];
  char *entry_point = argv[3];
  char **entry_point_argv = NULL;
  if (argc >= 5) {
    entry_point_argv = &argv[4];
  }
  if (spawn_init_proc(root, pid_path, entry_point, entry_point_argv) < 0) {
    printf("spawn_init_proc() failed\n");
    return 1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x4,-0x8(%rbp)
jge    1161 <main+0x41>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xeb2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    11e3 <main+0xc3>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rax
mov    %rax,-0x28(%rbp)
movq   $0x0,-0x30(%rbp)
cmpl   $0x5,-0x8(%rbp)
jl     11a3 <main+0x83>
mov    -0x10(%rbp),%rax
add    $0x20,%rax
mov    %rax,-0x30(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    -0x28(%rbp),%rdx
mov    -0x30(%rbp),%rcx
call   1040 <spawn_init_proc@plt>
cmp    $0x0,%rax
jge    11dc <main+0xbc>
lea    0xe71(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    11e3 <main+0xc3>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
cmp    $0x3,%edi
jg     1149 <main+0x19>
mov    (%rsi),%rsi
lea    0xec0(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    1183 <main+0x53>
mov    0x8(%rsi),%rax
mov    0x10(%rsi),%r8
mov    0x18(%rsi),%rdx
add    $0x20,%rsi
xor    %ebx,%ebx
cmp    $0x4,%edi
mov    $0x0,%ecx
cmovne %rsi,%rcx
mov    %rax,%rdi
mov    %r8,%rsi
call   1050 <spawn_init_proc@plt>
test   %rax,%rax
jns    1188 <main+0x58>
lea    0xebc(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%ebx
mov    %ebx,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [58 x i8] c"usage: %s <root> <pidfile> <entry point> [<argument>...]\0A\00"
@.str.1 = [26 x i8] c"spawn_init_proc() failed\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i8**
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%10 = load i32, i32* %4
%11 = icmp slt i32 %10, 4
br i1 %11, label %12, label %17
12: ; preds = %2
%13 = load i8**, i8*** %5
%14 = getelementptr inbounds i8*, i8** %13, i64 0
%15 = load i8*, i8** %14
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str, i64 0, i64 0), i8* %15)
store i32 1, i32* %3
br label %42
17: ; preds = %2
%18 = load i8**, i8*** %5
%19 = getelementptr inbounds i8*, i8** %18, i64 1
%20 = load i8*, i8** %19
store i8* %20, i8** %6
%21 = load i8**, i8*** %5
%22 = getelementptr inbounds i8*, i8** %21, i64 2
%23 = load i8*, i8** %22
store i8* %23, i8** %7
%24 = load i8**, i8*** %5
%25 = getelementptr inbounds i8*, i8** %24, i64 3
%26 = load i8*, i8** %25
store i8* %26, i8** %8
store i8** null, i8*** %9
%27 = load i32, i32* %4
%28 = icmp sge i32 %27, 5
br i1 %28, label %29, label %32
29: ; preds = %17
%30 = load i8**, i8*** %5
%31 = getelementptr inbounds i8*, i8** %30, i64 4
store i8** %31, i8*** %9
br label %32
32: ; preds = %29, %17
%33 = load i8*, i8** %6
%34 = load i8*, i8** %7
%35 = load i8*, i8** %8
%36 = load i8**, i8*** %9
%37 = call i64 @spawn_init_proc(i8* %33, i8* %34, i8* %35, i8** %36)
%38 = icmp slt i64 %37, 0
br i1 %38, label %39, label %41
39: ; preds = %32
%40 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0))
store i32 1, i32* %3
br label %42
41: ; preds = %32
store i32 0, i32* %3
br label %42
42: ; preds = %41, %39, %12
%43 = load i32, i32* %3
ret i32 %43
}

LLVM IR (-O2):
@.str = [58 x i8] c"usage: %s <root> <pidfile> <entry point> [<argument>...]\0A\00"
@str = [25 x i8] c"spawn_init_proc() failed\00"
define i32 @main(i32 %0, i8** %1) {
%3 = icmp slt i32 %0, 4
br i1 %3, label %4, label %7
4: ; preds = %2
%5 = load i8*, i8** %1
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([58 x i8], [58 x i8]* @.str, i64 0, i64 0), i8* %5)
br label %21
7: ; preds = %2
%8 = getelementptr inbounds i8*, i8** %1, i64 1
%9 = load i8*, i8** %8
%10 = getelementptr inbounds i8*, i8** %1, i64 2
%11 = load i8*, i8** %10
%12 = getelementptr inbounds i8*, i8** %1, i64 3
%13 = load i8*, i8** %12
%14 = icmp eq i32 %0, 4
%15 = getelementptr inbounds i8*, i8** %1, i64 4
%16 = select i1 %14, i8** null, i8** %15
%17 = tail call i64 @spawn_init_proc(i8* %9, i8* %11, i8* %13, i8** %16)
%18 = icmp slt i64 %17, 0
br i1 %18, label %19, label %21
19: ; preds = %7
%20 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @str, i64 0, i64 0))
br label %21
21: ; preds = %19, %7, %4
%22 = phi i32 [ 1, %4 ], [ 1, %19 ], [ 0, %7 ]
ret i32 %22
}