// File: /workspace/github_cpp_makefile_star2_O1/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 0x9044(%rip), %rdi      # 0x18bb1
leaq 0x8a76(%rip), %rsi      # 0x185ea
callq 0x21a0
testq %rax, %rax
je 0xff8e
movq %rax, %rbx
leaq 0x903d(%rip), %rdi      # 0x18bc9
movl $0x16, %esi
movl $0x1, %edx
movq %rax, %rcx
callq 0x22b0
leaq -0x74(%rbp), %rdi
movl $0x1, (%rdi)
movl $0x4, %esi
movl $0x1, %edx
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, -0x38(%rbp)
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
movl $0x0, -0x2c(%rbp)
movq -0x38(%rbp), %rax
movl 0x2000050(%rax), %eax
testq %rax, %rax
je 0xfc8b
movq -0x38(%rbp), %rcx
addq $0x2000058, %rcx        # imm = 0x2000058
xorl %edx, %edx
xorl %r13d, %r13d
imulq $0x190, %rdx, %rdi      # imm = 0x190
movl 0x150(%rcx,%rdi), %esi
testl %esi, %esi
je 0xfc83
addq %rcx, %rdi
movq 0x158(%rdi), %rdi
movl (%rdi), %r8d
testl %r8d, %r8d
je 0xff9d
decl %r8d
cmpl %r12d, %r8d
jae 0xffc0
movl %r8d, %r9d
cmpl $0x0, (%r15,%r9,4)
jne 0xfc7b
movl %r13d, %r10d
leal 0x1(%r13), %r11d
movl %r11d, (%r15,%r9,4)
movl %r8d, (%r14,%r10,4)
movl %r11d, %r13d
addq $0x18, %rdi
decl %esi
jne 0xfc47
incq %rdx
cmpq %rax, %rdx
jne 0xfc2b
leaq -0x2c(%rbp), %r14
movl %r13d, (%r14)
movl $0x4, %esi
movl $0x1, %edx
movq %r14, %rdi
movq %rbx, %rcx
callq 0x22b0
movl (%r14), %r14d
testq %r14, %r14
movq -0x38(%rbp), %r13
je 0xfcf4
xorl %r12d, %r12d
movq -0x60(%rbp), %rax
movl (%rax,%r12,4), %eax
cmpl %eax, 0x2000000(%r13)
jbe 0xffe3
leaq (%rax,%rax,4), %rdi
shlq $0x4, %rdi
addq 0x2000008(%r13), %rdi
movl $0x14, %esi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x22b0
incq %r12
cmpl %r12d, %r14d
jne 0xfcb6
leaq 0x2000050(%r13), %r14
movl $0x4, %esi
movl $0x1, %edx
movq %r14, %rdi
movq %rbx, %rcx
callq 0x22b0
movq %r14, %rcx
cmpl $0x0, (%r14)
movq %r14, -0x68(%rbp)
je 0xfdb4
leaq 0x2000058(%r13), %r14
xorl %r12d, %r12d
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 0xfd2b
movq %rbx, -0x58(%rbp)
cmpl $0x0, (%rcx)
je 0xff74
addq $0x2000058, %r13        # imm = 0x2000058
xorl %ecx, %ecx
movq %r13, -0x38(%rbp)
imulq $0x190, %rcx, %r12      # imm = 0x190
addq %r13, %r12
movq %rcx, -0x70(%rbp)
testq %rcx, %rcx
je 0xfef6
cmpl $0x0, 0x160(%r12)
movq -0x58(%rbp), %r14
je 0xfe49
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 0xfdf9
cmpl $0x0, 0x168(%r12)
je 0xfea9
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 0xfe59
cmpl $0x0, 0x164(%r12)
je 0xff5a
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 0xfeba
jmp 0xff5a
cmpl $0x0, 0x150(%r12)
movq -0x58(%rbp), %r14
je 0xff5a
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 0xff0a
movq -0x70(%rbp), %rcx
incq %rcx
movq -0x68(%rbp), %rax
movl (%rax), %eax
cmpq %rax, %rcx
movq -0x38(%rbp), %r13
jb 0xfdce
movq %r15, %rdi
callq 0x21f0
movq -0x60(%rbp), %rdi
callq 0x21f0
movq -0x58(%rbp), %rdi
callq 0x2150
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl %r13d, -0x2c(%rbp)
leaq 0x8c37(%rip), %rdi      # 0x18bdf
leaq 0x7841(%rip), %rsi      # 0x177f0
leaq 0x8c35(%rip), %rcx      # 0x18beb
movl $0xf61, %edx            # imm = 0xF61
callq 0x20c0
movl %r13d, -0x2c(%rbp)
leaq 0x8c58(%rip), %rdi      # 0x18c23
leaq 0x781e(%rip), %rsi      # 0x177f0
leaq 0x8c12(%rip), %rcx      # 0x18beb
movl $0xf63, %edx            # imm = 0xF63
callq 0x20c0
leaq 0x820e(%rip), %rdi      # 0x181f8
leaq 0x77ff(%rip), %rsi      # 0x177f0
leaq 0x8214(%rip), %rcx      # 0x1820c
movl $0x143, %edx            # imm = 0x143
callq 0x20c0