#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 /*<<< orphan*/ brain_free_(char *);
char *brain_strdup(void *);
long hashmap_hash_cstring(void *, char *);
long strlen(char *);
char tolower(char);
long hashmap_utf8_hash_(void *in_context, void *in_key) {
  char *buffer = brain_strdup(in_key);
  long length = strlen(buffer);
  for (long i = 0; i < length; i++)
    buffer[i] = tolower(buffer[i]);
  long hash = hashmap_hash_cstring(in_context, buffer);
  brain_free_(buffer);
  return hash;
}


x86 assembly (clang, -O0):
<hashmap_utf8_hash_>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <brain_strdup@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
call   1050 <strlen@plt>
mov    %rax,-0x20(%rbp)
movq   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%rax
cmp    -0x20(%rbp),%rax
jge    11bf <hashmap_utf8_hash_+0x6f>
mov    -0x18(%rbp),%rax
mov    -0x28(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1060 <tolower@plt>
mov    %al,%dl
mov    -0x18(%rbp),%rax
mov    -0x28(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x28(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
jmp    1182 <hashmap_utf8_hash_+0x32>
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1040 <hashmap_hash_cstring@plt>
mov    %rax,-0x30(%rbp)
mov    -0x18(%rbp),%rdi
call   1070 <brain_free_@plt>
mov    -0x30(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<hashmap_utf8_hash_>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rdi,%r14
mov    %rsi,%rdi
call   1030 <brain_strdup@plt>
mov    %rax,%r12
mov    %rax,%rdi
call   1050 <strlen@plt>
test   %rax,%rax
jle    1197 <hashmap_utf8_hash_+0x47>
mov    %rax,%r15
xor    %ebx,%ebx
nopl   0x0(%rax,%rax,1)
movsbl (%r12,%rbx,1),%edi
call   1060 <tolower@plt>
mov    %al,(%r12,%rbx,1)
add    $0x1,%rbx
cmp    %rbx,%r15
jne    1180 <hashmap_utf8_hash_+0x30>
mov    %r14,%rdi
mov    %r12,%rsi
call   1040 <hashmap_hash_cstring@plt>
mov    %rax,%r14
mov    %r12,%rdi
call   1070 <brain_free_@plt>
mov    %r14,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
define i64 @hashmap_utf8_hash_(i8* %0, i8* %1) {
%3 = tail call i8* @brain_strdup(i8* %1)
%4 = tail call i64 @strlen(i8* dereferenceable(1) %3)
%5 = icmp sgt i64 %4, 0
br i1 %5, label %9, label %6
6: ; preds = %9, %2
%7 = tail call i64 @hashmap_hash_cstring(i8* %0, i8* %3)
%8 = tail call i32 @brain_free_(i8* %3)
ret i64 %7
9: ; preds = %2, %9
%10 = phi i64 [ %14, %9 ], [ 0, %2 ]
%11 = getelementptr inbounds i8, i8* %3, i64 %10
%12 = load i8, i8* %11
%13 = tail call signext i8 @tolower(i8 signext %12)
store i8 %13, i8* %11
%14 = add nuw nsw i64 %10, 1
%15 = icmp eq i64 %14, %4
br i1 %15, label %6, label %9
}