#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 *, int /*<<< orphan*/ *);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fork();
int /*<<< orphan*/ open(char *, int /*<<< orphan*/);
int /*<<< orphan*/ wait(int *);
int main(int argc, char **argv) {
  if (argc == 3) {
    execlp("tr", argv[1], argv[2], NULL);
    exit(0);
  }
  for (int i = 3; i < argc; i++)
    if (!fork()) {
      close(0);
      open(argv[i], O_RDONLY);
      execlp("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)
jne    11a7 <main+0x47>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdx
lea    0xe69(%rip),%rdi
xor    %eax,%eax
mov    %eax,%ecx
call   1060 <execlp@plt>
xor    %edi,%edi
call   1050 <exit@plt>
movl   $0x3,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    121e <main+0xbe>
mov    $0x0,%al
call   1080 <fork@plt>
cmp    $0x0,%eax
jne    120b <main+0xab>
xor    %edi,%edi
call   1030 <close@plt>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
mov    0x2e04(%rip),%rax
mov    (%rax),%esi
call   1040 <open@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdx
lea    0xdfe(%rip),%rdi
xor    %eax,%eax
mov    %eax,%ecx
call   1060 <execlp@plt>
jmp    1210 <main+0xb0>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11ae <main+0x4e>
movl   $0x3,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1248 <main+0xe8>
lea    -0x1c(%rbp),%rdi
call   1070 <wait@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1225 <main+0xc5>
xor    %eax,%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    %rsi,%r14
cmp    $0x3,%edi
je     120e <main+0xae>
jle    11fd <main+0x9d>
mov    %edi,%ebp
mov    %edi,%r12d
mov    $0x3,%ebx
mov    0x2e5a(%rip),%r13
lea    0xe6b(%rip),%r15
jmp    11a9 <main+0x49>
nopw   0x0(%rax,%rax,1)
add    $0x1,%rbx
cmp    %rbx,%r12
je     11dc <main+0x7c>
xor    %eax,%eax
call   1080 <fork@plt>
test   %eax,%eax
jne    11a0 <main+0x40>
xor    %edi,%edi
call   1030 <close@plt>
mov    (%r14,%rbx,8),%rdi
mov    0x0(%r13),%esi
call   1040 <open@plt>
mov    0x8(%r14),%rsi
mov    0x10(%r14),%rdx
mov    %r15,%rdi
xor    %ecx,%ecx
call   1060 <execlp@plt>
jmp    11a0 <main+0x40>
cmp    $0x4,%ebp
jl     11fd <main+0x9d>
add    $0xfffffffd,%ebp
lea    0x4(%rsp),%r14
nopl   0x0(%rax)
mov    %r14,%rdi
call   1070 <wait@plt>
add    $0xffffffff,%ebp
jne    11f0 <main+0x90>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x8(%r14),%rsi
mov    0x10(%r14),%rdx
lea    0xde3(%rip),%rdi
xor    %ecx,%ecx
call   1060 <execlp@plt>
xor    %edi,%edi
call   1050 <exit@plt>

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

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 eq i32 %0, 3
br i1 %4, label %11, label %5
5: ; preds = %2
%6 = icmp sgt i32 %0, 3
br i1 %6, label %7, label %37
7: ; preds = %5
%8 = getelementptr inbounds i8*, i8** %1, i64 1
%9 = getelementptr inbounds i8*, i8** %1, i64 2
%10 = zext i32 %0 to i64
br label %21
11: ; preds = %2
%12 = getelementptr inbounds i8*, i8** %1, i64 1
%13 = load i8*, i8** %12
%14 = getelementptr inbounds i8*, i8** %1, i64 2
%15 = load i8*, i8** %14
%16 = tail call i32 @execlp(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %13, i8* %15, i32* null)
%17 = tail call i32 @exit(i32 0)
unreachable
18: ; preds = %34
br i1 %6, label %19, label %37
19: ; preds = %18
%20 = bitcast i32* %3 to i8*
br label %38
21: ; preds = %7, %34
%22 = phi i64 [ 3, %7 ], [ %35, %34 ]
%23 = tail call i32 (...) @fork()
%24 = icmp eq i32 %23, 0
br i1 %24, label %25, label %34
25: ; preds = %21
%26 = tail call i32 @close(i32 0)
%27 = getelementptr inbounds i8*, i8** %1, i64 %22
%28 = load i8*, i8** %27
%29 = load i32, i32* @O_RDONLY
%30 = tail call i32 @open(i8* %28, i32 %29)
%31 = load i8*, i8** %8
%32 = load i8*, i8** %9
%33 = tail call i32 @execlp(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %31, i8* %32, i32* null)
br label %34
34: ; preds = %21, %25
%35 = add nuw nsw i64 %22, 1
%36 = icmp eq i64 %35, %10
br i1 %36, label %18, label %21
37: ; preds = %38, %5, %18
ret i32 0
38: ; preds = %19, %38
%39 = phi i32 [ 3, %19 ], [ %41, %38 ]
%40 = call i32 @wait(i32* %3)
%41 = add nuw nsw i32 %39, 1
%42 = icmp eq i32 %41, %0
br i1 %42, label %37, label %38
}