// File: /workspace/github_cpp_makefile_star2_O3/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 0xd2c9
callq 0x2200
movq $0x0, 0x2000048(%rbx)
movl 0x2000000(%rbx), %r15d
testq %r15, %r15
je 0xd32d
movq 0x2000008(%rbx), %rax
addq $0x40, %rax
movq %r15, %rcx
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 0xd305
xorl %r14d, %r14d
cmpl $0x0, 0x2000010(%rbx)
je 0xd420
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 0xd3a6
movl $0x8, %r13d
xorl %r14d, %r14d
movq 0x18(%r12), %rax
movl (%rax,%r13), %esi
movq %rbx, %rdi
callq 0xd1b2
testq %rax, %rax
je 0xd395
movl 0x38(%rax), %ecx
cmpq %rcx, %r15
je 0xd395
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 0xd366
cmpl $0x0, 0x8(%r12)
je 0xd3f4
xorl %r13d, %r13d
movq -0x30(%rbp), %r14
movq 0x10(%r12), %rax
movq (%rax,%r13,8), %rax
testq %rax, %rax
je 0xd3e5
movl 0x8(%rax), %esi
movq %rbx, %rdi
callq 0xd1b2
testq %rax, %rax
je 0xd3e5
movl 0x38(%rax), %ecx
cmpq %rcx, %r15
je 0xd3e5
movl %r15d, 0x38(%rax)
incl 0x3c(%rax)
incl %r14d
incq %r13
movl 0x8(%r12), %eax
cmpq %rax, %r13
jb 0xd3b5
jmp 0xd3f8
movq -0x30(%rbp), %r14
incq %r15
movl 0x2000010(%rbx), %eax
cmpq %rax, %r15
jb 0xd340
movl 0x2000000(%rbx), %r15d
movl %r14d, %r14d
shlq $0x3, %r14
testl %eax, %eax
sete %r12b
jmp 0xd423
movb $0x1, %r12b
movq %r14, %rdi
callq 0x2040
movq %rax, 0x2000048(%rbx)
testl %r15d, %r15d
je 0xd472
movq 0x2000008(%rbx), %rcx
movl %r15d, %edx
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 0xd453
testb %r12b, %r12b
jne 0xd586
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 0xd508
movl $0x8, %r12d
xorl %r13d, %r13d
movq 0x18(%r15), %rbx
movl (%rbx,%r12), %esi
movq -0x38(%rbp), %rdi
callq 0xd1b2
testq %rax, %rax
je 0xd4f8
movl 0x38(%rax), %ecx
cmpq %rcx, %r14
je 0xd4d7
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 0xd4f8
movl %ecx, 0x18(%rax)
cmpl $0x0, 0x1c(%rax)
jne 0xd4f8
movl %ecx, 0x1c(%rax)
incq %r13
movl 0xc(%r15), %eax
addq $0x10, %r12
cmpq %rax, %r13
jb 0xd4a4
cmpl $0x0, 0x8(%r15)
movq -0x38(%rbp), %rbx
je 0xd574
xorl %r12d, %r12d
movq 0x10(%r15), %rax
movq (%rax,%r12,8), %r13
testq %r13, %r13
je 0xd568
movl 0x8(%r13), %esi
movq %rbx, %rdi
callq 0xd1b2
testq %rax, %rax
je 0xd568
movl 0x38(%rax), %ecx
cmpq %rcx, %r14
je 0xd551
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 0xd568
movl %ecx, 0x14(%rax)
incq %r12
movl 0x8(%r15), %eax
cmpq %rax, %r12
jb 0xd516
incq %r14
movl 0x2000010(%rbx), %eax
cmpq %rax, %r14
jb 0xd482
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop