// File: /workspace/github_cpp_makefile_star2_O1/jeffchan[P]blockchain-parser/BlockChain.cpp
// Function: BitcoinTransactionFactory::printTopBalances(unsigned int, unsigned int)
void printTopBalances(uint32_t tcount,uint32_t minBalance)
	{
		uint32_t plotCount = 0;
		uint64_t mbtc = minBalance*ONE_BTC;
		for (uint32_t i=0; i<mAddresses.size(); i++) // print one in every 10,000 addresses (just for testing right now)
		{
			BitcoinAddress *ba = mAddresses.getKey(i);
			uint64_t balance = ba->getBalance();
			if ( balance >= mbtc )
			{
				plotCount++;
			}
		}

		if ( !plotCount )
		{
			printf("No addresses found with a balance more than %d bitcoins\r\n", minBalance );
			return;
		}

		BitcoinAddress **sortPointers = new BitcoinAddress*[plotCount];
		plotCount = 0;
		for (uint32_t i=0; i<mAddresses.size(); i++) // print one in every 10,000 addresses (just for testing right now)
		{
			BitcoinAddress *ba = mAddresses.getKey(i);
			uint64_t balance = ba->getBalance();
			if ( balance >= mbtc )
			{
				sortPointers[plotCount] = ba;
				plotCount++;
			}
		}
		SortByBalance sb(sortPointers,plotCount);
		time_t currentTime;
		time(&currentTime); // get the current time.

		if ( plotCount < tcount )
		{
			tcount = plotCount;
		}
		printf("Displaying the top %d addresses by balance.\r\n", tcount );
		printf("==============================================\r\n");
		printf(" Address           : Balance  : Days Since Last Use\r\n");
		printf("==============================================\r\n");
		for (uint32_t i=0; i<tcount; i++)
		{
			BitcoinAddress *ba = sortPointers[i];
			uint64_t balance = ba->mTotalReceived-ba->mTotalSent;
			uint32_t lastUsed = ba->mLastInputTime; // the last time we sent money (not received because anyone can send us money).
			if ( ba->mLastInputTime == 0 ) // if it has never had a spend.. then we use the time of first receive..
			{
				lastUsed = ba->mFirstOutputTime;
			}
			double seconds = difftime(currentTime,time_t(lastUsed));
			double minutes = seconds/60;
			double hours = minutes/60;
			uint32_t days = (uint32_t) (hours/24);
			uint32_t adr = mAddresses.getIndex(ba)+1;
			printf("%40s,  %8d,  %4d\r\n", getKey(adr), (uint32_t)( balance / ONE_BTC ), days );
		}
		delete []sortPointers;
	}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movl %esi, %r14d
movq %rdi, %rbx
imull $0x5f5e100, %edx, %r15d # imm = 0x5F5E100
movl 0x2000000(%rdi), %r13d
testq %r13, %r13
je 0x10aaf
movq 0x2000008(%rbx), %rcx
movq %r13, %rax
shlq $0x4, %rax
leaq (%rax,%rax,4), %rsi
xorl %edi, %edi
xorl %eax, %eax
movq 0x28(%rcx,%rdi), %r8
subq 0x20(%rcx,%rdi), %r8
cmpq %r15, %r8
sbbl $-0x1, %eax
addq $0x50, %rdi
cmpq %rdi, %rsi
jne 0x10a94
jmp 0x10ab1
xorl %eax, %eax
testl %eax, %eax
je 0x10af9
movl %eax, %edi
shlq $0x3, %rdi
callq 0x2040
movq %rax, -0x30(%rbp)
testq %r13, %r13
je 0x10b17
movq 0x2000008(%rbx), %rax
xorl %r12d, %r12d
movq -0x30(%rbp), %rdx
movq 0x28(%rax), %rcx
subq 0x20(%rax), %rcx
cmpq %r15, %rcx
jb 0x10aee
movl %r12d, %ecx
movq %rax, (%rdx,%rcx,8)
incl %r12d
addq $0x50, %rax
decq %r13
jne 0x10ad7
jmp 0x10b1a
leaq 0x86a4(%rip), %rdi      # 0x191a4
movl %edx, %esi
xorl %eax, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x2050
xorl %r12d, %r12d
movq %rbx, -0x38(%rbp)
leaq 0xe0bb(%rip), %rax      # 0x1ebe0
leaq -0x48(%rbp), %rdi
movq %rax, (%rdi)
movq -0x30(%rbp), %rsi
movl %r12d, %edx
callq 0xb372
leaq -0x40(%rbp), %rdi
callq 0x2120
cmpl %r14d, %r12d
movl %r14d, %r13d
cmovbl %r12d, %r13d
leaq 0x868c(%rip), %rdi      # 0x191de
movl %r13d, %esi
xorl %eax, %eax
callq 0x2050
leaq 0x8de0(%rip), %r15      # 0x19943
movq %r15, %rdi
callq 0x2260
leaq 0x903c(%rip), %rdi      # 0x19bae
callq 0x2260
movq %r15, %rdi
callq 0x2260
testl %r13d, %r13d
je 0x10c33
movl %r12d, %eax
movl %r14d, %r15d
cmpq %r15, %rax
cmovbq %rax, %r15
xorl %r14d, %r14d
movq -0x30(%rbp), %rax
movq (%rax,%r14,8), %rbx
movl 0x14(%rbx), %eax
testl %eax, %eax
jne 0x10baa
movl 0x1c(%rbx), %eax
testq %rbx, %rbx
je 0x10c4b
movq 0x28(%rbx), %r12
subq 0x20(%rbx), %r12
movq -0x40(%rbp), %rdi
movl %eax, %esi
callq 0x20a0
movsd 0x6c12(%rip), %xmm1     # 0x177e0
divsd %xmm1, %xmm0
divsd %xmm1, %xmm0
divsd 0x6c0a(%rip), %xmm0     # 0x177e8
cvttsd2si %xmm0, %r13
movq -0x38(%rbp), %rdi
subq 0x2000008(%rdi), %rbx
shrq $0x4, %rbx
imull $0xcccccccd, %ebx, %esi # imm = 0xCCCCCCCD
incl %esi
callq 0xe040
movq %rax, %rsi
movq %r12, %rax
movabsq $-0x543388ee7b9e3103, %rcx # imm = 0xABCC77118461CEFD
mulq %rcx
shrq $0x1a, %rdx
leaq 0x85ef(%rip), %rdi      # 0x1920c
movl %r13d, %ecx
xorl %eax, %eax
callq 0x2050
incq %r14
cmpl %r14d, %r15d
jne 0x10b98
movq -0x30(%rbp), %rdi
callq 0x21f0
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x9585(%rip), %rdi      # 0x1a1d7
leaq 0x6b97(%rip), %rsi      # 0x177f0
leaq 0x7477(%rip), %rcx      # 0x180d7
movl $0x13b, %edx            # imm = 0x13B
callq 0x20c0