LLM4Binary/decompile-bench-makefile huggingface dataset:
// File: /workspace/github_cpp_makefile_star2_O1/statgen[P]statgen/lib/samtools-0.1.7a-hybrid/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 0xaca5(%rip), %rsi      # 0x26965
movl $0x6, %edx
callq 0x31c0
testl %eax, %eax
je 0x1bce3
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 0x1bcce
cmpl $0x2f, %eax
je 0x1bd0b
incq %rbx
addq %rbp, %r13
jmp 0x1bcf7
movl $0x1, %edi
movl $0x80, %esi
callq 0x3530
movq %rax, %r14
movabsq $-0xfffffffe, %rax      # imm = 0xFFFFFFFF00000002
movq %rax, (%r14)
leaq 0xb816(%rip), %rdi      # 0x27547
callq 0x34b0
movq %rax, 0x18(%r14)
addq %r13, %rbp
sarq $0x20, %rbp
movl $0x1, %esi
movq %rbp, %rdi
callq 0x3530
movq %rax, %rbp
movq %rax, 0x10(%r14)
movq %r12, %rdi
movl $0x63, %esi
callq 0x3440
testq %rax, %rax
je 0x1bd6f
movl $0x1, 0x3c(%r14)
sarq $0x20, %r13
movq %rbp, %rdi
movq %r15, %rsi
movq %r13, %rdx
callq 0x3580
movq %rbx, %rdi
callq 0x32d0
leaq 0x8(%rax), %rdi
movl $0x1, %esi
callq 0x3530
movq %rax, 0x50(%r14)
leaq 0xb7a8(%rip), %rsi      # 0x2754a
movq %rax, %rdi
movq %rbx, %rdx
xorl %eax, %eax
callq 0x3350
movq %rbx, %rdi
callq 0x32d0
leaq 0x8(%rax), %rdi
movl $0x1, %esi
callq 0x3530
movq %rax, 0x58(%r14)
leaq 0xb784(%rip), %rsi      # 0x27554
movq %rax, %rdi
movq %rbx, %rdx
xorl %eax, %eax
callq 0x3350
movq $0x0, 0x60(%r14)
jmp 0x1bcd1
// File: /workspace/github_cpp_makefile_star2_O1/statgen[P]statgen/lib/samtools-0.1.7a-hybrid/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 0xa9ae(%rip), %rsi      # 0x2696c
movl $0x7, %edx
callq 0x31c0
testl %eax, %eax
je 0x1bfd3
xorl %ebx, %ebx
jmp 0x1c130
movabsq $0x100000000, %rbp      # imm = 0x100000000
leaq 0x7(%rbx), %r13
xorl %r12d, %r12d
movq %r13, %r15
movzbl (%r15), %r14d
testl %r14d, %r14d
je 0x1bffe
cmpl $0x2f, %r14d
je 0x1bffe
incq %r15
addq %rbp, %r12
jmp 0x1bfe7
movq %rbx, (%rsp)
movl $0x1, %edi
movl $0x80, %esi
callq 0x3530
movq %rax, %rbx
addq %r12, %rbp
sarq $0x20, %rbp
movl $0x1, %esi
movq %rbp, %rdi
callq 0x3530
movq %rax, %rbp
movq %rax, 0x78(%rbx)
sarq $0x20, %r12
movq %rax, %rdi
movq %r13, %rsi
movq %r12, %rdx
callq 0x3580
movb $0x0, (%rbp,%r12)
movq %rbp, %r13
movzbl (%r13), %eax
testl %eax, %eax
je 0x1c065
cmpl $0x3a, %eax
je 0x1c05d
incq %r13
jmp 0x1c04a
movb $0x0, (%r13)
incq %r13
leaq 0xb51f(%rip), %rdi      # 0x2758b
callq 0x3480
testq %rax, %rax
je 0x1c0b2
movq %rax, %r12
leaq 0xa8ec(%rip), %rsi      # 0x2696c
movl $0x7, %edx
movq %rax, %rdi
callq 0x31c0
leaq 0x7(%r12), %rdi
testl %eax, %eax
cmovneq %r12, %rdi
callq 0x34b0
movq %rax, 0x10(%rbx)
movzbl (%rax), %ecx
testl %ecx, %ecx
je 0x1c0f0
cmpl $0x3a, %ecx
je 0x1c0ea
incq %rax
jmp 0x1c0a1
movq %rbp, %rdi
callq 0x34b0
cmpb $0x0, (%r13)
movq %rax, 0x10(%rbx)
leaq 0xb4cc(%rip), %rdi      # 0x27596
cmovneq %r13, %rdi
callq 0x34b0
movq %rax, 0x18(%rbx)
testb %r14b, %r14b
leaq 0xa889(%rip), %rax      # 0x2696a
cmoveq %rax, %r15
movq %r15, %rdi
jmp 0x1c10b
movb $0x0, (%rax)
incq %rax
cmpb $0x0, (%rax)
leaq 0xb49c(%rip), %rdi      # 0x27596
cmovneq %rax, %rdi
callq 0x34b0
movq %rax, 0x18(%rbx)
movq (%rsp), %rdi
callq 0x34b0
movq %rax, 0x70(%rbx)
movabsq $-0xfffffffd, %rax      # imm = 0xFFFFFFFF00000003
movq %rax, (%rbx)
movl $0xffffffff, 0x20(%rbx) # imm = 0xFFFFFFFF
movq $0x0, 0x60(%rbx)
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O1/statgen[P]statgen/lib/samtools-0.1.7a-hybrid/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 0x1c338
movq %rdx, %r14
movq %rsi, %r15
movl %edi, %ebp
xorl %ebx, %ebx
movl %ebp, %edi
movl $0x1, %esi
callq 0x1c5f8
testl %eax, %eax
jle 0x1c33a
leaq (%r15,%rbx), %rsi
movl %ebp, %edi
movq %r14, %rdx
callq 0x31b0
testq %rax, %rax
je 0x1c33a
addq %rax, %rbx
subq %rax, %r14
jne 0x1c30b
jmp 0x1c33a
xorl %ebx, %ebx
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O1/statgen[P]statgen/lib/samtools-0.1.7a-hybrid/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 0x1c41c
movq %rsi, %r14
movq %rdi, %rbx
leaq 0xa603(%rip), %rsi      # 0x26965
movl $0x6, %edx
callq 0x31c0
testl %eax, %eax
je 0x1c3c8
leaq 0xa5f5(%rip), %rsi      # 0x2696c
movl $0x7, %edx
movq %rbx, %rdi
callq 0x31c0
movq %rbx, %rdi
testl %eax, %eax
je 0x1c3f2
xorl %esi, %esi
xorl %eax, %eax
callq 0x33b0
movl %eax, %ebp
cmpl $-0x1, %eax
je 0x1c42b
movl $0x1, %edi
movl $0x80, %esi
callq 0x3530
movq %rax, %rbx
movl $0x1, (%rax)
movl %ebp, 0x4(%rax)
movl $0xffffffff, 0x20(%rax) # imm = 0xFFFFFFFF
cmpl $-0x1, %ebp
jne 0x1c407
jmp 0x1c421
movq %rbx, %rdi
movq %r14, %rsi
callq 0x1bca8
testq %rax, %rax
je 0x1c421
movq %rax, %rbx
movq %rax, %rdi
callq 0x1b9a0
cmpl $-0x1, %eax
je 0x1c412
movq %rbx, %rdi
callq 0x1bdea
jmp 0x1c407
callq 0x1bfa9
testq %rax, %rax
je 0x1c421
movq %rax, %rbx
movq %rax, %rdi
callq 0x1c142
testq %rbx, %rbx
je 0x1c423
cmpl $-0x1, 0x4(%rbx)
jne 0x1c423
movq %rbx, %rdi
callq 0x1c43b
jmp 0x1c421
callq 0x4b5c
xorl %ebx, %ebx
movq %rbx, %rax
popq %rbx
popq %r14
popq %rbp
retq
leaq 0xb1ff(%rip), %rdi      # 0x27631
callq 0x3620
xorl %ebx, %ebx
jmp 0x1c3c1
// File: /workspace/github_cpp_makefile_star2_O1/statgen[P]statgen/lib/samtools-0.1.7a-hybrid/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 0x1c49d
pushq %rbx
movq %rdi, %rbx
movl 0x20(%rdi), %edi
cmpl $-0x1, %edi
je 0x1c451
callq 0x3090
movl 0x4(%rbx), %edi
cmpl $-0x1, %edi
je 0x1c45e
callq 0x3090
movq 0x10(%rbx), %rdi
callq 0x32c0
movq 0x18(%rbx), %rdi
callq 0x32c0
movq 0x48(%rbx), %rdi
callq 0x32c0
movq 0x50(%rbx), %rdi
callq 0x32c0
movq 0x70(%rbx), %rdi
callq 0x32c0
movq 0x78(%rbx), %rdi
callq 0x32c0
movq %rbx, %rdi
callq 0x32c0
popq %rbx
xorl %eax, %eax
retq
// File: /workspace/github_cpp_makefile_star2_O1/statgen[P]statgen/lib/samtools-0.1.7a-hybrid/knetfile.c
// Function: knet_dopen
knetFile *knet_dopen(int fd, const char *mode)
{
	knetFile *fp = (knetFile*)calloc(1, sizeof(knetFile));
	fp->type = KNF_TYPE_LOCAL;
	fp->fd = fd;
	return fp;
}

// Assembly:
pushq %rbx
movl %edi, %ebx
movl $0x1, %edi
movl $0x80, %esi
callq 0x3530
movl $0x1, (%rax)
movl %ebx, 0x4(%rax)
popq %rbx
retq
// File: /workspace/github_cpp_makefile_star2_O1/statgen[P]statgen/lib/samtools-0.1.7a-hybrid/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
cmpl $-0x1, 0x4(%rdi)
je 0x1c4ff
movq %rdx, %r14
movq %rsi, %r15
movq %rdi, %rbx
movl (%rdi), %eax
cmpl $0x3, %eax
je 0x1c504
cmpl $0x2, %eax
jne 0x1c512
cmpl $0x0, 0x40(%rbx)
jne 0x1c512
cmpl $0x0, 0x3c(%rbx)
jne 0x1c4f5
movq %rbx, %rdi
callq 0x1bc78
movq %rbx, %rdi
callq 0x1bdea
jmp 0x1c512
xorl %r12d, %r12d
jmp 0x1c56c
cmpl $0x0, 0x40(%rbx)
jne 0x1c512
movq %rbx, %rdi
callq 0x1c142
cmpl $0x1, (%rbx)
jne 0x1c54e
xorl %r12d, %r12d
testq %r14, %r14
je 0x1c55f
leaq (%r15,%r12), %r13
movl 0x4(%rbx), %edi
movq %r13, %rsi
movq %r14, %rdx
callq 0x31b0
testq %rax, %rax
jns 0x1c542
callq 0x34a0
cmpl $0x4, (%rax)
je 0x1c523
jmp 0x1c565
je 0x1c55f
addq %rax, %r12
subq %rax, %r14
jne 0x1c51f
jmp 0x1c55f
movl 0x4(%rbx), %edi
movq %r15, %rsi
movq %r14, %rdx
callq 0x1c2f5
movq %rax, %r12
addq %r12, 0x8(%rbx)
jmp 0x1c56c
movq $-0x1, %r12
movq %r12, %rax
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
// File: /workspace/github_cpp_makefile_star2_O1/statgen[P]statgen/lib/samtools-0.1.7a-hybrid/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 0x1c587
cmpq %rsi, 0x8(%rbx)
je 0x1c5df
movl (%rbx), %eax
cmpl $0x3, %eax
je 0x1c5ac
cmpl $0x2, %eax
je 0x1c5bc
cmpl $0x1, %eax
jne 0x1c5e3
movl 0x4(%rbx), %edi
callq 0x3590
cmpq $-0x1, %rax
je 0x1c5ef
movq %rax, 0x8(%rbx)
jmp 0x1c5df
cmpl $0x1, %edx
je 0x1c5c1
cmpl $0x2, %edx
je 0x1c5ea
testl %edx, %edx
jne 0x1c5d8
jmp 0x1c5d4
cmpl $0x1, %edx
jne 0x1c5c7
addq %rsi, 0x8(%rbx)
jmp 0x1c5d8
testl %edx, %edx
je 0x1c5d4
cmpl $0x2, %edx
jne 0x1c5d8
addq 0x68(%rbx), %rsi
movq %rsi, 0x8(%rbx)
movl $0x0, 0x40(%rbx)
xorl %eax, %eax
popq %rbx
retq
callq 0x4ba5
jmp 0x1c5ef
callq 0x4b78
movq $-0x1, %rax
jmp 0x1c5e1
// File: /workspace/github_cpp_makefile_star2_O1/statgen[P]statgen/lib/samtools-0.1.7a-hybrid/knetfile.c
// Function: socket_wait
static int socket_wait(int fd, int is_read)
{
	fd_set fds, *fdr = 0, *fdw = 0;
	struct timeval tv;
	int ret;
	tv.tv_sec = 5; tv.tv_usec = 0; // 5 seconds time out
	FD_ZERO(&fds);
	FD_SET(fd, &fds);
	if (is_read) fdr = &fds;
	else fdw = &fds;
	ret = select(fd+1, fdr, fdw, 0, &tv);
#ifndef _WIN32
	if (ret == -1) perror("select");
#else
	if (ret == 0)
		fprintf(stderr, "select time-out\n");
	else if (ret == SOCKET_ERROR)
		fprintf(stderr, "select: %d\n", WSAGetLastError());
#endif
	return ret;
}

// Assembly:
pushq %rbx
subq $0x90, %rsp
movl %esi, %eax
movq %rsp, %r8
movq $0x5, (%r8)
xorps %xmm0, %xmm0
leaq 0x10(%rsp), %rsi
movaps %xmm0, (%rsi)
movaps %xmm0, 0x10(%rsi)
movaps %xmm0, 0x20(%rsi)
movaps %xmm0, 0x30(%rsi)
movaps %xmm0, 0x40(%rsi)
movaps %xmm0, 0x50(%rsi)
leal 0x3f(%rdi), %edx
testl %edi, %edi
cmovnsl %edi, %edx
movl %edx, %r9d
andl $-0x40, %r9d
movl %edi, %ecx
subl %r9d, %ecx
movl $0x1, %r9d
shlq %cl, %r9
movaps %xmm0, 0x60(%rsi)
movaps %xmm0, 0x70(%rsi)
sarl $0x6, %edx
movslq %edx, %rcx
orq %r9, 0x10(%rsp,%rcx,8)
xorl %ecx, %ecx
testl %eax, %eax
movl $0x0, %edx
cmoveq %rsi, %rdx
movq $0x0, 0x8(%r8)
cmoveq %rcx, %rsi
incl %edi
xorl %ecx, %ecx
callq 0x3110
movl %eax, %ebx
cmpl $-0x1, %eax
je 0x1c68f
movl %ebx, %eax
addq $0x90, %rsp
popq %rbx
retq
leaq 0xb01c(%rip), %rdi      # 0x276b2
callq 0x3620
jmp 0x1c684
nopl (%rax)
// File: /workspace/github_cpp_makefile_star2_O1/statgen[P]statgen/lib/samtools-0.1.7a-hybrid/bam_sort.c
// Function: bam_merge
int bam_merge(int argc, char *argv[])
{
	int c, is_by_qname = 0, add_RG = 0;
	char *fn_headers = NULL;

	while ((c = getopt(argc, argv, "h:nr")) >= 0) {
		switch (c) {
		case 'r': add_RG = 1; break;
		case 'h': fn_headers = strdup(optarg); break;
		case 'n': is_by_qname = 1; break;
		}
	}
	if (optind + 2 >= argc) {
		fprintf(stderr, "\n");
		fprintf(stderr, "Usage:   samtools merge [-nr] [-h inh.sam] <out.bam> <in1.bam> <in2.bam> [...]\n\n");
		fprintf(stderr, "Options: -n       sort by read names\n");
		fprintf(stderr, "         -r       attach RG tag (inferred from file names)\n");
		fprintf(stderr, "         -h FILE  copy the header in FILE to <out.bam> [in1.bam]\n\n");
		fprintf(stderr, "Note: Samtools' merge does not reconstruct the @RG dictionary in the header. Users\n");
		fprintf(stderr, "      must provide the correct header with -h, or uses Picard which properly maintains\n");
		fprintf(stderr, "      the header dictionary in merging.\n\n");
		return 1;
	}
	bam_merge_core(is_by_qname, argv[optind], fn_headers, argc - optind - 1, argv + optind + 1, add_RG);
	free(fn_headers);
	return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rsi, %r14
movl %edi, %ebx
leaq 0x93e6(%rip), %rdx      # 0x27953
callq 0x31a0
testl %eax, %eax
js 0x1e5c8
xorl %r15d, %r15d
leaq 0x93d3(%rip), %r13      # 0x27953
xorl %ebp, %ebp
xorl %r12d, %r12d
cmpl $0x68, %eax
je 0x1e5a3
cmpl $0x6e, %eax
je 0x1e59b
cmpl $0x72, %eax
jne 0x1e5b5
movl $0x1, %ebp
jmp 0x1e5b5
movl $0x1, %r12d
jmp 0x1e5b5
movq 0x10a36(%rip), %rax     # 0x2efe0
movq (%rax), %rdi
callq 0x34b0
movq %rax, %r15
movl %ebx, %edi
movq %r14, %rsi
movq %r13, %rdx
callq 0x31a0
testl %eax, %eax
jns 0x1e585
jmp 0x1e5d0
xorl %r12d, %r12d
xorl %ebp, %ebp
xorl %r15d, %r15d
movq 0x109e1(%rip), %rax     # 0x2efb8
movslq (%rax), %rcx
leal 0x2(%rcx), %eax
cmpl %ebx, %eax
jge 0x1e618
leaq (%r14,%rcx,8), %r8
addq $0x8, %r8
movq -0x8(%r8), %rsi
notl %ecx
addl %ebx, %ecx
movl %r12d, %edi
movq %r15, %rdx
movl %ebp, %r9d
callq 0x1de28
movq %r15, %rdi
callq 0x32c0
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x4c62
movl $0x1, %eax
jmp 0x1e609
// File: /workspace/github_cpp_makefile_star2_O1/statgen[P]statgen/lib/samtools-0.1.7a-hybrid/bam_sort.c
// Function: bam_sort
int bam_sort(int argc, char *argv[])
{
	size_t max_mem = 500000000;
	int c, is_by_qname = 0, is_stdout = 0;
	while ((c = getopt(argc, argv, "nom:")) >= 0) {
		switch (c) {
		case 'o': is_stdout = 1; break;
		case 'n': is_by_qname = 1; break;
		case 'm': max_mem = atol(optarg); break;
		}
	}
	if (optind + 2 > argc) {
		fprintf(stderr, "Usage: samtools sort [-on] [-m <maxMem>] <in.bam> <out.prefix>\n");
		return 1;
	}
	bam_sort_core_ext(is_by_qname, argv[optind], argv[optind+1], max_mem, is_stdout);
	return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rsi, %rbx
movl %edi, %ebp
leaq 0x83cc(%rip), %rdx      # 0x27bb9
callq 0x31a0
testl %eax, %eax
js 0x1f84d
movl $0x1dcd6500, %r15d      # imm = 0x1DCD6500
xorl %r14d, %r14d
leaq 0x83b3(%rip), %r13      # 0x27bb9
xorl %r12d, %r12d
cmpl $0x6d, %eax
je 0x1f828
cmpl $0x6e, %eax
je 0x1f820
cmpl $0x6f, %eax
jne 0x1f83a
movl $0x1, %r14d
jmp 0x1f83a
movl $0x1, %r12d
jmp 0x1f83a
movq 0xf7b1(%rip), %rax      # 0x2efe0
movq (%rax), %rdi
callq 0x3370
movq %rax, %r15
movl %ebp, %edi
movq %rbx, %rsi
movq %r13, %rdx
callq 0x31a0
testl %eax, %eax
jns 0x1f809
jmp 0x1f859
xorl %r12d, %r12d
movl $0x1dcd6500, %r15d      # imm = 0x1DCD6500
xorl %r14d, %r14d
movq 0xf758(%rip), %rax      # 0x2efb8
movslq (%rax), %rax
leal 0x2(%rax), %ecx
cmpl %ebp, %ecx
jg 0x1f892
movq (%rbx,%rax,8), %rsi
movq 0x8(%rbx,%rax,8), %rdx
movl %r12d, %edi
movq %r15, %rcx
movl %r14d, %r8d
callq 0x1f3a6
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x4d59
movl $0x1, %eax
jmp 0x1f883
// File: /workspace/github_cpp_makefile_star2_O1/statgen[P]statgen/lib/samtools-0.1.7a-hybrid/bam_sort.c
// Function: strnum_cmp
static inline int strnum_cmp(const char *a, const char *b)
{
	char *pa, *pb;
	pa = (char*)a; pb = (char*)b;
	while (*pa && *pb) {
		if (isdigit(*pa) && isdigit(*pb)) {
			long ai, bi;
			ai = strtol(pa, &pa, 10);
			bi = strtol(pb, &pb, 10);
			if (ai != bi) return ai<bi? -1 : ai>bi? 1 : 0;
		} else {
			if (*pa != *pb) break;
			++pa; ++pb;
		}
	}
	if (*pa == *pb)
		return (pa-a) < (pb-b)? -1 : (pa-a) > (pb-b)? 1 : 0;
	return *pa<*pb? -1 : *pa>*pb? 1 : 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rdi, %r14
movq %rdi, 0x8(%rsp)
movq %rsi, 0x10(%rsp)
movq %rsi, (%rsp)
movb (%rdi), %r12b
movq %rdi, %r13
testb %r12b, %r12b
je 0x1f955
movq (%rsp), %r15
movsbq (%r15), %rbx
testq %rbx, %rbx
je 0x1f955
callq 0x3310
movq (%rax), %rax
movsbq %r12b, %rcx
testb $0x8, 0x1(%rax,%rcx,2)
je 0x1f8f3
testb $0x8, 0x1(%rax,%rbx,2)
jne 0x1f909
cmpb %bl, %r12b
jne 0x1f955
incq %r13
movq %r13, 0x8(%rsp)
incq %r15
movq %r15, (%rsp)
jmp 0x1f943
movq %r13, %rdi
leaq 0x8(%rsp), %rsi
movl $0xa, %edx
callq 0x3400
movq %rax, %r13
movq %r15, %rdi
movq %rsp, %rsi
movl $0xa, %edx
callq 0x3400
xorl %ecx, %ecx
cmpq %rax, %r13
setg %cl
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
cmovll %eax, %ecx
cmovnel %ecx, %ebp
jne 0x1f986
movq 0x8(%rsp), %r13
movb (%r13), %r12b
testb %r12b, %r12b
jne 0x1f8cc
movq (%rsp), %rax
cmpb (%rax), %r12b
jne 0x1f978
subq %r14, %r13
subq 0x10(%rsp), %rax
xorl %ecx, %ecx
cmpq %rax, %r13
setg %cl
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
cmovgel %ecx, %ebp
jmp 0x1f986
setg %al
movzbl %al, %eax
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
cmovgel %eax, %ebp
movl %ebp, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop
// File: /workspace/github_cpp_makefile_star2_O1/statgen[P]statgen/lib/samtools-0.1.7a-hybrid/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 0x1f9d2
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %rbx
movq %rdi, %r14
movq 0x8(%r14), %rdi
callq 0x1f9d3
movq (%r14), %r14
testq %r14, %r14
jne 0x1f9a7
movq (%rbx), %r14
movq %rbx, %rdi
callq 0x32c0
movq %r14, %rbx
testq %r14, %r14
jne 0x1f9b8
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_cpp_makefile_star2_O1/statgen[P]statgen/lib/samtools-0.1.7a-hybrid/sam_header.c
// Function: sam_header_line_free
static void sam_header_line_free(HeaderLine *hline)
{
    list_t *tags = hline->tags;
    while (tags)
    {
        HeaderTag *tag = tags->data;
        free(tag->value);
        free(tag);
        tags = tags->next;
    }
    list_free(hline->tags);
    free(hline);
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movq %rdi, %rbx
movq 0x8(%rdi), %r15
testq %r15, %r15
je 0x1f9fe
movq 0x8(%r15), %r14
movq 0x8(%r14), %rdi
callq 0x32c0
movq %r14, %rdi
callq 0x32c0
movq (%r15), %r15
jmp 0x1f9df
movq 0x8(%rbx), %rdi
testq %rdi, %rdi
je 0x1fa17
movq (%rdi), %r14
callq 0x32c0
movq %r14, %rdi
testq %r14, %r14
jne 0x1fa07
movq %rbx, %rdi
popq %rbx
popq %r14
popq %r15
jmp 0x32c0
// File: /workspace/github_cpp_makefile_star2_O1/statgen[P]statgen/lib/samtools-0.1.7a-hybrid/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 0x1fa54
movq %rdi, %rbx
xorl %r14d, %r14d
movq 0x8(%rbx), %rdi
callq 0x1fab0
movq %r14, %rdi
movq %rax, %rsi
callq 0x1fa62
movq %rax, %r14
movq (%rbx), %rbx
testq %rbx, %rbx
jne 0x1fa33
jmp 0x1fa57
xorl %r14d, %r14d
movq %r14, %rax
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_cpp_makefile_star2_O1/statgen[P]statgen/lib/samtools-0.1.7a-hybrid/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 0x1fa8f
movq %rax, %r15
movq (%rax), %rax
testq %rax, %rax
jne 0x1fa70
movl $0x10, %edi
callq 0x31d0
movq %rax, (%r15)
jmp 0x1fa9c
movl $0x10, %edi
callq 0x31d0
movq %rax, %r14
movq %rbx, 0x8(%rax)
movq $0x0, (%rax)
movq %r14, %rax
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_cpp_makefile_star2_O1/statgen[P]statgen/lib/samtools-0.1.7a-hybrid/sam_header.c
// Function: sam_header_line_clone
static HeaderLine *sam_header_line_clone(const HeaderLine *hline)
{
    list_t *tags;
    HeaderLine *out = malloc(sizeof(HeaderLine));
    out->type[0] = hline->type[0];
    out->type[1] = hline->type[1];
    out->tags = NULL;

    tags = hline->tags;
    while (tags)
    {
        HeaderTag *old = tags->data;

        HeaderTag *new = malloc(sizeof(HeaderTag));
        new->key[0] = old->key[0];
        new->key[1] = old->key[1];
        new->value  = strdup(old->value);
        out->tags = list_append(out->tags, new);

        tags = tags->next;
    }
    return out;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
movq %rdi, %r14
movl $0x10, %edi
callq 0x31d0
movq %rax, %rbx
movb (%r14), %al
movb %al, (%rbx)
movb 0x1(%r14), %al
movb %al, 0x1(%rbx)
movq $0x0, 0x8(%rbx)
movq 0x8(%r14), %r12
testq %r12, %r12
je 0x1fb33
movq 0x8(%rbx), %r14
movq 0x8(%r12), %r13
movl $0x10, %edi
callq 0x31d0
movq %rax, %r15
movb (%r13), %al
movb %al, (%r15)
movb 0x1(%r13), %al
movb %al, 0x1(%r15)
movq 0x8(%r13), %rdi
callq 0x34b0
movq %rax, 0x8(%r15)
movq %r14, %rdi
movq %r15, %rsi
callq 0x1fa62
movq %rax, %r14
movq (%r12), %r12
testq %r12, %r12
jne 0x1faea
movq %r14, 0x8(%rbx)
movq %rbx, %rax
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
// File: /workspace/github_cpp_makefile_star2_O1/statgen[P]statgen/lib/samtools-0.1.7a-hybrid/sam_header.c
// Function: sam_header_write
char *sam_header_write(const void *_header)
{
	const HeaderDict *header = (const HeaderDict*)_header;
    char *out = NULL;
    int len=0, nout=0;
    const list_t *hlines;

    // Calculate the length of the string to allocate
    hlines = header;
    while (hlines)
    {
        len += 4;   // @XY and \n

        HeaderLine *hline = hlines->data;
        list_t *tags = hline->tags;
        while (tags)
        {
            HeaderTag *tag = tags->data;
            len += strlen(tag->value) + 1;                  // \t
            if ( tag->key[0]!=' ' || tag->key[1]!=' ' )
                len += strlen(tag->value) + 3;              // XY:
            tags = tags->next;
        }
        hlines = hlines->next;
    }

    nout = 0;
    out  = malloc(len+1);
    hlines = header;
    while (hlines)
    {
        HeaderLine *hline = hlines->data;

        nout += sprintf(out+nout,"@%c%c",hline->type[0],hline->type[1]);

        list_t *tags = hline->tags;
        while (tags)
        {
            HeaderTag *tag = tags->data;
            nout += sprintf(out+nout,"\t");
            if ( tag->key[0]!=' ' || tag->key[1]!=' ' )
                nout += sprintf(out+nout,"%c%c:", tag->key[0],tag->key[1]);
            nout += sprintf(out+nout,"%s", tag->value);
            tags = tags->next;
        }
        hlines = hlines->next;
        nout += sprintf(out+nout,"\n");
    }
    out[len] = 0;
    return out;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %r12
xorl %ebp, %ebp
testq %rdi, %rdi
je 0x1fb98
movq %r12, %r14
addl $0x4, %ebp
movq 0x8(%r14), %rax
movq 0x8(%rax), %rbx
testq %rbx, %rbx
je 0x1fb90
movq 0x8(%rbx), %r15
movq 0x8(%r15), %rdi
callq 0x32d0
addl %eax, %ebp
incl %ebp
cmpb $0x20, (%r15)
jne 0x1fb86
cmpb $0x20, 0x1(%r15)
je 0x1fb8b
addl %eax, %ebp
addl $0x3, %ebp
movq (%rbx), %rbx
jmp 0x1fb63
movq (%r14), %r14
testq %r14, %r14
jne 0x1fb58
leal 0x1(%rbp), %eax
movslq %eax, %rdi
callq 0x31d0
movq %rax, %r14
testq %r12, %r12
je 0x1fc5d
xorl %eax, %eax
movq %r12, (%rsp)
movq 0x8(%r12), %r15
movslq %eax, %rbx
leaq (%r14,%rbx), %rdi
movsbl (%r15), %edx
movsbl 0x1(%r15), %ecx
leaq 0x8087(%rip), %rsi      # 0x27c58
xorl %eax, %eax
callq 0x3350
addl %eax, %ebx
movq 0x8(%r15), %r15
testq %r15, %r15
je 0x1fc40
movq 0x8(%r15), %r12
movslq %ebx, %rbx
movw $0x9, (%r14,%rbx)
incl %ebx
movsbl (%r12), %edx
cmpl $0x20, %edx
jne 0x1fc05
cmpb $0x20, 0x1(%r12)
je 0x1fc22
movslq %ebx, %rbx
leaq (%r14,%rbx), %rdi
movsbl 0x1(%r12), %ecx
leaq 0x685b(%rip), %rsi      # 0x26474
xorl %eax, %eax
callq 0x3350
addl %eax, %ebx
movslq %ebx, %rbx
leaq (%r14,%rbx), %r13
movq 0x8(%r12), %rsi
movq %r13, %rdi
callq 0x30c0
subl %r13d, %eax
addl %eax, %ebx
movq (%r15), %r15
jmp 0x1fbde
movq (%rsp), %r12
movq (%r12), %r12
movslq %ebx, %rax
movw $0xa, (%r14,%rax)
incl %eax
testq %r12, %r12
jne 0x1fbb1
movslq %ebp, %rax
movb $0x0, (%r14,%rax)
movq %r14, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O1/statgen[P]statgen/lib/samtools-0.1.7a-hybrid/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
movq %rcx, (%rsp)
movl $0x0, (%rcx)
testq %rdi, %rdi
je 0x2061e
movq %rdx, %r14
movq %rsi, %r15
movq %rdi, %r12
xorl %ecx, %ecx
xorl %eax, %eax
xorl %r13d, %r13d
movq 0x8(%r12), %rdx
movb (%rdx), %sil
cmpb (%r15), %sil
jne 0x2060f
movb 0x1(%rdx), %sil
cmpb 0x1(%r15), %sil
jne 0x2060f
movq 0x8(%rdx), %rdx
testq %rdx, %rdx
je 0x205d7
movq 0x8(%rdx), %rdi
movb (%rdi), %sil
cmpb (%r14), %sil
jne 0x205ca
movb 0x1(%rdi), %sil
cmpb 0x1(%r14), %sil
jne 0x205ca
xorl %esi, %esi
movq %rdi, %rbp
jmp 0x205d0
movq (%rdx), %rdx
movb $0x1, %sil
testb %sil, %sil
jne 0x205a8
jmp 0x205d9
xorl %ebp, %ebp
testq %rbp, %rbp
je 0x2060f
cmpl %ecx, %r13d
jne 0x20601
leal (%rcx,%rcx), %ebx
testl %ecx, %ecx
movl $0x4, %ecx
cmovel %ecx, %ebx
movslq %ebx, %rsi
shlq $0x3, %rsi
movq %rax, %rdi
callq 0x3610
movl %ebx, %ecx
movq 0x8(%rbp), %rdx
movslq %r13d, %rsi
incl %r13d
movq %rdx, (%rax,%rsi,8)
movq (%r12), %r12
testq %r12, %r12
jne 0x2058d
jmp 0x20623
xorl %r13d, %r13d
xorl %eax, %eax
movq (%rsp), %rcx
movl %r13d, (%rcx)
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O1/statgen[P]statgen/lib/samtools-0.1.7a-hybrid/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), %r10d
testl %r10d, %r10d
je 0x2068a
movq %rsi, %r14
movsbl (%rsi), %edi
xorl %r8d, %r8d
movl $0x0, %ecx
testl %edi, %edi
je 0x20694
movb 0x1(%r14), %al
testb %al, %al
je 0x20692
leaq 0x2(%r14), %rdx
movl %edi, %ecx
movl %ecx, %edi
shll $0x5, %edi
subl %ecx, %edi
movsbl %al, %ecx
addl %edi, %ecx
movb (%rdx), %al
incq %rdx
testb %al, %al
jne 0x20673
jmp 0x20694
xorl %r13d, %r13d
jmp 0x20734
movl %edi, %ecx
movl %ecx, %eax
xorl %edx, %edx
divl %r10d
movl %edx, %r15d
leal -0x1(%r10), %edi
movl %ecx, %eax
xorl %edx, %edx
divl %edi
movl %edx, %ebx
incl %ebx
movq (%rsp), %rax
movq 0x10(%rax), %rdi
movl %r15d, %r13d
movq %r10, 0x10(%rsp)
movq %rdi, 0x8(%rsp)
movl %r13d, %eax
shrl $0x4, %eax
movl (%rdi,%rax,4), %ebp
leal (,%r13,2), %r12d
andl $0x1e, %r12d
movl %ebp, %eax
movl %r12d, %ecx
shrl %cl, %eax
testb $0x2, %al
jne 0x20727
testb $0x1, %al
jne 0x2070d
movq (%rsp), %rax
movq 0x18(%rax), %rax
movl %r13d, %ecx
movq (%rax,%rcx,8), %rdi
movq %r14, %rsi
callq 0x34e0
movq 0x8(%rsp), %rdi
movq 0x10(%rsp), %r10
xorl %r8d, %r8d
testl %eax, %eax
je 0x20727
addl %ebx, %r13d
cmpl %r10d, %r13d
movl %r10d, %eax
cmovbl %r8d, %eax
subl %eax, %r13d
cmpl %r15d, %r13d
jne 0x206c1
movl %r10d, %r13d
jmp 0x20734
movl %r12d, %ecx
shrl %cl, %ebp
testb $0x3, %bpl
cmovnel %r10d, %r13d
cmpl %r10d, %r13d
jne 0x2073d
xorl %eax, %eax
jmp 0x2074c
movq (%rsp), %rax
movq 0x20(%rax), %rax
movl %r13d, %ecx
movq (%rax,%rcx,8), %rax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O1/statgen[P]statgen/lib/samtools-0.1.7a-hybrid/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 0x6f5d(%rip), %rsi      # 0x27c58
xorl %eax, %eax
callq 0x3630
testq %r15, %r15
je 0x20d59
leaq 0x5766(%rip), %r14      # 0x26474
movq 0x8(%r15), %r12
movl $0x9, %edi
movq %rbx, %rsi
callq 0x3290
movsbl (%r12), %edx
cmpl $0x20, %edx
jne 0x20d31
cmpb $0x20, 0x1(%r12)
je 0x20d44
movsbl 0x1(%r12), %ecx
movq %rbx, %rdi
movq %r14, %rsi
xorl %eax, %eax
callq 0x3630
movq 0x8(%r12), %rdi
movq %rbx, %rsi
callq 0x33f0
movq (%r15), %r15
testq %r15, %r15
jne 0x20d0e
movl $0xa, %edi
movq %rbx, %rsi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
jmp 0x3290
// File: /workspace/github_cpp_makefile_star2_O1/statgen[P]statgen/lib/samtools-0.1.7a-hybrid/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 %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
movq %rdx, %rbx
movq %rsi, %r15
movq %rdi, %r12
movl $0x10, %edi
callq 0x31d0
movq %rax, %r14
subl %r15d, %ebx
movb (%r12), %al
movb %al, (%r14)
movb 0x1(%r12), %al
movb %al, 0x1(%r14)
shlq $0x20, %rbx
movabsq $0x200000000, %r12      # imm = 0x200000000
addq %rbx, %r12
sarq $0x20, %r12
movq %r12, %rdi
callq 0x31d0
movq %rax, %r13
movq %rax, 0x8(%r14)
movq %rax, %rdi
movq %r15, %rsi
movq %r12, %rdx
callq 0x3680
movabsq $0x100000000, %rax      # imm = 0x100000000
addq %rbx, %rax
sarq $0x20, %rax
movb $0x0, (%r13,%rax)
movq %r14, %rax
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
// File: /workspace/github_cpp_makefile_star2_O1/statgen[P]statgen/lib/samtools-0.1.7a-hybrid/razf.c
// Function: razf_buffered_write
static void _razf_buffered_write(RAZF *rz, const void *data, int size){
	int i, n;
	while(1){
		if(rz->buf_len == RZ_BUFFER_SIZE){
			_razf_write(rz, rz->inbuf, rz->buf_len);
			rz->buf_len = 0;
		}
		if(size + rz->buf_len < RZ_BUFFER_SIZE){
			for(i=0;i<size;i++) ((char*)rz->inbuf + rz->buf_len)[i] = ((char*)data)[i];
			rz->buf_len += size;
			return;
		} else {
			n = RZ_BUFFER_SIZE - rz->buf_len;
			for(i=0;i<n;i++) ((char*)rz->inbuf + rz->buf_len)[i] = ((char*)data)[i];
			size -= n;
			data += n;
			rz->buf_len += n;
		}
	}
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movl %edx, %ebx
movq %rsi, %r15
movq %rdi, %r14
cmpl $0x1000, 0x84(%r14) # imm = 0x1000
jne 0x2225b
movq 0x60(%r14), %rsi
movq %r14, %rdi
movl $0x1000, %edx           # imm = 0x1000
callq 0x230d8
movl $0x0, 0x84(%r14)
movl 0x84(%r14), %ecx
leal (%rcx,%rbx), %eax
cmpl $0xfff, %eax            # imm = 0xFFF
jle 0x222b7
movl $0x1000, %eax           # imm = 0x1000
subl %ecx, %eax
cmpl $0xfff, %ecx            # imm = 0xFFF
jg 0x222a3
cmpl $0x2, %eax
movl $0x1, %ecx
cmovgel %eax, %ecx
xorl %edx, %edx
movslq 0x84(%r14), %rsi
addq 0x60(%r14), %rsi
movb (%r15,%rdx), %dil
movb %dil, (%rdx,%rsi)
incq %rdx
cmpq %rdx, %rcx
jne 0x22288
subl %eax, %ebx
movslq %eax, %rcx
addq %rcx, %r15
addl %eax, 0x84(%r14)
jmp 0x22232
testl %ebx, %ebx
jle 0x222da
movl %ebx, %eax
xorl %ecx, %ecx
movslq 0x84(%r14), %rdx
addq 0x60(%r14), %rdx
movb (%r15,%rcx), %sil
movb %sil, (%rcx,%rdx)
incq %rcx
cmpq %rcx, %rax
jne 0x222bf
addl %ebx, 0x84(%r14)
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_cpp_makefile_star2_O1/statgen[P]statgen/lib/samtools-0.1.7a-hybrid/razf.c
// Function: razf_open_w
static RAZF* razf_open_w(int fd){
	RAZF *rz;
#ifdef _WIN32
	setmode(fd, O_BINARY);
#endif
	rz = calloc(1, sizeof(RAZF));
	rz->mode = 'w';
#ifdef _USE_KNETFILE
    rz->x.fpw = fd;
#else
	rz->filedes = fd;
#endif
	rz->stream = calloc(sizeof(z_stream), 1);
	rz->inbuf  = malloc(RZ_BUFFER_SIZE);
	rz->outbuf = malloc(RZ_BUFFER_SIZE);
	rz->index = calloc(sizeof(ZBlockIndex), 1);
	deflateInit2(rz->stream, RZ_COMPRESS_LEVEL, Z_DEFLATED, WINDOW_BITS + 16, DEF_MEM_LEVEL, Z_DEFAULT_STRATEGY);
	rz->stream->avail_out = RZ_BUFFER_SIZE;
	rz->stream->next_out  = rz->outbuf;
	rz->header = calloc(sizeof(gz_header), 1);
	rz->header->os    = 0x03; //Unix
	rz->header->text  = 0;
	rz->header->time  = 0;
	rz->header->extra = malloc(7);
	strncpy((char*)rz->header->extra, "RAZF", 4);
	rz->header->extra[4] = 1; // obsolete field
	// block size = RZ_BLOCK_SIZE, Big-Endian
	rz->header->extra[5] = RZ_BLOCK_SIZE >> 8;
	rz->header->extra[6] = RZ_BLOCK_SIZE & 0xFF;
	rz->header->extra_len = 7;
	rz->header->name = rz->header->comment  = 0;
	rz->header->hcrc = 0;
	deflateSetHeader(rz->stream, rz->header);
	rz->block_pos = rz->block_off = 0;
	return rz;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movl %edi, %ebp
movl $0x1, %edi
movl $0x98, %esi
callq 0x3530
movq %rax, %rbx
movb $0x77, (%rax)
movl %ebp, 0x8(%rax)
movl $0x70, %edi
movl $0x1, %esi
callq 0x3530
movq %rax, %r14
movq %rax, 0x10(%rbx)
movl $0x1000, %edi           # imm = 0x1000
callq 0x31d0
movq %rax, 0x60(%rbx)
movl $0x1000, %edi           # imm = 0x1000
callq 0x31d0
movq %rax, %r15
movq %rax, 0x68(%rbx)
movl $0x18, %edi
movl $0x1, %esi
callq 0x3530
movq %rax, 0x18(%rbx)
leaq 0x3ddd(%rip), %rax      # 0x2617c
xorl %r12d, %r12d
movq %r14, %rdi
movl $0x6, %esi
movl $0x8, %edx
movl $0x1f, %ecx
movl $0x8, %r8d
xorl %r9d, %r9d
pushq $0x70
pushq %rax
callq 0x3520
addq $0x10, %rsp
movl $0x1000, 0x20(%r14)     # imm = 0x1000
movq %r15, 0x18(%r14)
movl $0x50, %edi
movl $0x1, %esi
callq 0x3530
movq %rax, %r15
movq %rax, 0x78(%rbx)
movl $0x3, 0x14(%rax)
movl %r12d, (%rax)
movq %r12, 0x8(%rax)
movl $0x7, %edi
callq 0x31d0
movq %rax, 0x18(%r15)
movl $0x465a4152, (%rax)     # imm = 0x465A4152
movw $0x8001, 0x4(%rax)      # imm = 0x8001
movb $0x0, 0x6(%rax)
movl $0x7, 0x20(%r15)
movq %r12, 0x38(%r15)
movq %r12, 0x28(%r15)
movl %r12d, 0x44(%r15)
movq %r14, %rdi
movq %r15, %rsi
callq 0x33e0
xorps %xmm0, %xmm0
movups %xmm0, 0x48(%rbx)
movq %rbx, %rax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O1/statgen[P]statgen/lib/samtools-0.1.7a-hybrid/razf.c
// Function: razf_get_data_size
int razf_get_data_size(RAZF *rz, int64_t *u_size, int64_t *c_size){
	int64_t n;
	if(rz->mode != 'r' && rz->mode != 'R') return 0;
	switch(rz->file_type){
		case FILE_TYPE_PLAIN:
			if(rz->end == 0x7fffffffffffffffLL){
#ifdef _USE_KNETFILE
				if(knet_seek(rz->x.fpr, 0, SEEK_CUR) == -1) return 0;
                n = knet_tell(rz->x.fpr);
				knet_seek(rz->x.fpr, 0, SEEK_END);
                rz->end = knet_tell(rz->x.fpr);
				knet_seek(rz->x.fpr, n, SEEK_SET);
#else
				if((n = lseek(rz->filedes, 0, SEEK_CUR)) == -1) return 0;
				rz->end = lseek(rz->filedes, 0, SEEK_END);
				lseek(rz->filedes, n, SEEK_SET);
#endif                
			}
			*u_size = *c_size = rz->end;
			return 1;
		case FILE_TYPE_GZ:
			return 0;
		case FILE_TYPE_RZ:
			if(rz->src_end == rz->end) return 0;
			*u_size = rz->src_end;
			*c_size = rz->end;
			return 1;
		default:
			return 0;
	}
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
movzbl (%rdi), %eax
xorl %r12d, %r12d
orl $0x20, %eax
cmpl $0x72, %eax
jne 0x2291c
movq %rdx, %rbx
movq %rsi, %r14
movq %rdi, %r15
movl 0x4(%rdi), %eax
cmpl $0x1, %eax
je 0x22902
cmpl $0x2, %eax
jne 0x2291c
movabsq $0x7fffffffffffffff, %rax # imm = 0x7FFFFFFFFFFFFFFF
cmpq %rax, 0x30(%r15)
jne 0x228f6
movq 0x8(%r15), %rdi
xorl %r12d, %r12d
xorl %esi, %esi
movl $0x1, %edx
callq 0x1c579
cmpq $-0x1, %rax
je 0x2291c
movq 0x8(%r15), %rdi
movq 0x8(%rdi), %r12
xorl %esi, %esi
movl $0x2, %edx
callq 0x1c579
movq 0x8(%r15), %rdi
movq 0x8(%rdi), %rax
movq %rax, 0x30(%r15)
movq %r12, %rsi
xorl %edx, %edx
callq 0x1c579
movq 0x30(%r15), %rax
movq %rax, (%rbx)
movq %rax, (%r14)
jmp 0x22916
movq 0x38(%r15), %rax
cmpq 0x30(%r15), %rax
je 0x2291c
movq %rax, (%r14)
movq 0x30(%r15), %rax
movq %rax, (%rbx)
movl $0x1, %r12d
movl %r12d, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
// File: /workspace/github_cpp_makefile_star2_O1/statgen[P]statgen/lib/samtools-0.1.7a-hybrid/razf.c
// Function: razf_read
int razf_read(RAZF *rz, void *data, int size){
	int ori_size, i;
	ori_size = size;
	while(size > 0){
		if(rz->buf_len){
			if(size < rz->buf_len){
				for(i=0;i<size;i++) ((char*)data)[i] = ((char*)rz->outbuf + rz->buf_off)[i];
				rz->buf_off += size;
				rz->buf_len -= size;
				data += size;
				rz->block_off += size;
				size = 0;
				break;
			} else {
				for(i=0;i<rz->buf_len;i++) ((char*)data)[i] = ((char*)rz->outbuf + rz->buf_off)[i];
				data += rz->buf_len;
				size -= rz->buf_len;
				rz->block_off += rz->buf_len;
				rz->buf_off = 0;
				rz->buf_len = 0;
				if(rz->buf_flush){
					rz->block_pos = rz->next_block_pos;
					rz->block_off = 0;
					rz->buf_flush = 0;
				}
			}
		} else if(rz->buf_flush){
			rz->block_pos = rz->next_block_pos;
			rz->block_off = 0;
			rz->buf_flush = 0;
		}
		if(rz->buf_flush) continue;
		rz->buf_len = _razf_read(rz, rz->outbuf, RZ_BUFFER_SIZE);
		if(rz->z_eof && rz->buf_len == 0) break;
	}
	rz->out += ori_size - size;
	return ori_size - size;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movl %edx, %ebx
movq %rdi, %r14
movl %edx, %ebp
testl %edx, %edx
jle 0x22a2d
movq %rsi, %r15
movl %ebx, %ebp
movl 0x84(%r14), %eax
testl %eax, %eax
je 0x2299e
cmpl %eax, %ebp
jl 0x229f7
movl 0x84(%r14), %ecx
testl %ecx, %ecx
jle 0x22987
xorl %eax, %eax
movslq 0x80(%r14), %rcx
addq 0x68(%r14), %rcx
movb (%rax,%rcx), %cl
movb %cl, (%r15,%rax)
incq %rax
movslq 0x84(%r14), %rcx
cmpq %rcx, %rax
jl 0x22966
movslq %ecx, %rax
addq %rax, %r15
addq %rax, 0x50(%r14)
subl %eax, %ebp
movq $0x0, 0x80(%r14)
cmpl $0x0, 0x40(%r14)
je 0x229bd
movq 0x58(%r14), %rax
movq %rax, 0x48(%r14)
movq $0x0, 0x50(%r14)
movl $0x0, 0x40(%r14)
cmpl $0x0, 0x40(%r14)
jne 0x229ed
movq 0x68(%r14), %rsi
movq %r14, %rdi
callq 0x22a41
movl %eax, 0x84(%r14)
cmpl $0x0, 0x8c(%r14)
sete %cl
testl %eax, %eax
setne %al
orb %cl, %al
cmpb $0x1, %al
jne 0x22a2d
testl %ebp, %ebp
jg 0x22946
jmp 0x22a2d
movl %ebp, %eax
testl %ebp, %ebp
jle 0x22a19
xorl %ecx, %ecx
movslq 0x80(%r14), %rdx
addq 0x68(%r14), %rdx
movb (%rcx,%rdx), %dl
movb %dl, (%r15,%rcx)
incq %rcx
cmpq %rcx, %rax
jne 0x229ff
addl %ebp, 0x80(%r14)
subl %ebp, 0x84(%r14)
addq %rax, 0x50(%r14)
xorl %ebp, %ebp
subl %ebp, %ebx
movslq %ebx, %rax
addq %rax, 0x28(%r14)
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O1/statgen[P]statgen/lib/samtools-0.1.7a-hybrid/razf.c
// Function: razf_skip
int razf_skip(RAZF* rz, int size){
	int ori_size;
	ori_size = size;
	while(size > 0){
		if(rz->buf_len){
			if(size < rz->buf_len){
				rz->buf_off += size;
				rz->buf_len -= size;
				rz->block_off += size;
				size = 0;
				break;
			} else {
				size -= rz->buf_len;
				rz->buf_off = 0;
				rz->buf_len = 0;
				rz->block_off += rz->buf_len;
				if(rz->buf_flush){
					rz->block_pos = rz->next_block_pos;
					rz->block_off = 0;
					rz->buf_flush = 0;
				}
			}
		} else if(rz->buf_flush){
			rz->block_pos = rz->next_block_pos;
			rz->block_off = 0;
			rz->buf_flush = 0;
		}
		if(rz->buf_flush) continue;
		rz->buf_len = _razf_read(rz, rz->outbuf, RZ_BUFFER_SIZE);
		if(rz->z_eof || rz->z_err) break;
	}
	rz->out += ori_size - size;
	return ori_size - size;
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
movl %esi, %ebp
movq %rdi, %rbx
movl %esi, %r14d
testl %esi, %esi
jle 0x22c50
movl %ebp, %r14d
movl 0x84(%rbx), %ecx
testl %ecx, %ecx
je 0x22c2b
movl %r14d, %eax
subl %ecx, %eax
jl 0x22c36
movq $0x0, 0x80(%rbx)
cmpl $0x0, 0x40(%rbx)
movl %eax, %r14d
je 0x22bfa
movq 0x58(%rbx), %rcx
movq %rcx, 0x48(%rbx)
movq $0x0, 0x50(%rbx)
movl $0x0, 0x40(%rbx)
movl %eax, %r14d
cmpl $0x0, 0x40(%rbx)
jne 0x22c24
movq 0x68(%rbx), %rsi
movq %rbx, %rdi
callq 0x22a41
movl %eax, 0x84(%rbx)
cmpl $0x0, 0x8c(%rbx)
jne 0x22c50
cmpl $0x0, 0x88(%rbx)
jne 0x22c50
testl %r14d, %r14d
jg 0x22bbb
jmp 0x22c50
cmpl $0x0, 0x40(%rbx)
movl %r14d, %eax
jne 0x22be0
jmp 0x22bfa
addl %r14d, 0x80(%rbx)
subl %r14d, %ecx
movl %ecx, 0x84(%rbx)
movl %r14d, %eax
addq %rax, 0x50(%rbx)
xorl %r14d, %r14d
subl %r14d, %ebp
movslq %ebp, %rax
addq %rax, 0x28(%rbx)
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O1/statgen[P]statgen/lib/samtools-0.1.7a-hybrid/razf.c
// Function: razf_jump
int64_t razf_jump(RAZF *rz, int64_t block_start, int block_offset){
	int64_t pos;
	rz->z_eof = 0;
	if(rz->file_type == FILE_TYPE_PLAIN){
		rz->buf_off = rz->buf_len = 0;
		pos = block_start + block_offset;
#ifdef _USE_KNETFILE
		knet_seek(rz->x.fpr, pos, SEEK_SET);
        pos = knet_tell(rz->x.fpr);
#else
		pos = lseek(rz->filedes, pos, SEEK_SET);
#endif
		rz->out = rz->in = pos;
		return pos;
	}
	if(block_start == rz->block_pos && block_offset >= rz->block_off) {
		block_offset -= rz->block_off;
		goto SKIP; // Needn't reset inflate
	}
	if(block_start  == 0) block_start = rz->header_size; // Automaticly revist wrong block_start
	_razf_reset_read(rz, block_start, 0);
	SKIP:
	if(block_offset) razf_skip(rz, block_offset);
	return rz->block_off;
}

// Assembly:
pushq %rbp
pushq %rbx
pushq %rax
movl %edx, %ebp
movq %rdi, %rbx
movl $0x0, 0x8c(%rdi)
cmpl $0x2, 0x4(%rdi)
jne 0x22ca8
movq $0x0, 0x80(%rbx)
movslq %ebp, %rax
addq %rsi, %rax
movq 0x8(%rbx), %rdi
movq %rax, %rsi
xorl %edx, %edx
callq 0x1c579
movq 0x8(%rbx), %rax
movq 0x8(%rax), %rax
movq %rax, 0x20(%rbx)
movq %rax, 0x28(%rbx)
jmp 0x22ce3
cmpq %rsi, 0x48(%rbx)
jne 0x22cba
movslq %ebp, %rcx
movq 0x50(%rbx), %rax
cmpq %rcx, %rax
jle 0x22ccf
testq %rsi, %rsi
jne 0x22cc3
movslq 0x70(%rbx), %rsi
movq %rbx, %rdi
xorl %edx, %edx
callq 0x22cea
jmp 0x22cd1
subl %eax, %ebp
testl %ebp, %ebp
je 0x22cdf
movq %rbx, %rdi
movl %ebp, %esi
callq 0x22ba4
movq 0x50(%rbx), %rax
addq $0x8, %rsp
popq %rbx
popq %rbp
retq