// File: /workspace/github_cpp_makefile_star2_O2/ethanmick[P]Blowfish482/Blowfish.cpp
// Function: Blowfish::setKey(unsigned char*)
void Blowfish::setKey(uint8_t* key){
    
    for (int i = 0; i < 18; i++) {
        pArray[i] = computeHexPi();
    }
    
    for (int i=0; i < 256; i++) {
    	s1[i] = computeHexPi();
    }
    
    for (int i=0; i < 256; i++) {
    	s2[i] = computeHexPi();
    }
    
    for (int i=0; i < 256; i++) {
    	s3[i] = computeHexPi();
    }
   
    for (int i=0; i < 256; i++) {
    	s4[i] = computeHexPi();
    }

    uint32_t key_size = keySize();
   
    uint32_t subkeyCounter = 0; 
    for (int pI=0; pI < 18; pI++) {
        
        uint32_t subkey = 0; 

        for (int i=0; i < 4; i++, subkeyCounter++) {
            if (subkeyCounter >= key_size) {
                subkeyCounter = 0;
            }
    	    subkey <<= 8;
            subkey |= (uint32_t)key[subkeyCounter];
        }

    	pArray[pI] ^= subkey;
    } 
        
    uint8_t* zeros = new uint8_t[ 8 ];
    for( int i = 0; i < 8; i++ ){
        zeros[ i ] = 0;
    }
        
    for (int i=0; i < 18; i += 2) {
        encrypt(zeros);
        pArray[i] = pack32BitWord(zeros, 0);
        pArray[i+1] = pack32BitWord(zeros, 4);
    }

    for (int i=0; i < 256; i += 2) {
        encrypt(zeros);
        s1[i] = pack32BitWord(zeros, 0);
        s1[i+1] = pack32BitWord(zeros, 4);
    } 

    for (int i=0; i < 256; i += 2) {
        encrypt(zeros);
        s2[i] = pack32BitWord(zeros, 0);
        s2[i+1] = pack32BitWord(zeros, 4);
    } 

    for (int i=0; i < 256; i += 2) {
        encrypt(zeros);
        s3[i] = pack32BitWord(zeros, 0);
        s3[i+1] = pack32BitWord(zeros, 4);
    } 

    for (int i=0; i < 256; i += 2) {
        encrypt(zeros);
        s4[i] = pack32BitWord(zeros, 0);
        s4[i+1] = pack32BitWord(zeros, 4);
    } 

}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movq %rsi, %r14
movq %rdi, %rbx
movl $0x403, %r15d           # imm = 0x403
cmpq $0x415, %r15            # imm = 0x415
je 0x2331
movq %rbx, %rdi
callq 0x256e
movl %eax, (%rbx,%r15,4)
incq %r15
jmp 0x2317
pushq $0x3
popq %r15
cmpq $0x103, %r15            # imm = 0x103
je 0x234f
movq %rbx, %rdi
callq 0x256e
movl %eax, (%rbx,%r15,4)
incq %r15
jmp 0x2335
movl $0x103, %r15d           # imm = 0x103
cmpq $0x203, %r15            # imm = 0x203
je 0x236f
movq %rbx, %rdi
callq 0x256e
movl %eax, (%rbx,%r15,4)
incq %r15
jmp 0x2355
movl $0x203, %r15d           # imm = 0x203
cmpq $0x303, %r15            # imm = 0x303
je 0x238f
movq %rbx, %rdi
callq 0x256e
movl %eax, (%rbx,%r15,4)
incq %r15
jmp 0x2375
movl $0x303, %r15d           # imm = 0x303
cmpq $0x403, %r15            # imm = 0x403
je 0x23af
movq %rbx, %rdi
callq 0x256e
movl %eax, (%rbx,%r15,4)
incq %r15
jmp 0x2395
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x8(%rax)
xorl %ecx, %ecx
pushq $0x4
popq %rdx
xorl %esi, %esi
xorl %edi, %edi
cmpq $0x12, %rsi
je 0x23f5
xorl %r8d, %r8d
movl %edx, %r9d
subl $0x1, %r9d
jb 0x23e8
cmpl %eax, %edi
cmovael %ecx, %edi
shll $0x8, %r8d
movzbl (%r14,%rdi), %r10d
orl %r10d, %r8d
incl %edi
jmp 0x23cd
xorl %r8d, 0x100c(%rbx,%rsi,4)
incq %rsi
jmp 0x23c1
pushq $0x8
popq %rdi
callq 0x2030
movq %rax, %r14
xorl %eax, %eax
cmpq $0x8, %rax
je 0x2412
movb $0x0, (%r14,%rax)
incq %rax
jmp 0x2402
xorl %r15d, %r15d
pushq $0x4
popq %rbp
cmpq $0x12, %r15
jae 0x2454
movq (%rbx), %rax
movq %rbx, %rdi
movq %r14, %rsi
callq *0x18(%rax)
movq %r14, %rsi
xorl %edx, %edx
callq 0x264a
movl %eax, 0x100c(%rbx,%r15,4)
movq %r14, %rsi
movl %ebp, %edx
callq 0x264a
movl %eax, 0x1010(%rbx,%r15,4)
addq $0x2, %r15
jmp 0x2418
xorl %r15d, %r15d
pushq $0x4
popq %rbp
cmpq $0x100, %r15            # imm = 0x100
jae 0x2493
movq (%rbx), %rax
movq %rbx, %rdi
movq %r14, %rsi
callq *0x18(%rax)
movq %r14, %rsi
xorl %edx, %edx
callq 0x264a
movl %eax, 0xc(%rbx,%r15,4)
movq %r14, %rsi
movl %ebp, %edx
callq 0x264a
movl %eax, 0x10(%rbx,%r15,4)
addq $0x2, %r15
jmp 0x245a
xorl %r15d, %r15d
pushq $0x4
popq %rbp
cmpq $0x100, %r15            # imm = 0x100
jae 0x24d8
movq (%rbx), %rax
movq %rbx, %rdi
movq %r14, %rsi
callq *0x18(%rax)
movq %r14, %rsi
xorl %edx, %edx
callq 0x264a
movl %eax, 0x40c(%rbx,%r15,4)
movq %r14, %rsi
movl %ebp, %edx
callq 0x264a
movl %eax, 0x410(%rbx,%r15,4)
addq $0x2, %r15
jmp 0x2499
xorl %r15d, %r15d
pushq $0x4
popq %rbp
cmpq $0x100, %r15            # imm = 0x100
jae 0x251d
movq (%rbx), %rax
movq %rbx, %rdi
movq %r14, %rsi
callq *0x18(%rax)
movq %r14, %rsi
xorl %edx, %edx
callq 0x264a
movl %eax, 0x80c(%rbx,%r15,4)
movq %r14, %rsi
movl %ebp, %edx
callq 0x264a
movl %eax, 0x810(%rbx,%r15,4)
addq $0x2, %r15
jmp 0x24de
xorl %r15d, %r15d
pushq $0x4
popq %rbp
cmpq $0x100, %r15            # imm = 0x100
jae 0x2562
movq (%rbx), %rax
movq %rbx, %rdi
movq %r14, %rsi
callq *0x18(%rax)
movq %r14, %rsi
xorl %edx, %edx
callq 0x264a
movl %eax, 0xc0c(%rbx,%r15,4)
movq %r14, %rsi
movl %ebp, %edx
callq 0x264a
movl %eax, 0xc10(%rbx,%r15,4)
addq $0x2, %r15
jmp 0x2523
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
nop