#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*/ strcpy(char *, char *);
int /*<<< orphan*/ strlwr(char *);
char *strstr(char *, char *);
char *db_stristr(char *pHaystack, char *pNeedle) {
  char szHaystack[2048] = {0};
  char szNeedle[2048] = {0};
  strcpy(szHaystack, pHaystack);
  strcpy(szNeedle, pNeedle);
  strlwr(szHaystack);
  strlwr(szNeedle);
  return (strstr(szHaystack, szNeedle));
}


x86 assembly (clang, -O0):
<db_stristr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1010,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x810(%rbp),%rdi
xor    %esi,%esi
mov    $0x800,%edx
call   1050 <memset@plt>
lea    -0x1010(%rbp),%rdi
xor    %esi,%esi
mov    $0x800,%edx
call   1050 <memset@plt>
lea    -0x810(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1040 <strcpy@plt>
lea    -0x1010(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1040 <strcpy@plt>
lea    -0x810(%rbp),%rdi
call   1030 <strlwr@plt>
lea    -0x1010(%rbp),%rdi
call   1030 <strlwr@plt>
lea    -0x810(%rbp),%rdi
lea    -0x1010(%rbp),%rsi
call   1060 <strstr@plt>
add    $0x1010,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<db_stristr>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x1008,%rsp
mov    %rsi,%r14
mov    %rdi,%r12
lea    0x800(%rsp),%r15
mov    $0x800,%edx
mov    %r15,%rdi
xor    %esi,%esi
call   1050 <memset@plt>
mov    %rsp,%rbx
mov    $0x800,%edx
mov    %rbx,%rdi
xor    %esi,%esi
call   1050 <memset@plt>
mov    %r15,%rdi
mov    %r12,%rsi
call   1040 <strcpy@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1040 <strcpy@plt>
mov    %r15,%rdi
call   1030 <strlwr@plt>
mov    %rbx,%rdi
call   1030 <strlwr@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1060 <strstr@plt>
add    $0x1008,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i8* @db_stristr(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca [2048 x i8]
%6 = alloca [2048 x i8]
store i8* %0, i8** %3
store i8* %1, i8** %4
%7 = bitcast [2048 x i8]* %5 to i8*
%8 = bitcast [2048 x i8]* %6 to i8*
%9 = getelementptr inbounds [2048 x i8], [2048 x i8]* %5, i64 0, i64 0
%10 = load i8*, i8** %3
%11 = call i32 @strcpy(i8* %9, i8* %10)
%12 = getelementptr inbounds [2048 x i8], [2048 x i8]* %6, i64 0, i64 0
%13 = load i8*, i8** %4
%14 = call i32 @strcpy(i8* %12, i8* %13)
%15 = getelementptr inbounds [2048 x i8], [2048 x i8]* %5, i64 0, i64 0
%16 = call i32 @strlwr(i8* %15)
%17 = getelementptr inbounds [2048 x i8], [2048 x i8]* %6, i64 0, i64 0
%18 = call i32 @strlwr(i8* %17)
%19 = getelementptr inbounds [2048 x i8], [2048 x i8]* %5, i64 0, i64 0
%20 = getelementptr inbounds [2048 x i8], [2048 x i8]* %6, i64 0, i64 0
%21 = call i8* @strstr(i8* %19, i8* %20)
ret i8* %21
}

LLVM IR (-O2):
define i8* @db_stristr(i8* %0, i8* %1) {
%3 = alloca [2048 x i8]
%4 = alloca [2048 x i8]
%5 = getelementptr inbounds [2048 x i8], [2048 x i8]* %3, i64 0, i64 0
%6 = getelementptr inbounds [2048 x i8], [2048 x i8]* %4, i64 0, i64 0
%7 = call i32 @strcpy(i8* %5, i8* %0)
%8 = call i32 @strcpy(i8* %6, i8* %1)
%9 = call i32 @strlwr(i8* %5)
%10 = call i32 @strlwr(i8* %6)
%11 = call i8* @strstr(i8* %5, i8* %6)
ret i8* %11
}