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

    if (argc != 2) {
        cout << "usage: Profile <num-iterations>" << endl;
        return 0;
    }

    string str(argv[1]);
    istringstream is(str);
    uint32_t numIter = 0;
    is >> numIter;

    uint8_t* key = new uint8_t[ b.keySize() ];
    
    for( unsigned int i = 0; i < b.keySize(); i++ ){
        key[ i ] = 0x00;
    }
    
    time_t start = time(NULL) * 1000;
    print_uint8_hex(key, b.keySize(), "Key: ");
    b.setKey( key );


    uint8_t* text;// = new uint8_t[ b.blockSize() ];
    for (unsigned int i = 0; i < numIter; i++) {
        text = new uint8_t[ b.blockSize() ];
    
        for( unsigned int i = 0; i < b.blockSize(); i++ ){
            text[ i ] = 0x00;
        }

        b.encrypt( text );
        delete[] text;
    }
    time_t end = time(NULL) * 1000;

    cout << "Running Time: " << (end - start) << " msec" << endl;
    //print_uint8_hex(text, b.blockSize(), "Plaintext");
    //print_uint8_hex(text, b.blockSize(), "Ciphertext");
    
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x1208, %rsp           # imm = 0x1208
movq %rsi, %rbx
movl %edi, %ebp
leaq 0x1b0(%rsp), %rdi
callq 0x22ec
cmpl $0x2, %ebp
jne 0x29e3
movq 0x8(%rbx), %rsi
leaq 0x10(%rsp), %rbx
leaq 0x30(%rsp), %rdx
movq %rbx, %rdi
callq 0x2b32
leaq 0x30(%rsp), %rdi
pushq $0x8
popq %rdx
movq %rbx, %rsi
callq 0x2140
leaq 0xc(%rsp), %rsi
andl $0x0, (%rsi)
leaq 0x30(%rsp), %rdi
callq 0x2160
leaq 0x1b0(%rsp), %rdi
callq 0x2300
movl %eax, %edi
callq 0x2030
movq %rax, %r14
xorl %r15d, %r15d
leaq 0x1b0(%rsp), %rbx
movq %rbx, %rdi
callq 0x2300
movl %eax, %eax
cmpq %rax, %r15
jae 0x2a03
movb $0x0, (%r14,%r15)
incq %r15
jmp 0x29ca
movq 0x25ee(%rip), %rdi      # 0x4fd8
leaq 0x65a(%rip), %rsi       # 0x304b
callq 0x20f0
movq %rax, %rdi
callq 0x2080
jmp 0x2aed
xorl %edi, %edi
callq 0x20d0
movq %rax, %rbx
leaq 0x1b0(%rsp), %rdi
callq 0x2300
leaq 0x64a(%rip), %rdx       # 0x306b
movq %r14, %rdi
movl %eax, %esi
callq 0x28f4
leaq 0x1b0(%rsp), %rdi
movq %r14, %rsi
callq 0x2304
xorl %r12d, %r12d
leaq 0x1b0(%rsp), %r14
cmpl 0xc(%rsp), %r12d
jae 0x2a93
movq %r14, %rdi
callq 0x22fc
movl %eax, %edi
callq 0x2030
movq %rax, %r15
xorl %r13d, %r13d
movq %r14, %rdi
callq 0x22fc
movl %eax, %eax
cmpq %rax, %r13
jae 0x2a7b
movb $0x0, (%r15,%r13)
incq %r13
jmp 0x2a62
movq %r14, %rdi
movq %r15, %rsi
callq 0x2666
movq %r15, %rdi
callq 0x2100
incl %r12d
jmp 0x2a46
xorl %edi, %edi
callq 0x20d0
movq %rax, %r14
movq 0x2534(%rip), %rdi      # 0x4fd8
leaq 0x5c6(%rip), %rsi       # 0x3071
callq 0x20f0
subq %rbx, %r14
imulq $0x3e8, %r14, %rsi      # imm = 0x3E8
movq %rax, %rdi
callq 0x20e0
leaq 0x5b7(%rip), %rsi       # 0x3080
movq %rax, %rdi
callq 0x20f0
movq %rax, %rdi
callq 0x2080
leaq 0x30(%rsp), %rdi
callq 0x2070
leaq 0x10(%rsp), %rdi
callq 0x2060
xorl %eax, %eax
addq $0x1208, %rsp           # imm = 0x1208
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x2b12
movq %rax, %rbx
jmp 0x2b1f
jmp 0x2b12
jmp 0x2b12
jmp 0x2b12
jmp 0x2b12
jmp 0x2b12
movq %rax, %rbx
leaq 0x30(%rsp), %rdi
callq 0x2070
leaq 0x10(%rsp), %rdi
callq 0x2060
movq %rbx, %rdi
callq 0x2170
nop