#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 sqchat_rfc1459_tolower(char const);
int sqchat_rfc1459_strcasecmp(const char *s1, const char *s2) {
  const char *c1 = s1;
  const char *c2 = s2;
  int result;
  if (c1 == c2)
    return 0;
  while ((result =
              sqchat_rfc1459_tolower(*c1) - sqchat_rfc1459_tolower(*c2++)) == 0)
    if (*c1++ == '\0')
      break;
  return result;
}


x86 assembly (clang, -O0):
<sqchat_rfc1459_strcasecmp>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x20(%rbp),%rax
cmp    -0x28(%rbp),%rax
jne    114a <sqchat_rfc1459_strcasecmp+0x3a>
movl   $0x0,-0x4(%rbp)
jmp    11b3 <sqchat_rfc1459_strcasecmp+0xa3>
jmp    114f <sqchat_rfc1459_strcasecmp+0x3f>
mov    -0x20(%rbp),%rax
movsbl (%rax),%edi
call   1030 <sqchat_rfc1459_tolower@plt>
mov    %eax,-0x30(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x28(%rbp)
movsbl (%rax),%edi
call   1030 <sqchat_rfc1459_tolower@plt>
mov    %eax,%ecx
mov    -0x30(%rbp),%eax
sub    %ecx,%eax
mov    %eax,-0x2c(%rbp)
cmp    $0x0,%eax
jne    11ad <sqchat_rfc1459_strcasecmp+0x9d>
mov    -0x20(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x20(%rbp)
movsbl (%rax),%eax
cmp    $0x0,%eax
jne    11a8 <sqchat_rfc1459_strcasecmp+0x98>
jmp    11ad <sqchat_rfc1459_strcasecmp+0x9d>
jmp    114f <sqchat_rfc1459_strcasecmp+0x3f>
mov    -0x2c(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sqchat_rfc1459_strcasecmp>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
cmp    %rsi,%rdi
je     1155 <sqchat_rfc1459_strcasecmp+0x45>
mov    %rsi,%r14
mov    %rdi,%r15
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movsbl (%r15,%rbx,1),%edi
call   1030 <sqchat_rfc1459_tolower@plt>
mov    %eax,%ebp
movsbl (%r14,%rbx,1),%edi
call   1030 <sqchat_rfc1459_tolower@plt>
sub    %eax,%ebp
jne    1157 <sqchat_rfc1459_strcasecmp+0x47>
cmpb   $0x0,(%r15,%rbx,1)
lea    0x1(%rbx),%rbx
jne    1130 <sqchat_rfc1459_strcasecmp+0x20>
xor    %ebp,%ebp
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

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