#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 ssize_t;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int getline(char **, size_t *, int /*<<< orphan*/ *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ strcat(char *, char *);
scalar_t__ strcmp(char *, char *);
int read_config(char *path, char *whitelist_exact, char *whitelist_similar) {
  FILE *fp;
  char *line = NULL;
  size_t len = 0;
  ssize_t read;
  char flag_exact = 0;
  char flag_similar = 0;
  int wl_size_e = 0;
  int wl_size_s = 0;
  fp = fopen(path, "r");
  if (fp == NULL) {
    fprintf(stderr, "error: can't read the file %s\n", path);
    return -1;
  }
  while ((read = getline(&line, &len, fp)) != -1) {
    if (line[0] == ' ' || line[0] == ';' || line[0] == '\n')
      continue;
    if (line[0] == '[') {
      line[read - 2] = '\0';
      line++;
      if (strcmp(line, "whitelist_exact") == 0) {
        flag_exact = 1;
        flag_similar = 0;
      }
      if (strcmp(line, "whitelist_similar") == 0) {
        flag_exact = 0;
        flag_similar = 1;
      }
      continue;
    }
    line[read - 1] = '/';
    if (wl_size_e + read >= 10240 - 1 || wl_size_e + read >= 10240 - 1) {
      fprintf(stderr,
              "error: the section in the config file is more than %i bytes.\n",
              10240);
      fclose(fp);
      return -1;
    }
    if (flag_exact) {
      wl_size_e += read;
      strcat(whitelist_exact, line);
    }
    if (flag_similar) {
      wl_size_s += read;
      strcat(whitelist_similar, line);
    }
  }
  fclose(fp);
  return 0;
}


x86 assembly (clang, -O0):
<read_config>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
movq   $0x0,-0x30(%rbp)
movq   $0x0,-0x38(%rbp)
movb   $0x0,-0x3d(%rbp)
movb   $0x0,-0x3e(%rbp)
movl   $0x0,-0x44(%rbp)
movl   $0x0,-0x48(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xe9a(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    11e0 <read_config+0x80>
mov    0x2e20(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rdx
lea    0xe33(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1366 <read_config+0x206>
jmp    11e5 <read_config+0x85>
mov    -0x28(%rbp),%rdx
lea    -0x30(%rbp),%rdi
lea    -0x38(%rbp),%rsi
call   1070 <getline@plt>
mov    %eax,-0x3c(%rbp)
cmp    $0xffffffff,%eax
je     1356 <read_config+0x1f6>
mov    -0x30(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x20,%eax
je     1232 <read_config+0xd2>
mov    -0x30(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x3b,%eax
je     1232 <read_config+0xd2>
mov    -0x30(%rbp),%rax
movsbl (%rax),%eax
cmp    $0xa,%eax
jne    1237 <read_config+0xd7>
jmp    11e5 <read_config+0x85>
mov    -0x30(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x5b,%eax
jne    12ad <read_config+0x14d>
mov    -0x30(%rbp),%rax
mov    -0x3c(%rbp),%ecx
sub    $0x2,%ecx
movslq %ecx,%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x30(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rdi
lea    0xdb0(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    1286 <read_config+0x126>
movb   $0x1,-0x3d(%rbp)
movb   $0x0,-0x3e(%rbp)
mov    -0x30(%rbp),%rdi
lea    0xd9e(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    12a8 <read_config+0x148>
movb   $0x0,-0x3d(%rbp)
movb   $0x1,-0x3e(%rbp)
jmp    11e5 <read_config+0x85>
mov    -0x30(%rbp),%rax
mov    -0x3c(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movb   $0x2f,(%rax,%rcx,1)
mov    -0x44(%rbp),%eax
add    -0x3c(%rbp),%eax
cmp    $0x27ff,%eax
jge    12e0 <read_config+0x180>
mov    -0x44(%rbp),%eax
add    -0x3c(%rbp),%eax
cmp    $0x27ff,%eax
jl     1311 <read_config+0x1b1>
mov    0x2cf9(%rip),%rax
mov    (%rax),%edi
lea    0xd51(%rip),%rsi
mov    $0x2800,%edx
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    -0x28(%rbp),%rdi
call   1030 <fclose@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1366 <read_config+0x206>
cmpb   $0x0,-0x3d(%rbp)
je     1331 <read_config+0x1d1>
mov    -0x3c(%rbp),%eax
add    -0x44(%rbp),%eax
mov    %eax,-0x44(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x30(%rbp),%rsi
call   1080 <strcat@plt>
cmpb   $0x0,-0x3e(%rbp)
je     1351 <read_config+0x1f1>
mov    -0x3c(%rbp),%eax
add    -0x48(%rbp),%eax
mov    %eax,-0x48(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x30(%rbp),%rsi
call   1080 <strcat@plt>
jmp    11e5 <read_config+0x85>
mov    -0x28(%rbp),%rdi
call   1030 <fclose@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<read_config>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%rbp
movq   $0x0,(%rsp)
movq   $0x0,0x10(%rsp)
lea    0xeb0(%rip),%rsi
call   1060 <fopen@plt>
test   %rax,%rax
je     12d0 <read_config+0x170>
mov    %rax,%rbx
mov    %r15,0x18(%rsp)
mov    %r14,0x20(%rsp)
mov    %rsp,%rdi
lea    0x10(%rsp),%rsi
mov    %rax,%rdx
call   1070 <getline@plt>
cmp    $0xffffffff,%eax
je     12c4 <read_config+0x164>
mov    %eax,%ebp
mov    %rsp,%r12
lea    0x10(%rsp),%r13
movl   $0x0,0xc(%rsp)
xor    %r14d,%r14d
xor    %r15d,%r15d
jmp    11fe <read_config+0x9e>
nopl   (%rax)
cmp    $0x3b,%cl
jne    1216 <read_config+0xb6>
mov    %r12,%rdi
mov    %r13,%rsi
mov    %rbx,%rdx
call   1070 <getline@plt>
mov    %eax,%ebp
cmp    $0xffffffff,%eax
je     12c4 <read_config+0x164>
mov    (%rsp),%rax
movzbl (%rax),%ecx
cmp    $0x3a,%cl
jg     11e0 <read_config+0x80>
cmp    $0xa,%cl
je     11e5 <read_config+0x85>
cmp    $0x20,%cl
je     11e5 <read_config+0x85>
jmp    127d <read_config+0x11d>
cmp    $0x5b,%cl
jne    127d <read_config+0x11d>
movslq %ebp,%rcx
movb   $0x0,-0x2(%rcx,%rax,1)
mov    (%rsp),%rdi
add    $0x1,%rdi
mov    %rdi,(%rsp)
lea    0xde9(%rip),%rsi
call   1040 <strcmp@plt>
test   %rax,%rax
movzbl %r15b,%r15d
mov    $0x1,%eax
cmove  %eax,%r15d
movzbl %r14b,%r14d
mov    $0x0,%ebp
cmove  %ebp,%r14d
mov    (%rsp),%rdi
lea    0xdcc(%rip),%rsi
call   1040 <strcmp@plt>
test   %rax,%rax
cmove  %ebp,%r15d
mov    $0x1,%eax
cmove  %eax,%r14d
jmp    11e5 <read_config+0x85>
movslq %ebp,%rcx
movb   $0x2f,-0x1(%rcx,%rax,1)
add    0xc(%rsp),%ebp
cmp    $0x27ff,%ebp
jge    12fe <read_config+0x19e>
test   %r15b,%r15b
je     12a8 <read_config+0x148>
mov    (%rsp),%rsi
mov    0x18(%rsp),%rdi
call   1080 <strcat@plt>
mov    %ebp,0xc(%rsp)
test   %r14b,%r14b
je     11e5 <read_config+0x85>
mov    (%rsp),%rsi
mov    0x20(%rsp),%rdi
call   1080 <strcat@plt>
jmp    11e5 <read_config+0x85>
mov    %rbx,%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
jmp    12ef <read_config+0x18f>
mov    0x2d09(%rip),%rax
mov    (%rax),%edi
lea    0xd20(%rip),%rsi
mov    %rbp,%rdx
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    $0xffffffff,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2cdb(%rip),%rax
mov    (%rax),%edi
lea    0xd33(%rip),%rsi
mov    $0x2800,%edx
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    %rbx,%rdi
call   1030 <fclose@plt>
jmp    12ea <read_config+0x18a>

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
@stderr = global i32 0
@.str.1 = [31 x i8] c"error: can't read the file %s\0A\00"
@.str.2 = [16 x i8] c"whitelist_exact\00"
@.str.3 = [18 x i8] c"whitelist_similar\00"
@.str.4 = [62 x i8] c"error: the section in the config file is more than %i bytes.\0A\00"
define i32 @read_config(i8* %0, i8* %1, i8* %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i32*
%9 = alloca i8*
%10 = alloca i64
%11 = alloca i32
%12 = alloca i8
%13 = alloca i8
%14 = alloca i32
%15 = alloca i32
store i8* %0, i8** %5
store i8* %1, i8** %6
store i8* %2, i8** %7
store i8* null, i8** %9
store i64 0, i64* %10
store i8 0, i8* %12
store i8 0, i8* %13
store i32 0, i32* %14
store i32 0, i32* %15
%16 = load i8*, i8** %5
%17 = call i32* @fopen(i8* %16, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %17, i32** %8
%18 = load i32*, i32** %8
%19 = icmp eq i32* %18, null
br i1 %19, label %20, label %24
20: ; preds = %3
%21 = load i32, i32* @stderr
%22 = load i8*, i8** %5
%23 = call i32 (i32, i8*, ...) @fprintf(i32 %21, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0), i8* %22)
store i32 -1, i32* %4
br label %116
24: ; preds = %3
br label %25
25: ; preds = %112, %71, %47, %24
%26 = load i32*, i32** %8
%27 = call i32 @getline(i8** %9, i64* %10, i32* %26)
store i32 %27, i32* %11
%28 = icmp ne i32 %27, -1
br i1 %28, label %29, label %113
29: ; preds = %25
%30 = load i8*, i8** %9
%31 = getelementptr inbounds i8, i8* %30, i64 0
%32 = load i8, i8* %31
%33 = sext i8 %32 to i32
%34 = icmp eq i32 %33, 32
br i1 %34, label %47, label %35
35: ; preds = %29
%36 = load i8*, i8** %9
%37 = getelementptr inbounds i8, i8* %36, i64 0
%38 = load i8, i8* %37
%39 = sext i8 %38 to i32
%40 = icmp eq i32 %39, 59
br i1 %40, label %47, label %41
41: ; preds = %35
%42 = load i8*, i8** %9
%43 = getelementptr inbounds i8, i8* %42, i64 0
%44 = load i8, i8* %43
%45 = sext i8 %44 to i32
%46 = icmp eq i32 %45, 10
br i1 %46, label %47, label %48
47: ; preds = %41, %35, %29
br label %25
48: ; preds = %41
%49 = load i8*, i8** %9
%50 = getelementptr inbounds i8, i8* %49, i64 0
%51 = load i8, i8* %50
%52 = sext i8 %51 to i32
%53 = icmp eq i32 %52, 91
br i1 %53, label %54, label %72
54: ; preds = %48
%55 = load i8*, i8** %9
%56 = load i32, i32* %11
%57 = sub nsw i32 %56, 2
%58 = sext i32 %57 to i64
%59 = getelementptr inbounds i8, i8* %55, i64 %58
store i8 0, i8* %59
%60 = load i8*, i8** %9
%61 = getelementptr inbounds i8, i8* %60, i32 1
store i8* %61, i8** %9
%62 = load i8*, i8** %9
%63 = call i64 @strcmp(i8* %62, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0))
%64 = icmp eq i64 %63, 0
br i1 %64, label %65, label %66
65: ; preds = %54
store i8 1, i8* %12
store i8 0, i8* %13
br label %66
66: ; preds = %65, %54
%67 = load i8*, i8** %9
%68 = call i64 @strcmp(i8* %67, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0))
%69 = icmp eq i64 %68, 0
br i1 %69, label %70, label %71
70: ; preds = %66
store i8 0, i8* %12
store i8 1, i8* %13
br label %71
71: ; preds = %70, %66
br label %25
72: ; preds = %48
%73 = load i8*, i8** %9
%74 = load i32, i32* %11
%75 = sub nsw i32 %74, 1
%76 = sext i32 %75 to i64
%77 = getelementptr inbounds i8, i8* %73, i64 %76
store i8 47, i8* %77
%78 = load i32, i32* %14
%79 = load i32, i32* %11
%80 = add nsw i32 %78, %79
%81 = icmp sge i32 %80, 10239
br i1 %81, label %87, label %82
82: ; preds = %72
%83 = load i32, i32* %14
%84 = load i32, i32* %11
%85 = add nsw i32 %83, %84
%86 = icmp sge i32 %85, 10239
br i1 %86, label %87, label %92
87: ; preds = %82, %72
%88 = load i32, i32* @stderr
%89 = call i32 (i32, i8*, ...) @fprintf(i32 %88, i8* getelementptr inbounds ([62 x i8], [62 x i8]* @.str.4, i64 0, i64 0), i32 10240)
%90 = load i32*, i32** %8
%91 = call i32 @fclose(i32* %90)
store i32 -1, i32* %4
br label %116
92: ; preds = %82
%93 = load i8, i8* %12
%94 = icmp ne i8 %93, 0
br i1 %94, label %95, label %102
95: ; preds = %92
%96 = load i32, i32* %11
%97 = load i32, i32* %14
%98 = add nsw i32 %97, %96
store i32 %98, i32* %14
%99 = load i8*, i8** %6
%100 = load i8*, i8** %9
%101 = call i32 @strcat(i8* %99, i8* %100)
br label %102
102: ; preds = %95, %92
%103 = load i8, i8* %13
%104 = icmp ne i8 %103, 0
br i1 %104, label %105, label %112
105: ; preds = %102
%106 = load i32, i32* %11
%107 = load i32, i32* %15
%108 = add nsw i32 %107, %106
store i32 %108, i32* %15
%109 = load i8*, i8** %7
%110 = load i8*, i8** %9
%111 = call i32 @strcat(i8* %109, i8* %110)
br label %112
112: ; preds = %105, %102
br label %25
113: ; preds = %25
%114 = load i32*, i32** %8
%115 = call i32 @fclose(i32* %114)
store i32 0, i32* %4
br label %116
116: ; preds = %113, %87, %20
%117 = load i32, i32* %4
ret i32 %117
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
@stderr = global i32 0
@.str.1 = [31 x i8] c"error: can't read the file %s\0A\00"
@.str.2 = [16 x i8] c"whitelist_exact\00"
@.str.3 = [18 x i8] c"whitelist_similar\00"
@.str.4 = [62 x i8] c"error: the section in the config file is more than %i bytes.\0A\00"
define i32 @read_config(i8* %0, i8* %1, i8* %2) {
%4 = alloca i8*
%5 = alloca i64
%6 = bitcast i8** %4 to i8*
store i8* null, i8** %4
%7 = bitcast i64* %5 to i8*
store i64 0, i64* %5
%8 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%9 = icmp eq i32* %8, null
br i1 %9, label %13, label %10
10: ; preds = %3
%11 = call i32 @getline(i8** %4, i64* %5, i32* %8)
%12 = icmp eq i32 %11, -1
br i1 %12, label %72, label %40
13: ; preds = %3
%14 = load i32, i32* @stderr
%15 = tail call i32 (i32, i8*, ...) @fprintf(i32 %14, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0), i8* %0)
br label %74
16: ; preds = %47, %20
%17 = phi i32 [ %48, %47 ], [ %21, %20 ]
%18 = load i8*, i8** %4
%19 = load i8, i8* %18
switch i8 %19, label %50 [
i8 32, label %20
i8 59, label %20
i8 10, label %20
i8 91, label %23
]
20: ; preds = %16, %16, %16
%21 = call i32 @getline(i8** %4, i64* %5, i32* %8)
%22 = icmp eq i32 %21, -1
br i1 %22, label %72, label %16
23: ; preds = %16
%24 = add nsw i32 %17, -2
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds i8, i8* %18, i64 %25
store i8 0, i8* %26
%27 = load i8*, i8** %4
%28 = getelementptr inbounds i8, i8* %27, i64 1
store i8* %28, i8** %4
%29 = call i64 @strcmp(i8* %28, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0))
%30 = icmp eq i64 %29, 0
%31 = select i1 %30, i8 1, i8 %44
%32 = select i1 %30, i8 0, i8 %43
%33 = load i8*, i8** %4
%34 = call i64 @strcmp(i8* %33, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0))
%35 = icmp eq i64 %34, 0
%36 = select i1 %35, i8 0, i8 %31
%37 = select i1 %35, i8 1, i8 %32
%38 = call i32 @getline(i8** %4, i64* %5, i32* %8)
%39 = icmp eq i32 %38, -1
br i1 %39, label %72, label %40
40: ; preds = %10, %23
%41 = phi i32 [ %38, %23 ], [ %11, %10 ]
%42 = phi i32 [ %49, %23 ], [ 0, %10 ]
%43 = phi i8 [ %37, %23 ], [ 0, %10 ]
%44 = phi i8 [ %36, %23 ], [ 0, %10 ]
%45 = icmp eq i8 %44, 0
%46 = icmp eq i8 %43, 0
br label %47
47: ; preds = %40, %69
%48 = phi i32 [ %41, %40 ], [ %70, %69 ]
%49 = phi i32 [ %42, %40 ], [ %65, %69 ]
br label %16
50: ; preds = %16
%51 = add nsw i32 %17, -1
%52 = sext i32 %51 to i64
%53 = getelementptr inbounds i8, i8* %18, i64 %52
store i8 47, i8* %53
%54 = add nsw i32 %17, %49
%55 = icmp sgt i32 %54, 10238
br i1 %55, label %56, label %60
56: ; preds = %50
%57 = load i32, i32* @stderr
%58 = call i32 (i32, i8*, ...) @fprintf(i32 %57, i8* getelementptr inbounds ([62 x i8], [62 x i8]* @.str.4, i64 0, i64 0), i32 10240)
%59 = call i32 @fclose(i32* %8)
br label %74
60: ; preds = %50
br i1 %45, label %64, label %61
61: ; preds = %60
%62 = load i8*, i8** %4
%63 = call i32 @strcat(i8* %1, i8* %62)
br label %64
64: ; preds = %61, %60
%65 = phi i32 [ %54, %61 ], [ %49, %60 ]
br i1 %46, label %69, label %66
66: ; preds = %64
%67 = load i8*, i8** %4
%68 = call i32 @strcat(i8* %2, i8* %67)
br label %69
69: ; preds = %66, %64
%70 = call i32 @getline(i8** %4, i64* %5, i32* %8)
%71 = icmp eq i32 %70, -1
br i1 %71, label %72, label %47
72: ; preds = %23, %69, %20, %10
%73 = call i32 @fclose(i32* %8)
br label %74
74: ; preds = %72, %56, %13
%75 = phi i32 [ -1, %13 ], [ -1, %56 ], [ 0, %72 ]
ret i32 %75
}