#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 tolower(int /*<<< orphan*/);
int strcasecmp(const char *s1, const char *s2) {
  while (1) {
    int a = tolower(*s1++);
    int b = tolower(*s2++);
    if ((a == b)) {
      if (a == 0)
        break;
      continue;
    }
    if (a < b)
      return -1;
    return 1;
  }
  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    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x18(%rbp)
movsbl (%rax),%edi
call   1030 <tolower@plt>
mov    %eax,-0x20(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x20(%rbp),%eax
jne    1174 <strcasecmp+0x64>
cmpl   $0x0,-0x1c(%rbp)
jne    116f <strcasecmp+0x5f>
jmp    1198 <strcasecmp+0x88>
jmp    1120 <strcasecmp+0x10>
mov    -0x1c(%rbp),%eax
cmp    -0x20(%rbp),%eax
jge    118c <strcasecmp+0x7c>
movl   $0xffffffff,-0x4(%rbp)
jmp    119f <strcasecmp+0x8f>
movl   $0x1,-0x4(%rbp)
jmp    119f <strcasecmp+0x8f>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<strcasecmp>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%r15
xor    %ebp,%ebp
mov    $0x1,%r13d
nopl   0x0(%rax)
movsbl (%r15,%rbp,1),%edi
call   1030 <tolower@plt>
mov    %eax,%r12d
movsbl (%r14,%rbp,1),%edi
call   1030 <tolower@plt>
xor    %ecx,%ecx
test   %r12d,%r12d
sete   %cl
or     $0x2,%ecx
xor    %edx,%edx
cmp    %eax,%r12d
setge  %dl
lea    -0x1(%rdx,%rdx,1),%eax
cmovne %eax,%ebx
cmovne %r13d,%ecx
add    $0x1,%rbp
cmp    $0x2,%ecx
je     1130 <strcasecmp+0x20>
cmp    $0x3,%ecx
jne    1175 <strcasecmp+0x65>
xor    %ebx,%ebx
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
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 i32
%7 = alloca i32
store i8* %0, i8** %4
store i8* %1, i8** %5
br label %8
8: ; preds = %2, %26
%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 i32 @tolower(i32 %12)
store i32 %13, i32* %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 i32 @tolower(i32 %17)
store i32 %18, i32* %7
%19 = load i32, i32* %6
%20 = load i32, i32* %7
%21 = icmp eq i32 %19, %20
br i1 %21, label %22, label %27
22: ; preds = %8
%23 = load i32, i32* %6
%24 = icmp eq i32 %23, 0
br i1 %24, label %25, label %26
25: ; preds = %22
br label %33
26: ; preds = %22
br label %8
27: ; preds = %8
%28 = load i32, i32* %6
%29 = load i32, i32* %7
%30 = icmp slt i32 %28, %29
br i1 %30, label %31, label %32
31: ; preds = %27
store i32 -1, i32* %3
br label %34
32: ; preds = %27
store i32 1, i32* %3
br label %34
33: ; preds = %25
store i32 0, i32* %3
br label %34
34: ; preds = %33, %32, %31
%35 = load i32, i32* %3
ret i32 %35
}

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