#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*/ execvp(char *, char **);
int /*<<< orphan*/ strcmp(char *, char *);
int main(int argc, char **argv) {
  argv[0] = "wc";
  if (argc > 2) {
    if (!strcmp(argv[1], "chars"))
      argv[1] = "-c";
    else if (!strcmp(argv[1], "words"))
      argv[1] = "-w";
    else if (!strcmp(argv[1], "lines"))
      argv[1] = "-l";
  }
  execvp(argv[0], argv);
}


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)
mov    -0x10(%rbp),%rax
lea    0xebf(%rip),%rcx
mov    %rcx,(%rax)
cmpl   $0x2,-0x8(%rbp)
jle    11eb <main+0xcb>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xea6(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%eax
jne    117f <main+0x5f>
mov    -0x10(%rbp),%rax
lea    0xe93(%rip),%rcx
mov    %rcx,0x8(%rax)
jmp    11e6 <main+0xc6>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe7e(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%eax
jne    11b0 <main+0x90>
mov    -0x10(%rbp),%rax
lea    0xe6b(%rip),%rcx
mov    %rcx,0x8(%rax)
jmp    11e1 <main+0xc1>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe56(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%eax
jne    11dc <main+0xbc>
mov    -0x10(%rbp),%rax
lea    0xe43(%rip),%rcx
mov    %rcx,0x8(%rax)
jmp    11e1 <main+0xc1>
jmp    11e6 <main+0xc6>
jmp    11eb <main+0xcb>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
mov    -0x10(%rbp),%rsi
call   1040 <execvp@plt>
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%rbx
lea    0xed2(%rip),%rax
mov    %rax,(%rsi)
cmp    $0x3,%edi
jl     1190 <main+0x70>
mov    0x8(%rbx),%r14
lea    0xec2(%rip),%rsi
mov    %r14,%rdi
call   1030 <strcmp@plt>
test   %eax,%eax
je     117c <main+0x5c>
lea    0xeb8(%rip),%rsi
mov    %r14,%rdi
call   1030 <strcmp@plt>
test   %eax,%eax
je     1185 <main+0x65>
lea    0xeae(%rip),%rsi
mov    %r14,%rdi
call   1030 <strcmp@plt>
test   %eax,%eax
jne    1190 <main+0x70>
lea    0xea1(%rip),%rax
jmp    118c <main+0x6c>
lea    0xe86(%rip),%rax
jmp    118c <main+0x6c>
lea    0xe86(%rip),%rax
mov    %rax,0x8(%rbx)
lea    0xe69(%rip),%rdi
mov    %rbx,%rsi
call   1040 <execvp@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [3 x i8] c"wc\00"
@.str.1 = [6 x i8] c"chars\00"
@.str.2 = [3 x i8] c"-c\00"
@.str.3 = [6 x i8] c"words\00"
@.str.4 = [3 x i8] c"-w\00"
@.str.5 = [6 x i8] c"lines\00"
@.str.6 = [3 x i8] c"-l\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 i8**, i8*** %5
%7 = getelementptr inbounds i8*, i8** %6, i64 0
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8** %7
%8 = load i32, i32* %4
%9 = icmp sgt i32 %8, 2
br i1 %9, label %10, label %40
10: ; preds = %2
%11 = load i8**, i8*** %5
%12 = getelementptr inbounds i8*, i8** %11, i64 1
%13 = load i8*, i8** %12
%14 = call i32 @strcmp(i8* %13, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%15 = icmp ne i32 %14, 0
br i1 %15, label %19, label %16
16: ; preds = %10
%17 = load i8**, i8*** %5
%18 = getelementptr inbounds i8*, i8** %17, i64 1
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8** %18
br label %39
19: ; preds = %10
%20 = load i8**, i8*** %5
%21 = getelementptr inbounds i8*, i8** %20, i64 1
%22 = load i8*, i8** %21
%23 = call i32 @strcmp(i8* %22, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
%24 = icmp ne i32 %23, 0
br i1 %24, label %28, label %25
25: ; preds = %19
%26 = load i8**, i8*** %5
%27 = getelementptr inbounds i8*, i8** %26, i64 1
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8** %27
br label %38
28: ; preds = %19
%29 = load i8**, i8*** %5
%30 = getelementptr inbounds i8*, i8** %29, i64 1
%31 = load i8*, i8** %30
%32 = call i32 @strcmp(i8* %31, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0))
%33 = icmp ne i32 %32, 0
br i1 %33, label %37, label %34
34: ; preds = %28
%35 = load i8**, i8*** %5
%36 = getelementptr inbounds i8*, i8** %35, i64 1
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i8** %36
br label %37
37: ; preds = %34, %28
br label %38
38: ; preds = %37, %25
br label %39
39: ; preds = %38, %16
br label %40
40: ; preds = %39, %2
%41 = load i8**, i8*** %5
%42 = getelementptr inbounds i8*, i8** %41, i64 0
%43 = load i8*, i8** %42
%44 = load i8**, i8*** %5
%45 = call i32 @execvp(i8* %43, i8** %44)
%46 = load i32, i32* %3
ret i32 %46
}

LLVM IR (-O2):
@.str = [3 x i8] c"wc\00"
@.str.1 = [6 x i8] c"chars\00"
@.str.2 = [3 x i8] c"-c\00"
@.str.3 = [6 x i8] c"words\00"
@.str.4 = [3 x i8] c"-w\00"
@.str.5 = [6 x i8] c"lines\00"
@.str.6 = [3 x i8] c"-l\00"
define i32 @main(i32 %0, i8** %1) {
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8** %1
%3 = icmp sgt i32 %0, 2
br i1 %3, label %4, label %17
4: ; preds = %2
%5 = getelementptr inbounds i8*, i8** %1, i64 1
%6 = load i8*, i8** %5
%7 = tail call i32 @strcmp(i8* dereferenceable(1) %6, i8* dereferenceable(6) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%8 = icmp eq i32 %7, 0
br i1 %8, label %15, label %9
9: ; preds = %4
%10 = tail call i32 @strcmp(i8* dereferenceable(1) %6, i8* dereferenceable(6) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
%11 = icmp eq i32 %10, 0
br i1 %11, label %15, label %12
12: ; preds = %9
%13 = tail call i32 @strcmp(i8* dereferenceable(1) %6, i8* dereferenceable(6) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0))
%14 = icmp eq i32 %13, 0
br i1 %14, label %15, label %17
15: ; preds = %12, %9, %4
%16 = phi i8* [ getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), %4 ], [ getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), %9 ], [ getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), %12 ]
store i8* %16, i8** %5
br label %17
17: ; preds = %15, %12, %2
%18 = tail call i32 @execvp(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8** %1)
ret i32 0
}