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

/* Variables and functions */
int /*<<< orphan*/ errno;
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
scalar_t__ feof(int /*<<< orphan*/ *);
int /*<<< orphan*/ fflush(int /*<<< orphan*/);
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *, ...);
scalar_t__ ndb_io_check_exist_file(char *, int /*<<< orphan*/ *);
int /*<<< orphan*/ ndb_list_addToFileMaskList(struct ndb_l_filemasklist *,
                                              int /*<<< orphan*/, char);
int /*<<< orphan*/ ndb_osdep_makeIntFileName(char *);
int /*<<< orphan*/ stderr;
char *strerror(int /*<<< orphan*/);
int strlen(char *);
void copyFileLinesToIncludeList(char *s_files,
                                struct ndb_l_filemasklist *pfilemasks) {
  FILE *fList = NULL;
  char sLine[260];
  if (0 != ndb_io_check_exist_file(s_files, NULL)) {
    fprintf(stderr, "\nError: could not read filemasks from file '%s'\n",
            s_files);
    fprintf(stderr, "ignoring '-i@%s'\n\n", s_files);
    fflush(stderr);
  } else {
    fList = fopen(s_files, "r");
    if (fList == NULL) {
      fprintf(stderr, "\nError: could not open file '%s': %s\n", s_files,
              strerror(errno));
      fflush(stderr);
    } else {
      while (!feof(fList)) {
        fgets(sLine, sizeof(sLine), fList);
        if (feof(fList))
          break;
        while ((sLine[strlen(sLine) - 1] == '\n') ||
               (sLine[strlen(sLine) - 1] == '\n'))
          sLine[strlen(sLine) - 1] = '\0';
        ndb_list_addToFileMaskList(pfilemasks, ndb_osdep_makeIntFileName(sLine),
                                   'I');
      }
      fclose(fList);
    }
  }
}


x86 assembly (clang, -O0):
<copyFileLinesToIncludeList>:
push   %rbp
mov    %rsp,%rbp
sub    $0x140,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1050 <ndb_io_check_exist_file@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
je     122f <copyFileLinesToIncludeList+0x7f>
mov    0x2df3(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rdx
lea    0xe06(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    0x2dd8(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rdx
lea    0xe1c(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    0x2dbd(%rip),%rax
mov    (%rax),%edi
call   10a0 <fflush@plt>
jmp    13ba <copyFileLinesToIncludeList+0x20a>
mov    -0x8(%rbp),%rdi
lea    0xe0a(%rip),%rsi
call   10c0 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    12a7 <copyFileLinesToIncludeList+0xf7>
mov    0x2d8b(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x12c(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x128(%rbp)
mov    0x2d69(%rip),%rax
mov    (%rax),%edi
call   10d0 <strerror@plt>
mov    -0x12c(%rbp),%edi
mov    -0x128(%rbp),%rdx
mov    %rax,%rcx
lea    0xdb9(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    0x2d45(%rip),%rax
mov    (%rax),%edi
call   10a0 <fflush@plt>
jmp    13b5 <copyFileLinesToIncludeList+0x205>
jmp    12ac <copyFileLinesToIncludeList+0xfc>
mov    -0x18(%rbp),%rdi
call   1090 <feof@plt>
cmp    $0x0,%rax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    12cb <copyFileLinesToIncludeList+0x11b>
jmp    13ac <copyFileLinesToIncludeList+0x1fc>
lea    -0x120(%rbp),%rdi
mov    -0x18(%rbp),%rdx
mov    $0x104,%esi
call   1060 <fgets@plt>
mov    -0x18(%rbp),%rdi
call   1090 <feof@plt>
cmp    $0x0,%rax
je     12f8 <copyFileLinesToIncludeList+0x148>
jmp    13ac <copyFileLinesToIncludeList+0x1fc>
jmp    12fd <copyFileLinesToIncludeList+0x14d>
lea    -0x120(%rbp),%rdi
call   1040 <strlen@plt>
sub    $0x1,%eax
cltq
movsbl -0x120(%rbp,%rax,1),%ecx
ff
mov    $0x1,%al
cmp    $0xa,%ecx
mov    %al,-0x12d(%rbp)
je     134c <copyFileLinesToIncludeList+0x19c>
lea    -0x120(%rbp),%rdi
call   1040 <strlen@plt>
sub    $0x1,%eax
cltq
movsbl -0x120(%rbp,%rax,1),%eax
ff
cmp    $0xa,%eax
sete   %al
mov    %al,-0x12d(%rbp)
mov    -0x12d(%rbp),%al
test   $0x1,%al
jne    135f <copyFileLinesToIncludeList+0x1af>
jmp    137d <copyFileLinesToIncludeList+0x1cd>
lea    -0x120(%rbp),%rdi
call   1040 <strlen@plt>
sub    $0x1,%eax
cltq
movb   $0x0,-0x120(%rbp,%rax,1)
jmp    12fd <copyFileLinesToIncludeList+0x14d>
mov    -0x10(%rbp),%rax
mov    %rax,-0x138(%rbp)
lea    -0x120(%rbp),%rdi
call   1070 <ndb_osdep_makeIntFileName@plt>
mov    -0x138(%rbp),%rdi
mov    %eax,%esi
mov    $0x49,%edx
call   10b0 <ndb_list_addToFileMaskList@plt>
jmp    12ac <copyFileLinesToIncludeList+0xfc>
mov    -0x18(%rbp),%rdi
call   1030 <fclose@plt>
jmp    13ba <copyFileLinesToIncludeList+0x20a>
add    $0x140,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<copyFileLinesToIncludeList>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x108,%rsp
mov    %rsi,%r14
mov    %rdi,%rbx
xor    %esi,%esi
call   1050 <ndb_io_check_exist_file@plt>
test   %rax,%rax
je     1213 <copyFileLinesToIncludeList+0x63>
mov    0x2e0a(%rip),%rbp
mov    0x0(%rbp),%edi
lea    0xe20(%rip),%rsi
mov    %rbx,%rdx
xor    %eax,%eax
call   1080 <fprintf@plt>
mov    0x0(%rbp),%edi
lea    0xe3d(%rip),%rsi
mov    %rbx,%rdx
xor    %eax,%eax
call   1080 <fprintf@plt>
mov    0x0(%rbp),%edi
add    $0x108,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    10a0 <fflush@plt>
lea    0xe2a(%rip),%rsi
mov    %rbx,%rdi
call   10c0 <fopen@plt>
test   %rax,%rax
je     12db <copyFileLinesToIncludeList+0x12b>
mov    %rax,%r15
mov    %rax,%rdi
call   1090 <feof@plt>
test   %rax,%rax
jne    12c5 <copyFileLinesToIncludeList+0x115>
mov    %rsp,%rbx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %rbx,%rdi
mov    $0x104,%esi
mov    %r15,%rdx
call   1060 <fgets@plt>
mov    %r15,%rdi
call   1090 <feof@plt>
test   %rax,%rax
je     127f <copyFileLinesToIncludeList+0xcf>
jmp    12c5 <copyFileLinesToIncludeList+0x115>
nop
mov    %rbx,%rdi
call   1040 <strlen@plt>
cltq
movb   $0x0,-0x1(%rax,%rbx,1)
mov    %rbx,%rdi
call   1040 <strlen@plt>
cltq
cmpb   $0xa,-0x1(%rax,%rbx,1)
je     1270 <copyFileLinesToIncludeList+0xc0>
mov    %rbx,%rdi
call   1040 <strlen@plt>
cltq
cmpb   $0xa,-0x1(%rax,%rbx,1)
je     1270 <copyFileLinesToIncludeList+0xc0>
mov    %rbx,%rdi
call   1070 <ndb_osdep_makeIntFileName@plt>
mov    %r14,%rdi
mov    %eax,%esi
mov    $0x49,%edx
call   10b0 <ndb_list_addToFileMaskList@plt>
mov    %r15,%rdi
call   1090 <feof@plt>
test   %rax,%rax
je     1250 <copyFileLinesToIncludeList+0xa0>
mov    %r15,%rdi
call   1030 <fclose@plt>
add    $0x108,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2cfe(%rip),%r14
mov    (%r14),%ebp
mov    0x2cec(%rip),%rax
mov    (%rax),%edi
call   10d0 <strerror@plt>
lea    0xd4c(%rip),%rsi
mov    %ebp,%edi
mov    %rbx,%rdx
mov    %rax,%rcx
xor    %eax,%eax
call   1080 <fprintf@plt>
mov    (%r14),%edi
jmp    1201 <copyFileLinesToIncludeList+0x51>

LLVM IR (-O0):
%struct.ndb_l_filemasklist = type { i32 }
@stderr = global i32 0
@.str = [49 x i8] c"\0AError: could not read filemasks from file '%s'\0A\00"
@.str.1 = [19 x i8] c"ignoring '-i@%s'\0A\0A\00"
@.str.2 = [2 x i8] c"r\00"
@.str.3 = [38 x i8] c"\0AError: could not open file '%s': %s\0A\00"
@errno = global i32 0
define void @copyFileLinesToIncludeList(i8* %0, %struct.ndb_l_filemasklist* %1) {
%3 = alloca i8*
%4 = alloca %struct.ndb_l_filemasklist*
%5 = alloca i32*
%6 = alloca [260 x i8]
store i8* %0, i8** %3
store %struct.ndb_l_filemasklist* %1, %struct.ndb_l_filemasklist** %4
store i32* null, i32** %5
%7 = load i8*, i8** %3
%8 = call i64 @ndb_io_check_exist_file(i8* %7, i32* null)
%9 = icmp ne i64 0, %8
br i1 %9, label %10, label %19
10: ; preds = %2
%11 = load i32, i32* @stderr
%12 = load i8*, i8** %3
%13 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %11, i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str, i64 0, i64 0), i8* %12)
%14 = load i32, i32* @stderr
%15 = load i8*, i8** %3
%16 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %14, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), i8* %15)
%17 = load i32, i32* @stderr
%18 = call i32 @fflush(i32 %17)
br label %82
19: ; preds = %2
%20 = load i8*, i8** %3
%21 = call i32* @fopen(i8* %20, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i32* %21, i32** %5
%22 = load i32*, i32** %5
%23 = icmp eq i32* %22, null
br i1 %23, label %24, label %32
24: ; preds = %19
%25 = load i32, i32* @stderr
%26 = load i8*, i8** %3
%27 = load i32, i32* @errno
%28 = call i8* @strerror(i32 %27)
%29 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %25, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.3, i64 0, i64 0), i8* %26, i8* %28)
%30 = load i32, i32* @stderr
%31 = call i32 @fflush(i32 %30)
br label %81
32: ; preds = %19
br label %33
33: ; preds = %73, %32
%34 = load i32*, i32** %5
%35 = call i64 @feof(i32* %34)
%36 = icmp ne i64 %35, 0
%37 = xor i1 %36, true
br i1 %37, label %38, label %78
38: ; preds = %33
%39 = getelementptr inbounds [260 x i8], [260 x i8]* %6, i64 0, i64 0
%40 = load i32*, i32** %5
%41 = call i32 @fgets(i8* %39, i32 260, i32* %40)
%42 = load i32*, i32** %5
%43 = call i64 @feof(i32* %42)
%44 = icmp ne i64 %43, 0
br i1 %44, label %45, label %46
45: ; preds = %38
br label %78
46: ; preds = %38
br label %47
47: ; preds = %67, %46
%48 = getelementptr inbounds [260 x i8], [260 x i8]* %6, i64 0, i64 0
%49 = call i32 @strlen(i8* %48)
%50 = sub nsw i32 %49, 1
%51 = sext i32 %50 to i64
%52 = getelementptr inbounds [260 x i8], [260 x i8]* %6, i64 0, i64 %51
%53 = load i8, i8* %52
%54 = sext i8 %53 to i32
%55 = icmp eq i32 %54, 10
br i1 %55, label %65, label %56
56: ; preds = %47
%57 = getelementptr inbounds [260 x i8], [260 x i8]* %6, i64 0, i64 0
%58 = call i32 @strlen(i8* %57)
%59 = sub nsw i32 %58, 1
%60 = sext i32 %59 to i64
%61 = getelementptr inbounds [260 x i8], [260 x i8]* %6, i64 0, i64 %60
%62 = load i8, i8* %61
%63 = sext i8 %62 to i32
%64 = icmp eq i32 %63, 10
br label %65
65: ; preds = %56, %47
%66 = phi i1 [ true, %47 ], [ %64, %56 ]
br i1 %66, label %67, label %73
67: ; preds = %65
%68 = getelementptr inbounds [260 x i8], [260 x i8]* %6, i64 0, i64 0
%69 = call i32 @strlen(i8* %68)
%70 = sub nsw i32 %69, 1
%71 = sext i32 %70 to i64
%72 = getelementptr inbounds [260 x i8], [260 x i8]* %6, i64 0, i64 %71
store i8 0, i8* %72
br label %47
73: ; preds = %65
%74 = load %struct.ndb_l_filemasklist*, %struct.ndb_l_filemasklist** %4
%75 = getelementptr inbounds [260 x i8], [260 x i8]* %6, i64 0, i64 0
%76 = call i32 @ndb_osdep_makeIntFileName(i8* %75)
%77 = call i32 @ndb_list_addToFileMaskList(%struct.ndb_l_filemasklist* %74, i32 %76, i8 signext 73)
br label %33
78: ; preds = %45, %33
%79 = load i32*, i32** %5
%80 = call i32 @fclose(i32* %79)
br label %81
81: ; preds = %78, %24
br label %82
82: ; preds = %81, %10
ret void
}

LLVM IR (-O2):
%struct.ndb_l_filemasklist = type { i32 }
@stderr = global i32 0
@.str = [49 x i8] c"\0AError: could not read filemasks from file '%s'\0A\00"
@.str.1 = [19 x i8] c"ignoring '-i@%s'\0A\0A\00"
@.str.2 = [2 x i8] c"r\00"
@.str.3 = [38 x i8] c"\0AError: could not open file '%s': %s\0A\00"
@errno = global i32 0
define void @copyFileLinesToIncludeList(i8* %0, %struct.ndb_l_filemasklist* %1) {
%3 = alloca [260 x i8]
%4 = getelementptr inbounds [260 x i8], [260 x i8]* %3, i64 0, i64 0
%5 = tail call i64 @ndb_io_check_exist_file(i8* %0, i32* null)
%6 = icmp eq i64 %5, 0
br i1 %6, label %14, label %7
7: ; preds = %2
%8 = load i32, i32* @stderr
%9 = tail call i32 (i32, i8*, i8*, ...) @fprintf(i32 %8, i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str, i64 0, i64 0), i8* %0)
%10 = load i32, i32* @stderr
%11 = tail call i32 (i32, i8*, i8*, ...) @fprintf(i32 %10, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), i8* %0)
%12 = load i32, i32* @stderr
%13 = tail call i32 @fflush(i32 %12)
br label %57
14: ; preds = %2
%15 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%16 = icmp eq i32* %15, null
br i1 %16, label %20, label %17
17: ; preds = %14
%18 = call i64 @feof(i32* %15)
%19 = icmp eq i64 %18, 0
br i1 %19, label %27, label %55
20: ; preds = %14
%21 = load i32, i32* @stderr
%22 = load i32, i32* @errno
%23 = tail call i8* @strerror(i32 %22)
%24 = tail call i32 (i32, i8*, i8*, ...) @fprintf(i32 %21, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.3, i64 0, i64 0), i8* %0, i8* %23)
%25 = load i32, i32* @stderr
%26 = tail call i32 @fflush(i32 %25)
br label %57
27: ; preds = %17, %50
%28 = call i32 @fgets(i8* %4, i32 260, i32* %15)
%29 = call i64 @feof(i32* %15)
%30 = icmp eq i64 %29, 0
br i1 %30, label %31, label %55
31: ; preds = %27, %45
%32 = call i32 @strlen(i8* %4)
%33 = add nsw i32 %32, -1
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds [260 x i8], [260 x i8]* %3, i64 0, i64 %34
%36 = load i8, i8* %35
%37 = icmp eq i8 %36, 10
br i1 %37, label %45, label %38
38: ; preds = %31
%39 = call i32 @strlen(i8* %4)
%40 = add nsw i32 %39, -1
%41 = sext i32 %40 to i64
%42 = getelementptr inbounds [260 x i8], [260 x i8]* %3, i64 0, i64 %41
%43 = load i8, i8* %42
%44 = icmp eq i8 %43, 10
br i1 %44, label %45, label %50
45: ; preds = %31, %38
%46 = call i32 @strlen(i8* %4)
%47 = add nsw i32 %46, -1
%48 = sext i32 %47 to i64
%49 = getelementptr inbounds [260 x i8], [260 x i8]* %3, i64 0, i64 %48
store i8 0, i8* %49
br label %31
50: ; preds = %38
%51 = call i32 @ndb_osdep_makeIntFileName(i8* %4)
%52 = call i32 @ndb_list_addToFileMaskList(%struct.ndb_l_filemasklist* %1, i32 %51, i8 signext 73)
%53 = call i64 @feof(i32* %15)
%54 = icmp eq i64 %53, 0
br i1 %54, label %27, label %55
55: ; preds = %50, %27, %17
%56 = call i32 @fclose(i32* %15)
br label %57
57: ; preds = %20, %55, %7
ret void
}