// File: /workspace/github_cpp_makefile_star2_O1/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rdi, %rbx
movq 0x2000048(%rdi), %rdi
testq %rdi, %rdi
je 0xd34d
callq 0x21f0
movq $0x0, 0x2000048(%rbx)
movl 0x2000000(%rbx), %ecx
testq %rcx, %rcx
je 0xd3ad
movq 0x2000008(%rbx), %rax
addq $0x40, %rax
shlq $0x4, %rcx
leaq (%rcx,%rcx,4), %rcx
xorl %edx, %edx
xorps %xmm0, %xmm0
movabsq $-0x100000000, %rsi     # imm = 0xFFFFFFFF00000000
movl $0x0, -0x4(%rax,%rdx)
movq $0x0, (%rax,%rdx)
movups %xmm0, -0x2c(%rax,%rdx)
movups %xmm0, -0x1c(%rax,%rdx)
movq %rsi, -0xc(%rax,%rdx)
addq $0x50, %rdx
cmpq %rdx, %rcx
jne 0xd385
xorl %r14d, %r14d
cmpl $0x0, 0x2000010(%rbx)
je 0xd491
xorl %r15d, %r15d
movq %r14, -0x30(%rbp)
movq 0x2000020(%rbx), %rax
movq %r15, %rcx
shlq $0x5, %rcx
leaq (%rax,%rcx), %r12
cmpl $0x0, 0xc(%rax,%rcx)
je 0xd426
movl $0x8, %r13d
xorl %r14d, %r14d
movq 0x18(%r12), %rax
movl (%rax,%r13), %esi
movq %rbx, %rdi
callq 0xd236
testq %rax, %rax
je 0xd415
movl 0x38(%rax), %ecx
cmpq %rcx, %r15
je 0xd415
movl %r15d, 0x38(%rax)
incl 0x3c(%rax)
movq -0x30(%rbp), %rax
incl %eax
movq %rax, -0x30(%rbp)
incq %r14
movl 0xc(%r12), %eax
addq $0x10, %r13
cmpq %rax, %r14
jb 0xd3e6
cmpl $0x0, 0x8(%r12)
je 0xd474
xorl %r13d, %r13d
movq -0x30(%rbp), %r14
movq 0x10(%r12), %rax
movq (%rax,%r13,8), %rax
testq %rax, %rax
je 0xd465
movl 0x8(%rax), %esi
movq %rbx, %rdi
callq 0xd236
testq %rax, %rax
je 0xd465
movl 0x38(%rax), %ecx
cmpq %rcx, %r15
je 0xd465
movl %r15d, 0x38(%rax)
incl 0x3c(%rax)
incl %r14d
incq %r13
movl 0x8(%r12), %eax
cmpq %rax, %r13
jb 0xd435
jmp 0xd478
movq -0x30(%rbp), %r14
incq %r15
movl 0x2000010(%rbx), %eax
cmpq %rax, %r15
jb 0xd3c0
movl %r14d, %r14d
shlq $0x3, %r14
movq %r14, %rdi
callq 0x2040
movq %rax, 0x2000048(%rbx)
movl 0x2000000(%rbx), %edx
testq %rdx, %rdx
je 0xd4e3
movq 0x2000008(%rbx), %rcx
shlq $0x4, %rdx
leaq (%rdx,%rdx,4), %rdx
xorl %esi, %esi
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
xorl %r8d, %r8d
movl %r8d, %r9d
leaq (%rax,%r9,8), %r9
movq %r9, 0x40(%rcx,%rsi)
addl 0x3c(%rcx,%rsi), %r8d
movq %rdi, 0x38(%rcx,%rsi)
addq $0x50, %rsi
cmpq %rsi, %rdx
jne 0xd4c4
cmpl $0x0, 0x2000010(%rbx)
je 0xd5fb
xorl %r14d, %r14d
movq %rbx, -0x38(%rbp)
movq 0x2000020(%rbx), %rax
movq %r14, %rcx
shlq $0x5, %rcx
leaq (%rax,%rcx), %r15
cmpl $0x0, 0xc(%rax,%rcx)
je 0xd57d
movl $0x8, %r12d
xorl %r13d, %r13d
movq 0x18(%r15), %rbx
movl (%rbx,%r12), %esi
movq -0x38(%rbp), %rdi
callq 0xd236
testq %rax, %rax
je 0xd56d
movl 0x38(%rax), %ecx
cmpq %rcx, %r14
je 0xd54c
movl %r14d, 0x38(%rax)
movq 0x40(%rax), %rcx
movl 0x3c(%rax), %edx
movq %r15, (%rcx,%rdx,8)
leal 0x1(%rdx), %ecx
movl %ecx, 0x3c(%rax)
movq -0x8(%rbx,%r12), %rcx
addq %rcx, 0x28(%rax)
incl 0x34(%rax)
movl 0x4(%r15), %ecx
cmpl 0x18(%rax), %ecx
jbe 0xd56d
movl %ecx, 0x18(%rax)
cmpl $0x0, 0x1c(%rax)
jne 0xd56d
movl %ecx, 0x1c(%rax)
incq %r13
movl 0xc(%r15), %eax
addq $0x10, %r12
cmpq %rax, %r13
jb 0xd519
cmpl $0x0, 0x8(%r15)
movq -0x38(%rbp), %rbx
je 0xd5e9
xorl %r12d, %r12d
movq 0x10(%r15), %rax
movq (%rax,%r12,8), %r13
testq %r13, %r13
je 0xd5dd
movl 0x8(%r13), %esi
movq %rbx, %rdi
callq 0xd236
testq %rax, %rax
je 0xd5dd
movl 0x38(%rax), %ecx
cmpq %rcx, %r14
je 0xd5c6
movl %r14d, 0x38(%rax)
movq 0x40(%rax), %rcx
movl 0x3c(%rax), %edx
movq %r15, (%rcx,%rdx,8)
leal 0x1(%rdx), %ecx
movl %ecx, 0x3c(%rax)
movq (%r13), %rcx
addq %rcx, 0x20(%rax)
incl 0x30(%rax)
movl 0x4(%r15), %ecx
cmpl 0x14(%rax), %ecx
jbe 0xd5dd
movl %ecx, 0x14(%rax)
incq %r12
movl 0x8(%r15), %eax
cmpq %rax, %r12
jb 0xd58b
incq %r14
movl 0x2000010(%rbx), %eax
cmpq %rax, %r14
jb 0xd4f7
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq