// File: koraa[P]sbcrack/cube/crypto.cpp
// Function: tiger::hash(unsigned char const*, int, tiger::hashval&)
void hash(const uchar *str, int length, hashval &val)
    {
        static bool init = false;
        if(!init) { gensboxes(); init = true; }

        uchar temp[64];

        val.chunks[0] = 0x0123456789ABCDEFULL;
        val.chunks[1] = 0xFEDCBA9876543210ULL;
        val.chunks[2] = 0xF096A5B4C3B2E187ULL;

        int i = length;
        for(; i >= 64; i -= 64, str += 64)
        {
            if(!*(const uchar *)&islittleendian)
            {
                loopj(64) temp[j^7] = str[j];
                compress((chunk *)temp, val.chunks);
            }
            else compress((chunk *)str, val.chunks);
        }

        int j;
        if(!*(const uchar *)&islittleendian)
        {
            for(j = 0; j < i; j++) temp[j^7] = str[j];
            temp[j^7] = 0x01;
            while(++j&7) temp[j^7] = 0;
        }
        else
        {
            for(j = 0; j < i; j++) temp[j] = str[j];
            temp[j] = 0x01;
            while(++j&7) temp[j] = 0;
        }

        if(j > 56)
        {
            while(j < 64) temp[j++] = 0;
            compress((chunk *)temp, val.chunks);
            j = 0;
        }
        while(j < 56) temp[j++] = 0;
        *(chunk *)(temp+56) = (chunk)length<<3;
        compress((chunk *)temp, val.chunks);
        if(!*(const uchar *)&islittleendian)
        {
            loopk(3) 
            {
                uchar *c = &val.bytes[k*sizeof(chunk)];
                loopl(sizeof(chunk)/2) swap(c[l], c[sizeof(chunk)-1-l]);
            }
        }
    }

// Assembly:
subq $0x78, %rsp
movq %rdi, 0x70(%rsp)
movl %esi, 0x6c(%rsp)
movq %rdx, 0x60(%rsp)
testb $0x1, 0xac47(%rip)      # 0x130e0
jne 0x84a7
callq 0x81d0
movb $0x1, 0xac39(%rip)      # 0x130e0
movq 0x60(%rsp), %rax
movabsq $0x123456789abcdef, %rcx # imm = 0x123456789ABCDEF
movq %rcx, (%rax)
movq 0x60(%rsp), %rax
movabsq $-0x123456789abcdf0, %rcx # imm = 0xFEDCBA9876543210
movq %rcx, 0x8(%rax)
movq 0x60(%rsp), %rax
movabsq $-0xf695a4b3c4d1e79, %rcx # imm = 0xF096A5B4C3B2E187
movq %rcx, 0x10(%rax)
movl 0x6c(%rsp), %eax
movl %eax, 0x1c(%rsp)
cmpl $0x40, 0x1c(%rsp)
jl 0x856d
cmpb $0x0, 0x5ca3(%rip)      # 0xe198
jne 0x853e
movl $0x0, 0x18(%rsp)
cmpl $0x40, 0x18(%rsp)
jge 0x852d
movq 0x70(%rsp), %rax
movslq 0x18(%rsp), %rcx
movb (%rax,%rcx), %cl
movl 0x18(%rsp), %eax
xorl $0x7, %eax
cltq
movb %cl, 0x20(%rsp,%rax)
movl 0x18(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x18(%rsp)
jmp 0x84ff
leaq 0x20(%rsp), %rdi
movq 0x60(%rsp), %rsi
callq 0x75d0
jmp 0x854d
movq 0x70(%rsp), %rdi
movq 0x60(%rsp), %rsi
callq 0x75d0
jmp 0x854f
movl 0x1c(%rsp), %eax
subl $0x40, %eax
movl %eax, 0x1c(%rsp)
movq 0x70(%rsp), %rax
addq $0x40, %rax
movq %rax, 0x70(%rsp)
jmp 0x84e7
cmpb $0x0, 0x5c24(%rip)      # 0xe198
jne 0x85e2
movl $0x0, 0x14(%rsp)
movl 0x14(%rsp), %eax
cmpl 0x1c(%rsp), %eax
jge 0x85af
movq 0x70(%rsp), %rax
movslq 0x14(%rsp), %rcx
movb (%rax,%rcx), %cl
movl 0x14(%rsp), %eax
xorl $0x7, %eax
cltq
movb %cl, 0x20(%rsp,%rax)
movl 0x14(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x14(%rsp)
jmp 0x857e
movl 0x14(%rsp), %eax
xorl $0x7, %eax
cltq
movb $0x1, 0x20(%rsp,%rax)
movl 0x14(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x14(%rsp)
andl $0x7, %eax
cmpl $0x0, %eax
je 0x85e0
movl 0x14(%rsp), %eax
xorl $0x7, %eax
cltq
movb $0x0, 0x20(%rsp,%rax)
jmp 0x85bd
jmp 0x8642
movl $0x0, 0x14(%rsp)
movl 0x14(%rsp), %eax
cmpl 0x1c(%rsp), %eax
jge 0x8617
movq 0x70(%rsp), %rax
movslq 0x14(%rsp), %rcx
movb (%rax,%rcx), %cl
movslq 0x14(%rsp), %rax
movb %cl, 0x20(%rsp,%rax)
movl 0x14(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x14(%rsp)
jmp 0x85ea
movslq 0x14(%rsp), %rax
movb $0x1, 0x20(%rsp,%rax)
movl 0x14(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x14(%rsp)
andl $0x7, %eax
cmpl $0x0, %eax
je 0x8640
movslq 0x14(%rsp), %rax
movb $0x0, 0x20(%rsp,%rax)
jmp 0x8621
jmp 0x8642
cmpl $0x38, 0x14(%rsp)
jle 0x867f
jmp 0x864b
cmpl $0x40, 0x14(%rsp)
jge 0x8668
movl 0x14(%rsp), %eax
movl %eax, %ecx
addl $0x1, %ecx
movl %ecx, 0x14(%rsp)
cltq
movb $0x0, 0x20(%rsp,%rax)
jmp 0x864b
leaq 0x20(%rsp), %rdi
movq 0x60(%rsp), %rsi
callq 0x75d0
movl $0x0, 0x14(%rsp)
jmp 0x8681
cmpl $0x38, 0x14(%rsp)
jge 0x869e
movl 0x14(%rsp), %eax
movl %eax, %ecx
addl $0x1, %ecx
movl %ecx, 0x14(%rsp)
cltq
movb $0x0, 0x20(%rsp,%rax)
jmp 0x8681
movslq 0x6c(%rsp), %rax
shlq $0x3, %rax
movq %rax, 0x58(%rsp)
leaq 0x20(%rsp), %rdi
movq 0x60(%rsp), %rsi
callq 0x75d0
cmpb $0x0, 0x5ad6(%rip)      # 0xe198
jne 0x873d
movl $0x0, 0x10(%rsp)
cmpl $0x3, 0x10(%rsp)
jge 0x873b
movq 0x60(%rsp), %rax
movslq 0x10(%rsp), %rcx
shlq $0x3, %rcx
addq %rcx, %rax
movq %rax, 0x8(%rsp)
movl $0x0, 0x4(%rsp)
cmpl $0x4, 0x4(%rsp)
jge 0x872c
movq 0x8(%rsp), %rdi
movslq 0x4(%rsp), %rax
addq %rax, %rdi
movq 0x8(%rsp), %rsi
movslq 0x4(%rsp), %rcx
movl $0x7, %eax
subq %rcx, %rax
addq %rax, %rsi
callq 0x8750
movl 0x4(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x4(%rsp)
jmp 0x86f1
jmp 0x872e
movl 0x10(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x10(%rsp)
jmp 0x86cc
jmp 0x873d
addq $0x78, %rsp
retq
nopw %cs:(%rax,%rax)