#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 tolower(unsigned char const);
int strcicmp(const char *s1, const char *s2) {
  const unsigned char *us1 = (const unsigned char *)s1,
                      *us2 = (const unsigned char *)s2;
  while (tolower(*us1) == tolower(*us2)) {
    if (*us1++ == '\0')
      return 0;
    us2++;
  }
  return tolower(*us1) - tolower(*us2);
}


x86 assembly (clang, -O0):
<strcicmp>:
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
movzbl (%rax),%edi
call   1030 <tolower@plt>
mov    %eax,-0x2c(%rbp)
mov    -0x28(%rbp),%rax
movzbl (%rax),%edi
call   1030 <tolower@plt>
mov    %eax,%ecx
mov    -0x2c(%rbp),%eax
cmp    %ecx,%eax
jne    1190 <strcicmp+0x80>
mov    -0x20(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x20(%rbp)
movzbl (%rax),%eax
cmp    $0x0,%eax
jne    117f <strcicmp+0x6f>
movl   $0x0,-0x4(%rbp)
jmp    11b5 <strcicmp+0xa5>
mov    -0x28(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
jmp    1130 <strcicmp+0x20>
mov    -0x20(%rbp),%rax
movzbl (%rax),%edi
call   1030 <tolower@plt>
mov    %eax,-0x30(%rbp)
mov    -0x28(%rbp),%rax
movzbl (%rax),%edi
call   1030 <tolower@plt>
mov    %eax,%ecx
mov    -0x30(%rbp),%eax
sub    %ecx,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<strcicmp>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
movzbl (%rdi),%edi
call   1030 <tolower@plt>
mov    %eax,%ebp
movzbl (%r14),%edi
call   1030 <tolower@plt>
cmp    %eax,%ebp
jne    116d <strcicmp+0x5d>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
cmpb   $0x0,(%rbx)
je     1187 <strcicmp+0x77>
lea    0x1(%r14),%rbp
movzbl 0x1(%rbx),%edi
add    $0x1,%rbx
call   1030 <tolower@plt>
mov    %eax,%r15d
movzbl 0x1(%r14),%edi
call   1030 <tolower@plt>
mov    %rbp,%r14
cmp    %eax,%r15d
je     1140 <strcicmp+0x30>
jmp    1170 <strcicmp+0x60>
mov    %r14,%rbp
movzbl (%rbx),%edi
call   1030 <tolower@plt>
mov    %eax,%ebx
movzbl 0x0(%rbp),%edi
call   1030 <tolower@plt>
sub    %eax,%ebx
jmp    1189 <strcicmp+0x79>
xor    %ebx,%ebx
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

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