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


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,%rcx
add    $0x1,%rcx
mov    %rcx,-0x8(%rbp)
movsbl (%rax),%eax
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x10(%rbp)
movsbl (%rax),%eax
mov    %eax,-0x18(%rbp)
xor    %eax,%eax
cmpl   $0x0,-0x14(%rbp)
mov    %al,-0x19(%rbp)
je     117d <strcasecmp+0x6d>
mov    -0x14(%rbp),%edi
call   1030 <toupper@plt>
mov    %rax,-0x28(%rbp)
mov    -0x18(%rbp),%edi
call   1030 <toupper@plt>
mov    %rax,%rcx
mov    -0x28(%rbp),%rax
cmp    %rcx,%rax
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    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<strcasecmp>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r15
mov    %rdi,%r12
xor    %r14d,%r14d
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movsbl (%r12,%r14,1),%ebx
movsbl (%r15,%r14,1),%ebp
test   %ebx,%ebx
je     115c <strcasecmp+0x4c>
mov    %ebx,%edi
call   1030 <toupper@plt>
mov    %rax,%r13
mov    %ebp,%edi
call   1030 <toupper@plt>
add    $0x1,%r14
cmp    %rax,%r13
je     1130 <strcasecmp+0x20>
mov    %ebx,%eax
jmp    115e <strcasecmp+0x4e>
xor    %eax,%eax
sub    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@c1 = global i32 0
@c2 = global i32 0
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
store i32 %11, i32* %5
%12 = load i8*, i8** %4
%13 = getelementptr inbounds i8, i8* %12, i32 1
store i8* %13, i8** %4
%14 = load i8, i8* %12
%15 = sext i8 %14 to i32
store i32 %15, i32* %6
br label %16
16: ; preds = %7
%17 = load i32, i32* %5
%18 = icmp ne i32 %17, 0
br i1 %18, label %19, label %25
19: ; preds = %16
%20 = load i32, i32* %5
%21 = call i64 @toupper(i32 %20)
%22 = load i32, i32* %6
%23 = call i64 @toupper(i32 %22)
%24 = icmp eq i64 %21, %23
br label %25
25: ; preds = %19, %16
%26 = phi i1 [ false, %16 ], [ %24, %19 ]
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):
@c1 = global i32 0
@c2 = global i32 0
define i32 @strcasecmp(i8* nocapture %0, i8* nocapture %1) {
br label %3
3: ; preds = %9, %2
%4 = phi i8* [ %1, %2 ], [ %12, %9 ]
%5 = phi i8* [ %0, %2 ], [ %13, %9 ]
%6 = load i8, i8* %5
%7 = load i8, i8* %4
%8 = icmp eq i8 %6, 0
br i1 %8, label %19, label %9
9: ; preds = %3
%10 = sext i8 %7 to i32
%11 = sext i8 %6 to i32
%12 = getelementptr inbounds i8, i8* %4, i64 1
%13 = getelementptr inbounds i8, i8* %5, i64 1
%14 = tail call i64 @toupper(i32 %11)
%15 = tail call i64 @toupper(i32 %10)
%16 = icmp eq i64 %14, %15
br i1 %16, label %3, label %17
17: ; preds = %9
%18 = sext i8 %6 to i32
br label %19
19: ; preds = %3, %17
%20 = phi i32 [ %18, %17 ], [ 0, %3 ]
%21 = sext i8 %7 to i32
%22 = sub nsw i32 %20, %21
ret i32 %22
}