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


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),%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x11(%rbp)
je     1161 <strcasecmp+0x51>
mov    -0x8(%rbp),%rax
movsbl (%rax),%edi
call   1030 <toupper@plt>
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%edi
call   1030 <toupper@plt>
mov    %rax,%rcx
mov    -0x20(%rbp),%rax
cmp    %rcx,%rax
sete   %al
mov    %al,-0x11(%rbp)
mov    -0x11(%rbp),%al
test   $0x1,%al
jne    1171 <strcasecmp+0x61>
jmp    118e <strcasecmp+0x7e>
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>
mov    -0x8(%rbp),%rax
movzbl (%rax),%eax
mov    -0x10(%rbp),%rcx
movzbl (%rcx),%ecx
sub    %ecx,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<strcasecmp>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    (%rdi),%al
xor    %r14d,%r14d
test   %al,%al
je     115f <strcasecmp+0x4f>
mov    %rdi,%rbp
add    $0x1,%rbp
nopw   0x0(%rax,%rax,1)
movsbl %al,%edi
call   1030 <toupper@plt>
mov    %rax,%r15
movsbl (%rbx),%edi
call   1030 <toupper@plt>
cmp    %rax,%r15
jne    115a <strcasecmp+0x4a>
add    $0x1,%rbx
movzbl 0x0(%rbp),%eax
add    $0x1,%rbp
test   %al,%al
jne    1130 <strcasecmp+0x20>
jmp    115f <strcasecmp+0x4f>
movzbl -0x1(%rbp),%r14d
movzbl (%rbx),%eax
sub    %eax,%r14d
mov    %r14d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

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