#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*/ execlp(char *, char *, int /*<<< orphan*/ *);
int fork();
int /*<<< orphan*/ wait(int *);
int main(int argc, char **argv) {
  for (int i = 0; i < argc; i++) {
    int status;
    int pid = fork();
    if (pid == 0) {
      execlp(argv[i + 1], argv[i + 1], NULL);
    } else {
      wait(&status);
    }
  }
  return 1;
}


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   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11b9 <main+0x89>
mov    $0x0,%al
call   1050 <fork@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jne    119d <main+0x6d>
mov    -0x10(%rbp),%rax
mov    -0x14(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rdi
mov    -0x10(%rbp),%rax
mov    -0x14(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rsi
xor    %eax,%eax
mov    %eax,%edx
call   1030 <execlp@plt>
jmp    11a6 <main+0x76>
lea    -0x18(%rbp),%rdi
call   1040 <wait@plt>
jmp    11ab <main+0x7b>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    114d <main+0x1d>
mov    $0x1,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
test   %edi,%edi
jle    1184 <main+0x54>
mov    %rsi,%r15
mov    %edi,%r12d
lea    0x4(%rsp),%r14
xor    %ebx,%ebx
jmp    1161 <main+0x31>
nopl   0x0(%rax,%rax,1)
mov    %r14,%rdi
call   1040 <wait@plt>
add    $0x1,%rbx
cmp    %r12,%rbx
je     1184 <main+0x54>
xor    %eax,%eax
call   1050 <fork@plt>
test   %eax,%eax
jne    1150 <main+0x20>
mov    0x8(%r15,%rbx,8),%rdi
add    $0x1,%rbx
mov    %rdi,%rsi
xor    %edx,%edx
call   1030 <execlp@plt>
cmp    %r12,%rbx
jne    1161 <main+0x31>
mov    $0x1,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %6
br label %9
9: ; preds = %34, %2
%10 = load i32, i32* %6
%11 = load i32, i32* %4
%12 = icmp slt i32 %10, %11
br i1 %12, label %13, label %37
13: ; preds = %9
%14 = call i32 (...) @fork()
store i32 %14, i32* %8
%15 = load i32, i32* %8
%16 = icmp eq i32 %15, 0
br i1 %16, label %17, label %31
17: ; preds = %13
%18 = load i8**, i8*** %5
%19 = load i32, i32* %6
%20 = add nsw i32 %19, 1
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds i8*, i8** %18, i64 %21
%23 = load i8*, i8** %22
%24 = load i8**, i8*** %5
%25 = load i32, i32* %6
%26 = add nsw i32 %25, 1
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds i8*, i8** %24, i64 %27
%29 = load i8*, i8** %28
%30 = call i32 @execlp(i8* %23, i8* %29, i32* null)
br label %33
31: ; preds = %13
%32 = call i32 @wait(i32* %7)
br label %33
33: ; preds = %31, %17
br label %34
34: ; preds = %33
%35 = load i32, i32* %6
%36 = add nsw i32 %35, 1
store i32 %36, i32* %6
br label %9
37: ; preds = %9
ret i32 1
}

LLVM IR (-O2):
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i32
%4 = icmp sgt i32 %0, 0
br i1 %4, label %5, label %8
5: ; preds = %2
%6 = bitcast i32* %3 to i8*
%7 = zext i32 %0 to i64
br label %9
8: ; preds = %21, %2
ret i32 1
9: ; preds = %5, %21
%10 = phi i64 [ 0, %5 ], [ %22, %21 ]
%11 = call i32 (...) @fork()
%12 = icmp eq i32 %11, 0
br i1 %12, label %13, label %18
13: ; preds = %9
%14 = add nuw nsw i64 %10, 1
%15 = getelementptr inbounds i8*, i8** %1, i64 %14
%16 = load i8*, i8** %15
%17 = call i32 @execlp(i8* %16, i8* %16, i32* null)
br label %21
18: ; preds = %9
%19 = call i32 @wait(i32* %3)
%20 = add nuw nsw i64 %10, 1
br label %21
21: ; preds = %18, %13
%22 = phi i64 [ %20, %18 ], [ %14, %13 ]
%23 = icmp eq i64 %22, %7
br i1 %23, label %8, label %9
}