#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*/ ProcessFile(char *, int /*<<< orphan*/ *);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ *stdin;
int /*<<< orphan*/ usage();
int main(int argc, char **argv) {
  FILE *f = NULL;
  int argn;
  if (argc == 0)
    usage();
  if (argc == 1)
    ProcessFile(NULL, stdin);
  else {
    for (argn = 1; argn < argc; argn++) {
      f = fopen(argv[argn], "r");
      if (f == NULL) {
        fprintf(stderr, "Can't open \"%s\"\n", argv[argn]);
        return 0;
      }
      ProcessFile(argv[argn], f);
      fclose(f);
    }
  }
  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)
movq   $0x0,-0x18(%rbp)
cmpl   $0x0,-0x8(%rbp)
jne    117f <main+0x2f>
mov    $0x0,%al
call   1060 <usage@plt>
cmpl   $0x1,-0x8(%rbp)
jne    11a1 <main+0x51>
mov    0x2e58(%rip),%rax
mov    (%rax),%rsi
xor    %eax,%eax
mov    %eax,%edi
call   1030 <ProcessFile@plt>
jmp    1239 <main+0xe9>
movl   $0x1,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1234 <main+0xe4>
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    0xe39(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    1208 <main+0xb8>
mov    0x2df6(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rdx
lea    0xe0b(%rip),%rsi
call   1050 <fprintf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1240 <main+0xf0>
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
mov    -0x18(%rbp),%rsi
call   1030 <ProcessFile@plt>
mov    -0x18(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    11a8 <main+0x58>
jmp    1239 <main+0xe9>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
cmp    $0x1,%edi
je     116e <main+0x1e>
test   %edi,%edi
jne    1181 <main+0x31>
xor    %eax,%eax
call   1060 <usage@plt>
jmp    11ec <main+0x9c>
mov    0x2e73(%rip),%rax
mov    (%rax),%rsi
xor    %edi,%edi
call   1030 <ProcessFile@plt>
jmp    11ec <main+0x9c>
cmp    $0x2,%edi
jl     11ec <main+0x9c>
mov    %rsi,%r15
mov    %edi,%r13d
mov    $0x1,%r12d
lea    0xe67(%rip),%r14
nopl   0x0(%rax)
mov    (%r15,%r12,8),%rdi
mov    %r14,%rsi
call   1070 <fopen@plt>
test   %rax,%rax
je     11d3 <main+0x83>
mov    %rax,%rbx
mov    (%r15,%r12,8),%rdi
mov    %rax,%rsi
call   1030 <ProcessFile@plt>
mov    %rbx,%rdi
call   1040 <fclose@plt>
add    $0x1,%r12
cmp    %r12,%r13
jne    11a0 <main+0x50>
jmp    11ec <main+0x9c>
mov    0x2dfe(%rip),%rax
mov    (%rax),%edi
mov    (%r15,%r12,8),%rdx
lea    0xe1b(%rip),%rsi
call   1050 <fprintf@plt>
xor    %eax,%eax
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@stdin = global i32* null
@.str = [2 x i8] c"r\00"
@stderr = global i32 0
@.str.1 = [17 x i8] c"Can't open \22%s\22\0A\00"
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* null, i32** %6
%8 = load i32, i32* %4
%9 = icmp eq i32 %8, 0
br i1 %9, label %10, label %12
10: ; preds = %2
%11 = call i32 (...) @usage()
br label %12
12: ; preds = %10, %2
%13 = load i32, i32* %4
%14 = icmp eq i32 %13, 1
br i1 %14, label %15, label %18
15: ; preds = %12
%16 = load i32*, i32** @stdin
%17 = call i32 @ProcessFile(i8* null, i32* %16)
br label %54
18: ; preds = %12
store i32 1, i32* %7
br label %19
19: ; preds = %50, %18
%20 = load i32, i32* %7
%21 = load i32, i32* %4
%22 = icmp slt i32 %20, %21
br i1 %22, label %23, label %53
23: ; preds = %19
%24 = load i8**, i8*** %5
%25 = load i32, i32* %7
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds i8*, i8** %24, i64 %26
%28 = load i8*, i8** %27
%29 = call i32* @fopen(i8* %28, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %29, i32** %6
%30 = load i32*, i32** %6
%31 = icmp eq i32* %30, null
br i1 %31, label %32, label %40
32: ; preds = %23
%33 = load i32, i32* @stderr
%34 = load i8**, i8*** %5
%35 = load i32, i32* %7
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds i8*, i8** %34, i64 %36
%38 = load i8*, i8** %37
%39 = call i32 @fprintf(i32 %33, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0), i8* %38)
store i32 0, i32* %3
br label %55
40: ; preds = %23
%41 = load i8**, i8*** %5
%42 = load i32, i32* %7
%43 = sext i32 %42 to i64
%44 = getelementptr inbounds i8*, i8** %41, i64 %43
%45 = load i8*, i8** %44
%46 = load i32*, i32** %6
%47 = call i32 @ProcessFile(i8* %45, i32* %46)
%48 = load i32*, i32** %6
%49 = call i32 @fclose(i32* %48)
br label %50
50: ; preds = %40
%51 = load i32, i32* %7
%52 = add nsw i32 %51, 1
store i32 %52, i32* %7
br label %19
53: ; preds = %19
br label %54
54: ; preds = %53, %15
store i32 0, i32* %3
br label %55
55: ; preds = %54, %32
%56 = load i32, i32* %3
ret i32 %56
}

LLVM IR (-O2):
@stdin = global i32* null
@.str = [2 x i8] c"r\00"
@stderr = global i32 0
@.str.1 = [17 x i8] c"Can't open \22%s\22\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
switch i32 %0, label %8 [
i32 0, label %3
i32 1, label %5
]
3: ; preds = %2
%4 = tail call i32 (...) @usage()
br label %28
5: ; preds = %2
%6 = load i32*, i32** @stdin
%7 = tail call i32 @ProcessFile(i8* null, i32* %6)
br label %28
8: ; preds = %2
%9 = icmp sgt i32 %0, 1
br i1 %9, label %10, label %28
10: ; preds = %8
%11 = zext i32 %0 to i64
br label %12
12: ; preds = %10, %22
%13 = phi i64 [ 1, %10 ], [ %26, %22 ]
%14 = getelementptr inbounds i8*, i8** %1, i64 %13
%15 = load i8*, i8** %14
%16 = tail call i32* @fopen(i8* %15, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%17 = icmp eq i32* %16, null
br i1 %17, label %18, label %22
18: ; preds = %12
%19 = load i32, i32* @stderr
%20 = load i8*, i8** %14
%21 = tail call i32 @fprintf(i32 %19, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0), i8* %20)
br label %28
22: ; preds = %12
%23 = load i8*, i8** %14
%24 = tail call i32 @ProcessFile(i8* %23, i32* %16)
%25 = tail call i32 @fclose(i32* %16)
%26 = add nuw nsw i64 %13, 1
%27 = icmp eq i64 %26, %11
br i1 %27, label %28, label %12
28: ; preds = %22, %3, %8, %5, %18
ret i32 0
}