#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*/ sprintf(char *, char *, char *, char *, ...);
int /*<<< orphan*/ strcpy(char *, char *);
char *process_generic_output_begin_end_date_where_clause(
    char *date_attribute_name, char *begin_date_string, char *end_date_string) {
  static char where_clause[256];
  if (begin_date_string && *begin_date_string && end_date_string &&
      *end_date_string) {
    sprintf(where_clause, " and %s >= '%s' and %s <= '%s'", date_attribute_name,
            begin_date_string, date_attribute_name, end_date_string);
  } else if (begin_date_string && *begin_date_string) {
    sprintf(where_clause, " and %s = '%s'", date_attribute_name,
            begin_date_string);
  } else if (end_date_string && *end_date_string) {
    sprintf(where_clause, " and %s <= '%s'", date_attribute_name,
            end_date_string);
  } else {
    strcpy(where_clause, "and 1 = 1");
  }
  return where_clause;
}


x86 assembly (clang, -O0):
<process_generic_output_begin_end_date_where_clause>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     1194 <process_generic_output_begin_end_date_where_clause+0x74>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     1194 <process_generic_output_begin_end_date_where_clause+0x74>
cmpq   $0x0,-0x18(%rbp)
je     1194 <process_generic_output_begin_end_date_where_clause+0x74>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     1194 <process_generic_output_begin_end_date_where_clause+0x74>
mov    -0x8(%rbp),%rdx
mov    -0x10(%rbp),%rcx
mov    -0x8(%rbp),%r8
mov    -0x18(%rbp),%r9
lea    0x2ebf(%rip),%rdi
lea    0xe78(%rip),%rsi
mov    $0x0,%al
call   1040 <sprintf@plt>
jmp    122b <process_generic_output_begin_end_date_where_clause+0x10b>
cmpq   $0x0,-0x10(%rbp)
je     11d1 <process_generic_output_begin_end_date_where_clause+0xb1>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     11d1 <process_generic_output_begin_end_date_where_clause+0xb1>
mov    -0x8(%rbp),%rdx
mov    -0x10(%rbp),%rcx
lea    0x2e82(%rip),%rdi
lea    0xe5a(%rip),%rsi
mov    $0x0,%al
call   1040 <sprintf@plt>
jmp    1226 <process_generic_output_begin_end_date_where_clause+0x106>
cmpq   $0x0,-0x18(%rbp)
je     120e <process_generic_output_begin_end_date_where_clause+0xee>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     120e <process_generic_output_begin_end_date_where_clause+0xee>
mov    -0x8(%rbp),%rdx
mov    -0x18(%rbp),%rcx
lea    0x2e45(%rip),%rdi
lea    0xe0d(%rip),%rsi
mov    $0x0,%al
call   1040 <sprintf@plt>
jmp    1221 <process_generic_output_begin_end_date_where_clause+0x101>
lea    0x2e2b(%rip),%rdi
lea    0xe12(%rip),%rsi
call   1030 <strcpy@plt>
jmp    1226 <process_generic_output_begin_end_date_where_clause+0x106>
jmp    122b <process_generic_output_begin_end_date_where_clause+0x10b>
lea    0x2e0e(%rip),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<process_generic_output_begin_end_date_where_clause>:
push   %rax
mov    %rdx,%r9
mov    %rdi,%rdx
test   %rsi,%rsi
je     116e <process_generic_output_begin_end_date_where_clause+0x4e>
mov    %rsi,%rcx
mov    (%rsi),%al
test   %r9,%r9
je     115a <process_generic_output_begin_end_date_where_clause+0x3a>
test   %al,%al
je     115a <process_generic_output_begin_end_date_where_clause+0x3a>
cmpb   $0x0,(%r9)
je     115e <process_generic_output_begin_end_date_where_clause+0x3e>
lea    0x2ef9(%rip),%rdi
lea    0xeb2(%rip),%rsi
mov    %rdx,%r8
xor    %eax,%eax
call   1040 <sprintf@plt>
jmp    11a6 <process_generic_output_begin_end_date_where_clause+0x86>
test   %al,%al
je     116e <process_generic_output_begin_end_date_where_clause+0x4e>
lea    0x2edb(%rip),%rdi
lea    0xeb3(%rip),%rsi
jmp    118a <process_generic_output_begin_end_date_where_clause+0x6a>
test   %r9,%r9
je     1193 <process_generic_output_begin_end_date_where_clause+0x73>
cmpb   $0x0,(%r9)
je     1193 <process_generic_output_begin_end_date_where_clause+0x73>
lea    0x2ec0(%rip),%rdi
lea    0xe88(%rip),%rsi
mov    %r9,%rcx
xor    %eax,%eax
call   1040 <sprintf@plt>
jmp    11a6 <process_generic_output_begin_end_date_where_clause+0x86>
lea    0x2ea6(%rip),%rdi
lea    0xe8d(%rip),%rsi
call   1030 <strcpy@plt>
lea    0x2e93(%rip),%rax
pop    %rcx
ret

LLVM IR (-O0):
@process_generic_output_begin_end_date_where_clause.where_clause = internal global [256 x i8] zeroinitializer
@.str = [31 x i8] c" and %s >= '%s' and %s <= '%s'\00"
@.str.1 = [15 x i8] c" and %s = '%s'\00"
@.str.2 = [16 x i8] c" and %s <= '%s'\00"
@.str.3 = [10 x i8] c"and 1 = 1\00"
define i8* @process_generic_output_begin_end_date_where_clause(i8* %0, i8* %1, i8* %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
store i8* %0, i8** %4
store i8* %1, i8** %5
store i8* %2, i8** %6
%7 = load i8*, i8** %5
%8 = icmp ne i8* %7, null
br i1 %8, label %9, label %28
9: ; preds = %3
%10 = load i8*, i8** %5
%11 = load i8, i8* %10
%12 = sext i8 %11 to i32
%13 = icmp ne i32 %12, 0
br i1 %13, label %14, label %28
14: ; preds = %9
%15 = load i8*, i8** %6
%16 = icmp ne i8* %15, null
br i1 %16, label %17, label %28
17: ; preds = %14
%18 = load i8*, i8** %6
%19 = load i8, i8* %18
%20 = sext i8 %19 to i32
%21 = icmp ne i32 %20, 0
br i1 %21, label %22, label %28
22: ; preds = %17
%23 = load i8*, i8** %4
%24 = load i8*, i8** %5
%25 = load i8*, i8** %4
%26 = load i8*, i8** %6
%27 = call i32 (i8*, i8*, i8*, i8*, ...) @sprintf(i8* getelementptr inbounds ([256 x i8], [256 x i8]* @process_generic_output_begin_end_date_where_clause.where_clause, i64 0, i64 0), i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0), i8* %23, i8* %24, i8* %25, i8* %26)
br label %56
28: ; preds = %17, %14, %9, %3
%29 = load i8*, i8** %5
%30 = icmp ne i8* %29, null
br i1 %30, label %31, label %40
31: ; preds = %28
%32 = load i8*, i8** %5
%33 = load i8, i8* %32
%34 = sext i8 %33 to i32
%35 = icmp ne i32 %34, 0
br i1 %35, label %36, label %40
36: ; preds = %31
%37 = load i8*, i8** %4
%38 = load i8*, i8** %5
%39 = call i32 (i8*, i8*, i8*, i8*, ...) @sprintf(i8* getelementptr inbounds ([256 x i8], [256 x i8]* @process_generic_output_begin_end_date_where_clause.where_clause, i64 0, i64 0), i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i8* %37, i8* %38)
br label %55
40: ; preds = %31, %28
%41 = load i8*, i8** %6
%42 = icmp ne i8* %41, null
br i1 %42, label %43, label %52
43: ; preds = %40
%44 = load i8*, i8** %6
%45 = load i8, i8* %44
%46 = sext i8 %45 to i32
%47 = icmp ne i32 %46, 0
br i1 %47, label %48, label %52
48: ; preds = %43
%49 = load i8*, i8** %4
%50 = load i8*, i8** %6
%51 = call i32 (i8*, i8*, i8*, i8*, ...) @sprintf(i8* getelementptr inbounds ([256 x i8], [256 x i8]* @process_generic_output_begin_end_date_where_clause.where_clause, i64 0, i64 0), i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0), i8* %49, i8* %50)
br label %54
52: ; preds = %43, %40
%53 = call i32 @strcpy(i8* getelementptr inbounds ([256 x i8], [256 x i8]* @process_generic_output_begin_end_date_where_clause.where_clause, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0))
br label %54
54: ; preds = %52, %48
br label %55
55: ; preds = %54, %36
br label %56
56: ; preds = %55, %22
ret i8* getelementptr inbounds ([256 x i8], [256 x i8]* @process_generic_output_begin_end_date_where_clause.where_clause, i64 0, i64 0)
}

LLVM IR (-O2):
@process_generic_output_begin_end_date_where_clause.where_clause = internal global [256 x i8] zeroinitializer
@.str = [31 x i8] c" and %s >= '%s' and %s <= '%s'\00"
@.str.1 = [15 x i8] c" and %s = '%s'\00"
@.str.2 = [16 x i8] c" and %s <= '%s'\00"
@.str.3 = [10 x i8] c"and 1 = 1\00"
define i8* @process_generic_output_begin_end_date_where_clause(i8* %0, i8* %1, i8* %2) {
%4 = icmp eq i8* %1, null
br i1 %4, label %19, label %5
5: ; preds = %3
%6 = load i8, i8* %1
%7 = icmp ne i8 %6, 0
%8 = icmp ne i8* %2, null
%9 = and i1 %8, %7
br i1 %9, label %10, label %15
10: ; preds = %5
%11 = load i8, i8* %2
%12 = icmp eq i8 %11, 0
br i1 %12, label %17, label %13
13: ; preds = %10
%14 = tail call i32 (i8*, i8*, i8*, i8*, ...) @sprintf(i8* dereferenceable(1) getelementptr inbounds ([256 x i8], [256 x i8]* @process_generic_output_begin_end_date_where_clause.where_clause, i64 0, i64 0), i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0), i8* %0, i8* %1, i8* %0, i8* %2)
br label %28
15: ; preds = %5
%16 = icmp eq i8 %6, 0
br i1 %16, label %19, label %17
17: ; preds = %10, %15
%18 = tail call i32 (i8*, i8*, i8*, i8*, ...) @sprintf(i8* dereferenceable(1) getelementptr inbounds ([256 x i8], [256 x i8]* @process_generic_output_begin_end_date_where_clause.where_clause, i64 0, i64 0), i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i8* %0, i8* %1)
br label %28
19: ; preds = %3, %15
%20 = icmp eq i8* %2, null
br i1 %20, label %26, label %21
21: ; preds = %19
%22 = load i8, i8* %2
%23 = icmp eq i8 %22, 0
br i1 %23, label %26, label %24
24: ; preds = %21
%25 = tail call i32 (i8*, i8*, i8*, i8*, ...) @sprintf(i8* dereferenceable(1) getelementptr inbounds ([256 x i8], [256 x i8]* @process_generic_output_begin_end_date_where_clause.where_clause, i64 0, i64 0), i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0), i8* %0, i8* %2)
br label %28
26: ; preds = %21, %19
%27 = tail call i32 @strcpy(i8* getelementptr inbounds ([256 x i8], [256 x i8]* @process_generic_output_begin_end_date_where_clause.where_clause, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0))
br label %28
28: ; preds = %17, %26, %24, %13
ret i8* getelementptr inbounds ([256 x i8], [256 x i8]* @process_generic_output_begin_end_date_where_clause.where_clause, i64 0, i64 0)
}