// File: pollow[P]MIPSClide/assembler.cpp
// Function: Assembler::format()
void Assembler::format() {
    static regex label("(\\s*(\\w+)\\s*:\\s*).*");
    // 0. remove empty line
    {
        auto i = statements.begin();
        while( i != statements.end() ) {
            if (i->length() < 1) statements.erase(i);
            else i++;
        }
    }
    // 1. extract label into new line:
    size_t i = 0;
    while ( i < statements.size() ) {
        string &str = statements[i];
        smatch result;
        if ( regex_match(str, result, label) ) {
            if ( (size_t) result[1].length() != str.length() ) {
                string tmp = result[2].str();
                str.erase( str.find(result[1].str()), result[1].length() );
                statements.insert(statements.begin()+i,tmp+":");
                i++;
            }
            i++;
        } else i++;
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x170, %rsp            # imm = 0x170
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0xf8(%rbp)
cmpb $0x0, 0x5726f(%rip)     # 0x6b970
jne 0x14754
leaq 0x57266(%rip), %rdi     # 0x6b970
callq 0x67c0
cmpl $0x0, %eax
je 0x14754
leaq 0x57235(%rip), %rdi     # 0x6b950
leaq 0x35d79(%rip), %rsi     # 0x4a49b
movl $0x10, %edx
callq 0x14f60
jmp 0x1472e
leaq 0x8cb(%rip), %rdi       # 0x15000
leaq 0x57214(%rip), %rsi     # 0x6b950
leaq 0x56d15(%rip), %rdx     # 0x6b458
callq 0x63d0
leaq 0x57221(%rip), %rdi     # 0x6b970
callq 0x62e0
movq -0xf8(%rbp), %rdi
addq $0x20, %rdi
callq 0xf7d0
movq %rax, -0x20(%rbp)
movq -0xf8(%rbp), %rdi
addq $0x20, %rdi
callq 0xf9c0
movq %rax, -0x28(%rbp)
leaq -0x20(%rbp), %rdi
leaq -0x28(%rbp), %rsi
callq 0xf980
testb $0x1, %al
jne 0x1478f
jmp 0x1480c
leaq -0x20(%rbp), %rdi
callq 0x15190
movq %rax, %rdi
callq 0x6640
cmpq $0x1, %rax
jae 0x147f8
movq -0xf8(%rbp), %rax
addq $0x20, %rax
movq %rax, -0x100(%rbp)
leaq -0x30(%rbp), %rdi
leaq -0x20(%rbp), %rsi
callq 0xf880
movq -0x100(%rbp), %rdi
movq -0x30(%rbp), %rsi
callq 0x163d0
movq %rax, -0x38(%rbp)
jmp 0x14807
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x10(%rbp)
movl %eax, -0x14(%rbp)
leaq 0x57182(%rip), %rdi     # 0x6b970
callq 0x62d0
jmp 0x14b02
leaq -0x20(%rbp), %rdi
xorl %esi, %esi
callq 0xfa10
movq %rax, -0x40(%rbp)
jmp 0x14768
movq $0x0, -0x48(%rbp)
movq -0xf8(%rbp), %rdi
movq -0x48(%rbp), %rax
movq %rax, -0x108(%rbp)
addq $0x20, %rdi
callq 0x11210
movq %rax, %rcx
movq -0x108(%rbp), %rax
cmpq %rcx, %rax
jae 0x14af9
movq -0xf8(%rbp), %rdi
addq $0x20, %rdi
movq -0x48(%rbp), %rsi
callq 0x162c0
movq %rax, -0x50(%rbp)
leaq -0x70(%rbp), %rdi
movq %rdi, -0x118(%rbp)
callq 0x15150
movq -0x118(%rbp), %rsi
movq -0x50(%rbp), %rdi
leaq 0x570d4(%rip), %rdx     # 0x6b950
xorl %ecx, %ecx
callq 0x15670
movb %al, -0x109(%rbp)
jmp 0x1488b
movb -0x109(%rbp), %al
testb $0x1, %al
jne 0x1489a
jmp 0x14ad4
leaq -0x70(%rbp), %rdi
movl $0x1, %esi
callq 0x157b0
movq %rax, -0x120(%rbp)
jmp 0x148b1
movq -0x120(%rbp), %rdi
callq 0x16530
movq %rax, -0x128(%rbp)
movq -0x50(%rbp), %rdi
callq 0x6640
movq %rax, %rcx
movq -0x128(%rbp), %rax
cmpq %rcx, %rax
je 0x14ac6
leaq -0x70(%rbp), %rdi
movl $0x2, %esi
callq 0x157b0
movq %rax, -0x130(%rbp)
jmp 0x148f7
movq -0x130(%rbp), %rsi
leaq -0x90(%rbp), %rdi
callq 0x15820
jmp 0x1490c
movq -0x50(%rbp), %rax
movq %rax, -0x148(%rbp)
movq %rax, -0x140(%rbp)
leaq -0x70(%rbp), %rdi
movl $0x1, %esi
callq 0x157b0
movq %rax, -0x138(%rbp)
jmp 0x14935
movq -0x138(%rbp), %rsi
leaq -0xb0(%rbp), %rdi
callq 0x15820
jmp 0x1494a
movq -0x148(%rbp), %rdi
xorl %eax, %eax
movl %eax, %edx
leaq -0xb0(%rbp), %rsi
callq 0x6880
movq %rax, -0x158(%rbp)
leaq -0x70(%rbp), %rdi
movl $0x1, %esi
callq 0x157b0
movq %rax, -0x150(%rbp)
jmp 0x1497f
movq -0x150(%rbp), %rdi
callq 0x16530
movq -0x140(%rbp), %rdi
movq -0x158(%rbp), %rsi
movq %rax, %rdx
callq 0x60e0
jmp 0x149a3
leaq -0xb0(%rbp), %rdi
callq 0x62a0
movq -0xf8(%rbp), %rdi
addq $0x20, %rdi
movq %rdi, -0x160(%rbp)
callq 0xf7d0
movq %rax, -0xc8(%rbp)
movq -0x48(%rbp), %rsi
leaq -0xc8(%rbp), %rdi
callq 0xf800
movq %rax, -0xc0(%rbp)
leaq -0xb8(%rbp), %rdi
leaq -0xc0(%rbp), %rsi
callq 0xf880
leaq 0x35a86(%rip), %rdx     # 0x4a484
leaq -0xe8(%rbp), %rdi
leaq -0x90(%rbp), %rsi
callq 0xf8c0
jmp 0x14a13
movq -0x160(%rbp), %rdi
movq -0xb8(%rbp), %rsi
leaq -0xe8(%rbp), %rdx
callq 0xf790
movq %rax, -0x168(%rbp)
jmp 0x14a36
movq -0x168(%rbp), %rax
movq %rax, -0xf0(%rbp)
leaq -0xe8(%rbp), %rdi
callq 0x62a0
movq -0x48(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x48(%rbp)
leaq -0x90(%rbp), %rdi
callq 0x62a0
jmp 0x14ac6
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x10(%rbp)
movl %eax, -0x14(%rbp)
jmp 0x14aee
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x10(%rbp)
movl %eax, -0x14(%rbp)
jmp 0x14ab8
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x10(%rbp)
movl %eax, -0x14(%rbp)
leaq -0xb0(%rbp), %rdi
callq 0x62a0
jmp 0x14ab8
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x10(%rbp)
movl %eax, -0x14(%rbp)
leaq -0xe8(%rbp), %rdi
callq 0x62a0
leaq -0x90(%rbp), %rdi
callq 0x62a0
jmp 0x14aee
movq -0x48(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x48(%rbp)
jmp 0x14ae0
movq -0x48(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x48(%rbp)
leaq -0x70(%rbp), %rdi
callq 0x162a0
jmp 0x14814
leaq -0x70(%rbp), %rdi
callq 0x162a0
jmp 0x14b02
addq $0x170, %rsp            # imm = 0x170
popq %rbp
retq
movq -0x10(%rbp), %rdi
callq 0x6790
nopl (%rax,%rax)