#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*/ exit(int);
int /*<<< orphan*/ free(char *);
scalar_t__ malloc(scalar_t__);
int /*<<< orphan*/ print_error(char *);
int /*<<< orphan*/ strcpy(char *, char *);
int /*<<< orphan*/ string_lower(char *);
scalar_t__ strlen(char *);
int /*<<< orphan*/ *strstr(char *, char *);
int strcase_search(char *in_s1, char *in_s2) {
  char *s1, *s2;
  int retflag = 0;
  s1 = (char *)malloc((strlen(in_s1) + 1));
  if (s1 == NULL) {
    print_error("strcase_search: Out of memory for malloc");
    exit((1));
  }
  s2 = (char *)malloc((strlen(in_s2) + 1));
  if (s2 == NULL) {
    free(s1);
    print_error("strcase_search: Out of memory for malloc");
    exit((1));
  }
  strcpy(s1, in_s1);
  strcpy(s2, in_s2);
  string_lower(s1);
  string_lower(s2);
  if (strstr(s1, s2) == NULL)
    retflag = 0;
  else
    retflag = 1;
  free(s1);
  free(s2);
  return retflag;
}


x86 assembly (clang, -O0):
<strcase_search>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x8(%rbp),%rdi
call   1060 <strlen@plt>
mov    %rax,%rdi
add    $0x1,%rdi
call   1070 <malloc@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    11d1 <strcase_search+0x51>
lea    0xe3e(%rip),%rdi
call   1050 <print_error@plt>
mov    $0x1,%edi
call   1090 <exit@plt>
mov    -0x10(%rbp),%rdi
call   1060 <strlen@plt>
mov    %rax,%rdi
add    $0x1,%rdi
call   1070 <malloc@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    1214 <strcase_search+0x94>
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
lea    0xdfb(%rip),%rdi
call   1050 <print_error@plt>
mov    $0x1,%edi
call   1090 <exit@plt>
mov    -0x18(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1040 <strcpy@plt>
mov    -0x20(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1040 <strcpy@plt>
mov    -0x18(%rbp),%rdi
call   1080 <string_lower@plt>
mov    -0x20(%rbp),%rdi
call   1080 <string_lower@plt>
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   10a0 <strstr@plt>
cmp    $0x0,%rax
jne    1263 <strcase_search+0xe3>
movl   $0x0,-0x24(%rbp)
jmp    126a <strcase_search+0xea>
movl   $0x1,-0x24(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
mov    -0x24(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<strcase_search>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rsi,%r14
mov    %rdi,%r12
call   1060 <strlen@plt>
lea    0x1(%rax),%rdi
call   1070 <malloc@plt>
test   %rax,%rax
je     121a <strcase_search+0x9a>
mov    %rax,%r15
mov    %r14,%rdi
call   1060 <strlen@plt>
lea    0x1(%rax),%rdi
call   1070 <malloc@plt>
test   %rax,%rax
je     1212 <strcase_search+0x92>
mov    %rax,%rbx
mov    %r15,%rdi
mov    %r12,%rsi
call   1040 <strcpy@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1040 <strcpy@plt>
mov    %r15,%rdi
call   1080 <string_lower@plt>
mov    %rbx,%rdi
call   1080 <string_lower@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   10a0 <strstr@plt>
xor    %ebp,%ebp
test   %rax,%rax
setne  %bpl
mov    %r15,%rdi
call   1030 <free@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    %ebp,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %r15,%rdi
call   1030 <free@plt>
lea    0xddf(%rip),%rdi
call   1050 <print_error@plt>
mov    $0x1,%edi
call   1090 <exit@plt>

LLVM IR (-O0):
@.str = [41 x i8] c"strcase_search: Out of memory for malloc\00"
define i32 @strcase_search(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i32
store i8* %0, i8** %3
store i8* %1, i8** %4
store i32 0, i32* %7
%8 = load i8*, i8** %3
%9 = call i64 @strlen(i8* %8)
%10 = add nsw i64 %9, 1
%11 = call i64 @malloc(i64 %10)
%12 = inttoptr i64 %11 to i8*
store i8* %12, i8** %5
%13 = load i8*, i8** %5
%14 = icmp eq i8* %13, null
br i1 %14, label %15, label %18
15: ; preds = %2
%16 = call i32 @print_error(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str, i64 0, i64 0))
%17 = call i32 @exit(i32 1)
unreachable
18: ; preds = %2
%19 = load i8*, i8** %4
%20 = call i64 @strlen(i8* %19)
%21 = add nsw i64 %20, 1
%22 = call i64 @malloc(i64 %21)
%23 = inttoptr i64 %22 to i8*
store i8* %23, i8** %6
%24 = load i8*, i8** %6
%25 = icmp eq i8* %24, null
br i1 %25, label %26, label %31
26: ; preds = %18
%27 = load i8*, i8** %5
%28 = call i32 @free(i8* %27)
%29 = call i32 @print_error(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str, i64 0, i64 0))
%30 = call i32 @exit(i32 1)
unreachable
31: ; preds = %18
%32 = load i8*, i8** %5
%33 = load i8*, i8** %3
%34 = call i32 @strcpy(i8* %32, i8* %33)
%35 = load i8*, i8** %6
%36 = load i8*, i8** %4
%37 = call i32 @strcpy(i8* %35, i8* %36)
%38 = load i8*, i8** %5
%39 = call i32 @string_lower(i8* %38)
%40 = load i8*, i8** %6
%41 = call i32 @string_lower(i8* %40)
%42 = load i8*, i8** %5
%43 = load i8*, i8** %6
%44 = call i32* @strstr(i8* %42, i8* %43)
%45 = icmp eq i32* %44, null
br i1 %45, label %46, label %47
46: ; preds = %31
store i32 0, i32* %7
br label %48
47: ; preds = %31
store i32 1, i32* %7
br label %48
48: ; preds = %47, %46
%49 = load i8*, i8** %5
%50 = call i32 @free(i8* %49)
%51 = load i8*, i8** %6
%52 = call i32 @free(i8* %51)
%53 = load i32, i32* %7
ret i32 %53
}

LLVM IR (-O2):
@.str = [41 x i8] c"strcase_search: Out of memory for malloc\00"
define i32 @strcase_search(i8* %0, i8* %1) {
%3 = tail call i64 @strlen(i8* dereferenceable(1) %0)
%4 = add nsw i64 %3, 1
%5 = tail call i64 @malloc(i64 %4)
%6 = inttoptr i64 %5 to i8*
%7 = icmp eq i64 %5, 0
br i1 %7, label %8, label %11
8: ; preds = %2
%9 = tail call i32 @print_error(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str, i64 0, i64 0))
%10 = tail call i32 @exit(i32 1)
unreachable
11: ; preds = %2
%12 = tail call i64 @strlen(i8* dereferenceable(1) %1)
%13 = add nsw i64 %12, 1
%14 = tail call i64 @malloc(i64 %13)
%15 = inttoptr i64 %14 to i8*
%16 = icmp eq i64 %14, 0
br i1 %16, label %17, label %21
17: ; preds = %11
%18 = tail call i32 @free(i8* %6)
%19 = tail call i32 @print_error(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str, i64 0, i64 0))
%20 = tail call i32 @exit(i32 1)
unreachable
21: ; preds = %11
%22 = tail call i32 @strcpy(i8* %6, i8* %0)
%23 = tail call i32 @strcpy(i8* %15, i8* %1)
%24 = tail call i32 @string_lower(i8* %6)
%25 = tail call i32 @string_lower(i8* %15)
%26 = tail call i32* @strstr(i8* %6, i8* %15)
%27 = icmp ne i32* %26, null
%28 = zext i1 %27 to i32
%29 = tail call i32 @free(i8* %6)
%30 = tail call i32 @free(i8* %15)
ret i32 %28
}