#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; (tmp = *(string + i)) != '\0'; 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    -0x8(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    (%rax,%rcx,1),%al
mov    %al,-0x19(%rbp)
movsbl %al,%eax
cmp    $0x0,%eax
je     11a2 <hashfuc+0x82>
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   %r12
push   %rbx
mov    (%rdi),%r12b
test   %r12b,%r12b
je     1176 <hashfuc+0x56>
mov    %esi,%ebp
mov    %rdi,%rbx
add    $0x1,%rbx
add    $0xffffffff,%ebp
xor    %r14d,%r14d
nop
xorps  %xmm0,%xmm0
cvtsi2sd %ebp,%xmm0
mov    $0x4,%edi
call   1030 <pow@plt>
mov    %rax,%r15
movsbl %r12b,%edi
call   1040 <nuc2num@plt>
imul   %r15d,%eax
add    %eax,%r14d
movzbl (%rbx),%r12d
add    $0x1,%rbx
add    $0xffffffff,%ebp
test   %r12b,%r12b
jne    1140 <hashfuc+0x20>
jmp    1179 <hashfuc+0x59>
xor    %r14d,%r14d
mov    %r14d,%eax
pop    %rbx
pop    %r12
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 = %31, %2
%11 = load i8*, i8** %3
%12 = load i32, i32* %7
%13 = sext i32 %12 to i64
%14 = getelementptr inbounds i8, i8* %11, i64 %13
%15 = load i8, i8* %14
store i8 %15, i8* %8
%16 = sext i8 %15 to i32
%17 = icmp ne i32 %16, 0
br i1 %17, label %18, label %34
18: ; preds = %10
%19 = load i32, i32* %6
%20 = sub nsw i32 %19, 1
%21 = sitofp i32 %20 to double
%22 = call i64 @pow(i32 4, double %21)
%23 = trunc i64 %22 to i32
%24 = load i8, i8* %8
%25 = call i32 @nuc2num(i8 signext %24)
%26 = mul nsw i32 %23, %25
%27 = load i32, i32* %5
%28 = add nsw i32 %27, %26
store i32 %28, i32* %5
%29 = load i32, i32* %6
%30 = sub nsw i32 %29, 1
store i32 %30, i32* %6
br label %31
31: ; preds = %18
%32 = load i32, i32* %7
%33 = add nsw i32 %32, 1
store i32 %33, i32* %7
br label %10
34: ; preds = %10
%35 = load i32, i32* %5
ret i32 %35
}

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