#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 lafe_matching {
  int dummy;
};
struct lafe_line_reader {
  int dummy;
};

/* Variables and functions */
scalar_t__ lafe_exclude(struct lafe_matching **, char const *);
struct lafe_line_reader *lafe_line_reader(char const *, char);
int /*<<< orphan*/ lafe_line_reader_free(struct lafe_line_reader *);
char *lafe_line_reader_next(struct lafe_line_reader *);
int lafe_exclude_from_file(struct lafe_matching **matching,
                           const char *pathname) {
  struct lafe_line_reader *lr;
  const char *p;
  int ret = 0;
  lr = lafe_line_reader(pathname, '\n');
  while ((p = lafe_line_reader_next(lr)) != NULL) {
    if (lafe_exclude(matching, p) != 0)
      ret = -1;
  }
  lafe_line_reader_free(lr);
  return (ret);
}


x86 assembly (clang, -O0):
<lafe_exclude_from_file>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x10(%rbp),%rdi
mov    $0xa,%esi
call   1050 <lafe_line_reader@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <lafe_line_reader_next@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
je     11a3 <lafe_exclude_from_file+0x63>
mov    -0x8(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1040 <lafe_exclude@plt>
cmp    $0x0,%rax
je     119e <lafe_exclude_from_file+0x5e>
movl   $0xffffffff,-0x24(%rbp)
jmp    1169 <lafe_exclude_from_file+0x29>
mov    -0x18(%rbp),%rdi
call   1060 <lafe_line_reader_free@plt>
mov    -0x24(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<lafe_exclude_from_file>:
push   %rbp
push   %r14
push   %rbx
mov    %rdi,%r14
mov    %rsi,%rdi
mov    $0xa,%esi
call   1050 <lafe_line_reader@plt>
mov    %rax,%rbx
mov    %rax,%rdi
call   1030 <lafe_line_reader_next@plt>
xor    %ebp,%ebp
test   %rax,%rax
je     118f <lafe_exclude_from_file+0x4f>
cs nopw 0x0(%rax,%rax,1)
mov    %r14,%rdi
mov    %rax,%rsi
call   1040 <lafe_exclude@plt>
neg    %rax
sbb    %eax,%eax
or     %eax,%ebp
mov    %rbx,%rdi
call   1030 <lafe_line_reader_next@plt>
test   %rax,%rax
jne    1170 <lafe_exclude_from_file+0x30>
mov    %rbx,%rdi
call   1060 <lafe_line_reader_free@plt>
mov    %ebp,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
%struct.lafe_matching = type { i32 }
%struct.lafe_line_reader = type { i32 }
define i32 @lafe_exclude_from_file(%struct.lafe_matching** %0, i8* %1) {
%3 = alloca %struct.lafe_matching**
%4 = alloca i8*
%5 = alloca %struct.lafe_line_reader*
%6 = alloca i8*
%7 = alloca i32
store %struct.lafe_matching** %0, %struct.lafe_matching*** %3
store i8* %1, i8** %4
store i32 0, i32* %7
%8 = load i8*, i8** %4
%9 = call %struct.lafe_line_reader* @lafe_line_reader(i8* %8, i8 signext 10)
store %struct.lafe_line_reader* %9, %struct.lafe_line_reader** %5
br label %10
10: ; preds = %20, %2
%11 = load %struct.lafe_line_reader*, %struct.lafe_line_reader** %5
%12 = call i8* @lafe_line_reader_next(%struct.lafe_line_reader* %11)
store i8* %12, i8** %6
%13 = icmp ne i8* %12, null
br i1 %13, label %14, label %21
14: ; preds = %10
%15 = load %struct.lafe_matching**, %struct.lafe_matching*** %3
%16 = load i8*, i8** %6
%17 = call i64 @lafe_exclude(%struct.lafe_matching** %15, i8* %16)
%18 = icmp ne i64 %17, 0
br i1 %18, label %19, label %20
19: ; preds = %14
store i32 -1, i32* %7
br label %20
20: ; preds = %19, %14
br label %10
21: ; preds = %10
%22 = load %struct.lafe_line_reader*, %struct.lafe_line_reader** %5
%23 = call i32 @lafe_line_reader_free(%struct.lafe_line_reader* %22)
%24 = load i32, i32* %7
ret i32 %24
}

LLVM IR (-O2):
%struct.lafe_matching = type { i32 }
%struct.lafe_line_reader = type { i32 }
define i32 @lafe_exclude_from_file(%struct.lafe_matching** %0, i8* %1) {
%3 = tail call %struct.lafe_line_reader* @lafe_line_reader(i8* %1, i8 signext 10)
%4 = tail call i8* @lafe_line_reader_next(%struct.lafe_line_reader* %3)
%5 = icmp eq i8* %4, null
br i1 %5, label %14, label %6
6: ; preds = %2, %6
%7 = phi i8* [ %12, %6 ], [ %4, %2 ]
%8 = phi i32 [ %11, %6 ], [ 0, %2 ]
%9 = tail call i64 @lafe_exclude(%struct.lafe_matching** %0, i8* %7)
%10 = icmp eq i64 %9, 0
%11 = select i1 %10, i32 %8, i32 -1
%12 = tail call i8* @lafe_line_reader_next(%struct.lafe_line_reader* %3)
%13 = icmp eq i8* %12, null
br i1 %13, label %14, label %6
14: ; preds = %6, %2
%15 = phi i32 [ 0, %2 ], [ %11, %6 ]
%16 = tail call i32 @lafe_line_reader_free(%struct.lafe_line_reader* %3)
ret i32 %15
}