#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 EXIT_FAILURE;
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ process_file(int /*<<< orphan*/ *, char *);
int /*<<< orphan*/ *stdin;
int main(int argc, char **argv) {
  int i;
  if (argc == 1) {
    if (!process_file(stdin, "stdin"))
      return EXIT_FAILURE;
  } else
    for (i = 1; i < argc; i++) {
      FILE *f;
      f = fopen(argv[i], "r");
      if (!f) {
        perror(argv[i]);
        return 0;
      }
      if (!process_file(f, argv[i]))
        return EXIT_FAILURE;
      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)
cmpl   $0x1,-0x8(%rbp)
jne    1195 <main+0x55>
mov    0x2e81(%rip),%rax
mov    (%rax),%rdi
lea    0xe8f(%rip),%rsi
call   1040 <process_file@plt>
cmp    $0x0,%eax
jne    1190 <main+0x50>
mov    0x2e52(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    123e <main+0xfe>
jmp    1237 <main+0xf7>
movl   $0x1,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1232 <main+0xf2>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    0xe4b(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    11ec <main+0xac>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1060 <perror@plt>
movl   $0x0,-0x4(%rbp)
jmp    123e <main+0xfe>
mov    -0x20(%rbp),%rdi
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
call   1040 <process_file@plt>
cmp    $0x0,%eax
jne    121b <main+0xdb>
mov    0x2dc7(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    123e <main+0xfe>
mov    -0x20(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    119c <main+0x5c>
jmp    1237 <main+0xf7>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
cmp    $0x1,%edi
jne    1179 <main+0x39>
mov    0x2e91(%rip),%rax
mov    (%rax),%rdi
lea    0xe9f(%rip),%rsi
call   1040 <process_file@plt>
xor    %r14d,%r14d
test   %eax,%eax
jne    11d7 <main+0x97>
mov    0x2e64(%rip),%rax
mov    (%rax),%r14d
jmp    11d7 <main+0x97>
xor    %r14d,%r14d
cmp    $0x2,%edi
jl     11d7 <main+0x97>
mov    %rsi,%r13
mov    %edi,%r12d
mov    $0x1,%ebx
lea    0xe73(%rip),%r15
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    0x0(%r13,%rbx,8),%rdi
mov    %r15,%rsi
call   1050 <fopen@plt>
mov    0x0(%r13,%rbx,8),%rsi
test   %rax,%rax
je     11e9 <main+0xa9>
mov    %rax,%rbp
mov    %rax,%rdi
call   1040 <process_file@plt>
test   %eax,%eax
je     116d <main+0x2d>
mov    %rbp,%rdi
call   1030 <fclose@plt>
add    $0x1,%rbx
cmp    %rbx,%r12
jne    11a0 <main+0x60>
mov    %r14d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %rsi,%rdi
call   1060 <perror@plt>
jmp    11d7 <main+0x97>

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

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