#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*/ exit(int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
scalar_t__ fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
scalar_t__ malloc(size_t);
int /*<<< orphan*/ stderr;
size_t strlen(char *);
char *strncpy(char *, char *, size_t);
void get_exclude_list(char *fname, char *list[]) {
  FILE *fp;
  char *a, buf[1024];
  size_t len;
  int i = 0;
  fp = fopen(fname, "r");
  if (fp == NULL) {
    fprintf(stderr, "could not open: %s\n", fname);
    exit(1);
  }
  while (fgets(buf, 1024, (FILE *)fp)) {
    len = strlen(buf);
    buf[len - 1] = '\0';
    a = (char *)malloc(len);
    list[i++] = strncpy(a, buf, len);
  }
  list[i] = NULL;
  fclose(fp);
}


x86 assembly (clang, -O0):
<get_exclude_list>:
push   %rbp
mov    %rsp,%rbp
sub    $0x430,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x42c(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xe58(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    11df <get_exclude_list+0x5f>
mov    0x2e1d(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rdx
lea    0xe32(%rip),%rsi
call   1070 <fprintf@plt>
mov    $0x1,%edi
call   10a0 <exit@plt>
jmp    11e4 <get_exclude_list+0x64>
lea    -0x420(%rbp),%rdi
mov    -0x18(%rbp),%rdx
mov    $0x400,%esi
call   1060 <fgets@plt>
cmp    $0x0,%rax
je     1274 <get_exclude_list+0xf4>
lea    -0x420(%rbp),%rdi
call   1050 <strlen@plt>
mov    %rax,-0x428(%rbp)
mov    -0x428(%rbp),%rax
sub    $0x1,%rax
movb   $0x0,-0x420(%rbp,%rax,1)
mov    -0x428(%rbp),%rdi
call   1080 <malloc@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
lea    -0x420(%rbp),%rsi
mov    -0x428(%rbp),%rdx
call   1030 <strncpy@plt>
mov    %rax,%rdx
mov    -0x10(%rbp),%rax
mov    -0x42c(%rbp),%ecx
mov    %ecx,%esi
add    $0x1,%esi
mov    %esi,-0x42c(%rbp)
movslq %ecx,%rcx
mov    %rdx,(%rax,%rcx,8)
jmp    11e4 <get_exclude_list+0x64>
mov    -0x10(%rbp),%rax
movslq -0x42c(%rbp),%rcx
movq   $0x0,(%rax,%rcx,8)
mov    -0x18(%rbp),%rdi
call   1040 <fclose@plt>
add    $0x430,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_exclude_list>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x408,%rsp
mov    %rsi,%r14
mov    %rdi,%rbx
lea    0xe62(%rip),%rsi
call   1090 <fopen@plt>
test   %rax,%rax
je     123f <get_exclude_list+0xbf>
mov    %rax,%r15
mov    %rsp,%r12
mov    %r12,%rdi
mov    $0x400,%esi
mov    %rax,%rdx
call   1060 <fgets@plt>
test   %rax,%rax
je     121b <get_exclude_list+0x9b>
xor    %ebp,%ebp
nopl   0x0(%rax)
mov    %r12,%rdi
call   1050 <strlen@plt>
mov    %rax,%rbx
movb   $0x0,-0x1(%rax,%r12,1)
mov    %rax,%rdi
call   1080 <malloc@plt>
mov    %rax,%r13
mov    %rax,%rdi
mov    %r12,%rsi
mov    %rbx,%rdx
call   1030 <strncpy@plt>
mov    %r13,(%r14,%rbp,8)
add    $0x1,%rbp
mov    %r12,%rdi
mov    $0x400,%esi
mov    %r15,%rdx
call   1060 <fgets@plt>
test   %rax,%rax
jne    11d0 <get_exclude_list+0x50>
mov    %ebp,%eax
jmp    121d <get_exclude_list+0x9d>
xor    %eax,%eax
movq   $0x0,(%r14,%rax,8)
mov    %r15,%rdi
call   1040 <fclose@plt>
add    $0x408,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2d9a(%rip),%rax
mov    (%rax),%edi
lea    0xdb3(%rip),%rsi
mov    %rbx,%rdx
call   1070 <fprintf@plt>
mov    $0x1,%edi
call   10a0 <exit@plt>

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
@stderr = global i32 0
@.str.1 = [20 x i8] c"could not open: %s\0A\00"
define void @get_exclude_list(i8* %0, i8** %1) {
%3 = alloca i8*
%4 = alloca i8**
%5 = alloca i32*
%6 = alloca i8*
%7 = alloca [1024 x i8]
%8 = alloca i64
%9 = alloca i32
store i8* %0, i8** %3
store i8** %1, i8*** %4
store i32 0, i32* %9
%10 = load i8*, i8** %3
%11 = call i32* @fopen(i8* %10, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %11, i32** %5
%12 = load i32*, i32** %5
%13 = icmp eq i32* %12, null
br i1 %13, label %14, label %19
14: ; preds = %2
%15 = load i32, i32* @stderr
%16 = load i8*, i8** %3
%17 = call i32 @fprintf(i32 %15, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i8* %16)
%18 = call i32 @exit(i32 1)
unreachable
19: ; preds = %2
br label %20
20: ; preds = %25, %19
%21 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 0
%22 = load i32*, i32** %5
%23 = call i64 @fgets(i8* %21, i32 1024, i32* %22)
%24 = icmp ne i64 %23, 0
br i1 %24, label %25, label %43
25: ; preds = %20
%26 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 0
%27 = call i64 @strlen(i8* %26)
store i64 %27, i64* %8
%28 = load i64, i64* %8
%29 = sub i64 %28, 1
%30 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 %29
store i8 0, i8* %30
%31 = load i64, i64* %8
%32 = call i64 @malloc(i64 %31)
%33 = inttoptr i64 %32 to i8*
store i8* %33, i8** %6
%34 = load i8*, i8** %6
%35 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 0
%36 = load i64, i64* %8
%37 = call i8* @strncpy(i8* %34, i8* %35, i64 %36)
%38 = load i8**, i8*** %4
%39 = load i32, i32* %9
%40 = add nsw i32 %39, 1
store i32 %40, i32* %9
%41 = sext i32 %39 to i64
%42 = getelementptr inbounds i8*, i8** %38, i64 %41
store i8* %37, i8** %42
br label %20
43: ; preds = %20
%44 = load i8**, i8*** %4
%45 = load i32, i32* %9
%46 = sext i32 %45 to i64
%47 = getelementptr inbounds i8*, i8** %44, i64 %46
store i8* null, i8** %47
%48 = load i32*, i32** %5
%49 = call i32 @fclose(i32* %48)
ret void
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
@stderr = global i32 0
@.str.1 = [20 x i8] c"could not open: %s\0A\00"
define void @get_exclude_list(i8* %0, i8** nocapture writeonly %1) {
%3 = alloca [1024 x i8]
%4 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%5 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%6 = icmp eq i32* %5, null
br i1 %6, label %10, label %7
7: ; preds = %2
%8 = call i64 @fgets(i8* %4, i32 1024, i32* %5)
%9 = icmp eq i64 %8, 0
br i1 %9, label %28, label %14
10: ; preds = %2
%11 = load i32, i32* @stderr
%12 = tail call i32 @fprintf(i32 %11, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i8* %0)
%13 = tail call i32 @exit(i32 1)
unreachable
14: ; preds = %7, %14
%15 = phi i64 [ %22, %14 ], [ 0, %7 ]
%16 = call i64 @strlen(i8* %4)
%17 = add i64 %16, -1
%18 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 %17
store i8 0, i8* %18
%19 = call i64 @malloc(i64 %16)
%20 = inttoptr i64 %19 to i8*
%21 = call i8* @strncpy(i8* dereferenceable(1) %20, i8* %4, i64 %16)
%22 = add nuw i64 %15, 1
%23 = getelementptr inbounds i8*, i8** %1, i64 %15
store i8* %20, i8** %23
%24 = call i64 @fgets(i8* %4, i32 1024, i32* %5)
%25 = icmp eq i64 %24, 0
br i1 %25, label %26, label %14
26: ; preds = %14
%27 = and i64 %22, 4294967295
br label %28
28: ; preds = %26, %7
%29 = phi i64 [ 0, %7 ], [ %27, %26 ]
%30 = getelementptr inbounds i8*, i8** %1, i64 %29
store i8* null, i8** %30
%31 = call i32 @fclose(i32* %5)
ret void
}