#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 EXIT_SUCCESS;
int /*<<< orphan*/ exit(int);
scalar_t__ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ perror(char *);
int main(int ac, char **av) {
  int exit_status = EXIT_SUCCESS;
  FILE *input;
  while (*++av != NULL) {
    input = fopen(*av, "r");
    if (input == NULL) {
      perror(*av);
      exit_status = EXIT_FAILURE;
      continue;
    }
    if (fclose(input) != 0) {
      perror("fclose");
      exit(EXIT_FAILURE);
    }
  }
  return exit_status;
}


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)
mov    0x2e7b(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x8,%rcx
mov    %rcx,-0x10(%rbp)
cmpq   $0x0,0x8(%rax)
je     11ed <main+0xad>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
lea    0xe76(%rip),%rsi
call   1040 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    11bb <main+0x7b>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1050 <perror@plt>
mov    0x2e2f(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x14(%rbp)
jmp    1162 <main+0x22>
mov    -0x20(%rbp),%rdi
call   1030 <fclose@plt>
cmp    $0x0,%rax
je     11e8 <main+0xa8>
lea    0xe2d(%rip),%rdi
call   1050 <perror@plt>
mov    0x2dff(%rip),%rax
mov    (%rax),%edi
call   1060 <exit@plt>
jmp    1162 <main+0x22>
mov    -0x14(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    0x2e87(%rip),%rax
lea    0xea8(%rip),%r14
mov    0x2e81(%rip),%r15
mov    (%rax),%ebp
add    $0x8,%rbx
cs nopw 0x0(%rax,%rax,1)
nop
mov    (%rbx),%rdi
test   %rdi,%rdi
je     11a5 <main+0x65>
mov    %r14,%rsi
call   1040 <fopen@plt>
test   %rax,%rax
je     1198 <main+0x58>
mov    %rax,%rdi
call   1030 <fclose@plt>
add    $0x8,%rbx
test   %rax,%rax
je     1170 <main+0x30>
jmp    11b2 <main+0x72>
mov    (%rbx),%rdi
call   1050 <perror@plt>
mov    %r15,%rax
jmp    115f <main+0x1f>
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xe49(%rip),%rdi
call   1050 <perror@plt>
mov    0x2e1b(%rip),%rax
mov    (%rax),%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@EXIT_SUCCESS = global i32 0
@.str = [2 x i8] c"r\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [7 x i8] c"fclose\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* @EXIT_SUCCESS
store i32 %8, i32* %6
br label %9
9: ; preds = %33, %20, %2
%10 = load i8**, i8*** %5
%11 = getelementptr inbounds i8*, i8** %10, i32 1
store i8** %11, i8*** %5
%12 = load i8*, i8** %11
%13 = icmp ne i8* %12, null
br i1 %13, label %14, label %34
14: ; preds = %9
%15 = load i8**, i8*** %5
%16 = load i8*, i8** %15
%17 = call i32* @fopen(i8* %16, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %17, i32** %7
%18 = load i32*, i32** %7
%19 = icmp eq i32* %18, null
br i1 %19, label %20, label %25
20: ; preds = %14
%21 = load i8**, i8*** %5
%22 = load i8*, i8** %21
%23 = call i32 @perror(i8* %22)
%24 = load i32, i32* @EXIT_FAILURE
store i32 %24, i32* %6
br label %9
25: ; preds = %14
%26 = load i32*, i32** %7
%27 = call i64 @fclose(i32* %26)
%28 = icmp ne i64 %27, 0
br i1 %28, label %29, label %33
29: ; preds = %25
%30 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%31 = load i32, i32* @EXIT_FAILURE
%32 = call i32 @exit(i32 %31)
unreachable
33: ; preds = %25
br label %9
34: ; preds = %9
%35 = load i32, i32* %6
ret i32 %35
}

LLVM IR (-O2):
@EXIT_SUCCESS = global i32 0
@.str = [2 x i8] c"r\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [7 x i8] c"fclose\00"
define i32 @main(i32 %0, i8** nocapture %1) {
br label %3
3: ; preds = %15, %2
%4 = phi i32* [ @EXIT_FAILURE, %15 ], [ @EXIT_SUCCESS, %2 ]
%5 = phi i8** [ %9, %15 ], [ %1, %2 ]
%6 = load i32, i32* %4
br label %7
7: ; preds = %3, %18
%8 = phi i8** [ %9, %18 ], [ %5, %3 ]
%9 = getelementptr inbounds i8*, i8** %8, i64 1
%10 = load i8*, i8** %9
%11 = icmp eq i8* %10, null
br i1 %11, label %25, label %12
12: ; preds = %7
%13 = tail call i32* @fopen(i8* %10, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%14 = icmp eq i32* %13, null
br i1 %14, label %15, label %18
15: ; preds = %12
%16 = load i8*, i8** %9
%17 = tail call i32 @perror(i8* %16)
br label %3
18: ; preds = %12
%19 = tail call i64 @fclose(i32* %13)
%20 = icmp eq i64 %19, 0
br i1 %20, label %7, label %21
21: ; preds = %18
%22 = tail call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%23 = load i32, i32* @EXIT_FAILURE
%24 = tail call i32 @exit(i32 %23)
unreachable
25: ; preds = %7
ret i32 %6
}