#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*/ assert(char *);
int /*<<< orphan*/ chars_equals_ignore_case(char, char);
unsigned int strings_length(char *);
bool strings_equals_ignore_case(char *string1, char *string2) {
  assert(string1);
  assert(string2);
  unsigned int length1 = strings_length(string1),
               length2 = strings_length(string2);
  if (length1 != length2)
    return false;
  for (unsigned int k = 0; k < length1; k++) {
    if (!chars_equals_ignore_case(string1[k], string2[k]))
      return false;
  }
  return true;
}


x86 assembly (clang, -O0):
<strings_equals_ignore_case>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
call   1050 <assert@plt>
mov    -0x18(%rbp),%rdi
call   1050 <assert@plt>
mov    -0x10(%rbp),%rdi
call   1040 <strings_length@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <strings_length@plt>
mov    %eax,-0x20(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x20(%rbp),%eax
je     1182 <strings_equals_ignore_case+0x52>
movl   $0x0,-0x4(%rbp)
jmp    11e1 <strings_equals_ignore_case+0xb1>
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jae    11da <strings_equals_ignore_case+0xaa>
mov    -0x10(%rbp),%rax
mov    -0x24(%rbp),%ecx
mov    (%rax,%rcx,1),%dl
mov    -0x18(%rbp),%rax
mov    -0x24(%rbp),%ecx
movsbl %dl,%edi
movsbl (%rax,%rcx,1),%esi
call   1030 <chars_equals_ignore_case@plt>
cmp    $0x0,%eax
jne    11c7 <strings_equals_ignore_case+0x97>
movl   $0x0,-0x4(%rbp)
jmp    11e1 <strings_equals_ignore_case+0xb1>
jmp    11cc <strings_equals_ignore_case+0x9c>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1189 <strings_equals_ignore_case+0x59>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<strings_equals_ignore_case>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rsi,%r14
mov    %rdi,%rbx
call   1050 <assert@plt>
mov    %r14,%rdi
call   1050 <assert@plt>
mov    %rbx,%rdi
call   1040 <strings_length@plt>
mov    %eax,%ebp
mov    %r14,%rdi
call   1040 <strings_length@plt>
xor    %r15d,%r15d
cmp    %eax,%ebp
jne    11b0 <strings_equals_ignore_case+0x80>
test   %ebp,%ebp
je     11aa <strings_equals_ignore_case+0x7a>
movsbl (%rbx),%edi
movsbl (%r14),%esi
call   1030 <chars_equals_ignore_case@plt>
test   %eax,%eax
je     11b0 <strings_equals_ignore_case+0x80>
mov    %ebp,%r12d
mov    $0x1,%ecx
mov    %rcx,%rbp
cmp    %rcx,%r12
je     119e <strings_equals_ignore_case+0x6e>
movsbl (%rbx,%rbp,1),%edi
movsbl (%r14,%rbp,1),%esi
call   1030 <chars_equals_ignore_case@plt>
lea    0x1(%rbp),%rcx
test   %eax,%eax
jne    1180 <strings_equals_ignore_case+0x50>
xor    %r15d,%r15d
cmp    %r12,%rbp
setae  %r15b
jmp    11b0 <strings_equals_ignore_case+0x80>
mov    $0x1,%r15d
mov    %r15d,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @strings_equals_ignore_case(i8* %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i8* %0, i8** %4
store i8* %1, i8** %5
%9 = load i8*, i8** %4
%10 = call i32 @assert(i8* %9)
%11 = load i8*, i8** %5
%12 = call i32 @assert(i8* %11)
%13 = load i8*, i8** %4
%14 = call i32 @strings_length(i8* %13)
store i32 %14, i32* %6
%15 = load i8*, i8** %5
%16 = call i32 @strings_length(i8* %15)
store i32 %16, i32* %7
%17 = load i32, i32* %6
%18 = load i32, i32* %7
%19 = icmp ne i32 %17, %18
br i1 %19, label %20, label %21
20: ; preds = %2
store i32 0, i32* %3
br label %45
21: ; preds = %2
store i32 0, i32* %8
br label %22
22: ; preds = %41, %21
%23 = load i32, i32* %8
%24 = load i32, i32* %6
%25 = icmp ult i32 %23, %24
br i1 %25, label %26, label %44
26: ; preds = %22
%27 = load i8*, i8** %4
%28 = load i32, i32* %8
%29 = zext i32 %28 to i64
%30 = getelementptr inbounds i8, i8* %27, i64 %29
%31 = load i8, i8* %30
%32 = load i8*, i8** %5
%33 = load i32, i32* %8
%34 = zext i32 %33 to i64
%35 = getelementptr inbounds i8, i8* %32, i64 %34
%36 = load i8, i8* %35
%37 = call i32 @chars_equals_ignore_case(i8 signext %31, i8 signext %36)
%38 = icmp ne i32 %37, 0
br i1 %38, label %40, label %39
39: ; preds = %26
store i32 0, i32* %3
br label %45
40: ; preds = %26
br label %41
41: ; preds = %40
%42 = load i32, i32* %8
%43 = add i32 %42, 1
store i32 %43, i32* %8
br label %22
44: ; preds = %22
store i32 1, i32* %3
br label %45
45: ; preds = %44, %39, %20
%46 = load i32, i32* %3
ret i32 %46
}

LLVM IR (-O2):
define i32 @strings_equals_ignore_case(i8* %0, i8* %1) {
%3 = tail call i32 @assert(i8* %0)
%4 = tail call i32 @assert(i8* %1)
%5 = tail call i32 @strings_length(i8* %0)
%6 = tail call i32 @strings_length(i8* %1)
%7 = icmp eq i32 %5, %6
br i1 %7, label %8, label %30
8: ; preds = %2
%9 = icmp eq i32 %5, 0
br i1 %9, label %30, label %10
10: ; preds = %8
%11 = zext i32 %5 to i64
%12 = load i8, i8* %0
%13 = load i8, i8* %1
%14 = tail call i32 @chars_equals_ignore_case(i8 signext %12, i8 signext %13)
%15 = icmp eq i32 %14, 0
br i1 %15, label %30, label %16
16: ; preds = %10, %19
%17 = phi i64 [ %26, %19 ], [ 1, %10 ]
%18 = icmp eq i64 %17, %11
br i1 %18, label %27, label %19
19: ; preds = %16
%20 = getelementptr inbounds i8, i8* %0, i64 %17
%21 = load i8, i8* %20
%22 = getelementptr inbounds i8, i8* %1, i64 %17
%23 = load i8, i8* %22
%24 = tail call i32 @chars_equals_ignore_case(i8 signext %21, i8 signext %23)
%25 = icmp eq i32 %24, 0
%26 = add nuw nsw i64 %17, 1
br i1 %25, label %27, label %16
27: ; preds = %16, %19
%28 = icmp uge i64 %17, %11
%29 = zext i1 %28 to i32
br label %30
30: ; preds = %8, %10, %27, %2
%31 = phi i32 [ 0, %2 ], [ 1, %8 ], [ 0, %10 ], [ %29, %27 ]
ret i32 %31
}