#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__ CK_Cross_toupper(char const);
int CK_Cross_strcasecmp(const char *s1, const char *s2) {
  unsigned char uc1, uc2;
  for (; (*s1) && (CK_Cross_toupper(*s1) == CK_Cross_toupper(*s2)); s1++, s2++)
    ;
  uc1 = (unsigned char)((char)(CK_Cross_toupper(*s1)));
  uc2 = (unsigned char)((char)(CK_Cross_toupper(*s2)));
  return ((int)uc1 - (int)uc2);
}


x86 assembly (clang, -O0):
<CK_Cross_strcasecmp>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rax
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x13(%rbp)
je     1161 <CK_Cross_strcasecmp+0x51>
mov    -0x8(%rbp),%rax
movsbl (%rax),%edi
call   1030 <CK_Cross_toupper@plt>
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%edi
call   1030 <CK_Cross_toupper@plt>
mov    %rax,%rcx
mov    -0x20(%rbp),%rax
cmp    %rcx,%rax
sete   %al
mov    %al,-0x13(%rbp)
mov    -0x13(%rbp),%al
test   $0x1,%al
jne    1171 <CK_Cross_strcasecmp+0x61>
jmp    1193 <CK_Cross_strcasecmp+0x83>
jmp    1176 <CK_Cross_strcasecmp+0x66>
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    1120 <CK_Cross_strcasecmp+0x10>
mov    -0x8(%rbp),%rax
movsbl (%rax),%edi
call   1030 <CK_Cross_toupper@plt>
mov    %al,-0x11(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%edi
call   1030 <CK_Cross_toupper@plt>
mov    %al,-0x12(%rbp)
movzbl -0x11(%rbp),%eax
movzbl -0x12(%rbp),%ecx
sub    %ecx,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<CK_Cross_strcasecmp>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%r14
mov    (%rdi),%al
test   %al,%al
je     1158 <CK_Cross_strcasecmp+0x48>
mov    %rdi,%rbx
add    $0x1,%rbx
cs nopw 0x0(%rax,%rax,1)
nop
movsbl %al,%edi
call   1030 <CK_Cross_toupper@plt>
mov    %rax,%r15
movsbl (%r14),%edi
call   1030 <CK_Cross_toupper@plt>
cmp    %rax,%r15
jne    115c <CK_Cross_strcasecmp+0x4c>
add    $0x1,%r14
movzbl (%rbx),%eax
add    $0x1,%rbx
test   %al,%al
jne    1130 <CK_Cross_strcasecmp+0x20>
xor    %eax,%eax
jmp    115f <CK_Cross_strcasecmp+0x4f>
mov    -0x1(%rbx),%al
movsbl %al,%edi
call   1030 <CK_Cross_toupper@plt>
mov    %rax,%rbx
movsbl (%r14),%edi
call   1030 <CK_Cross_toupper@plt>
movzbl %bl,%ecx
movzbl %al,%eax
sub    %eax,%ecx
mov    %ecx,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
define i32 @CK_Cross_strcasecmp(i8* nocapture %0, i8* nocapture %1) {
%3 = load i8, i8* %0
%4 = icmp eq i8 %3, 0
br i1 %4, label %20, label %5
5: ; preds = %2, %15
%6 = phi i8 [ %18, %15 ], [ %3, %2 ]
%7 = phi i8* [ %16, %15 ], [ %0, %2 ]
%8 = phi i8* [ %17, %15 ], [ %1, %2 ]
%9 = tail call i64 @CK_Cross_toupper(i8 signext %6)
%10 = load i8, i8* %8
%11 = tail call i64 @CK_Cross_toupper(i8 signext %10)
%12 = icmp eq i64 %9, %11
br i1 %12, label %15, label %13
13: ; preds = %5
%14 = load i8, i8* %7
br label %20
15: ; preds = %5
%16 = getelementptr inbounds i8, i8* %7, i64 1
%17 = getelementptr inbounds i8, i8* %8, i64 1
%18 = load i8, i8* %16
%19 = icmp eq i8 %18, 0
br i1 %19, label %20, label %5
20: ; preds = %15, %13, %2
%21 = phi i8 [ 0, %2 ], [ %14, %13 ], [ 0, %15 ]
%22 = phi i8* [ %1, %2 ], [ %8, %13 ], [ %17, %15 ]
%23 = tail call i64 @CK_Cross_toupper(i8 signext %21)
%24 = trunc i64 %23 to i32
%25 = load i8, i8* %22
%26 = tail call i64 @CK_Cross_toupper(i8 signext %25)
%27 = trunc i64 %26 to i32
%28 = and i32 %24, 255
%29 = and i32 %27, 255
%30 = sub nsw i32 %28, %29
ret i32 %30
}