#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(unsigned char);
int strcasecmp(register const char *s1, register const char *s2) {
  int r = 0;
  while (((s1 == s2) || !(r = ((int)(tolower(*((unsigned char *)s1)))) -
                              tolower(*((unsigned char *)s2)))) &&
         (++s2, *s1++))
    ;
  return r;
}


x86 assembly (clang, -O0):
<strcasecmp>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x8(%rbp),%rax
cmp    -0x10(%rbp),%rax
je     1166 <strcasecmp+0x56>
mov    -0x8(%rbp),%rax
movzbl (%rax),%edi
call   1030 <tolower@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x10(%rbp),%rax
movzbl (%rax),%edi
call   1030 <tolower@plt>
mov    -0x1c(%rbp),%ecx
sub    %eax,%ecx
mov    %ecx,-0x14(%rbp)
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x15(%rbp)
jne    118d <strcasecmp+0x7d>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x8(%rbp)
movsbl (%rax),%eax
cmp    $0x0,%eax
setne  %al
mov    %al,-0x15(%rbp)
mov    -0x15(%rbp),%al
test   $0x1,%al
jne    119d <strcasecmp+0x8d>
jmp    11a2 <strcasecmp+0x92>
jmp    1127 <strcasecmp+0x17>
mov    -0x14(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<strcasecmp>:
push   %rbp
push   %r14
push   %rbx
mov    %rsi,%rbx
mov    %rdi,%r14
jmp    112e <strcasecmp+0x1e>
nopl   0x0(%rax)
add    $0x1,%rbx
cmpb   $0x0,(%r14)
lea    0x1(%r14),%r14
je     114c <strcasecmp+0x3c>
cmp    %r14,%rbx
je     1120 <strcasecmp+0x10>
movzbl (%r14),%edi
call   1030 <tolower@plt>
mov    %eax,%ebp
movzbl (%rbx),%edi
call   1030 <tolower@plt>
sub    %eax,%ebp
je     1120 <strcasecmp+0x10>
jmp    114e <strcasecmp+0x3e>
xor    %ebp,%ebp
mov    %ebp,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

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

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