#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*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ feof(int /*<<< orphan*/ *);
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ logErrorMessages(char *, char *);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ read_str_from_line(char *, char *);
scalar_t__ strstr(char *, char *);
int main(int argc, char *argv[]) {
  char **to_be_returned[100][50];
  FILE *fp;
  char buf[100];
  char log_file_name[50] = "/root/logs/files.log";
  if ((fp = fopen(log_file_name, "r")) == NULL) {
    logErrorMessages("Failed to open config file", log_file_name);
  }
  while (!feof(fp)) {
    fgets(buf, 100, fp);
    if (strstr(buf, "23-03-2017")) {
      char tester[50];
      read_str_from_line(buf, tester);
      printf("%s\n", tester);
    }
  }
  fclose(fp);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x9d40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x9d00(%rbp),%rdi
lea    0xe49(%rip),%rsi
mov    $0x32,%edx
call   1080 <memcpy@plt>
lea    -0x9d00(%rbp),%rdi
lea    0xe63(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,-0x9c58(%rbp)
cmp    $0x0,%rax
jne    11f8 <main+0x68>
lea    -0x9d00(%rbp),%rsi
lea    0xe41(%rip),%rdi
call   1090 <logErrorMessages@plt>
jmp    11fd <main+0x6d>
mov    -0x9c58(%rbp),%rdi
call   1070 <feof@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    121e <main+0x8e>
jmp    127e <main+0xee>
lea    -0x9cc0(%rbp),%rdi
mov    -0x9c58(%rbp),%rdx
mov    $0x64,%esi
call   1060 <fgets@plt>
lea    -0x9cc0(%rbp),%rdi
lea    0xe0b(%rip),%rsi
call   10b0 <strstr@plt>
cmp    $0x0,%rax
je     1279 <main+0xe9>
lea    -0x9cc0(%rbp),%rdi
lea    -0x9d40(%rbp),%rsi
call   1050 <read_str_from_line@plt>
lea    -0x9d40(%rbp),%rsi
lea    0xde6(%rip),%rdi
call   1040 <printf@plt>
jmp    11fd <main+0x6d>
mov    -0x9c58(%rbp),%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
add    $0x9d40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0xf0,%rsp
movaps 0xe89(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
movaps 0xe6d(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movaps 0xe51(%rip),%xmm0
movaps %xmm0,(%rsp)
movw   $0x0,0x30(%rsp)
lea    0xe71(%rip),%rsi
mov    %rsp,%rdi
call   1090 <fopen@plt>
mov    %rax,%rbx
test   %rax,%rax
jne    11e0 <main+0x60>
lea    0xe5c(%rip),%rdi
mov    %rsp,%rsi
call   1080 <logErrorMessages@plt>
mov    %rbx,%rdi
call   1070 <feof@plt>
test   %eax,%eax
je     1207 <main+0x87>
mov    %rbx,%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
add    $0xf0,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret
lea    0x80(%rsp),%r14
lea    0xe39(%rip),%r15
lea    0x40(%rsp),%r12
lea    0xe38(%rip),%r13
jmp    123c <main+0xbc>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %rbx,%rdi
call   1070 <feof@plt>
test   %eax,%eax
jne    11ec <main+0x6c>
mov    %r14,%rdi
mov    $0x64,%esi
mov    %rbx,%rdx
call   1060 <fgets@plt>
mov    %r14,%rdi
mov    %r15,%rsi
call   10a0 <strstr@plt>
test   %rax,%rax
je     1230 <main+0xb0>
mov    %r14,%rdi
mov    %r12,%rsi
call   1050 <read_str_from_line@plt>
mov    %r13,%rdi
mov    %r12,%rsi
call   1040 <printf@plt>
jmp    1230 <main+0xb0>

LLVM IR (-O0):
@__const.main.log_file_name = [50 x i8] c"/root/logs/files.log\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00"
@.str = [2 x i8] c"r\00"
@.str.1 = [27 x i8] c"Failed to open config file\00"
@.str.2 = [11 x i8] c"23-03-2017\00"
@.str.3 = [4 x i8] c"%s\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [100 x [50 x i8**]]
%7 = alloca i32*
%8 = alloca [100 x i8]
%9 = alloca [50 x i8]
%10 = alloca [50 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%11 = bitcast [50 x i8]* %9 to i8*
%12 = getelementptr inbounds [50 x i8], [50 x i8]* %9, i64 0, i64 0
%13 = call i32* @fopen(i8* %12, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %13, i32** %7
%14 = icmp eq i32* %13, null
br i1 %14, label %15, label %18
15: ; preds = %2
%16 = getelementptr inbounds [50 x i8], [50 x i8]* %9, i64 0, i64 0
%17 = call i32 @logErrorMessages(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0), i8* %16)
br label %18
18: ; preds = %15, %2
br label %19
19: ; preds = %37, %18
%20 = load i32*, i32** %7
%21 = call i32 @feof(i32* %20)
%22 = icmp ne i32 %21, 0
%23 = xor i1 %22, true
br i1 %23, label %24, label %38
24: ; preds = %19
%25 = getelementptr inbounds [100 x i8], [100 x i8]* %8, i64 0, i64 0
%26 = load i32*, i32** %7
%27 = call i32 @fgets(i8* %25, i32 100, i32* %26)
%28 = getelementptr inbounds [100 x i8], [100 x i8]* %8, i64 0, i64 0
%29 = call i64 @strstr(i8* %28, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0))
%30 = icmp ne i64 %29, 0
br i1 %30, label %31, label %37
31: ; preds = %24
%32 = getelementptr inbounds [100 x i8], [100 x i8]* %8, i64 0, i64 0
%33 = getelementptr inbounds [50 x i8], [50 x i8]* %10, i64 0, i64 0
%34 = call i32 @read_str_from_line(i8* %32, i8* %33)
%35 = getelementptr inbounds [50 x i8], [50 x i8]* %10, i64 0, i64 0
%36 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8* %35)
br label %37
37: ; preds = %31, %24
br label %19
38: ; preds = %19
%39 = load i32*, i32** %7
%40 = call i32 @fclose(i32* %39)
ret i32 0
}

LLVM IR (-O2):
@__const.main.log_file_name = [50 x i8] c"/root/logs/files.log\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00"
@.str = [2 x i8] c"r\00"
@.str.1 = [27 x i8] c"Failed to open config file\00"
@.str.2 = [11 x i8] c"23-03-2017\00"
@.str.3 = [4 x i8] c"%s\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [100 x i8]
%4 = alloca [50 x i8]
%5 = alloca [50 x i8]
%6 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%7 = getelementptr inbounds [50 x i8], [50 x i8]* %4, i64 0, i64 0
%8 = call i32* @fopen(i8* %7, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%9 = icmp eq i32* %8, null
br i1 %9, label %10, label %12
10: ; preds = %2
%11 = call i32 @logErrorMessages(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0), i8* %7)
br label %12
12: ; preds = %10, %2
%13 = call i32 @feof(i32* %8)
%14 = icmp eq i32 %13, 0
br i1 %14, label %15, label %27
15: ; preds = %12
%16 = getelementptr inbounds [50 x i8], [50 x i8]* %5, i64 0, i64 0
br label %17
17: ; preds = %15, %24
%18 = call i32 @fgets(i8* %6, i32 100, i32* %8)
%19 = call i64 @strstr(i8* %6, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0))
%20 = icmp eq i64 %19, 0
br i1 %20, label %24, label %21
21: ; preds = %17
%22 = call i32 @read_str_from_line(i8* %6, i8* %16)
%23 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8* %16)
br label %24
24: ; preds = %21, %17
%25 = call i32 @feof(i32* %8)
%26 = icmp eq i32 %25, 0
br i1 %26, label %17, label %27
27: ; preds = %24, %12
%28 = call i32 @fclose(i32* %8)
ret i32 0
}