#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(unsigned char);
int stricmp(const char *s1, const char *s2) {
  unsigned char c1, c2;
  do {
    c1 = (unsigned char)*s1;
    c2 = (unsigned char)*s2;
    c1 = (unsigned char)tolower(c1);
    c2 = (unsigned char)tolower(c2);
    s1++;
    s2++;
  } while ((c1 == c2) && (c1 != '\0'));
  return (int)c1 - c2;
}


x86 assembly (clang, -O0):
<stricmp>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%al
mov    %al,-0x11(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%al
mov    %al,-0x12(%rbp)
movzbl -0x11(%rbp),%edi
call   1030 <tolower@plt>
mov    %al,-0x11(%rbp)
movzbl -0x12(%rbp),%edi
call   1030 <tolower@plt>
mov    %al,-0x12(%rbp)
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
movzbl -0x11(%rbp),%ecx
movzbl -0x12(%rbp),%edx
xor    %eax,%eax
cmp    %edx,%ecx
mov    %al,-0x13(%rbp)
jne    1184 <stricmp+0x74>
movzbl -0x11(%rbp),%eax
cmp    $0x0,%eax
setne  %al
mov    %al,-0x13(%rbp)
mov    -0x13(%rbp),%al
test   $0x1,%al
jne    1120 <stricmp+0x10>
movzbl -0x11(%rbp),%eax
movzbl -0x12(%rbp),%ecx
sub    %ecx,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<stricmp>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rsi,%r14
mov    %rdi,%r15
xor    %ebp,%ebp
movzbl (%r15,%rbp,1),%edi
movzbl (%r14,%rbp,1),%r12d
call   1030 <tolower@plt>
mov    %rax,%rbx
mov    %r12d,%edi
call   1030 <tolower@plt>
movzbl %al,%eax
and    $0xff,%ebx
je     114d <stricmp+0x3d>
add    $0x1,%rbp
cmp    %eax,%ebx
je     1120 <stricmp+0x10>
sub    %eax,%ebx
mov    %ebx,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

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

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