#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*/ add_regex(char *);
int /*<<< orphan*/ chomp(char *);
int /*<<< orphan*/ free(char *);
char *get_line_from_file(int /*<<< orphan*/ *);
int /*<<< orphan*/ *xfopen(char const *, char *);
void load_regexes_from_file(const char *filename) {
  char *line;
  FILE *f = xfopen(filename, "r");
  while ((line = get_line_from_file(f)) != NULL) {
    chomp(line);
    add_regex(line);
    free(line);
  }
}


x86 assembly (clang, -O0):
<load_regexes_from_file>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xe99(%rip),%rsi
call   1040 <xfopen@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
call   1070 <get_line_from_file@plt>
mov    %rax,-0x10(%rbp)
cmp    $0x0,%rax
je     11a7 <load_regexes_from_file+0x57>
mov    -0x10(%rbp),%rdi
call   1060 <chomp@plt>
mov    -0x10(%rbp),%rdi
call   1050 <add_regex@plt>
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
jmp    1170 <load_regexes_from_file+0x20>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<load_regexes_from_file>:
push   %r14
push   %rbx
push   %rax
lea    0xea5(%rip),%rsi
call   1040 <xfopen@plt>
mov    %rax,%r14
mov    %rax,%rdi
call   1070 <get_line_from_file@plt>
test   %rax,%rax
je     11a8 <load_regexes_from_file+0x58>
mov    %rax,%rbx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %rbx,%rdi
call   1060 <chomp@plt>
mov    %rbx,%rdi
call   1050 <add_regex@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    %r14,%rdi
call   1070 <get_line_from_file@plt>
mov    %rax,%rbx
test   %rax,%rax
jne    1180 <load_regexes_from_file+0x30>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
define void @load_regexes_from_file(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i32*
store i8* %0, i8** %2
%5 = load i8*, i8** %2
%6 = call i32* @xfopen(i8* %5, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %6, i32** %4
br label %7
7: ; preds = %11, %1
%8 = load i32*, i32** %4
%9 = call i8* @get_line_from_file(i32* %8)
store i8* %9, i8** %3
%10 = icmp ne i8* %9, null
br i1 %10, label %11, label %18
11: ; preds = %7
%12 = load i8*, i8** %3
%13 = call i32 @chomp(i8* %12)
%14 = load i8*, i8** %3
%15 = call i32 @add_regex(i8* %14)
%16 = load i8*, i8** %3
%17 = call i32 @free(i8* %16)
br label %7
18: ; preds = %7
ret void
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
define void @load_regexes_from_file(i8* %0) {
%2 = tail call i32* @xfopen(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%3 = tail call i8* @get_line_from_file(i32* %2)
%4 = icmp eq i8* %3, null
br i1 %4, label %12, label %5
5: ; preds = %1, %5
%6 = phi i8* [ %10, %5 ], [ %3, %1 ]
%7 = tail call i32 @chomp(i8* %6)
%8 = tail call i32 @add_regex(i8* %6)
%9 = tail call i32 @free(i8* %6)
%10 = tail call i8* @get_line_from_file(i32* %2)
%11 = icmp eq i8* %10, null
br i1 %11, label %12, label %5
12: ; preds = %5, %1
ret void
}