#include "src/string/strcasestr.h"
#include "src/__support/common.h"
#include "src/__support/ctype_utils.h"
#include "src/__support/macros/config.h"
#include "src/__support/macros/null_check.h"
#include "src/string/memory_utils/inline_strstr.h"
namespace LIBC_NAMESPACE_DECL {
LLVM_LIBC_FUNCTION(char *, strcasestr,
(const char *haystack, const char *needle)) {
auto case_cmp = [](char a, char b) {
return static_cast<int>(LIBC_NAMESPACE::internal::tolower(a)) -
static_cast<int>(LIBC_NAMESPACE::internal::tolower(b));
};
LIBC_CRASH_ON_NULLPTR(haystack);
LIBC_CRASH_ON_NULLPTR(needle);
return inline_strstr(haystack, needle, case_cmp);
}
}