// File: /workspace/github_cpp_makefile_star2_O2/ethanmick[P]Blowfish482/Tester.cpp
// Function: main
int main( int argc, char* argv[] ){
    Blowfish b;

    if( (unsigned int) argc != b.blockSize() + b.keySize() + 1 ){
        cout << "usage: Blowfish key[ 0th byte ] key[ 1st byte ] " \
                "etc... ptext[ 0th byte ] ptext[ 1st byte ] etc..." << endl;
        exit( 0 );
    }
    
    for( int i = 1; i < argc; i++ ){
        if( strlen( argv[ i ] ) != 2 ){
            cout << "This arg isn't 2 characters long." << endl;
            exit( 0 );
        }
    }
        
    uint8_t* key = new uint8_t[ b.keySize() ];
    
    for( unsigned int i = 0; i < b.keySize(); i++ ){
        char * p;
        key[ i ] = (uint8_t) strtol( argv[ 1 + i ], &p, 16 );
        if( *p != 0 ){
            cout << "Problem parsing string." << endl;
        }
    }
    
    print_uint8_hex(key, b.keySize(), "Key: ");
    b.setKey( key );
    

    uint8_t* text = new uint8_t[ b.blockSize() ];

    
    
    for( unsigned int i = 0; i < b.blockSize(); i++ ){
        char * p;
        text[ i ] = (uint8_t) strtol( argv[ b.keySize() + 1 + i ], &p, 16 );
        if( *p != 0 ){
            cout << "Problem parsing string." << endl;
        }
    }
    print_uint8_hex(text, b.blockSize(), "Plaintext: ");
    b.encrypt( text );
    print_uint8_hex(text, b.blockSize(), "Ciphertext: ");
    
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x1068, %rsp           # imm = 0x1068
movq %rsi, %rbx
movl %edi, %ebp
leaq 0x10(%rsp), %r14
movq %r14, %rdi
callq 0x124c
movq %r14, %rdi
callq 0x125c
movl %eax, %r15d
movq %r14, %rdi
callq 0x1260
addl %r15d, %eax
incl %eax
cmpl %ebp, %eax
jne 0x1aca
movslq %ebp, %r14
pushq $0x1
popq %r15
cmpq %r14, %r15
jge 0x1968
movq (%rbx,%r15,8), %rdi
callq 0x1040
incq %r15
cmpq $0x2, %rax
je 0x192f
movq 0x268b(%rip), %rdi      # 0x3fd8
leaq 0x74e(%rip), %rsi       # 0x20a2
callq 0x1090
movq %rax, %rdi
callq 0x1050
xorl %edi, %edi
callq 0x10a0
leaq 0x10(%rsp), %r14
movq %r14, %rdi
callq 0x1260
movl %eax, %edi
callq 0x1030
movq %rax, %r15
xorl %r13d, %r13d
leaq 0x8(%rsp), %r12
pushq $0x10
popq %rbp
movq %r14, %rdi
callq 0x1260
movl %eax, %eax
cmpq %rax, %r13
jae 0x19d6
movq 0x8(%rbx,%r13,8), %rdi
movq %r12, %rsi
movl %ebp, %edx
callq 0x10c0
movb %al, (%r15,%r13)
movq 0x8(%rsp), %rax
cmpb $0x0, (%rax)
je 0x19d1
movq 0x261b(%rip), %rdi      # 0x3fd8
leaq 0x700(%rip), %rsi       # 0x20c4
callq 0x1090
movq %rax, %rdi
callq 0x1050
incq %r13
jmp 0x198a
leaq 0x10(%rsp), %r14
movq %r14, %rdi
callq 0x1260
leaq 0x6f2(%rip), %rdx       # 0x20dc
movq %r15, %rdi
movl %eax, %esi
callq 0x1854
movq %r14, %rdi
movq %r15, %rsi
callq 0x1264
movq %r14, %rdi
callq 0x125c
movl %eax, %edi
callq 0x1030
movq %rax, %r15
xorl %r13d, %r13d
leaq 0x8(%rsp), %r12
pushq $0x10
popq %rbp
movq %r14, %rdi
callq 0x125c
movl %eax, %eax
cmpq %rax, %r13
jae 0x1a74
movq %r14, %rdi
callq 0x1260
addl %r13d, %eax
incl %eax
movq (%rbx,%rax,8), %rdi
movq %r12, %rsi
movl %ebp, %edx
callq 0x10c0
movb %al, (%r15,%r13)
movq 0x8(%rsp), %rax
cmpb $0x0, (%rax)
je 0x1a6f
movq 0x257d(%rip), %rdi      # 0x3fd8
leaq 0x662(%rip), %rsi       # 0x20c4
callq 0x1090
movq %rax, %rdi
callq 0x1050
incq %r13
jmp 0x1a1c
leaq 0x10(%rsp), %rbx
movq %rbx, %rdi
callq 0x125c
leaq 0x65a(%rip), %rdx       # 0x20e2
movq %r15, %rdi
movl %eax, %esi
callq 0x1854
movq %rbx, %rdi
movq %r15, %rsi
callq 0x15c6
movq %rbx, %rdi
callq 0x125c
leaq 0x642(%rip), %rdx       # 0x20ee
movq %r15, %rdi
movl %eax, %esi
callq 0x1854
xorl %eax, %eax
addq $0x1068, %rsp           # imm = 0x1068
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x2507(%rip), %rdi      # 0x3fd8
leaq 0x568(%rip), %rsi       # 0x2040
jmp 0x1954