#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 */
char *fread_line(int /*<<< orphan*/ *);
int /*<<< orphan*/ free(char *);
int /*<<< orphan*/ strlist_append_string(struct strlist *, char *);
struct strlist *strlist_new();
char *trim(char *);
struct strlist *tagfile_parse_from_fp(FILE *fp) {
  char *line, *tmp;
  struct strlist *list;
  list = strlist_new();
  while ((tmp = fread_line(fp)) != NULL) {
    line = trim(tmp);
    free(tmp);
    strlist_append_string(list, line);
    free(line);
  }
  return list;
}


x86 assembly (clang, -O0):
<tagfile_parse_from_fp>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    $0x0,%al
call   1050 <strlist_new@plt>
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
call   1070 <fread_line@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
je     11af <tagfile_parse_from_fp+0x5f>
mov    -0x18(%rbp),%rdi
call   1040 <trim@plt>
mov    %rax,-0x10(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
mov    -0x20(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1060 <strlist_append_string@plt>
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
jmp    1167 <tagfile_parse_from_fp+0x17>
mov    -0x20(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<tagfile_parse_from_fp>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rdi,%r14
xor    %eax,%eax
call   1050 <strlist_new@plt>
mov    %rax,%r15
mov    %r14,%rdi
call   1070 <fread_line@plt>
test   %rax,%rax
je     11b6 <tagfile_parse_from_fp+0x66>
mov    %rax,%rbx
cs nopw 0x0(%rax,%rax,1)
nop
mov    %rbx,%rdi
call   1040 <trim@plt>
mov    %rax,%r12
mov    %rbx,%rdi
call   1030 <free@plt>
mov    %r15,%rdi
mov    %r12,%rsi
call   1060 <strlist_append_string@plt>
mov    %r12,%rdi
call   1030 <free@plt>
mov    %r14,%rdi
call   1070 <fread_line@plt>
mov    %rax,%rbx
test   %rax,%rax
jne    1180 <tagfile_parse_from_fp+0x30>
mov    %r15,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.strlist = type { i32 }
define %struct.strlist* @tagfile_parse_from_fp(i32* %0) {
%2 = alloca i32*
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca %struct.strlist*
store i32* %0, i32** %2
%6 = call %struct.strlist* (...) @strlist_new()
store %struct.strlist* %6, %struct.strlist** %5
br label %7
7: ; preds = %11, %1
%8 = load i32*, i32** %2
%9 = call i8* @fread_line(i32* %8)
store i8* %9, i8** %4
%10 = icmp ne i8* %9, null
br i1 %10, label %11, label %21
11: ; preds = %7
%12 = load i8*, i8** %4
%13 = call i8* @trim(i8* %12)
store i8* %13, i8** %3
%14 = load i8*, i8** %4
%15 = call i32 @free(i8* %14)
%16 = load %struct.strlist*, %struct.strlist** %5
%17 = load i8*, i8** %3
%18 = call i32 @strlist_append_string(%struct.strlist* %16, i8* %17)
%19 = load i8*, i8** %3
%20 = call i32 @free(i8* %19)
br label %7
21: ; preds = %7
%22 = load %struct.strlist*, %struct.strlist** %5
ret %struct.strlist* %22
}

LLVM IR (-O2):
%struct.strlist = type { i32 }
define %struct.strlist* @tagfile_parse_from_fp(i32* %0) {
%2 = tail call %struct.strlist* (...) @strlist_new()
%3 = tail call i8* @fread_line(i32* %0)
%4 = icmp eq i8* %3, null
br i1 %4, label %13, label %5
5: ; preds = %1, %5
%6 = phi i8* [ %11, %5 ], [ %3, %1 ]
%7 = tail call i8* @trim(i8* %6)
%8 = tail call i32 @free(i8* %6)
%9 = tail call i32 @strlist_append_string(%struct.strlist* %2, i8* %7)
%10 = tail call i32 @free(i8* %7)
%11 = tail call i8* @fread_line(i32* %0)
%12 = icmp eq i8* %11, null
br i1 %12, label %13, label %5
13: ; preds = %5, %1
ret %struct.strlist* %2
}