#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);
scalar_t__ fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
char *getDomainRegexlst(char *);
int /*<<< orphan*/ strcpy(char *, char const *);
char *strstr(char *, char *);
int getActive(const char *domain1) {
  char domain[100];
  strcpy(domain, domain1);
  char *dregex = getDomainRegexlst(domain);
  if (dregex)
    strcpy(domain, dregex);
  FILE *ft = fopen("/etc/haarp/haarp.lst", "r");
  if (!ft)
    exit(1);
  char line[1000];
  char *l, *t;
  while (fgets(line, 1000, ft)) {
    t = strstr(line, "#");
    if (t)
      *t = '\0';
    l = strstr(line, domain);
    if (l)
      return 1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<getActive>:
push   %rbp
mov    %rsp,%rbp
sub    $0x490,%rsp
mov    %rdi,-0x10(%rbp)
lea    -0x80(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1030 <strcpy@plt>
lea    -0x80(%rbp),%rdi
call   1040 <getDomainRegexlst@plt>
mov    %rax,-0x88(%rbp)
cmpq   $0x0,-0x88(%rbp)
je     11aa <getActive+0x4a>
lea    -0x80(%rbp),%rdi
mov    -0x88(%rbp),%rsi
call   1030 <strcpy@plt>
lea    0xe4f(%rip),%rdi
lea    0xe5d(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x90(%rbp)
cmpq   $0x0,-0x90(%rbp)
jne    11dc <getActive+0x7c>
mov    $0x1,%edi
call   1070 <exit@plt>
jmp    11e1 <getActive+0x81>
lea    -0x480(%rbp),%rdi
mov    -0x90(%rbp),%rdx
mov    $0x3e8,%esi
call   1050 <fgets@plt>
cmp    $0x0,%rax
je     126b <getActive+0x10b>
lea    -0x480(%rbp),%rdi
lea    0xe06(%rip),%rsi
call   1080 <strstr@plt>
mov    %rax,-0x490(%rbp)
cmpq   $0x0,-0x490(%rbp)
je     1235 <getActive+0xd5>
mov    -0x490(%rbp),%rax
movb   $0x0,(%rax)
lea    -0x480(%rbp),%rdi
lea    -0x80(%rbp),%rsi
call   1080 <strstr@plt>
mov    %rax,-0x488(%rbp)
cmpq   $0x0,-0x488(%rbp)
je     1266 <getActive+0x106>
movl   $0x1,-0x4(%rbp)
jmp    1272 <getActive+0x112>
jmp    11e1 <getActive+0x81>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x490,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getActive>:
push   %r15
push   %r14
push   %rbx
sub    $0x460,%rsp
mov    %rdi,%rsi
mov    %rsp,%rbx
mov    %rbx,%rdi
call   1030 <strcpy@plt>
mov    %rbx,%rdi
call   1040 <getDomainRegexlst@plt>
test   %rax,%rax
je     11a2 <getActive+0x32>
mov    %rsp,%rdi
mov    %rax,%rsi
call   1030 <strcpy@plt>
lea    0xe57(%rip),%rdi
lea    0xe65(%rip),%rsi
call   1070 <fopen@plt>
test   %rax,%rax
je     1222 <getActive+0xb2>
mov    %rax,%r14
lea    0x70(%rsp),%rbx
mov    %rsp,%r15
jmp    11e0 <getActive+0x70>
nopw   0x0(%rax,%rax,1)
mov    %rbx,%rdi
mov    %r15,%rsi
call   1090 <strstr@plt>
test   %rax,%rax
jne    1210 <getActive+0xa0>
mov    %rbx,%rdi
mov    $0x3e8,%esi
mov    %r14,%rdx
call   1060 <fgets@plt>
test   %rax,%rax
je     120c <getActive+0x9c>
mov    %rbx,%rdi
mov    $0x23,%esi
call   1050 <strchr@plt>
test   %rax,%rax
je     11d0 <getActive+0x60>
movb   $0x0,(%rax)
jmp    11d0 <getActive+0x60>
xor    %eax,%eax
jmp    1215 <getActive+0xa5>
mov    $0x1,%eax
add    $0x460,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret
mov    $0x1,%edi
call   1080 <exit@plt>

LLVM IR (-O0):
@.str = [21 x i8] c"/etc/haarp/haarp.lst\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [2 x i8] c"#\00"
define i32 @getActive(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca [100 x i8]
%5 = alloca i8*
%6 = alloca i32*
%7 = alloca [1000 x i8]
%8 = alloca i8*
%9 = alloca i8*
store i8* %0, i8** %3
%10 = getelementptr inbounds [100 x i8], [100 x i8]* %4, i64 0, i64 0
%11 = load i8*, i8** %3
%12 = call i32 @strcpy(i8* %10, i8* %11)
%13 = getelementptr inbounds [100 x i8], [100 x i8]* %4, i64 0, i64 0
%14 = call i8* @getDomainRegexlst(i8* %13)
store i8* %14, i8** %5
%15 = load i8*, i8** %5
%16 = icmp ne i8* %15, null
br i1 %16, label %17, label %21
17: ; preds = %1
%18 = getelementptr inbounds [100 x i8], [100 x i8]* %4, i64 0, i64 0
%19 = load i8*, i8** %5
%20 = call i32 @strcpy(i8* %18, i8* %19)
br label %21
21: ; preds = %17, %1
%22 = call i32* @fopen(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %22, i32** %6
%23 = load i32*, i32** %6
%24 = icmp ne i32* %23, null
br i1 %24, label %27, label %25
25: ; preds = %21
%26 = call i32 @exit(i32 1)
unreachable
27: ; preds = %21
br label %28
28: ; preds = %47, %27
%29 = getelementptr inbounds [1000 x i8], [1000 x i8]* %7, i64 0, i64 0
%30 = load i32*, i32** %6
%31 = call i64 @fgets(i8* %29, i32 1000, i32* %30)
%32 = icmp ne i64 %31, 0
br i1 %32, label %33, label %48
33: ; preds = %28
%34 = getelementptr inbounds [1000 x i8], [1000 x i8]* %7, i64 0, i64 0
%35 = call i8* @strstr(i8* %34, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i8* %35, i8** %9
%36 = load i8*, i8** %9
%37 = icmp ne i8* %36, null
br i1 %37, label %38, label %40
38: ; preds = %33
%39 = load i8*, i8** %9
store i8 0, i8* %39
br label %40
40: ; preds = %38, %33
%41 = getelementptr inbounds [1000 x i8], [1000 x i8]* %7, i64 0, i64 0
%42 = getelementptr inbounds [100 x i8], [100 x i8]* %4, i64 0, i64 0
%43 = call i8* @strstr(i8* %41, i8* %42)
store i8* %43, i8** %8
%44 = load i8*, i8** %8
%45 = icmp ne i8* %44, null
br i1 %45, label %46, label %47
46: ; preds = %40
store i32 1, i32* %2
br label %49
47: ; preds = %40
br label %28
48: ; preds = %28
store i32 0, i32* %2
br label %49
49: ; preds = %48, %46
%50 = load i32, i32* %2
ret i32 %50
}

LLVM IR (-O2):
@.str = [21 x i8] c"/etc/haarp/haarp.lst\00"
@.str.1 = [2 x i8] c"r\00"
define i32 @getActive(i8* %0) {
%2 = alloca [100 x i8]
%3 = alloca [1000 x i8]
%4 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%5 = call i32 @strcpy(i8* %4, i8* %0)
%6 = call i8* @getDomainRegexlst(i8* %4)
%7 = icmp eq i8* %6, null
br i1 %7, label %10, label %8
8: ; preds = %1
%9 = call i32 @strcpy(i8* %4, i8* %6)
br label %10
10: ; preds = %8, %1
%11 = call i32* @fopen(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%12 = icmp eq i32* %11, null
br i1 %12, label %13, label %15
13: ; preds = %10
%14 = call i32 @exit(i32 1)
unreachable
15: ; preds = %10
%16 = getelementptr inbounds [1000 x i8], [1000 x i8]* %3, i64 0, i64 0
br label %17
17: ; preds = %24, %15
%18 = call i64 @fgets(i8* %16, i32 1000, i32* %11)
%19 = icmp eq i64 %18, 0
br i1 %19, label %27, label %20
20: ; preds = %17
%21 = call i8* @strchr(i8* %16, i32 35)
%22 = icmp eq i8* %21, null
br i1 %22, label %24, label %23
23: ; preds = %20
store i8 0, i8* %21
br label %24
24: ; preds = %23, %20
%25 = call i8* @strstr(i8* %16, i8* %4)
%26 = icmp eq i8* %25, null
br i1 %26, label %17, label %27
27: ; preds = %17, %24
%28 = phi i32 [ 1, %24 ], [ 0, %17 ]
ret i32 %28
}