#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);
int open(char *, int /*<<< orphan*/);
int /*<<< orphan*/ perror(int /*<<< orphan*/ *);
int /*<<< orphan*/ printfile(int, size_t);
scalar_t__ strcmp(char *, char *);
int main(int argc, char **argv) {
  size_t bufoff = 0;
  if (argc > 1 && strcmp(argv[1], "-u") == 0) {
    bufoff = 1;
  }
  if (argc == 1 + bufoff) {
    printfile(0, bufoff);
  } else {
    size_t ind;
    for (ind = 1 + bufoff; ind < argc; ++ind) {
      int file = open(argv[ind], O_RDONLY);
      if (file == -1) {
        perror(NULL);
      } else {
        printfile(file, bufoff);
        close(file);
      }
    }
  }
  return 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)
movq   $0x0,-0x18(%rbp)
cmpl   $0x1,-0x8(%rbp)
jle    119e <main+0x4e>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe79(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jne    119e <main+0x4e>
movq   $0x1,-0x18(%rbp)
movslq -0x8(%rbp),%rax
mov    -0x18(%rbp),%rcx
add    $0x1,%rcx
cmp    %rcx,%rax
jne    11c3 <main+0x73>
mov    -0x18(%rbp),%rsi
xor    %edi,%edi
call   1030 <printfile@plt>
jmp    1244 <main+0xf4>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
movslq -0x8(%rbp),%rcx
cmp    %rcx,%rax
jae    123f <main+0xef>
mov    -0x10(%rbp),%rax
mov    -0x20(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
mov    0x2df5(%rip),%rax
mov    (%rax),%esi
call   1060 <open@plt>
mov    %eax,-0x24(%rbp)
cmpl   $0xffffffff,-0x24(%rbp)
jne    1215 <main+0xc5>
xor    %eax,%eax
mov    %eax,%edi
call   1070 <perror@plt>
jmp    1229 <main+0xd9>
mov    -0x24(%rbp),%edi
mov    -0x18(%rbp),%rsi
call   1030 <printfile@plt>
mov    -0x24(%rbp),%edi
call   1040 <close@plt>
jmp    122e <main+0xde>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    11cf <main+0x7f>
jmp    1244 <main+0xf4>
xor    %eax,%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
mov    %rsi,%r14
mov    %edi,%ebp
cmp    $0x2,%edi
jl     1181 <main+0x31>
mov    0x8(%r14),%rdi
lea    0xe90(%rip),%rsi
call   1050 <strcmp@plt>
xor    %r15d,%r15d
test   %rax,%rax
sete   %r15b
jmp    1184 <main+0x34>
xor    %r15d,%r15d
movslq %ebp,%r12
lea    0x1(%r15),%rbx
cmp    %r12,%rbx
jne    119c <main+0x4c>
xor    %edi,%edi
mov    %r15,%rsi
call   1030 <printfile@plt>
jmp    11e9 <main+0x99>
jae    11e9 <main+0x99>
mov    0x2e43(%rip),%r13
cs nopw 0x0(%rax,%rax,1)
nop
mov    (%r14,%rbx,8),%rdi
mov    0x0(%r13),%esi
call   1060 <open@plt>
cmp    $0xffffffff,%eax
je     11e0 <main+0x90>
mov    %eax,%ebp
mov    %eax,%edi
mov    %r15,%rsi
call   1030 <printfile@plt>
mov    %ebp,%edi
call   1040 <close@plt>
add    $0x1,%rbx
cmp    %rbx,%r12
jne    11b0 <main+0x60>
jmp    11e9 <main+0x99>
xor    %edi,%edi
call   1070 <perror@plt>
jmp    11d5 <main+0x85>
xor    %eax,%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"-u\00"
@O_RDONLY = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i64
%7 = alloca i64
%8 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i64 0, i64* %6
%9 = load i32, i32* %4
%10 = icmp sgt i32 %9, 1
br i1 %10, label %11, label %18
11: ; preds = %2
%12 = load i8**, i8*** %5
%13 = getelementptr inbounds i8*, i8** %12, i64 1
%14 = load i8*, i8** %13
%15 = call i64 @strcmp(i8* %14, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%16 = icmp eq i64 %15, 0
br i1 %16, label %17, label %18
17: ; preds = %11
store i64 1, i64* %6
br label %18
18: ; preds = %17, %11, %2
%19 = load i32, i32* %4
%20 = sext i32 %19 to i64
%21 = load i64, i64* %6
%22 = add i64 1, %21
%23 = icmp eq i64 %20, %22
br i1 %23, label %24, label %27
24: ; preds = %18
%25 = load i64, i64* %6
%26 = call i32 @printfile(i32 0, i64 %25)
br label %57
27: ; preds = %18
%28 = load i64, i64* %6
%29 = add i64 1, %28
store i64 %29, i64* %7
br label %30
30: ; preds = %53, %27
%31 = load i64, i64* %7
%32 = load i32, i32* %4
%33 = sext i32 %32 to i64
%34 = icmp ult i64 %31, %33
br i1 %34, label %35, label %56
35: ; preds = %30
%36 = load i8**, i8*** %5
%37 = load i64, i64* %7
%38 = getelementptr inbounds i8*, i8** %36, i64 %37
%39 = load i8*, i8** %38
%40 = load i32, i32* @O_RDONLY
%41 = call i32 @open(i8* %39, i32 %40)
store i32 %41, i32* %8
%42 = load i32, i32* %8
%43 = icmp eq i32 %42, -1
br i1 %43, label %44, label %46
44: ; preds = %35
%45 = call i32 @perror(i32* null)
br label %52
46: ; preds = %35
%47 = load i32, i32* %8
%48 = load i64, i64* %6
%49 = call i32 @printfile(i32 %47, i64 %48)
%50 = load i32, i32* %8
%51 = call i32 @close(i32 %50)
br label %52
52: ; preds = %46, %44
br label %53
53: ; preds = %52
%54 = load i64, i64* %7
%55 = add i64 %54, 1
store i64 %55, i64* %7
br label %30
56: ; preds = %30
br label %57
57: ; preds = %56, %24
ret i32 0
}

LLVM IR (-O2):
@.str = [3 x i8] c"-u\00"
@O_RDONLY = global i32 0
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp sgt i32 %0, 1
br i1 %3, label %4, label %10
4: ; preds = %2
%5 = getelementptr inbounds i8*, i8** %1, i64 1
%6 = load i8*, i8** %5
%7 = tail call i64 @strcmp(i8* %6, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%8 = icmp eq i64 %7, 0
%9 = zext i1 %8 to i64
br label %10
10: ; preds = %4, %2
%11 = phi i64 [ 0, %2 ], [ %9, %4 ]
%12 = sext i32 %0 to i64
%13 = add nuw nsw i64 %11, 1
%14 = icmp eq i64 %13, %12
br i1 %14, label %17, label %15
15: ; preds = %10
%16 = icmp ult i64 %13, %12
br i1 %16, label %19, label %34
17: ; preds = %10
%18 = tail call i32 @printfile(i32 0, i64 %11)
br label %34
19: ; preds = %15, %31
%20 = phi i64 [ %32, %31 ], [ %13, %15 ]
%21 = getelementptr inbounds i8*, i8** %1, i64 %20
%22 = load i8*, i8** %21
%23 = load i32, i32* @O_RDONLY
%24 = tail call i32 @open(i8* %22, i32 %23)
%25 = icmp eq i32 %24, -1
br i1 %25, label %26, label %28
26: ; preds = %19
%27 = tail call i32 @perror(i32* null)
br label %31
28: ; preds = %19
%29 = tail call i32 @printfile(i32 %24, i64 %11)
%30 = tail call i32 @close(i32 %24)
br label %31
31: ; preds = %28, %26
%32 = add i64 %20, 1
%33 = icmp eq i64 %32, %12
br i1 %33, label %34, label %19
34: ; preds = %31, %15, %17
ret i32 0
}