// File: /workspace/github_cpp_makefile_star2_O1/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 0x231c
cmpl $0x2, %ebp
jne 0x2b0c
movq 0x8(%rbx), %rsi
leaq 0x10(%rsp), %rbx
leaq 0x30(%rsp), %rdx
movq %rbx, %rdi
callq 0x2d00
leaq 0x30(%rsp), %rdi
movq %rbx, %rsi
movl $0x8, %edx
callq 0x2170
leaq 0xc(%rsp), %rsi
movl $0x0, (%rsi)
leaq 0x30(%rsp), %rdi
callq 0x2190
leaq 0x1b0(%rsp), %rdi
callq 0x2334
movl %eax, %edi
callq 0x2030
movq %rax, %r14
xorl %r15d, %r15d
leaq 0x1b0(%rsp), %rbx
movq %rbx, %rdi
callq 0x2334
movl %eax, %eax
cmpq %rax, %r15
jae 0x2b53
movb $0x0, (%r14,%r15)
incq %r15
jmp 0x2af3
movq 0x24c5(%rip), %rbx      # 0x4fd8
leaq 0x531(%rip), %rsi       # 0x304b
movl $0x1f, %edx
movq %rbx, %rdi
callq 0x2110
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x20f0
movsbl %al, %esi
movq %rbx, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x2080
jmp 0x2c97
xorl %edi, %edi
callq 0x20d0
movq %rax, %rbx
leaq 0x1b0(%rsp), %rdi
callq 0x2334
leaq 0x4fa(%rip), %rdx       # 0x306b
movq %r14, %rdi
movl %eax, %esi
callq 0x2a14
leaq 0x1b0(%rsp), %rdi
movq %r14, %rsi
callq 0x233a
cmpl $0x0, 0xc(%rsp)
je 0x2be8
xorl %r12d, %r12d
leaq 0x1b0(%rsp), %r14
movq %r14, %rdi
callq 0x232e
movl %eax, %edi
callq 0x2030
movq %rax, %r15
xorl %r13d, %r13d
movq %r14, %rdi
callq 0x232e
movl %eax, %eax
cmpq %rax, %r13
jae 0x2bcb
movb $0x0, (%r15,%r13)
incq %r13
jmp 0x2bb2
movq %r14, %rdi
movq %r15, %rsi
callq 0x2728
movq %r15, %rdi
callq 0x2120
incl %r12d
cmpl 0xc(%rsp), %r12d
jb 0x2b9d
xorl %edi, %edi
callq 0x20d0
movq %rax, %r14
movq 0x23df(%rip), %rdi      # 0x4fd8
leaq 0x471(%rip), %rsi       # 0x3071
movl $0xe, %edx
callq 0x2110
subq %rbx, %r14
imulq $0x3e8, %r14, %rsi      # imm = 0x3E8
movq 0x23bd(%rip), %rdi      # 0x4fd8
callq 0x20e0
movq %rax, %rbx
leaq 0x456(%rip), %rsi       # 0x3080
movl $0x5, %edx
movq %rax, %rdi
callq 0x2110
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x20f0
movsbl %al, %esi
movq %rbx, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x2080
movq 0x236b(%rip), %rsi      # 0x4fd0
leaq 0x30(%rsp), %rdi
callq 0x2150
leaq 0xa8(%rsp), %rdi
callq 0x2060
leaq 0x20(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x2c97
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x2100
xorl %eax, %eax
addq $0x1208, %rsp           # imm = 0x1208
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x2cbc
movq %rax, %rbx
jmp 0x2cdd
jmp 0x2cbc
jmp 0x2cbc
jmp 0x2cbc
jmp 0x2cbc
jmp 0x2cbc
movq %rax, %rbx
movq 0x230a(%rip), %rsi      # 0x4fd0
leaq 0x30(%rsp), %rdi
callq 0x2150
leaq 0xa8(%rsp), %rdi
callq 0x2060
leaq 0x20(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x2cf8
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x2100
movq %rbx, %rdi
callq 0x21a0