#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 */
unsigned int tolower(int /*<<< orphan*/);
int strcmpic(const char *str1, const char *str2) {
  unsigned int c1, c2;
  while (*str1 != '\0' || *str2 != '\0') {
    c1 = tolower(*str1++);
    c2 = tolower(*str2++);
    if (c1 != c2)
      return ((c1 > c2) << 1) - 1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<strcmpic>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%ecx
mov    $0x1,%al
cmp    $0x0,%ecx
mov    %al,-0x21(%rbp)
jne    1145 <strcmpic+0x35>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
setne  %al
mov    %al,-0x21(%rbp)
mov    -0x21(%rbp),%al
test   $0x1,%al
jne    1155 <strcmpic+0x45>
jmp    11b6 <strcmpic+0xa6>
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x10(%rbp)
movsbl (%rax),%edi
call   1030 <tolower@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x18(%rbp)
movsbl (%rax),%edi
call   1030 <tolower@plt>
mov    %eax,-0x20(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x20(%rbp),%eax
je     11b1 <strcmpic+0xa1>
mov    -0x1c(%rbp),%eax
cmp    -0x20(%rbp),%eax
seta   %al
and    $0x1,%al
movzbl %al,%eax
shl    $0x1,%eax
sub    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    11bd <strcmpic+0xad>
jmp    1120 <strcmpic+0x10>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<strcmpic>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r15
mov    %rdi,%r14
xor    %ebx,%ebx
jmp    1149 <strcmpic+0x39>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
call   1030 <tolower@plt>
mov    %eax,%ebp
movsbl (%r15,%rbx,1),%edi
call   1030 <tolower@plt>
add    $0x1,%rbx
cmp    %eax,%ebp
jne    115d <strcmpic+0x4d>
movsbl (%r14,%rbx,1),%edi
test   %edi,%edi
jne    1130 <strcmpic+0x20>
cmpb   $0x0,(%r15,%rbx,1)
jne    1130 <strcmpic+0x20>
xor    %eax,%eax
jmp    1168 <strcmpic+0x58>
seta   %al
movzbl %al,%eax
add    %eax,%eax
add    $0xffffffff,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @strcmpic(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 = %41, %2
%9 = load i8*, i8** %4
%10 = load i8, i8* %9
%11 = sext i8 %10 to i32
%12 = icmp ne i32 %11, 0
br i1 %12, label %18, label %13
13: ; preds = %8
%14 = load i8*, i8** %5
%15 = load i8, i8* %14
%16 = sext i8 %15 to i32
%17 = icmp ne i32 %16, 0
br label %18
18: ; preds = %13, %8
%19 = phi i1 [ true, %8 ], [ %17, %13 ]
br i1 %19, label %20, label %42
20: ; preds = %18
%21 = load i8*, i8** %4
%22 = getelementptr inbounds i8, i8* %21, i32 1
store i8* %22, i8** %4
%23 = load i8, i8* %21
%24 = sext i8 %23 to i32
%25 = call i32 @tolower(i32 %24)
store i32 %25, i32* %6
%26 = load i8*, i8** %5
%27 = getelementptr inbounds i8, i8* %26, i32 1
store i8* %27, i8** %5
%28 = load i8, i8* %26
%29 = sext i8 %28 to i32
%30 = call i32 @tolower(i32 %29)
store i32 %30, i32* %7
%31 = load i32, i32* %6
%32 = load i32, i32* %7
%33 = icmp ne i32 %31, %32
br i1 %33, label %34, label %41
34: ; preds = %20
%35 = load i32, i32* %6
%36 = load i32, i32* %7
%37 = icmp ugt i32 %35, %36
%38 = zext i1 %37 to i32
%39 = shl i32 %38, 1
%40 = sub nsw i32 %39, 1
store i32 %40, i32* %3
br label %43
41: ; preds = %20
br label %8
42: ; preds = %18
store i32 0, i32* %3
br label %43
43: ; preds = %42, %34
%44 = load i32, i32* %3
ret i32 %44
}

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