#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*/ EXIT_FAILURE;
int EXIT_SUCCESS;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fputs(char *, int /*<<< orphan*/ *);
int /*<<< orphan*/ free(char *);
int getline(char **, size_t *, int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ sprintf(char *, char *, char *, ...);
int /*<<< orphan*/ strcpy(char *, char *);
scalar_t__ strstr(char *, char *);
char *strtok(char *, char *);
int main(int argc, char *argv[]) {
  FILE *fp;
  char *line = NULL;
  size_t len = 0;
  ssize_t read;
  fp = fopen(argv[1], "r");
  char filenameOutput[30];
  char *dateSave;
  char *timeSave;
  int doTokenize = 1;
  if (fp == NULL)
    exit(EXIT_FAILURE);
  while ((read = getline(&line, &len, fp)) != -1) {
    if ((strstr(line, "-----")) || (strstr(line, "====="))) {
      doTokenize = 1;
      sprintf(filenameOutput, "%s", "");
      continue;
    }
    if (doTokenize == 1) {
      char saveLine[4096];
      strcpy(saveLine, line);
      dateSave = strtok(saveLine, " ");
      timeSave = strtok(NULL, " ");
      sprintf(filenameOutput, "%s_%s.out", dateSave, timeSave);
      doTokenize = 0;
    }
    FILE *fpWrite = fopen(filenameOutput, "a");
    if (!fpWrite) {
      printf("Output File could not be opened.\n");
      exit(EXIT_FAILURE);
    }
    fputs(line, fpWrite);
    fclose(fpWrite);
  }
  if (line)
    free(line);
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1080,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x20(%rbp)
movq   $0x0,-0x28(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe18(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x18(%rbp)
movl   $0x1,-0x64(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    1211 <main+0x61>
mov    0x2dd6(%rip),%rax
mov    (%rax),%edi
call   10c0 <exit@plt>
jmp    1216 <main+0x66>
mov    -0x18(%rbp),%rdx
lea    -0x20(%rbp),%rdi
lea    -0x28(%rbp),%rsi
call   10a0 <getline@plt>
mov    %eax,-0x2c(%rbp)
cmp    $0xffffffff,%eax
je     1352 <main+0x1a2>
mov    -0x20(%rbp),%rdi
lea    0xdc4(%rip),%rsi
call   10d0 <strstr@plt>
cmp    $0x0,%rax
jne    1267 <main+0xb7>
mov    -0x20(%rbp),%rdi
lea    0xdb0(%rip),%rsi
call   10d0 <strstr@plt>
cmp    $0x0,%rax
je     128c <main+0xdc>
movl   $0x1,-0x64(%rbp)
lea    -0x50(%rbp),%rdi
lea    0xd95(%rip),%rsi
lea    0xdc0(%rip),%rdx
mov    $0x0,%al
call   10b0 <sprintf@plt>
jmp    1216 <main+0x66>
cmpl   $0x1,-0x64(%rbp)
jne    12f2 <main+0x142>
lea    -0x1070(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1040 <strcpy@plt>
lea    -0x1070(%rbp),%rdi
lea    0xd5d(%rip),%rsi
call   1090 <strtok@plt>
mov    %rax,-0x58(%rbp)
xor    %eax,%eax
mov    %eax,%edi
lea    0xd49(%rip),%rsi
call   1090 <strtok@plt>
mov    %rax,-0x60(%rbp)
lea    -0x50(%rbp),%rdi
mov    -0x58(%rbp),%rdx
mov    -0x60(%rbp),%rcx
lea    0xd2f(%rip),%rsi
mov    $0x0,%al
call   10b0 <sprintf@plt>
movl   $0x0,-0x64(%rbp)
lea    -0x50(%rbp),%rdi
lea    0xd20(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x1078(%rbp)
cmpq   $0x0,-0x1078(%rbp)
jne    1331 <main+0x181>
lea    0xd01(%rip),%rdi
call   1060 <printf@plt>
mov    0x2cb6(%rip),%rax
mov    (%rax),%edi
call   10c0 <exit@plt>
mov    -0x20(%rbp),%rdi
mov    -0x1078(%rbp),%rsi
call   1070 <fputs@plt>
mov    -0x1078(%rbp),%rdi
call   1050 <fclose@plt>
jmp    1216 <main+0x66>
cmpq   $0x0,-0x20(%rbp)
je     1366 <main+0x1b6>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
mov    0x2c6b(%rip),%rax
mov    (%rax),%eax
add    $0x1080,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x1038,%rsp
movq   $0x0,(%rsp)
movq   $0x0,0x8(%rsp)
mov    0x8(%rsi),%rdi
lea    0xe23(%rip),%rsi
call   1080 <fopen@plt>
test   %rax,%rax
je     1336 <main+0x186>
mov    %rax,%r13
mov    %rsp,%rdi
lea    0x8(%rsp),%rsi
mov    %rax,%rdx
call   10a0 <getline@plt>
cmp    $0xffffffff,%eax
je     1301 <main+0x151>
mov    $0x1,%bpl
lea    0xdf1(%rip),%rbx
lea    0xdf0(%rip),%r15
lea    0x10(%rsp),%r14
lea    0x8(%rsp),%r12
jmp    1259 <main+0xa9>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %r14,%rdi
lea    0xdd5(%rip),%rsi
call   1040 <strcpy@plt>
mov    $0x1,%bpl
mov    %rsp,%rdi
mov    %r12,%rsi
mov    %r13,%rdx
call   10a0 <getline@plt>
cmp    $0xffffffff,%eax
je     1301 <main+0x151>
mov    (%rsp),%rdi
mov    %rbx,%rsi
call   10d0 <strstr@plt>
test   %rax,%rax
jne    1230 <main+0x80>
mov    (%rsp),%rdi
mov    %r15,%rsi
call   10d0 <strstr@plt>
test   %rax,%rax
jne    1230 <main+0x80>
test   $0x1,%bpl
je     12c8 <main+0x118>
mov    (%rsp),%rsi
lea    0x30(%rsp),%rbp
mov    %rbp,%rdi
call   1040 <strcpy@plt>
mov    %rbp,%rdi
lea    0xd72(%rip),%rbp
mov    %rbp,%rsi
call   1090 <strtok@plt>
mov    %rax,%r15
xor    %edi,%edi
mov    %rbp,%rsi
call   1090 <strtok@plt>
mov    %r14,%rdi
lea    0xd55(%rip),%rsi
mov    %r15,%rdx
mov    %rax,%rcx
xor    %eax,%eax
call   10b0 <sprintf@plt>
mov    %r14,%rdi
lea    0xd48(%rip),%rsi
call   1080 <fopen@plt>
test   %rax,%rax
je     132a <main+0x17a>
mov    %rax,%r15
mov    (%rsp),%rdi
mov    %rax,%rsi
call   1070 <fputs@plt>
mov    %r15,%rdi
call   1060 <fclose@plt>
xor    %ebp,%ebp
lea    0xd0c(%rip),%r15
jmp    1242 <main+0x92>
mov    (%rsp),%rdi
test   %rdi,%rdi
je     130f <main+0x15f>
call   1030 <free@plt>
mov    0x2cc2(%rip),%rax
mov    (%rax),%eax
add    $0x1038,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xceb(%rip),%rdi
call   1050 <puts@plt>
mov    0x2ca3(%rip),%rax
mov    (%rax),%edi
call   10c0 <exit@plt>

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [6 x i8] c"-----\00"
@.str.2 = [6 x i8] c"=====\00"
@.str.3 = [3 x i8] c"%s\00"
@.str.4 = [1 x i8] zeroinitializer
@.str.5 = [2 x i8] c" \00"
@.str.6 = [10 x i8] c"%s_%s.out\00"
@.str.7 = [2 x i8] c"a\00"
@.str.8 = [34 x i8] c"Output File could not be opened.\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
%7 = alloca i8*
%8 = alloca i64
%9 = alloca i32
%10 = alloca [30 x i8]
%11 = alloca i8*
%12 = alloca i8*
%13 = alloca i32
%14 = alloca [4096 x i8]
%15 = alloca i32*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i8* null, i8** %7
store i64 0, i64* %8
%16 = load i8**, i8*** %5
%17 = getelementptr inbounds i8*, i8** %16, i64 1
%18 = load i8*, i8** %17
%19 = call i32* @fopen(i8* %18, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %19, i32** %6
store i32 1, i32* %13
%20 = load i32*, i32** %6
%21 = icmp eq i32* %20, null
br i1 %21, label %22, label %25
22: ; preds = %2
%23 = load i32, i32* @EXIT_FAILURE
%24 = call i32 @exit(i32 %23)
unreachable
25: ; preds = %2
br label %26
26: ; preds = %64, %38, %25
%27 = load i32*, i32** %6
%28 = call i32 @getline(i8** %7, i64* %8, i32* %27)
store i32 %28, i32* %9
%29 = icmp ne i32 %28, -1
br i1 %29, label %30, label %70
30: ; preds = %26
%31 = load i8*, i8** %7
%32 = call i64 @strstr(i8* %31, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%33 = icmp ne i64 %32, 0
br i1 %33, label %38, label %34
34: ; preds = %30
%35 = load i8*, i8** %7
%36 = call i64 @strstr(i8* %35, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%37 = icmp ne i64 %36, 0
br i1 %37, label %38, label %41
38: ; preds = %34, %30
store i32 1, i32* %13
%39 = getelementptr inbounds [30 x i8], [30 x i8]* %10, i64 0, i64 0
%40 = call i32 (i8*, i8*, i8*, ...) @sprintf(i8* %39, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.4, i64 0, i64 0))
br label %26
41: ; preds = %34
%42 = load i32, i32* %13
%43 = icmp eq i32 %42, 1
br i1 %43, label %44, label %55
44: ; preds = %41
%45 = getelementptr inbounds [4096 x i8], [4096 x i8]* %14, i64 0, i64 0
%46 = load i8*, i8** %7
%47 = call i32 @strcpy(i8* %45, i8* %46)
%48 = getelementptr inbounds [4096 x i8], [4096 x i8]* %14, i64 0, i64 0
%49 = call i8* @strtok(i8* %48, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
store i8* %49, i8** %11
%50 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
store i8* %50, i8** %12
%51 = getelementptr inbounds [30 x i8], [30 x i8]* %10, i64 0, i64 0
%52 = load i8*, i8** %11
%53 = load i8*, i8** %12
%54 = call i32 (i8*, i8*, i8*, ...) @sprintf(i8* %51, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.6, i64 0, i64 0), i8* %52, i8* %53)
store i32 0, i32* %13
br label %55
55: ; preds = %44, %41
%56 = getelementptr inbounds [30 x i8], [30 x i8]* %10, i64 0, i64 0
%57 = call i32* @fopen(i8* %56, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0))
store i32* %57, i32** %15
%58 = load i32*, i32** %15
%59 = icmp ne i32* %58, null
br i1 %59, label %64, label %60
60: ; preds = %55
%61 = call i32 @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.8, i64 0, i64 0))
%62 = load i32, i32* @EXIT_FAILURE
%63 = call i32 @exit(i32 %62)
unreachable
64: ; preds = %55
%65 = load i8*, i8** %7
%66 = load i32*, i32** %15
%67 = call i32 @fputs(i8* %65, i32* %66)
%68 = load i32*, i32** %15
%69 = call i32 @fclose(i32* %68)
br label %26
70: ; preds = %26
%71 = load i8*, i8** %7
%72 = icmp ne i8* %71, null
br i1 %72, label %73, label %76
73: ; preds = %70
%74 = load i8*, i8** %7
%75 = call i32 @free(i8* %74)
br label %76
76: ; preds = %73, %70
%77 = load i32, i32* @EXIT_SUCCESS
ret i32 %77
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [6 x i8] c"-----\00"
@.str.2 = [6 x i8] c"=====\00"
@.str.4 = [1 x i8] zeroinitializer
@.str.5 = [2 x i8] c" \00"
@.str.6 = [10 x i8] c"%s_%s.out\00"
@.str.7 = [2 x i8] c"a\00"
@EXIT_SUCCESS = global i32 0
@str = [33 x i8] c"Output File could not be opened.\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i8*
%4 = alloca i64
%5 = alloca [30 x i8]
%6 = alloca [4096 x i8]
%7 = bitcast i8** %3 to i8*
store i8* null, i8** %3
%8 = bitcast i64* %4 to i8*
store i64 0, i64* %4
%9 = getelementptr inbounds i8*, i8** %1, i64 1
%10 = load i8*, i8** %9
%11 = tail call i32* @fopen(i8* %10, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%12 = getelementptr inbounds [30 x i8], [30 x i8]* %5, i64 0, i64 0
%13 = icmp eq i32* %11, null
br i1 %13, label %19, label %14
14: ; preds = %2
%15 = call i32 @getline(i8** %3, i64* %4, i32* %11)
%16 = icmp eq i32 %15, -1
br i1 %16, label %55, label %17
17: ; preds = %14
%18 = getelementptr inbounds [4096 x i8], [4096 x i8]* %6, i64 0, i64 0
br label %22
19: ; preds = %2
%20 = load i32, i32* @EXIT_FAILURE
%21 = tail call i32 @exit(i32 %20)
unreachable
22: ; preds = %17, %33
%23 = phi i1 [ true, %17 ], [ %34, %33 ]
%24 = load i8*, i8** %3
%25 = call i64 @strstr(i8* %24, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%26 = icmp eq i64 %25, 0
br i1 %26, label %27, label %31
27: ; preds = %22
%28 = load i8*, i8** %3
%29 = call i64 @strstr(i8* %28, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%30 = icmp eq i64 %29, 0
br i1 %30, label %37, label %31
31: ; preds = %27, %22
%32 = call i8* bitcast (i32 (i8*, i8*)* @strcpy to i8* (i8*, i8*)*)(i8* %12, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.4, i64 0, i64 0))
br label %33
33: ; preds = %31, %51
%34 = phi i1 [ false, %51 ], [ true, %31 ]
%35 = call i32 @getline(i8** %3, i64* %4, i32* %11)
%36 = icmp eq i32 %35, -1
br i1 %36, label %55, label %22
37: ; preds = %27
br i1 %23, label %38, label %44
38: ; preds = %37
%39 = load i8*, i8** %3
%40 = call i32 @strcpy(i8* %18, i8* %39)
%41 = call i8* @strtok(i8* %18, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
%42 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
%43 = call i32 (i8*, i8*, i8*, ...) @sprintf(i8* %12, i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.6, i64 0, i64 0), i8* %41, i8* %42)
br label %44
44: ; preds = %38, %37
%45 = call i32* @fopen(i8* %12, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0))
%46 = icmp eq i32* %45, null
br i1 %46, label %47, label %51
47: ; preds = %44
%48 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @str, i64 0, i64 0))
%49 = load i32, i32* @EXIT_FAILURE
%50 = call i32 @exit(i32 %49)
unreachable
51: ; preds = %44
%52 = load i8*, i8** %3
%53 = call i32 @fputs(i8* %52, i32* %45)
%54 = call i32 @fclose(i32* %45)
br label %33
55: ; preds = %33, %14
%56 = load i8*, i8** %3
%57 = icmp eq i8* %56, null
br i1 %57, label %60, label %58
58: ; preds = %55
%59 = call i32 @free(i8* %56)
br label %60
60: ; preds = %58, %55
%61 = load i32, i32* @EXIT_SUCCESS
ret i32 %61
}