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


x86 assembly (clang, -O0):
<stricompare>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x10(%rbp)
movsbl (%rax),%edi
call   1030 <tolower@plt>
mov    %al,-0x19(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x18(%rbp)
movsbl (%rax),%edi
call   1030 <tolower@plt>
mov    %al,-0x1a(%rbp)
movsbl -0x19(%rbp),%eax
movsbl -0x1a(%rbp),%ecx
cmp    %ecx,%eax
je     1176 <stricompare+0x66>
movsbl -0x19(%rbp),%eax
movsbl -0x1a(%rbp),%ecx
sub    %ecx,%eax
mov    %eax,-0x4(%rbp)
jmp    119e <stricompare+0x8e>
movsbl -0x19(%rbp),%eax
cmp    $0x0,%eax
jne    118f <stricompare+0x7f>
movl   $0x0,-0x4(%rbp)
jmp    119e <stricompare+0x8e>
jmp    1194 <stricompare+0x84>
jmp    1199 <stricompare+0x89>
jmp    1120 <stricompare+0x10>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<stricompare>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%r15
xor    %ebx,%ebx
nop
movsbl (%r15,%rbx,1),%edi
call   1030 <tolower@plt>
mov    %eax,%ebp
movsbl (%r14,%rbx,1),%edi
call   1030 <tolower@plt>
cmp    %al,%bpl
jne    1148 <stricompare+0x38>
add    $0x1,%rbx
test   %bpl,%bpl
jne    1120 <stricompare+0x10>
xor    %eax,%eax
jmp    1153 <stricompare+0x43>
mov    %eax,%ecx
movsbl %bpl,%eax
movsbl %cl,%ecx
sub    %ecx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

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