#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(unsigned char);
int strcasecmp(const char *s1, const char *s2) {
  const unsigned char *c1 = (const unsigned char *)s1;
  const unsigned char *c2 = (const unsigned char *)s2;
  unsigned char ch;
  int d = 0;
  while (1) {
    d = toupper(ch = *c1++) - toupper(*c2++);
    if (d || !ch)
      break;
  }
  return d;
}


x86 assembly (clang, -O0):
<strcasecmp>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
movl   $0x0,-0x28(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x18(%rbp)
mov    (%rax),%al
mov    %al,-0x21(%rbp)
movzbl %al,%edi
call   1030 <toupper@plt>
mov    %eax,-0x2c(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x20(%rbp)
movzbl (%rax),%edi
call   1030 <toupper@plt>
mov    %eax,%ecx
mov    -0x2c(%rbp),%eax
sub    %ecx,%eax
mov    %eax,-0x28(%rbp)
cmpl   $0x0,-0x28(%rbp)
jne    118b <strcasecmp+0x7b>
cmpb   $0x0,-0x21(%rbp)
jne    1190 <strcasecmp+0x80>
jmp    1195 <strcasecmp+0x85>
jmp    1137 <strcasecmp+0x27>
mov    -0x28(%rbp),%eax
add    $0x30,%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    %ebx,%ebx
movzbl (%r15,%rbx,1),%r12d
mov    %r12d,%edi
call   1030 <toupper@plt>
mov    %eax,%ebp
movzbl (%r14,%rbx,1),%edi
call   1030 <toupper@plt>
sub    %eax,%ebp
test   %r12d,%r12d
je     1148 <strcasecmp+0x38>
add    $0x1,%rbx
test   %ebp,%ebp
je     1120 <strcasecmp+0x10>
mov    %ebp,%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*
%7 = alloca i8
%8 = alloca i32
store i8* %0, i8** %3
store i8* %1, i8** %4
%9 = load i8*, i8** %3
store i8* %9, i8** %5
%10 = load i8*, i8** %4
store i8* %10, i8** %6
store i32 0, i32* %8
br label %11
11: ; preds = %2, %27
%12 = load i8*, i8** %5
%13 = getelementptr inbounds i8, i8* %12, i32 1
store i8* %13, i8** %5
%14 = load i8, i8* %12
store i8 %14, i8* %7
%15 = call i32 @toupper(i8 zeroext %14)
%16 = load i8*, i8** %6
%17 = getelementptr inbounds i8, i8* %16, i32 1
store i8* %17, i8** %6
%18 = load i8, i8* %16
%19 = call i32 @toupper(i8 zeroext %18)
%20 = sub nsw i32 %15, %19
store i32 %20, i32* %8
%21 = load i32, i32* %8
%22 = icmp ne i32 %21, 0
br i1 %22, label %26, label %23
23: ; preds = %11
%24 = load i8, i8* %7
%25 = icmp ne i8 %24, 0
br i1 %25, label %27, label %26
26: ; preds = %23, %11
br label %28
27: ; preds = %23
br label %11
28: ; preds = %26
%29 = load i32, i32* %8
ret i32 %29
}

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