#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 gfarm_hash_key_equal_casefold(const void *key1, int key1len,
                                  const void *key2, int key2len) {
  int i;
  if (key1len != key2len)
    return (0);
  for (i = 0; i < key1len; i++) {
    if (tolower(((unsigned char *)key1)[i]) !=
        tolower(((unsigned char *)key2)[i]))
      return (0);
  }
  return (1);
}


x86 assembly (clang, -O0):
<gfarm_hash_key_equal_casefold>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %ecx,-0x24(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x24(%rbp),%eax
je     113e <gfarm_hash_key_equal_casefold+0x2e>
movl   $0x0,-0x4(%rbp)
jmp    11ad <gfarm_hash_key_equal_casefold+0x9d>
movl   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    11a6 <gfarm_hash_key_equal_casefold+0x96>
mov    -0x10(%rbp),%rax
movslq -0x28(%rbp),%rcx
movzbl (%rax,%rcx,1),%edi
call   1030 <tolower@plt>
mov    %rax,-0x30(%rbp)
mov    -0x20(%rbp),%rax
movslq -0x28(%rbp),%rcx
movzbl (%rax,%rcx,1),%edi
call   1030 <tolower@plt>
mov    %rax,%rcx
mov    -0x30(%rbp),%rax
cmp    %rcx,%rax
je     1193 <gfarm_hash_key_equal_casefold+0x83>
movl   $0x0,-0x4(%rbp)
jmp    11ad <gfarm_hash_key_equal_casefold+0x9d>
jmp    1198 <gfarm_hash_key_equal_casefold+0x88>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    1145 <gfarm_hash_key_equal_casefold+0x35>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<gfarm_hash_key_equal_casefold>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
xor    %r14d,%r14d
cmp    %ecx,%esi
jne    116a <gfarm_hash_key_equal_casefold+0x5a>
mov    $0x1,%r14d
test   %esi,%esi
jle    116a <gfarm_hash_key_equal_casefold+0x5a>
mov    %rdx,%r15
mov    %rdi,%r12
mov    %esi,%r13d
xor    %ebp,%ebp
nopw   0x0(%rax,%rax,1)
movzbl (%r12,%rbp,1),%edi
call   1030 <tolower@plt>
mov    %rax,%rbx
movzbl (%r15,%rbp,1),%edi
call   1030 <tolower@plt>
cmp    %rax,%rbx
jne    1167 <gfarm_hash_key_equal_casefold+0x57>
add    $0x1,%rbp
cmp    %rbp,%r13
jne    1140 <gfarm_hash_key_equal_casefold+0x30>
jmp    116a <gfarm_hash_key_equal_casefold+0x5a>
xor    %r14d,%r14d
mov    %r14d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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