#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 */
char tolower(int /*<<< orphan*/);
char *wordsrch(char *, char const *);
char *cwordsrch(char *s, const char *c) {
  char *r, *p, l[100];
  if ((r = wordsrch(s, c)) == NULL) {
    for (p = l; *p++ = tolower(*c++);)
      ;
    r = wordsrch(s, l);
  }
  return r;
}


x86 assembly (clang, -O0):
<cwordsrch>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1030 <wordsrch@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
jne    11a2 <cwordsrch+0x82>
lea    -0x90(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x10(%rbp)
movsbl (%rax),%edi
call   1040 <tolower@plt>
mov    -0x20(%rbp),%rcx
mov    %rcx,%rdx
add    $0x1,%rdx
mov    %rdx,-0x20(%rbp)
mov    %al,(%rcx)
cmp    $0x0,%al
je     118e <cwordsrch+0x6e>
jmp    1159 <cwordsrch+0x39>
mov    -0x8(%rbp),%rdi
lea    -0x90(%rbp),%rsi
call   1030 <wordsrch@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cwordsrch>:
push   %r15
push   %r14
push   %rbx
sub    $0x70,%rsp
mov    %rsi,%r15
mov    %rdi,%r14
call   1030 <wordsrch@plt>
test   %rax,%rax
jne    1160 <cwordsrch+0x40>
xor    %ebx,%ebx
nopl   0x0(%rax,%rax,1)
movsbl (%r15,%rbx,1),%edi
call   1040 <tolower@plt>
mov    %al,(%rsp,%rbx,1)
add    $0x1,%rbx
test   %al,%al
jne    1140 <cwordsrch+0x20>
mov    %rsp,%rsi
mov    %r14,%rdi
call   1030 <wordsrch@plt>
add    $0x70,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i8* @cwordsrch(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca [100 x i8]
store i8* %0, i8** %3
store i8* %1, i8** %4
%8 = load i8*, i8** %3
%9 = load i8*, i8** %4
%10 = call i8* @wordsrch(i8* %8, i8* %9)
store i8* %10, i8** %5
%11 = icmp eq i8* %10, null
br i1 %11, label %12, label %28
12: ; preds = %2
%13 = getelementptr inbounds [100 x i8], [100 x i8]* %7, i64 0, i64 0
store i8* %13, i8** %6
br label %14
14: ; preds = %23, %12
%15 = load i8*, i8** %4
%16 = getelementptr inbounds i8, i8* %15, i32 1
store i8* %16, i8** %4
%17 = load i8, i8* %15
%18 = sext i8 %17 to i32
%19 = call signext i8 @tolower(i32 %18)
%20 = load i8*, i8** %6
%21 = getelementptr inbounds i8, i8* %20, i32 1
store i8* %21, i8** %6
store i8 %19, i8* %20
%22 = icmp ne i8 %19, 0
br i1 %22, label %23, label %24
23: ; preds = %14
br label %14
24: ; preds = %14
%25 = load i8*, i8** %3
%26 = getelementptr inbounds [100 x i8], [100 x i8]* %7, i64 0, i64 0
%27 = call i8* @wordsrch(i8* %25, i8* %26)
store i8* %27, i8** %5
br label %28
28: ; preds = %24, %2
%29 = load i8*, i8** %5
ret i8* %29
}

LLVM IR (-O2):
define i8* @cwordsrch(i8* %0, i8* %1) {
%3 = alloca [100 x i8]
%4 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%5 = tail call i8* @wordsrch(i8* %0, i8* %1)
%6 = icmp eq i8* %5, null
br i1 %6, label %7, label %18
7: ; preds = %2, %7
%8 = phi i8* [ %10, %7 ], [ %1, %2 ]
%9 = phi i8* [ %14, %7 ], [ %4, %2 ]
%10 = getelementptr inbounds i8, i8* %8, i64 1
%11 = load i8, i8* %8
%12 = sext i8 %11 to i32
%13 = tail call signext i8 @tolower(i32 %12)
%14 = getelementptr inbounds i8, i8* %9, i64 1
store i8 %13, i8* %9
%15 = icmp eq i8 %13, 0
br i1 %15, label %16, label %7
16: ; preds = %7
%17 = call i8* @wordsrch(i8* %0, i8* %4)
br label %18
18: ; preds = %16, %2
%19 = phi i8* [ %17, %16 ], [ %5, %2 ]
ret i8* %19
}