// File: /workspace/github_cpp_makefile_star2_O1/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rsi, %r14
movq %rdi, %rbx
movq (%rsi), %rax
movq 0x8(%rsi), %rcx
movq 0x10(%rsi), %rdx
movq 0x18(%rsi), %rsi
movq %rcx, %rdi
xorq %rax, %rdi
movq %rdx, %r8
xorq %rsi, %r8
xorq %rdi, %r8
shrq $0x20, %r8
movl %ecx, %edi
xorl %eax, %edi
movl %edx, %r9d
xorl %edi, %r9d
movl %esi, %edi
xorl %r9d, %edi
xorl %r8d, %edi
andl $0x3fffff, %edi         # imm = 0x3FFFFF
movq 0x16f12f0(%rbx,%rdi,8), %r15
testq %r15, %r15
je 0xc3c7
cmpq %rax, (%r15)
jne 0xc3c1
cmpq %rcx, 0x8(%r15)
jne 0xc3c1
cmpq %rdx, 0x10(%r15)
jne 0xc3c1
cmpq %rsi, 0x18(%r15)
je 0xc3ca
movq 0x30(%r15), %r15
jmp 0xc3a5
xorl %r15d, %r15d
testq %r15, %r15
je 0xc4a0
movl 0x20(%r15), %eax
cmpq $0x1ff, %rax            # imm = 0x1FF
ja 0xc4da
movq 0x208(%rbx,%rax,8), %r14
testq %r14, %r14
je 0xc4da
movl 0x28(%r15), %r13d
cmpl $0x9fffff, %r13d        # imm = 0x9FFFFF
ja 0xc4da
movq %rax, -0x38(%rbp)
movl 0x24(%r15), %r12d
movq %r14, %rdi
callq 0x2030
movq %rax, -0x40(%rbp)
movq %r14, %rdi
movq %r12, %rsi
xorl %edx, %edx
callq 0x2180
movq %r14, %rdi
callq 0x2030
movq %r12, -0x30(%rbp)
cmpl %eax, %r12d
jne 0xc4f9
leaq 0xcf12e8(%rbx), %r12
movl $0x1, %edx
movq %r12, %rdi
movq %r13, %rsi
movq %r14, %rcx
callq 0x2250
cmpq $0x1, %rax
jne 0xc518
movq (%rbx), %rax
movq %rbx, %rdi
movq %r12, %rsi
movl %r13d, %edx
callq *0xc0(%rax)
movq %rax, %r13
testq %rax, %rax
je 0xc491
movl 0x2c(%r15), %eax
movl %eax, 0x50(%r13)
movq -0x38(%rbp), %rax
movl %eax, 0x48(%r13)
movq -0x30(%rbp), %rax
movl %eax, 0x4c(%r13)
movl -0x40(%rbp), %esi
movq %r14, %rdi
xorl %edx, %edx
callq 0x2180
jmp 0xc4c8
leaq 0xb8e9(%rip), %rdi      # 0x17d90
xorl %r13d, %r13d
xorl %eax, %eax
callq 0x2050
movq %rbx, %rdi
movq %r14, %rsi
callq 0xcfa8
leaq 0xd5ab(%rip), %rdi      # 0x19a6e
callq 0x2260
movq %r13, %rax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0xb88f(%rip), %rdi      # 0x17d70
leaq 0xb308(%rip), %rsi      # 0x177f0
leaq 0xb8d0(%rip), %rcx      # 0x17dbf
movl $0x12eb, %edx           # imm = 0x12EB
callq 0x20c0
leaq 0xb870(%rip), %rdi      # 0x17d70
leaq 0xb2e9(%rip), %rsi      # 0x177f0
leaq 0xb8b1(%rip), %rcx      # 0x17dbf
movl $0x12e5, %edx           # imm = 0x12E5
callq 0x20c0
leaq 0xb851(%rip), %rdi      # 0x17d70
leaq 0xb2ca(%rip), %rsi      # 0x177f0
leaq 0xb892(%rip), %rcx      # 0x17dbf
movl $0x12e0, %edx           # imm = 0x12E0
callq 0x20c0
nop