// File: koraa[P]sbcrack/cube/crypto.cpp
// Function: tiger::gensboxes()
void gensboxes()
    {
        const char *str = "Tiger - A Fast New Hash Function, by Ross Anderson and Eli Biham";
        chunk state[3] = { 0x0123456789ABCDEFULL, 0xFEDCBA9876543210ULL, 0xF096A5B4C3B2E187ULL };
        uchar temp[64];

        if(!*(const uchar *)&islittleendian) loopj(64) temp[j^7] = str[j];
        else loopj(64) temp[j] = str[j];
        loopi(1024) loop(col, 8) ((uchar *)&sboxes[i])[col] = i&0xFF;

        int abc = 2;
        loop(pass, 5) loopi(256) for(int sb = 0; sb < 1024; sb += 256)
        {
            abc++;
            if(abc >= 3) { abc = 0; compress((chunk *)temp, state); }
            loop(col, 8)
            {
                uchar val = ((uchar *)&sboxes[sb+i])[col];
                ((uchar *)&sboxes[sb+i])[col] = ((uchar *)&sboxes[sb + ((uchar *)&state[abc])[col]])[col];
                ((uchar *)&sboxes[sb + ((uchar *)&state[abc])[col]])[col] = val;
            }
        }
    }

// Assembly:
subq $0x98, %rsp
leaq 0x5e42(%rip), %rax      # 0xe020
movq %rax, 0x90(%rsp)
movq 0x5f93(%rip), %rax      # 0xe180
movq %rax, 0x70(%rsp)
movq 0x5f8f(%rip), %rax      # 0xe188
movq %rax, 0x78(%rsp)
movq 0x5f8b(%rip), %rax      # 0xe190
movq %rax, 0x80(%rsp)
cmpb $0x0, 0x5f84(%rip)      # 0xe198
jne 0x8251
movl $0x0, 0x2c(%rsp)
cmpl $0x40, 0x2c(%rsp)
jge 0x824f
movq 0x90(%rsp), %rax
movslq 0x2c(%rsp), %rcx
movb (%rax,%rcx), %cl
movl 0x2c(%rsp), %eax
xorl $0x7, %eax
cltq
movb %cl, 0x30(%rsp,%rax)
movl 0x2c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x2c(%rsp)
jmp 0x821e
jmp 0x8288
movl $0x0, 0x28(%rsp)
cmpl $0x40, 0x28(%rsp)
jge 0x8286
movq 0x90(%rsp), %rax
movslq 0x28(%rsp), %rcx
movb (%rax,%rcx), %cl
movslq 0x28(%rsp), %rax
movb %cl, 0x30(%rsp,%rax)
movl 0x28(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x28(%rsp)
jmp 0x8259
jmp 0x8288
movl $0x0, 0x24(%rsp)
cmpl $0x400, 0x24(%rsp)      # imm = 0x400
jge 0x82eb
movl $0x0, 0x20(%rsp)
cmpl $0x8, 0x20(%rsp)
jge 0x82dc
movl 0x24(%rsp), %eax
andl $0xff, %eax
movb %al, %dl
movslq 0x24(%rsp), %rcx
leaq 0x8e20(%rip), %rax      # 0x110e0
shlq $0x3, %rcx
addq %rcx, %rax
movslq 0x20(%rsp), %rcx
movb %dl, (%rax,%rcx)
movl 0x20(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x20(%rsp)
jmp 0x82a2
jmp 0x82de
movl 0x24(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x24(%rsp)
jmp 0x8290
movl $0x2, 0x1c(%rsp)
movl $0x0, 0x18(%rsp)
cmpl $0x5, 0x18(%rsp)
jge 0x8472
movl $0x0, 0x14(%rsp)
cmpl $0x100, 0x14(%rsp)      # imm = 0x100
jge 0x8460
movl $0x0, 0x10(%rsp)
cmpl $0x400, 0x10(%rsp)      # imm = 0x400
jge 0x844e
movl 0x1c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x1c(%rsp)
cmpl $0x3, 0x1c(%rsp)
jl 0x835b
movl $0x0, 0x1c(%rsp)
leaq 0x30(%rsp), %rdi
leaq 0x70(%rsp), %rsi
callq 0x75d0
movl $0x0, 0xc(%rsp)
cmpl $0x8, 0xc(%rsp)
jge 0x843a
movl 0x10(%rsp), %eax
addl 0x14(%rsp), %eax
movslq %eax, %rcx
leaq 0x8d60(%rip), %rax      # 0x110e0
shlq $0x3, %rcx
addq %rcx, %rax
movslq 0xc(%rsp), %rcx
movb (%rax,%rcx), %al
movb %al, 0xb(%rsp)
movl 0x10(%rsp), %eax
movslq 0x1c(%rsp), %rdx
leaq 0x70(%rsp), %rcx
shlq $0x3, %rdx
addq %rdx, %rcx
movslq 0xc(%rsp), %rdx
movzbl (%rcx,%rdx), %ecx
addl %ecx, %eax
movslq %eax, %rcx
leaq 0x8d23(%rip), %rax      # 0x110e0
shlq $0x3, %rcx
addq %rcx, %rax
movslq 0xc(%rsp), %rcx
movb (%rax,%rcx), %dl
movl 0x10(%rsp), %eax
addl 0x14(%rsp), %eax
movslq %eax, %rcx
leaq 0x8d02(%rip), %rax      # 0x110e0
shlq $0x3, %rcx
addq %rcx, %rax
movslq 0xc(%rsp), %rcx
movb %dl, (%rax,%rcx)
movb 0xb(%rsp), %dl
movl 0x10(%rsp), %eax
movslq 0x1c(%rsp), %rsi
leaq 0x70(%rsp), %rcx
shlq $0x3, %rsi
addq %rsi, %rcx
movslq 0xc(%rsp), %rsi
movzbl (%rcx,%rsi), %ecx
addl %ecx, %eax
movslq %eax, %rcx
leaq 0x8cc5(%rip), %rax      # 0x110e0
shlq $0x3, %rcx
addq %rcx, %rax
movslq 0xc(%rsp), %rcx
movb %dl, (%rax,%rcx)
movl 0xc(%rsp), %eax
addl $0x1, %eax
movl %eax, 0xc(%rsp)
jmp 0x8363
jmp 0x843c
movl 0x10(%rsp), %eax
addl $0x100, %eax            # imm = 0x100
movl %eax, 0x10(%rsp)
jmp 0x8324
jmp 0x8450
movl 0x14(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x14(%rsp)
jmp 0x830e
jmp 0x8462
movl 0x18(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x18(%rsp)
jmp 0x82fb
addq $0x98, %rsp
retq
nopw (%rax,%rax)