#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ do_cat(int /*<<< orphan*/ *, int);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int getopt(int, char **, char *);
scalar_t__ optind;
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ *stdin;
int main(int argc, char *argv[]) {
  int opt;
  int escape = 0;
  int i;
  while ((opt = getopt(argc, argv, "e")) != -1) {
    switch (opt) {
    case 'e':
      escape = 1;
      break;
    case '?':
      fprintf(stderr, "Usage: %s [-e] [file...]\n", argv[0]);
      exit(1);
    }
  }
  argc -= optind;
  argv += optind;
  if (argc == 0) {
    do_cat(stdin, escape);
  } else {
    for (i = 0; i < argc; i++) {
      FILE *f;
      f = fopen(argv[i], "r");
      if (!f) {
        perror(argv[i]);
        exit(1);
      }
      do_cat(f, escape);
      fclose(f);
    }
  }
  exit(0);
}


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,-0x18(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xe65(%rip),%rdx
call   1080 <getopt@plt>
mov    %eax,-0x14(%rbp)
cmp    $0xffffffff,%eax
je     1208 <main+0x98>
mov    -0x14(%rbp),%eax
mov    %eax,-0x2c(%rbp)
sub    $0x3f,%eax
je     11dd <main+0x6d>
jmp    11c0 <main+0x50>
mov    -0x2c(%rbp),%eax
sub    $0x65,%eax
jne    1203 <main+0x93>
jmp    11d1 <main+0x61>
movl   $0x1,-0x18(%rbp)
jmp    1203 <main+0x93>
mov    0x2dec(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe0e(%rip),%rsi
call   1050 <fprintf@plt>
mov    $0x1,%edi
call   1090 <exit@plt>
jmp    118d <main+0x1d>
mov    0x2dd1(%rip),%rax
mov    (%rax),%rcx
movslq -0x8(%rbp),%rax
sub    %rcx,%rax
mov    %eax,-0x8(%rbp)
mov    0x2dbd(%rip),%rax
mov    (%rax),%rax
shl    $0x3,%rax
add    -0x10(%rbp),%rax
mov    %rax,-0x10(%rbp)
cmpl   $0x0,-0x8(%rbp)
jne    1253 <main+0xe3>
mov    0x2da5(%rip),%rax
mov    (%rax),%rdi
mov    -0x18(%rbp),%esi
call   1030 <do_cat@plt>
jmp    12d0 <main+0x160>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    12cb <main+0x15b>
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    0xda3(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    12a8 <main+0x138>
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1070 <perror@plt>
mov    $0x1,%edi
call   1090 <exit@plt>
mov    -0x28(%rbp),%rdi
mov    -0x18(%rbp),%esi
call   1030 <do_cat@plt>
mov    -0x28(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    125a <main+0xea>
jmp    12d0 <main+0x160>
xor    %edi,%edi
call   1090 <exit@plt>

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
xor    %r14d,%r14d
lea    0xe76(%rip),%r15
jmp    11a0 <main+0x30>
mov    $0x1,%r14d
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %r15,%rdx
call   1080 <getopt@plt>
cmp    $0x65,%eax
je     118c <main+0x1c>
cmp    $0xffffffff,%eax
je     11de <main+0x6e>
cmp    $0x3f,%eax
jne    11a0 <main+0x30>
mov    0x2e0d(%rip),%rax
mov    (%rax),%edi
mov    (%rbx),%rdx
lea    0xe33(%rip),%rsi
call   1050 <fprintf@plt>
mov    $0x1,%edi
call   1090 <exit@plt>
mov    0x2dfb(%rip),%rax
mov    (%rax),%rax
sub    %eax,%ebp
jne    1205 <main+0x95>
mov    0x2df5(%rip),%rax
mov    (%rax),%rdi
mov    %r14d,%esi
call   1030 <do_cat@plt>
xor    %edi,%edi
call   1090 <exit@plt>
test   %ebp,%ebp
jle    1250 <main+0xe0>
lea    (%rbx,%rax,8),%r12
mov    %ebp,%r13d
xor    %ebx,%ebx
lea    0xe03(%rip),%r15
nopl   0x0(%rax)
mov    (%r12,%rbx,8),%rdi
mov    %r15,%rsi
call   1060 <fopen@plt>
test   %rax,%rax
je     1257 <main+0xe7>
mov    %rax,%rbp
mov    %rax,%rdi
mov    %r14d,%esi
call   1030 <do_cat@plt>
mov    %rbp,%rdi
call   1040 <fclose@plt>
add    $0x1,%rbx
cmp    %rbx,%r13
jne    1220 <main+0xb0>
xor    %edi,%edi
call   1090 <exit@plt>
mov    (%r12,%rbx,8),%rdi
call   1070 <perror@plt>
mov    $0x1,%edi
call   1090 <exit@plt>

LLVM IR (-O0):
@.str = [2 x i8] c"e\00"
@stderr = global i32 0
@.str.1 = [26 x i8] c"Usage: %s [-e] [file...]\0A\00"
@optind = global i64 0
@stdin = global i32* null
@.str.2 = [2 x i8] c"r\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* %7
br label %10
10: ; preds = %25, %2
%11 = load i32, i32* %4
%12 = load i8**, i8*** %5
%13 = call i32 @getopt(i32 %11, i8** %12, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32 %13, i32* %6
%14 = icmp ne i32 %13, -1
br i1 %14, label %15, label %26
15: ; preds = %10
%16 = load i32, i32* %6
switch i32 %16, label %25 [
i32 101, label %17
i32 63, label %18
]
17: ; preds = %15
store i32 1, i32* %7
br label %25
18: ; preds = %15
%19 = load i32, i32* @stderr
%20 = load i8**, i8*** %5
%21 = getelementptr inbounds i8*, i8** %20, i64 0
%22 = load i8*, i8** %21
%23 = call i32 @fprintf(i32 %19, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0), i8* %22)
%24 = call i32 @exit(i32 1)
unreachable
25: ; preds = %15, %17
br label %10
26: ; preds = %10
%27 = load i64, i64* @optind
%28 = load i32, i32* %4
%29 = sext i32 %28 to i64
%30 = sub nsw i64 %29, %27
%31 = trunc i64 %30 to i32
store i32 %31, i32* %4
%32 = load i64, i64* @optind
%33 = load i8**, i8*** %5
%34 = getelementptr inbounds i8*, i8** %33, i64 %32
store i8** %34, i8*** %5
%35 = load i32, i32* %4
%36 = icmp eq i32 %35, 0
br i1 %36, label %37, label %41
37: ; preds = %26
%38 = load i32*, i32** @stdin
%39 = load i32, i32* %7
%40 = call i32 @do_cat(i32* %38, i32 %39)
br label %73
41: ; preds = %26
store i32 0, i32* %8
br label %42
42: ; preds = %69, %41
%43 = load i32, i32* %8
%44 = load i32, i32* %4
%45 = icmp slt i32 %43, %44
br i1 %45, label %46, label %72
46: ; preds = %42
%47 = load i8**, i8*** %5
%48 = load i32, i32* %8
%49 = sext i32 %48 to i64
%50 = getelementptr inbounds i8*, i8** %47, i64 %49
%51 = load i8*, i8** %50
%52 = call i32* @fopen(i8* %51, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i32* %52, i32** %9
%53 = load i32*, i32** %9
%54 = icmp ne i32* %53, null
br i1 %54, label %63, label %55
55: ; preds = %46
%56 = load i8**, i8*** %5
%57 = load i32, i32* %8
%58 = sext i32 %57 to i64
%59 = getelementptr inbounds i8*, i8** %56, i64 %58
%60 = load i8*, i8** %59
%61 = call i32 @perror(i8* %60)
%62 = call i32 @exit(i32 1)
unreachable
63: ; preds = %46
%64 = load i32*, i32** %9
%65 = load i32, i32* %7
%66 = call i32 @do_cat(i32* %64, i32 %65)
%67 = load i32*, i32** %9
%68 = call i32 @fclose(i32* %67)
br label %69
69: ; preds = %63
%70 = load i32, i32* %8
%71 = add nsw i32 %70, 1
store i32 %71, i32* %8
br label %42
72: ; preds = %42
br label %73
73: ; preds = %72, %37
%74 = call i32 @exit(i32 0)
unreachable
}

LLVM IR (-O2):
@.str = [2 x i8] c"e\00"
@stderr = global i32 0
@.str.1 = [26 x i8] c"Usage: %s [-e] [file...]\0A\00"
@optind = global i64 0
@stdin = global i32* null
@.str.2 = [2 x i8] c"r\00"
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 = %3, %5
%6 = tail call i32 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
switch i32 %6, label %5 [
i32 -1, label %12
i32 101, label %3
i32 63, label %7
]
7: ; preds = %5
%8 = load i32, i32* @stderr
%9 = load i8*, i8** %1
%10 = tail call i32 @fprintf(i32 %8, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0), i8* %9)
%11 = tail call i32 @exit(i32 1)
unreachable
12: ; preds = %5
%13 = load i64, i64* @optind
%14 = trunc i64 %13 to i32
%15 = sub i32 %0, %14
%16 = getelementptr inbounds i8*, i8** %1, i64 %13
%17 = icmp eq i32 %15, 0
br i1 %17, label %22, label %18
18: ; preds = %12
%19 = icmp sgt i32 %15, 0
br i1 %19, label %20, label %42
20: ; preds = %18
%21 = zext i32 %15 to i64
br label %25
22: ; preds = %12
%23 = load i32*, i32** @stdin
%24 = tail call i32 @do_cat(i32* %23, i32 %4)
br label %42
25: ; preds = %20, %37
%26 = phi i64 [ 0, %20 ], [ %40, %37 ]
%27 = getelementptr inbounds i8*, i8** %16, i64 %26
%28 = load i8*, i8** %27
%29 = tail call i32* @fopen(i8* %28, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%30 = icmp eq i32* %29, null
br i1 %30, label %31, label %37
31: ; preds = %25
%32 = and i64 %26, 4294967295
%33 = getelementptr inbounds i8*, i8** %16, i64 %32
%34 = load i8*, i8** %33
%35 = tail call i32 @perror(i8* %34)
%36 = tail call i32 @exit(i32 1)
unreachable
37: ; preds = %25
%38 = tail call i32 @do_cat(i32* %29, i32 %4)
%39 = tail call i32 @fclose(i32* %29)
%40 = add nuw nsw i64 %26, 1
%41 = icmp eq i64 %40, %21
br i1 %41, label %42, label %25
42: ; preds = %37, %18, %22
%43 = tail call i32 @exit(i32 0)
unreachable
}