// File: /workspace/github_cpp_makefile_star2_O3/jeffchan[P]blockchain-parser/BitcoinTransactions.cpp
// Function: BitcoinTransactionsImpl::processBlock(BlockChain::Block const&)
virtual void processBlock(const BlockChain::Block &block)
	{
		uint64_t btc=0;
		uint64_t oneBTC = 100000000;

		printf("%d transactions.\r\n", block.transactionCount );
		for (uint32_t i=0; i<block.transactionCount; i++)
		{
			const BlockChain::BlockTransaction &t = block.transactions[i];
#if 0
			for (uint32_t i=0; i<t.inputCount; i++)
			{
				const BlockChain::BlockInput &input = t.inputs[i];
				mBitcoinScript->executeScript(input.responseScript,input.responseScriptLength);
			}
			for (uint32_t i=0; i<t.outputCount; i++)
			{
				const BlockChain::BlockOutput &ou tput = t.outputs[i];
				mBitcoinScript->resetStack();
				mBitcoinScript->executeScript(output.challengeScript,output.challengeScriptLength);
			}
#else
			printf("Transaction #%d has %d outputs and %d inputs.\r\n", i+1, t.outputCount, t.inputCount );
			for (uint32_t i=0; i<t.inputCount; i++)
			{
				const BlockChain::BlockInput &input = t.inputs[i];
				printf("Input %d : hash(%s) Index: %d\r\n", i+1, hashString(input.transactionHash), input.transactionIndex );
				mBitcoinScript->resetStack();
				mBitcoinScript->executeScript(input.responseScript,input.responseScriptLength);
			}
			for (uint32_t i=0; i<t.outputCount; i++)
			{
				const BlockChain::BlockOutput &output = t.outputs[i];
				printf("output %d is %d BTC.\r\n", i+1, (int)(output.value / oneBTC) );
				btc+=output.value;
				mBitcoinScript->resetStack();
				mBitcoinScript->executeScript(output.challengeScript,output.challengeScriptLength);
			}
#endif
		}
		printf("OutputBTC: %0.4f\r\n", (float)btc / (float)oneBTC );
	}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %rsi, %r14
movq %rdi, %rbx
movl 0x24(%rsi), %esi
leaq 0x102a3(%rip), %rdi     # 0x17744
xorl %eax, %eax
callq 0x2050
cmpl $0x0, 0x24(%r14)
je 0x766d
movq %rbx, -0x40(%rbp)
leaq 0x10313(%rip), %rbx     # 0x177d1
xorl %esi, %esi
movq $0x0, -0x30(%rbp)
movq %r14, -0x48(%rbp)
movq 0x28(%r14), %r14
imulq $0x58, %rsi, %r15
leaq (%r14,%r15), %r12
incq %rsi
movl 0x4(%r14,%r15), %ecx
movl 0x10(%r14,%r15), %edx
leaq 0x1026b(%rip), %rdi     # 0x17757
movq %rsi, -0x50(%rbp)
xorl %eax, %eax
callq 0x2050
cmpl $0x0, 0x4(%r14,%r15)
leaq 0x17c9c(%rip), %r14     # 0x1f1a0
movq %r12, -0x38(%rbp)
je 0x75b0
xorl %r13d, %r13d
movq 0x8(%r12), %rax
movq %r13, %rcx
shlq $0x5, %rcx
leaq (%rax,%rcx), %rdx
movq %rdx, -0x58(%rbp)
movq (%rax,%rcx), %r12
movb $0x0, 0x17cb0(%rip)     # 0x1f1e0
movq %r14, %r15
xorl %r14d, %r14d
movzbl (%r12,%r14), %edx
movq %r15, %rdi
movq %rbx, %rsi
xorl %eax, %eax
callq 0x2060
incq %r14
addq $0x2, %r15
cmpq $0x20, %r14
jne 0x7536
incq %r13
movq -0x58(%rbp), %r12
movl 0x8(%r12), %ecx
leaq 0x1021f(%rip), %rdi     # 0x17787
movl %r13d, %esi
leaq 0x17c2e(%rip), %r14     # 0x1f1a0
movq %r14, %rdx
xorl %eax, %eax
callq 0x2050
movq -0x40(%rbp), %r15
movq 0x8(%r15), %rdi
movq (%rdi), %rax
callq *0x8(%rax)
movq 0x8(%r15), %rdi
movq 0x10(%r12), %rsi
movl 0xc(%r12), %edx
movq (%rdi), %rax
callq *0x10(%rax)
movq -0x38(%rbp), %r12
movl 0x4(%r12), %eax
cmpq %rax, %r13
jb 0x7511
cmpl $0x0, 0x10(%r12)
je 0x7640
xorl %r15d, %r15d
xorl %r13d, %r13d
movq -0x30(%rbp), %r12
movabsq $-0x543388ee7b9e3103, %rax # imm = 0xABCC77118461CEFD
movq -0x38(%rbp), %rcx
movq 0x18(%rcx), %r14
mulq (%r14,%r15)
incq %r13
shrq $0x1a, %rdx
leaq 0x101bd(%rip), %rdi     # 0x177a7
movl %r13d, %esi
xorl %eax, %eax
callq 0x2050
addq (%r14,%r15), %r12
movq %r12, -0x30(%rbp)
movq -0x40(%rbp), %r12
movq 0x8(%r12), %rdi
movq (%rdi), %rax
callq *0x8(%rax)
movq 0x8(%r12), %rdi
movq -0x30(%rbp), %r12
movq 0x10(%r14,%r15), %rsi
movl 0x8(%r14,%r15), %edx
movq (%rdi), %rax
callq *0x10(%rax)
movabsq $-0x543388ee7b9e3103, %rax # imm = 0xABCC77118461CEFD
movq -0x38(%rbp), %rcx
movl 0x10(%rcx), %ecx
addq $0x28, %r15
cmpq %rcx, %r13
jb 0x75d0
jmp 0x7644
movq -0x30(%rbp), %r12
movq %r12, -0x30(%rbp)
movq -0x48(%rbp), %r14
movl 0x24(%r14), %eax
movq -0x50(%rbp), %rsi
cmpq %rax, %rsi
jb 0x74cc
movq -0x30(%rbp), %rcx
testq %rcx, %rcx
js 0x7672
cvtsi2ss %rcx, %xmm0
jmp 0x7687
xorps %xmm0, %xmm0
jmp 0x7687
movq %rcx, %rax
shrq %rax
andl $0x1, %ecx
orq %rax, %rcx
cvtsi2ss %rcx, %xmm0
addss %xmm0, %xmm0
divss 0x10081(%rip), %xmm0    # 0x17710
cvtss2sd %xmm0, %xmm0
leaq 0x10124(%rip), %rdi     # 0x177be
movb $0x1, %al
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x2050
nop