// File: readmapping[P]alfalfa/src/main.cpp
// Function: createHeader[abi:cxx11](int, char**, long, sparseSA*)
string createHeader(int argc, char* argv[], long refLength, sparseSA *sa) {
    stringstream ss;
    ss << "@HD\tVN:" << SAM_VERSION << endl;
    for (size_t i = 0; i < sa->descr.size() - 1; i++) {
        long length = sa->startpos[i + 1] - sa->startpos[i] - 1;
        ss << "@SQ\tSN:" << sa->descr[i] << "\tLN:" << length << endl; //startpos contains refSequences with '`' in between.
    }
    long length = refLength - sa->startpos[sa->descr.size() - 1];
    ss << "@SQ\tSN:" << sa->descr[sa->descr.size() - 1] << "\tLN:" << length << endl;
    ss << "@PG\tID:" << PROG << "\tCL:";
    for (int i = 0; i < argc; i++) {
        if (i > 0)
            ss << " ";
        ss << argv[i]; //add number to the stream
    }
    ss << "\tVN:" << PROG_VERSION << endl;
    return ss.str();
}

// Assembly:
subq $0x288, %rsp            # imm = 0x288
movq %rdi, 0x90(%rsp)
movq %rdi, %rax
movq %rax, 0x98(%rsp)
movq %rdi, 0x280(%rsp)
movl %esi, 0x27c(%rsp)
movq %rdx, 0x270(%rsp)
movq %rcx, 0x268(%rsp)
movq %r8, 0x260(%rsp)
leaq 0xd8(%rsp), %rdi
callq 0x8260
leaq 0xe8(%rsp), %rdi
leaq 0x6eeae(%rip), %rsi     # 0x7914b
callq 0x8360
movq %rax, 0xa0(%rsp)
jmp 0xa2ac
movq 0xa0(%rsp), %rdi
leaq 0x8d1b5(%rip), %rsi     # 0x97470
callq 0x8330
movq %rax, 0x88(%rsp)
jmp 0xa2ca
movq 0x88(%rsp), %rdi
movq 0x8ccd7(%rip), %rsi     # 0x96fb0
callq 0x83b0
jmp 0xa2e0
movq $0x0, 0xc0(%rsp)
movq 0xc0(%rsp), %rax
movq %rax, 0x80(%rsp)
movq 0x260(%rsp), %rdi
callq 0xccb0
movq %rax, %rcx
movq 0x80(%rsp), %rax
subq $0x1, %rcx
cmpq %rcx, %rax
jae 0xa43d
movq 0x260(%rsp), %rdi
addq $0x18, %rdi
movq 0xc0(%rsp), %rsi
incq %rsi
callq 0xccd0
movq (%rax), %rax
movq %rax, 0x70(%rsp)
movq 0x260(%rsp), %rdi
addq $0x18, %rdi
movq 0xc0(%rsp), %rsi
callq 0xccd0
movq 0x70(%rsp), %rcx
movq (%rax), %rax
notq %rax
addq %rcx, %rax
movq %rax, 0xb8(%rsp)
leaq 0xe8(%rsp), %rdi
leaq 0x6edd0(%rip), %rsi     # 0x79153
callq 0x8360
movq %rax, 0x78(%rsp)
jmp 0xa38f
movq 0x260(%rsp), %rdi
movq 0xc0(%rsp), %rsi
callq 0xccf0
movq 0x78(%rsp), %rdi
movq %rax, %rsi
callq 0x8330
movq %rax, 0x68(%rsp)
jmp 0xa3b8
movq 0x68(%rsp), %rdi
leaq 0x6ed97(%rip), %rsi     # 0x7915b
callq 0x8360
movq %rax, 0x60(%rsp)
jmp 0xa3d0
movq 0x60(%rsp), %rdi
movq 0xb8(%rsp), %rsi
callq 0x8790
movq %rax, 0x58(%rsp)
jmp 0xa3e9
movq 0x58(%rsp), %rdi
movq 0x8cbbb(%rip), %rsi     # 0x96fb0
callq 0x83b0
jmp 0xa3fc
jmp 0xa3fe
movq 0xc0(%rsp), %rax
addq $0x1, %rax
movq %rax, 0xc0(%rsp)
jmp 0xa2ec
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xd0(%rsp)
movl %eax, 0xcc(%rsp)
leaq 0xd8(%rsp), %rdi
callq 0x8290
jmp 0xa651
movq 0x268(%rsp), %rax
movq %rax, 0x48(%rsp)
movq 0x260(%rsp), %rdi
movq %rdi, %rax
addq $0x18, %rax
movq %rax, 0x40(%rsp)
callq 0xccb0
movq 0x40(%rsp), %rdi
movq %rax, %rsi
decq %rsi
callq 0xccd0
movq %rax, %rcx
movq 0x48(%rsp), %rax
movq (%rcx), %rcx
subq %rcx, %rax
movq %rax, 0xb0(%rsp)
leaq 0xe8(%rsp), %rdi
leaq 0x6ecbb(%rip), %rsi     # 0x79153
callq 0x8360
movq %rax, 0x50(%rsp)
jmp 0xa4a4
movq 0x260(%rsp), %rdi
movq %rdi, 0x30(%rsp)
callq 0xccb0
movq 0x30(%rsp), %rdi
movq %rax, %rsi
decq %rsi
callq 0xccf0
movq 0x50(%rsp), %rdi
movq %rax, %rsi
callq 0x8330
movq %rax, 0x38(%rsp)
jmp 0xa4da
movq 0x38(%rsp), %rdi
leaq 0x6ec75(%rip), %rsi     # 0x7915b
callq 0x8360
movq %rax, 0x28(%rsp)
jmp 0xa4f2
movq 0x28(%rsp), %rdi
movq 0xb0(%rsp), %rsi
callq 0x8790
movq %rax, 0x20(%rsp)
jmp 0xa50b
movq 0x20(%rsp), %rdi
movq 0x8ca99(%rip), %rsi     # 0x96fb0
callq 0x83b0
jmp 0xa51e
leaq 0xe8(%rsp), %rdi
leaq 0x6ec33(%rip), %rsi     # 0x79160
callq 0x8360
movq %rax, 0x18(%rsp)
jmp 0xa539
movq 0x18(%rsp), %rdi
leaq 0x8cf0b(%rip), %rsi     # 0x97450
callq 0x8330
movq %rax, 0x10(%rsp)
jmp 0xa551
movq 0x10(%rsp), %rdi
leaq 0x6ec0b(%rip), %rsi     # 0x79168
callq 0x8360
jmp 0xa564
movl $0x0, 0xac(%rsp)
movl 0xac(%rsp), %eax
cmpl 0x27c(%rsp), %eax
jge 0xa5d9
cmpl $0x0, 0xac(%rsp)
jle 0xa5a1
leaq 0xe8(%rsp), %rdi
leaq 0x74e7a(%rip), %rsi     # 0x7f412
callq 0x8360
jmp 0xa59f
jmp 0xa5a1
leaq 0xe8(%rsp), %rdi
movq 0x270(%rsp), %rax
movslq 0xac(%rsp), %rcx
movq (%rax,%rcx,8), %rsi
callq 0x8360
jmp 0xa5c4
jmp 0xa5c6
movl 0xac(%rsp), %eax
addl $0x1, %eax
movl %eax, 0xac(%rsp)
jmp 0xa56f
leaq 0xe8(%rsp), %rdi
leaq 0x6eb66(%rip), %rsi     # 0x7914e
callq 0x8360
movq %rax, 0x8(%rsp)
jmp 0xa5f4
movq 0x8(%rsp), %rdi
leaq 0x8ce90(%rip), %rsi     # 0x97490
callq 0x8330
movq %rax, (%rsp)
jmp 0xa60b
movq (%rsp), %rdi
movq 0x8c99a(%rip), %rsi     # 0x96fb0
callq 0x83b0
jmp 0xa61d
movq 0x90(%rsp), %rdi
leaq 0xd8(%rsp), %rsi
callq 0x8350
jmp 0xa634
leaq 0xd8(%rsp), %rdi
callq 0x8290
movq 0x98(%rsp), %rax
addq $0x288, %rsp            # imm = 0x288
retq
movq 0xd0(%rsp), %rdi
callq 0x8730
nop