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

/* Variables and functions */
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char const *, char *);
struct strlist *tagfile_parse_from_fp(int /*<<< orphan*/ *);
struct strlist *tagfile_parse(const char *path) {
  FILE *fp;
  struct strlist *result;
  if ((fp = fopen(path, "r")) == NULL)
    return NULL;
  result = tagfile_parse_from_fp(fp);
  fclose(fp);
  return result;
}


x86 assembly (clang, -O0):
<tagfile_parse>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xeb9(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
jne    1167 <tagfile_parse+0x37>
movq   $0x0,-0x8(%rbp)
jmp    1185 <tagfile_parse+0x55>
mov    -0x18(%rbp),%rdi
call   1040 <tagfile_parse_from_fp@plt>
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x20(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<tagfile_parse>:
push   %r14
push   %rbx
push   %rax
lea    0xec5(%rip),%rsi
call   1050 <fopen@plt>
test   %rax,%rax
je     1160 <tagfile_parse+0x30>
mov    %rax,%rbx
mov    %rax,%rdi
call   1040 <tagfile_parse_from_fp@plt>
mov    %rax,%r14
mov    %rbx,%rdi
call   1030 <fclose@plt>
mov    %r14,%rax
jmp    1162 <tagfile_parse+0x32>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.strlist = type { i32 }
@.str = [2 x i8] c"r\00"
define %struct.strlist* @tagfile_parse(i8* %0) {
%2 = alloca %struct.strlist*
%3 = alloca i8*
%4 = alloca i32*
%5 = alloca %struct.strlist*
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 = icmp eq i32* %7, null
br i1 %8, label %9, label %10
9: ; preds = %1
store %struct.strlist* null, %struct.strlist** %2
br label %16
10: ; preds = %1
%11 = load i32*, i32** %4
%12 = call %struct.strlist* @tagfile_parse_from_fp(i32* %11)
store %struct.strlist* %12, %struct.strlist** %5
%13 = load i32*, i32** %4
%14 = call i32 @fclose(i32* %13)
%15 = load %struct.strlist*, %struct.strlist** %5
store %struct.strlist* %15, %struct.strlist** %2
br label %16
16: ; preds = %10, %9
%17 = load %struct.strlist*, %struct.strlist** %2
ret %struct.strlist* %17
}

LLVM IR (-O2):
%struct.strlist = type { i32 }
@.str = [2 x i8] c"r\00"
define %struct.strlist* @tagfile_parse(i8* nocapture %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 %7, label %4
4: ; preds = %1
%5 = tail call %struct.strlist* @tagfile_parse_from_fp(i32* %2)
%6 = tail call i32 @fclose(i32* %2)
br label %7
7: ; preds = %1, %4
%8 = phi %struct.strlist* [ %5, %4 ], [ null, %1 ]
ret %struct.strlist* %8
}