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

/* Variables and functions */
int /*<<< orphan*/ EXIT_FAILURE;
int /*<<< orphan*/ WEXITSTATUS(int);
int /*<<< orphan*/ WIFEXITED(int);
int /*<<< orphan*/ execve(char *, char *const *, char *const *);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int fork();
int vfork();
int /*<<< orphan*/ wait(int *);
int main(int argc, char **ignored) {
  char *const argv[] = {"true", NULL};
  char *const envp[] = {NULL};
  pid_t pid;
  int status;
  pid = (argc <= 1 ? vfork() : fork());
  switch (pid) {
  case -1:
    exit(EXIT_FAILURE);
  case 0:
    exit(execve("/bin/true", argv, envp));
  default:
    if (wait(&status) < 0 || !WIFEXITED(status))
      exit(EXIT_FAILURE);
    exit(WEXITSTATUS(status));
  }
  exit(EXIT_FAILURE);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0x2c63(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0x2c60(%rip),%rax
mov    %rax,-0x18(%rbp)
lea    -0x28(%rbp),%rdi
xor    %esi,%esi
mov    $0x8,%edx
call   1030 <memset@plt>
cmpl   $0x1,-0x8(%rbp)
jg     11d3 <main+0x53>
call   1060 <vfork@plt>
mov    %eax,-0x34(%rbp)
jmp    11dd <main+0x5d>
mov    $0x0,%al
call   10a0 <fork@plt>
mov    %eax,-0x34(%rbp)
mov    -0x34(%rbp),%eax
mov    %eax,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
mov    %eax,-0x38(%rbp)
sub    $0xffffffff,%eax
je     1207 <main+0x87>
jmp    11f7 <main+0x77>
mov    -0x38(%rbp),%eax
test   %eax,%eax
je     1215 <main+0x95>
jmp    1230 <main+0xb0>
mov    0x2dca(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>
lea    -0x20(%rbp),%rsi
lea    -0x28(%rbp),%rdx
lea    0xddc(%rip),%rdi
call   1040 <execve@plt>
mov    %eax,%edi
call   1080 <exit@plt>
lea    -0x30(%rbp),%rdi
call   1090 <wait@plt>
cmp    $0x0,%eax
jl     1253 <main+0xd3>
mov    -0x30(%rbp),%edi
call   1070 <WIFEXITED@plt>
cmp    $0x0,%eax
jne    1261 <main+0xe1>
mov    0x2d7e(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>
mov    -0x30(%rbp),%edi
call   1050 <WEXITSTATUS@plt>
mov    %eax,%edi
call   1080 <exit@plt>

x86 assembly (clang, -O2):
<main>:
sub    $0x28,%rsp
movaps 0x2c85(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movq   $0x0,0x8(%rsp)
cmp    $0x1,%edi
jg     11c5 <main+0x55>
call   1050 <vfork@plt>
test   %eax,%eax
je     11d0 <main+0x60>
cmp    $0xffffffff,%eax
je     11b7 <main+0x47>
lea    0x4(%rsp),%rdi
call   1080 <wait@plt>
test   %eax,%eax
js     11b7 <main+0x47>
mov    0x4(%rsp),%edi
call   1060 <WIFEXITED@plt>
test   %eax,%eax
jne    11ed <main+0x7d>
mov    0x2e1a(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>
xor    %eax,%eax
call   1090 <fork@plt>
test   %eax,%eax
jne    1197 <main+0x27>
lea    0xe29(%rip),%rdi
lea    0x10(%rsp),%rsi
lea    0x8(%rsp),%rdx
call   1030 <execve@plt>
mov    %eax,%edi
call   1070 <exit@plt>
mov    0x4(%rsp),%edi
call   1040 <WEXITSTATUS@plt>
mov    %eax,%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@.str = [5 x i8] c"true\00"
@__const.main.argv = [2 x i8*] [i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i32 0, i32 0), i8* null]
@EXIT_FAILURE = global i32 0
@.str.1 = [10 x i8] c"/bin/true\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [2 x i8*]
%7 = alloca [1 x i8*]
%8 = alloca i32
%9 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%10 = bitcast [2 x i8*]* %6 to i8*
%11 = bitcast [1 x i8*]* %7 to i8*
%12 = load i32, i32* %4
%13 = icmp sle i32 %12, 1
br i1 %13, label %14, label %16
14: ; preds = %2
%15 = call i32 @vfork()
br label %18
16: ; preds = %2
%17 = call i32 (...) @fork()
br label %18
18: ; preds = %16, %14
%19 = phi i32 [ %15, %14 ], [ %17, %16 ]
store i32 %19, i32* %8
%20 = load i32, i32* %8
switch i32 %20, label %29 [
i32 -1, label %21
i32 0, label %24
]
21: ; preds = %18
%22 = load i32, i32* @EXIT_FAILURE
%23 = call i32 @exit(i32 %22)
unreachable
24: ; preds = %18
%25 = getelementptr inbounds [2 x i8*], [2 x i8*]* %6, i64 0, i64 0
%26 = getelementptr inbounds [1 x i8*], [1 x i8*]* %7, i64 0, i64 0
%27 = call i32 @execve(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i8** %25, i8** %26)
%28 = call i32 @exit(i32 %27)
unreachable
29: ; preds = %18
%30 = call i32 @wait(i32* %9)
%31 = icmp slt i32 %30, 0
br i1 %31, label %36, label %32
32: ; preds = %29
%33 = load i32, i32* %9
%34 = call i32 @WIFEXITED(i32 %33)
%35 = icmp ne i32 %34, 0
br i1 %35, label %39, label %36
36: ; preds = %32, %29
%37 = load i32, i32* @EXIT_FAILURE
%38 = call i32 @exit(i32 %37)
unreachable
39: ; preds = %32
%40 = load i32, i32* %9
%41 = call i32 @WEXITSTATUS(i32 %40)
%42 = call i32 @exit(i32 %41)
unreachable
}

LLVM IR (-O2):
@.str = [5 x i8] c"true\00"
@__const.main.argv = [2 x i8*] [i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i32 0, i32 0), i8* null]
@EXIT_FAILURE = global i32 0
@.str.1 = [10 x i8] c"/bin/true\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [2 x i8*]
%4 = alloca [1 x i8*]
%5 = alloca i32
%6 = bitcast [2 x i8*]* %3 to i8*
%7 = bitcast [1 x i8*]* %4 to i8*
%8 = bitcast [1 x i8*]* %4 to i64*
store i64 0, i64* %8
%9 = bitcast i32* %5 to i8*
%10 = icmp slt i32 %0, 2
br i1 %10, label %11, label %13
11: ; preds = %2
%12 = call i32 @vfork()
br label %15
13: ; preds = %2
%14 = call i32 (...) @fork()
br label %15
15: ; preds = %13, %11
%16 = phi i32 [ %12, %11 ], [ %14, %13 ]
switch i32 %16, label %25 [
i32 -1, label %17
i32 0, label %20
]
17: ; preds = %15
%18 = load i32, i32* @EXIT_FAILURE
%19 = call i32 @exit(i32 %18)
unreachable
20: ; preds = %15
%21 = getelementptr inbounds [2 x i8*], [2 x i8*]* %3, i64 0, i64 0
%22 = getelementptr inbounds [1 x i8*], [1 x i8*]* %4, i64 0, i64 0
%23 = call i32 @execve(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i8** %21, i8** %22)
%24 = call i32 @exit(i32 %23)
unreachable
25: ; preds = %15
%26 = call i32 @wait(i32* %5)
%27 = icmp slt i32 %26, 0
br i1 %27, label %32, label %28
28: ; preds = %25
%29 = load i32, i32* %5
%30 = call i32 @WIFEXITED(i32 %29)
%31 = icmp eq i32 %30, 0
br i1 %31, label %32, label %35
32: ; preds = %28, %25
%33 = load i32, i32* @EXIT_FAILURE
%34 = call i32 @exit(i32 %33)
unreachable
35: ; preds = %28
%36 = load i32, i32* %5
%37 = call i32 @WEXITSTATUS(i32 %36)
%38 = call i32 @exit(i32 %37)
unreachable
}