#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 */
typedef int uint64_t;

/* Variables and functions */
int /*<<< orphan*/ strncpy(char *, char *, int);
uint64_t database_hash(char *input) {
  uint64_t hash = 0;
  char temp[8];
  int i;
  strncpy(temp, input, 8);
  for (i = 0; i < 8; i++) {
    if ((temp[i] >= 'a') && (temp[i] <= 'z')) {
      temp[i] -= ('a' - 'A');
    }
  }
  for (i = 0; i < 8; i++) {
    hash += ((uint64_t)temp[i] << (8 * (7 - i)));
  }
  return hash;
}


x86 assembly (clang, -O0):
<database_hash>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
lea    -0x14(%rbp),%rdi
mov    -0x8(%rbp),%rsi
mov    $0x8,%edx
call   1030 <strncpy@plt>
movl   $0x0,-0x18(%rbp)
cmpl   $0x8,-0x18(%rbp)
jge    118d <database_hash+0x7d>
movslq -0x18(%rbp),%rax
movsbl -0x14(%rbp,%rax,1),%eax
cmp    $0x61,%eax
jl     117a <database_hash+0x6a>
movslq -0x18(%rbp),%rax
movsbl -0x14(%rbp,%rax,1),%eax
cmp    $0x7a,%eax
jg     117a <database_hash+0x6a>
movslq -0x18(%rbp),%rax
movsbl -0x14(%rbp,%rax,1),%ecx
sub    $0x20,%ecx
mov    %cl,-0x14(%rbp,%rax,1)
jmp    117f <database_hash+0x6f>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    113c <database_hash+0x2c>
movl   $0x0,-0x18(%rbp)
cmpl   $0x8,-0x18(%rbp)
jge    11c8 <database_hash+0xb8>
movslq -0x18(%rbp),%rax
movsbl -0x14(%rbp,%rax,1),%eax
mov    $0x7,%ecx
sub    -0x18(%rbp),%ecx
shl    $0x3,%ecx
shl    %cl,%eax
add    -0xc(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1194 <database_hash+0x84>
mov    -0xc(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<database_hash>:
push   %rax
mov    %rdi,%rsi
mov    %rsp,%rdi
mov    $0x8,%edx
call   1030 <strncpy@plt>
pop    %rcx
ret

LLVM IR (-O0):
define i32 @database_hash(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca [8 x i8]
%5 = alloca i32
store i8* %0, i8** %2
store i32 0, i32* %3
%6 = getelementptr inbounds [8 x i8], [8 x i8]* %4, i64 0, i64 0
%7 = load i8*, i8** %2
%8 = call i32 @strncpy(i8* %6, i8* %7, i32 8)
store i32 0, i32* %5
br label %9
9: ; preds = %35, %1
%10 = load i32, i32* %5
%11 = icmp slt i32 %10, 8
br i1 %11, label %12, label %38
12: ; preds = %9
%13 = load i32, i32* %5
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds [8 x i8], [8 x i8]* %4, i64 0, i64 %14
%16 = load i8, i8* %15
%17 = sext i8 %16 to i32
%18 = icmp sge i32 %17, 97
br i1 %18, label %19, label %34
19: ; preds = %12
%20 = load i32, i32* %5
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds [8 x i8], [8 x i8]* %4, i64 0, i64 %21
%23 = load i8, i8* %22
%24 = sext i8 %23 to i32
%25 = icmp sle i32 %24, 122
br i1 %25, label %26, label %34
26: ; preds = %19
%27 = load i32, i32* %5
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds [8 x i8], [8 x i8]* %4, i64 0, i64 %28
%30 = load i8, i8* %29
%31 = sext i8 %30 to i32
%32 = sub nsw i32 %31, 32
%33 = trunc i32 %32 to i8
store i8 %33, i8* %29
br label %34
34: ; preds = %26, %19, %12
br label %35
35: ; preds = %34
%36 = load i32, i32* %5
%37 = add nsw i32 %36, 1
store i32 %37, i32* %5
br label %9
38: ; preds = %9
store i32 0, i32* %5
br label %39
39: ; preds = %54, %38
%40 = load i32, i32* %5
%41 = icmp slt i32 %40, 8
br i1 %41, label %42, label %57
42: ; preds = %39
%43 = load i32, i32* %5
%44 = sext i32 %43 to i64
%45 = getelementptr inbounds [8 x i8], [8 x i8]* %4, i64 0, i64 %44
%46 = load i8, i8* %45
%47 = sext i8 %46 to i32
%48 = load i32, i32* %5
%49 = sub nsw i32 7, %48
%50 = mul nsw i32 8, %49
%51 = shl i32 %47, %50
%52 = load i32, i32* %3
%53 = add nsw i32 %52, %51
store i32 %53, i32* %3
br label %54
54: ; preds = %42
%55 = load i32, i32* %5
%56 = add nsw i32 %55, 1
store i32 %56, i32* %5
br label %39
57: ; preds = %39
%58 = load i32, i32* %3
ret i32 %58
}

LLVM IR (-O2):
define i32 @database_hash(i8* %0) {
%2 = alloca [8 x i8]
%3 = getelementptr inbounds [8 x i8], [8 x i8]* %2, i64 0, i64 0
%4 = call i32 @strncpy(i8* %3, i8* %0, i32 8)
ret i32 poison
}