#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 toupper(char const);
int strcasecmp(const char *s1, const char *s2) {
  while ((*s1) && (*s2) && (toupper(*s1) == toupper(*s2))) {
    s1++;
    s2++;
  }
  return toupper(*s1) - toupper(*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     1172 <strcasecmp+0x62>
mov    -0x10(%rbp),%rax
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x11(%rbp)
je     1172 <strcasecmp+0x62>
mov    -0x8(%rbp),%rax
movsbl (%rax),%edi
call   1030 <toupper@plt>
mov    %eax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%edi
call   1030 <toupper@plt>
mov    %eax,%ecx
mov    -0x18(%rbp),%eax
cmp    %ecx,%eax
sete   %al
mov    %al,-0x11(%rbp)
mov    -0x11(%rbp),%al
test   $0x1,%al
jne    1182 <strcasecmp+0x72>
jmp    119f <strcasecmp+0x8f>
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
movsbl (%rax),%edi
call   1030 <toupper@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%edi
call   1030 <toupper@plt>
mov    %eax,%ecx
mov    -0x1c(%rbp),%eax
sub    %ecx,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<strcasecmp>:
push   %rbp
push   %r14
push   %rbx
mov    %rsi,%r14
mov    (%rdi),%al
test   %al,%al
je     115c <strcasecmp+0x4c>
mov    %rdi,%rbx
add    $0x1,%rbx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
cmpb   $0x0,(%r14)
je     1163 <strcasecmp+0x53>
movsbl %al,%edi
call   1030 <toupper@plt>
mov    %eax,%ebp
movsbl (%r14),%edi
call   1030 <toupper@plt>
cmp    %eax,%ebp
jne    1160 <strcasecmp+0x50>
add    $0x1,%r14
movzbl (%rbx),%eax
add    $0x1,%rbx
test   %al,%al
jne    1130 <strcasecmp+0x20>
xor    %eax,%eax
jmp    1163 <strcasecmp+0x53>
mov    -0x1(%rbx),%al
movsbl %al,%edi
call   1030 <toupper@plt>
mov    %eax,%ebx
movsbl (%r14),%edi
call   1030 <toupper@plt>
sub    %eax,%ebx
mov    %ebx,%eax
pop    %rbx
pop    %r14
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 = %25, %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 %23
10: ; preds = %5
%11 = load i8*, i8** %4
%12 = load i8, i8* %11
%13 = sext i8 %12 to i32
%14 = icmp ne i32 %13, 0
br i1 %14, label %15, label %23
15: ; preds = %10
%16 = load i8*, i8** %3
%17 = load i8, i8* %16
%18 = call i32 @toupper(i8 signext %17)
%19 = load i8*, i8** %4
%20 = load i8, i8* %19
%21 = call i32 @toupper(i8 signext %20)
%22 = icmp eq i32 %18, %21
br label %23
23: ; preds = %15, %10, %5
%24 = phi i1 [ false, %10 ], [ false, %5 ], [ %22, %15 ]
br i1 %24, label %25, label %30
25: ; preds = %23
%26 = load i8*, i8** %3
%27 = getelementptr inbounds i8, i8* %26, i32 1
store i8* %27, i8** %3
%28 = load i8*, i8** %4
%29 = getelementptr inbounds i8, i8* %28, i32 1
store i8* %29, i8** %4
br label %5
30: ; preds = %23
%31 = load i8*, i8** %3
%32 = load i8, i8* %31
%33 = call i32 @toupper(i8 signext %32)
%34 = load i8*, i8** %4
%35 = load i8, i8* %34
%36 = call i32 @toupper(i8 signext %35)
%37 = sub nsw i32 %33, %36
ret i32 %37
}

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 %23, label %5
5: ; preds = %2, %18
%6 = phi i8 [ %21, %18 ], [ %3, %2 ]
%7 = phi i8* [ %20, %18 ], [ %1, %2 ]
%8 = phi i8* [ %19, %18 ], [ %0, %2 ]
%9 = load i8, i8* %7
%10 = icmp eq i8 %9, 0
br i1 %10, label %23, label %11
11: ; preds = %5
%12 = tail call i32 @toupper(i8 signext %6)
%13 = load i8, i8* %7
%14 = tail call i32 @toupper(i8 signext %13)
%15 = icmp eq i32 %12, %14
br i1 %15, label %18, label %16
16: ; preds = %11
%17 = load i8, i8* %8
br label %23
18: ; preds = %11
%19 = getelementptr inbounds i8, i8* %8, i64 1
%20 = getelementptr inbounds i8, i8* %7, i64 1
%21 = load i8, i8* %19
%22 = icmp eq i8 %21, 0
br i1 %22, label %23, label %5
23: ; preds = %5, %18, %16, %2
%24 = phi i8 [ 0, %2 ], [ %17, %16 ], [ %6, %5 ], [ 0, %18 ]
%25 = phi i8* [ %1, %2 ], [ %7, %16 ], [ %7, %5 ], [ %20, %18 ]
%26 = tail call i32 @toupper(i8 signext %24)
%27 = load i8, i8* %25
%28 = tail call i32 @toupper(i8 signext %27)
%29 = sub nsw i32 %26, %28
ret i32 %29
}