// File: jeffchan[P]blockchain-parser/BlockChain.cpp
// Function: BlockChainImpl::readSingleTransaction(unsigned char const*)
virtual const BlockTransaction *readSingleTransaction(const uint8_t *transactionHash) 
	{
		const BlockTransaction *ret = NULL;

		Hash256 h(transactionHash);
		FileLocation key(h,0,0,0,0);
		FileLocation *found = mTransactionMap.find(key);
		if ( found == NULL )
		{
			printf("ERROR: Unable to locate this transaction hash:");
			printReverseHash(transactionHash);
			printf("\r\n");
			return NULL; 
		}
		const FileLocation &f = *found;
		uint32_t fileIndex = f.mFileIndex;
		uint32_t fileOffset = f.mFileOffset;
		uint32_t transactionLength = f.mFileLength;

		if ( fileIndex < MAX_BLOCK_FILES && mBlockChain[fileIndex] && transactionLength < MAX_BLOCK_SIZE )
		{
			FILE *fph = mBlockChain[fileIndex];
			uint32_t saveLocation = (uint32_t)ftell(fph);
			fseek(fph,fileOffset,SEEK_SET);
			uint32_t s = (uint32_t)ftell(fph);
			if ( s == fileOffset )
			{
				uint8_t *blockData = mTransactionBlockBuffer;
				size_t r = fread(blockData,transactionLength,1,fph);
				if ( r == 1 ) // if we successfully read in the entire transaction
				{
					ret = processSingleTransaction(blockData,transactionLength);
					if ( ret )
					{
						BlockTransaction *t = (BlockTransaction *)ret;
						t->transactionIndex = f.mTransactionIndex;
						t->fileIndex = fileIndex;
						t->fileOffset = fileOffset;
					}
				}
				else
				{
					assert(0);
				}
			}
			else
			{
				assert(0);
			}
			fseek(fph,saveLocation,SEEK_SET); // restore the file position back to it's previous location.
		}
		else
		{
			assert(0);
		}
		return ret;
	}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xc0, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0xc0(%rbp)
movq $0x0, -0x20(%rbp)
movq -0x18(%rbp), %rsi
leaq -0x40(%rbp), %rdi
callq 0x1c660
leaq -0x70(%rbp), %rdi
leaq -0x40(%rbp), %rsi
xorl %r9d, %r9d
movl %r9d, %edx
movl %r9d, %ecx
movl %r9d, %r8d
callq 0x1c6a0
movq -0xc0(%rbp), %rdi
addq $0x16f12f0, %rdi        # imm = 0x16F12F0
leaq -0x70(%rbp), %rsi
callq 0x1c700
movq %rax, -0x78(%rbp)
cmpq $0x0, -0x78(%rbp)
jne 0x1b1e7
leaq 0x16177(%rip), %rdi     # 0x3132c
movb $0x0, %al
callq 0x2050
movq -0xc0(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x1c5f0
leaq 0x16249(%rip), %rdi     # 0x3141c
movb $0x0, %al
callq 0x2050
movq $0x0, -0x8(%rbp)
jmp 0x1b3e4
movq -0x78(%rbp), %rax
movq %rax, -0x80(%rbp)
movq -0x80(%rbp), %rax
movl 0x20(%rax), %eax
movl %eax, -0x84(%rbp)
movq -0x80(%rbp), %rax
movl 0x24(%rax), %eax
movl %eax, -0x88(%rbp)
movq -0x80(%rbp), %rax
movl 0x28(%rax), %eax
movl %eax, -0x8c(%rbp)
cmpl $0x200, -0x84(%rbp)     # imm = 0x200
jae 0x1b3bd
movq -0xc0(%rbp), %rax
movl -0x84(%rbp), %ecx
cmpq $0x0, 0x208(%rax,%rcx,8)
je 0x1b3bd
cmpl $0xa00000, -0x8c(%rbp)  # imm = 0xA00000
jae 0x1b3bd
movq -0xc0(%rbp), %rax
movl -0x84(%rbp), %ecx
movq 0x208(%rax,%rcx,8), %rax
movq %rax, -0x98(%rbp)
movq -0x98(%rbp), %rdi
callq 0x2030
movl %eax, -0x9c(%rbp)
movq -0x98(%rbp), %rdi
movl -0x88(%rbp), %eax
movl %eax, %esi
xorl %edx, %edx
callq 0x2170
movq -0x98(%rbp), %rdi
callq 0x2030
movl %eax, -0xa0(%rbp)
movl -0xa0(%rbp), %eax
cmpl -0x88(%rbp), %eax
jne 0x1b386
movq -0xc0(%rbp), %rax
addq $0xcf12e8, %rax         # imm = 0xCF12E8
movq %rax, -0xa8(%rbp)
movq -0xa8(%rbp), %rdi
movl -0x8c(%rbp), %eax
movl %eax, %esi
movq -0x98(%rbp), %rcx
movl $0x1, %edx
callq 0x2220
movq %rax, -0xb0(%rbp)
cmpq $0x1, -0xb0(%rbp)
jne 0x1b365
movq -0xc0(%rbp), %rdi
movq -0xa8(%rbp), %rsi
movl -0x8c(%rbp), %edx
movq (%rdi), %rax
callq *0xc0(%rax)
movq %rax, -0x20(%rbp)
cmpq $0x0, -0x20(%rbp)
je 0x1b363
movq -0x20(%rbp), %rax
movq %rax, -0xb8(%rbp)
movq -0x80(%rbp), %rax
movl 0x2c(%rax), %ecx
movq -0xb8(%rbp), %rax
movl %ecx, 0x50(%rax)
movl -0x84(%rbp), %ecx
movq -0xb8(%rbp), %rax
movl %ecx, 0x48(%rax)
movl -0x88(%rbp), %ecx
movq -0xb8(%rbp), %rax
movl %ecx, 0x4c(%rax)
jmp 0x1b384
leaq 0x15f45(%rip), %rdi     # 0x312b1
leaq 0x158dd(%rip), %rsi     # 0x30c50
movl $0x12e0, %edx           # imm = 0x12E0
leaq 0x15fdc(%rip), %rcx     # 0x3135b
callq 0x20c0
jmp 0x1b3a5
leaq 0x15f24(%rip), %rdi     # 0x312b1
leaq 0x158bc(%rip), %rsi     # 0x30c50
movl $0x12e5, %edx           # imm = 0x12E5
leaq 0x15fbb(%rip), %rcx     # 0x3135b
callq 0x20c0
movq -0x98(%rbp), %rdi
movl -0x9c(%rbp), %eax
movl %eax, %esi
xorl %edx, %edx
callq 0x2170
jmp 0x1b3dc
leaq 0x15eed(%rip), %rdi     # 0x312b1
leaq 0x15885(%rip), %rsi     # 0x30c50
movl $0x12eb, %edx           # imm = 0x12EB
leaq 0x15f84(%rip), %rcx     # 0x3135b
callq 0x20c0
movq -0x20(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0xc0, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
nopl (%rax,%rax)