#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__ tolower(unsigned char);
int strcasecmp(const char *s1, const char *s2) {
  unsigned char c1, c2;
  do {
    c1 = *s1++;
    c2 = *s2++;
    c1 = (unsigned char)tolower((unsigned char)c1);
    c2 = (unsigned char)tolower((unsigned char)c2);
  } while ((c1 == c2) && (c1 != '\0'));
  return (int)c1 - c2;
}


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
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x8(%rbp)
mov    (%rax),%al
mov    %al,-0x11(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x10(%rbp)
mov    (%rax),%al
mov    %al,-0x12(%rbp)
movzbl -0x11(%rbp),%edi
call   1030 <tolower@plt>
mov    %al,-0x11(%rbp)
movzbl -0x12(%rbp),%edi
call   1030 <tolower@plt>
mov    %al,-0x12(%rbp)
movzbl -0x11(%rbp),%ecx
movzbl -0x12(%rbp),%edx
xor    %eax,%eax
cmp    %edx,%ecx
mov    %al,-0x13(%rbp)
jne    1182 <strcasecmp+0x72>
movzbl -0x11(%rbp),%eax
cmp    $0x0,%eax
setne  %al
mov    %al,-0x13(%rbp)
mov    -0x13(%rbp),%al
test   $0x1,%al
jne    1120 <strcasecmp+0x10>
movzbl -0x11(%rbp),%eax
movzbl -0x12(%rbp),%ecx
sub    %ecx,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<strcasecmp>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rsi,%r14
mov    %rdi,%r15
xor    %ebp,%ebp
movzbl (%r15,%rbp,1),%edi
movzbl (%r14,%rbp,1),%r12d
call   1030 <tolower@plt>
mov    %rax,%rbx
mov    %r12d,%edi
call   1030 <tolower@plt>
movzbl %al,%eax
and    $0xff,%ebx
je     114d <strcasecmp+0x3d>
add    $0x1,%rbp
cmp    %eax,%ebx
je     1120 <strcasecmp+0x10>
sub    %eax,%ebx
mov    %ebx,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

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

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