#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);
int /*<<< orphan*/ creat(char *, int);
int /*<<< orphan*/ execlp(char *, char *, char *, char *, int /*<<< orphan*/ *);
int /*<<< orphan*/ open(char *, int /*<<< orphan*/);
int main(int argc, char **argv) {
  if (argc < 5)
    return 1;
  close(0);
  open(argv[3], O_RDONLY);
  close(1);
  creat(argv[4], 0644);
  execlp("tr", "tr", argv[1], argv[2], NULL);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x5,-0x8(%rbp)
jge    116c <main+0x2c>
movl   $0x1,-0x4(%rbp)
jmp    11c9 <main+0x89>
xor    %edi,%edi
call   1030 <close@plt>
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
mov    0x2e66(%rip),%rax
mov    (%rax),%esi
call   1040 <open@plt>
mov    $0x1,%edi
call   1030 <close@plt>
mov    -0x10(%rbp),%rax
mov    0x20(%rax),%rdi
mov    $0x1a4,%esi
call   1050 <creat@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdx
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rcx
lea    0xe44(%rip),%rsi
xor    %eax,%eax
mov    %eax,%r8d
mov    %rsi,%rdi
call   1060 <execlp@plt>
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
mov    $0x1,%r14d
cmp    $0x5,%edi
jl     11a0 <main+0x60>
mov    %rsi,%rbx
xor    %r14d,%r14d
xor    %edi,%edi
call   1030 <close@plt>
mov    0x18(%rbx),%rdi
mov    0x2e81(%rip),%rax
mov    (%rax),%esi
call   1040 <open@plt>
mov    $0x1,%edi
call   1030 <close@plt>
mov    0x20(%rbx),%rdi
mov    $0x1a4,%esi
call   1050 <creat@plt>
mov    0x8(%rbx),%rdx
mov    0x10(%rbx),%rcx
lea    0xe6b(%rip),%rdi
mov    %rdi,%rsi
xor    %r8d,%r8d
call   1060 <execlp@plt>
mov    %r14d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@O_RDONLY = global i32 0
@.str = [3 x i8] c"tr\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%6 = load i32, i32* %4
%7 = icmp slt i32 %6, 5
br i1 %7, label %8, label %9
8: ; preds = %2
store i32 1, i32* %3
br label %28
9: ; preds = %2
%10 = call i32 @close(i32 0)
%11 = load i8**, i8*** %5
%12 = getelementptr inbounds i8*, i8** %11, i64 3
%13 = load i8*, i8** %12
%14 = load i32, i32* @O_RDONLY
%15 = call i32 @open(i8* %13, i32 %14)
%16 = call i32 @close(i32 1)
%17 = load i8**, i8*** %5
%18 = getelementptr inbounds i8*, i8** %17, i64 4
%19 = load i8*, i8** %18
%20 = call i32 @creat(i8* %19, i32 420)
%21 = load i8**, i8*** %5
%22 = getelementptr inbounds i8*, i8** %21, i64 1
%23 = load i8*, i8** %22
%24 = load i8**, i8*** %5
%25 = getelementptr inbounds i8*, i8** %24, i64 2
%26 = load i8*, i8** %25
%27 = 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* %23, i8* %26, i32* null)
br label %28
28: ; preds = %9, %8
%29 = load i32, i32* %3
ret i32 %29
}

LLVM IR (-O2):
@O_RDONLY = global i32 0
@.str = [3 x i8] c"tr\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp slt i32 %0, 5
br i1 %3, label %19, label %4
4: ; preds = %2
%5 = tail call i32 @close(i32 0)
%6 = getelementptr inbounds i8*, i8** %1, i64 3
%7 = load i8*, i8** %6
%8 = load i32, i32* @O_RDONLY
%9 = tail call i32 @open(i8* %7, i32 %8)
%10 = tail call i32 @close(i32 1)
%11 = getelementptr inbounds i8*, i8** %1, i64 4
%12 = load i8*, i8** %11
%13 = tail call i32 @creat(i8* %12, i32 420)
%14 = getelementptr inbounds i8*, i8** %1, i64 1
%15 = load i8*, i8** %14
%16 = getelementptr inbounds i8*, i8** %1, i64 2
%17 = load i8*, i8** %16
%18 = 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* %15, i8* %17, i32* null)
br label %19
19: ; preds = %2, %4
%20 = phi i32 [ 0, %4 ], [ 1, %2 ]
ret i32 %20
}