#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*/);
int StrCaseCmp(char *s1, char *s2) {
  char c1, c2;
  for (;;) {
    c1 = ToLower(*s1++);
    c2 = ToLower(*s2++);
    if (c1 > c2)
      return 1;
    if (c1 < c2)
      return -1;
    if (c1 == '\000')
      return 0;
  }
}


x86 assembly (clang, -O0):
<StrCaseCmp>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x10(%rbp)
movsbl (%rax),%edi
call   1030 <ToLower@plt>
mov    %al,-0x19(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x18(%rbp)
movsbl (%rax),%edi
call   1030 <ToLower@plt>
mov    %al,-0x1a(%rbp)
movsbl -0x19(%rbp),%eax
movsbl -0x1a(%rbp),%ecx
cmp    %ecx,%eax
jle    1170 <StrCaseCmp+0x60>
movl   $0x1,-0x4(%rbp)
jmp    11aa <StrCaseCmp+0x9a>
movsbl -0x19(%rbp),%eax
movsbl -0x1a(%rbp),%ecx
cmp    %ecx,%eax
jge    118c <StrCaseCmp+0x7c>
movl   $0xffffffff,-0x4(%rbp)
jmp    11aa <StrCaseCmp+0x9a>
movsbl -0x19(%rbp),%eax
cmp    $0x0,%eax
jne    11a5 <StrCaseCmp+0x95>
movl   $0x0,-0x4(%rbp)
jmp    11aa <StrCaseCmp+0x9a>
jmp    1120 <StrCaseCmp+0x10>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<StrCaseCmp>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%r15
xor    %ebx,%ebx
nop
movsbl (%r15,%rbx,1),%edi
call   1030 <ToLower@plt>
mov    %eax,%ebp
movsbl (%r14,%rbx,1),%edi
call   1030 <ToLower@plt>
cmp    %al,%bpl
jg     114a <StrCaseCmp+0x3a>
jl     1151 <StrCaseCmp+0x41>
add    $0x1,%rbx
test   %bpl,%bpl
jne    1120 <StrCaseCmp+0x10>
xor    %eax,%eax
jmp    1156 <StrCaseCmp+0x46>
mov    $0x1,%eax
jmp    1156 <StrCaseCmp+0x46>
mov    $0xffffffff,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

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