// File: /workspace/github_c_makefile_star2_O1/zuocheng-liu[P]ae-memcached/src/assoc.c
// Function: hash
ub4 hash( k, length, initval)
     register ub1 *k;        /* the key */
     register ub4  length;   /* the length of the key */
     register ub4  initval;  /* the previous hash, or an arbitrary value */
{
    register ub4 a,b,c,len;

    /* Set up the internal state */
    len = length;
    a = b = 0x9e3779b9;  /* the golden ratio; an arbitrary value */
    c = initval;         /* the previous hash value */

    /*---------------------------------------- handle most of the key */
    while (len >= 12)
        {
            a += (k[0] +((ub4)k[1]<<8) +((ub4)k[2]<<16) +((ub4)k[3]<<24));
            b += (k[4] +((ub4)k[5]<<8) +((ub4)k[6]<<16) +((ub4)k[7]<<24));
            c += (k[8] +((ub4)k[9]<<8) +((ub4)k[10]<<16)+((ub4)k[11]<<24));
            mix(a,b,c);
            k += 12; len -= 12;
        }

    /*------------------------------------- handle the last 11 bytes */
    c += length;
    switch(len)              /* all the case statements fall through */
        {
        case 11: c+=((ub4)k[10]<<24);
        case 10: c+=((ub4)k[9]<<16);
        case 9 : c+=((ub4)k[8]<<8);
            /* the first byte of c is reserved for the length */
        case 8 : b+=((ub4)k[7]<<24);
        case 7 : b+=((ub4)k[6]<<16);
        case 6 : b+=((ub4)k[5]<<8);
        case 5 : b+=k[4];
        case 4 : a+=((ub4)k[3]<<24);
        case 3 : a+=((ub4)k[2]<<16);
        case 2 : a+=((ub4)k[1]<<8);
        case 1 : a+=k[0];
            /* case 0: nothing left to add */
        }
    mix(a,b,c);
    /*-------------------------------------------- report the result */
    return c;
}

// Assembly:
movl $0x9e3779b9, %eax       # imm = 0x9E3779B9
cmpq $0xc, %rsi
jb 0x36da
movq %rsi, %r8
movl $0x9e3779b9, %ecx       # imm = 0x9E3779B9
movl (%rdi), %r9d
movl 0x4(%rdi), %r10d
addq %rcx, %r9
addq %rax, %r10
movl 0x8(%rdi), %eax
addq %rdx, %rax
subq %r10, %r9
subq %rax, %r9
movq %rax, %rcx
shrq $0xd, %rcx
xorq %r9, %rcx
subq %rax, %r10
subq %rcx, %r10
movq %rcx, %rdx
shlq $0x8, %rdx
xorq %r10, %rdx
subq %rcx, %rax
subq %rdx, %rax
movq %rdx, %r9
shrq $0xd, %r9
xorq %rax, %r9
subq %rdx, %rcx
subq %r9, %rcx
movq %r9, %rax
shrq $0xc, %rax
xorq %rcx, %rax
subq %r9, %rdx
subq %rax, %rdx
movq %rax, %r10
shlq $0x10, %r10
xorq %rdx, %r10
subq %rax, %r9
subq %r10, %r9
movq %r10, %r11
shrq $0x5, %r11
xorq %r9, %r11
subq %r10, %rax
subq %r11, %rax
movq %r11, %rcx
shrq $0x3, %rcx
xorq %rax, %rcx
subq %r11, %r10
subq %rcx, %r10
movq %rcx, %rax
shlq $0xa, %rax
xorq %r10, %rax
subq %rcx, %r11
subq %rax, %r11
movq %rax, %rdx
shrq $0xf, %rdx
xorq %r11, %rdx
addq $0xc, %rdi
addq $-0xc, %r8
cmpq $0xb, %r8
ja 0x3623
jmp 0x36e2
movl $0x9e3779b9, %ecx       # imm = 0x9E3779B9
movq %rsi, %r8
addq %rsi, %rdx
decq %r8
cmpq $0xa, %r8
ja 0x3766
leaq 0x4963(%rip), %rsi      # 0x8058
movslq (%rsi,%r8,4), %r8
addq %rsi, %r8
jmpq *%r8
movzbl 0xa(%rdi), %esi
shll $0x18, %esi
addq %rsi, %rdx
movzbl 0x9(%rdi), %esi
shll $0x10, %esi
addq %rsi, %rdx
movzbl 0x8(%rdi), %esi
shll $0x8, %esi
addq %rsi, %rdx
movzbl 0x7(%rdi), %esi
shll $0x18, %esi
addq %rsi, %rax
movzbl 0x6(%rdi), %esi
shll $0x10, %esi
addq %rsi, %rax
movzbl 0x5(%rdi), %esi
shll $0x8, %esi
addq %rsi, %rax
movzbl 0x4(%rdi), %esi
addq %rsi, %rax
movzbl 0x3(%rdi), %esi
shll $0x18, %esi
addq %rsi, %rcx
movzbl 0x2(%rdi), %esi
shll $0x10, %esi
addq %rsi, %rcx
movzbl 0x1(%rdi), %esi
shll $0x8, %esi
addq %rsi, %rcx
movzbl (%rdi), %esi
addq %rsi, %rcx
subq %rax, %rcx
subq %rdx, %rcx
movq %rdx, %rsi
shrq $0xd, %rsi
xorq %rcx, %rsi
subq %rdx, %rax
subq %rsi, %rax
movq %rsi, %rcx
shlq $0x8, %rcx
xorq %rax, %rcx
subq %rsi, %rdx
subq %rcx, %rdx
movq %rcx, %rax
shrq $0xd, %rax
xorq %rdx, %rax
subq %rcx, %rsi
subq %rax, %rsi
movq %rax, %rdx
shrq $0xc, %rdx
xorq %rsi, %rdx
subq %rax, %rcx
subq %rdx, %rcx
movq %rdx, %rsi
shlq $0x10, %rsi
xorq %rcx, %rsi
subq %rdx, %rax
subq %rsi, %rax
movq %rsi, %rcx
shrq $0x5, %rcx
xorq %rax, %rcx
subq %rsi, %rdx
subq %rcx, %rdx
movq %rcx, %rdi
shrq $0x3, %rdi
xorq %rdx, %rdi
subq %rcx, %rsi
subq %rdi, %rsi
movq %rdi, %rax
shlq $0xa, %rax
xorq %rsi, %rax
addq %rax, %rdi
subq %rdi, %rcx
shrq $0xf, %rax
xorq %rcx, %rax
retq