#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 irc_tolower(char const);
int irc_strcasecmp(const char *s1, const char *s2) {
  int diff;
  while (*s1) {
    diff = irc_tolower(*s1) - irc_tolower(*s2);
    if (diff)
      return diff;
    s1++;
    s2++;
  }
  return *s2;
}


x86 assembly (clang, -O0):
<irc_strcasecmp>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rax
cmpb   $0x0,(%rax)
je     1184 <irc_strcasecmp+0x74>
mov    -0x10(%rbp),%rax
movsbl (%rax),%edi
call   1030 <irc_tolower@plt>
mov    %eax,-0x20(%rbp)
mov    -0x18(%rbp),%rax
movsbl (%rax),%edi
call   1030 <irc_tolower@plt>
mov    %eax,%ecx
mov    -0x20(%rbp),%eax
sub    %ecx,%eax
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
je     1167 <irc_strcasecmp+0x57>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    118e <irc_strcasecmp+0x7e>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    1120 <irc_strcasecmp+0x10>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<irc_strcasecmp>:
push   %rbp
push   %r14
push   %rbx
mov    %rsi,%r14
mov    (%rdi),%al
test   %al,%al
je     1156 <irc_strcasecmp+0x46>
mov    %rdi,%rbx
add    $0x1,%rbx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movsbl %al,%edi
call   1030 <irc_tolower@plt>
mov    %eax,%ebp
movsbl (%r14),%edi
call   1030 <irc_tolower@plt>
sub    %eax,%ebp
jne    115a <irc_strcasecmp+0x4a>
add    $0x1,%r14
movzbl (%rbx),%eax
add    $0x1,%rbx
test   %al,%al
jne    1130 <irc_strcasecmp+0x20>
movsbl (%r14),%ebp
mov    %ebp,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

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

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