#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 */
struct rmsummary {
  int dummy;
};
struct list {
  int dummy;
};
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ cctools_debug(long long, char *, char const *,
                                 int /*<<< orphan*/);
struct list *cctools_list_create(int /*<<< orphan*/);
int /*<<< orphan*/ cctools_list_push_tail(struct list *, struct rmsummary *);
int /*<<< orphan*/ errno;
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char const *, char *);
struct rmsummary *rmsummary_parse_next(int /*<<< orphan*/ *);
int /*<<< orphan*/ strerror(int /*<<< orphan*/);
struct list *rmsummary_parse_file_multiple(const char *filename) {
  FILE *stream;
  stream = fopen(filename, "r");
  if (!stream) {
    cctools_debug((1LL << 2), "Cannot open resources summary file: %s : %s\n",
                  filename, strerror(errno));
    return NULL;
  }
  struct list *lst = cctools_list_create(0);
  struct rmsummary *s;
  do {
    s = rmsummary_parse_next(stream);
    if (s)
      cctools_list_push_tail(lst, s);
  } while (s);
  fclose(stream);
  return lst;
}


x86 assembly (clang, -O0):
<rmsummary_parse_file_multiple>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xe79(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    11d5 <rmsummary_parse_file_multiple+0x65>
mov    -0x10(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    0x2e36(%rip),%rax
mov    (%rax),%edi
call   1090 <strerror@plt>
mov    -0x30(%rbp),%rdx
mov    %eax,%ecx
mov    $0x4,%edi
lea    0xe3f(%rip),%rsi
call   1060 <cctools_debug@plt>
movq   $0x0,-0x8(%rbp)
jmp    1226 <rmsummary_parse_file_multiple+0xb6>
xor    %edi,%edi
call   1050 <cctools_list_create@plt>
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <rmsummary_parse_next@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     1205 <rmsummary_parse_file_multiple+0x95>
mov    -0x20(%rbp),%rdi
mov    -0x28(%rbp),%rsi
call   1080 <cctools_list_push_tail@plt>
jmp    120a <rmsummary_parse_file_multiple+0x9a>
cmpq   $0x0,-0x28(%rbp)
jne    11e0 <rmsummary_parse_file_multiple+0x70>
mov    -0x18(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x20(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<rmsummary_parse_file_multiple>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
lea    0xe82(%rip),%rsi
call   1070 <fopen@plt>
test   %rax,%rax
je     11c4 <rmsummary_parse_file_multiple+0x54>
mov    %rax,%rbx
xor    %edi,%edi
call   1050 <cctools_list_create@plt>
mov    %rax,%r14
cs nopw 0x0(%rax,%rax,1)
nop
mov    %rbx,%rdi
call   1030 <rmsummary_parse_next@plt>
test   %rax,%rax
je     11ba <rmsummary_parse_file_multiple+0x4a>
mov    %r14,%rdi
mov    %rax,%rsi
call   1080 <cctools_list_push_tail@plt>
jmp    11a0 <rmsummary_parse_file_multiple+0x30>
mov    %rbx,%rdi
call   1040 <fclose@plt>
jmp    11eb <rmsummary_parse_file_multiple+0x7b>
mov    0x2e15(%rip),%rax
mov    (%rax),%edi
call   1090 <strerror@plt>
lea    0xe29(%rip),%rsi
mov    $0x4,%edi
mov    %r14,%rdx
mov    %eax,%ecx
call   1060 <cctools_debug@plt>
xor    %r14d,%r14d
mov    %r14,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.list = type { i32 }
%struct.rmsummary = type { i32 }
@.str = [2 x i8] c"r\00"
@.str.1 = [45 x i8] c"Cannot open resources summary file: %s : %s\0A\00"
@errno = global i32 0
define %struct.list* @rmsummary_parse_file_multiple(i8* %0) {
%2 = alloca %struct.list*
%3 = alloca i8*
%4 = alloca i32*
%5 = alloca %struct.list*
%6 = alloca %struct.rmsummary*
store i8* %0, i8** %3
%7 = load i8*, i8** %3
%8 = call i32* @fopen(i8* %7, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %8, i32** %4
%9 = load i32*, i32** %4
%10 = icmp ne i32* %9, null
br i1 %10, label %16, label %11
11: ; preds = %1
%12 = load i8*, i8** %3
%13 = load i32, i32* @errno
%14 = call i32 @strerror(i32 %13)
%15 = call i32 @cctools_debug(i64 4, i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.1, i64 0, i64 0), i8* %12, i32 %14)
store %struct.list* null, %struct.list** %2
br label %35
16: ; preds = %1
%17 = call %struct.list* @cctools_list_create(i32 0)
store %struct.list* %17, %struct.list** %5
br label %18
18: ; preds = %28, %16
%19 = load i32*, i32** %4
%20 = call %struct.rmsummary* @rmsummary_parse_next(i32* %19)
store %struct.rmsummary* %20, %struct.rmsummary** %6
%21 = load %struct.rmsummary*, %struct.rmsummary** %6
%22 = icmp ne %struct.rmsummary* %21, null
br i1 %22, label %23, label %27
23: ; preds = %18
%24 = load %struct.list*, %struct.list** %5
%25 = load %struct.rmsummary*, %struct.rmsummary** %6
%26 = call i32 @cctools_list_push_tail(%struct.list* %24, %struct.rmsummary* %25)
br label %27
27: ; preds = %23, %18
br label %28
28: ; preds = %27
%29 = load %struct.rmsummary*, %struct.rmsummary** %6
%30 = icmp ne %struct.rmsummary* %29, null
br i1 %30, label %18, label %31
31: ; preds = %28
%32 = load i32*, i32** %4
%33 = call i32 @fclose(i32* %32)
%34 = load %struct.list*, %struct.list** %5
store %struct.list* %34, %struct.list** %2
br label %35
35: ; preds = %31, %11
%36 = load %struct.list*, %struct.list** %2
ret %struct.list* %36
}

LLVM IR (-O2):
%struct.list = type { i32 }
%struct.rmsummary = type { i32 }
@.str = [2 x i8] c"r\00"
@.str.1 = [45 x i8] c"Cannot open resources summary file: %s : %s\0A\00"
@errno = global i32 0
define %struct.list* @rmsummary_parse_file_multiple(i8* %0) {
%2 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%3 = icmp eq i32* %2, null
br i1 %3, label %4, label %8
4: ; preds = %1
%5 = load i32, i32* @errno
%6 = tail call i32 @strerror(i32 %5)
%7 = tail call i32 @cctools_debug(i64 4, i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.1, i64 0, i64 0), i8* %0, i32 %6)
br label %19
8: ; preds = %1
%9 = tail call %struct.list* @cctools_list_create(i32 0)
%10 = tail call %struct.rmsummary* @rmsummary_parse_next(i32* %2)
%11 = icmp eq %struct.rmsummary* %10, null
br i1 %11, label %17, label %12
12: ; preds = %8, %12
%13 = phi %struct.rmsummary* [ %15, %12 ], [ %10, %8 ]
%14 = tail call i32 @cctools_list_push_tail(%struct.list* %9, %struct.rmsummary* %13)
%15 = tail call %struct.rmsummary* @rmsummary_parse_next(i32* %2)
%16 = icmp eq %struct.rmsummary* %15, null
br i1 %16, label %17, label %12
17: ; preds = %12, %8
%18 = tail call i32 @fclose(i32* %2)
br label %19
19: ; preds = %17, %4
%20 = phi %struct.list* [ %9, %17 ], [ null, %4 ]
ret %struct.list* %20
}