LLM4Binary/decompile-bench-makefile huggingface dataset:
// File: /workspace/github_c_makefile_star2_O3/xiongxu[P]bam2bedGraph2/samtools-0.1.19/faidx.c
// Function: fai_read
faidx_t *fai_read(FILE *fp)
{
	faidx_t *fai;
	char *buf, *p;
	int len, line_len, line_blen;
#ifdef _WIN32
	long offset;
#else
	long long offset;
#endif
	fai = (faidx_t*)calloc(1, sizeof(faidx_t));
	fai->hash = kh_init(s);
	buf = (char*)calloc(0x10000, 1);
	while (!feof(fp) && fgets(buf, 0x10000, fp)) {
		for (p = buf; *p && isgraph(*p); ++p);
		*p = 0; ++p;
#ifdef _WIN32
		sscanf(p, "%d%ld%d%d", &len, &offset, &line_blen, &line_len);
#else
		sscanf(p, "%d%lld%d%d", &len, &offset, &line_blen, &line_len);
#endif
		fai_insert_index(fai, buf, len, line_len, line_blen, offset);
	}
	free(buf);
	return fai;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rdi, %rbx
movl $0x1, %edi
movl $0x20, %esi
callq 0x32e0
movq %rax, %r14
movl $0x1, %edi
movl $0x28, %esi
callq 0x32e0
movq %rax, 0x18(%r14)
movl $0x10000, %edi          # imm = 0x10000
movl $0x1, %esi
callq 0x32e0
movq %rax, %r15
movq %rbx, %rdi
callq 0x3330
testl %eax, %eax
jne 0x14641
leaq 0x4(%rsp), %r12
leaq 0x8(%rsp), %r13
movq %r15, %rdi
movl $0x10000, %esi          # imm = 0x10000
movq %rbx, %rdx
callq 0x32d0
testq %rax, %rax
je 0x14641
movb (%r15), %bpl
movq %r15, %rdi
testb %bpl, %bpl
je 0x145f0
callq 0x35f0
movq (%rax), %rax
movq %r15, %rdi
movsbq %bpl, %rcx
cmpw $0x0, (%rax,%rcx,2)
jns 0x145f0
movb 0x1(%rdi), %bpl
incq %rdi
testb %bpl, %bpl
jne 0x145d9
movb $0x0, (%rdi)
incq %rdi
leaq 0x8423(%rip), %rsi      # 0x1ca20
leaq 0xc(%rsp), %rdx
leaq 0x10(%rsp), %rcx
movq %r12, %r8
movq %r13, %r9
xorl %eax, %eax
callq 0x3410
movl 0xc(%rsp), %edx
movl 0x8(%rsp), %ecx
movl 0x4(%rsp), %r8d
movq 0x10(%rsp), %r9
movq %r14, %rdi
movq %r15, %rsi
callq 0x13e02
movq %rbx, %rdi
callq 0x3330
testl %eax, %eax
je 0x145ae
movq %r15, %rdi
callq 0x3060
movq %r14, %rax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/xiongxu[P]bam2bedGraph2/samtools-0.1.19/faidx.c
// Function: fai_build
int fai_build(const char *fn)
{
	char *str;
	RAZF *rz;
	FILE *fp;
	faidx_t *fai;
	str = (char*)calloc(strlen(fn) + 5, 1);
	sprintf(str, "%s.fai", fn);
	rz = razf_open(fn, "r");
	if (rz == 0) {
		fprintf(stderr, "[fai_build] fail to open the FASTA file %s\n",fn);
		free(str);
		return -1;
	}
	fai = fai_build_core(rz);
	razf_close(rz);
	fp = fopen(str, "wb");
	if (fp == 0) {
		fprintf(stderr, "[fai_build] fail to write FASTA index %s\n",str);
		fai_destroy(fai); free(str);
		return -1;
	}
	fai_save(fai, fp);
	fclose(fp);
	free(str);
	fai_destroy(fai);
	return 0;
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movq %rdi, %r14
callq 0x31e0
leaq 0x5(%rax), %rdi
movl $0x1, %esi
callq 0x32e0
movq %rax, %rbx
leaq 0x83ab(%rip), %rsi      # 0x1ca2b
movq %rax, %rdi
movq %r14, %rdx
xorl %eax, %eax
callq 0x3510
leaq 0x8292(%rip), %rsi      # 0x1c926
movq %r14, %rdi
callq 0x12d1b
testq %rax, %rax
je 0x146f9
movq %rax, %r15
movq %rax, %rdi
callq 0x13aec
movq %rax, %r14
movq %r15, %rdi
callq 0x1373c
leaq 0x7dc6(%rip), %rsi      # 0x1c484
movq %rbx, %rdi
callq 0x3340
testq %rax, %rax
je 0x1471e
movq %rax, %r15
movq %r14, %rdi
movq %rax, %rsi
callq 0x143ca
movq %r15, %rdi
callq 0x31c0
movq %rbx, %rdi
callq 0x3060
movq %r14, %rdi
callq 0x14350
xorl %eax, %eax
popq %rbx
popq %r14
popq %r15
retq
movq 0xe8f8(%rip), %rax      # 0x22ff8
movq (%rax), %rdi
leaq 0x8328(%rip), %rsi      # 0x1ca32
movq %r14, %rdx
xorl %eax, %eax
callq 0x3320
movq %rbx, %rdi
callq 0x3060
jmp 0x14729
movq %rbx, %rdi
movq %r14, %rsi
callq 0x438f
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
jmp 0x146f3
// File: /workspace/github_c_makefile_star2_O3/xiongxu[P]bam2bedGraph2/samtools-0.1.19/faidx.c
// Function: download_and_open
FILE *download_and_open(const char *fn)
{
    const int buf_size = 1 * 1024 * 1024;
    uint8_t *buf;
    FILE *fp;
    knetFile *fp_remote;
    const char *url = fn;
    const char *p;
    int l = strlen(fn);
    for (p = fn + l - 1; p >= fn; --p)
        if (*p == '/') break;
    fn = p + 1;

    // First try to open a local copy
    fp = fopen(fn, "r");
    if (fp)
        return fp;

    // If failed, download from remote and open
    fp_remote = knet_open(url, "rb");
    if (fp_remote == 0) {
        fprintf(stderr, "[download_from_remote] fail to open remote file %s\n",url);
        return NULL;
    }
    if ((fp = fopen(fn, "wb")) == 0) {
        fprintf(stderr, "[download_from_remote] fail to create file in the working directory %s\n",fn);
        knet_close(fp_remote);
        return NULL;
    }
    buf = (uint8_t*)calloc(buf_size, 1);
    while ((l = knet_read(fp_remote, buf, buf_size)) != 0)
        fwrite(buf, 1, l, fp);
    free(buf);
    fclose(fp);
    knet_close(fp_remote);

    return fopen(fn, "r");
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %r15
callq 0x31e0
cltq
addq %r15, %rax
decq %rax
movq %rax, %rbx
cmpq %r15, %rax
jb 0x14759
leaq -0x1(%rbx), %rax
cmpb $0x2f, (%rbx)
jne 0x14748
incq %rbx
leaq 0x81c3(%rip), %rsi      # 0x1c926
movq %rbx, %rdi
callq 0x3340
movq %rax, %r12
testq %rax, %rax
je 0x14782
movq %r12, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
leaq 0x667a(%rip), %rsi      # 0x1ae03
movq %r15, %rdi
callq 0x15cab
testq %rax, %rax
je 0x14830
movq %rax, %r14
leaq 0x7ce0(%rip), %rsi      # 0x1c484
movq %rbx, %rdi
callq 0x3340
testq %rax, %rax
je 0x14853
movq %rax, %r15
movl $0x100000, %edi         # imm = 0x100000
movl $0x1, %esi
callq 0x32e0
movq %rax, %r12
movl $0x100000, %edx         # imm = 0x100000
movq %r14, %rdi
movq %rax, %rsi
callq 0x15e14
testl %eax, %eax
je 0x147fe
movslq %eax, %rdx
movl $0x1, %esi
movq %r12, %rdi
movq %r15, %rcx
callq 0x3540
movl $0x100000, %edx         # imm = 0x100000
movq %r14, %rdi
movq %r12, %rsi
jmp 0x147d5
movq %r12, %rdi
callq 0x3060
movq %r15, %rdi
callq 0x31c0
movq %r14, %rdi
callq 0x15d92
leaq 0x8109(%rip), %rsi      # 0x1c926
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
jmp 0x3340
movq 0xe7c1(%rip), %rax      # 0x22ff8
movq (%rax), %rdi
leaq 0x8247(%rip), %rsi      # 0x1ca88
xorl %r12d, %r12d
movq %r15, %rdx
xorl %eax, %eax
callq 0x3320
jmp 0x14773
movq 0xe79e(%rip), %rax      # 0x22ff8
movq (%rax), %rdi
leaq 0x8258(%rip), %rsi      # 0x1cabc
xorl %r12d, %r12d
movq %rbx, %rdx
xorl %eax, %eax
callq 0x3320
movq %r14, %rdi
callq 0x15d92
jmp 0x14773
// File: /workspace/github_c_makefile_star2_O3/xiongxu[P]bam2bedGraph2/samtools-0.1.19/faidx.c
// Function: fai_load
faidx_t *fai_load(const char *fn)
{
	char *str;
	FILE *fp;
	faidx_t *fai;
	str = (char*)calloc(strlen(fn) + 5, 1);
	sprintf(str, "%s.fai", fn);

#ifdef _USE_KNETFILE
    if (strstr(fn, "ftp://") == fn || strstr(fn, "http://") == fn)
    {
        fp = download_and_open(str);
        if ( !fp )
        {
            fprintf(stderr, "[fai_load] failed to open remote FASTA index %s\n", str);
            free(str);
            return 0;
        }
    }
    else
#endif
        fp = fopen(str, "rb");
	if (fp == 0) {
		fprintf(stderr, "[fai_load] build FASTA index.\n");
		fai_build(fn);
		fp = fopen(str, "rb");
		if (fp == 0) {
			fprintf(stderr, "[fai_load] fail to open FASTA index.\n");
			free(str);
			return 0;
		}
	}

	fai = fai_read(fp);
	fclose(fp);

	fai->rz = razf_open(fn, "rb");
	free(str);
	if (fai->rz == 0) {
		fprintf(stderr, "[fai_load] fail to open FASTA file.\n");
		return 0;
	}
	return fai;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %rbx
callq 0x31e0
leaq 0x5(%rax), %rdi
movl $0x1, %esi
callq 0x32e0
movq %rax, %r14
leaq 0x8185(%rip), %rsi      # 0x1ca2b
movq %rax, %rdi
movq %rbx, %rdx
xorl %eax, %eax
callq 0x3510
leaq 0x7aed(%rip), %rsi      # 0x1c3a7
movl $0x6, %edx
movq %rbx, %rdi
callq 0x30c0
testl %eax, %eax
je 0x1490f
leaq 0x7adc(%rip), %rsi      # 0x1c3ae
movl $0x7, %edx
movq %rbx, %rdi
callq 0x30c0
testl %eax, %eax
je 0x1490f
leaq 0x6519(%rip), %rsi      # 0x1ae03
movq %r14, %rdi
callq 0x3340
testq %rax, %rax
jne 0x1491c
movq %rsp, %rdx
movq %rbx, %rdi
movq %r14, %rsi
callq 0x43cb
testb $0x1, %al
je 0x14972
movq (%rsp), %r12
jmp 0x1491f
movq %r14, %rdi
callq 0x14730
testq %rax, %rax
je 0x1496a
movq %rax, %r12
movq %r12, %rdi
callq 0x1454c
movq %rax, %r15
movq %r12, %rdi
callq 0x31c0
leaq 0x64ca(%rip), %rsi      # 0x1ae03
movq %rbx, %rdi
callq 0x12d1b
movq %rax, %rbx
movq %rax, (%r15)
movq %r14, %rdi
callq 0x3060
testq %rbx, %rbx
je 0x14963
movq %r15, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
callq 0x4448
jmp 0x14972
movq %r14, %rdi
callq 0x4464
xorl %r15d, %r15d
jmp 0x14954
// File: /workspace/github_c_makefile_star2_O3/xiongxu[P]bam2bedGraph2/samtools-0.1.19/faidx.c
// Function: faidx_main
int faidx_main(int argc, char *argv[])
{
	if (argc == 1) {
		fprintf(stderr, "Usage: faidx <in.fasta> [<reg> [...]]\n");
		return 1;
	} else {
		if (argc == 2) fai_build(argv[1]);
		else {
			int i, j, k, l;
			char *s;
			faidx_t *fai;
			fai = fai_load(argv[1]);
			if (fai == 0) return 1;
			for (i = 2; i != argc; ++i) {
				printf(">%s\n", argv[i]);
				s = fai_fetch(fai, argv[i], &l);
				for (j = 0; j < l; j += 60) {
					for (k = 0; k < 60 && k < l - j; ++k)
						putchar(s[j + k]);
					putchar('\n');
				}
				free(s);
			}
			fai_destroy(fai);
		}
	}
	return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rsi, %rbx
cmpl $0x2, %edi
je 0x150a9
movl %edi, %ebp
cmpl $0x1, %edi
je 0x150b6
movq 0x8(%rbx), %rdi
callq 0x1487e
movq %rax, 0x8(%rsp)
testq %rax, %rax
je 0x150bb
movl %ebp, %eax
movq %rax, 0x18(%rsp)
movl $0x2, %r15d
movq %rbx, 0x20(%rsp)
movq (%rbx,%r15,8), %rsi
leaq 0x7c07(%rip), %rdi      # 0x1cc1c
xorl %eax, %eax
callq 0x3210
movq (%rbx,%r15,8), %rsi
movq 0x8(%rsp), %rdi
leaq 0x4(%rsp), %rdx
callq 0x14977
movq %rax, 0x10(%rsp)
movslq 0x4(%rsp), %rbx
testq %rbx, %rbx
jle 0x15080
movq 0x10(%rsp), %r13
xorl %r14d, %r14d
movq %rbx, %r12
subq %r14, %r12
jle 0x15069
xorl %ebp, %ebp
movsbl (%r13,%rbp), %edi
callq 0x3070
cmpq $0x3a, %rbp
ja 0x15069
incq %rbp
cmpq %r12, %rbp
jb 0x15050
movl $0xa, %edi
callq 0x3070
addq $0x3c, %r14
addq $0x3c, %r13
cmpq %rbx, %r14
jb 0x15046
movq 0x10(%rsp), %rdi
callq 0x3060
incq %r15
cmpq 0x18(%rsp), %r15
movq 0x20(%rsp), %rbx
jne 0x1500a
movq 0x8(%rsp), %rdi
callq 0x14350
jmp 0x150b2
movq 0x8(%rbx), %rdi
callq 0x1465b
xorl %eax, %eax
jmp 0x150c0
callq 0x448c
movl $0x1, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/xiongxu[P]bam2bedGraph2/samtools-0.1.19/knetfile.c
// Function: kftp_connect
int kftp_connect(knetFile *ftp)
{
	ftp->ctrl_fd = socket_connect(ftp->host, ftp->port);
	if (ftp->ctrl_fd == -1) return -1;
	kftp_get_response(ftp);
	kftp_send_cmd(ftp, "USER anonymous\r\n", 1);
	kftp_send_cmd(ftp, "PASS kftp@\r\n", 1);
	kftp_send_cmd(ftp, "TYPE I\r\n", 1);
	return 0;
}

// Assembly:
pushq %rbx
movq %rdi, %rbx
movq 0x10(%rdi), %rdi
movq 0x18(%rbx), %rsi
callq 0x15378
movl %eax, 0x20(%rbx)
cmpl $-0x1, %eax
je 0x15371
movq %rbx, %rdi
callq 0x1546e
leaq 0x7978(%rip), %rsi      # 0x1ccb0
movq %rbx, %rdi
movl $0x1, %edx
callq 0x1559d
leaq 0x7975(%rip), %rsi      # 0x1ccc1
movq %rbx, %rdi
movl $0x1, %edx
callq 0x1559d
leaq 0x796e(%rip), %rsi      # 0x1ccce
movq %rbx, %rdi
movl $0x1, %edx
callq 0x1559d
xorl %eax, %eax
jmp 0x15376
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
popq %rbx
retq
// File: /workspace/github_c_makefile_star2_O3/xiongxu[P]bam2bedGraph2/samtools-0.1.19/knetfile.c
// Function: socket_connect
static int socket_connect(const char *host, const char *port)
{
#define __err_connect(func) do { perror(func); freeaddrinfo(res); return -1; } while (0)

	int on = 1, fd;
	struct linger lng = { 0, 0 };
	struct addrinfo hints, *res = 0;
	memset(&hints, 0, sizeof(struct addrinfo));
	hints.ai_family = AF_UNSPEC;
	hints.ai_socktype = SOCK_STREAM;
	/* In Unix/Mac, getaddrinfo() is the most convenient way to get
	 * server information. */
	if (getaddrinfo(host, port, &hints, &res) != 0) __err_connect("getaddrinfo");
	if ((fd = socket(res->ai_family, res->ai_socktype, res->ai_protocol)) == -1) __err_connect("socket");
	/* The following two setsockopt() are used by ftplib
	 * (http://nbpfaus.net/~pfau/ftplib/). I am not sure if they
	 * necessary. */
	if (setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &on, sizeof(on)) == -1) __err_connect("setsockopt");
	if (setsockopt(fd, SOL_SOCKET, SO_LINGER, &lng, sizeof(lng)) == -1) __err_connect("setsockopt");
	if (connect(fd, res->ai_addr, res->ai_addrlen) != 0) __err_connect("connect");
	freeaddrinfo(res);
	return fd;
}

// Assembly:
pushq %r14
pushq %rbx
subq $0x58, %rsp
movl $0x1, %eax
movl %eax, 0x14(%rsp)
xorl %edx, %edx
movq %rdx, 0x18(%rsp)
leaq 0x8(%rsp), %rcx
movq %rdx, (%rcx)
xorps %xmm0, %xmm0
leaq 0x20(%rsp), %rdx
movaps %xmm0, (%rdx)
movaps %xmm0, 0x10(%rdx)
movaps %xmm0, 0x20(%rdx)
movl %eax, 0x8(%rdx)
callq 0x3570
testl %eax, %eax
jne 0x1543d
movq 0x8(%rsp), %rax
movl 0x4(%rax), %edi
movl 0x8(%rax), %esi
movl 0xc(%rax), %edx
callq 0x3620
cmpl $-0x1, %eax
je 0x15446
movl %eax, %ebx
leaq 0x14(%rsp), %rcx
movl %eax, %edi
movl $0x1, %esi
movl $0x2, %edx
movl $0x4, %r8d
callq 0x3160
leaq 0x7a38(%rip), %r14      # 0x1ce2f
cmpl $-0x1, %eax
je 0x1544d
leaq 0x18(%rsp), %rcx
movl %ebx, %edi
movl $0x1, %esi
movl $0xd, %edx
movl $0x8, %r8d
callq 0x3160
cmpl $-0x1, %eax
je 0x1544d
movq 0x8(%rsp), %rax
movq 0x18(%rax), %rsi
movl 0x10(%rax), %edx
movl %ebx, %edi
callq 0x3530
testl %eax, %eax
je 0x1545a
leaq 0x79ff(%rip), %r14      # 0x1ce3a
jmp 0x1544d
leaq 0x79d8(%rip), %r14      # 0x1ce1c
jmp 0x1544d
leaq 0x79db(%rip), %r14      # 0x1ce28
movq %r14, %rdi
callq 0x34d0
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
movq 0x8(%rsp), %rdi
callq 0x3610
movl %ebx, %eax
addq $0x58, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O3/xiongxu[P]bam2bedGraph2/samtools-0.1.19/knetfile.c
// Function: kftp_get_response
static int kftp_get_response(knetFile *ftp)
{
#ifndef _WIN32
	unsigned char c;
#else
	char c;
#endif
	int n = 0;
	char *p;
	if (socket_wait(ftp->ctrl_fd, 1) <= 0) return 0;
	while (netread(ftp->ctrl_fd, &c, 1)) { // FIXME: this is *VERY BAD* for unbuffered I/O
		//fputc(c, stderr);
		if (n >= ftp->max_response) {
			ftp->max_response = ftp->max_response? ftp->max_response<<1 : 256;
			ftp->response = realloc(ftp->response, ftp->max_response);
		}
		ftp->response[n++] = c;
		if (c == '\n') {
			if (n >= 4 && isdigit(ftp->response[0]) && isdigit(ftp->response[1]) && isdigit(ftp->response[2])
				&& ftp->response[3] != '-') break;
			n = 0;
			continue;
		}
	}
	if (n < 2) return -1;
	ftp->response[n-2] = 0;
	return strtol(ftp->response, &p, 0);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rdi, %rbx
movl 0x20(%rdi), %edi
movl $0x1, %esi
callq 0x15f53
testl %eax, %eax
jle 0x15588
movl 0x20(%rbx), %edi
leaq 0xf(%rsp), %rsi
movl $0x1, %edx
callq 0x32b0
movl $0xffffffff, %r14d      # imm = 0xFFFFFFFF
testq %rax, %rax
je 0x1558b
xorl %r12d, %r12d
leaq 0xf(%rsp), %r15
movl $0x100, %ebp            # imm = 0x100
movl 0x38(%rbx), %ecx
movq 0x48(%rbx), %rax
cmpl %ecx, %r12d
jl 0x154e8
leal (%rcx,%rcx), %edx
testl %ecx, %ecx
cmovel %ebp, %edx
movl %edx, 0x38(%rbx)
movslq %edx, %rsi
movq %rax, %rdi
callq 0x3430
movq %rax, 0x48(%rbx)
movb 0xf(%rsp), %cl
leal 0x1(%r12), %r13d
movslq %r12d, %rdx
movb %cl, (%rax,%rdx)
cmpb $0xa, %cl
jne 0x15507
cmpl $0x3, %r12d
jge 0x15521
xorl %r12d, %r12d
jmp 0x1550a
movl %r13d, %r12d
movl 0x20(%rbx), %edi
movl $0x1, %edx
movq %r15, %rsi
callq 0x32b0
testq %rax, %rax
jne 0x154c2
jmp 0x1555e
callq 0x35f0
movq (%rax), %rcx
movq 0x48(%rbx), %rax
movsbq (%rax), %rdx
testb $0x8, 0x1(%rcx,%rdx,2)
je 0x15502
movsbq 0x1(%rax), %rdx
testb $0x8, 0x1(%rcx,%rdx,2)
je 0x15502
movsbq 0x2(%rax), %rdx
testb $0x8, 0x1(%rcx,%rdx,2)
je 0x15502
cmpb $0x2d, 0x3(%rax)
movl $0x0, %r12d
je 0x1550a
jmp 0x1556b
cmpl $0x2, %r12d
jl 0x1558b
movq 0x48(%rbx), %rax
movl %r12d, %r13d
movl %r13d, %ecx
movb $0x0, -0x2(%rax,%rcx)
movq 0x48(%rbx), %rdi
leaq 0x10(%rsp), %rsi
xorl %edx, %edx
callq 0x3360
movq %rax, %r14
jmp 0x1558b
xorl %r14d, %r14d
movl %r14d, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/xiongxu[P]bam2bedGraph2/samtools-0.1.19/knetfile.c
// Function: kftp_reconnect
int kftp_reconnect(knetFile *ftp)
{
	if (ftp->ctrl_fd != -1) {
		netclose(ftp->ctrl_fd);
		ftp->ctrl_fd = -1;
	}
	netclose(ftp->fd);
	ftp->fd = -1;
	return kftp_connect(ftp);
}

// Assembly:
pushq %rbx
movq %rdi, %rbx
movl 0x20(%rdi), %edi
cmpl $-0x1, %edi
je 0x1560d
callq 0x3270
movl $0xffffffff, 0x20(%rbx) # imm = 0xFFFFFFFF
movl 0x4(%rbx), %edi
callq 0x3270
movl $0xffffffff, 0x4(%rbx)  # imm = 0xFFFFFFFF
movq %rbx, %rdi
popq %rbx
jmp 0x15310
// File: /workspace/github_c_makefile_star2_O3/xiongxu[P]bam2bedGraph2/samtools-0.1.19/knetfile.c
// Function: kftp_parse_url
knetFile *kftp_parse_url(const char *fn, const char *mode)
{
	knetFile *fp;
	char *p;
	int l;
	if (strstr(fn, "ftp://") != fn) return 0;
	for (p = (char*)fn + 6; *p && *p != '/'; ++p);
	if (*p != '/') return 0;
	l = p - fn - 6;
	fp = calloc(1, sizeof(knetFile));
	fp->type = KNF_TYPE_FTP;
	fp->fd = -1;
	/* the Linux/Mac version of socket_connect() also recognizes a port
	 * like "ftp", but the Windows version does not. */
	fp->port = strdup("21");
	fp->host = calloc(l + 1, 1);
	if (strchr(mode, 'c')) fp->no_reconnect = 1;
	strncpy(fp->host, fn + 6, l);
	fp->retr = calloc(strlen(p) + 8, 1);
	sprintf(fp->retr, "RETR %s\r\n", p);
    fp->size_cmd = calloc(strlen(p) + 8, 1);
    sprintf(fp->size_cmd, "SIZE %s\r\n", p);
	fp->seek_offset = 0;
	return fp;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rsi, %r12
movq %rdi, %r15
leaq 0x6d6a(%rip), %rsi      # 0x1c3a7
movl $0x6, %edx
callq 0x30c0
testl %eax, %eax
je 0x15660
xorl %r14d, %r14d
movq %r14, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movabsq $0x100000000, %rbp      # imm = 0x100000000
addq $0x6, %r15
xorl %r13d, %r13d
movq %r15, %rbx
movzbl (%rbx), %eax
testl %eax, %eax
je 0x1564b
cmpl $0x2f, %eax
je 0x15688
incq %rbx
addq %rbp, %r13
jmp 0x15674
movl $0x1, %edi
movl $0x80, %esi
callq 0x32e0
movq %rax, %r14
movabsq $-0xfffffffe, %rax      # imm = 0xFFFFFFFF00000002
movq %rax, (%r14)
leaq 0x7629(%rip), %rdi      # 0x1ccd7
callq 0x3590
movq %rax, 0x18(%r14)
addq %r13, %rbp
sarq $0x20, %rbp
movl $0x1, %esi
movq %rbp, %rdi
callq 0x32e0
movq %rax, %rbp
movq %rax, 0x10(%r14)
movq %r12, %rdi
movl $0x63, %esi
callq 0x3200
testq %rax, %rax
je 0x156ec
movl $0x1, 0x3c(%r14)
sarq $0x20, %r13
movq %rbp, %rdi
movq %r15, %rsi
movq %r13, %rdx
callq 0x30b0
movq %rbx, %rdi
callq 0x31e0
leaq 0x8(%rax), %rdi
movl $0x1, %esi
callq 0x32e0
movq %rax, 0x50(%r14)
leaq 0x75bb(%rip), %rsi      # 0x1ccda
movq %rax, %rdi
movq %rbx, %rdx
xorl %eax, %eax
callq 0x3510
movq %rbx, %rdi
callq 0x31e0
leaq 0x8(%rax), %rdi
movl $0x1, %esi
callq 0x32e0
movq %rax, 0x58(%r14)
leaq 0x7597(%rip), %rsi      # 0x1cce4
movq %rax, %rdi
movq %rbx, %rdx
xorl %eax, %eax
callq 0x3510
jmp 0x1564e
// File: /workspace/github_c_makefile_star2_O3/xiongxu[P]bam2bedGraph2/samtools-0.1.19/knetfile.c
// Function: khttp_parse_url
knetFile *khttp_parse_url(const char *fn, const char *mode)
{
	knetFile *fp;
	char *p, *proxy, *q;
	int l;
	if (strstr(fn, "http://") != fn) return 0;
	// set ->http_host
	for (p = (char*)fn + 7; *p && *p != '/'; ++p);
	l = p - fn - 7;
	fp = calloc(1, sizeof(knetFile));
	fp->http_host = calloc(l + 1, 1);
	strncpy(fp->http_host, fn + 7, l);
	fp->http_host[l] = 0;
	for (q = fp->http_host; *q && *q != ':'; ++q);
	if (*q == ':') *q++ = 0;
	// get http_proxy
	proxy = getenv("http_proxy");
	// set ->host, ->port and ->path
	if (proxy == 0) {
		fp->host = strdup(fp->http_host); // when there is no proxy, server name is identical to http_host name.
		fp->port = strdup(*q? q : "80");
		fp->path = strdup(*p? p : "/");
	} else {
		fp->host = (strstr(proxy, "http://") == proxy)? strdup(proxy + 7) : strdup(proxy);
		for (q = fp->host; *q && *q != ':'; ++q);
		if (*q == ':') *q++ = 0; 
		fp->port = strdup(*q? q : "80");
		fp->path = strdup(fn);
	}
	fp->type = KNF_TYPE_HTTP;
	fp->ctrl_fd = fp->fd = -1;
	fp->seek_offset = 0;
	return fp;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %rbx
leaq 0x6a7b(%rip), %rsi      # 0x1c3ae
movl $0x7, %edx
callq 0x30c0
testl %eax, %eax
je 0x15948
xorl %ebx, %ebx
jmp 0x15aa3
movabsq $0x100000000, %rbp      # imm = 0x100000000
leaq 0x7(%rbx), %r13
xorl %r12d, %r12d
movq %r13, %r15
movzbl (%r15), %r14d
testl %r14d, %r14d
je 0x15973
cmpl $0x2f, %r14d
je 0x15973
incq %r15
addq %rbp, %r12
jmp 0x1595c
movq %rbx, (%rsp)
movl $0x1, %edi
movl $0x80, %esi
callq 0x32e0
movq %rax, %rbx
addq %r12, %rbp
sarq $0x20, %rbp
movl $0x1, %esi
movq %rbp, %rdi
callq 0x32e0
movq %rax, %rbp
movq %rax, 0x78(%rbx)
sarq $0x20, %r12
movq %rax, %rdi
movq %r13, %rsi
movq %r12, %rdx
callq 0x30b0
movb $0x0, (%rbp,%r12)
movq %rbp, %r13
movzbl (%r13), %eax
testl %eax, %eax
je 0x159da
cmpl $0x3a, %eax
je 0x159d2
incq %r13
jmp 0x159bf
movb $0x0, (%r13)
incq %r13
leaq 0x733a(%rip), %rdi      # 0x1cd1b
callq 0x3040
testq %rax, %rax
je 0x15a3a
movq %rax, %r12
leaq 0x69b9(%rip), %rsi      # 0x1c3ae
movl $0x7, %edx
movq %rax, %rdi
callq 0x30c0
leaq 0x7(%r12), %rdi
testl %eax, %eax
cmovneq %r12, %rdi
callq 0x3590
movq %rax, 0x10(%rbx)
incq %rax
movzbl -0x1(%rax), %ecx
testl %ecx, %ecx
je 0x15a72
cmpl $0x3a, %ecx
jne 0x15a16
movb $0x0, -0x1(%rax)
cmpb $0x0, (%rax)
leaq 0x72f2(%rip), %rdi      # 0x1cd26
cmovneq %rax, %rdi
jmp 0x15a79
movq %rbp, %rdi
callq 0x3590
cmpb $0x0, (%r13)
movq %rax, 0x10(%rbx)
leaq 0x72d4(%rip), %rdi      # 0x1cd26
cmovneq %r13, %rdi
callq 0x3590
movq %rax, 0x18(%rbx)
testb %r14b, %r14b
leaq 0x6943(%rip), %rax      # 0x1c3ac
cmoveq %rax, %r15
movq %r15, %rdi
jmp 0x15a86
leaq 0x72ad(%rip), %rdi      # 0x1cd26
callq 0x3590
movq %rax, 0x18(%rbx)
movq (%rsp), %rdi
callq 0x3590
movq %rax, 0x70(%rbx)
movabsq $-0xfffffffd, %rax      # imm = 0xFFFFFFFF00000003
movq %rax, (%rbx)
movl $0xffffffff, 0x20(%rbx) # imm = 0xFFFFFFFF
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/xiongxu[P]bam2bedGraph2/samtools-0.1.19/knetfile.c
// Function: my_netread
static off_t my_netread(int fd, void *buf, off_t len)
{
	off_t rest = len, curr, l = 0;
	/* recv() and read() may not read the required length of data with
	 * one call. They have to be called repeatedly. */
	while (rest) {
		if (socket_wait(fd, 1) <= 0) break; // socket is not ready for reading
		curr = netread(fd, buf + l, rest);
		/* According to the glibc manual, section 13.2, a zero returned
		 * value indicates end-of-file (EOF), which should mean that
		 * read() will not return zero if EOF has not been met but data
		 * are not immediately available. */
		if (curr == 0) break;
		l += curr; rest -= curr;
	}
	return l;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
testq %rdx, %rdx
je 0x15c9b
movq %rdx, %r14
movq %rsi, %r15
movl %edi, %ebp
xorl %ebx, %ebx
movl %ebp, %edi
movl $0x1, %esi
callq 0x15f53
testl %eax, %eax
jle 0x15c9d
leaq (%r15,%rbx), %rsi
movl %ebp, %edi
movq %r14, %rdx
callq 0x32b0
testq %rax, %rax
je 0x15c9d
addq %rax, %rbx
subq %rax, %r14
jne 0x15c6e
jmp 0x15c9d
xorl %ebx, %ebx
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/xiongxu[P]bam2bedGraph2/samtools-0.1.19/knetfile.c
// Function: knet_open
knetFile *knet_open(const char *fn, const char *mode)
{
	knetFile *fp = 0;
	if (mode[0] != 'r') {
		fprintf(stderr, "[kftp_open] only mode \"r\" is supported.\n");
		return 0;
	}
	if (strstr(fn, "ftp://") == fn) {
		fp = kftp_parse_url(fn, mode);
		if (fp == 0) return 0;
		if (kftp_connect(fp) == -1) {
			knet_close(fp);
			return 0;
		}
		kftp_connect_file(fp);
	} else if (strstr(fn, "http://") == fn) {
		fp = khttp_parse_url(fn, mode);
		if (fp == 0) return 0;
		khttp_connect_file(fp);
	} else { // local file
#ifdef _WIN32
		/* In windows, O_BINARY is necessary. In Linux/Mac, O_BINARY may
		 * be undefined on some systems, although it is defined on my
		 * Mac and the Linux I have tested on. */
		int fd = open(fn, O_RDONLY | O_BINARY);
#else		
		int fd = open(fn, O_RDONLY);
#endif
		if (fd == -1) {
			perror("open");
			return 0;
		}
		fp = (knetFile*)calloc(1, sizeof(knetFile));
		fp->type = KNF_TYPE_LOCAL;
		fp->fd = fd;
		fp->ctrl_fd = -1;
	}
	if (fp && fp->fd == -1) {
		knet_close(fp);
		return 0;
	}
	return fp;
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
cmpb $0x72, (%rsi)
jne 0x15d7d
movq %rsi, %r14
movq %rdi, %rbx
leaq 0x66e2(%rip), %rsi      # 0x1c3a7
movl $0x6, %edx
callq 0x30c0
testl %eax, %eax
je 0x15d26
leaq 0x66d4(%rip), %rsi      # 0x1c3ae
movl $0x7, %edx
movq %rbx, %rdi
callq 0x30c0
movq %rbx, %rdi
testl %eax, %eax
je 0x15d50
xorl %esi, %esi
xorl %eax, %eax
callq 0x3460
cmpl $-0x1, %eax
je 0x15d84
movl %eax, %ebp
movl $0x1, %edi
movl $0x80, %esi
callq 0x32e0
movq %rax, %rbx
movl $0x1, (%rax)
movl %ebp, 0x4(%rax)
movl $0xffffffff, 0x20(%rax) # imm = 0xFFFFFFFF
jmp 0x15d65
movq %rbx, %rdi
movq %r14, %rsi
callq 0x15625
testq %rax, %rax
je 0x15d73
movq %rax, %rbx
movq %rax, %rdi
callq 0x15310
cmpl $-0x1, %eax
je 0x15d6b
movq %rbx, %rdi
callq 0x1575f
jmp 0x15d65
callq 0x1591e
testq %rax, %rax
je 0x15d73
movq %rax, %rbx
movq %rax, %rdi
callq 0x15ab5
cmpl $-0x1, 0x4(%rbx)
jne 0x15d75
movq %rbx, %rdi
callq 0x15d92
xorl %ebx, %ebx
movq %rbx, %rax
popq %rbx
popq %r14
popq %rbp
retq
callq 0x4554
jmp 0x15d73
leaq 0x7036(%rip), %rdi      # 0x1cdc1
callq 0x34d0
jmp 0x15d73
// File: /workspace/github_c_makefile_star2_O3/xiongxu[P]bam2bedGraph2/samtools-0.1.19/knetfile.c
// Function: knet_close
int knet_close(knetFile *fp)
{
	if (fp == 0) return 0;
	if (fp->ctrl_fd != -1) netclose(fp->ctrl_fd); // FTP specific
	if (fp->fd != -1) {
		/* On Linux/Mac, netclose() is an alias of close(), but on
		 * Windows, it is an alias of closesocket(). */
		if (fp->type == KNF_TYPE_LOCAL) close(fp->fd);
		else netclose(fp->fd);
	}
	free(fp->host); free(fp->port);
	free(fp->response); free(fp->retr); // FTP specific
	free(fp->path); free(fp->http_host); // HTTP specific
	free(fp);
	return 0;
}

// Assembly:
testq %rdi, %rdi
je 0x15df4
pushq %rbx
movq %rdi, %rbx
movl 0x20(%rdi), %edi
cmpl $-0x1, %edi
je 0x15da8
callq 0x3270
movl 0x4(%rbx), %edi
cmpl $-0x1, %edi
je 0x15db5
callq 0x3270
movq 0x10(%rbx), %rdi
callq 0x3060
movq 0x18(%rbx), %rdi
callq 0x3060
movq 0x48(%rbx), %rdi
callq 0x3060
movq 0x50(%rbx), %rdi
callq 0x3060
movq 0x70(%rbx), %rdi
callq 0x3060
movq 0x78(%rbx), %rdi
callq 0x3060
movq %rbx, %rdi
callq 0x3060
popq %rbx
xorl %eax, %eax
retq
// File: /workspace/github_c_makefile_star2_O3/xiongxu[P]bam2bedGraph2/samtools-0.1.19/knetfile.c
// Function: knet_read
off_t knet_read(knetFile *fp, void *buf, off_t len)
{
	off_t l = 0;
	if (fp->fd == -1) return 0;
	if (fp->type == KNF_TYPE_FTP) {
		if (fp->is_ready == 0) {
			if (!fp->no_reconnect) kftp_reconnect(fp);
			kftp_connect_file(fp);
		}
	} else if (fp->type == KNF_TYPE_HTTP) {
		if (fp->is_ready == 0)
			khttp_connect_file(fp);
	}
	if (fp->type == KNF_TYPE_LOCAL) { // on Windows, the following block is necessary; not on UNIX
		off_t rest = len, curr;
		while (rest) {
			do {
				curr = read(fp->fd, buf + l, rest);
			} while (curr < 0 && EINTR == errno);
			if (curr < 0) return -1;
			if (curr == 0) break;
			l += curr; rest -= curr;
		}
	} else l = my_netread(fp->fd, buf, len);
	fp->offset += l;
	return l;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
movq %rdi, %rbx
movl 0x4(%rdi), %edi
cmpl $-0x1, %edi
je 0x15e58
movq %rdx, %r14
movq %rsi, %r15
movl (%rbx), %eax
cmpl $0x3, %eax
je 0x15e5d
cmpl $0x2, %eax
jne 0x15e6d
cmpl $0x0, 0x40(%rbx)
jne 0x15eac
cmpl $0x0, 0x3c(%rbx)
jne 0x15e4e
movq %rbx, %rdi
callq 0x155f5
movq %rbx, %rdi
callq 0x1575f
jmp 0x15e6b
xorl %r12d, %r12d
jmp 0x15ebe
cmpl $0x0, 0x40(%rbx)
jne 0x15eac
movq %rbx, %rdi
callq 0x15ab5
movl (%rbx), %eax
cmpl $0x1, %eax
jne 0x15ea9
xorl %r12d, %r12d
testq %r14, %r14
je 0x15eba
leaq (%r15,%r12), %r13
movl 0x4(%rbx), %edi
movq %r13, %rsi
movq %r14, %rdx
callq 0x32b0
testq %rax, %rax
jns 0x15e9d
callq 0x3090
cmpl $0x4, (%rax)
je 0x15e7e
jmp 0x15ecb
je 0x15eba
addq %rax, %r12
subq %rax, %r14
jne 0x15e7a
jmp 0x15eba
movl 0x4(%rbx), %edi
movq %r15, %rsi
movq %r14, %rdx
callq 0x15c58
movq %rax, %r12
addq %r12, 0x8(%rbx)
movq %r12, %rax
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
movq $-0x1, %r12
jmp 0x15ebe
// File: /workspace/github_c_makefile_star2_O3/xiongxu[P]bam2bedGraph2/samtools-0.1.19/knetfile.c
// Function: knet_seek
off_t knet_seek(knetFile *fp, int64_t off, int whence)
{
	if (whence == SEEK_SET && off == fp->offset) return 0;
	if (fp->type == KNF_TYPE_LOCAL) {
		/* Be aware that lseek() returns the offset after seeking,
		 * while fseek() returns zero on success. */
		off_t offset = lseek(fp->fd, off, whence);
		if (offset == -1) {
            // Be silent, it is OK for knet_seek to fail when the file is streamed
            // fprintf(stderr,"[knet_seek] %s\n", strerror(errno));
			return -1;
		}
		fp->offset = offset;
		return 0;
	}
    else if (fp->type == KNF_TYPE_FTP) 
    {
        if (whence==SEEK_CUR)
            fp->offset += off;
        else if (whence==SEEK_SET)
            fp->offset = off;
        else if ( whence==SEEK_END)
            fp->offset = fp->file_size+off;
		fp->is_ready = 0;
		return 0;
	} 
    else if (fp->type == KNF_TYPE_HTTP) 
    {
		if (whence == SEEK_END) { // FIXME: can we allow SEEK_END in future?
			fprintf(stderr, "[knet_seek] SEEK_END is not supported for HTTP. Offset is unchanged.\n");
			errno = ESPIPE;
			return -1;
		}
        if (whence==SEEK_CUR)
            fp->offset += off;
        else if (whence==SEEK_SET)
            fp->offset = off;
		fp->is_ready = 0;
		return 0;
	}
	errno = EINVAL;
    fprintf(stderr,"[knet_seek] %s\n", strerror(errno));
	return -1;
}

// Assembly:
pushq %rbx
movq %rdi, %rbx
testl %edx, %edx
jne 0x15ee2
cmpq %rsi, 0x8(%rbx)
je 0x15f3a
movl (%rbx), %eax
cmpl $0x3, %eax
je 0x15f07
cmpl $0x2, %eax
je 0x15f17
cmpl $0x1, %eax
jne 0x15f3e
movl 0x4(%rbx), %edi
callq 0x3550
cmpq $-0x1, %rax
je 0x15f4a
movq %rax, 0x8(%rbx)
jmp 0x15f3a
cmpl $0x1, %edx
je 0x15f1c
cmpl $0x2, %edx
je 0x15f45
testl %edx, %edx
jne 0x15f33
jmp 0x15f2f
cmpl $0x1, %edx
jne 0x15f22
addq %rsi, 0x8(%rbx)
jmp 0x15f33
testl %edx, %edx
je 0x15f2f
cmpl $0x2, %edx
jne 0x15f33
addq 0x68(%rbx), %rsi
movq %rsi, 0x8(%rbx)
movl $0x0, 0x40(%rbx)
xorl %eax, %eax
popq %rbx
retq
callq 0x459d
jmp 0x15f4a
callq 0x4570
movq $-0x1, %rax
jmp 0x15f3c
// File: /workspace/github_c_makefile_star2_O3/xiongxu[P]bam2bedGraph2/samtools-0.1.19/sam_header.c
// Function: sam_header_free
void sam_header_free(void *_header)
{
	HeaderDict *header = (HeaderDict*)_header;
    list_t *hlines = header;
    while (hlines)
    {
        sam_header_line_free(hlines->data);
        hlines = hlines->next;
    }
    list_free(header);
}

// Assembly:
testq %rdi, %rdi
je 0x16085
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
movq %rdi, %rbx
movq %rdi, %r12
movq 0x10(%r12), %r14
movq 0x8(%r14), %r13
testq %r13, %r13
je 0x16056
movq 0x10(%r13), %r15
movq 0x8(%r15), %rdi
callq 0x3060
movq %r15, %rdi
callq 0x3060
movq 0x8(%r13), %r13
testq %r13, %r13
jne 0x1601e
movq 0x8(%r14), %rdi
testq %rdi, %rdi
je 0x16056
movq 0x8(%rdi), %r15
callq 0x3060
movq %r15, %rdi
testq %r15, %r15
jne 0x16045
movq %r14, %rdi
callq 0x3060
movq 0x8(%r12), %r12
testq %r12, %r12
jne 0x16010
movq 0x8(%rbx), %r14
movq %rbx, %rdi
callq 0x3060
movq %r14, %rbx
testq %r14, %r14
jne 0x16068
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O3/xiongxu[P]bam2bedGraph2/samtools-0.1.19/sam_header.c
// Function: sam_header_clone
HeaderDict *sam_header_clone(const HeaderDict *dict)
{
    HeaderDict *out = NULL;
    while (dict)
    {
        HeaderLine *hline = dict->data;
        out = list_append(out, sam_header_line_clone(hline));
        dict = dict->next;
    }
    return out;
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
testq %rdi, %rdi
je 0x160b7
movq %rdi, %rbx
xorl %r14d, %r14d
movq 0x10(%rbx), %rdi
callq 0x16116
movq %r14, %rdi
movq %rax, %rsi
callq 0x160c5
movq %rax, %r14
movq 0x8(%rbx), %rbx
testq %rbx, %rbx
jne 0x16095
jmp 0x160ba
xorl %r14d, %r14d
movq %r14, %rax
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O3/xiongxu[P]bam2bedGraph2/samtools-0.1.19/sam_header.c
// Function: list_append
static list_t *list_append(list_t *root, void *data)
{
    list_t *l = root;
    while (l && l->next)
        l = l->next;
    if ( l ) 
    {
        l->next = malloc(sizeof(list_t));
        l = l->next;
    }
    else
    {
        l = malloc(sizeof(list_t));
        root = l;
    }
    l->data = data;
    l->next = NULL;
    return root;
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movq %rsi, %rbx
movq %rdi, %r14
movq %rdi, %rax
testq %rax, %rax
je 0x160f4
movq %rax, %r15
movq 0x8(%rax), %rax
testq %rax, %rax
jne 0x160d3
movl $0x18, %edi
callq 0x33e0
movq %rax, 0x8(%r15)
jmp 0x16101
movl $0x18, %edi
callq 0x33e0
movq %rax, %r14
movq %rbx, 0x10(%rax)
movq $0x0, 0x8(%rax)
movq %r14, %rax
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O3/xiongxu[P]bam2bedGraph2/samtools-0.1.19/sam_header.c
// Function: sam_header2list
char **sam_header2list(const void *_dict, char type[2], char key_tag[2], int *_n)
{
	const HeaderDict *dict = (const HeaderDict*)_dict;
    const list_t *l   = dict;
    int max, n;
	char **ret;

	ret = 0; *_n = max = n = 0;
    while (l)
    {
        HeaderLine *hline = l->data;
        if ( hline->type[0]!=type[0] || hline->type[1]!=type[1] ) 
        {
            l = l->next;
            continue;
        }
        
        HeaderTag *key;
        key   = header_line_has_tag(hline,key_tag);
        if ( !key )
        {
            l = l->next;
            continue;
        }

		if (n == max) {
			max = max? max<<1 : 4;
			ret = realloc(ret, max * sizeof(void*));
		}
		ret[n++] = key->value;

        l = l->next;
    }
	*_n = n;
    return ret;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl $0x0, (%rcx)
testq %rdi, %rdi
je 0x16df2
movq %rdx, %r14
movq %rsi, %r15
movq %rdi, %r12
xorl %r8d, %r8d
movl $0x4, %r9d
xorl %eax, %eax
xorl %r13d, %r13d
movq 0x10(%r12), %rdx
movb (%rdx), %sil
cmpb (%r15), %sil
jne 0x16de2
movb 0x1(%rdx), %sil
cmpb 0x1(%r15), %sil
jne 0x16de2
movq 0x8(%rdx), %rdx
testq %rdx, %rdx
je 0x16de2
movb (%r14), %sil
movq 0x10(%rdx), %rbp
cmpb %sil, (%rbp)
jne 0x16d99
movb 0x1(%rbp), %dil
cmpb 0x1(%r14), %dil
je 0x16da4
movq 0x8(%rdx), %rdx
testq %rdx, %rdx
jne 0x16d85
jmp 0x16de2
cmpl %r8d, %r13d
jne 0x16dd4
leal (%r8,%r8), %ebx
testl %r8d, %r8d
cmovel %r9d, %ebx
movslq %ebx, %rsi
shlq $0x3, %rsi
movq %rax, %rdi
movq %rcx, (%rsp)
callq 0x3430
movl $0x4, %r9d
movq (%rsp), %rcx
movl %ebx, %r8d
movq 0x8(%rbp), %rdx
movslq %r13d, %rsi
incl %r13d
movq %rdx, (%rax,%rsi,8)
movq 0x8(%r12), %r12
testq %r12, %r12
jne 0x16d62
jmp 0x16df7
xorl %r13d, %r13d
xorl %eax, %eax
movl %r13d, (%rcx)
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/xiongxu[P]bam2bedGraph2/samtools-0.1.19/sam_header.c
// Function: sam_header2key_val
void *sam_header2key_val(void *iter, const char type[2], const char key_tag[2], const char value_tag[2], const char **_key, const char **_value)
{
    list_t *l = iter;
    if ( !l ) return NULL;

    while (l)
    {
        HeaderLine *hline = l->data;
        if ( hline->type[0]!=type[0] || hline->type[1]!=type[1] )
        {
            l = l->next;
            continue;
        }

        HeaderTag *key, *value;
        key   = header_line_has_tag(hline,key_tag);
        value = header_line_has_tag(hline,value_tag);
        if ( !key && !value ) 
        {
            l = l->next;
            continue;
        }

        *_key = key->value;
        *_value = value->value;
        return l->next;
    }
    return l;
}

// Assembly:
testq %rdi, %rdi
je 0x16e9f
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
movb (%rsi), %r10b
xorl %eax, %eax
movq 0x10(%rdi), %r11
cmpb %r10b, (%r11)
jne 0x16e7b
movb 0x1(%r11), %bl
cmpb 0x1(%rsi), %bl
jne 0x16e7b
movq 0x8(%r11), %r11
testq %r11, %r11
je 0x16e7b
movb (%rdx), %bpl
movq %r11, %r14
movq 0x10(%r14), %rbx
cmpb %bpl, (%rbx)
jne 0x16e51
movb 0x1(%rbx), %r15b
cmpb 0x1(%rdx), %r15b
je 0x16e5c
movq 0x8(%r14), %r14
testq %r14, %r14
jne 0x16e3e
xorl %ebx, %ebx
movb (%rcx), %bpl
movq 0x10(%r11), %r14
cmpb %bpl, (%r14)
jne 0x16e72
movb 0x1(%r14), %r15b
cmpb 0x1(%rcx), %r15b
je 0x16e86
movq 0x8(%r11), %r11
testq %r11, %r11
jne 0x16e5f
movq 0x8(%rdi), %rdi
testq %rdi, %rdi
jne 0x16e1d
jmp 0x16e98
movq 0x8(%rbx), %rax
movq %rax, (%r8)
movq 0x8(%r14), %rax
movq %rax, (%r9)
movq 0x8(%rdi), %rax
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
xorl %eax, %eax
retq
// File: /workspace/github_c_makefile_star2_O3/xiongxu[P]bam2bedGraph2/samtools-0.1.19/sam_header.c
// Function: sam_tbl_get
const char *sam_tbl_get(void *h, const char *key)
{
	khash_t(str) *tbl = (khash_t(str)*)h;
	khint_t k;
	k = kh_get(str, tbl, key);
	return k == kh_end(tbl)? 0 : kh_val(tbl, k);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rdi, (%rsp)
movl (%rdi), %ebx
testl %ebx, %ebx
je 0x16ef7
movq %rsi, %r14
movsbl (%rsi), %r8d
xorl %edi, %edi
movl $0x0, %ecx
testl %r8d, %r8d
je 0x16f02
movb 0x1(%r14), %al
testb %al, %al
je 0x16eff
leaq 0x2(%r14), %rdx
movl %r8d, %ecx
movl %ecx, %r8d
shll $0x5, %r8d
subl %ecx, %r8d
movsbl %al, %ecx
addl %r8d, %ecx
movb (%rdx), %al
incq %rdx
testb %al, %al
jne 0x16edc
jmp 0x16f02
xorl %r15d, %r15d
jmp 0x16f95
movl %r8d, %ecx
movl %ecx, %eax
xorl %edx, %edx
divl %ebx
movl %edx, %r12d
leal -0x1(%rbx), %r8d
movl %ecx, %eax
xorl %edx, %edx
divl %r8d
incl %edx
movq (%rsp), %rax
movq 0x10(%rax), %r8
movl %r12d, %r15d
movl %edx, 0xc(%rsp)
movq %r8, 0x10(%rsp)
movl %r15d, %eax
shrl $0x4, %eax
movl (%r8,%rax,4), %ebp
leal (%r15,%r15), %r13d
andl $0x1e, %r13d
movl %ebp, %eax
movl %r13d, %ecx
shrl %cl, %eax
testb $0x2, %al
jne 0x16f88
testb $0x1, %al
jne 0x16f73
movq (%rsp), %rax
movq 0x18(%rax), %rax
movl %r15d, %ecx
movq (%rax,%rcx,8), %rdi
movq %r14, %rsi
callq 0x3300
movq 0x10(%rsp), %r8
movl 0xc(%rsp), %edx
xorl %edi, %edi
testl %eax, %eax
je 0x16f88
addl %edx, %r15d
cmpl %ebx, %r15d
movl %ebx, %eax
cmovbl %edi, %eax
subl %eax, %r15d
cmpl %r12d, %r15d
jne 0x16f2c
jmp 0x16fad
movl %r13d, %ecx
shrl %cl, %ebp
testb $0x3, %bpl
cmovnel %ebx, %r15d
cmpl %ebx, %r15d
jne 0x16f9e
xorl %edi, %edi
jmp 0x16fad
movq (%rsp), %rax
movq 0x20(%rax), %rax
movl %r15d, %ecx
movq (%rax,%rcx,8), %rdi
movq %rdi, %rax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/xiongxu[P]bam2bedGraph2/samtools-0.1.19/sam_header.c
// Function: print_header_line
static void print_header_line(FILE *fp, HeaderLine *hline)
{
    list_t *tags = hline->tags;
    HeaderTag *tag;

    fprintf(fp, "@%c%c", hline->type[0],hline->type[1]);
    while (tags)
    {
        tag = tags->data;

        fprintf(fp, "\t");
        if ( tag->key[0]!=' ' || tag->key[1]!=' ' )
            fprintf(fp, "%c%c:", tag->key[0],tag->key[1]);
        fprintf(fp, "%s", tag->value);

        tags = tags->next;
    }
    fprintf(fp,"\n");
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %rbx
movq 0x8(%rsi), %r15
movsbl (%rsi), %edx
movsbl 0x1(%rsi), %ecx
leaq 0x59ea(%rip), %rsi      # 0x1cee8
xorl %eax, %eax
callq 0x3320
testq %r15, %r15
je 0x17562
leaq 0x59dd(%rip), %r14      # 0x1ceee
movq 0x10(%r15), %r12
movl $0x9, %edi
movq %rbx, %rsi
callq 0x3280
movsbl (%r12), %edx
movl %edx, %ecx
xorb $0x20, %cl
movb 0x1(%r12), %al
movl %eax, %esi
xorb $0x20, %sil
orb %cl, %sil
je 0x1754c
movsbl %al, %ecx
movq %rbx, %rdi
movq %r14, %rsi
xorl %eax, %eax
callq 0x3320
movq 0x8(%r12), %rdi
movq %rbx, %rsi
callq 0x3240
movq 0x8(%r15), %r15
testq %r15, %r15
jne 0x17511
movl $0xa, %edi
movq %rbx, %rsi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
jmp 0x3280
// File: /workspace/github_c_makefile_star2_O3/xiongxu[P]bam2bedGraph2/samtools-0.1.19/sam_header.c
// Function: sam_header2tbl_n
char **sam_header2tbl_n(const void *dict, const char type[2], const char *tags[], int *n)
{
    int nout = 0;
    char **out = NULL;

    *n = 0;
    list_t *l = (list_t *)dict;
    if ( !l ) return NULL;

    int i, ntags = 0;
    while ( tags[ntags] ) ntags++;

    while (l)
    {
        HeaderLine *hline = l->data;
        if ( hline->type[0]!=type[0] || hline->type[1]!=type[1] )
        {
            l = l->next;
            continue;
        }
        out = (char**) realloc(out, sizeof(char*)*(nout+1)*ntags);
        for (i=0; i<ntags; i++)
        {
            HeaderTag *key = header_line_has_tag(hline, tags[i]);
            if ( !key ) 
            {
                out[nout*ntags+i] = NULL;
                continue;
            }
            out[nout*ntags+i] = key->value;
        }
        nout++;
        l = l->next;
    }
    *n = nout;
    return out;
}

// Assembly:
movl $0x0, (%rcx)
testq %rdi, %rdi
je 0x17683
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rdx, %r14
movq %rdi, %r12
movq %rcx, 0x10(%rsp)
movq $-0x1, %rbp
movl $0x8, %r13d
addq $-0x8, %r13
cmpq $0x0, 0x8(%r14,%rbp,8)
leaq 0x1(%rbp), %rbp
jne 0x175af
negq %r13
xorl %ebx, %ebx
xorl %eax, %eax
movq %rsi, 0x8(%rsp)
movq 0x10(%r12), %r15
movb (%r15), %cl
cmpb (%rsi), %cl
jne 0x1765f
movb 0x1(%r15), %cl
cmpb 0x1(%rsi), %cl
jne 0x1765f
leal 0x1(%rbx), %ecx
movl %ecx, 0x4(%rsp)
movslq %ecx, %rsi
imulq %r13, %rsi
movq %rax, %rdi
callq 0x3430
testq %rbp, %rbp
je 0x17654
movq 0x8(%r15), %rcx
imull %ebp, %ebx
movslq %ebx, %rdx
leaq (%rax,%rdx,8), %rdx
xorl %esi, %esi
movl 0x4(%rsp), %ebx
testq %rcx, %rcx
je 0x1763e
movq (%r14,%rsi,8), %rdi
movb (%rdi), %r8b
movq %rcx, %r9
movq 0x10(%r9), %r10
cmpb %r8b, (%r10)
jne 0x17635
movb 0x1(%r10), %r11b
cmpb 0x1(%rdi), %r11b
je 0x17642
movq 0x8(%r9), %r9
testq %r9, %r9
jne 0x17622
xorl %edi, %edi
jmp 0x17646
movq 0x8(%r10), %rdi
movq %rdi, (%rdx,%rsi,8)
incq %rsi
cmpq %rsi, %rbp
jne 0x17613
jmp 0x1765a
movl 0x4(%rsp), %ecx
movl %ecx, %ebx
movq 0x8(%rsp), %rsi
movq 0x8(%r12), %r12
testq %r12, %r12
jne 0x175cb
movq 0x10(%rsp), %rcx
movl %ebx, (%rcx)
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
xorl %eax, %eax
retq
// File: /workspace/github_c_makefile_star2_O3/xiongxu[P]bam2bedGraph2/samtools-0.1.19/sam_header.c
// Function: new_tag
static HeaderTag *new_tag(const char *name, const char *value_from, const char *value_to)
{
    HeaderTag *tag = malloc(sizeof(HeaderTag));
    int len = value_to-value_from+1;

    tag->key[0] = name[0];
    tag->key[1] = name[1];
    tag->value = malloc(len+1);
    memcpy(tag->value,value_from,len+1);
    tag->value[len] = 0;
    return tag;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rcx, %rbx
movq %rdx, %r15
movl %esi, %ebp
movl %edi, %r12d
movl $0x10, %edi
callq 0x33e0
movq %rax, %r14
subl %r15d, %ebx
movb %r12b, (%rax)
movb %bpl, 0x1(%rax)
shlq $0x20, %rbx
movabsq $0x200000000, %r12      # imm = 0x200000000
addq %rbx, %r12
sarq $0x20, %r12
movq %r12, %rdi
callq 0x33e0
movq %rax, %r13
movq %rax, 0x8(%r14)
movq %rax, %rdi
movq %r15, %rsi
movq %r12, %rdx
callq 0x3370
movabsq $0x100000000, %rax      # imm = 0x100000000
addq %rbx, %rax
sarq $0x20, %rax
movb $0x0, (%r13,%rax)
movq %r14, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop
// File: /workspace/github_c_makefile_star2_O3/xiongxu[P]bam2bedGraph2/samtools-0.1.19/bgzf.c
// Function: bgzf_open
BGZF *bgzf_open(const char *path, const char *mode)
{
	BGZF *fp = 0;
	assert(compressBound(BGZF_BLOCK_SIZE) < BGZF_MAX_BLOCK_SIZE);
	if (strchr(mode, 'r') || strchr(mode, 'R')) {
		_bgzf_file_t fpr;
		if ((fpr = _bgzf_open(path, "r")) == 0) return 0;
		fp = bgzf_read_init();
		fp->fp = fpr;
	} else if (strchr(mode, 'w') || strchr(mode, 'W')) {
		FILE *fpw;
		if ((fpw = fopen(path, "w")) == 0) return 0;
		fp = bgzf_write_init(mode2level(mode));
		fp->fp = fpw;
	}
	return fp;
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rsi, %rbx
movq %rdi, %r14
movl $0xff00, %edi           # imm = 0xFF00
callq 0x3400
cmpq $0x10000, %rax          # imm = 0x10000
jae 0x177cc
movq %rbx, %rdi
movl $0x72, %esi
callq 0x3200
testq %rax, %rax
jne 0x17754
movq %rbx, %rdi
movl $0x52, %esi
callq 0x3200
testq %rax, %rax
je 0x17776
leaq 0x51cb(%rip), %rsi      # 0x1c926
movq %r14, %rdi
callq 0x15cab
testq %rax, %rax
je 0x177c2
movq %rax, %r14
callq 0x18c9c
movq %r14, 0x30(%rax)
jmp 0x177c4
movq %rbx, %rdi
movl $0x77, %esi
callq 0x3200
testq %rax, %rax
jne 0x1779a
movq %rbx, %rdi
movl $0x57, %esi
callq 0x3200
testq %rax, %rax
je 0x177c2
leaq 0x4949(%rip), %rsi      # 0x1c0ea
movq %r14, %rdi
callq 0x3340
testq %rax, %rax
je 0x177c2
movq %rax, %r14
movq %rbx, %rdi
callq 0x1784d
movl %eax, %edi
callq 0x177eb
jmp 0x17770
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
retq
leaq 0x596d(%rip), %rdi      # 0x1d140
leaq 0x599b(%rip), %rsi      # 0x1d175
leaq 0x599b(%rip), %rcx      # 0x1d17c
movl $0x8e, %edx
callq 0x3230
// File: /workspace/github_c_makefile_star2_O3/xiongxu[P]bam2bedGraph2/samtools-0.1.19/bgzf.c
// Function: bgzf_write_init
static BGZF *bgzf_write_init(int compress_level) // compress_level==-1 for the default level
{
	BGZF *fp;
	fp = calloc(1, sizeof(BGZF));
	fp->is_write = 1;
	fp->uncompressed_block = malloc(BGZF_MAX_BLOCK_SIZE);
	fp->compressed_block = malloc(BGZF_MAX_BLOCK_SIZE);
	fp->compress_level = compress_level < 0? Z_DEFAULT_COMPRESSION : compress_level; // Z_DEFAULT_COMPRESSION==-1
	if (fp->compress_level > 9) fp->compress_level = Z_DEFAULT_COMPRESSION;
	return fp;
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movl %edi, %ebx
movl $0x1, %edi
movl $0x40, %esi
callq 0x32e0
movq %rax, %r14
movl $0x10000, %edi          # imm = 0x10000
callq 0x33e0
movq %rax, 0x18(%r14)
movl $0x10000, %edi          # imm = 0x10000
callq 0x33e0
movq %rax, 0x20(%r14)
testl %ebx, %ebx
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
cmovnsl %ebx, %eax
shll $0x12, %eax
leal 0x10000(%rax), %ecx
cmpl $0x240001, %eax         # imm = 0x240001
movl $0xfffd0000, %eax       # imm = 0xFFFD0000
cmovll %ecx, %eax
movl %eax, (%r14)
movq %r14, %rax
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O3/xiongxu[P]bam2bedGraph2/samtools-0.1.19/bgzf.c
// Function: mode2level
static int mode2level(const char *__restrict mode)
{
	int i, compress_level = -1;
	for (i = 0; mode[i]; ++i)
		if (mode[i] >= '0' && mode[i] <= '9') break;
	if (mode[i]) compress_level = (int)mode[i] - '0';
	if (strchr(mode, 'u')) compress_level = 0;
	return compress_level;
}

// Assembly:
pushq %rbp
pushq %rbx
pushq %rax
movq %rdi, %rcx
movzbl (%rcx), %eax
testl %eax, %eax
je 0x17865
leal -0x30(%rax), %edx
incq %rcx
cmpb $0x9, %dl
ja 0x17853
leal -0x30(%rax), %ecx
xorl %ebp, %ebp
cmpl $0x1, %eax
movl $0x0, %ebx
sbbl %ebx, %ebx
orl %ecx, %ebx
movl $0x75, %esi
callq 0x3200
testq %rax, %rax
cmovnel %ebp, %ebx
movl %ebx, %eax
addq $0x8, %rsp
popq %rbx
popq %rbp
retq