#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 */

/* Variables and functions */
int /*<<< orphan*/ sscanf(char *, char *, ...);
int /*<<< orphan*/ strcat(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
int /*<<< orphan*/ *strstr(char *, char *);
unsigned long event_stolu(char *str, bool startFlag, bool isStart) {
  char date[8192];
  char hhmmss[8192];
  char lu_str[8192];
  unsigned long encoding;
  strcpy(lu_str, "");
  if (strstr(str, "Z") != NULL) {
    sscanf(str, "%[^T]T%[^Z]%*s", date, hhmmss);
  } else {
    sscanf(str, "%[^T]T%s", date, hhmmss);
  }
  strcat(lu_str, date);
  hhmmss[4] = '\0';
  strcat(lu_str, hhmmss);
  if (startFlag) {
    if (isStart) {
      strcat(lu_str, "0");
    } else {
      strcat(lu_str, "1");
    }
  }
  sscanf(lu_str, "%lu", &encoding);
  return encoding;
}


x86 assembly (clang, -O0):
<event_stolu>:
push   %rbp
mov    %rsp,%rbp
sub    $0x6020,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
lea    -0x6010(%rbp),%rdi
lea    0xeb8(%rip),%rsi
call   1030 <strcpy@plt>
mov    -0x8(%rbp),%rdi
lea    0xe8d(%rip),%rsi
call   1060 <strstr@plt>
cmp    $0x0,%rax
je     11a7 <event_stolu+0x67>
mov    -0x8(%rbp),%rdi
lea    -0x2010(%rbp),%rdx
lea    -0x4010(%rbp),%rcx
lea    0xe67(%rip),%rsi
mov    $0x0,%al
call   1040 <sscanf@plt>
jmp    11c7 <event_stolu+0x87>
mov    -0x8(%rbp),%rdi
lea    -0x2010(%rbp),%rdx
lea    -0x4010(%rbp),%rcx
lea    0xe51(%rip),%rsi
mov    $0x0,%al
call   1040 <sscanf@plt>
lea    -0x6010(%rbp),%rdi
lea    -0x2010(%rbp),%rsi
call   1050 <strcat@plt>
movb   $0x0,-0x400c(%rbp)
lea    -0x6010(%rbp),%rdi
lea    -0x4010(%rbp),%rsi
call   1050 <strcat@plt>
cmpl   $0x0,-0xc(%rbp)
je     1238 <event_stolu+0xf8>
cmpl   $0x0,-0x10(%rbp)
je     1220 <event_stolu+0xe0>
lea    -0x6010(%rbp),%rdi
lea    0xe04(%rip),%rsi
call   1050 <strcat@plt>
jmp    1233 <event_stolu+0xf3>
lea    -0x6010(%rbp),%rdi
lea    0xdee(%rip),%rsi
call   1050 <strcat@plt>
jmp    1238 <event_stolu+0xf8>
lea    -0x6010(%rbp),%rdi
lea    0xdd8(%rip),%rsi
lea    -0x6018(%rbp),%rdx
mov    $0x0,%al
call   1040 <sscanf@plt>
mov    -0x6018(%rbp),%rax
add    $0x6020,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<event_stolu>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x6018,%rsp
mov    %edx,%r14d
mov    %esi,%r15d
mov    %rdi,%rbp
lea    0xeb8(%rip),%rsi
lea    0x10(%rsp),%r12
mov    %r12,%rdi
call   1030 <strcpy@plt>
mov    %rbp,%rdi
mov    $0x5a,%esi
call   1040 <strchr@plt>
test   %rax,%rax
lea    0xe8a(%rip),%rax
lea    0xe74(%rip),%rsi
cmove  %rax,%rsi
lea    0x4010(%rsp),%rbx
lea    0x2010(%rsp),%r13
mov    %rbp,%rdi
mov    %rbx,%rdx
mov    %r13,%rcx
xor    %eax,%eax
call   1050 <sscanf@plt>
mov    %r12,%rdi
mov    %rbx,%rsi
call   1060 <strcat@plt>
movb   $0x0,0x2014(%rsp)
mov    %r12,%rdi
mov    %r13,%rsi
call   1060 <strcat@plt>
test   %r15d,%r15d
je     11f2 <event_stolu+0xb2>
test   %r14d,%r14d
lea    0xe3d(%rip),%rax
lea    0xe34(%rip),%rsi
cmove  %rax,%rsi
lea    0x10(%rsp),%rdi
call   1060 <strcat@plt>
lea    0xe23(%rip),%rsi
lea    0x10(%rsp),%rdi
lea    0x8(%rsp),%rdx
xor    %eax,%eax
call   1050 <sscanf@plt>
mov    0x8(%rsp),%rax
add    $0x6018,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [1 x i8] zeroinitializer
@.str.1 = [2 x i8] c"Z\00"
@.str.2 = [15 x i8] c"%[^T]T%[^Z]%*s\00"
@.str.3 = [9 x i8] c"%[^T]T%s\00"
@.str.4 = [2 x i8] c"0\00"
@.str.5 = [2 x i8] c"1\00"
@.str.6 = [4 x i8] c"%lu\00"
define i64 @event_stolu(i8* %0, i32 %1, i32 %2) {
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i32
%7 = alloca [8192 x i8]
%8 = alloca [8192 x i8]
%9 = alloca [8192 x i8]
%10 = alloca i64
store i8* %0, i8** %4
store i32 %1, i32* %5
store i32 %2, i32* %6
%11 = getelementptr inbounds [8192 x i8], [8192 x i8]* %9, i64 0, i64 0
%12 = call i32 @strcpy(i8* %11, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
%13 = load i8*, i8** %4
%14 = call i32* @strstr(i8* %13, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%15 = icmp ne i32* %14, null
br i1 %15, label %16, label %21
16: ; preds = %3
%17 = load i8*, i8** %4
%18 = getelementptr inbounds [8192 x i8], [8192 x i8]* %7, i64 0, i64 0
%19 = getelementptr inbounds [8192 x i8], [8192 x i8]* %8, i64 0, i64 0
%20 = call i32 (i8*, i8*, ...) @sscanf(i8* %17, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0), i8* %18, i8* %19)
br label %26
21: ; preds = %3
%22 = load i8*, i8** %4
%23 = getelementptr inbounds [8192 x i8], [8192 x i8]* %7, i64 0, i64 0
%24 = getelementptr inbounds [8192 x i8], [8192 x i8]* %8, i64 0, i64 0
%25 = call i32 (i8*, i8*, ...) @sscanf(i8* %22, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i8* %23, i8* %24)
br label %26
26: ; preds = %21, %16
%27 = getelementptr inbounds [8192 x i8], [8192 x i8]* %9, i64 0, i64 0
%28 = getelementptr inbounds [8192 x i8], [8192 x i8]* %7, i64 0, i64 0
%29 = call i32 @strcat(i8* %27, i8* %28)
%30 = getelementptr inbounds [8192 x i8], [8192 x i8]* %8, i64 0, i64 4
store i8 0, i8* %30
%31 = getelementptr inbounds [8192 x i8], [8192 x i8]* %9, i64 0, i64 0
%32 = getelementptr inbounds [8192 x i8], [8192 x i8]* %8, i64 0, i64 0
%33 = call i32 @strcat(i8* %31, i8* %32)
%34 = load i32, i32* %5
%35 = icmp ne i32 %34, 0
br i1 %35, label %36, label %46
36: ; preds = %26
%37 = load i32, i32* %6
%38 = icmp ne i32 %37, 0
br i1 %38, label %39, label %42
39: ; preds = %36
%40 = getelementptr inbounds [8192 x i8], [8192 x i8]* %9, i64 0, i64 0
%41 = call i32 @strcat(i8* %40, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
br label %45
42: ; preds = %36
%43 = getelementptr inbounds [8192 x i8], [8192 x i8]* %9, i64 0, i64 0
%44 = call i32 @strcat(i8* %43, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
br label %45
45: ; preds = %42, %39
br label %46
46: ; preds = %45, %26
%47 = getelementptr inbounds [8192 x i8], [8192 x i8]* %9, i64 0, i64 0
%48 = call i32 (i8*, i8*, ...) @sscanf(i8* %47, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), i64* %10)
%49 = load i64, i64* %10
ret i64 %49
}

LLVM IR (-O2):
@.str = [1 x i8] zeroinitializer
@.str.2 = [15 x i8] c"%[^T]T%[^Z]%*s\00"
@.str.3 = [9 x i8] c"%[^T]T%s\00"
@.str.4 = [2 x i8] c"0\00"
@.str.5 = [2 x i8] c"1\00"
@.str.6 = [4 x i8] c"%lu\00"
define i64 @event_stolu(i8* %0, i32 %1, i32 %2) {
%4 = alloca [8192 x i8]
%5 = alloca [8192 x i8]
%6 = alloca [8192 x i8]
%7 = alloca i64
%8 = getelementptr inbounds [8192 x i8], [8192 x i8]* %4, i64 0, i64 0
%9 = getelementptr inbounds [8192 x i8], [8192 x i8]* %5, i64 0, i64 0
%10 = getelementptr inbounds [8192 x i8], [8192 x i8]* %6, i64 0, i64 0
%11 = bitcast i64* %7 to i8*
%12 = call i32 @strcpy(i8* %10, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
%13 = call i8* @strchr(i8* dereferenceable(1) %0, i32 90)
%14 = icmp eq i8* %13, null
%15 = select i1 %14, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0)
%16 = call i32 (i8*, i8*, ...) @sscanf(i8* %0, i8* %15, i8* %8, i8* %9)
%17 = call i32 @strcat(i8* %10, i8* %8)
%18 = getelementptr inbounds [8192 x i8], [8192 x i8]* %5, i64 0, i64 4
store i8 0, i8* %18
%19 = call i32 @strcat(i8* %10, i8* %9)
%20 = icmp eq i32 %1, 0
br i1 %20, label %25, label %21
21: ; preds = %3
%22 = icmp eq i32 %2, 0
%23 = select i1 %22, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0)
%24 = call i32 @strcat(i8* %10, i8* %23)
br label %25
25: ; preds = %21, %3
%26 = call i32 (i8*, i8*, ...) @sscanf(i8* %10, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), i64* %7)
%27 = load i64, i64* %7
ret i64 %27
}