#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(int /*<<< orphan*/);
int strcasecmp(const char *str1, const char *str2) {
  int c1;
  int c2;
  do {
    c1 = toupper(*(str1++));
    c2 = toupper(*(str2++));
  } while ((c1 != '\0') && (c1 == c2));
  return (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)
movsbl (%rax),%edi
call   1030 <toupper@plt>
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x10(%rbp)
movsbl (%rax),%edi
call   1030 <toupper@plt>
mov    %eax,-0x18(%rbp)
xor    %eax,%eax
cmpl   $0x0,-0x14(%rbp)
mov    %al,-0x19(%rbp)
je     116f <strcasecmp+0x5f>
mov    -0x14(%rbp),%eax
cmp    -0x18(%rbp),%eax
sete   %al
mov    %al,-0x19(%rbp)
mov    -0x19(%rbp),%al
test   $0x1,%al
jne    1120 <strcasecmp+0x10>
mov    -0x14(%rbp),%eax
sub    -0x18(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<strcasecmp>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%r15
xor    %ebx,%ebx
nop
movsbl (%r15,%rbx,1),%edi
call   1030 <toupper@plt>
mov    %eax,%ebp
movsbl (%r14,%rbx,1),%edi
call   1030 <toupper@plt>
test   %ebp,%ebp
je     1142 <strcasecmp+0x32>
add    $0x1,%rbx
cmp    %eax,%ebp
je     1120 <strcasecmp+0x10>
sub    %eax,%ebp
mov    %ebp,%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*
%5 = alloca i32
%6 = alloca i32
store i8* %0, i8** %3
store i8* %1, i8** %4
br label %7
7: ; preds = %25, %2
%8 = load i8*, i8** %3
%9 = getelementptr inbounds i8, i8* %8, i32 1
store i8* %9, i8** %3
%10 = load i8, i8* %8
%11 = sext i8 %10 to i32
%12 = call i32 @toupper(i32 %11)
store i32 %12, i32* %5
%13 = load i8*, i8** %4
%14 = getelementptr inbounds i8, i8* %13, i32 1
store i8* %14, i8** %4
%15 = load i8, i8* %13
%16 = sext i8 %15 to i32
%17 = call i32 @toupper(i32 %16)
store i32 %17, i32* %6
br label %18
18: ; preds = %7
%19 = load i32, i32* %5
%20 = icmp ne i32 %19, 0
br i1 %20, label %21, label %25
21: ; preds = %18
%22 = load i32, i32* %5
%23 = load i32, i32* %6
%24 = icmp eq i32 %22, %23
br label %25
25: ; preds = %21, %18
%26 = phi i1 [ false, %18 ], [ %24, %21 ]
br i1 %26, label %7, label %27
27: ; preds = %25
%28 = load i32, i32* %5
%29 = load i32, i32* %6
%30 = sub nsw i32 %28, %29
ret i32 %30
}

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