#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 nuc2num(char);
scalar_t__ pow(int, double);
int hashfuc(char *string, int mer) {
  int sum = 0, loc = mer, i;
  char tmp;
  for (i = 0; i < mer; i++) {
    tmp = *(string + i);
    sum += (int)pow(4, (double)(loc - 1)) * nuc2num(tmp);
    loc -= 1;
  }
  return sum;
}


x86 assembly (clang, -O0):
<hashfuc>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11a2 <hashfuc+0x82>
mov    -0x8(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    (%rax,%rcx,1),%al
mov    %al,-0x19(%rbp)
mov    -0x14(%rbp),%eax
sub    $0x1,%eax
cvtsi2sd %eax,%xmm0
mov    $0x4,%edi
call   1030 <pow@plt>
mov    %eax,-0x20(%rbp)
movsbl -0x19(%rbp),%edi
call   1040 <nuc2num@plt>
mov    %eax,%ecx
mov    -0x20(%rbp),%eax
imul   %ecx,%eax
add    -0x10(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0x14(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x14(%rbp)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1143 <hashfuc+0x23>
mov    -0x10(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<hashfuc>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
test   %esi,%esi
jle    118a <hashfuc+0x6a>
mov    %esi,%ebx
mov    %rdi,%r13
mov    %esi,%eax
neg    %rax
mov    %rax,(%rsp)
add    $0xffffffff,%ebx
xor    %r14d,%r14d
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
nop
movsbl 0x0(%r13,%r14,1),%r15d
xorps  %xmm0,%xmm0
cvtsi2sd %ebx,%xmm0
mov    $0x4,%edi
call   1030 <pow@plt>
mov    %rax,%r12
mov    %r15d,%edi
call   1040 <nuc2num@plt>
imul   %r12d,%eax
add    %eax,%ebp
add    $0x1,%r14
add    $0xffffffff,%ebx
mov    (%rsp),%rax
add    %r14,%rax
jne    1150 <hashfuc+0x30>
jmp    118c <hashfuc+0x6c>
xor    %ebp,%ebp
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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