#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 */
scalar_t__ tolower(char);
bool chk_ele_sym(char *element, char *symbol) {
  bool first = false;
  bool result = false;
  for (; *element; element++) {
    if (tolower(*element) == tolower(*symbol)) {
      if (!first) {
        first = true;
        symbol++;
      } else {
        result = true;
      }
    }
  }
  return result;
}


x86 assembly (clang, -O0):
<chk_ele_sym>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x8(%rbp),%rax
cmpb   $0x0,(%rax)
je     11ab <chk_ele_sym+0x9b>
mov    -0x8(%rbp),%rax
movsbl (%rax),%edi
call   1030 <tolower@plt>
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%edi
call   1030 <tolower@plt>
mov    %rax,%rcx
mov    -0x20(%rbp),%rax
cmp    %rcx,%rax
jne    1195 <chk_ele_sym+0x85>
cmpl   $0x0,-0x14(%rbp)
jne    1189 <chk_ele_sym+0x79>
movl   $0x1,-0x14(%rbp)
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    1190 <chk_ele_sym+0x80>
movl   $0x1,-0x18(%rbp)
jmp    1195 <chk_ele_sym+0x85>
jmp    119a <chk_ele_sym+0x8a>
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
jmp    112e <chk_ele_sym+0x1e>
mov    -0x18(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<chk_ele_sym>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    (%rdi),%al
test   %al,%al
je     1185 <chk_ele_sym+0x75>
mov    %rsi,%r14
mov    %rdi,%r13
add    $0x1,%r13
xor    %ebp,%ebp
mov    $0x1,%r12d
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nop
movsbl %al,%edi
call   1030 <tolower@plt>
mov    %rax,%r15
movsbl (%r14),%edi
call   1030 <tolower@plt>
test   %ebx,%ebx
sete   %cl
mov    $0x1,%edx
cmove  %ebp,%edx
cmp    %rax,%r15
sete   %al
cmove  %r12d,%ebx
cmove  %edx,%ebp
and    %cl,%al
movzbl %al,%eax
add    %rax,%r14
movzbl 0x0(%r13),%eax
add    $0x1,%r13
test   %al,%al
jne    1140 <chk_ele_sym+0x30>
jmp    1187 <chk_ele_sym+0x77>
xor    %ebp,%ebp
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define i32 @chk_ele_sym(i8* nocapture %0, i8* nocapture %1) {
%3 = load i8, i8* %0
%4 = icmp eq i8 %3, 0
br i1 %4, label %25, label %5
5: ; preds = %2, %5
%6 = phi i8 [ %23, %5 ], [ %3, %2 ]
%7 = phi i32 [ %21, %5 ], [ 0, %2 ]
%8 = phi i32 [ %20, %5 ], [ 0, %2 ]
%9 = phi i8* [ %19, %5 ], [ %1, %2 ]
%10 = phi i8* [ %22, %5 ], [ %0, %2 ]
%11 = tail call i64 @tolower(i8 signext %6)
%12 = load i8, i8* %9
%13 = tail call i64 @tolower(i8 signext %12)
%14 = icmp eq i64 %11, %13
%15 = icmp eq i32 %8, 0
%16 = select i1 %15, i32 %7, i32 1
%17 = select i1 %14, i1 %15, i1 false
%18 = zext i1 %17 to i64
%19 = getelementptr i8, i8* %9, i64 %18
%20 = select i1 %14, i32 1, i32 %8
%21 = select i1 %14, i32 %16, i32 %7
%22 = getelementptr inbounds i8, i8* %10, i64 1
%23 = load i8, i8* %22
%24 = icmp eq i8 %23, 0
br i1 %24, label %25, label %5
25: ; preds = %5, %2
%26 = phi i32 [ 0, %2 ], [ %21, %5 ]
ret i32 %26
}