#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 */
char *hydrology_library_get_period_of_record_begin_date(char *, char *, char *);
char *hydrology_library_get_period_of_record_end_date(char *, char *, char *);
scalar_t__ strcmp(char *, char *);
void hydrology_library_get_clean_begin_end_date(char **begin_date,
                                                char **end_date,
                                                char *application_name,
                                                char *station, char *datatype) {
  int seeked_begin_date = 0;
  if (!station || !*station)
    return;
  if (!*begin_date || !**begin_date || strcmp(*begin_date, "begin_date") == 0) {
    *begin_date = hydrology_library_get_period_of_record_begin_date(
        application_name, station, datatype);
    seeked_begin_date = 1;
  }
  if (!*end_date || !**end_date || strcmp(*end_date, "end_date") == 0) {
    if (seeked_begin_date) {
      *end_date = hydrology_library_get_period_of_record_end_date(
          application_name, station, datatype);
    } else {
      *end_date = *begin_date;
    }
  }
}


x86 assembly (clang, -O0):
<hydrology_library_get_clean_begin_end_date>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     116b <hydrology_library_get_clean_begin_end_date+0x3b>
mov    -0x20(%rbp),%rax
cmpb   $0x0,(%rax)
jne    1170 <hydrology_library_get_clean_begin_end_date+0x40>
jmp    1245 <hydrology_library_get_clean_begin_end_date+0x115>
mov    -0x8(%rbp),%rax
cmpq   $0x0,(%rax)
je     11ab <hydrology_library_get_clean_begin_end_date+0x7b>
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
cmpb   $0x0,(%rax)
je     11ab <hydrology_library_get_clean_begin_end_date+0x7b>
mov    -0x8(%rbp),%rax
mov    (%rax),%rdi
lea    0xe64(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    11cd <hydrology_library_get_clean_begin_end_date+0x9d>
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    -0x28(%rbp),%rdx
call   1050 <hydrology_library_get_period_of_record_begin_date@plt>
mov    %rax,%rcx
mov    -0x8(%rbp),%rax
mov    %rcx,(%rax)
movl   $0x1,-0x2c(%rbp)
mov    -0x10(%rbp),%rax
cmpq   $0x0,(%rax)
je     1208 <hydrology_library_get_clean_begin_end_date+0xd8>
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
cmpb   $0x0,(%rax)
je     1208 <hydrology_library_get_clean_begin_end_date+0xd8>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
lea    0xe12(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    1245 <hydrology_library_get_clean_begin_end_date+0x115>
cmpl   $0x0,-0x2c(%rbp)
je     1232 <hydrology_library_get_clean_begin_end_date+0x102>
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    -0x28(%rbp),%rdx
call   1040 <hydrology_library_get_period_of_record_end_date@plt>
mov    %rax,%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,(%rax)
jmp    1240 <hydrology_library_get_clean_begin_end_date+0x110>
mov    -0x8(%rbp),%rax
mov    (%rax),%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,(%rax)
jmp    1245 <hydrology_library_get_clean_begin_end_date+0x115>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<hydrology_library_get_clean_begin_end_date>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
test   %rcx,%rcx
je     11c7 <hydrology_library_get_clean_begin_end_date+0x97>
mov    %rcx,%rbx
cmpb   $0x0,(%rcx)
je     11c7 <hydrology_library_get_clean_begin_end_date+0x97>
mov    %r8,%r14
mov    %rdx,%r12
mov    %rsi,%r15
mov    %rdi,%r13
mov    (%rdi),%rdi
test   %rdi,%rdi
je     1179 <hydrology_library_get_clean_begin_end_date+0x49>
cmpb   $0x0,(%rdi)
je     1179 <hydrology_library_get_clean_begin_end_date+0x49>
lea    0xe94(%rip),%rsi
call   1030 <strcmp@plt>
mov    $0x1,%bpl
test   %rax,%rax
jne    118d <hydrology_library_get_clean_begin_end_date+0x5d>
mov    %r12,%rdi
mov    %rbx,%rsi
mov    %r14,%rdx
call   1050 <hydrology_library_get_period_of_record_begin_date@plt>
mov    %rax,0x0(%r13)
xor    %ebp,%ebp
mov    (%r15),%rdi
test   %rdi,%rdi
je     11ab <hydrology_library_get_clean_begin_end_date+0x7b>
cmpb   $0x0,(%rdi)
je     11ab <hydrology_library_get_clean_begin_end_date+0x7b>
lea    0xe6a(%rip),%rsi
call   1030 <strcmp@plt>
test   %rax,%rax
jne    11c7 <hydrology_library_get_clean_begin_end_date+0x97>
test   %bpl,%bpl
je     11b6 <hydrology_library_get_clean_begin_end_date+0x86>
mov    0x0(%r13),%rax
jmp    11c4 <hydrology_library_get_clean_begin_end_date+0x94>
mov    %r12,%rdi
mov    %rbx,%rsi
mov    %r14,%rdx
call   1040 <hydrology_library_get_period_of_record_end_date@plt>
mov    %rax,(%r15)
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [11 x i8] c"begin_date\00"
@.str.1 = [9 x i8] c"end_date\00"
define void @hydrology_library_get_clean_begin_end_date(i8** %0, i8** %1, i8* %2, i8* %3, i8* %4) {
%6 = alloca i8**
%7 = alloca i8**
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i8*
%11 = alloca i32
store i8** %0, i8*** %6
store i8** %1, i8*** %7
store i8* %2, i8** %8
store i8* %3, i8** %9
store i8* %4, i8** %10
store i32 0, i32* %11
%12 = load i8*, i8** %9
%13 = icmp ne i8* %12, null
br i1 %13, label %14, label %18
14: ; preds = %5
%15 = load i8*, i8** %9
%16 = load i8, i8* %15
%17 = icmp ne i8 %16, 0
br i1 %17, label %19, label %18
18: ; preds = %14, %5
br label %67
19: ; preds = %14
%20 = load i8**, i8*** %6
%21 = load i8*, i8** %20
%22 = icmp ne i8* %21, null
br i1 %22, label %23, label %33
23: ; preds = %19
%24 = load i8**, i8*** %6
%25 = load i8*, i8** %24
%26 = load i8, i8* %25
%27 = icmp ne i8 %26, 0
br i1 %27, label %28, label %33
28: ; preds = %23
%29 = load i8**, i8*** %6
%30 = load i8*, i8** %29
%31 = call i64 @strcmp(i8* %30, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
%32 = icmp eq i64 %31, 0
br i1 %32, label %33, label %39
33: ; preds = %28, %23, %19
%34 = load i8*, i8** %8
%35 = load i8*, i8** %9
%36 = load i8*, i8** %10
%37 = call i8* @hydrology_library_get_period_of_record_begin_date(i8* %34, i8* %35, i8* %36)
%38 = load i8**, i8*** %6
store i8* %37, i8** %38
store i32 1, i32* %11
br label %39
39: ; preds = %33, %28
%40 = load i8**, i8*** %7
%41 = load i8*, i8** %40
%42 = icmp ne i8* %41, null
br i1 %42, label %43, label %53
43: ; preds = %39
%44 = load i8**, i8*** %7
%45 = load i8*, i8** %44
%46 = load i8, i8* %45
%47 = icmp ne i8 %46, 0
br i1 %47, label %48, label %53
48: ; preds = %43
%49 = load i8**, i8*** %7
%50 = load i8*, i8** %49
%51 = call i64 @strcmp(i8* %50, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
%52 = icmp eq i64 %51, 0
br i1 %52, label %53, label %67
53: ; preds = %48, %43, %39
%54 = load i32, i32* %11
%55 = icmp ne i32 %54, 0
br i1 %55, label %56, label %62
56: ; preds = %53
%57 = load i8*, i8** %8
%58 = load i8*, i8** %9
%59 = load i8*, i8** %10
%60 = call i8* @hydrology_library_get_period_of_record_end_date(i8* %57, i8* %58, i8* %59)
%61 = load i8**, i8*** %7
store i8* %60, i8** %61
br label %66
62: ; preds = %53
%63 = load i8**, i8*** %6
%64 = load i8*, i8** %63
%65 = load i8**, i8*** %7
store i8* %64, i8** %65
br label %66
66: ; preds = %62, %56
br label %67
67: ; preds = %18, %66, %48
ret void
}

LLVM IR (-O2):
@.str = [11 x i8] c"begin_date\00"
@.str.1 = [9 x i8] c"end_date\00"
define void @hydrology_library_get_clean_begin_end_date(i8** nocapture %0, i8** nocapture %1, i8* %2, i8* %3, i8* %4) {
%6 = icmp eq i8* %3, null
br i1 %6, label %38, label %7
7: ; preds = %5
%8 = load i8, i8* %3
%9 = icmp eq i8 %8, 0
br i1 %9, label %38, label %10
10: ; preds = %7
%11 = load i8*, i8** %0
%12 = icmp eq i8* %11, null
br i1 %12, label %19, label %13
13: ; preds = %10
%14 = load i8, i8* %11
%15 = icmp eq i8 %14, 0
br i1 %15, label %19, label %16
16: ; preds = %13
%17 = tail call i64 @strcmp(i8* %11, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
%18 = icmp eq i64 %17, 0
br i1 %18, label %19, label %21
19: ; preds = %16, %13, %10
%20 = tail call i8* @hydrology_library_get_period_of_record_begin_date(i8* %2, i8* %3, i8* %4)
store i8* %20, i8** %0
br label %21
21: ; preds = %19, %16
%22 = phi i1 [ false, %19 ], [ true, %16 ]
%23 = load i8*, i8** %1
%24 = icmp eq i8* %23, null
br i1 %24, label %31, label %25
25: ; preds = %21
%26 = load i8, i8* %23
%27 = icmp eq i8 %26, 0
br i1 %27, label %31, label %28
28: ; preds = %25
%29 = tail call i64 @strcmp(i8* %23, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
%30 = icmp eq i64 %29, 0
br i1 %30, label %31, label %38
31: ; preds = %28, %25, %21
br i1 %22, label %34, label %32
32: ; preds = %31
%33 = tail call i8* @hydrology_library_get_period_of_record_end_date(i8* %2, i8* %3, i8* %4)
br label %36
34: ; preds = %31
%35 = load i8*, i8** %0
br label %36
36: ; preds = %32, %34
%37 = phi i8* [ %35, %34 ], [ %33, %32 ]
store i8* %37, i8** %1
br label %38
38: ; preds = %36, %28, %5, %7
ret void
}