#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*/ fprintf(int /*<<< orphan*/, char *, char *);
int getopt(int, char **, char *);
int /*<<< orphan*/ help();
int optind;
int /*<<< orphan*/ show_ver();
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ tee(char *, int);
int main(int argc, char *argv[]) {
  int c;
  int flag = 0;
  while ((c = getopt(argc, argv, "ahv")) != -1) {
    switch (c) {
    case 'h':
      help();
      break;
    case 'a':
      flag = 1;
      break;
    case 'v':
      show_ver();
      break;
    default:
      fprintf(stderr, "usage: %s -ha\n", argv[0]);
      help();
    }
  }
  if (optind < argc) {
    tee(argv[optind], flag);
  } else {
    tee(NULL, flag);
  }
  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)
movl   $0x0,-0x18(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xe85(%rip),%rdx
call   1060 <getopt@plt>
mov    %eax,-0x14(%rbp)
cmp    $0xffffffff,%eax
je     120e <main+0xbe>
mov    -0x14(%rbp),%eax
mov    %eax,-0x1c(%rbp)
sub    $0x61,%eax
je     11ce <main+0x7e>
jmp    11a0 <main+0x50>
mov    -0x1c(%rbp),%eax
sub    $0x68,%eax
je     11c2 <main+0x72>
jmp    11b1 <main+0x61>
mov    -0x1c(%rbp),%eax
sub    $0x76,%eax
je     11da <main+0x8a>
jmp    11e6 <main+0x96>
mov    $0x0,%al
call   1070 <help@plt>
jmp    1209 <main+0xb9>
movl   $0x1,-0x18(%rbp)
jmp    1209 <main+0xb9>
mov    $0x0,%al
call   1050 <show_ver@plt>
jmp    1209 <main+0xb9>
mov    0x2deb(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe07(%rip),%rsi
call   1030 <fprintf@plt>
mov    $0x0,%al
call   1070 <help@plt>
jmp    116d <main+0x1d>
mov    0x2dd3(%rip),%rax
mov    (%rax),%eax
cmp    -0x8(%rbp),%eax
jge    123f <main+0xef>
mov    -0x10(%rbp),%rax
mov    0x2dbd(%rip),%rcx
movslq (%rcx),%rcx
mov    (%rax,%rcx,8),%rdi
mov    -0x18(%rbp),%esi
call   1040 <tee@plt>
jmp    124b <main+0xfb>
mov    -0x18(%rbp),%esi
xor    %eax,%eax
mov    %eax,%edi
call   1040 <tee@plt>
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,%rbx
mov    %edi,%ebp
lea    0xe99(%rip),%r15
mov    0x2e6a(%rip),%r13
lea    0xe8f(%rip),%r12
xor    %r14d,%r14d
jmp    1196 <main+0x46>
nopw   0x0(%rax,%rax,1)
mov    0x0(%r13),%edi
mov    (%rbx),%rdx
mov    %r12,%rsi
call   1030 <fprintf@plt>
xor    %eax,%eax
call   1070 <help@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %r15,%rdx
call   1060 <getopt@plt>
cmp    $0x75,%eax
jg     11c0 <main+0x70>
cmp    $0x68,%eax
je     118f <main+0x3f>
cmp    $0xffffffff,%eax
je     11ce <main+0x7e>
cmp    $0x61,%eax
jne    1180 <main+0x30>
mov    $0x1,%r14d
jmp    1196 <main+0x46>
nop
cmp    $0x76,%eax
jne    1180 <main+0x30>
xor    %eax,%eax
call   1050 <show_ver@plt>
jmp    1196 <main+0x46>
mov    0x2e13(%rip),%rax
movslq (%rax),%rax
cmp    %ebp,%eax
jge    11e2 <main+0x92>
mov    (%rbx,%rax,8),%rdi
jmp    11e4 <main+0x94>
xor    %edi,%edi
mov    %r14d,%esi
call   1040 <tee@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [4 x i8] c"ahv\00"
@stderr = global i32 0
@.str.1 = [15 x i8] c"usage: %s -ha\0A\00"
@optind = 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
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %7
br label %8
8: ; preds = %27, %2
%9 = load i32, i32* %4
%10 = load i8**, i8*** %5
%11 = call i32 @getopt(i32 %9, i8** %10, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
store i32 %11, i32* %6
%12 = icmp ne i32 %11, -1
br i1 %12, label %13, label %28
13: ; preds = %8
%14 = load i32, i32* %6
switch i32 %14, label %20 [
i32 104, label %15
i32 97, label %17
i32 118, label %18
]
15: ; preds = %13
%16 = call i32 (...) @help()
br label %27
17: ; preds = %13
store i32 1, i32* %7
br label %27
18: ; preds = %13
%19 = call i32 (...) @show_ver()
br label %27
20: ; preds = %13
%21 = load i32, i32* @stderr
%22 = load i8**, i8*** %5
%23 = getelementptr inbounds i8*, i8** %22, i64 0
%24 = load i8*, i8** %23
%25 = call i32 @fprintf(i32 %21, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i8* %24)
%26 = call i32 (...) @help()
br label %27
27: ; preds = %20, %18, %17, %15
br label %8
28: ; preds = %8
%29 = load i32, i32* @optind
%30 = load i32, i32* %4
%31 = icmp slt i32 %29, %30
br i1 %31, label %32, label %40
32: ; preds = %28
%33 = load i8**, i8*** %5
%34 = load i32, i32* @optind
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds i8*, i8** %33, i64 %35
%37 = load i8*, i8** %36
%38 = load i32, i32* %7
%39 = call i32 @tee(i8* %37, i32 %38)
br label %43
40: ; preds = %28
%41 = load i32, i32* %7
%42 = call i32 @tee(i8* null, i32 %41)
br label %43
43: ; preds = %40, %32
ret i32 0
}

LLVM IR (-O2):
@.str = [4 x i8] c"ahv\00"
@stderr = global i32 0
@.str.1 = [15 x i8] c"usage: %s -ha\0A\00"
@optind = global i32 0
define i32 @main(i32 %0, i8** %1) {
br label %3
3: ; preds = %5, %2
%4 = phi i32 [ 0, %2 ], [ 1, %5 ]
br label %5
5: ; preds = %16, %3
%6 = tail call i32 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
switch i32 %6, label %11 [
i32 -1, label %17
i32 104, label %7
i32 97, label %3
i32 118, label %9
]
7: ; preds = %5
%8 = tail call i32 (...) @help()
br label %16
9: ; preds = %5
%10 = tail call i32 (...) @show_ver()
br label %16
11: ; preds = %5
%12 = load i32, i32* @stderr
%13 = load i8*, i8** %1
%14 = tail call i32 @fprintf(i32 %12, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i8* %13)
%15 = tail call i32 (...) @help()
br label %16
16: ; preds = %11, %9, %7
br label %5
17: ; preds = %5
%18 = load i32, i32* @optind
%19 = icmp slt i32 %18, %0
br i1 %19, label %20, label %24
20: ; preds = %17
%21 = sext i32 %18 to i64
%22 = getelementptr inbounds i8*, i8** %1, i64 %21
%23 = load i8*, i8** %22
br label %24
24: ; preds = %17, %20
%25 = phi i8* [ %23, %20 ], [ null, %17 ]
%26 = tail call i32 @tee(i8* %25, i32 %4)
ret i32 0
}