#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 EOF;
int EXIT_FAILURE;
int EXIT_SUCCESS;
scalar_t__ ferror(int /*<<< orphan*/);
int fgetc(int /*<<< orphan*/);
int /*<<< orphan*/ fileno(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int fputc(int, int /*<<< orphan*/);
int /*<<< orphan*/ io_error(int /*<<< orphan*/);
scalar_t__ isatty(int /*<<< orphan*/);
scalar_t__ match(char *, char *, char *);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ print_time();
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdin;
int /*<<< orphan*/ stdout;
int /*<<< orphan*/ usage(int /*<<< orphan*/);
int /*<<< orphan*/ version(int /*<<< orphan*/);
int main(int argc, char **argv) {
  int bad_usage = 0;
  for (int i = 1; i < argc; i++) {
    if (match(argv[i], "-v", "--version")) {
      version(stdout);
      return EXIT_SUCCESS;
    }
    if (match(argv[i], "-h", "--help")) {
      usage(stdout);
      return EXIT_SUCCESS;
    }
    bad_usage = 1;
    fprintf(stderr, "Invalid option:\t%s\n", argv[i]);
  }
  if (bad_usage) {
    usage(stderr);
    return EXIT_FAILURE;
  }
  if (isatty(fileno(stdin))) {
    fprintf(stderr, "Warning: input is from TTY\n");
  }
  int last = '\n';
  for (int c = fgetc(stdin); c != EOF; c = fgetc(stdin)) {
    if (last == '\n') {
      print_time();
    }
    if (EOF == fputc(c, stdout)) {
      io_error(stdout);
    }
    last = c;
  }
  if (ferror(stdin)) {
    perror("output error");
    return EXIT_FAILURE;
  }
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x1,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    12b8 <main+0xf8>
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    0xdfd(%rip),%rsi
lea    0xdf9(%rip),%rdx
call   10a0 <match@plt>
cmp    $0x0,%rax
je     1238 <main+0x78>
mov    0x2da0(%rip),%rax
mov    (%rax),%edi
call   1090 <version@plt>
mov    0x2d8a(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    13e7 <main+0x227>
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    0xdc2(%rip),%rsi
lea    0xdbe(%rip),%rdx
call   10a0 <match@plt>
cmp    $0x0,%rax
je     1280 <main+0xc0>
mov    0x2d58(%rip),%rax
mov    (%rax),%edi
call   10b0 <usage@plt>
mov    0x2d42(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    13e7 <main+0x227>
movl   $0x1,-0x14(%rbp)
mov    0x2d42(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    (%rax,%rcx,8),%rdx
lea    0xd74(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    11e4 <main+0x24>
cmpl   $0x0,-0x14(%rbp)
je     12e1 <main+0x121>
mov    0x2d07(%rip),%rax
mov    (%rax),%edi
call   10b0 <usage@plt>
mov    0x2cf1(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    13e7 <main+0x227>
mov    0x2d00(%rip),%rax
mov    (%rax),%edi
call   1080 <fileno@plt>
mov    %eax,%edi
call   1040 <isatty@plt>
cmp    $0x0,%rax
je     1317 <main+0x157>
mov    0x2cc9(%rip),%rax
mov    (%rax),%edi
lea    0xd1b(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
movl   $0xa,-0x1c(%rbp)
mov    0x2cc3(%rip),%rax
mov    (%rax),%edi
call   1050 <fgetc@plt>
mov    %eax,-0x20(%rbp)
mov    -0x20(%rbp),%eax
mov    0x2ca7(%rip),%rcx
cmp    (%rcx),%eax
je     13a6 <main+0x1e6>
cmpl   $0xa,-0x1c(%rbp)
jne    1352 <main+0x192>
mov    $0x0,%al
call   10c0 <print_time@plt>
mov    0x2c87(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x24(%rbp)
mov    -0x20(%rbp),%edi
mov    0x2c58(%rip),%rax
mov    (%rax),%esi
call   1060 <fputc@plt>
mov    %eax,%ecx
mov    -0x24(%rbp),%eax
cmp    %ecx,%eax
jne    138a <main+0x1ca>
mov    0x2c3d(%rip),%rax
mov    (%rax),%edi
call   10e0 <io_error@plt>
mov    -0x20(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    0x2c51(%rip),%rax
mov    (%rax),%edi
call   1050 <fgetc@plt>
mov    %eax,-0x20(%rbp)
jmp    132f <main+0x16f>
mov    0x2c3b(%rip),%rax
mov    (%rax),%edi
call   1030 <ferror@plt>
cmp    $0x0,%rax
je     13db <main+0x21b>
lea    0xc82(%rip),%rdi
call   10d0 <perror@plt>
mov    0x2bf7(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    13e7 <main+0x227>
mov    0x2bd6(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
cmp    $0x2,%edi
jl     1272 <main+0xb2>
mov    %rsi,%rbx
mov    %edi,%r12d
mov    $0x1,%r14d
lea    0xe1c(%rip),%r15
lea    0xe22(%rip),%r13
lea    0xe22(%rip),%rbp
cs nopw 0x0(%rax,%rax,1)
nop
mov    (%rbx,%r14,8),%rdi
lea    0xdf5(%rip),%rsi
mov    %r15,%rdx
call   10a0 <match@plt>
test   %rax,%rax
jne    132c <main+0x16c>
mov    (%rbx,%r14,8),%rdi
lea    0xde6(%rip),%rsi
mov    %r13,%rdx
call   10a0 <match@plt>
test   %rax,%rax
jne    133c <main+0x17c>
mov    0x2d91(%rip),%rax
mov    (%rax),%edi
mov    (%rbx,%r14,8),%rdx
mov    %rbp,%rsi
xor    %eax,%eax
call   1070 <fprintf@plt>
add    $0x1,%r14
cmp    %r14,%r12
jne    1200 <main+0x40>
mov    0x2d71(%rip),%rax
mov    (%rax),%edi
call   10b0 <usage@plt>
mov    0x2d5b(%rip),%rax
jmp    1351 <main+0x191>
mov    0x2d6f(%rip),%r14
mov    (%r14),%edi
call   1080 <fileno@plt>
mov    %eax,%edi
call   1040 <isatty@plt>
test   %rax,%rax
je     12a4 <main+0xe4>
mov    0x2d3c(%rip),%rax
mov    (%rax),%edi
lea    0xd8e(%rip),%rsi
xor    %eax,%eax
call   1070 <fprintf@plt>
mov    (%r14),%edi
call   1050 <fgetc@plt>
mov    0x2d2d(%rip),%r15
mov    (%r15),%ebp
cmp    %ebp,%eax
jne    12d9 <main+0x119>
mov    (%r14),%edi
call   1030 <ferror@plt>
test   %rax,%rax
je     134a <main+0x18a>
lea    0xd75(%rip),%rdi
call   10d0 <perror@plt>
jmp    1266 <main+0xa6>
mov    $0xa,%ebx
mov    0x2cdb(%rip),%r12
jmp    12ff <main+0x13f>
nopw   0x0(%rax,%rax,1)
mov    (%r14),%edi
call   1050 <fgetc@plt>
mov    (%r15),%ebp
cmp    %ebp,%eax
je     12ba <main+0xfa>
mov    %ebx,%ecx
mov    %eax,%ebx
cmp    $0xa,%ecx
jne    1312 <main+0x152>
xor    %eax,%eax
call   10c0 <print_time@plt>
mov    (%r15),%ebp
mov    (%r12),%esi
mov    %ebx,%edi
call   1060 <fputc@plt>
cmp    %eax,%ebp
jne    12f0 <main+0x130>
mov    (%r12),%edi
call   10e0 <io_error@plt>
jmp    12f0 <main+0x130>
mov    0x2c8d(%rip),%rax
mov    (%rax),%edi
call   1090 <version@plt>
jmp    134a <main+0x18a>
mov    0x2c7d(%rip),%rax
mov    (%rax),%edi
call   10b0 <usage@plt>
mov    0x2c67(%rip),%rax
mov    (%rax),%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"-v\00"
@.str.1 = [10 x i8] c"--version\00"
@stdout = global i32 0
@EXIT_SUCCESS = global i32 0
@.str.2 = [3 x i8] c"-h\00"
@.str.3 = [7 x i8] c"--help\00"
@stderr = global i32 0
@.str.4 = [20 x i8] c"Invalid option:\09%s\0A\00"
@EXIT_FAILURE = global i32 0
@stdin = global i32 0
@.str.5 = [28 x i8] c"Warning: input is from TTY\0A\00"
@EOF = global i32 0
@.str.6 = [13 x i8] c"output error\00"
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
%9 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %6
store i32 1, i32* %7
br label %10
10: ; preds = %46, %2
%11 = load i32, i32* %7
%12 = load i32, i32* %4
%13 = icmp slt i32 %11, %12
br i1 %13, label %14, label %49
14: ; preds = %10
%15 = load i8**, i8*** %5
%16 = load i32, i32* %7
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds i8*, i8** %15, i64 %17
%19 = load i8*, i8** %18
%20 = call i64 @match(i8* %19, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0))
%21 = icmp ne i64 %20, 0
br i1 %21, label %22, label %26
22: ; preds = %14
%23 = load i32, i32* @stdout
%24 = call i32 @version(i32 %23)
%25 = load i32, i32* @EXIT_SUCCESS
store i32 %25, i32* %3
br label %99
26: ; preds = %14
%27 = load i8**, i8*** %5
%28 = load i32, i32* %7
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds i8*, i8** %27, i64 %29
%31 = load i8*, i8** %30
%32 = call i64 @match(i8* %31, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
%33 = icmp ne i64 %32, 0
br i1 %33, label %34, label %38
34: ; preds = %26
%35 = load i32, i32* @stdout
%36 = call i32 @usage(i32 %35)
%37 = load i32, i32* @EXIT_SUCCESS
store i32 %37, i32* %3
br label %99
38: ; preds = %26
store i32 1, i32* %6
%39 = load i32, i32* @stderr
%40 = load i8**, i8*** %5
%41 = load i32, i32* %7
%42 = sext i32 %41 to i64
%43 = getelementptr inbounds i8*, i8** %40, i64 %42
%44 = load i8*, i8** %43
%45 = call i32 (i32, i8*, ...) @fprintf(i32 %39, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.4, i64 0, i64 0), i8* %44)
br label %46
46: ; preds = %38
%47 = load i32, i32* %7
%48 = add nsw i32 %47, 1
store i32 %48, i32* %7
br label %10
49: ; preds = %10
%50 = load i32, i32* %6
%51 = icmp ne i32 %50, 0
br i1 %51, label %52, label %56
52: ; preds = %49
%53 = load i32, i32* @stderr
%54 = call i32 @usage(i32 %53)
%55 = load i32, i32* @EXIT_FAILURE
store i32 %55, i32* %3
br label %99
56: ; preds = %49
%57 = load i32, i32* @stdin
%58 = call i32 @fileno(i32 %57)
%59 = call i64 @isatty(i32 %58)
%60 = icmp ne i64 %59, 0
br i1 %60, label %61, label %64
61: ; preds = %56
%62 = load i32, i32* @stderr
%63 = call i32 (i32, i8*, ...) @fprintf(i32 %62, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.5, i64 0, i64 0))
br label %64
64: ; preds = %61, %56
store i32 10, i32* %8
%65 = load i32, i32* @stdin
%66 = call i32 @fgetc(i32 %65)
store i32 %66, i32* %9
br label %67
67: ; preds = %87, %64
%68 = load i32, i32* %9
%69 = load i32, i32* @EOF
%70 = icmp ne i32 %68, %69
br i1 %70, label %71, label %90
71: ; preds = %67
%72 = load i32, i32* %8
%73 = icmp eq i32 %72, 10
br i1 %73, label %74, label %76
74: ; preds = %71
%75 = call i32 (...) @print_time()
br label %76
76: ; preds = %74, %71
%77 = load i32, i32* @EOF
%78 = load i32, i32* %9
%79 = load i32, i32* @stdout
%80 = call i32 @fputc(i32 %78, i32 %79)
%81 = icmp eq i32 %77, %80
br i1 %81, label %82, label %85
82: ; preds = %76
%83 = load i32, i32* @stdout
%84 = call i32 @io_error(i32 %83)
br label %85
85: ; preds = %82, %76
%86 = load i32, i32* %9
store i32 %86, i32* %8
br label %87
87: ; preds = %85
%88 = load i32, i32* @stdin
%89 = call i32 @fgetc(i32 %88)
store i32 %89, i32* %9
br label %67
90: ; preds = %67
%91 = load i32, i32* @stdin
%92 = call i64 @ferror(i32 %91)
%93 = icmp ne i64 %92, 0
br i1 %93, label %94, label %97
94: ; preds = %90
%95 = call i32 @perror(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.6, i64 0, i64 0))
%96 = load i32, i32* @EXIT_FAILURE
store i32 %96, i32* %3
br label %99
97: ; preds = %90
%98 = load i32, i32* @EXIT_SUCCESS
store i32 %98, i32* %3
br label %99
99: ; preds = %97, %94, %52, %34, %22
%100 = load i32, i32* %3
ret i32 %100
}

LLVM IR (-O2):
@.str = [3 x i8] c"-v\00"
@.str.1 = [10 x i8] c"--version\00"
@stdout = global i32 0
@EXIT_SUCCESS = global i32 0
@.str.2 = [3 x i8] c"-h\00"
@.str.3 = [7 x i8] c"--help\00"
@stderr = global i32 0
@.str.4 = [20 x i8] c"Invalid option:\09%s\0A\00"
@EXIT_FAILURE = global i32 0
@stdin = global i32 0
@.str.5 = [28 x i8] c"Warning: input is from TTY\0A\00"
@EOF = global i32 0
@.str.6 = [13 x i8] c"output error\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp sgt i32 %0, 1
br i1 %3, label %4, label %31
4: ; preds = %2
%5 = zext i32 %0 to i64
br label %6
6: ; preds = %4, %22
%7 = phi i64 [ 1, %4 ], [ %26, %22 ]
%8 = getelementptr inbounds i8*, i8** %1, i64 %7
%9 = load i8*, i8** %8
%10 = tail call i64 @match(i8* %9, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0))
%11 = icmp eq i64 %10, 0
br i1 %11, label %15, label %12
12: ; preds = %6
%13 = load i32, i32* @stdout
%14 = tail call i32 @version(i32 %13)
br label %71
15: ; preds = %6
%16 = load i8*, i8** %8
%17 = tail call i64 @match(i8* %16, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
%18 = icmp eq i64 %17, 0
br i1 %18, label %22, label %19
19: ; preds = %15
%20 = load i32, i32* @stdout
%21 = tail call i32 @usage(i32 %20)
br label %71
22: ; preds = %15
%23 = load i32, i32* @stderr
%24 = load i8*, i8** %8
%25 = tail call i32 (i32, i8*, ...) @fprintf(i32 %23, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.4, i64 0, i64 0), i8* %24)
%26 = add nuw nsw i64 %7, 1
%27 = icmp eq i64 %26, %5
br i1 %27, label %28, label %6
28: ; preds = %22
%29 = load i32, i32* @stderr
%30 = tail call i32 @usage(i32 %29)
br label %71
31: ; preds = %2
%32 = load i32, i32* @stdin
%33 = tail call i32 @fileno(i32 %32)
%34 = tail call i64 @isatty(i32 %33)
%35 = icmp eq i64 %34, 0
br i1 %35, label %39, label %36
36: ; preds = %31
%37 = load i32, i32* @stderr
%38 = tail call i32 (i32, i8*, ...) @fprintf(i32 %37, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.5, i64 0, i64 0))
br label %39
39: ; preds = %36, %31
%40 = load i32, i32* @stdin
%41 = tail call i32 @fgetc(i32 %40)
%42 = load i32, i32* @EOF
%43 = icmp eq i32 %41, %42
br i1 %43, label %44, label %48
44: ; preds = %64, %39
%45 = load i32, i32* @stdin
%46 = tail call i64 @ferror(i32 %45)
%47 = icmp eq i64 %46, 0
br i1 %47, label %71, label %69
48: ; preds = %39, %64
%49 = phi i32 [ %67, %64 ], [ %42, %39 ]
%50 = phi i32 [ %66, %64 ], [ %41, %39 ]
%51 = phi i32 [ %50, %64 ], [ 10, %39 ]
%52 = icmp eq i32 %51, 10
br i1 %52, label %53, label %56
53: ; preds = %48
%54 = tail call i32 (...) @print_time()
%55 = load i32, i32* @EOF
br label %56
56: ; preds = %53, %48
%57 = phi i32 [ %55, %53 ], [ %49, %48 ]
%58 = load i32, i32* @stdout
%59 = tail call i32 @fputc(i32 %50, i32 %58)
%60 = icmp eq i32 %57, %59
br i1 %60, label %61, label %64
61: ; preds = %56
%62 = load i32, i32* @stdout
%63 = tail call i32 @io_error(i32 %62)
br label %64
64: ; preds = %61, %56
%65 = load i32, i32* @stdin
%66 = tail call i32 @fgetc(i32 %65)
%67 = load i32, i32* @EOF
%68 = icmp eq i32 %66, %67
br i1 %68, label %44, label %48
69: ; preds = %44
%70 = tail call i32 @perror(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.6, i64 0, i64 0))
br label %71
71: ; preds = %69, %44, %19, %12, %28
%72 = phi i32* [ @EXIT_FAILURE, %28 ], [ @EXIT_SUCCESS, %19 ], [ @EXIT_SUCCESS, %12 ], [ @EXIT_FAILURE, %69 ], [ @EXIT_SUCCESS, %44 ]
%73 = load i32, i32* %72
ret i32 %73
}