#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 const *, int /*<<< orphan*/ *);
int /*<<< orphan*/ open(char const *, int /*<<< orphan*/);
int main(int argc, char **argv) {
  const char *filename = NULL, *option = NULL;
  if (argc < 2)
    return 1;
  else if (argc > 2 && '-' == *argv[1]) {
    option = argv[1];
    filename = argv[2];
  } else
    filename = argv[1];
  close(0);
  open(filename, O_RDONLY);
  execlp("wc", "wc", option, NULL);
}


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)
movq   $0x0,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
cmpl   $0x2,-0x8(%rbp)
jge    116c <main+0x3c>
movl   $0x1,-0x4(%rbp)
jmp    11ec <main+0xbc>
cmpl   $0x2,-0x8(%rbp)
jle    11ab <main+0x7b>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
movsbl (%rax),%ecx
mov    $0x2d,%eax
cmp    %ecx,%eax
jne    11ab <main+0x7b>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rax
mov    %rax,-0x18(%rbp)
jmp    11b7 <main+0x87>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x18(%rbp)
jmp    11bc <main+0x8c>
xor    %edi,%edi
call   1030 <close@plt>
mov    -0x18(%rbp),%rdi
mov    0x2e1a(%rip),%rax
mov    (%rax),%esi
call   1040 <open@plt>
mov    -0x20(%rbp),%rdx
lea    0xe20(%rip),%rsi
xor    %eax,%eax
mov    %eax,%ecx
mov    %rsi,%rdi
call   1050 <execlp@plt>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
mov    $0x1,%ebx
cmp    $0x2,%edi
jl     118a <main+0x5a>
je     1150 <main+0x20>
mov    0x8(%rsi),%r14
mov    $0x2,%eax
cmpb   $0x2d,(%r14)
je     1158 <main+0x28>
mov    $0x1,%eax
xor    %r14d,%r14d
mov    (%rsi,%rax,8),%r15
xor    %ebx,%ebx
xor    %edi,%edi
call   1030 <close@plt>
mov    0x2e7c(%rip),%rax
mov    (%rax),%esi
mov    %r15,%rdi
call   1040 <open@plt>
lea    0xe83(%rip),%rdi
mov    %rdi,%rsi
mov    %r14,%rdx
xor    %ecx,%ecx
call   1050 <execlp@plt>
mov    %ebx,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@O_RDONLY = global i32 0
@.str = [3 x i8] c"wc\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i8* null, i8** %6
store i8* null, i8** %7
%8 = load i32, i32* %4
%9 = icmp slt i32 %8, 2
br i1 %9, label %10, label %11
10: ; preds = %2
store i32 1, i32* %3
br label %40
11: ; preds = %2
%12 = load i32, i32* %4
%13 = icmp sgt i32 %12, 2
br i1 %13, label %14, label %28
14: ; preds = %11
%15 = load i8**, i8*** %5
%16 = getelementptr inbounds i8*, i8** %15, i64 1
%17 = load i8*, i8** %16
%18 = load i8, i8* %17
%19 = sext i8 %18 to i32
%20 = icmp eq i32 45, %19
br i1 %20, label %21, label %28
21: ; preds = %14
%22 = load i8**, i8*** %5
%23 = getelementptr inbounds i8*, i8** %22, i64 1
%24 = load i8*, i8** %23
store i8* %24, i8** %7
%25 = load i8**, i8*** %5
%26 = getelementptr inbounds i8*, i8** %25, i64 2
%27 = load i8*, i8** %26
store i8* %27, i8** %6
br label %32
28: ; preds = %14, %11
%29 = load i8**, i8*** %5
%30 = getelementptr inbounds i8*, i8** %29, i64 1
%31 = load i8*, i8** %30
store i8* %31, i8** %6
br label %32
32: ; preds = %28, %21
br label %33
33: ; preds = %32
%34 = call i32 @close(i32 0)
%35 = load i8*, i8** %6
%36 = load i32, i32* @O_RDONLY
%37 = call i32 @open(i8* %35, i32 %36)
%38 = load i8*, i8** %7
%39 = 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* %38, i32* null)
br label %40
40: ; preds = %33, %10
%41 = load i32, i32* %3
ret i32 %41
}

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