#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(char);
int lcl_strcasecmp(char *s1, char *s2) {
  int c1;
  int c2;
  for (;; s1++, s2++) {
    c1 = toupper(*s1);
    c2 = toupper(*s2);
    if (c1 < c2)
      return -1;
    if (c1 > c2)
      return 1;
    if (c1 == 0)
      return 0;
  }
}


x86 assembly (clang, -O0):
<lcl_strcasecmp>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%edi
call   1030 <toupper@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%rax
movsbl (%rax),%edi
call   1030 <toupper@plt>
mov    %eax,-0x20(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x20(%rbp),%eax
jge    1156 <lcl_strcasecmp+0x46>
movl   $0xffffffff,-0x4(%rbp)
jmp    11a6 <lcl_strcasecmp+0x96>
mov    -0x1c(%rbp),%eax
cmp    -0x20(%rbp),%eax
jle    116e <lcl_strcasecmp+0x5e>
movl   $0x1,-0x4(%rbp)
jmp    11a6 <lcl_strcasecmp+0x96>
cmpl   $0x0,-0x1c(%rbp)
jne    1184 <lcl_strcasecmp+0x74>
movl   $0x0,-0x4(%rbp)
jmp    11a6 <lcl_strcasecmp+0x96>
jmp    1189 <lcl_strcasecmp+0x79>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    1120 <lcl_strcasecmp+0x10>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<lcl_strcasecmp>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rsi,%r14
mov    %rdi,%r12
movsbl (%rdi),%edi
call   1030 <toupper@plt>
mov    %eax,%ebp
movsbl (%r14),%edi
call   1030 <toupper@plt>
mov    $0xffffffff,%r15d
cmp    %eax,%ebp
jl     1173 <lcl_strcasecmp+0x63>
mov    $0x1,%ebx
cmp    %eax,%ebp
jg     1168 <lcl_strcasecmp+0x58>
test   %ebp,%ebp
je     1170 <lcl_strcasecmp+0x60>
movsbl (%r12,%rbx,1),%edi
call   1030 <toupper@plt>
mov    %eax,%ebp
movsbl (%r14,%rbx,1),%edi
call   1030 <toupper@plt>
add    $0x1,%rbx
cmp    %eax,%ebp
jge    1140 <lcl_strcasecmp+0x30>
jmp    1173 <lcl_strcasecmp+0x63>
mov    $0x1,%r15d
jmp    1173 <lcl_strcasecmp+0x63>
xor    %r15d,%r15d
mov    %r15d,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

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

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