#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*/ exclude_add(char *);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int strlen(char *);
int exclude_addfile(char *file) {
  FILE *f;
  char buf[256];
  int len;
  if ((f = fopen(file, "r")) == NULL)
    return 1;
  while (fgets(buf, 256, f) != NULL) {
    len = strlen(buf) - 1;
    while (len >= 0 && (buf[len] == '\r' || buf[len] == '\n'))
      buf[len--] = '\0';
    if (len < 0)
      continue;
    exclude_add(buf);
  }
  fclose(f);
  return 0;
}


x86 assembly (clang, -O0):
<exclude_addfile>:
push   %rbp
mov    %rsp,%rbp
sub    $0x130,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xe96(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
jne    1189 <exclude_addfile+0x39>
movl   $0x1,-0x4(%rbp)
jmp    1284 <exclude_addfile+0x134>
jmp    118e <exclude_addfile+0x3e>
lea    -0x120(%rbp),%rdi
mov    -0x18(%rbp),%rdx
mov    $0x100,%esi
call   1050 <fgets@plt>
cmp    $0x0,%rax
je     1274 <exclude_addfile+0x124>
lea    -0x120(%rbp),%rdi
call   1040 <strlen@plt>
sub    $0x1,%eax
mov    %eax,-0x124(%rbp)
xor    %eax,%eax
cmpl   $0x0,-0x124(%rbp)
mov    %al,-0x125(%rbp)
jl     121e <exclude_addfile+0xce>
movslq -0x124(%rbp),%rax
movsbl -0x120(%rbp,%rax,1),%ecx
ff
mov    $0x1,%al
cmp    $0xd,%ecx
mov    %al,-0x126(%rbp)
je     1212 <exclude_addfile+0xc2>
movslq -0x124(%rbp),%rax
movsbl -0x120(%rbp,%rax,1),%eax
ff
cmp    $0xa,%eax
sete   %al
mov    %al,-0x126(%rbp)
mov    -0x126(%rbp),%al
mov    %al,-0x125(%rbp)
mov    -0x125(%rbp),%al
test   $0x1,%al
jne    1231 <exclude_addfile+0xe1>
jmp    1251 <exclude_addfile+0x101>
mov    -0x124(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0x124(%rbp)
cltq
movb   $0x0,-0x120(%rbp,%rax,1)
jmp    11c2 <exclude_addfile+0x72>
cmpl   $0x0,-0x124(%rbp)
jge    1263 <exclude_addfile+0x113>
jmp    118e <exclude_addfile+0x3e>
lea    -0x120(%rbp),%rdi
call   1060 <exclude_add@plt>
jmp    118e <exclude_addfile+0x3e>
mov    -0x18(%rbp),%rdi
call   1030 <fclose@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x130,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<exclude_addfile>:
push   %r14
push   %rbx
sub    $0x108,%rsp
lea    0xe9f(%rip),%rsi
call   1070 <fopen@plt>
test   %rax,%rax
je     11f5 <exclude_addfile+0xa5>
mov    %rax,%r14
mov    %rsp,%rdi
mov    $0x100,%esi
mov    %rax,%rdx
call   1050 <fgets@plt>
test   %rax,%rax
je     11e9 <exclude_addfile+0x99>
mov    %rsp,%rbx
jmp    11a5 <exclude_addfile+0x55>
nopl   0x0(%rax)
mov    %rbx,%rdi
mov    $0x100,%esi
mov    %r14,%rdx
call   1050 <fgets@plt>
test   %rax,%rax
je     11e9 <exclude_addfile+0x99>
mov    %rbx,%rdi
call   1040 <strlen@plt>
test   %eax,%eax
jle    1190 <exclude_addfile+0x40>
mov    %eax,%eax
add    $0x1,%rax
jmp    11ce <exclude_addfile+0x7e>
nopl   0x0(%rax)
movb   $0x0,(%rsp,%rcx,1)
add    $0xffffffffffffffff,%rax
cmp    $0x1,%rax
jbe    1190 <exclude_addfile+0x40>
lea    -0x2(%rax),%ecx
movzbl (%rsp,%rcx,1),%edx
cmp    $0xd,%dl
je     11c0 <exclude_addfile+0x70>
cmp    $0xa,%dl
je     11c0 <exclude_addfile+0x70>
mov    %rbx,%rdi
call   1060 <exclude_add@plt>
jmp    1190 <exclude_addfile+0x40>
mov    %r14,%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
jmp    11fa <exclude_addfile+0xaa>
mov    $0x1,%eax
add    $0x108,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
define i32 @exclude_addfile(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i32*
%5 = alloca [256 x i8]
%6 = alloca i32
store i8* %0, i8** %3
%7 = load i8*, i8** %3
%8 = call i32* @fopen(i8* %7, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %8, i32** %4
%9 = icmp eq i32* %8, null
br i1 %9, label %10, label %11
10: ; preds = %1
store i32 1, i32* %2
br label %57
11: ; preds = %1
br label %12
12: ; preds = %51, %50, %11
%13 = getelementptr inbounds [256 x i8], [256 x i8]* %5, i64 0, i64 0
%14 = load i32*, i32** %4
%15 = call i32* @fgets(i8* %13, i32 256, i32* %14)
%16 = icmp ne i32* %15, null
br i1 %16, label %17, label %54
17: ; preds = %12
%18 = getelementptr inbounds [256 x i8], [256 x i8]* %5, i64 0, i64 0
%19 = call i32 @strlen(i8* %18)
%20 = sub nsw i32 %19, 1
store i32 %20, i32* %6
br label %21
21: ; preds = %42, %17
%22 = load i32, i32* %6
%23 = icmp sge i32 %22, 0
br i1 %23, label %24, label %40
24: ; preds = %21
%25 = load i32, i32* %6
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds [256 x i8], [256 x i8]* %5, i64 0, i64 %26
%28 = load i8, i8* %27
%29 = sext i8 %28 to i32
%30 = icmp eq i32 %29, 13
br i1 %30, label %38, label %31
31: ; preds = %24
%32 = load i32, i32* %6
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds [256 x i8], [256 x i8]* %5, i64 0, i64 %33
%35 = load i8, i8* %34
%36 = sext i8 %35 to i32
%37 = icmp eq i32 %36, 10
br label %38
38: ; preds = %31, %24
%39 = phi i1 [ true, %24 ], [ %37, %31 ]
br label %40
40: ; preds = %38, %21
%41 = phi i1 [ false, %21 ], [ %39, %38 ]
br i1 %41, label %42, label %47
42: ; preds = %40
%43 = load i32, i32* %6
%44 = add nsw i32 %43, -1
store i32 %44, i32* %6
%45 = sext i32 %43 to i64
%46 = getelementptr inbounds [256 x i8], [256 x i8]* %5, i64 0, i64 %45
store i8 0, i8* %46
br label %21
47: ; preds = %40
%48 = load i32, i32* %6
%49 = icmp slt i32 %48, 0
br i1 %49, label %50, label %51
50: ; preds = %47
br label %12
51: ; preds = %47
%52 = getelementptr inbounds [256 x i8], [256 x i8]* %5, i64 0, i64 0
%53 = call i32 @exclude_add(i8* %52)
br label %12
54: ; preds = %12
%55 = load i32*, i32** %4
%56 = call i32 @fclose(i32* %55)
store i32 0, i32* %2
br label %57
57: ; preds = %54, %10
%58 = load i32, i32* %2
ret i32 %58
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
define i32 @exclude_addfile(i8* nocapture %0) {
%2 = alloca [256 x i8]
%3 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 0
%4 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%5 = icmp eq i32* %4, null
br i1 %5, label %29, label %6
6: ; preds = %1
%7 = call i32* @fgets(i8* %3, i32 256, i32* %4)
%8 = icmp eq i32* %7, null
br i1 %8, label %27, label %9
9: ; preds = %6, %24
%10 = call i32 @strlen(i8* %3)
%11 = icmp sgt i32 %10, 0
br i1 %11, label %12, label %24
12: ; preds = %9
%13 = zext i32 %10 to i64
br label %14
14: ; preds = %12, %20
%15 = phi i64 [ %13, %12 ], [ %16, %20 ]
%16 = add nsw i64 %15, -1
%17 = and i64 %16, 4294967295
%18 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 %17
%19 = load i8, i8* %18
switch i8 %19, label %22 [
i8 13, label %20
i8 10, label %20
]
20: ; preds = %14, %14
store i8 0, i8* %18
%21 = icmp ugt i64 %15, 1
br i1 %21, label %14, label %24
22: ; preds = %14
%23 = call i32 @exclude_add(i8* %3)
br label %24
24: ; preds = %20, %9, %22
%25 = call i32* @fgets(i8* %3, i32 256, i32* %4)
%26 = icmp eq i32* %25, null
br i1 %26, label %27, label %9
27: ; preds = %24, %6
%28 = call i32 @fclose(i32* %4)
br label %29
29: ; preds = %1, %27
%30 = phi i32 [ 0, %27 ], [ 1, %1 ]
ret i32 %30
}