// File: jeffchan[P]blockchain-parser/BlockChain.cpp
// Function: BlockImpl::readTransation(BlockChain::BlockTransaction&, unsigned int&, unsigned int)
bool readTransation(BlockChain::BlockTransaction &transaction,uint32_t &transactionIndex,uint32_t tindex)
	{
		bool ret = false;

		const uint8_t *transactionBegin = mBlockRead;

		transaction.transactionVersionNumber = readU32(); // read the transaction version number; always expect it to be 1
		if ( transaction.transactionVersionNumber == 1 || transaction.transactionVersionNumber == 2 )
		{
		}
		else
		{
			gIsWarning = true;
			printf("Encountered unusual and unexpected transaction version number of [%d] for transaction #%d\r\n", transaction.transactionVersionNumber, tindex );
		}
		transaction.inputCount = readVariableLengthInteger();
		assert( transaction.inputCount < MAX_REASONABLE_INPUTS );
		transaction.inputs = &mInputs[totalInputCount];
		totalInputCount+=transaction.inputCount;
		assert( totalInputCount < MAX_BLOCK_INPUTS );
		if ( totalInputCount < MAX_BLOCK_INPUTS )
		{
			for (uint32_t i=0; i<transaction.inputCount; i++)
			{
				BlockChain::BlockInput &input = transaction.inputs[i];
				ret = readInput(input);	// read the input 
				if ( !ret )
				{
					break;
				}
			}
		}
		else
		{
			ret = false;
		}
		if ( ret )
		{
			transaction.outputCount = readVariableLengthInteger();
			assert( transaction.outputCount < MAX_REASONABLE_OUTPUTS );
			transaction.outputs = &mOutputs[totalOutputCount];
			totalOutputCount+=transaction.outputCount;
			assert( totalOutputCount < MAX_BLOCK_OUTPUTS );
			if ( totalOutputCount < MAX_BLOCK_OUTPUTS )
			{
				for (uint32_t i=0; i<transaction.outputCount; i++)
				{
					gOutputIndex = i;
					BlockChain::BlockOutput &output = transaction.outputs[i];
					ret = readOutput(output);
					if ( !ret )
					{
						break;
					}
				}

				transaction.lockTime = readU32();

				if ( ret )
				{
					transaction.transactionLength = (uint32_t)(mBlockRead - transactionBegin);
					transaction.fileIndex = fileIndex;
					transaction.fileOffset = fileOffset + (uint32_t)(transactionBegin-mBlockData);
					transaction.transactionIndex = transactionIndex;
					transactionIndex++;
					BLOCKCHAIN_SHA256::computeSHA256(transactionBegin,transaction.transactionLength,transaction.transactionHash);
					BLOCKCHAIN_SHA256::computeSHA256(transaction.transactionHash,32,transaction.transactionHash);
				}

			}
		}
		return ret;
	}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movl %ecx, -0x1c(%rbp)
movq -0x8(%rbp), %rdi
movq %rdi, -0x50(%rbp)
movb $0x0, -0x1d(%rbp)
movq 0x80(%rdi), %rax
movq %rax, -0x28(%rbp)
callq 0x23650
movl %eax, %ecx
movq -0x10(%rbp), %rax
movl %ecx, (%rax)
movq -0x10(%rbp), %rax
cmpl $0x1, (%rax)
je 0x2383d
movq -0x10(%rbp), %rax
cmpl $0x2, (%rax)
jne 0x2383f
jmp 0x2385d
movb $0x1, 0x15f9e(%rip)     # 0x397e4
movq -0x10(%rbp), %rax
movl (%rax), %esi
movl -0x1c(%rbp), %edx
leaq 0xf399(%rip), %rdi      # 0x32bef
movb $0x0, %al
callq 0x2050
movq -0x50(%rbp), %rdi
callq 0x23750
movl %eax, %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x4(%rax)
movq -0x10(%rbp), %rax
cmpl $0x1000, 0x4(%rax)      # imm = 0x1000
jae 0x2387e
jmp 0x2389d
leaq 0xf3c6(%rip), %rdi      # 0x32c4b
leaq 0xd3c4(%rip), %rsi      # 0x30c50
movl $0x8ae, %edx            # imm = 0x8AE
leaq 0xf3e2(%rip), %rcx      # 0x32c7a
callq 0x20c0
movq -0x50(%rbp), %rax
movq %rax, %rdx
addq $0xb0098, %rdx          # imm = 0xB0098
movl 0x54(%rax), %ecx
shlq $0x5, %rcx
addq %rcx, %rdx
movq -0x10(%rbp), %rcx
movq %rdx, 0x8(%rcx)
movq -0x10(%rbp), %rcx
movl 0x4(%rcx), %ecx
addl 0x54(%rax), %ecx
movl %ecx, 0x54(%rax)
cmpl $0x8000, 0x54(%rax)     # imm = 0x8000
jae 0x238d5
jmp 0x238f4
leaq 0xf3f3(%rip), %rdi      # 0x32ccf
leaq 0xd36d(%rip), %rsi      # 0x30c50
movl $0x8b1, %edx            # imm = 0x8B1
leaq 0xf38b(%rip), %rcx      # 0x32c7a
callq 0x20c0
movq -0x50(%rbp), %rax
cmpl $0x8000, 0x54(%rax)     # imm = 0x8000
jae 0x23953
movl $0x0, -0x2c(%rbp)
movl -0x2c(%rbp), %eax
movq -0x10(%rbp), %rcx
cmpl 0x4(%rcx), %eax
jae 0x23951
movq -0x50(%rbp), %rdi
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movl -0x2c(%rbp), %ecx
shlq $0x5, %rcx
addq %rcx, %rax
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rsi
callq 0x23c20
andb $0x1, %al
movb %al, -0x1d(%rbp)
testb $0x1, -0x1d(%rbp)
jne 0x23944
jmp 0x23951
jmp 0x23946
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0x23908
jmp 0x23957
movb $0x0, -0x1d(%rbp)
testb $0x1, -0x1d(%rbp)
je 0x23b0b
movq -0x50(%rbp), %rdi
callq 0x23750
movl %eax, %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x10(%rax)
movq -0x10(%rbp), %rax
cmpl $0x1000, 0x10(%rax)     # imm = 0x1000
jae 0x23982
jmp 0x239a1
leaq 0xf369(%rip), %rdi      # 0x32cf2
leaq 0xd2c0(%rip), %rsi      # 0x30c50
movl $0x8c5, %edx            # imm = 0x8C5
leaq 0xf2de(%rip), %rcx      # 0x32c7a
callq 0x20c0
movq -0x50(%rbp), %rax
movq %rax, %rdx
addq $0x1b0098, %rdx         # imm = 0x1B0098
movl 0x58(%rax), %ecx
imulq $0x28, %rcx, %rcx
addq %rcx, %rdx
movq -0x10(%rbp), %rcx
movq %rdx, 0x18(%rcx)
movq -0x10(%rbp), %rcx
movl 0x10(%rcx), %ecx
addl 0x58(%rax), %ecx
movl %ecx, 0x58(%rax)
cmpl $0x8000, 0x58(%rax)     # imm = 0x8000
jae 0x239d9
jmp 0x239f8
leaq 0xf343(%rip), %rdi      # 0x32d23
leaq 0xd269(%rip), %rsi      # 0x30c50
movl $0x8c8, %edx            # imm = 0x8C8
leaq 0xf287(%rip), %rcx      # 0x32c7a
callq 0x20c0
movq -0x50(%rbp), %rax
cmpl $0x8000, 0x58(%rax)     # imm = 0x8000
jae 0x23b09
movl $0x0, -0x3c(%rbp)
movl -0x3c(%rbp), %eax
movq -0x10(%rbp), %rcx
cmpl 0x10(%rcx), %eax
jae 0x23a62
movq -0x50(%rbp), %rdi
movl -0x3c(%rbp), %eax
movl %eax, 0x15dc3(%rip)     # 0x397ec
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rax
movl -0x3c(%rbp), %ecx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x48(%rbp)
movq -0x48(%rbp), %rsi
callq 0x23d10
andb $0x1, %al
movb %al, -0x1d(%rbp)
testb $0x1, -0x1d(%rbp)
jne 0x23a55
jmp 0x23a62
jmp 0x23a57
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
jmp 0x23a10
movq -0x50(%rbp), %rdi
callq 0x23650
movl %eax, %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x20(%rax)
testb $0x1, -0x1d(%rbp)
je 0x23b07
movq -0x50(%rbp), %rdx
movq 0x80(%rdx), %rax
movq -0x28(%rbp), %rcx
subq %rcx, %rax
movl %eax, %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x44(%rax)
movl 0x5c(%rdx), %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x48(%rax)
movl 0x60(%rdx), %ecx
movq -0x28(%rbp), %rax
movq 0x90(%rdx), %rdx
subq %rdx, %rax
addl %eax, %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x4c(%rax)
movq -0x18(%rbp), %rax
movl (%rax), %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x50(%rax)
movq -0x18(%rbp), %rax
movl (%rax), %ecx
addl $0x1, %ecx
movl %ecx, (%rax)
movq -0x28(%rbp), %rdi
movq -0x10(%rbp), %rax
movl 0x44(%rax), %esi
movq -0x10(%rbp), %rdx
addq $0x24, %rdx
callq 0x186b0
movq -0x10(%rbp), %rdi
addq $0x24, %rdi
movq -0x10(%rbp), %rdx
addq $0x24, %rdx
movl $0x20, %esi
callq 0x186b0
jmp 0x23b09
jmp 0x23b0b
movb -0x1d(%rbp), %al
andb $0x1, %al
addq $0x50, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)