// File: WeichenZhou[P]PALMER/./scp/1_samtools.cpp
// Function: samtools(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>)
int samtools(string working_dir, string input_bam, string chr, string start, string end, string fasta){
    
    //cout<<"Samtools Step is now running."<<endl;
    //##########hard code warming########## -q -F ##########
    //std::ios::sync_with_stdio(false);
    //std::cin.tie(0);
    
    string sys;
    sys="samtools view -q 10 -F 0x100 -F 0x200  -F 0x400 -T "+fasta+" "+input_bam+" "+chr+":"+start+"-"+end+" |sed -e 's/[ ][ ]*/_/g'  > "+working_dir+"region.sam";
    
    char *syst = new char[sys.length()+1];
    strcpy(syst, sys.c_str());
    system(syst);
    
    //string sys_replace;
    //sys_replace="sed -e 's/[ ][ ]*/_/g' "+working_dir+"region.pre.sam"+" > "+working_dir+"region.sam";
    
    ///char *syst_replace = new char[sys_replace.length()+1];
    //strcpy(syst_replace, sys_replace.c_str());
    //system(syst_replace);
    
    return 0;
}

// Assembly:
subq $0x238, %rsp            # imm = 0x238
movq %rdi, 0x20(%rsp)
movq %rsi, 0x28(%rsp)
movq %rdx, 0x30(%rsp)
movq %rcx, 0x38(%rsp)
movq %r8, 0x40(%rsp)
movq %r9, 0x48(%rsp)
movq %rdi, 0x230(%rsp)
movq %rsi, 0x228(%rsp)
movq %rdx, 0x220(%rsp)
movq %rcx, 0x218(%rsp)
movq %r8, 0x210(%rsp)
movq %r9, 0x208(%rsp)
leaq 0x1e8(%rsp), %rdi
callq 0x3370
movq 0x48(%rsp), %rdx
leaq 0x409b2(%rip), %rsi     # 0x44020
leaq 0x68(%rsp), %rdi
callq 0x42550
jmp 0x367a
leaq 0x40b01(%rip), %rdx     # 0x44182
leaq 0x88(%rsp), %rdi
leaq 0x68(%rsp), %rsi
callq 0x424b0
jmp 0x3695
movq 0x28(%rsp), %rdx
leaq 0xa8(%rsp), %rdi
leaq 0x88(%rsp), %rsi
callq 0x42500
jmp 0x36b1
leaq 0x40aca(%rip), %rdx     # 0x44182
leaq 0xc8(%rsp), %rdi
leaq 0xa8(%rsp), %rsi
callq 0x424b0
jmp 0x36cf
movq 0x30(%rsp), %rdx
leaq 0xe8(%rsp), %rdi
leaq 0xc8(%rsp), %rsi
callq 0x42500
jmp 0x36eb
leaq 0x41699(%rip), %rdx     # 0x44d8b
leaq 0x108(%rsp), %rdi
leaq 0xe8(%rsp), %rsi
callq 0x424b0
jmp 0x3709
movq 0x38(%rsp), %rdx
leaq 0x128(%rsp), %rdi
leaq 0x108(%rsp), %rsi
callq 0x42500
jmp 0x3725
leaq 0x40928(%rip), %rdx     # 0x44054
leaq 0x148(%rsp), %rdi
leaq 0x128(%rsp), %rsi
callq 0x424b0
jmp 0x3743
movq 0x40(%rsp), %rdx
leaq 0x168(%rsp), %rdi
leaq 0x148(%rsp), %rsi
callq 0x42500
jmp 0x375f
leaq 0x408f0(%rip), %rdx     # 0x44056
leaq 0x188(%rsp), %rdi
leaq 0x168(%rsp), %rsi
callq 0x424b0
jmp 0x377d
movq 0x20(%rsp), %rdx
leaq 0x1a8(%rsp), %rdi
leaq 0x188(%rsp), %rsi
callq 0x42500
jmp 0x3799
leaq 0x408d3(%rip), %rdx     # 0x44073
leaq 0x1c8(%rsp), %rdi
leaq 0x1a8(%rsp), %rsi
callq 0x424b0
jmp 0x37b7
leaq 0x1e8(%rsp), %rdi
movq %rdi, 0x10(%rsp)
leaq 0x1c8(%rsp), %rsi
movq %rsi, 0x8(%rsp)
callq 0x3300
movq 0x8(%rsp), %rdi
callq 0x31b0
leaq 0x1a8(%rsp), %rdi
callq 0x31b0
leaq 0x188(%rsp), %rdi
callq 0x31b0
leaq 0x168(%rsp), %rdi
callq 0x31b0
leaq 0x148(%rsp), %rdi
callq 0x31b0
leaq 0x128(%rsp), %rdi
callq 0x31b0
leaq 0x108(%rsp), %rdi
callq 0x31b0
leaq 0xe8(%rsp), %rdi
callq 0x31b0
leaq 0xc8(%rsp), %rdi
callq 0x31b0
leaq 0xa8(%rsp), %rdi
callq 0x31b0
leaq 0x88(%rsp), %rdi
callq 0x31b0
leaq 0x68(%rsp), %rdi
callq 0x31b0
movq 0x10(%rsp), %rdi
callq 0x33c0
movq %rax, %rdi
incq %rdi
callq 0x3030
movq %rax, 0x18(%rsp)
jmp 0x3888
movq 0x18(%rsp), %rax
movq %rax, 0x50(%rsp)
movq 0x50(%rsp), %rax
movq %rax, (%rsp)
leaq 0x1e8(%rsp), %rdi
callq 0x3110
movq (%rsp), %rdi
movq %rax, %rsi
callq 0x3250
movq 0x50(%rsp), %rdi
callq 0x3220
jmp 0x38c0
leaq 0x1e8(%rsp), %rdi
callq 0x31b0
xorl %eax, %eax
addq $0x238, %rsp            # imm = 0x238
retq
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x60(%rsp)
movl %eax, 0x5c(%rsp)
jmp 0x3a36
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x60(%rsp)
movl %eax, 0x5c(%rsp)
jmp 0x3a2c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x60(%rsp)
movl %eax, 0x5c(%rsp)
jmp 0x3a1f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x60(%rsp)
movl %eax, 0x5c(%rsp)
jmp 0x3a12
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x60(%rsp)
movl %eax, 0x5c(%rsp)
jmp 0x3a05
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x60(%rsp)
movl %eax, 0x5c(%rsp)
jmp 0x39f8
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x60(%rsp)
movl %eax, 0x5c(%rsp)
jmp 0x39eb
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x60(%rsp)
movl %eax, 0x5c(%rsp)
jmp 0x39de
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x60(%rsp)
movl %eax, 0x5c(%rsp)
jmp 0x39d1
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x60(%rsp)
movl %eax, 0x5c(%rsp)
jmp 0x39c4
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x60(%rsp)
movl %eax, 0x5c(%rsp)
jmp 0x39b7
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x60(%rsp)
movl %eax, 0x5c(%rsp)
leaq 0x1a8(%rsp), %rdi
callq 0x31b0
leaq 0x188(%rsp), %rdi
callq 0x31b0
leaq 0x168(%rsp), %rdi
callq 0x31b0
leaq 0x148(%rsp), %rdi
callq 0x31b0
leaq 0x128(%rsp), %rdi
callq 0x31b0
leaq 0x108(%rsp), %rdi
callq 0x31b0
leaq 0xe8(%rsp), %rdi
callq 0x31b0
leaq 0xc8(%rsp), %rdi
callq 0x31b0
leaq 0xa8(%rsp), %rdi
callq 0x31b0
leaq 0x88(%rsp), %rdi
callq 0x31b0
leaq 0x68(%rsp), %rdi
callq 0x31b0
leaq 0x1e8(%rsp), %rdi
callq 0x31b0
movq 0x60(%rsp), %rdi
callq 0x3450
nopl (%rax)