#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;
};
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ cctools_debug(long long, char *, char const *,
                                 int /*<<< orphan*/);
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 rmsummary *rmsummary_parse_file_single(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 rmsummary *s = rmsummary_parse_next(stream);
  fclose(stream);
  return s;
}


x86 assembly (clang, -O0):
<rmsummary_parse_file_single>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xe99(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    11b5 <rmsummary_parse_file_single+0x65>
mov    -0x10(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    0x2e56(%rip),%rax
mov    (%rax),%edi
call   1070 <strerror@plt>
mov    -0x28(%rbp),%rdx
mov    %eax,%ecx
mov    $0x4,%edi
lea    0xe5f(%rip),%rsi
call   1050 <cctools_debug@plt>
movq   $0x0,-0x8(%rbp)
jmp    11d3 <rmsummary_parse_file_single+0x83>
mov    -0x18(%rbp),%rdi
call   1030 <rmsummary_parse_next@plt>
mov    %rax,-0x20(%rbp)
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_single>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
lea    0xea2(%rip),%rsi
call   1060 <fopen@plt>
test   %rax,%rax
je     1183 <rmsummary_parse_file_single+0x33>
mov    %rax,%rbx
mov    %rax,%rdi
call   1030 <rmsummary_parse_next@plt>
mov    %rax,%r14
mov    %rbx,%rdi
call   1040 <fclose@plt>
mov    %r14,%rax
jmp    11a9 <rmsummary_parse_file_single+0x59>
mov    0x2e56(%rip),%rax
mov    (%rax),%edi
call   1070 <strerror@plt>
lea    0xe6a(%rip),%rsi
mov    $0x4,%edi
mov    %r14,%rdx
mov    %eax,%ecx
call   1050 <cctools_debug@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%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.rmsummary* @rmsummary_parse_file_single(i8* %0) {
%2 = alloca %struct.rmsummary*
%3 = alloca i8*
%4 = alloca i32*
%5 = alloca %struct.rmsummary*
store i8* %0, i8** %3
%6 = load i8*, i8** %3
%7 = call i32* @fopen(i8* %6, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %7, i32** %4
%8 = load i32*, i32** %4
%9 = icmp ne i32* %8, null
br i1 %9, label %15, label %10
10: ; preds = %1
%11 = load i8*, i8** %3
%12 = load i32, i32* @errno
%13 = call i32 @strerror(i32 %12)
%14 = call i32 @cctools_debug(i64 4, i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.1, i64 0, i64 0), i8* %11, i32 %13)
store %struct.rmsummary* null, %struct.rmsummary** %2
br label %21
15: ; preds = %1
%16 = load i32*, i32** %4
%17 = call %struct.rmsummary* @rmsummary_parse_next(i32* %16)
store %struct.rmsummary* %17, %struct.rmsummary** %5
%18 = load i32*, i32** %4
%19 = call i32 @fclose(i32* %18)
%20 = load %struct.rmsummary*, %struct.rmsummary** %5
store %struct.rmsummary* %20, %struct.rmsummary** %2
br label %21
21: ; preds = %15, %10
%22 = load %struct.rmsummary*, %struct.rmsummary** %2
ret %struct.rmsummary* %22
}

LLVM IR (-O2):
%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.rmsummary* @rmsummary_parse_file_single(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 %11
8: ; preds = %1
%9 = tail call %struct.rmsummary* @rmsummary_parse_next(i32* %2)
%10 = tail call i32 @fclose(i32* %2)
br label %11
11: ; preds = %8, %4
%12 = phi %struct.rmsummary* [ %9, %8 ], [ null, %4 ]
ret %struct.rmsummary* %12
}