#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*/ buffer;

/* Variables and functions */
int /*<<< orphan*/ *fgets(char *, int, int /*<<< orphan*/);
scalar_t__ printFile(char *, char *);
int /*<<< orphan*/ stdin;
int main(int argc, char **argv) {
  int done = 0;
  char contents[10000];
  for (int i = 1; i < argc; ++i) {
    if (printFile(*(argv + i), contents)) {
      return 1;
    }
    done = 1;
  }
  if (done) {
    return 0;
  }
  char buffer[100];
  while (NULL != fgets(buffer, sizeof(buffer), stdin)) {
    if (printFile(buffer, contents)) {
      return 1;
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x27a0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x1,-0x2734(%rbp)
mov    -0x2734(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11a5 <main+0x85>
mov    -0x10(%rbp),%rax
movslq -0x2734(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    -0x2730(%rbp),%rsi
call   1030 <printFile@plt>
cmp    $0x0,%rax
je     118a <main+0x6a>
movl   $0x1,-0x4(%rbp)
jmp    121d <main+0xfd>
movl   $0x1,-0x14(%rbp)
mov    -0x2734(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2734(%rbp)
jmp    114a <main+0x2a>
cmpl   $0x0,-0x14(%rbp)
je     11bb <main+0x9b>
movl   $0x0,-0x4(%rbp)
jmp    121d <main+0xfd>
jmp    11c0 <main+0xa0>
lea    -0x27a0(%rbp),%rdi
mov    0x2e1a(%rip),%rax
mov    (%rax),%edx
mov    $0x64,%esi
call   1040 <fgets@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
je     1216 <main+0xf6>
lea    -0x27a0(%rbp),%rdi
lea    -0x2730(%rbp),%rsi
call   1030 <printFile@plt>
cmp    $0x0,%rax
je     1211 <main+0xf1>
movl   $0x1,-0x4(%rbp)
jmp    121d <main+0xfd>
jmp    11c0 <main+0xa0>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x27a0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x2788,%rsp
mov    %edi,%r15d
xor    %r14d,%r14d
mov    $0x0,%eax
cmp    $0x2,%edi
jl     117e <main+0x5e>
mov    %rsi,%r13
mov    %r15d,%ebp
mov    $0x1,%ebx
lea    0x70(%rsp),%r12
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    0x0(%r13,%rbx,8),%rdi
mov    %r12,%rsi
call   1030 <printFile@plt>
test   %rax,%rax
jne    11c5 <main+0xa5>
add    $0x1,%rbx
cmp    %rbx,%rbp
jne    1160 <main+0x40>
seta   %al
cmp    $0x1,%r15d
jg     11d0 <main+0xb0>
test   %al,%al
jne    11d0 <main+0xb0>
mov    0x2e59(%rip),%r14
mov    %rsp,%rbx
lea    0x70(%rsp),%rbp
nopw   0x0(%rax,%rax,1)
mov    (%r14),%edx
mov    %rbx,%rdi
mov    $0x64,%esi
call   1040 <fgets@plt>
test   %rax,%rax
je     11cd <main+0xad>
mov    %rbx,%rdi
mov    %rbp,%rsi
call   1030 <printFile@plt>
test   %rax,%rax
je     11a0 <main+0x80>
mov    $0x1,%r14d
jmp    11d0 <main+0xb0>
xor    %r14d,%r14d
mov    %r14d,%eax
add    $0x2788,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@stdin = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca [10000 x i8]
%8 = alloca i32
%9 = alloca [100 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %6
store i32 1, i32* %8
br label %10
10: ; preds = %25, %2
%11 = load i32, i32* %8
%12 = load i32, i32* %4
%13 = icmp slt i32 %11, %12
br i1 %13, label %14, label %28
14: ; preds = %10
%15 = load i8**, i8*** %5
%16 = load i32, i32* %8
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds i8*, i8** %15, i64 %17
%19 = load i8*, i8** %18
%20 = getelementptr inbounds [10000 x i8], [10000 x i8]* %7, i64 0, i64 0
%21 = call i64 @printFile(i8* %19, i8* %20)
%22 = icmp ne i64 %21, 0
br i1 %22, label %23, label %24
23: ; preds = %14
store i32 1, i32* %3
br label %46
24: ; preds = %14
store i32 1, i32* %6
br label %25
25: ; preds = %24
%26 = load i32, i32* %8
%27 = add nsw i32 %26, 1
store i32 %27, i32* %8
br label %10
28: ; preds = %10
%29 = load i32, i32* %6
%30 = icmp ne i32 %29, 0
br i1 %30, label %31, label %32
31: ; preds = %28
store i32 0, i32* %3
br label %46
32: ; preds = %28
br label %33
33: ; preds = %44, %32
%34 = getelementptr inbounds [100 x i8], [100 x i8]* %9, i64 0, i64 0
%35 = load i32, i32* @stdin
%36 = call i32* @fgets(i8* %34, i32 100, i32 %35)
%37 = icmp ne i32* null, %36
br i1 %37, label %38, label %45
38: ; preds = %33
%39 = getelementptr inbounds [100 x i8], [100 x i8]* %9, i64 0, i64 0
%40 = getelementptr inbounds [10000 x i8], [10000 x i8]* %7, i64 0, i64 0
%41 = call i64 @printFile(i8* %39, i8* %40)
%42 = icmp ne i64 %41, 0
br i1 %42, label %43, label %44
43: ; preds = %38
store i32 1, i32* %3
br label %46
44: ; preds = %38
br label %33
45: ; preds = %33
store i32 0, i32* %3
br label %46
46: ; preds = %45, %43, %31, %23
%47 = load i32, i32* %3
ret i32 %47
}

LLVM IR (-O2):
@stdin = global i32 0
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [10000 x i8]
%4 = alloca [100 x i8]
%5 = getelementptr inbounds [10000 x i8], [10000 x i8]* %3, i64 0, i64 0
%6 = icmp sgt i32 %0, 1
br i1 %6, label %7, label %21
7: ; preds = %2
%8 = zext i32 %0 to i64
%9 = zext i32 %0 to i64
br label %12
10: ; preds = %12
%11 = icmp eq i64 %18, %9
br i1 %11, label %19, label %12
12: ; preds = %7, %10
%13 = phi i64 [ 1, %7 ], [ %18, %10 ]
%14 = getelementptr inbounds i8*, i8** %1, i64 %13
%15 = load i8*, i8** %14
%16 = call i64 @printFile(i8* %15, i8* %5)
%17 = icmp eq i64 %16, 0
%18 = add nuw nsw i64 %13, 1
br i1 %17, label %10, label %35
19: ; preds = %10
%20 = icmp ult i64 %18, %8
br label %21
21: ; preds = %19, %2
%22 = phi i1 [ false, %2 ], [ %20, %19 ]
%23 = or i1 %6, %22
br i1 %23, label %35, label %24
24: ; preds = %21
%25 = getelementptr inbounds [100 x i8], [100 x i8]* %4, i64 0, i64 0
br label %26
26: ; preds = %30, %24
%27 = load i32, i32* @stdin
%28 = call i32* @fgets(i8* %25, i32 100, i32 %27)
%29 = icmp eq i32* %28, null
br i1 %29, label %33, label %30
30: ; preds = %26
%31 = call i64 @printFile(i8* %25, i8* %5)
%32 = icmp eq i64 %31, 0
br i1 %32, label %26, label %33
33: ; preds = %26, %30
%34 = phi i32 [ 1, %30 ], [ 0, %26 ]
br label %35
35: ; preds = %12, %21, %33
%36 = phi i32 [ %34, %33 ], [ 0, %21 ], [ 1, %12 ]
ret i32 %36
}