// File: ArthoPacini[P]blockchaincpp/main.cpp
// Function: main
int main()
{
    //Create blockchain with difficulty level 3 and 2 transactions per block max
    Blockchain blockchain(3, 2); 

    //add transactions
    //the block is mined when the transaction count reaches maximum value
    blockchain.push_transaction({1.0, "Joe", "Paul"});
    blockchain.push_transaction({3.14, "Paul", "Ruth"});
    blockchain.push_transaction({1.32, "Joe", "Ruth"});
    blockchain.push_transaction({5.52, "Steve", "Joe"});
    blockchain.push_transaction({6.7, "Ruth", "Steve"});
    blockchain.push_transaction({7.62, "Joe", "Steve"});

    //prints blockchain
    std::cout << blockchain.dump() << std::endl;

    //saves blockchain do disk
    blockchain.save();

    //validates the chain
    std::cout << "Is blockchain valid? " << blockchain.validate() << std::endl;

    //load blockchain from disk
    Blockchain alternative;
}

// Assembly:
subq $0x5a8, %rsp            # imm = 0x5A8
leaq 0x588(%rsp), %rdi
movl $0x3, %esi
movl $0x2, %edx
callq 0x73d0
leaq 0x4ff(%rsp), %rdi
movq %rdi, 0x90(%rsp)
callq 0x57a0
movq 0x90(%rsp), %rdx
leaq 0x36786(%rip), %rsi     # 0x3cb58
leaq 0x500(%rsp), %rdi
callq 0x6f00
jmp 0x63e1
leaq 0x4c7(%rsp), %rdi
movq %rdi, 0x88(%rsp)
callq 0x57a0
movq 0x88(%rsp), %rdx
leaq 0x36757(%rip), %rsi     # 0x3cb5c
leaq 0x4c8(%rsp), %rdi
callq 0x6f00
jmp 0x6414
leaq 0x520(%rsp), %rdi
movsd 0x35be4(%rip), %xmm0    # 0x3c008
leaq 0x500(%rsp), %rsi
leaq 0x4c8(%rsp), %rdx
callq 0x7690
jmp 0x643b
leaq 0x588(%rsp), %rdi
leaq 0x520(%rsp), %rsi
callq 0x74a0
jmp 0x6452
leaq 0x520(%rsp), %rdi
callq 0x7790
leaq 0x4c8(%rsp), %rdi
callq 0x5320
leaq 0x4c7(%rsp), %rdi
callq 0x5520
leaq 0x500(%rsp), %rdi
callq 0x5320
leaq 0x4ff(%rsp), %rdi
callq 0x5520
leaq 0x437(%rsp), %rdi
movq %rdi, 0x80(%rsp)
callq 0x57a0
movq 0x80(%rsp), %rdx
leaq 0x366a5(%rip), %rsi     # 0x3cb5c
leaq 0x438(%rsp), %rdi
callq 0x6f00
jmp 0x64c6
leaq 0x40f(%rsp), %rdi
movq %rdi, 0x78(%rsp)
callq 0x57a0
movq 0x78(%rsp), %rdx
leaq 0x3667d(%rip), %rsi     # 0x3cb61
leaq 0x410(%rsp), %rdi
callq 0x6f00
jmp 0x64f3
leaq 0x458(%rsp), %rdi
movsd 0x35b0d(%rip), %xmm0    # 0x3c010
leaq 0x438(%rsp), %rsi
leaq 0x410(%rsp), %rdx
callq 0x7690
jmp 0x651a
leaq 0x588(%rsp), %rdi
leaq 0x458(%rsp), %rsi
callq 0x74a0
jmp 0x6531
leaq 0x458(%rsp), %rdi
callq 0x7790
leaq 0x410(%rsp), %rdi
callq 0x5320
leaq 0x40f(%rsp), %rdi
callq 0x5520
leaq 0x438(%rsp), %rdi
callq 0x5320
leaq 0x437(%rsp), %rdi
callq 0x5520
leaq 0x37f(%rsp), %rdi
movq %rdi, 0x70(%rsp)
callq 0x57a0
movq 0x70(%rsp), %rdx
leaq 0x365c8(%rip), %rsi     # 0x3cb58
leaq 0x380(%rsp), %rdi
callq 0x6f00
jmp 0x659f
leaq 0x357(%rsp), %rdi
movq %rdi, 0x68(%rsp)
callq 0x57a0
movq 0x68(%rsp), %rdx
leaq 0x365a4(%rip), %rsi     # 0x3cb61
leaq 0x358(%rsp), %rdi
callq 0x6f00
jmp 0x65cc
leaq 0x3a0(%rsp), %rdi
movsd 0x35a3c(%rip), %xmm0    # 0x3c018
leaq 0x380(%rsp), %rsi
leaq 0x358(%rsp), %rdx
callq 0x7690
jmp 0x65f3
leaq 0x588(%rsp), %rdi
leaq 0x3a0(%rsp), %rsi
callq 0x74a0
jmp 0x660a
leaq 0x3a0(%rsp), %rdi
callq 0x7790
leaq 0x358(%rsp), %rdi
callq 0x5320
leaq 0x357(%rsp), %rdi
callq 0x5520
leaq 0x380(%rsp), %rdi
callq 0x5320
leaq 0x37f(%rsp), %rdi
callq 0x5520
leaq 0x2c7(%rsp), %rdi
movq %rdi, 0x60(%rsp)
callq 0x57a0
movq 0x60(%rsp), %rdx
leaq 0x364fd(%rip), %rsi     # 0x3cb66
leaq 0x2c8(%rsp), %rdi
callq 0x6f00
jmp 0x6678
leaq 0x29f(%rsp), %rdi
movq %rdi, 0x58(%rsp)
callq 0x57a0
movq 0x58(%rsp), %rdx
leaq 0x364c2(%rip), %rsi     # 0x3cb58
leaq 0x2a0(%rsp), %rdi
callq 0x6f00
jmp 0x66a5
leaq 0x2e8(%rsp), %rdi
movsd 0x3596b(%rip), %xmm0    # 0x3c020
leaq 0x2c8(%rsp), %rsi
leaq 0x2a0(%rsp), %rdx
callq 0x7690
jmp 0x66cc
leaq 0x588(%rsp), %rdi
leaq 0x2e8(%rsp), %rsi
callq 0x74a0
jmp 0x66e3
leaq 0x2e8(%rsp), %rdi
callq 0x7790
leaq 0x2a0(%rsp), %rdi
callq 0x5320
leaq 0x29f(%rsp), %rdi
callq 0x5520
leaq 0x2c8(%rsp), %rdi
callq 0x5320
leaq 0x2c7(%rsp), %rdi
callq 0x5520
leaq 0x20f(%rsp), %rdi
movq %rdi, 0x50(%rsp)
callq 0x57a0
movq 0x50(%rsp), %rdx
leaq 0x3641f(%rip), %rsi     # 0x3cb61
leaq 0x210(%rsp), %rdi
callq 0x6f00
jmp 0x6751
leaq 0x1e7(%rsp), %rdi
movq %rdi, 0x48(%rsp)
callq 0x57a0
movq 0x48(%rsp), %rdx
leaq 0x363f7(%rip), %rsi     # 0x3cb66
leaq 0x1e8(%rsp), %rdi
callq 0x6f00
jmp 0x677e
leaq 0x230(%rsp), %rdi
movsd 0x3589a(%rip), %xmm0    # 0x3c028
leaq 0x210(%rsp), %rsi
leaq 0x1e8(%rsp), %rdx
callq 0x7690
jmp 0x67a5
leaq 0x588(%rsp), %rdi
leaq 0x230(%rsp), %rsi
callq 0x74a0
jmp 0x67bc
leaq 0x230(%rsp), %rdi
callq 0x7790
leaq 0x1e8(%rsp), %rdi
callq 0x5320
leaq 0x1e7(%rsp), %rdi
callq 0x5520
leaq 0x210(%rsp), %rdi
callq 0x5320
leaq 0x20f(%rsp), %rdi
callq 0x5520
leaq 0x157(%rsp), %rdi
movq %rdi, 0x40(%rsp)
callq 0x57a0
movq 0x40(%rsp), %rdx
leaq 0x3633d(%rip), %rsi     # 0x3cb58
leaq 0x158(%rsp), %rdi
callq 0x6f00
jmp 0x682a
leaq 0x12f(%rsp), %rdi
movq %rdi, 0x38(%rsp)
callq 0x57a0
movq 0x38(%rsp), %rdx
leaq 0x3631e(%rip), %rsi     # 0x3cb66
leaq 0x130(%rsp), %rdi
callq 0x6f00
jmp 0x6857
leaq 0x178(%rsp), %rdi
movsd 0x357c9(%rip), %xmm0    # 0x3c030
leaq 0x158(%rsp), %rsi
leaq 0x130(%rsp), %rdx
callq 0x7690
jmp 0x687e
leaq 0x588(%rsp), %rdi
leaq 0x178(%rsp), %rsi
callq 0x74a0
jmp 0x6895
leaq 0x178(%rsp), %rdi
callq 0x7790
leaq 0x130(%rsp), %rdi
callq 0x5320
leaq 0x12f(%rsp), %rdi
callq 0x5520
leaq 0x158(%rsp), %rdi
callq 0x5320
leaq 0x157(%rsp), %rdi
callq 0x5520
leaq 0x108(%rsp), %rdi
leaq 0x588(%rsp), %rsi
movl $0x4, %edx
callq 0x77d0
jmp 0x68f2
movq 0x516d7(%rip), %rdi     # 0x57fd0
leaq 0x108(%rsp), %rsi
callq 0x5480
movq %rax, 0x30(%rsp)
jmp 0x690d
movq 0x30(%rsp), %rdi
movq 0x51687(%rip), %rsi     # 0x57fa0
callq 0x5500
jmp 0x6920
leaq 0x108(%rsp), %rdi
callq 0x5320
leaq 0xe7(%rsp), %rdi
movq %rdi, 0x28(%rsp)
callq 0x57a0
movq 0x28(%rsp), %rdx
leaq 0x36221(%rip), %rsi     # 0x3cb6c
leaq 0xe8(%rsp), %rdi
callq 0x6f00
jmp 0x695a
leaq 0x588(%rsp), %rdi
leaq 0xe8(%rsp), %rsi
movl $0x4, %edx
callq 0x8030
jmp 0x6976
leaq 0xe8(%rsp), %rdi
callq 0x5320
leaq 0xe7(%rsp), %rdi
callq 0x5520
movq 0x51639(%rip), %rdi     # 0x57fd0
leaq 0x361de(%rip), %rsi     # 0x3cb7c
callq 0x54a0
movq %rax, 0x20(%rsp)
jmp 0x69aa
leaq 0x588(%rsp), %rdi
callq 0x8360
movb %al, 0x1f(%rsp)
jmp 0x69bd
movq 0x20(%rsp), %rdi
movb 0x1f(%rsp), %al
movzbl %al, %esi
andl $0x1, %esi
callq 0x57b0
movq %rax, 0x10(%rsp)
jmp 0x69d8
movq 0x10(%rsp), %rdi
movq 0x515bc(%rip), %rsi     # 0x57fa0
callq 0x5500
jmp 0x69eb
leaq 0x9f(%rsp), %rdi
movq %rdi, 0x8(%rsp)
callq 0x57a0
movq 0x8(%rsp), %rdx
leaq 0x36163(%rip), %rsi     # 0x3cb6c
leaq 0xa0(%rsp), %rdi
callq 0x6f00
jmp 0x6a18
leaq 0xc0(%rsp), %rdi
leaq 0xa0(%rsp), %rsi
callq 0x8670
jmp 0x6a2f
leaq 0xa0(%rsp), %rdi
callq 0x5320
leaq 0x9f(%rsp), %rdi
callq 0x5520
leaq 0xc0(%rsp), %rdi
callq 0x8720
leaq 0x588(%rsp), %rdi
callq 0x8720
xorl %eax, %eax
addq $0x5a8, %rsp            # imm = 0x5A8
retq
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x4f0(%rsp)
movl %eax, 0x4ec(%rsp)
jmp 0x6af7
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x4f0(%rsp)
movl %eax, 0x4ec(%rsp)
jmp 0x6add
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x4f0(%rsp)
movl %eax, 0x4ec(%rsp)
jmp 0x6ad0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x4f0(%rsp)
movl %eax, 0x4ec(%rsp)
leaq 0x520(%rsp), %rdi
callq 0x7790
leaq 0x4c8(%rsp), %rdi
callq 0x5320
leaq 0x4c7(%rsp), %rdi
callq 0x5520
leaq 0x500(%rsp), %rdi
callq 0x5320
leaq 0x4ff(%rsp), %rdi
callq 0x5520
jmp 0x6ede
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x4f0(%rsp)
movl %eax, 0x4ec(%rsp)
jmp 0x6b93
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x4f0(%rsp)
movl %eax, 0x4ec(%rsp)
jmp 0x6b79
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x4f0(%rsp)
movl %eax, 0x4ec(%rsp)
jmp 0x6b6c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x4f0(%rsp)
movl %eax, 0x4ec(%rsp)
leaq 0x458(%rsp), %rdi
callq 0x7790
leaq 0x410(%rsp), %rdi
callq 0x5320
leaq 0x40f(%rsp), %rdi
callq 0x5520
leaq 0x438(%rsp), %rdi
callq 0x5320
leaq 0x437(%rsp), %rdi
callq 0x5520
jmp 0x6ede
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x4f0(%rsp)
movl %eax, 0x4ec(%rsp)
jmp 0x6c2f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x4f0(%rsp)
movl %eax, 0x4ec(%rsp)
jmp 0x6c15
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x4f0(%rsp)
movl %eax, 0x4ec(%rsp)
jmp 0x6c08
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x4f0(%rsp)
movl %eax, 0x4ec(%rsp)
leaq 0x3a0(%rsp), %rdi
callq 0x7790
leaq 0x358(%rsp), %rdi
callq 0x5320
leaq 0x357(%rsp), %rdi
callq 0x5520
leaq 0x380(%rsp), %rdi
callq 0x5320
leaq 0x37f(%rsp), %rdi
callq 0x5520
jmp 0x6ede
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x4f0(%rsp)
movl %eax, 0x4ec(%rsp)
jmp 0x6ccb
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x4f0(%rsp)
movl %eax, 0x4ec(%rsp)
jmp 0x6cb1
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x4f0(%rsp)
movl %eax, 0x4ec(%rsp)
jmp 0x6ca4
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x4f0(%rsp)
movl %eax, 0x4ec(%rsp)
leaq 0x2e8(%rsp), %rdi
callq 0x7790
leaq 0x2a0(%rsp), %rdi
callq 0x5320
leaq 0x29f(%rsp), %rdi
callq 0x5520
leaq 0x2c8(%rsp), %rdi
callq 0x5320
leaq 0x2c7(%rsp), %rdi
callq 0x5520
jmp 0x6ede
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x4f0(%rsp)
movl %eax, 0x4ec(%rsp)
jmp 0x6d67
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x4f0(%rsp)
movl %eax, 0x4ec(%rsp)
jmp 0x6d4d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x4f0(%rsp)
movl %eax, 0x4ec(%rsp)
jmp 0x6d40
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x4f0(%rsp)
movl %eax, 0x4ec(%rsp)
leaq 0x230(%rsp), %rdi
callq 0x7790
leaq 0x1e8(%rsp), %rdi
callq 0x5320
leaq 0x1e7(%rsp), %rdi
callq 0x5520
leaq 0x210(%rsp), %rdi
callq 0x5320
leaq 0x20f(%rsp), %rdi
callq 0x5520
jmp 0x6ede
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x4f0(%rsp)
movl %eax, 0x4ec(%rsp)
jmp 0x6e03
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x4f0(%rsp)
movl %eax, 0x4ec(%rsp)
jmp 0x6de9
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x4f0(%rsp)
movl %eax, 0x4ec(%rsp)
jmp 0x6ddc
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x4f0(%rsp)
movl %eax, 0x4ec(%rsp)
leaq 0x178(%rsp), %rdi
callq 0x7790
leaq 0x130(%rsp), %rdi
callq 0x5320
leaq 0x12f(%rsp), %rdi
callq 0x5520
leaq 0x158(%rsp), %rdi
callq 0x5320
leaq 0x157(%rsp), %rdi
callq 0x5520
jmp 0x6ede
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x4f0(%rsp)
movl %eax, 0x4ec(%rsp)
jmp 0x6ede
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x4f0(%rsp)
movl %eax, 0x4ec(%rsp)
leaq 0x108(%rsp), %rdi
callq 0x5320
jmp 0x6ede
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x4f0(%rsp)
movl %eax, 0x4ec(%rsp)
jmp 0x6e8b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x4f0(%rsp)
movl %eax, 0x4ec(%rsp)
leaq 0xe8(%rsp), %rdi
callq 0x5320
leaq 0xe7(%rsp), %rdi
callq 0x5520
jmp 0x6ede
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x4f0(%rsp)
movl %eax, 0x4ec(%rsp)
jmp 0x6ed1
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x4f0(%rsp)
movl %eax, 0x4ec(%rsp)
leaq 0xa0(%rsp), %rdi
callq 0x5320
leaq 0x9f(%rsp), %rdi
callq 0x5520
leaq 0x588(%rsp), %rdi
callq 0x8720
movq 0x4f0(%rsp), %rdi
callq 0x5790
nopl (%rax,%rax)