#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 /*<<< orphan*/ stat;

/* Variables and functions */
int /*<<< orphan*/ errno;
int execlp(char const *, char const *, int /*<<< orphan*/ *);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
scalar_t__ fork();
int /*<<< orphan*/ pipe(int *);
int /*<<< orphan*/ printf(char *, char const *, ...);
int /*<<< orphan*/ read(int, int *, int);
int /*<<< orphan*/ wait(int *);
int /*<<< orphan*/ write(int, int *, int);
int main(int argc, char const *argv[]) {
  int c2p[2];
  int i;
  int stat;
  for (i = 1; i < argc; i++) {
    pipe(c2p);
    if (fork() == 0) {
      if (fork() == 0) {
        if (execlp(argv[i], argv[i], NULL) == -1)
          exit(errno);
      }
      wait(&stat);
      write(c2p[1], &stat, sizeof(stat));
      exit(0);
    }
    read(c2p[0], &stat, sizeof(int));
    if (stat != 0)
      printf("Not succsesful: %s %d\n", argv[i], stat);
    else
      printf("Succes! %s\n", argv[i]);
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x1,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    129c <main+0x11c>
lea    -0x18(%rbp),%rdi
call   1050 <pipe@plt>
mov    $0x0,%al
call   10a0 <fork@plt>
cmp    $0x0,%rax
jne    1232 <main+0xb2>
mov    $0x0,%al
call   10a0 <fork@plt>
cmp    $0x0,%rax
jne    1211 <main+0x91>
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
xor    %eax,%eax
mov    %eax,%edx
call   1080 <execlp@plt>
cmp    $0xffffffff,%eax
jne    120c <main+0x8c>
mov    0x2ddb(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>
jmp    1211 <main+0x91>
lea    -0x20(%rbp),%rdi
call   1090 <wait@plt>
mov    -0x14(%rbp),%edi
lea    -0x20(%rbp),%rsi
mov    $0x4,%edx
call   1030 <write@plt>
xor    %edi,%edi
call   1070 <exit@plt>
mov    -0x18(%rbp),%edi
lea    -0x20(%rbp),%rsi
mov    $0x4,%edx
call   1060 <read@plt>
cmpl   $0x0,-0x20(%rbp)
je     126f <main+0xef>
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
mov    -0x20(%rbp),%edx
lea    0xd9d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1289 <main+0x109>
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
lea    0xd95(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    128e <main+0x10e>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    119d <main+0x1d>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
cmp    $0x2,%edi
jl     1214 <main+0x94>
mov    %rsi,%rbx
mov    %edi,%r12d
mov    $0x1,%ebp
lea    0x10(%rsp),%r14
lea    0xc(%rsp),%r15
lea    0xe4d(%rip),%r13
jmp    11d7 <main+0x57>
cs nopw 0x0(%rax,%rax,1)
nop
lea    0xe50(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%rbp
cmp    %rbp,%r12
je     1214 <main+0x94>
mov    %r14,%rdi
call   1050 <pipe@plt>
xor    %eax,%eax
call   10a0 <fork@plt>
test   %rax,%rax
je     1225 <main+0xa5>
mov    0x10(%rsp),%edi
mov    %r15,%rsi
mov    $0x4,%edx
call   1060 <read@plt>
mov    0xc(%rsp),%edx
mov    (%rbx,%rbp,8),%rsi
test   %edx,%edx
je     11c0 <main+0x40>
mov    %r13,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    11ce <main+0x4e>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
xor    %eax,%eax
call   10a0 <fork@plt>
test   %rax,%rax
jne    1252 <main+0xd2>
mov    (%rbx,%rbp,8),%rdi
mov    %rdi,%rsi
xor    %edx,%edx
call   1080 <execlp@plt>
cmp    $0xffffffff,%eax
jne    1252 <main+0xd2>
mov    0x2d95(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>
lea    0xc(%rsp),%rbx
mov    %rbx,%rdi
call   1090 <wait@plt>
mov    0x14(%rsp),%edi
mov    %rbx,%rsi
mov    $0x4,%edx
call   1030 <write@plt>
xor    %edi,%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@errno = global i32 0
@.str = [23 x i8] c"Not succsesful: %s %d\0A\00"
@.str.1 = [12 x i8] c"Succes! %s\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [2 x i32]
%7 = alloca i32
%8 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 1, i32* %7
br label %9
9: ; preds = %66, %2
%10 = load i32, i32* %7
%11 = load i32, i32* %4
%12 = icmp slt i32 %10, %11
br i1 %12, label %13, label %69
13: ; preds = %9
%14 = getelementptr inbounds [2 x i32], [2 x i32]* %6, i64 0, i64 0
%15 = call i32 @pipe(i32* %14)
%16 = call i64 (...) @fork()
%17 = icmp eq i64 %16, 0
br i1 %17, label %18, label %44
18: ; preds = %13
%19 = call i64 (...) @fork()
%20 = icmp eq i64 %19, 0
br i1 %20, label %21, label %38
21: ; preds = %18
%22 = load i8**, i8*** %5
%23 = load i32, i32* %7
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds i8*, i8** %22, i64 %24
%26 = load i8*, i8** %25
%27 = load i8**, i8*** %5
%28 = load i32, i32* %7
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds i8*, i8** %27, i64 %29
%31 = load i8*, i8** %30
%32 = call i32 @execlp(i8* %26, i8* %31, i32* null)
%33 = icmp eq i32 %32, -1
br i1 %33, label %34, label %37
34: ; preds = %21
%35 = load i32, i32* @errno
%36 = call i32 @exit(i32 %35)
unreachable
37: ; preds = %21
br label %38
38: ; preds = %37, %18
%39 = call i32 @wait(i32* %8)
%40 = getelementptr inbounds [2 x i32], [2 x i32]* %6, i64 0, i64 1
%41 = load i32, i32* %40
%42 = call i32 @write(i32 %41, i32* %8, i32 4)
%43 = call i32 @exit(i32 0)
unreachable
44: ; preds = %13
%45 = getelementptr inbounds [2 x i32], [2 x i32]* %6, i64 0, i64 0
%46 = load i32, i32* %45
%47 = call i32 @read(i32 %46, i32* %8, i32 4)
%48 = load i32, i32* %8
%49 = icmp ne i32 %48, 0
br i1 %49, label %50, label %58
50: ; preds = %44
%51 = load i8**, i8*** %5
%52 = load i32, i32* %7
%53 = sext i32 %52 to i64
%54 = getelementptr inbounds i8*, i8** %51, i64 %53
%55 = load i8*, i8** %54
%56 = load i32, i32* %8
%57 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i8* %55, i32 %56)
br label %65
58: ; preds = %44
%59 = load i8**, i8*** %5
%60 = load i32, i32* %7
%61 = sext i32 %60 to i64
%62 = getelementptr inbounds i8*, i8** %59, i64 %61
%63 = load i8*, i8** %62
%64 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i8* %63)
br label %65
65: ; preds = %58, %50
br label %66
66: ; preds = %65
%67 = load i32, i32* %7
%68 = add nsw i32 %67, 1
store i32 %68, i32* %7
br label %9
69: ; preds = %9
%70 = load i32, i32* %3
ret i32 %70
}

LLVM IR (-O2):
@errno = global i32 0
@.str = [23 x i8] c"Not succsesful: %s %d\0A\00"
@.str.1 = [12 x i8] c"Succes! %s\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [2 x i32]
%4 = alloca i32
%5 = bitcast [2 x i32]* %3 to i8*
%6 = bitcast i32* %4 to i8*
%7 = icmp sgt i32 %0, 1
br i1 %7, label %8, label %48
8: ; preds = %2
%9 = getelementptr inbounds [2 x i32], [2 x i32]* %3, i64 0, i64 0
%10 = zext i32 %0 to i64
br label %11
11: ; preds = %8, %45
%12 = phi i64 [ 1, %8 ], [ %46, %45 ]
%13 = call i32 @pipe(i32* %9)
%14 = call i64 (...) @fork()
%15 = icmp eq i64 %14, 0
br i1 %15, label %16, label %34
16: ; preds = %11
%17 = call i64 (...) @fork()
%18 = icmp eq i64 %17, 0
br i1 %18, label %19, label %28
19: ; preds = %16
%20 = and i64 %12, 4294967295
%21 = getelementptr inbounds i8*, i8** %1, i64 %20
%22 = load i8*, i8** %21
%23 = call i32 @execlp(i8* %22, i8* %22, i32* null)
%24 = icmp eq i32 %23, -1
br i1 %24, label %25, label %28
25: ; preds = %19
%26 = load i32, i32* @errno
%27 = call i32 @exit(i32 %26)
unreachable
28: ; preds = %19, %16
%29 = call i32 @wait(i32* %4)
%30 = getelementptr inbounds [2 x i32], [2 x i32]* %3, i64 0, i64 1
%31 = load i32, i32* %30
%32 = call i32 @write(i32 %31, i32* %4, i32 4)
%33 = call i32 @exit(i32 0)
unreachable
34: ; preds = %11
%35 = load i32, i32* %9
%36 = call i32 @read(i32 %35, i32* %4, i32 4)
%37 = load i32, i32* %4
%38 = icmp eq i32 %37, 0
%39 = getelementptr inbounds i8*, i8** %1, i64 %12
%40 = load i8*, i8** %39
br i1 %38, label %43, label %41
41: ; preds = %34
%42 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i8* %40, i32 %37)
br label %45
43: ; preds = %34
%44 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i8* %40)
br label %45
45: ; preds = %41, %43
%46 = add nuw nsw i64 %12, 1
%47 = icmp eq i64 %46, %10
br i1 %47, label %48, label %11
48: ; preds = %45, %2
ret i32 0
}