#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__ strlen(char *);
scalar_t__ tolower(char);
int StrCmpCaseInsensitive(char *s, char *t) {
  int i, minLen;
  if (strlen(s) < strlen(t))
    minLen = (int)strlen(s);
  else
    minLen = (int)strlen(t);
  for (i = 0; i < minLen; i++)
    if (tolower(s[i]) != tolower(t[i]))
      break;
  if (s[i] == '\0' && t[i] == '\0')
    return 0;
  else if (tolower(s[i]) > tolower(t[i]))
    return 1;
  else
    return -1;
}


x86 assembly (clang, -O0):
<StrCmpCaseInsensitive>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %rax,-0x28(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <strlen@plt>
mov    %rax,%rcx
mov    -0x28(%rbp),%rax
cmp    %rcx,%rax
jge    1167 <StrCmpCaseInsensitive+0x47>
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x20(%rbp)
jmp    1173 <StrCmpCaseInsensitive+0x53>
mov    -0x18(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x20(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x20(%rbp),%eax
jge    11d4 <StrCmpCaseInsensitive+0xb4>
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1040 <tolower@plt>
mov    %rax,-0x30(%rbp)
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1040 <tolower@plt>
mov    %rax,%rcx
mov    -0x30(%rbp),%rax
cmp    %rcx,%rax
je     11c1 <StrCmpCaseInsensitive+0xa1>
jmp    11d4 <StrCmpCaseInsensitive+0xb4>
jmp    11c6 <StrCmpCaseInsensitive+0xa6>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    117a <StrCmpCaseInsensitive+0x5a>
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x0,%eax
jne    120a <StrCmpCaseInsensitive+0xea>
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x0,%eax
jne    120a <StrCmpCaseInsensitive+0xea>
movl   $0x0,-0x4(%rbp)
jmp    1253 <StrCmpCaseInsensitive+0x133>
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1040 <tolower@plt>
mov    %rax,-0x38(%rbp)
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1040 <tolower@plt>
mov    %rax,%rcx
mov    -0x38(%rbp),%rax
cmp    %rcx,%rax
jle    124c <StrCmpCaseInsensitive+0x12c>
movl   $0x1,-0x4(%rbp)
jmp    1253 <StrCmpCaseInsensitive+0x133>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<StrCmpCaseInsensitive>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%r13
call   1030 <strlen@plt>
mov    %rax,%r12
mov    %r14,%rdi
call   1030 <strlen@plt>
mov    %rax,%r15
cmp    %rax,%r12
cmovl  %r12,%r15
test   %r15d,%r15d
jle    118b <StrCmpCaseInsensitive+0x6b>
mov    %r15d,%ebp
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nop
movsbl 0x0(%r13,%rbx,1),%edi
call   1040 <tolower@plt>
mov    %rax,%r12
movsbl (%r14,%rbx,1),%edi
call   1040 <tolower@plt>
cmp    %rax,%r12
jne    118d <StrCmpCaseInsensitive+0x6d>
add    $0x1,%rbx
cmp    %rbx,%rbp
jne    1160 <StrCmpCaseInsensitive+0x40>
mov    %r15,%rbx
jmp    118d <StrCmpCaseInsensitive+0x6d>
xor    %ebx,%ebx
mov    %ebx,%ebp
mov    0x0(%r13,%rbp,1),%al
test   %al,%al
jne    119f <StrCmpCaseInsensitive+0x7f>
cmpb   $0x0,(%r14,%rbp,1)
je     11d1 <StrCmpCaseInsensitive+0xb1>
movsbl %al,%edi
call   1040 <tolower@plt>
mov    %rax,%rbx
movsbl (%r14,%rbp,1),%edi
call   1040 <tolower@plt>
xor    %ecx,%ecx
cmp    %rax,%rbx
setg   %cl
lea    (%rcx,%rcx,1),%eax
add    $0xffffffff,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
xor    %eax,%eax
jmp    11c2 <StrCmpCaseInsensitive+0xa2>

LLVM IR (-O0):
define i32 @StrCmpCaseInsensitive(i8* %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i32
store i8* %0, i8** %4
store i8* %1, i8** %5
%8 = load i8*, i8** %4
%9 = call i64 @strlen(i8* %8)
%10 = load i8*, i8** %5
%11 = call i64 @strlen(i8* %10)
%12 = icmp slt i64 %9, %11
br i1 %12, label %13, label %17
13: ; preds = %2
%14 = load i8*, i8** %4
%15 = call i64 @strlen(i8* %14)
%16 = trunc i64 %15 to i32
store i32 %16, i32* %7
br label %21
17: ; preds = %2
%18 = load i8*, i8** %5
%19 = call i64 @strlen(i8* %18)
%20 = trunc i64 %19 to i32
store i32 %20, i32* %7
br label %21
21: ; preds = %17, %13
store i32 0, i32* %6
br label %22
22: ; preds = %42, %21
%23 = load i32, i32* %6
%24 = load i32, i32* %7
%25 = icmp slt i32 %23, %24
br i1 %25, label %26, label %45
26: ; preds = %22
%27 = load i8*, i8** %4
%28 = load i32, i32* %6
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds i8, i8* %27, i64 %29
%31 = load i8, i8* %30
%32 = call i64 @tolower(i8 signext %31)
%33 = load i8*, i8** %5
%34 = load i32, i32* %6
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds i8, i8* %33, i64 %35
%37 = load i8, i8* %36
%38 = call i64 @tolower(i8 signext %37)
%39 = icmp ne i64 %32, %38
br i1 %39, label %40, label %41
40: ; preds = %26
br label %45
41: ; preds = %26
br label %42
42: ; preds = %41
%43 = load i32, i32* %6
%44 = add nsw i32 %43, 1
store i32 %44, i32* %6
br label %22
45: ; preds = %40, %22
%46 = load i8*, i8** %4
%47 = load i32, i32* %6
%48 = sext i32 %47 to i64
%49 = getelementptr inbounds i8, i8* %46, i64 %48
%50 = load i8, i8* %49
%51 = sext i8 %50 to i32
%52 = icmp eq i32 %51, 0
br i1 %52, label %53, label %62
53: ; preds = %45
%54 = load i8*, i8** %5
%55 = load i32, i32* %6
%56 = sext i32 %55 to i64
%57 = getelementptr inbounds i8, i8* %54, i64 %56
%58 = load i8, i8* %57
%59 = sext i8 %58 to i32
%60 = icmp eq i32 %59, 0
br i1 %60, label %61, label %62
61: ; preds = %53
store i32 0, i32* %3
br label %78
62: ; preds = %53, %45
%63 = load i8*, i8** %4
%64 = load i32, i32* %6
%65 = sext i32 %64 to i64
%66 = getelementptr inbounds i8, i8* %63, i64 %65
%67 = load i8, i8* %66
%68 = call i64 @tolower(i8 signext %67)
%69 = load i8*, i8** %5
%70 = load i32, i32* %6
%71 = sext i32 %70 to i64
%72 = getelementptr inbounds i8, i8* %69, i64 %71
%73 = load i8, i8* %72
%74 = call i64 @tolower(i8 signext %73)
%75 = icmp sgt i64 %68, %74
br i1 %75, label %76, label %77
76: ; preds = %62
store i32 1, i32* %3
br label %78
77: ; preds = %62
store i32 -1, i32* %3
br label %78
78: ; preds = %77, %76, %61
%79 = load i32, i32* %3
ret i32 %79
}

LLVM IR (-O2):
define i32 @StrCmpCaseInsensitive(i8* nocapture %0, i8* nocapture %1) {
%3 = tail call i64 @strlen(i8* dereferenceable(1) %0)
%4 = tail call i64 @strlen(i8* dereferenceable(1) %1)
%5 = icmp slt i64 %3, %4
%6 = select i1 %5, i64 %3, i64 %4
%7 = trunc i64 %6 to i32
%8 = icmp sgt i32 %7, 0
br i1 %8, label %9, label %23
9: ; preds = %2
%10 = and i64 %6, 4294967295
br label %11
11: ; preds = %9, %20
%12 = phi i64 [ 0, %9 ], [ %21, %20 ]
%13 = getelementptr inbounds i8, i8* %0, i64 %12
%14 = load i8, i8* %13
%15 = tail call i64 @tolower(i8 signext %14)
%16 = getelementptr inbounds i8, i8* %1, i64 %12
%17 = load i8, i8* %16
%18 = tail call i64 @tolower(i8 signext %17)
%19 = icmp eq i64 %15, %18
br i1 %19, label %20, label %23
20: ; preds = %11
%21 = add nuw nsw i64 %12, 1
%22 = icmp eq i64 %21, %10
br i1 %22, label %23, label %11
23: ; preds = %20, %11, %2
%24 = phi i64 [ 0, %2 ], [ %12, %11 ], [ %6, %20 ]
%25 = and i64 %24, 4294967295
%26 = getelementptr inbounds i8, i8* %0, i64 %25
%27 = load i8, i8* %26
%28 = icmp eq i8 %27, 0
br i1 %28, label %29, label %33
29: ; preds = %23
%30 = getelementptr inbounds i8, i8* %1, i64 %25
%31 = load i8, i8* %30
%32 = icmp eq i8 %31, 0
br i1 %32, label %40, label %33
33: ; preds = %29, %23
%34 = tail call i64 @tolower(i8 signext %27)
%35 = getelementptr inbounds i8, i8* %1, i64 %25
%36 = load i8, i8* %35
%37 = tail call i64 @tolower(i8 signext %36)
%38 = icmp sgt i64 %34, %37
%39 = select i1 %38, i32 1, i32 -1
br label %40
40: ; preds = %33, %29
%41 = phi i32 [ 0, %29 ], [ %39, %33 ]
ret i32 %41
}