#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 /*<<< orphan*/ mpz_t;

/* Variables and functions */
int /*<<< orphan*/ mpz_get_str(char *, int, int /*<<< orphan*/);
int quick_hash(mpz_t a) {
  char strrep[201 + 1];
  char *s = strrep;
  mpz_get_str(strrep, 10, a);
  int hash = 0;
  while (*s)
    hash = *s++ + (hash << 6) + (hash << 16) - hash;
  return hash;
}


x86 assembly (clang, -O0):
<quick_hash>:
push   %rbp
mov    %rsp,%rbp
sub    $0xe0,%rsp
mov    %edi,-0x4(%rbp)
lea    -0xd0(%rbp),%rax
mov    %rax,-0xd8(%rbp)
lea    -0xd0(%rbp),%rdi
mov    -0x4(%rbp),%edx
mov    $0xa,%esi
call   1030 <mpz_get_str@plt>
movl   $0x0,-0xdc(%rbp)
mov    -0xd8(%rbp),%rax
cmpb   $0x0,(%rax)
je     1199 <quick_hash+0x89>
mov    -0xd8(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0xd8(%rbp)
movsbl (%rax),%eax
mov    -0xdc(%rbp),%ecx
shl    $0x6,%ecx
add    %ecx,%eax
mov    -0xdc(%rbp),%ecx
shl    $0x10,%ecx
add    %ecx,%eax
sub    -0xdc(%rbp),%eax
mov    %eax,-0xdc(%rbp)
jmp    114a <quick_hash+0x3a>
mov    -0xdc(%rbp),%eax
add    $0xe0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<quick_hash>:
sub    $0xd8,%rsp
mov    %edi,%edx
mov    %rsp,%rdi
mov    $0xa,%esi
call   1030 <mpz_get_str@plt>
mov    (%rsp),%dl
test   %dl,%dl
je     115e <quick_hash+0x4e>
lea    0x1(%rsp),%rcx
xor    %eax,%eax
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movsbl %dl,%edx
imul   $0x1003f,%eax,%eax
add    %edx,%eax
movzbl (%rcx),%edx
add    $0x1,%rcx
test   %dl,%dl
jne    1140 <quick_hash+0x30>
add    $0xd8,%rsp
ret
xor    %eax,%eax
add    $0xd8,%rsp
ret

LLVM IR (-O0):
define i32 @quick_hash(i32 %0) {
%2 = alloca i32
%3 = alloca [202 x i8]
%4 = alloca i8*
%5 = alloca i32
store i32 %0, i32* %2
%6 = getelementptr inbounds [202 x i8], [202 x i8]* %3, i64 0, i64 0
store i8* %6, i8** %4
%7 = getelementptr inbounds [202 x i8], [202 x i8]* %3, i64 0, i64 0
%8 = load i32, i32* %2
%9 = call i32 @mpz_get_str(i8* %7, i32 10, i32 %8)
store i32 0, i32* %5
br label %10
10: ; preds = %14, %1
%11 = load i8*, i8** %4
%12 = load i8, i8* %11
%13 = icmp ne i8 %12, 0
br i1 %13, label %14, label %27
14: ; preds = %10
%15 = load i8*, i8** %4
%16 = getelementptr inbounds i8, i8* %15, i32 1
store i8* %16, i8** %4
%17 = load i8, i8* %15
%18 = sext i8 %17 to i32
%19 = load i32, i32* %5
%20 = shl i32 %19, 6
%21 = add nsw i32 %18, %20
%22 = load i32, i32* %5
%23 = shl i32 %22, 16
%24 = add nsw i32 %21, %23
%25 = load i32, i32* %5
%26 = sub nsw i32 %24, %25
store i32 %26, i32* %5
br label %10
27: ; preds = %10
%28 = load i32, i32* %5
ret i32 %28
}

LLVM IR (-O2):
define i32 @quick_hash(i32 %0) {
%2 = alloca [202 x i8]
%3 = getelementptr inbounds [202 x i8], [202 x i8]* %2, i64 0, i64 0
%4 = call i32 @mpz_get_str(i8* %3, i32 10, i32 %0)
%5 = load i8, i8* %3
%6 = icmp eq i8 %5, 0
br i1 %6, label %17, label %7
7: ; preds = %1, %7
%8 = phi i8 [ %15, %7 ], [ %5, %1 ]
%9 = phi i32 [ %14, %7 ], [ 0, %1 ]
%10 = phi i8* [ %11, %7 ], [ %3, %1 ]
%11 = getelementptr inbounds i8, i8* %10, i64 1
%12 = sext i8 %8 to i32
%13 = mul i32 %9, 65599
%14 = add i32 %13, %12
%15 = load i8, i8* %11
%16 = icmp eq i8 %15, 0
br i1 %16, label %17, label %7
17: ; preds = %7, %1
%18 = phi i32 [ 0, %1 ], [ %14, %7 ]
ret i32 %18
}