#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*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ fitfile(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ *stdin;
scalar_t__ strcmp(char *, char *);
int fitfiles(char *filenames[]) {
  int i;
  FILE *input;
  for (i = 0; filenames[i]; i++) {
    if (strcmp(filenames[i], "-") == 0) {
      fitfile(stdin);
      continue;
    }
    input = fopen(filenames[i], "r");
    if (!input) {
      fprintf(stderr, "error: could not open ``%s''\n", filenames[i]);
      continue;
    }
    fitfile(input);
    fclose(input);
  }
  return 0;
}


x86 assembly (clang, -O0):
<fitfiles>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
cmpq   $0x0,(%rax,%rcx,8)
je     1219 <fitfiles+0xc9>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    0xe77(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jne    11ac <fitfiles+0x5c>
mov    0x2e49(%rip),%rax
mov    (%rax),%rdi
call   1030 <fitfile@plt>
jmp    120b <fitfiles+0xbb>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    0xe43(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    11f9 <fitfiles+0xa9>
mov    0x2dfe(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
mov    (%rax,%rcx,8),%rdx
lea    0xe15(%rip),%rsi
call   1060 <fprintf@plt>
jmp    120b <fitfiles+0xbb>
mov    -0x18(%rbp),%rdi
call   1030 <fitfile@plt>
mov    -0x18(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1163 <fitfiles+0x13>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fitfiles>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdi,%rbx
mov    (%rdi),%rdi
test   %rdi,%rdi
je     11f6 <fitfiles+0xa6>
lea    0xe8f(%rip),%r14
mov    0x2e70(%rip),%rbp
lea    0xe83(%rip),%r15
lea    0xe7e(%rip),%r12
jmp    11a6 <fitfiles+0x56>
nopl   0x0(%rax,%rax,1)
mov    0x0(%rbp),%rdi
call   1030 <fitfile@plt>
mov    0x8(%rbx),%rdi
add    $0x8,%rbx
test   %rdi,%rdi
je     11f6 <fitfiles+0xa6>
mov    %r14,%rsi
call   1050 <strcmp@plt>
test   %rax,%rax
je     1190 <fitfiles+0x40>
mov    (%rbx),%rdi
mov    %r15,%rsi
call   1070 <fopen@plt>
test   %rax,%rax
je     11e0 <fitfiles+0x90>
mov    %rax,%r13
mov    %rax,%rdi
call   1030 <fitfile@plt>
mov    %r13,%rdi
call   1040 <fclose@plt>
jmp    1199 <fitfiles+0x49>
nopl   0x0(%rax,%rax,1)
mov    0x2df1(%rip),%rax
mov    (%rax),%edi
mov    (%rbx),%rdx
mov    %r12,%rsi
call   1060 <fprintf@plt>
jmp    1199 <fitfiles+0x49>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [2 x i8] c"-\00"
@stdin = global i32* null
@.str.1 = [2 x i8] c"r\00"
@stderr = global i32 0
@.str.2 = [30 x i8] c"error: could not open ``%s''\0A\00"
define i32 @fitfiles(i8** %0) {
%2 = alloca i8**
%3 = alloca i32
%4 = alloca i32*
store i8** %0, i8*** %2
store i32 0, i32* %3
br label %5
5: ; preds = %45, %1
%6 = load i8**, i8*** %2
%7 = load i32, i32* %3
%8 = sext i32 %7 to i64
%9 = getelementptr inbounds i8*, i8** %6, i64 %8
%10 = load i8*, i8** %9
%11 = icmp ne i8* %10, null
br i1 %11, label %12, label %48
12: ; preds = %5
%13 = load i8**, i8*** %2
%14 = load i32, i32* %3
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds i8*, i8** %13, i64 %15
%17 = load i8*, i8** %16
%18 = call i64 @strcmp(i8* %17, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%19 = icmp eq i64 %18, 0
br i1 %19, label %20, label %23
20: ; preds = %12
%21 = load i32*, i32** @stdin
%22 = call i32 @fitfile(i32* %21)
br label %45
23: ; preds = %12
%24 = load i8**, i8*** %2
%25 = load i32, i32* %3
%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.1, i64 0, i64 0))
store i32* %29, i32** %4
%30 = load i32*, i32** %4
%31 = icmp ne i32* %30, null
br i1 %31, label %40, label %32
32: ; preds = %23
%33 = load i32, i32* @stderr
%34 = load i8**, i8*** %2
%35 = load i32, i32* %3
%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 ([30 x i8], [30 x i8]* @.str.2, i64 0, i64 0), i8* %38)
br label %45
40: ; preds = %23
%41 = load i32*, i32** %4
%42 = call i32 @fitfile(i32* %41)
%43 = load i32*, i32** %4
%44 = call i32 @fclose(i32* %43)
br label %45
45: ; preds = %40, %32, %20
%46 = load i32, i32* %3
%47 = add nsw i32 %46, 1
store i32 %47, i32* %3
br label %5
48: ; preds = %5
ret i32 0
}

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