#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 const *);
int tolower(unsigned char const);
int strcasecmp(const char *s1, const char *s2) {
  assert(s1);
  assert(s2);
  while (*s1) {
    int c1 = tolower(*(const unsigned char *)s1);
    int c2 = tolower(*(const unsigned char *)s2);
    if (c1 < c2)
      return -1;
    if (c1 > c2)
      return +1;
    ++s1;
    ++s2;
  }
  if (*s2 != 0)
    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),%rdi
call   1030 <assert@plt>
mov    -0x18(%rbp),%rdi
call   1030 <assert@plt>
mov    -0x10(%rbp),%rax
cmpb   $0x0,(%rax)
je     11ba <strcasecmp+0x9a>
mov    -0x10(%rbp),%rax
movzbl (%rax),%edi
call   1040 <tolower@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%rax
movzbl (%rax),%edi
call   1040 <tolower@plt>
mov    %eax,-0x20(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x20(%rbp),%eax
jge    1185 <strcasecmp+0x65>
movl   $0xffffffff,-0x4(%rbp)
jmp    11dd <strcasecmp+0xbd>
mov    -0x1c(%rbp),%eax
cmp    -0x20(%rbp),%eax
jle    119d <strcasecmp+0x7d>
movl   $0x1,-0x4(%rbp)
jmp    11dd <strcasecmp+0xbd>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    1142 <strcasecmp+0x22>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     11d6 <strcasecmp+0xb6>
movl   $0xffffffff,-0x4(%rbp)
jmp    11dd <strcasecmp+0xbd>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<strcasecmp>:
push   %rbp
push   %r14
push   %rbx
mov    %rsi,%r14
mov    %rdi,%rbx
call   1030 <assert@plt>
mov    %r14,%rdi
call   1030 <assert@plt>
mov    (%rbx),%al
test   %al,%al
je     1178 <strcasecmp+0x58>
add    $0x1,%rbx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movzbl %al,%edi
call   1040 <tolower@plt>
mov    %eax,%ebp
movzbl (%r14),%edi
call   1040 <tolower@plt>
cmp    %eax,%ebp
jl     1181 <strcasecmp+0x61>
jg     1188 <strcasecmp+0x68>
add    $0x1,%r14
movzbl (%rbx),%eax
add    $0x1,%rbx
test   %al,%al
jne    1150 <strcasecmp+0x30>
xor    %eax,%eax
cmp    (%r14),%al
sbb    %eax,%eax
jmp    118d <strcasecmp+0x6d>
mov    $0xffffffff,%eax
jmp    118d <strcasecmp+0x6d>
mov    $0x1,%eax
pop    %rbx
pop    %r14
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
%8 = load i8*, i8** %4
%9 = call i32 @assert(i8* %8)
%10 = load i8*, i8** %5
%11 = call i32 @assert(i8* %10)
br label %12
12: ; preds = %32, %2
%13 = load i8*, i8** %4
%14 = load i8, i8* %13
%15 = icmp ne i8 %14, 0
br i1 %15, label %16, label %37
16: ; preds = %12
%17 = load i8*, i8** %4
%18 = load i8, i8* %17
%19 = call i32 @tolower(i8 zeroext %18)
store i32 %19, i32* %6
%20 = load i8*, i8** %5
%21 = load i8, i8* %20
%22 = call i32 @tolower(i8 zeroext %21)
store i32 %22, i32* %7
%23 = load i32, i32* %6
%24 = load i32, i32* %7
%25 = icmp slt i32 %23, %24
br i1 %25, label %26, label %27
26: ; preds = %16
store i32 -1, i32* %3
br label %44
27: ; preds = %16
%28 = load i32, i32* %6
%29 = load i32, i32* %7
%30 = icmp sgt i32 %28, %29
br i1 %30, label %31, label %32
31: ; preds = %27
store i32 1, i32* %3
br label %44
32: ; preds = %27
%33 = load i8*, i8** %4
%34 = getelementptr inbounds i8, i8* %33, i32 1
store i8* %34, i8** %4
%35 = load i8*, i8** %5
%36 = getelementptr inbounds i8, i8* %35, i32 1
store i8* %36, i8** %5
br label %12
37: ; preds = %12
%38 = load i8*, i8** %5
%39 = load i8, i8* %38
%40 = sext i8 %39 to i32
%41 = icmp ne i32 %40, 0
br i1 %41, label %42, label %43
42: ; preds = %37
store i32 -1, i32* %3
br label %44
43: ; preds = %37
store i32 0, i32* %3
br label %44
44: ; preds = %43, %42, %31, %26
%45 = load i32, i32* %3
ret i32 %45
}

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