#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 arg_stricmp(const char *lhs, const char *rhs) {
  while (*lhs != '\0') {
    if (*rhs == '\0') {
      return 1;
    }
    if (tolower((unsigned char)(*lhs)) > tolower((unsigned char)(*rhs))) {
      return 1;
    }
    if (tolower((unsigned char)(*rhs)) > tolower((unsigned char)(*lhs))) {
      return -1;
    }
    ++lhs;
    ++rhs;
  }
  if (*rhs != '\0') {
    return -1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<arg_stricmp>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     11d9 <arg_stricmp+0xc9>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
jne    114c <arg_stricmp+0x3c>
movl   $0x1,-0x4(%rbp)
jmp    11fc <arg_stricmp+0xec>
mov    -0x10(%rbp),%rax
movzbl (%rax),%edi
call   1030 <tolower@plt>
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rax
movzbl (%rax),%edi
call   1030 <tolower@plt>
mov    %rax,%rcx
mov    -0x20(%rbp),%rax
cmp    %rcx,%rax
jle    1184 <arg_stricmp+0x74>
movl   $0x1,-0x4(%rbp)
jmp    11fc <arg_stricmp+0xec>
mov    -0x18(%rbp),%rax
movzbl (%rax),%edi
call   1030 <tolower@plt>
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rax
movzbl (%rax),%edi
call   1030 <tolower@plt>
mov    %rax,%rcx
mov    -0x28(%rbp),%rax
cmp    %rcx,%rax
jle    11bc <arg_stricmp+0xac>
movl   $0xffffffff,-0x4(%rbp)
jmp    11fc <arg_stricmp+0xec>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    1120 <arg_stricmp+0x10>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     11f5 <arg_stricmp+0xe5>
movl   $0xffffffff,-0x4(%rbp)
jmp    11fc <arg_stricmp+0xec>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<arg_stricmp>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    (%rdi),%al
test   %al,%al
je     1178 <arg_stricmp+0x68>
mov    %rdi,%rbx
add    $0x1,%rbx
mov    $0x1,%r15d
nopl   (%rax)
cmpb   $0x0,(%r14)
je     1188 <arg_stricmp+0x78>
movzbl %al,%edi
call   1030 <tolower@plt>
mov    %rax,%rbp
movzbl (%r14),%edi
call   1030 <tolower@plt>
cmp    %rax,%rbp
jg     1188 <arg_stricmp+0x78>
movzbl (%r14),%edi
call   1030 <tolower@plt>
mov    %rax,%rbp
movzbl -0x1(%rbx),%edi
call   1030 <tolower@plt>
cmp    %rax,%rbp
jg     1182 <arg_stricmp+0x72>
add    $0x1,%r14
movzbl (%rbx),%eax
add    $0x1,%rbx
test   %al,%al
jne    1130 <arg_stricmp+0x20>
xor    %eax,%eax
cmp    (%r14),%al
sbb    %r15d,%r15d
jmp    1188 <arg_stricmp+0x78>
mov    $0xffffffff,%r15d
mov    %r15d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

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