#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_date_where(char *date_attribute_name, char *begin_date,
                                 char *end_date) {
  static char where[256];
  if (begin_date && *begin_date && end_date && *end_date) {
    sprintf(where, "%s >= '%s' and %s <= '%s'", date_attribute_name, begin_date,
            date_attribute_name, end_date);
  } else if (begin_date && *begin_date) {
    sprintf(where, "%s >= '%s'", date_attribute_name, begin_date);
  } else if (end_date && *end_date) {
    sprintf(where, "%s <= '%s'", date_attribute_name, end_date);
  } else {
    strcpy(where, "1 = 1");
  }
  return where;
}


x86 assembly (clang, -O0):
<process_generic_date_where>:
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_date_where+0x74>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     1194 <process_generic_date_where+0x74>
cmpq   $0x0,-0x18(%rbp)
je     1194 <process_generic_date_where+0x74>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     1194 <process_generic_date_where+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_date_where+0x10b>
cmpq   $0x0,-0x10(%rbp)
je     11d1 <process_generic_date_where+0xb1>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     11d1 <process_generic_date_where+0xb1>
mov    -0x8(%rbp),%rdx
mov    -0x10(%rbp),%rcx
lea    0x2e82(%rip),%rdi
lea    0xe55(%rip),%rsi
mov    $0x0,%al
call   1040 <sprintf@plt>
jmp    1226 <process_generic_date_where+0x106>
cmpq   $0x0,-0x18(%rbp)
je     120e <process_generic_date_where+0xee>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     120e <process_generic_date_where+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_date_where+0x101>
lea    0x2e2b(%rip),%rdi
lea    0xe09(%rip),%rsi
call   1030 <strcpy@plt>
jmp    1226 <process_generic_date_where+0x106>
jmp    122b <process_generic_date_where+0x10b>
lea    0x2e0e(%rip),%rax
add    $0x20,%rsp
pop    %rbp
ret

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

LLVM IR (-O0):
@process_generic_date_where.where = internal global [256 x i8] zeroinitializer
@.str = [26 x i8] c"%s >= '%s' and %s <= '%s'\00"
@.str.1 = [11 x i8] c"%s >= '%s'\00"
@.str.2 = [11 x i8] c"%s <= '%s'\00"
@.str.3 = [6 x i8] c"1 = 1\00"
define i8* @process_generic_date_where(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_date_where.where, i64 0, i64 0), i8* getelementptr inbounds ([26 x i8], [26 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_date_where.where, i64 0, i64 0), i8* getelementptr inbounds ([11 x i8], [11 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_date_where.where, i64 0, i64 0), i8* getelementptr inbounds ([11 x i8], [11 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_date_where.where, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 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_date_where.where, i64 0, i64 0)
}

LLVM IR (-O2):
@process_generic_date_where.where = internal global [256 x i8] zeroinitializer
@.str = [26 x i8] c"%s >= '%s' and %s <= '%s'\00"
@.str.1 = [11 x i8] c"%s >= '%s'\00"
@.str.2 = [11 x i8] c"%s <= '%s'\00"
@.str.3 = [6 x i8] c"1 = 1\00"
define i8* @process_generic_date_where(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_date_where.where, i64 0, i64 0), i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 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_date_where.where, i64 0, i64 0), i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 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_date_where.where, i64 0, i64 0), i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 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_date_where.where, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 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_date_where.where, i64 0, i64 0)
}