// File: /workspace/github_cpp_makefile_star2_O3/jeffchan[P]blockchain-parser/BlockChain.cpp
// Function: BitcoinTransactionFactory::saveAddressesOverTime()
void saveAddressesOverTime(void)
	{
		FILE *fph = fopen("BlockChainAddresses.bin", "wb");
		if ( fph )
		{
			const char *header = "BLOCK_CHAIN_ADDRESSES";
			fwrite(header,strlen(header)+1,1,fph);
			uint32_t version = 1;
			fwrite(&version, sizeof(version), 1, fph );

			// first..we need to count how many addresses are being used for this report.
			uint32_t *addressIndex = new uint32_t[mAddresses.size()];	// convert from master address list to used by statistics address list table
			uint32_t *inverseAddress = new uint32_t[mAddresses.size()]; // convert from remapped list back to master address.

			memset(addressIndex,0,sizeof(uint32_t)*mAddresses.size());
			memset(inverseAddress,0,sizeof(uint32_t)*mAddresses.size());

			uint32_t fcount = 0; // number of unique addresses found

			for (uint32_t i=0; i<mStatCount; i++)
			{
				StatRow &row = mStatistics[i];
				for (uint32_t i=0; i<row.mAddressCount; i++)
				{
					StatAddress &sa = row.mAddresses[i];
					assert( sa.mAddress	 );
					uint32_t a = sa.mAddress-1;
					assert( a < mAddresses.size() );
					if ( addressIndex[a] == 0 ) // if this is the first time we have encountered this address, then we add it to the forward and inverse lookup tables.
					{
						addressIndex[a] = fcount+1;
						inverseAddress[fcount] = a;
						fcount++;
					}
				}
			}
			// ok..now ready to write out the address headers.
			fwrite(&fcount,sizeof(fcount),1,fph);	// save how many unique addresses were found.
			// now write out the 20 byte public key address for each.
			for (uint32_t i=0; i<fcount; i++)
			{
				uint32_t a = inverseAddress[i]; // get the original address.
				BitcoinAddress *ba = mAddresses.getKey(a);
				fwrite(ba,20,1,fph);// write out the bitcoin address 160 bit public key (20 bytes long)
			}

			fwrite(&mStatCount, sizeof(mStatCount), 1, fph );

			for (uint32_t i=0; i<mStatCount; i++)
			{
				StatRow &row = mStatistics[i];
				fwrite(&row.mTime,sizeof(row.mTime),1, fph); // write out the time that this row was recorded...
				if ( i == 0 ) 
				{
					fwrite(&row.mAddressCount,sizeof(row.mAddressCount),1,fph);
				}
				else
				{
					fwrite(&row.mNewAddressCount,sizeof(row.mNewAddressCount),1,fph);
				}
				fwrite(&row.mChangeAddressCount,sizeof(row.mChangeAddressCount),1,fph);
				fwrite(&row.mDeleteAddressCount,sizeof(row.mDeleteAddressCount),1,fph);
			}

			for (uint32_t i=0; i<mStatCount; i++)
			{
				StatRow &row = mStatistics[i];
				if ( i == 0 )
				{
					for (uint32_t i=0; i<row.mAddressCount; i++)
					{
						StatAddress sa = row.mAddresses[i];
						sa.mAddress = addressIndex[sa.mAddress-1]; // convert to the new sequentially ordered hash
						fwrite(&sa,sizeof(sa),1,fph); // write it out...
					}
				}
				else
				{
					for (uint32_t i=0; i<row.mNewAddressCount; i++)
					{
						StatAddress sa = row.mNewAddresses[i];
						sa.mAddress = addressIndex[sa.mAddress-1]; // convert to the new sequentially ordered hash
						fwrite(&sa,sizeof(sa),1,fph); // write it out...
					}
					for (uint32_t i=0; i<row.mChangeAddressCount; i++)
					{
						StatAddress sa = row.mChangedAddresses[i];
						sa.mAddress = addressIndex[sa.mAddress-1]; // convert to the new sequentially ordered hash
						fwrite(&sa,sizeof(sa),1,fph); // write it out...
					}
					for (uint32_t i=0; i<row.mDeleteAddressCount; i++)
					{
						uint32_t da = row.mDeletedAddresses[i];
						uint32_t a = addressIndex[da-1];
						fwrite(&a,sizeof(uint32_t),1,fph);
					}
				}
			}
			delete []addressIndex;
			delete []inverseAddress;
			fclose(fph);
		}
	}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
movq %rdi, %r13
leaq 0x90dc(%rip), %rdi      # 0x18bb1
leaq 0x8b0e(%rip), %rsi      # 0x185ea
callq 0x21b0
testq %rax, %rax
je 0xff00
movq %rax, %rbx
leaq 0x90d5(%rip), %rdi      # 0x18bc9
movl $0x16, %esi
movl $0x1, %edx
movq %rax, %rcx
callq 0x22b0
leaq -0x78(%rbp), %rdi
movl $0x1, (%rdi)
movl $0x4, %esi
movl $0x1, %edx
movq %rbx, -0x30(%rbp)
movq %rbx, %rcx
callq 0x22b0
movl 0x2000000(%r13), %r12d
leaq (,%r12,4), %r14
movq %r14, %rdi
callq 0x2040
movq %rax, %r15
movq %r14, %rdi
callq 0x2040
movq %rax, -0x60(%rbp)
movq %r13, %rbx
xorl %r13d, %r13d
movq %r15, %rdi
xorl %esi, %esi
movq %r14, %rdx
callq 0x20b0
movq -0x60(%rbp), %rdi
xorl %esi, %esi
movq %r14, %rdx
movq %rdi, %r14
callq 0x20b0
movq %rbx, -0x58(%rbp)
movl 0x2000050(%rbx), %eax
testq %rax, %rax
je 0xfbfd
movq -0x58(%rbp), %rcx
addq $0x2000058, %rcx        # imm = 0x2000058
xorl %edx, %edx
xorl %r13d, %r13d
imulq $0x190, %rdx, %rsi      # imm = 0x190
movl 0x150(%rcx,%rsi), %edi
testq %rdi, %rdi
je 0xfbf5
addq %rcx, %rsi
movq 0x158(%rsi), %rsi
shlq $0x3, %rdi
leaq (%rdi,%rdi,2), %rdi
xorl %r8d, %r8d
movl (%rsi,%r8), %r9d
testl %r9d, %r9d
je 0xff0f
decl %r9d
cmpl %r12d, %r9d
jae 0xff2e
movl %r9d, %r10d
cmpl $0x0, (%r15,%r10,4)
jne 0xfbec
movl %r13d, %r11d
leal 0x1(%r13), %ebx
movl %ebx, (%r15,%r10,4)
movl %r9d, (%r14,%r11,4)
movl %ebx, %r13d
addq $0x18, %r8
cmpq %r8, %rdi
jne 0xfbb7
incq %rdx
cmpq %rax, %rdx
jne 0xfb8f
leaq -0x74(%rbp), %r14
movl %r13d, (%r14)
movl $0x4, %esi
movl $0x1, %edx
movq %r14, %rdi
movq -0x30(%rbp), %r12
movq %r12, %rcx
callq 0x22b0
movl (%r14), %r14d
testq %r14, %r14
movq -0x58(%rbp), %r13
je 0xfc68
xorl %ebx, %ebx
movq -0x60(%rbp), %rax
movl (%rax,%rbx,4), %eax
cmpl %eax, 0x2000000(%r13)
jbe 0xff4d
leaq (%rax,%rax,4), %rdi
shlq $0x4, %rdi
addq 0x2000008(%r13), %rdi
movl $0x14, %esi
movl $0x1, %edx
movq %r12, %rcx
callq 0x22b0
incq %rbx
cmpq %rbx, %r14
jne 0xfc2b
leaq 0x2000050(%r13), %rbx
movl $0x4, %esi
movl $0x1, %edx
movq %rbx, %rdi
movq %r12, %rcx
callq 0x22b0
cmpl $0x0, (%rbx)
je 0xfee6
movq %rbx, %rcx
leaq 0x2000058(%r13), %r14
xorl %r12d, %r12d
movq -0x30(%rbp), %rbx
movq %rcx, -0x68(%rbp)
leaq 0xc(%r14), %rdi
movl $0x4, %esi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x22b0
xorl %eax, %eax
testq %r12, %r12
setne %al
shll $0x4, %eax
leaq (%rax,%r14), %rdi
addq $0x150, %rdi            # imm = 0x150
movl $0x4, %esi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x22b0
leaq 0x168(%r14), %rdi
movl $0x4, %esi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x22b0
leaq 0x164(%r14), %rdi
movl $0x4, %esi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x22b0
movq -0x68(%rbp), %rcx
incq %r12
movl (%rcx), %eax
addq $0x190, %r14            # imm = 0x190
cmpq %rax, %r12
jb 0xfca2
testl %eax, %eax
je 0xfee6
addq $0x2000058, %r13        # imm = 0x2000058
xorl %ecx, %ecx
movq %r13, -0x58(%rbp)
imulq $0x190, %rcx, %r12      # imm = 0x190
addq %r13, %r12
movq %rcx, -0x70(%rbp)
testq %rcx, %rcx
je 0xfe68
cmpl $0x0, 0x160(%r12)
movq -0x30(%rbp), %r14
je 0xfdbb
xorl %r13d, %r13d
xorl %ebx, %ebx
movq 0x178(%r12), %rax
movups (%rax,%r13), %xmm0
movaps %xmm0, -0x50(%rbp)
movq 0x10(%rax,%r13), %rax
movq %rax, -0x40(%rbp)
movl -0x50(%rbp), %eax
decl %eax
movl (%r15,%rax,4), %eax
movl %eax, -0x50(%rbp)
movl $0x18, %esi
movl $0x1, %edx
leaq -0x50(%rbp), %rdi
movq %r14, %rcx
callq 0x22b0
incq %rbx
movl 0x160(%r12), %eax
addq $0x18, %r13
cmpq %rax, %rbx
jb 0xfd6b
cmpl $0x0, 0x168(%r12)
je 0xfe1b
xorl %r13d, %r13d
xorl %ebx, %ebx
movq 0x180(%r12), %rax
movups (%rax,%r13), %xmm0
movaps %xmm0, -0x50(%rbp)
movq 0x10(%rax,%r13), %rax
movq %rax, -0x40(%rbp)
movl -0x50(%rbp), %eax
decl %eax
movl (%r15,%rax,4), %eax
movl %eax, -0x50(%rbp)
movl $0x18, %esi
movl $0x1, %edx
leaq -0x50(%rbp), %rdi
movq %r14, %rcx
callq 0x22b0
incq %rbx
movl 0x168(%r12), %eax
addq $0x18, %r13
cmpq %rax, %rbx
jb 0xfdcb
cmpl $0x0, 0x164(%r12)
je 0xfecc
xorl %ebx, %ebx
movq 0x188(%r12), %rax
movl (%rax,%rbx,4), %eax
decl %eax
movl (%r15,%rax,4), %eax
movl %eax, -0x50(%rbp)
movl $0x4, %esi
movl $0x1, %edx
leaq -0x50(%rbp), %rdi
movq %r14, %rcx
callq 0x22b0
incq %rbx
movl 0x164(%r12), %eax
cmpq %rax, %rbx
jb 0xfe2c
jmp 0xfecc
cmpl $0x0, 0x150(%r12)
movq -0x30(%rbp), %r14
je 0xfecc
xorl %r13d, %r13d
xorl %ebx, %ebx
movq 0x158(%r12), %rax
movups (%rax,%r13), %xmm0
movaps %xmm0, -0x50(%rbp)
movq 0x10(%rax,%r13), %rax
movq %rax, -0x40(%rbp)
movl -0x50(%rbp), %eax
decl %eax
movl (%r15,%rax,4), %eax
movl %eax, -0x50(%rbp)
movl $0x18, %esi
movl $0x1, %edx
leaq -0x50(%rbp), %rdi
movq %r14, %rcx
callq 0x22b0
incq %rbx
movl 0x150(%r12), %eax
addq $0x18, %r13
cmpq %rax, %rbx
jb 0xfe7c
movq -0x70(%rbp), %rcx
incq %rcx
movq -0x68(%rbp), %rax
movl (%rax), %eax
cmpq %rax, %rcx
movq -0x58(%rbp), %r13
jb 0xfd40
movq %r15, %rdi
callq 0x2200
movq -0x60(%rbp), %rdi
callq 0x2200
movq -0x30(%rbp), %rdi
callq 0x2160
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x8cc9(%rip), %rdi      # 0x18bdf
leaq 0x78d3(%rip), %rsi      # 0x177f0
leaq 0x8cc7(%rip), %rcx      # 0x18beb
movl $0xf61, %edx            # imm = 0xF61
callq 0x20c0
leaq 0x8cee(%rip), %rdi      # 0x18c23
leaq 0x78b4(%rip), %rsi      # 0x177f0
leaq 0x8ca8(%rip), %rcx      # 0x18beb
movl $0xf63, %edx            # imm = 0xF63
callq 0x20c0
leaq 0x82a4(%rip), %rdi      # 0x181f8
leaq 0x7895(%rip), %rsi      # 0x177f0
leaq 0x82aa(%rip), %rcx      # 0x1820c
movl $0x143, %edx            # imm = 0x143
callq 0x20c0