#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(char);
int String_CompareCaseInsensitive(char *str0, char *str1) {
  for (int i = 0;; i++) {
    char c0 = tolower(str0[i]);
    char c1 = tolower(str1[i]);
    if (c0 != c1) {
      return (c0 < c1) ? -1 : 1;
    }
    if (c0 == '\0') {
      return 0;
    }
  }
}


x86 assembly (clang, -O0):
<String_CompareCaseInsensitive>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1030 <tolower@plt>
mov    %al,-0x1d(%rbp)
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1030 <tolower@plt>
mov    %al,-0x1e(%rbp)
movsbl -0x1d(%rbp),%eax
movsbl -0x1e(%rbp),%ecx
cmp    %ecx,%eax
je     117e <String_CompareCaseInsensitive+0x6e>
movsbl -0x1d(%rbp),%edx
movsbl -0x1e(%rbp),%esi
mov    $0x1,%eax
mov    $0xffffffff,%ecx
cmp    %esi,%edx
cmovl  %ecx,%eax
mov    %eax,-0x4(%rbp)
jmp    11aa <String_CompareCaseInsensitive+0x9a>
movsbl -0x1d(%rbp),%eax
cmp    $0x0,%eax
jne    1197 <String_CompareCaseInsensitive+0x87>
movl   $0x0,-0x4(%rbp)
jmp    11aa <String_CompareCaseInsensitive+0x9a>
jmp    119c <String_CompareCaseInsensitive+0x8c>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1127 <String_CompareCaseInsensitive+0x17>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<String_CompareCaseInsensitive>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%r15
movsbl (%rdi),%edi
call   1030 <tolower@plt>
mov    %eax,%ebp
movsbl (%r14),%edi
call   1030 <tolower@plt>
cmp    %al,%bpl
jne    1164 <String_CompareCaseInsensitive+0x54>
mov    $0x1,%ebx
nopw   0x0(%rax,%rax,1)
test   %bpl,%bpl
je     1174 <String_CompareCaseInsensitive+0x64>
movsbl (%r15,%rbx,1),%edi
call   1030 <tolower@plt>
mov    %eax,%ebp
movsbl (%r14,%rbx,1),%edi
call   1030 <tolower@plt>
add    $0x1,%rbx
cmp    %al,%bpl
je     1140 <String_CompareCaseInsensitive+0x30>
xor    %ecx,%ecx
cmp    %al,%bpl
setge  %cl
lea    (%rcx,%rcx,1),%eax
add    $0xffffffff,%eax
jmp    1176 <String_CompareCaseInsensitive+0x66>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

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