#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__ hash_key_dup(void const *, size_t);
char tolower(char);
void *hash_key_dup_lower_case(const void *key, size_t key_size) {
  char *new_key = (char *)hash_key_dup(key, key_size);
  size_t i = 0;
  for (i = 0; i < key_size; i++)
    new_key[i] = tolower(new_key[i]);
  return (void *)new_key;
}


x86 assembly (clang, -O0):
<hash_key_dup_lower_case>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1030 <hash_key_dup@plt>
mov    %rax,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
movq   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%rax
cmp    -0x10(%rbp),%rax
jae    118e <hash_key_dup_lower_case+0x6e>
mov    -0x18(%rbp),%rax
mov    -0x20(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1040 <tolower@plt>
mov    %al,%dl
mov    -0x18(%rbp),%rax
mov    -0x20(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    1151 <hash_key_dup_lower_case+0x31>
mov    -0x18(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<hash_key_dup_lower_case>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%r14
call   1030 <hash_key_dup@plt>
mov    %rax,%r15
test   %r14,%r14
je     1157 <hash_key_dup_lower_case+0x37>
xor    %ebx,%ebx
nopw   0x0(%rax,%rax,1)
movsbl (%r15,%rbx,1),%edi
call   1040 <tolower@plt>
mov    %al,(%r15,%rbx,1)
add    $0x1,%rbx
cmp    %rbx,%r14
jne    1140 <hash_key_dup_lower_case+0x20>
mov    %r15,%rax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i8* @hash_key_dup_lower_case(i8* %0, i64 %1) {
%3 = alloca i8*
%4 = alloca i64
%5 = alloca i8*
%6 = alloca i64
store i8* %0, i8** %3
store i64 %1, i64* %4
%7 = load i8*, i8** %3
%8 = load i64, i64* %4
%9 = call i64 @hash_key_dup(i8* %7, i64 %8)
%10 = inttoptr i64 %9 to i8*
store i8* %10, i8** %5
store i64 0, i64* %6
store i64 0, i64* %6
br label %11
11: ; preds = %24, %2
%12 = load i64, i64* %6
%13 = load i64, i64* %4
%14 = icmp ult i64 %12, %13
br i1 %14, label %15, label %27
15: ; preds = %11
%16 = load i8*, i8** %5
%17 = load i64, i64* %6
%18 = getelementptr inbounds i8, i8* %16, i64 %17
%19 = load i8, i8* %18
%20 = call signext i8 @tolower(i8 signext %19)
%21 = load i8*, i8** %5
%22 = load i64, i64* %6
%23 = getelementptr inbounds i8, i8* %21, i64 %22
store i8 %20, i8* %23
br label %24
24: ; preds = %15
%25 = load i64, i64* %6
%26 = add i64 %25, 1
store i64 %26, i64* %6
br label %11
27: ; preds = %11
%28 = load i8*, i8** %5
ret i8* %28
}

LLVM IR (-O2):
define i8* @hash_key_dup_lower_case(i8* %0, i64 %1) {
%3 = tail call i64 @hash_key_dup(i8* %0, i64 %1)
%4 = inttoptr i64 %3 to i8*
%5 = icmp eq i64 %1, 0
br i1 %5, label %13, label %6
6: ; preds = %2, %6
%7 = phi i64 [ %11, %6 ], [ 0, %2 ]
%8 = getelementptr inbounds i8, i8* %4, i64 %7
%9 = load i8, i8* %8
%10 = tail call signext i8 @tolower(i8 signext %9)
store i8 %10, i8* %8
%11 = add nuw i64 %7, 1
%12 = icmp eq i64 %11, %1
br i1 %12, label %13, label %6
13: ; preds = %6, %2
ret i8* %4
}