// File: jeffchan[P]blockchain-parser/BlockChain.cpp
// Function: BitcoinTransactionFactory::gatherAddresses()
void gatherAddresses(void)
	{
		delete []mTransactionReferences;
		mTransactionReferences = NULL;

		for (uint32_t i=0; i<mAddresses.size(); i++)
		{
			BitcoinAddress *ba = mAddresses.getKey(i);
			ba->mTransactionCount = 0;
			ba->mTransactionIndex = 0xFFFFFFFF;
			ba->mTransactions = NULL;
			ba->mLastInputTime = 0;
			ba->mLastOutputTime = 0;
			ba->mFirstOutputTime = 0;
			ba->mTotalReceived = 0;
			ba->mTotalSent = 0;
			ba->mInputCount = 0;
			ba->mOutputCount = 0;
		}

		uint32_t transactionReferenceCount=0;

		// ok..we.now it's time to add all transactions to all addresses...
		for (uint32_t i=0; i<mTransactionCount; i++)
		{
			Transaction &t = mTransactions[i];
			for (uint32_t j=0; j<t.mOutputCount; j++)
			{
				TransactionOutput &o = t.mOutputs[j];
				BitcoinAddress *ba = getAddress(o.mAddress);
				countTransaction(ba,i,transactionReferenceCount);
			}
			for (uint32_t j=0; j<t.mInputCount; j++)
			{
				TransactionInput &input = t.mInputs[j];
				if ( input.mOutput )
				{
					TransactionOutput &o = *input.mOutput;
					BitcoinAddress *ba = getAddress(o.mAddress);
					countTransaction(ba,i,transactionReferenceCount);
				}
			}
		}

		mTransactionReferences = new Transaction*[transactionReferenceCount];
		transactionReferenceCount=0;
		for (uint32_t i=0; i<mAddresses.size(); i++)
		{
			BitcoinAddress *ba = mAddresses.getKey(i);
			ba->mTransactions = &mTransactionReferences[transactionReferenceCount];
			transactionReferenceCount+=ba->mTransactionCount;
			ba->mTransactionIndex = 0xFFFFFFFF; // which transaction we have stored yet so far...
			ba->mTransactionCount = 0;
		}

		// ok..we.now it's time to add all transactions to all addresses...
		for (uint32_t i=0; i<mTransactionCount; i++)
		{
			Transaction &t = mTransactions[i];

			for (uint32_t j=0; j<t.mOutputCount; j++)
			{
				TransactionOutput &o = t.mOutputs[j];
				BitcoinAddress *ba = getAddress(o.mAddress);
				if ( ba )
				{
					gatherTransaction(ba,&t,i);
					ba->mTotalReceived+=o.mValue;
					ba->mOutputCount++;
					if ( t.mTime > ba->mLastOutputTime ) // if the transaction time is more recnet than the last output time..
					{
						ba->mLastOutputTime = t.mTime;
						if ( ba->mFirstOutputTime == 0 ) // if this is the first output encountered, then mark it as the first output time.
						{
							ba->mFirstOutputTime = t.mTime;
						}
					}

				}
			}

			for (uint32_t j=0; j<t.mInputCount; j++)
			{
				TransactionInput &input = t.mInputs[j];

				if ( input.mOutput )
				{
					TransactionOutput &o = *input.mOutput;
					BitcoinAddress *ba = getAddress(o.mAddress);
					if ( ba )
					{
						gatherTransaction(ba,&t,i);
						ba->mTotalSent+=o.mValue;
						ba->mInputCount++;
						if ( t.mTime > ba->mLastInputTime ) // if the transaction time is newer than the last input/spent time..
						{
							ba->mLastInputTime = t.mTime;
						}
					}
				}

			}
		}
	}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xd0, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0xc8(%rbp)
movq 0x2000048(%rax), %rax
movq %rax, -0xc0(%rbp)
cmpq $0x0, %rax
je 0x1d41a
movq -0xc0(%rbp), %rdi
callq 0x21d0
movq -0xc8(%rbp), %rax
movq $0x0, 0x2000048(%rax)
movl $0x0, -0xc(%rbp)
movq -0xc8(%rbp), %rdi
movl -0xc(%rbp), %eax
movl %eax, -0xcc(%rbp)
callq 0x1d960
movl %eax, %ecx
movl -0xcc(%rbp), %eax
cmpl %ecx, %eax
jae 0x1d4ea
movq -0xc8(%rbp), %rdi
movl -0xc(%rbp), %esi
callq 0x1d360
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rax
movl $0x0, 0x3c(%rax)
movq -0x18(%rbp), %rax
movl $0xffffffff, 0x38(%rax) # imm = 0xFFFFFFFF
movq -0x18(%rbp), %rax
movq $0x0, 0x40(%rax)
movq -0x18(%rbp), %rax
movl $0x0, 0x14(%rax)
movq -0x18(%rbp), %rax
movl $0x0, 0x18(%rax)
movq -0x18(%rbp), %rax
movl $0x0, 0x1c(%rax)
movq -0x18(%rbp), %rax
movq $0x0, 0x28(%rax)
movq -0x18(%rbp), %rax
movq $0x0, 0x20(%rax)
movq -0x18(%rbp), %rax
movl $0x0, 0x30(%rax)
movq -0x18(%rbp), %rax
movl $0x0, 0x34(%rax)
movl -0xc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xc(%rbp)
jmp 0x1d433
movl $0x0, -0x1c(%rbp)
movl $0x0, -0x20(%rbp)
movq -0xc8(%rbp), %rcx
movl -0x20(%rbp), %eax
cmpl 0x2000010(%rcx), %eax
jae 0x1d615
movq -0xc8(%rbp), %rax
movq 0x2000020(%rax), %rax
movl -0x20(%rbp), %ecx
shlq $0x5, %rcx
addq %rcx, %rax
movq %rax, -0x28(%rbp)
movl $0x0, -0x2c(%rbp)
movl -0x2c(%rbp), %eax
movq -0x28(%rbp), %rcx
cmpl 0xc(%rcx), %eax
jae 0x1d58c
movq -0xc8(%rbp), %rdi
movq -0x28(%rbp), %rax
movq 0x18(%rax), %rax
movl -0x2c(%rbp), %ecx
shlq $0x4, %rcx
addq %rcx, %rax
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rax
movl 0x8(%rax), %esi
callq 0x1cc70
movq -0xc8(%rbp), %rdi
movq %rax, -0x40(%rbp)
movq -0x40(%rbp), %rsi
movl -0x20(%rbp), %edx
leaq -0x1c(%rbp), %rcx
callq 0x1d980
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0x1d531
movl $0x0, -0x44(%rbp)
movl -0x44(%rbp), %eax
movq -0x28(%rbp), %rcx
cmpl 0x8(%rcx), %eax
jae 0x1d605
movq -0x28(%rbp), %rax
movq 0x10(%rax), %rax
movl -0x44(%rbp), %ecx
shlq $0x3, %rcx
addq %rcx, %rax
movq %rax, -0x50(%rbp)
movq -0x50(%rbp), %rax
cmpq $0x0, (%rax)
je 0x1d5f8
movq -0xc8(%rbp), %rdi
movq -0x50(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x58(%rbp)
movq -0x58(%rbp), %rax
movl 0x8(%rax), %esi
callq 0x1cc70
movq -0xc8(%rbp), %rdi
movq %rax, -0x60(%rbp)
movq -0x60(%rbp), %rsi
movl -0x20(%rbp), %edx
leaq -0x1c(%rbp), %rcx
callq 0x1d980
jmp 0x1d5fa
movl -0x44(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x44(%rbp)
jmp 0x1d593
jmp 0x1d607
movl -0x20(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x20(%rbp)
jmp 0x1d4f8
movl -0x1c(%rbp), %eax
movl $0x8, %ecx
mulq %rcx
movq %rax, %rdi
seto %cl
movq $-0x1, %rax
testb $0x1, %cl
cmovneq %rax, %rdi
callq 0x2040
movq %rax, %rcx
movq -0xc8(%rbp), %rax
movq %rcx, 0x2000048(%rax)
movl $0x0, -0x1c(%rbp)
movl $0x0, -0x64(%rbp)
movq -0xc8(%rbp), %rdi
movl -0x64(%rbp), %eax
movl %eax, -0xd0(%rbp)
callq 0x1d960
movl %eax, %ecx
movl -0xd0(%rbp), %eax
cmpl %ecx, %eax
jae 0x1d6e0
movq -0xc8(%rbp), %rdi
movl -0x64(%rbp), %esi
callq 0x1d360
movq %rax, %rcx
movq -0xc8(%rbp), %rax
movq %rcx, -0x70(%rbp)
movq 0x2000048(%rax), %rcx
movl -0x1c(%rbp), %eax
shlq $0x3, %rax
addq %rax, %rcx
movq -0x70(%rbp), %rax
movq %rcx, 0x40(%rax)
movq -0x70(%rbp), %rax
movl 0x3c(%rax), %eax
addl -0x1c(%rbp), %eax
movl %eax, -0x1c(%rbp)
movq -0x70(%rbp), %rax
movl $0xffffffff, 0x38(%rax) # imm = 0xFFFFFFFF
movq -0x70(%rbp), %rax
movl $0x0, 0x3c(%rax)
movl -0x64(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x64(%rbp)
jmp 0x1d658
movl $0x0, -0x74(%rbp)
movq -0xc8(%rbp), %rcx
movl -0x74(%rbp), %eax
cmpl 0x2000010(%rcx), %eax
jae 0x1d92f
movq -0xc8(%rbp), %rax
movq 0x2000020(%rax), %rax
movl -0x74(%rbp), %ecx
shlq $0x5, %rcx
addq %rcx, %rax
movq %rax, -0x80(%rbp)
movl $0x0, -0x84(%rbp)
movl -0x84(%rbp), %eax
movq -0x80(%rbp), %rcx
cmpl 0xc(%rcx), %eax
jae 0x1d81c
movq -0xc8(%rbp), %rdi
movq -0x80(%rbp), %rax
movq 0x18(%rax), %rax
movl -0x84(%rbp), %ecx
shlq $0x4, %rcx
addq %rcx, %rax
movq %rax, -0x90(%rbp)
movq -0x90(%rbp), %rax
movl 0x8(%rax), %esi
callq 0x1cc70
movq %rax, -0x98(%rbp)
cmpq $0x0, -0x98(%rbp)
je 0x1d806
movq -0xc8(%rbp), %rdi
movq -0x98(%rbp), %rsi
movq -0x80(%rbp), %rdx
movl -0x74(%rbp), %ecx
callq 0x1d9d0
movq -0x90(%rbp), %rax
movq (%rax), %rcx
movq -0x98(%rbp), %rax
addq 0x28(%rax), %rcx
movq %rcx, 0x28(%rax)
movq -0x98(%rbp), %rax
movl 0x34(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x34(%rax)
movq -0x80(%rbp), %rax
movl 0x4(%rax), %eax
movq -0x98(%rbp), %rcx
cmpl 0x18(%rcx), %eax
jbe 0x1d804
movq -0x80(%rbp), %rax
movl 0x4(%rax), %ecx
movq -0x98(%rbp), %rax
movl %ecx, 0x18(%rax)
movq -0x98(%rbp), %rax
cmpl $0x0, 0x1c(%rax)
jne 0x1d802
movq -0x80(%rbp), %rax
movl 0x4(%rax), %ecx
movq -0x98(%rbp), %rax
movl %ecx, 0x1c(%rax)
jmp 0x1d804
jmp 0x1d806
jmp 0x1d808
movl -0x84(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x84(%rbp)
jmp 0x1d723
movl $0x0, -0x9c(%rbp)
movl -0x9c(%rbp), %eax
movq -0x80(%rbp), %rcx
cmpl 0x8(%rcx), %eax
jae 0x1d91f
movq -0x80(%rbp), %rax
movq 0x10(%rax), %rax
movl -0x9c(%rbp), %ecx
shlq $0x3, %rcx
addq %rcx, %rax
movq %rax, -0xa8(%rbp)
movq -0xa8(%rbp), %rax
cmpq $0x0, (%rax)
je 0x1d909
movq -0xc8(%rbp), %rdi
movq -0xa8(%rbp), %rax
movq (%rax), %rax
movq %rax, -0xb0(%rbp)
movq -0xb0(%rbp), %rax
movl 0x8(%rax), %esi
callq 0x1cc70
movq %rax, -0xb8(%rbp)
cmpq $0x0, -0xb8(%rbp)
je 0x1d907
movq -0xc8(%rbp), %rdi
movq -0xb8(%rbp), %rsi
movq -0x80(%rbp), %rdx
movl -0x74(%rbp), %ecx
callq 0x1d9d0
movq -0xb0(%rbp), %rax
movq (%rax), %rcx
movq -0xb8(%rbp), %rax
addq 0x20(%rax), %rcx
movq %rcx, 0x20(%rax)
movq -0xb8(%rbp), %rax
movl 0x30(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x30(%rax)
movq -0x80(%rbp), %rax
movl 0x4(%rax), %eax
movq -0xb8(%rbp), %rcx
cmpl 0x14(%rcx), %eax
jbe 0x1d905
movq -0x80(%rbp), %rax
movl 0x4(%rax), %ecx
movq -0xb8(%rbp), %rax
movl %ecx, 0x14(%rax)
jmp 0x1d907
jmp 0x1d909
jmp 0x1d90b
movl -0x9c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x9c(%rbp)
jmp 0x1d826
jmp 0x1d921
movl -0x74(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x74(%rbp)
jmp 0x1d6e7
addq $0xd0, %rsp
popq %rbp
retq
nopl (%rax,%rax)