#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 */
typedef scalar_t__ int32_t;

/* Variables and functions */
scalar_t__ tolower(char const);
int32_t Strcasecmp(char const *a, char const *b) {
  for (;; ++a, ++b) {
    int32_t c = tolower(*a) - tolower(*b);
    if (c != 0 || !*a)
      return c;
  }
}


x86 assembly (clang, -O0):
<Strcasecmp>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rax
movsbl (%rax),%edi
call   1030 <tolower@plt>
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%edi
call   1030 <tolower@plt>
mov    %rax,%rcx
mov    -0x20(%rbp),%rax
sub    %rcx,%rax
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    1162 <Strcasecmp+0x52>
mov    -0x8(%rbp),%rax
cmpb   $0x0,(%rax)
jne    116c <Strcasecmp+0x5c>
mov    -0x18(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret
jmp    1171 <Strcasecmp+0x61>
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    1120 <Strcasecmp+0x10>

x86 assembly (clang, -O2):
<Strcasecmp>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%r15
movsbl (%rdi),%edi
call   1030 <tolower@plt>
mov    %rax,%rbx
movsbl (%r14),%edi
call   1030 <tolower@plt>
sub    %rax,%rbx
jne    116c <Strcasecmp+0x5c>
mov    $0x1,%r12d
nopl   (%rax)
cmpb   $0x0,-0x1(%r15,%r12,1)
je     116a <Strcasecmp+0x5a>
movsbl (%r15,%r12,1),%edi
call   1030 <tolower@plt>
mov    %rax,%rbx
movsbl (%r14,%r12,1),%edi
call   1030 <tolower@plt>
add    $0x1,%r12
sub    %rax,%rbx
je     1140 <Strcasecmp+0x30>
jmp    116c <Strcasecmp+0x5c>
xor    %ebx,%ebx
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i64 @Strcasecmp(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i64
store i8* %0, i8** %3
store i8* %1, i8** %4
br label %6
6: ; preds = %23, %2
%7 = load i8*, i8** %3
%8 = load i8, i8* %7
%9 = call i64 @tolower(i8 signext %8)
%10 = load i8*, i8** %4
%11 = load i8, i8* %10
%12 = call i64 @tolower(i8 signext %11)
%13 = sub nsw i64 %9, %12
store i64 %13, i64* %5
%14 = load i64, i64* %5
%15 = icmp ne i64 %14, 0
br i1 %15, label %20, label %16
16: ; preds = %6
%17 = load i8*, i8** %3
%18 = load i8, i8* %17
%19 = icmp ne i8 %18, 0
br i1 %19, label %22, label %20
20: ; preds = %16, %6
%21 = load i64, i64* %5
ret i64 %21
22: ; preds = %16
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 %6
}

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