#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*/ O_RDONLY;
int /*<<< orphan*/ close(int /*<<< orphan*/);
int /*<<< orphan*/ execlp(char *, char *, char *, char *, int /*<<< orphan*/ *);
int /*<<< orphan*/ fork();
int /*<<< orphan*/ open(char *, int /*<<< orphan*/);
int /*<<< orphan*/ wait(int *);
int main(int argc, char **argv) {
  if (argc < 3)
    return 1;
  if (argc == 3)
    execlp("tr", "tr", argv[1], argv[2], NULL);
  for (int i = 3; i < argc; i++)
    if (!fork()) {
      close(0);
      open(argv[i], O_RDONLY);
      execlp("tr", "tr", argv[1], argv[2], NULL);
    }
  for (int i = 3; i < argc; i++) {
    int status;
    wait(&status);
  }
  return 0;
}


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)
cmpl   $0x3,-0x8(%rbp)
jge    117c <main+0x2c>
movl   $0x1,-0x4(%rbp)
jmp    1256 <main+0x106>
cmpl   $0x3,-0x8(%rbp)
jne    11aa <main+0x5a>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdx
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rcx
lea    0xe63(%rip),%rsi
xor    %eax,%eax
mov    %eax,%r8d
mov    %rsi,%rdi
call   1050 <execlp@plt>
movl   $0x3,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1225 <main+0xd5>
mov    $0x0,%al
call   1070 <fork@plt>
cmp    $0x0,%eax
jne    1212 <main+0xc2>
xor    %edi,%edi
call   1030 <close@plt>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
mov    0x2e01(%rip),%rax
mov    (%rax),%esi
call   1040 <open@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdx
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rcx
lea    0xdfb(%rip),%rsi
xor    %eax,%eax
mov    %eax,%r8d
mov    %rsi,%rdi
call   1050 <execlp@plt>
jmp    1217 <main+0xc7>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11b1 <main+0x61>
movl   $0x3,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    124f <main+0xff>
lea    -0x1c(%rbp),%rdi
call   1060 <wait@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    122c <main+0xdc>
movl   $0x0,-0x4(%rbp)
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
push   %rax
mov    $0x1,%r15d
cmp    $0x3,%edi
jl     1210 <main+0xc0>
mov    %rsi,%r14
jne    1191 <main+0x41>
mov    0x8(%r14),%rdx
mov    0x10(%r14),%rcx
lea    0xe82(%rip),%rdi
xor    %r15d,%r15d
mov    %rdi,%rsi
xor    %r8d,%r8d
call   1050 <execlp@plt>
jmp    1210 <main+0xc0>
mov    %edi,%ebp
mov    %edi,%r12d
mov    $0x3,%ebx
mov    0x2e46(%rip),%r13
lea    0xe57(%rip),%r15
jmp    11b9 <main+0x69>
nopl   0x0(%rax,%rax,1)
add    $0x1,%rbx
cmp    %rbx,%r12
je     11f0 <main+0xa0>
xor    %eax,%eax
call   1070 <fork@plt>
test   %eax,%eax
jne    11b0 <main+0x60>
xor    %edi,%edi
call   1030 <close@plt>
mov    (%r14,%rbx,8),%rdi
mov    0x0(%r13),%esi
call   1040 <open@plt>
mov    0x8(%r14),%rdx
mov    0x10(%r14),%rcx
mov    %r15,%rdi
mov    %r15,%rsi
xor    %r8d,%r8d
call   1050 <execlp@plt>
jmp    11b0 <main+0x60>
add    $0xfffffffd,%ebp
lea    0x4(%rsp),%r14
nopl   0x0(%rax,%rax,1)
mov    %r14,%rdi
call   1060 <wait@plt>
add    $0xffffffff,%ebp
jne    1200 <main+0xb0>
xor    %r15d,%r15d
mov    %r15d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"tr\00"
@O_RDONLY = global i32 0
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
%9 = load i32, i32* %4
%10 = icmp slt i32 %9, 3
br i1 %10, label %11, label %12
11: ; preds = %2
store i32 1, i32* %3
br label %62
12: ; preds = %2
%13 = load i32, i32* %4
%14 = icmp eq i32 %13, 3
br i1 %14, label %15, label %23
15: ; preds = %12
%16 = load i8**, i8*** %5
%17 = getelementptr inbounds i8*, i8** %16, i64 1
%18 = load i8*, i8** %17
%19 = load i8**, i8*** %5
%20 = getelementptr inbounds i8*, i8** %19, i64 2
%21 = load i8*, i8** %20
%22 = call i32 @execlp(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %18, i8* %21, i32* null)
br label %23
23: ; preds = %15, %12
store i32 3, i32* %6
br label %24
24: ; preds = %48, %23
%25 = load i32, i32* %6
%26 = load i32, i32* %4
%27 = icmp slt i32 %25, %26
br i1 %27, label %28, label %51
28: ; preds = %24
%29 = call i32 (...) @fork()
%30 = icmp ne i32 %29, 0
br i1 %30, label %47, label %31
31: ; preds = %28
%32 = call i32 @close(i32 0)
%33 = load i8**, i8*** %5
%34 = load i32, i32* %6
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds i8*, i8** %33, i64 %35
%37 = load i8*, i8** %36
%38 = load i32, i32* @O_RDONLY
%39 = call i32 @open(i8* %37, i32 %38)
%40 = load i8**, i8*** %5
%41 = getelementptr inbounds i8*, i8** %40, i64 1
%42 = load i8*, i8** %41
%43 = load i8**, i8*** %5
%44 = getelementptr inbounds i8*, i8** %43, i64 2
%45 = load i8*, i8** %44
%46 = call i32 @execlp(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %42, i8* %45, i32* null)
br label %47
47: ; preds = %31, %28
br label %48
48: ; preds = %47
%49 = load i32, i32* %6
%50 = add nsw i32 %49, 1
store i32 %50, i32* %6
br label %24
51: ; preds = %24
store i32 3, i32* %7
br label %52
52: ; preds = %58, %51
%53 = load i32, i32* %7
%54 = load i32, i32* %4
%55 = icmp slt i32 %53, %54
br i1 %55, label %56, label %61
56: ; preds = %52
%57 = call i32 @wait(i32* %8)
br label %58
58: ; preds = %56
%59 = load i32, i32* %7
%60 = add nsw i32 %59, 1
store i32 %60, i32* %7
br label %52
61: ; preds = %52
store i32 0, i32* %3
br label %62
62: ; preds = %61, %11
%63 = load i32, i32* %3
ret i32 %63
}

LLVM IR (-O2):
@.str = [3 x i8] c"tr\00"
@O_RDONLY = global i32 0
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i32
%4 = icmp slt i32 %0, 3
br i1 %4, label %39, label %5
5: ; preds = %2
%6 = icmp eq i32 %0, 3
%7 = getelementptr inbounds i8*, i8** %1, i64 1
br i1 %6, label %8, label %13
8: ; preds = %5
%9 = load i8*, i8** %7
%10 = getelementptr inbounds i8*, i8** %1, i64 2
%11 = load i8*, i8** %10
%12 = tail call i32 @execlp(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %9, i8* %11, i32* null)
br label %39
13: ; preds = %5
%14 = getelementptr inbounds i8*, i8** %1, i64 2
%15 = zext i32 %0 to i64
br label %18
16: ; preds = %31
%17 = bitcast i32* %3 to i8*
br label %34
18: ; preds = %13, %31
%19 = phi i64 [ 3, %13 ], [ %32, %31 ]
%20 = tail call i32 (...) @fork()
%21 = icmp eq i32 %20, 0
br i1 %21, label %22, label %31
22: ; preds = %18
%23 = tail call i32 @close(i32 0)
%24 = getelementptr inbounds i8*, i8** %1, i64 %19
%25 = load i8*, i8** %24
%26 = load i32, i32* @O_RDONLY
%27 = tail call i32 @open(i8* %25, i32 %26)
%28 = load i8*, i8** %7
%29 = load i8*, i8** %14
%30 = tail call i32 @execlp(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %28, i8* %29, i32* null)
br label %31
31: ; preds = %18, %22
%32 = add nuw nsw i64 %19, 1
%33 = icmp eq i64 %32, %15
br i1 %33, label %16, label %18
34: ; preds = %16, %34
%35 = phi i32 [ 3, %16 ], [ %37, %34 ]
%36 = call i32 @wait(i32* %3)
%37 = add nuw nsw i32 %35, 1
%38 = icmp eq i32 %37, %0
br i1 %38, label %39, label %34
39: ; preds = %34, %8, %2
%40 = phi i32 [ 1, %2 ], [ 0, %8 ], [ 0, %34 ]
ret i32 %40
}