// File: /workspace/github_c_makefile_star2_O1/xiongxu[P]bam2bedGraph2/samtools-0.1.19/bam_plcmd.c
// Function: bam_mpileup
int bam_mpileup(int argc, char *argv[])
{
	int c;
    const char *file_list = NULL;
    char **fn = NULL;
    int nfiles = 0, use_orphan = 0;
	mplp_conf_t mplp;
	memset(&mplp, 0, sizeof(mplp_conf_t));
	mplp.max_mq = 60;
	mplp.min_baseQ = 13;
	mplp.capQ_thres = 0;
	mplp.max_depth = 250; mplp.max_indel_depth = 250;
	mplp.openQ = 40; mplp.extQ = 20; mplp.tandemQ = 100;
	mplp.min_frac = 0.002; mplp.min_support = 1;
	mplp.flag = MPLP_NO_ORPHAN | MPLP_REALN;
    static struct option lopts[] = 
    {
        {"rf",1,0,1},   // require flag
        {"ff",1,0,2},   // filter flag
        {0,0,0,0}
    };
	while ((c = getopt_long(argc, argv, "Agf:r:l:M:q:Q:uaRC:BDSd:L:b:P:po:e:h:Im:F:EG:6OsV1:2:",lopts,NULL)) >= 0) {
		switch (c) {
        case  1 : mplp.rflag_require = strtol(optarg,0,0); break;
        case  2 : mplp.rflag_filter  = strtol(optarg,0,0); break;
		case 'f':
			mplp.fai = fai_load(optarg);
			if (mplp.fai == 0) return 1;
            mplp.fai_fname = optarg;
			break;
		case 'd': mplp.max_depth = atoi(optarg); break;
		case 'r': mplp.reg = strdup(optarg); break;
		case 'l': mplp.bed = bed_read(optarg); break;
		case 'P': mplp.pl_list = strdup(optarg); break;
		case 'p': mplp.flag |= MPLP_PER_SAMPLE; break;
		case 'g': mplp.flag |= MPLP_GLF; break;
		case 'u': mplp.flag |= MPLP_NO_COMP | MPLP_GLF; break;
		case 'a': mplp.flag |= MPLP_NO_ORPHAN | MPLP_REALN; break;
		case 'B': mplp.flag &= ~MPLP_REALN; break;
		case 'D': mplp.fmt_flag |= B2B_FMT_DP; break;
		case 'S': mplp.fmt_flag |= B2B_FMT_SP; break;
		case 'V': mplp.fmt_flag |= B2B_FMT_DV; break;
		case 'I': mplp.flag |= MPLP_NO_INDEL; break;
		case 'E': mplp.flag |= MPLP_REDO_BAQ; break;
		case '6': mplp.flag |= MPLP_ILLUMINA13; break;
		case 'R': mplp.flag |= MPLP_IGNORE_RG; break;
		case 's': mplp.flag |= MPLP_PRINT_MAPQ; break;
		case 'O': mplp.flag |= MPLP_PRINT_POS; break;
		case 'C': mplp.capQ_thres = atoi(optarg); break;
		case 'M': mplp.max_mq = atoi(optarg); break;
		case 'q': mplp.min_mq = atoi(optarg); break;
		case 'Q': mplp.min_baseQ = atoi(optarg); break;
        case 'b': file_list = optarg; break;
		case 'o': mplp.openQ = atoi(optarg); break;
		case 'e': mplp.extQ = atoi(optarg); break;
		case 'h': mplp.tandemQ = atoi(optarg); break;
		case 'A': use_orphan = 1; break;
		case 'F': mplp.min_frac = atof(optarg); break;
		case 'm': mplp.min_support = atoi(optarg); break;
		case 'L': mplp.max_indel_depth = atoi(optarg); break;
		case 'G': {
				FILE *fp_rg;
				char buf[1024];
				mplp.rghash = bcf_str2id_init();
				if ((fp_rg = fopen(optarg, "r")) == 0)
					fprintf(stderr, "(%s) Fail to open file %s. Continue anyway.\n", __func__, optarg);
				while (!feof(fp_rg) && fscanf(fp_rg, "%s", buf) > 0) // this is not a good style, but forgive me...
					bcf_str2id_add(mplp.rghash, strdup(buf));
				fclose(fp_rg);
			}
			break;
		}
	}
	if (use_orphan) mplp.flag &= ~MPLP_NO_ORPHAN;
	if (argc == 1) {
		fprintf(stderr, "\n");
		fprintf(stderr, "Usage: samtools mpileup [options] in1.bam [in2.bam [...]]\n\n");
		fprintf(stderr, "Input options:\n\n");
		fprintf(stderr, "       -6           assume the quality is in the Illumina-1.3+ encoding\n");
		fprintf(stderr, "       -A           count anomalous read pairs\n");
		fprintf(stderr, "       -B           disable BAQ computation\n");
		fprintf(stderr, "       -b FILE      list of input BAM filenames, one per line [null]\n");
		fprintf(stderr, "       -C INT       parameter for adjusting mapQ; 0 to disable [0]\n");
		fprintf(stderr, "       -d INT       max per-BAM depth to avoid excessive memory usage [%d]\n", mplp.max_depth);
		fprintf(stderr, "       -E           recalculate extended BAQ on the fly thus ignoring existing BQs\n");
		fprintf(stderr, "       -f FILE      faidx indexed reference sequence file [null]\n");
		fprintf(stderr, "       -G FILE      exclude read groups listed in FILE [null]\n");
		fprintf(stderr, "       -l FILE      list of positions (chr pos) or regions (BED) [null]\n");
		fprintf(stderr, "       -M INT       cap mapping quality at INT [%d]\n", mplp.max_mq);
		fprintf(stderr, "       -r STR       region in which pileup is generated [null]\n");
		fprintf(stderr, "       -R           ignore RG tags\n");
		fprintf(stderr, "       -q INT       skip alignments with mapQ smaller than INT [%d]\n", mplp.min_mq);
		fprintf(stderr, "       -Q INT       skip bases with baseQ/BAQ smaller than INT [%d]\n", mplp.min_baseQ);
		fprintf(stderr, "       --rf INT     required flags: skip reads with mask bits unset []\n");
		fprintf(stderr, "       --ff INT     filter flags: skip reads with mask bits set []\n");
		fprintf(stderr, "\nOutput options:\n\n");
		fprintf(stderr, "       -D           output per-sample DP in BCF (require -g/-u)\n");
		fprintf(stderr, "       -g           generate BCF output (genotype likelihoods)\n");
		fprintf(stderr, "       -O           output base positions on reads (disabled by -g/-u)\n");
		fprintf(stderr, "       -s           output mapping quality (disabled by -g/-u)\n");
		fprintf(stderr, "       -S           output per-sample strand bias P-value in BCF (require -g/-u)\n");
		fprintf(stderr, "       -u           generate uncompress BCF output\n");
		fprintf(stderr, "\nSNP/INDEL genotype likelihoods options (effective with `-g' or `-u'):\n\n");
		fprintf(stderr, "       -e INT       Phred-scaled gap extension seq error probability [%d]\n", mplp.extQ);
		fprintf(stderr, "       -F FLOAT     minimum fraction of gapped reads for candidates [%g]\n", mplp.min_frac);
		fprintf(stderr, "       -h INT       coefficient for homopolymer errors [%d]\n", mplp.tandemQ);
		fprintf(stderr, "       -I           do not perform indel calling\n");
		fprintf(stderr, "       -L INT       max per-sample depth for INDEL calling [%d]\n", mplp.max_indel_depth);
		fprintf(stderr, "       -m INT       minimum gapped reads for indel candidates [%d]\n", mplp.min_support);
		fprintf(stderr, "       -o INT       Phred-scaled gap open sequencing error probability [%d]\n", mplp.openQ);
		fprintf(stderr, "       -p           apply -m and -F per-sample to increase sensitivity\n");
		fprintf(stderr, "       -P STR       comma separated list of platforms for indels [all]\n");
		fprintf(stderr, "\n");
		fprintf(stderr, "Notes: Assuming diploid individuals.\n\n");
		return 1;
	}
	bam_no_B = 1;
    if (file_list) {
        if ( read_file_list(file_list,&nfiles,&fn) ) return 1;
        mpileup(&mplp,nfiles,fn);
        for (c=0; c<nfiles; c++) free(fn[c]);
        free(fn);
    } else mpileup(&mplp, argc - optind, argv + optind);
	if (mplp.rghash) bcf_str2id_thorough_destroy(mplp.rghash);
	free(mplp.reg); free(mplp.pl_list);
	if (mplp.fai) fai_destroy(mplp.fai);
	if (mplp.bed) bed_destroy(mplp.bed);
	return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x4a8, %rsp            # imm = 0x4A8
movq %rsi, %r14
movl %edi, %ebx
movq $0x0, 0x90(%rsp)
movl $0x0, 0xc(%rsp)
xorps %xmm0, %xmm0
movaps %xmm0, 0x10(%rsp)
movaps %xmm0, 0x20(%rsp)
movaps %xmm0, 0x30(%rsp)
movaps %xmm0, 0x40(%rsp)
movaps %xmm0, 0x70(%rsp)
movaps %xmm0, 0x60(%rsp)
movaps %xmm0, 0x50(%rsp)
movl $0x3c, 0x10(%rsp)
movabsq $0xfa00000000, %rax     # imm = 0xFA00000000
movq %rax, 0x20(%rsp)
movl $0xfa, 0x28(%rsp)
movabsq $0x1400000028, %rax     # imm = 0x1400000028
movq %rax, 0x38(%rsp)
movabsq $0x100000064, %rax      # imm = 0x100000064
movq %rax, 0x40(%rsp)
movabsq $0x3f60624dd2f1a9fc, %rax # imm = 0x3F60624DD2F1A9FC
movq %rax, 0x48(%rsp)
movabsq $0xd000000c0, %rax      # imm = 0xD000000C0
movq %rax, 0x18(%rsp)
leaq 0x36e4c(%rip), %rdx     # 0x3e4db
leaq 0x47d9a(%rip), %rcx     # 0x4f430
xorl %r15d, %r15d
xorl %r8d, %r8d
callq 0x3500
testl %eax, %eax
js 0x7993
movq 0x47930(%rip), %rbp     # 0x4efe0
leaq 0x47d79(%rip), %r13     # 0x4f430
leaq 0x36c6a(%rip), %r12     # 0x3e328
movq $0x0, 0x88(%rsp)
leal -0x36(%rax), %ecx
cmpl $0x3f, %ecx
ja 0x76e5
movslq (%r12,%rcx,4), %rax
addq %r12, %rax
jmpq *%rax
orb $0x10, 0x19(%rsp)
jmp 0x7958
cmpl $0x2, %eax
je 0x7947
cmpl $0x1, %eax
jne 0x7958
movq (%rbp), %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x34b0
movl %eax, 0x30(%rsp)
jmp 0x7958
movq (%rbp), %rdi
callq 0x34c0
movl %eax, 0x38(%rsp)
jmp 0x7958
movq (%rbp), %rdi
callq 0x34c0
movl %eax, 0x44(%rsp)
jmp 0x7958
movq (%rbp), %rdi
callq 0x34c0
movl %eax, 0x40(%rsp)
jmp 0x7958
orb $0x20, 0x19(%rsp)
jmp 0x7958
orb $0x4, 0x19(%rsp)
jmp 0x7958
movq (%rbp), %rdi
callq 0x34c0
movl %eax, 0x14(%rsp)
jmp 0x7958
movq (%rbp), %rdi
callq 0x34c0
movl %eax, 0x3c(%rsp)
jmp 0x7958
movq (%rbp), %rdi
callq 0x34c0
movl %eax, 0x10(%rsp)
jmp 0x7958
movq %r15, 0x98(%rsp)
xorl %eax, %eax
callq 0x3be23
movq %rax, 0x78(%rsp)
movq (%rbp), %rdi
leaq 0x3d4c3(%rip), %rsi     # 0x44c6f
callq 0x36f0
movq %rax, %rbp
testq %rax, %rax
je 0x7979
movq %rbp, %rdi
callq 0x3630
testl %eax, %eax
jne 0x7805
leaq 0x3cf61(%rip), %rsi     # 0x44731
leaq 0xa0(%rsp), %rdx
movq %rbp, %rdi
xorl %eax, %eax
callq 0x30f0
testl %eax, %eax
jle 0x7805
movq 0x78(%rsp), %r15
leaq 0xa0(%rsp), %rdi
callq 0x3570
movq %r15, %rdi
movq %rax, %rsi
callq 0x3bffd
jmp 0x77bd
movq %rbp, %rdi
callq 0x3640
movq 0x98(%rsp), %r15
movq 0x477c4(%rip), %rbp     # 0x4efe0
jmp 0x7958
orb $0x2, 0x2c(%rsp)
jmp 0x7958
movq (%rbp), %rdi
callq 0x34c0
movl %eax, 0x28(%rsp)
jmp 0x7958
orb $-0x40, 0x18(%rsp)
jmp 0x7958
movq (%rbp), %rdi
callq 0x3570
movq %rax, 0x50(%rsp)
jmp 0x7958
movq (%rbp), %rdi
callq 0x32b0
movsd %xmm0, 0x48(%rsp)
jmp 0x7958
movq (%rbp), %rdi
callq 0x34c0
movl %eax, 0x1c(%rsp)
jmp 0x7958
movq (%rbp), %rdi
callq 0x34c0
movl %eax, 0x20(%rsp)
jmp 0x7958
movq (%rbp), %rdi
callq 0x3570
movq %rax, 0x58(%rsp)
jmp 0x7958
movl $0x1, %r15d
jmp 0x7958
andb $0x7f, 0x18(%rsp)
jmp 0x7958
orb $0x1, 0x2c(%rsp)
jmp 0x7958
movq (%rbp), %rdi
callq 0x34c0
movl %eax, 0x24(%rsp)
jmp 0x7958
movq (%rbp), %rax
movq %rax, 0x88(%rsp)
jmp 0x7958
orb $0x40, 0x19(%rsp)
jmp 0x7958
orb $-0x80, 0x19(%rsp)
jmp 0x7958
movq (%rbp), %rdi
callq 0x2ee9e
movq %rax, 0x68(%rsp)
testq %rax, %rax
je 0x7e26
movq (%rbp), %rax
movq %rax, 0x60(%rsp)
jmp 0x7958
orb $0x8, 0x19(%rsp)
jmp 0x7958
orb $0x4, 0x2c(%rsp)
jmp 0x7958
orb $0x10, 0x18(%rsp)
jmp 0x7958
orb $0x30, 0x18(%rsp)
jmp 0x7958
orb $0x1, 0x1a(%rsp)
jmp 0x7958
movq (%rbp), %rdi
callq 0x306fa
movq %rax, 0x70(%rsp)
jmp 0x7958
movq (%rbp), %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x34b0
movl %eax, 0x34(%rsp)
movl %ebx, %edi
movq %r14, %rsi
leaq 0x36b77(%rip), %rdx     # 0x3e4db
movq %r13, %rcx
xorl %r8d, %r8d
callq 0x3500
testl %eax, %eax
jns 0x76ca
jmp 0x7983
callq 0x390e
jmp 0x77bd
testl %r15d, %r15d
sete %al
movq 0x88(%rsp), %r15
jmp 0x7995
movb $0x1, %al
testb %al, %al
jne 0x799e
andb $-0x41, 0x18(%rsp)
cmpl $0x1, %ebx
je 0x7a8e
leaq 0x489be(%rip), %rax     # 0x5036c
movl $0x1, (%rax)
testq %r15, %r15
je 0x7a1b
leaq 0xc(%rsp), %rsi
leaq 0x90(%rsp), %rdx
movq %r15, %rdi
callq 0x7400
movl $0x1, %ebx
testl %eax, %eax
jne 0x7a7a
movslq 0xc(%rsp), %r14
movq 0x90(%rsp), %rbx
leaq 0x10(%rsp), %rdi
movl %r14d, %esi
movq %rbx, %rdx
callq 0x7e30
testq %r14, %r14
jle 0x7a11
xorl %r15d, %r15d
movq (%rbx,%r15,8), %rdi
callq 0x3350
incq %r15
cmpq %r15, %r14
jne 0x7a00
movq %rbx, %rdi
callq 0x3350
jmp 0x7a37
movq 0x47596(%rip), %rax     # 0x4efb8
movslq (%rax), %rax
subl %eax, %ebx
leaq (%r14,%rax,8), %rdx
leaq 0x10(%rsp), %rdi
movl %ebx, %esi
callq 0x7e30
movq 0x78(%rsp), %rdi
testq %rdi, %rdi
je 0x7a46
callq 0x3be60
movq 0x50(%rsp), %rdi
callq 0x3350
movq 0x58(%rsp), %rdi
callq 0x3350
movq 0x68(%rsp), %rdi
testq %rdi, %rdi
je 0x7a69
callq 0x2e970
movq 0x70(%rsp), %rdi
xorl %ebx, %ebx
testq %rdi, %rdi
je 0x7a7a
callq 0x30e77
movl %ebx, %eax
addq $0x4a8, %rsp            # imm = 0x4A8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x47553(%rip), %rbx     # 0x4efe8
movq (%rbx), %rsi
movl $0xa, %edi
callq 0x3320
movq (%rbx), %rcx
leaq 0x36a9e(%rip), %rdi     # 0x3e54a
movl $0x3b, %esi
movl $0x1, %edx
callq 0x3700
movq (%rbx), %rcx
leaq 0x36ac1(%rip), %rdi     # 0x3e586
movl $0x10, %esi
movl $0x1, %edx
callq 0x3700
movq (%rbx), %rcx
leaq 0x36ab9(%rip), %rdi     # 0x3e597
movl $0x48, %esi
movl $0x1, %edx
callq 0x3700
movq (%rbx), %rcx
leaq 0x36ae9(%rip), %rdi     # 0x3e5e0
movl $0x2f, %esi
movl $0x1, %edx
callq 0x3700
movq (%rbx), %rcx
leaq 0x36b00(%rip), %rdi     # 0x3e610
movl $0x2c, %esi
movl $0x1, %edx
callq 0x3700
movq (%rbx), %rcx
leaq 0x36b14(%rip), %rdi     # 0x3e63d
movl $0x45, %esi
movl $0x1, %edx
callq 0x3700
movq (%rbx), %rcx
leaq 0x36b41(%rip), %rdi     # 0x3e683
movl $0x43, %esi
movl $0x1, %edx
callq 0x3700
movq (%rbx), %rdi
movl 0x24(%rsp), %edx
leaq 0x36b68(%rip), %rsi     # 0x3e6c7
xorl %eax, %eax
callq 0x3750
movq (%rbx), %rcx
leaq 0x36ba3(%rip), %rdi     # 0x3e713
movl $0x53, %esi
movl $0x1, %edx
callq 0x3700
movq (%rbx), %rcx
leaq 0x36bde(%rip), %rdi     # 0x3e767
movl $0x41, %esi
movl $0x1, %edx
callq 0x3700
movq (%rbx), %rcx
leaq 0x36c07(%rip), %rdi     # 0x3e7a9
movl $0x3e, %esi
movl $0x1, %edx
callq 0x3700
movq (%rbx), %rcx
leaq 0x36c2d(%rip), %rdi     # 0x3e7e8
movl $0x48, %esi
movl $0x1, %edx
callq 0x3700
movq (%rbx), %rdi
movl 0x10(%rsp), %edx
leaq 0x36c59(%rip), %rsi     # 0x3e831
xorl %eax, %eax
callq 0x3750
movq (%rbx), %rcx
leaq 0x36c7d(%rip), %rdi     # 0x3e866
movl $0x3f, %esi
movl $0x1, %edx
callq 0x3700
movq (%rbx), %rcx
leaq 0x36ca4(%rip), %rdi     # 0x3e8a6
movl $0x23, %esi
movl $0x1, %edx
callq 0x3700
movq (%rbx), %rdi
movl 0x14(%rsp), %edx
leaq 0x36cab(%rip), %rsi     # 0x3e8ca
xorl %eax, %eax
callq 0x3750
movq (%rbx), %rdi
movl 0x1c(%rsp), %edx
leaq 0x36cdb(%rip), %rsi     # 0x3e90f
xorl %eax, %eax
callq 0x3750
movq (%rbx), %rcx
leaq 0x36d0f(%rip), %rdi     # 0x3e954
movl $0x47, %esi
movl $0x1, %edx
callq 0x3700
movq (%rbx), %rcx
leaq 0x36d3e(%rip), %rdi     # 0x3e99c
movl $0x43, %esi
movl $0x1, %edx
callq 0x3700
movq (%rbx), %rcx
leaq 0x36d69(%rip), %rdi     # 0x3e9e0
movl $0x12, %esi
movl $0x1, %edx
callq 0x3700
movq (%rbx), %rcx
leaq 0x36d63(%rip), %rdi     # 0x3e9f3
movl $0x40, %esi
movl $0x1, %edx
callq 0x3700
movq (%rbx), %rcx
leaq 0x36d8b(%rip), %rdi     # 0x3ea34
movl $0x3f, %esi
movl $0x1, %edx
callq 0x3700
movq (%rbx), %rcx
leaq 0x36db2(%rip), %rdi     # 0x3ea74
movl $0x47, %esi
movl $0x1, %edx
callq 0x3700
movq (%rbx), %rcx
leaq 0x36de1(%rip), %rdi     # 0x3eabc
movl $0x3f, %esi
movl $0x1, %edx
callq 0x3700
movq (%rbx), %rcx
leaq 0x36e08(%rip), %rdi     # 0x3eafc
movl $0x51, %esi
movl $0x1, %edx
callq 0x3700
movq (%rbx), %rcx
leaq 0x36e41(%rip), %rdi     # 0x3eb4e
movl $0x33, %esi
movl $0x1, %edx
callq 0x3700
movq (%rbx), %rcx
leaq 0x36e5c(%rip), %rdi     # 0x3eb82
movl $0x48, %esi
movl $0x1, %edx
callq 0x3700
movq (%rbx), %rdi
movl 0x3c(%rsp), %edx
leaq 0x36e88(%rip), %rsi     # 0x3ebcb
xorl %eax, %eax
callq 0x3750
movq (%rbx), %rdi
movsd 0x48(%rsp), %xmm0
leaq 0x36ebc(%rip), %rsi     # 0x3ec16
movb $0x1, %al
callq 0x3750
movq (%rbx), %rdi
movl 0x40(%rsp), %edx
leaq 0x36ef1(%rip), %rsi     # 0x3ec60
xorl %eax, %eax
callq 0x3750
movq (%rbx), %rcx
leaq 0x36f1d(%rip), %rdi     # 0x3ec9d
movl $0x31, %esi
movl $0x1, %edx
callq 0x3700
movq (%rbx), %rdi
movl 0x28(%rsp), %edx
leaq 0x36f32(%rip), %rsi     # 0x3eccf
xorl %eax, %eax
callq 0x3750
movq (%rbx), %rdi
movl 0x44(%rsp), %edx
leaq 0x36f5e(%rip), %rsi     # 0x3ed10
xorl %eax, %eax
callq 0x3750
movq (%rbx), %rdi
movl 0x38(%rsp), %edx
leaq 0x36f8d(%rip), %rsi     # 0x3ed54
xorl %eax, %eax
callq 0x3750
movq (%rbx), %rcx
leaq 0x36fc9(%rip), %rdi     # 0x3eda1
movl $0x47, %esi
movl $0x1, %edx
callq 0x3700
movq (%rbx), %rcx
leaq 0x36ff8(%rip), %rdi     # 0x3ede9
movl $0x47, %esi
movl $0x1, %edx
callq 0x3700
movq (%rbx), %rsi
movl $0xa, %edi
callq 0x3320
movq (%rbx), %rcx
leaq 0x3701a(%rip), %rdi     # 0x3ee31
movl $0x26, %esi
movl $0x1, %edx
callq 0x3700
movl $0x1, %ebx
jmp 0x7a7a