// File: /workspace/github_cpp_makefile_star2_O2/s0sasaki[P]ExecutableBlockchain/main.cpp
// Function: main
int main()
{
    Blockchain blockchain = Blockchain();
    VM vm = VM();
    Compiler compiler = Compiler();
    int32_t bin_data[Block::DATA_SIZE];
    char src_data1[] = "\
    : main              \n\
        1 2 3 4 * + + . \n\
    ; ";
    char src_data2[] = "\
    : square            \n\
        dup *           \n\
    ;                   \n\
    : main              \n\
        5 square .      \n\
    ; ";
    char src_data3[] = "\
    : main              \n\
        10 square .     \n\
    ; ";

    std::cout << src_data1 << std::endl;
    compiler.compile(bin_data, src_data1, blockchain.chain.size());
    vm.exec(bin_data, blockchain);
    blockchain.addBlock(Block(bin_data));
    std::cout << "Block mined: " << blockchain.chain.back().hash << std::endl;

    std::cout << src_data2 << std::endl;
    compiler.compile(bin_data, src_data2, blockchain.chain.size());
    vm.exec(bin_data, blockchain);
    blockchain.addBlock(Block(bin_data));
    std::cout << "Block mined: " << blockchain.chain.back().hash << std::endl;

    std::cout << src_data3 << std::endl;
    compiler.compile(bin_data, src_data3, blockchain.chain.size());
    vm.exec(bin_data, blockchain);
    blockchain.addBlock(Block(bin_data));
    std::cout << "Block mined: " << blockchain.chain.back().hash << std::endl;

    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %rbx
subq $0x9428, %rsp           # imm = 0x9428
leaq -0x28(%rbp), %rdi
callq 0x458c
leaq -0x9430(%rbp), %rdi
callq 0x5024
leaq -0xc8(%rbp), %rax
xorps %xmm0, %xmm0
movaps %xmm0, 0x8(%rax)
movaps %xmm0, 0x18(%rax)
movaps %xmm0, 0x28(%rax)
movaps %xmm0, -0x8(%rax)
movq %rax, 0x10(%rax)
movq %rax, 0x18(%rax)
leaq -0x98(%rbp), %rax
andl $0x0, (%rax)
andq $0x0, 0x8(%rax)
movq %rax, 0x10(%rax)
movq %rax, 0x18(%rax)
andq $0x0, 0x20(%rax)
movups 0x3af7(%rip), %xmm0     # 0x6039
leaq -0x110(%rbp), %rbx
movups %xmm0, 0x29(%rbx)
movaps 0x3adc(%rip), %xmm0     # 0x6030
movaps %xmm0, 0x20(%rbx)
movaps 0x3ac1(%rip), %xmm0     # 0x6020
movaps %xmm0, 0x10(%rbx)
movaps 0x3aa6(%rip), %xmm0     # 0x6010
movaps %xmm0, (%rbx)
leaq 0x3adc(%rip), %rsi      # 0x6050
leaq -0x1a0(%rbp), %rdi
movl $0x84, %edx
callq 0x2180
movups 0x3b7d(%rip), %xmm0     # 0x6109
movups %xmm0, -0x47(%rbp)
movaps 0x3b69(%rip), %xmm0     # 0x6100
movaps %xmm0, -0x50(%rbp)
movaps 0x3b4e(%rip), %xmm0     # 0x60f0
movaps %xmm0, -0x60(%rbp)
movaps 0x3b33(%rip), %xmm0     # 0x60e0
movaps %xmm0, -0x70(%rbp)
movq 0x7a18(%rip), %rdi      # 0x9fd0
movq %rbx, %rsi
callq 0x21e0
movq %rax, %rdi
callq 0x20e0
movq -0x20(%rbp), %rax
subq -0x28(%rbp), %rax
movl $0x1050, %ecx           # imm = 0x1050
cqto
idivq %rcx
leaq -0xd0(%rbp), %rdi
leaq -0x11a0(%rbp), %rsi
leaq -0x110(%rbp), %rdx
movl %eax, %ecx
callq 0x2ad4
leaq -0x9430(%rbp), %rdi
leaq -0x11a0(%rbp), %rsi
leaq -0x28(%rbp), %rdx
callq 0x5564
leaq -0x4290(%rbp), %rdi
leaq -0x11a0(%rbp), %rsi
callq 0x42c8
leaq -0x28(%rbp), %rdi
leaq -0x4290(%rbp), %rsi
callq 0x4730
leaq -0x4290(%rbp), %rdi
callq 0x284e
movq 0x798d(%rip), %rdi      # 0x9fd0
leaq 0x3acf(%rip), %rsi      # 0x6119
callq 0x21e0
movq $-0x1050, %rsi          # imm = 0xEFB0
addq -0x20(%rbp), %rsi
movq %rax, %rdi
callq 0x21a0
movq %rax, %rdi
callq 0x20e0
movq 0x795f(%rip), %rdi      # 0x9fd0
leaq -0x1a0(%rbp), %rsi
callq 0x21e0
movq %rax, %rdi
callq 0x20e0
movq -0x20(%rbp), %rax
subq -0x28(%rbp), %rax
movl $0x1050, %ecx           # imm = 0x1050
cqto
idivq %rcx
leaq -0xd0(%rbp), %rdi
leaq -0x11a0(%rbp), %rsi
leaq -0x1a0(%rbp), %rdx
movl %eax, %ecx
callq 0x2ad4
leaq -0x9430(%rbp), %rdi
leaq -0x11a0(%rbp), %rsi
leaq -0x28(%rbp), %rdx
callq 0x5564
leaq -0x3240(%rbp), %rdi
leaq -0x11a0(%rbp), %rsi
callq 0x42c8
leaq -0x28(%rbp), %rdi
leaq -0x3240(%rbp), %rsi
callq 0x4730
leaq -0x3240(%rbp), %rdi
callq 0x284e
movq 0x78d0(%rip), %rdi      # 0x9fd0
leaq 0x3a12(%rip), %rsi      # 0x6119
callq 0x21e0
movq $-0x1050, %rsi          # imm = 0xEFB0
addq -0x20(%rbp), %rsi
movq %rax, %rdi
callq 0x21a0
movq %rax, %rdi
callq 0x20e0
movq 0x78a2(%rip), %rdi      # 0x9fd0
leaq -0x70(%rbp), %rsi
callq 0x21e0
movq %rax, %rdi
callq 0x20e0
movq -0x20(%rbp), %rax
subq -0x28(%rbp), %rax
movl $0x1050, %ecx           # imm = 0x1050
cqto
idivq %rcx
leaq -0xd0(%rbp), %rdi
leaq -0x11a0(%rbp), %rsi
leaq -0x70(%rbp), %rdx
movl %eax, %ecx
callq 0x2ad4
leaq -0x9430(%rbp), %rdi
leaq -0x11a0(%rbp), %rsi
leaq -0x28(%rbp), %rdx
callq 0x5564
leaq -0x21f0(%rbp), %rdi
leaq -0x11a0(%rbp), %rsi
callq 0x42c8
leaq -0x28(%rbp), %rdi
leaq -0x21f0(%rbp), %rsi
callq 0x4730
leaq -0x21f0(%rbp), %rdi
callq 0x284e
movq 0x7819(%rip), %rdi      # 0x9fd0
leaq 0x395b(%rip), %rsi      # 0x6119
callq 0x21e0
movq $-0x1050, %rsi          # imm = 0xEFB0
addq -0x20(%rbp), %rsi
movq %rax, %rdi
callq 0x21a0
movq %rax, %rdi
callq 0x20e0
leaq -0xd0(%rbp), %rdi
callq 0x286e
leaq -0x28(%rbp), %rdi
callq 0x298c
xorl %eax, %eax
addq $0x9428, %rsp           # imm = 0x9428
popq %rbx
popq %rbp
retq
movq %rax, %rbx
leaq -0x21f0(%rbp), %rdi
jmp 0x2821
movq %rax, %rbx
leaq -0x3240(%rbp), %rdi
jmp 0x2821
movq %rax, %rbx
leaq -0x4290(%rbp), %rdi
callq 0x284e
jmp 0x2830
movq %rax, %rbx
jmp 0x283c
movq %rax, %rbx
leaq -0xd0(%rbp), %rdi
callq 0x286e
leaq -0x28(%rbp), %rdi
callq 0x298c
movq %rbx, %rdi
callq 0x22b0
nop