// File: /workspace/github_cpp_makefile_star2_O3/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 0x129c
movq %r14, %rdi
callq 0x12ae
movl %eax, %r15d
movq %r14, %rdi
callq 0x12b4
addl %r15d, %eax
incl %eax
cmpl %ebp, %eax
jne 0x1ccb
cmpl $0x2, %ebp
jl 0x1ad4
movl %ebp, %r14d
movl $0x1, %r15d
movq (%rbx,%r15,8), %rdi
callq 0x1050
cmpq $0x2, %rax
jne 0x1ca9
incq %r15
cmpq %r15, %r14
jne 0x1ab9
leaq 0x10(%rsp), %r15
movq %r15, %rdi
callq 0x12b4
movl %eax, %edi
callq 0x1030
movq %rax, %r14
movq %r15, %rdi
callq 0x12b4
testl %eax, %eax
je 0x1b7c
xorl %ebp, %ebp
leaq 0x8(%rsp), %r15
leaq 0x10(%rsp), %r12
movq 0x24ca(%rip), %r13      # 0x3fd8
movq 0x8(%rbx,%rbp,8), %rdi
movq %r15, %rsi
movl $0x10, %edx
callq 0x1100
movb %al, (%r14,%rbp)
movq 0x8(%rsp), %rax
cmpb $0x0, (%rax)
je 0x1b6a
movl $0x17, %edx
movq %r13, %rdi
leaq 0x587(%rip), %rsi       # 0x20c4
callq 0x10d0
movq (%r13), %rax
movq -0x18(%rax), %rdi
addq %r13, %rdi
movl $0xa, %esi
callq 0x10b0
movsbl %al, %esi
movq %r13, %rdi
callq 0x1040
movq %rax, %rdi
callq 0x1080
incq %rbp
movq %r12, %rdi
callq 0x12b4
movl %eax, %eax
cmpq %rax, %rbp
jb 0x1b0e
leaq 0x10(%rsp), %r15
movq %r15, %rdi
callq 0x12b4
leaq 0x54c(%rip), %rdx       # 0x20dc
movq %r14, %rdi
movl %eax, %esi
callq 0x1974
movq %r15, %rdi
movq %r14, %rsi
callq 0x12ba
movq %r15, %rdi
callq 0x12ae
movl %eax, %edi
callq 0x1030
movq %rax, %r14
movq %r15, %rdi
callq 0x12ae
testl %eax, %eax
je 0x1c53
xorl %ebp, %ebp
leaq 0x10(%rsp), %r15
leaq 0x8(%rsp), %r12
movq 0x23fe(%rip), %r13      # 0x3fd8
movq %r15, %rdi
callq 0x12b4
addl %ebp, %eax
incl %eax
movq (%rbx,%rax,8), %rdi
movq %r12, %rsi
movl $0x10, %edx
callq 0x1100
movb %al, (%r14,%rbp)
movq 0x8(%rsp), %rax
cmpb $0x0, (%rax)
je 0x1c41
movl $0x17, %edx
movq %r13, %rdi
leaq 0x4b0(%rip), %rsi       # 0x20c4
callq 0x10d0
movq (%r13), %rax
movq -0x18(%rax), %rdi
addq %r13, %rdi
movl $0xa, %esi
callq 0x10b0
movsbl %al, %esi
movq %r13, %rdi
callq 0x1040
movq %rax, %rdi
callq 0x1080
incq %rbp
movq %r15, %rdi
callq 0x12ae
movl %eax, %eax
cmpq %rax, %rbp
jb 0x1bda
leaq 0x10(%rsp), %rbx
movq %rbx, %rdi
callq 0x12ae
leaq 0x47b(%rip), %rdx       # 0x20e2
movq %r14, %rdi
movl %eax, %esi
callq 0x1974
movq %rbx, %rdi
movq %r14, %rsi
callq 0x16a8
movq %rbx, %rdi
callq 0x12ae
leaq 0x463(%rip), %rdx       # 0x20ee
movq %r14, %rdi
movl %eax, %esi
callq 0x1974
xorl %eax, %eax
addq $0x1068, %rsp           # imm = 0x1068
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x2328(%rip), %rdi      # 0x3fd8
leaq 0x3eb(%rip), %rsi       # 0x20a2
callq 0x10c0
movq %rax, %rdi
callq 0x1060
xorl %edi, %edi
callq 0x10e0
movq 0x2306(%rip), %rdi      # 0x3fd8
leaq 0x367(%rip), %rsi       # 0x2040
jmp 0x1cb7