#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 */
scalar_t__ tolower(char const);
int strcmp_lc(const char *A, const char *B) {
  if (A == NULL)
    return -1;
  if (B == NULL)
    return 1;
  const char *a = A;
  const char *b = B;
  for (;;) {
    if (tolower(*a) < tolower(*b))
      return -1;
    if (tolower(*a) > tolower(*b))
      return 1;
    if (*a == '\0')
      return 0;
    a++;
    b++;
  }
}


x86 assembly (clang, -O0):
<strcmp_lc>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1137 <strcmp_lc+0x27>
movl   $0xffffffff,-0x4(%rbp)
jmp    1207 <strcmp_lc+0xf7>
cmpq   $0x0,-0x18(%rbp)
jne    114e <strcmp_lc+0x3e>
movl   $0x1,-0x4(%rbp)
jmp    1207 <strcmp_lc+0xf7>
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x20(%rbp),%rax
movsbl (%rax),%edi
call   1030 <tolower@plt>
mov    %rax,-0x30(%rbp)
mov    -0x28(%rbp),%rax
movsbl (%rax),%edi
call   1030 <tolower@plt>
mov    %rax,%rcx
mov    -0x30(%rbp),%rax
cmp    %rcx,%rax
jge    1196 <strcmp_lc+0x86>
movl   $0xffffffff,-0x4(%rbp)
jmp    1207 <strcmp_lc+0xf7>
mov    -0x20(%rbp),%rax
movsbl (%rax),%edi
call   1030 <tolower@plt>
mov    %rax,-0x38(%rbp)
mov    -0x28(%rbp),%rax
movsbl (%rax),%edi
call   1030 <tolower@plt>
mov    %rax,%rcx
mov    -0x38(%rbp),%rax
cmp    %rcx,%rax
jle    11ce <strcmp_lc+0xbe>
movl   $0x1,-0x4(%rbp)
jmp    1207 <strcmp_lc+0xf7>
mov    -0x20(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
jne    11ea <strcmp_lc+0xda>
movl   $0x0,-0x4(%rbp)
jmp    1207 <strcmp_lc+0xf7>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
mov    -0x28(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
jmp    115e <strcmp_lc+0x4e>
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<strcmp_lc>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    $0xffffffff,%r14d
test   %rdi,%rdi
je     119f <strcmp_lc+0x8f>
mov    %rsi,%r12
test   %rsi,%rsi
je     1199 <strcmp_lc+0x89>
mov    %rdi,%r13
movsbl (%rdi),%edi
call   1030 <tolower@plt>
mov    %rax,%r15
movsbl (%r12),%edi
call   1030 <tolower@plt>
cmp    %rax,%r15
jl     119f <strcmp_lc+0x8f>
mov    $0x1,%ebp
movsbl -0x1(%r13,%rbp,1),%edi
call   1030 <tolower@plt>
mov    %rax,%rbx
movsbl -0x1(%r12,%rbp,1),%edi
call   1030 <tolower@plt>
cmp    %rax,%rbx
jg     1199 <strcmp_lc+0x89>
cmpb   $0x0,-0x1(%r13,%rbp,1)
je     11b1 <strcmp_lc+0xa1>
movsbl 0x0(%r13,%rbp,1),%edi
call   1030 <tolower@plt>
mov    %rax,%rbx
movsbl (%r12,%rbp,1),%edi
call   1030 <tolower@plt>
add    $0x1,%rbp
cmp    %rax,%rbx
jge    1150 <strcmp_lc+0x40>
jmp    119f <strcmp_lc+0x8f>
mov    $0x1,%r14d
mov    %r14d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
xor    %r14d,%r14d
jmp    119f <strcmp_lc+0x8f>

LLVM IR (-O0):
define i32 @strcmp_lc(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
%8 = load i8*, i8** %4
%9 = icmp eq i8* %8, null
br i1 %9, label %10, label %11
10: ; preds = %2
store i32 -1, i32* %3
br label %47
11: ; preds = %2
%12 = load i8*, i8** %5
%13 = icmp eq i8* %12, null
br i1 %13, label %14, label %15
14: ; preds = %11
store i32 1, i32* %3
br label %47
15: ; preds = %11
%16 = load i8*, i8** %4
store i8* %16, i8** %6
%17 = load i8*, i8** %5
store i8* %17, i8** %7
br label %18
18: ; preds = %42, %15
%19 = load i8*, i8** %6
%20 = load i8, i8* %19
%21 = call i64 @tolower(i8 signext %20)
%22 = load i8*, i8** %7
%23 = load i8, i8* %22
%24 = call i64 @tolower(i8 signext %23)
%25 = icmp slt i64 %21, %24
br i1 %25, label %26, label %27
26: ; preds = %18
store i32 -1, i32* %3
br label %47
27: ; preds = %18
%28 = load i8*, i8** %6
%29 = load i8, i8* %28
%30 = call i64 @tolower(i8 signext %29)
%31 = load i8*, i8** %7
%32 = load i8, i8* %31
%33 = call i64 @tolower(i8 signext %32)
%34 = icmp sgt i64 %30, %33
br i1 %34, label %35, label %36
35: ; preds = %27
store i32 1, i32* %3
br label %47
36: ; preds = %27
%37 = load i8*, i8** %6
%38 = load i8, i8* %37
%39 = sext i8 %38 to i32
%40 = icmp eq i32 %39, 0
br i1 %40, label %41, label %42
41: ; preds = %36
store i32 0, i32* %3
br label %47
42: ; preds = %36
%43 = load i8*, i8** %6
%44 = getelementptr inbounds i8, i8* %43, i32 1
store i8* %44, i8** %6
%45 = load i8*, i8** %7
%46 = getelementptr inbounds i8, i8* %45, i32 1
store i8* %46, i8** %7
br label %18
47: ; preds = %41, %35, %26, %14, %10
%48 = load i32, i32* %3
ret i32 %48
}

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