LLM4Binary/decompile-bench-makefile huggingface dataset:
// File: /workspace/github_c_makefile_star2_O2/genometools[P]genometools/src/external/samtools-0.1.18/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 0x2a1f8d
cmpq %rsi, 0x8(%rbx)
je 0x2a1fe6
movl (%rbx), %eax
cmpl $0x3, %eax
je 0x2a1fb6
cmpl $0x2, %eax
je 0x2a1fc6
cmpl $0x1, %eax
jne 0x2a1fea
movl 0x4(%rbx), %edi
callq 0x32260
cmpq $-0x1, %rax
je 0x2a2044
movq %rax, 0x8(%rbx)
jmp 0x2a1fe6
cmpl $0x1, %edx
je 0x2a1fcb
cmpl $0x2, %edx
je 0x2a201d
testl %edx, %edx
jne 0x2a1fe2
jmp 0x2a1fde
cmpl $0x1, %edx
jne 0x2a1fd1
addq %rsi, 0x8(%rbx)
jmp 0x2a1fe2
testl %edx, %edx
je 0x2a1fde
cmpl $0x2, %edx
jne 0x2a1fe2
addq 0x68(%rbx), %rsi
movq %rsi, 0x8(%rbx)
andl $0x0, 0x40(%rbx)
xorl %eax, %eax
popq %rbx
retq
callq 0x31620
movl $0x16, (%rax)
movq 0x168fb4(%rip), %rax    # 0x40afb0
movq (%rax), %rbx
pushq $0x16
popq %rdi
callq 0x309d0
leaq 0xb9f36(%rip), %rsi     # 0x35bf44
movq %rbx, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0x32960
jmp 0x2a2044
movq 0x168f8c(%rip), %rax    # 0x40afb0
movq (%rax), %rcx
leaq 0xb9ed0(%rip), %rdi     # 0x35befe
pushq $0x45
popq %rsi
pushq $0x1
popq %rdx
callq 0x32760
callq 0x31620
movl $0x1d, (%rax)
pushq $-0x1
popq %rax
jmp 0x2a1fe8
// File: /workspace/github_c_makefile_star2_O2/genometools[P]genometools/src/external/samtools-0.1.18/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
movq $0x5, (%rsp)
andq $0x0, 0x8(%rsp)
xorl %eax, %eax
cmpq $0x10, %rax
je 0x2a2072
andq $0x0, 0x10(%rsp,%rax,8)
incq %rax
jmp 0x2a2061
pushq $0x40
popq %rcx
movl %edi, %eax
cltd
idivl %ecx
movslq %eax, %rdx
shll $0x6, %eax
movl %edi, %ecx
subl %eax, %ecx
pushq $0x1
popq %rax
shlq %cl, %rax
orq %rax, 0x10(%rsp,%rdx,8)
xorl %eax, %eax
testl %esi, %esi
leaq 0x10(%rsp), %rsi
movl $0x0, %edx
cmoveq %rsi, %rdx
cmoveq %rax, %rsi
incl %edi
movq %rsp, %r8
xorl %ecx, %ecx
callq 0x2ed10
movl %eax, %ebx
cmpl $-0x1, %eax
je 0x2a20c3
movl %ebx, %eax
addq $0x90, %rsp
popq %rbx
retq
leaq 0x81788(%rip), %rdi     # 0x323852
callq 0x32870
jmp 0x2a20b8
nopl (%rax)
// File: /workspace/github_c_makefile_star2_O2/genometools[P]genometools/src/external/samtools-0.1.18/bam_sort.c
// Function: heap_lt
static inline int heap_lt(const heap1_t a, const heap1_t b)
{
	if (g_is_by_qname) {
		int t;
		if (a.b == 0 || b.b == 0) return a.b == 0? 1 : 0;
		t = strnum_cmp(bam1_qname(a.b), bam1_qname(b.b));
		return (t > 0 || (t == 0 && __pos_cmp(a, b)));
	} else return __pos_cmp(a, b);
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
leaq 0x40(%rsp), %r14
leaq 0x20(%rsp), %rbx
cmpl $0x0, 0x172f31(%rip)    # 0x415384
je 0x2a248e
movq 0x18(%rbx), %rax
testq %rax, %rax
sete %cl
movq 0x18(%r14), %rdx
testq %rdx, %rdx
sete %sil
orb %cl, %sil
jne 0x2a24ba
movq 0x30(%rax), %rdi
movq 0x30(%rdx), %rsi
callq 0x2a494b
movb $0x1, %cl
testl %eax, %eax
jg 0x2a24ba
jne 0x2a24b8
movq 0x8(%rbx), %rax
movq 0x8(%r14), %rdx
jmp 0x2a2498
movq 0x8(%rbx), %rax
movq 0x8(%r14), %rdx
movb $0x1, %cl
cmpq %rdx, %rax
ja 0x2a24ba
jne 0x2a24b8
movl (%r14), %eax
cmpl %eax, (%rbx)
jg 0x2a24ba
sete %al
movq 0x10(%r14), %rcx
cmpq %rcx, 0x10(%rbx)
seta %cl
andb %al, %cl
jmp 0x2a24ba
xorl %ecx, %ecx
movzbl %cl, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O2/genometools[P]genometools/src/external/samtools-0.1.18/bam_sort.c
// Function: sort_blocks
static void sort_blocks(int n, int k, bam1_p *buf, const char *prefix, const bam_header_t *h, int is_stdout)
{
	char *name, mode[3];
	int i;
	bamFile fp;
	ks_mergesort(sort, k, buf, 0);
	name = (char*)calloc(strlen(prefix) + 20, 1);
	if (n >= 0) {
		sprintf(name, "%s.%.4d.bam", prefix, n);
		strcpy(mode, "w1");
	} else {
		sprintf(name, "%s.bam", prefix);
		strcpy(mode, "w");
	}
	fp = is_stdout? bam_dopen(fileno(stdout), mode) : bam_open(name, mode);
	if (fp == 0) {
		fprintf(stderr, "[sort_blocks] fail to create file %s.\n", name);
		free(name);
		// FIXME: possible memory leak
		return;
	}
	free(name);
	bam_header_write(fp, h);
	for (i = 0; i < k; ++i)
		bam_write1_core(fp, &buf[i]->core, buf[i]->data_len, buf[i]->data);
	bam_close(fp);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movl %r9d, %ebp
movq %r8, 0x10(%rsp)
movq %rcx, %r13
movq %rdx, %rbx
movl %esi, %r14d
movl %edi, %r15d
movslq %esi, %rdi
movq %rdx, %rsi
xorl %edx, %edx
callq 0x2a3b4c
movq %r13, %rdi
callq 0x2fe60
leaq 0x14(%rax), %rdi
pushq $0x1
popq %rsi
callq 0x31f40
movq %rax, %r12
testl %r15d, %r15d
js 0x2a47bd
leaq 0xb7d8c(%rip), %rsi     # 0x35c52b
movq %r12, %rdi
movq %r13, %rdx
movl %r15d, %ecx
xorl %eax, %eax
callq 0x303f0
movw $0x3177, 0xc(%rsp)      # imm = 0x3177
movb $0x0, 0xe(%rsp)
jmp 0x2a47d8
leaq 0xb7d60(%rip), %rsi     # 0x35c524
movq %r12, %rdi
movq %r13, %rdx
xorl %eax, %eax
callq 0x303f0
movw $0x77, 0xc(%rsp)
testl %ebp, %ebp
je 0x2a47f9
movq 0x166805(%rip), %rax    # 0x40afe8
movq (%rax), %rdi
callq 0x2e230
leaq 0xc(%rsp), %rsi
movl %eax, %edi
callq 0x292c64
jmp 0x2a4806
leaq 0xc(%rsp), %rsi
movq %r12, %rdi
callq 0x292937
movq %rax, %r13
testq %rax, %rax
je 0x2a4861
movq %r12, %rdi
callq 0x33058
movq %r13, %rdi
movq 0x10(%rsp), %rsi
callq 0x294e9a
xorl %r15d, %r15d
testl %r14d, %r14d
cmovlel %r15d, %r14d
cmpq %r15, %r14
je 0x2a484a
movq (%rbx,%r15,8), %rsi
movl 0x24(%rsi), %edx
movq 0x30(%rsi), %rcx
movq %r13, %rdi
callq 0x29532d
incq %r15
jmp 0x2a482d
movq %r13, %rdi
callq 0x292a35
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x166748(%rip), %rax    # 0x40afb0
movq (%rax), %rdi
leaq 0xb7d0a(%rip), %rsi     # 0x35c57c
movq %r12, %rdx
xorl %eax, %eax
callq 0x32960
movq %r12, %rdi
callq 0x33058
jmp 0x2a4852
// File: /workspace/github_c_makefile_star2_O2/genometools[P]genometools/src/external/samtools-0.1.18/bam_sort.c
// Function: bam1_lt
static inline int bam1_lt(const bam1_p a, const bam1_p b)
{
	if (g_is_by_qname) {
		int t = strnum_cmp(bam1_qname(a), bam1_qname(b));
		return (t < 0 || (t == 0 && (((uint64_t)a->core.tid<<32|(a->core.pos+1)) < ((uint64_t)b->core.tid<<32|(b->core.pos+1)))));
	} else return (((uint64_t)a->core.tid<<32|(a->core.pos+1)) < ((uint64_t)b->core.tid<<32|(b->core.pos+1)));
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rsi, %rbx
movq %rdi, %r14
cmpl $0x0, 0x1715dd(%rip)    # 0x415384
je 0x2a3dc2
movq 0x30(%r14), %rdi
movq 0x30(%rbx), %rsi
callq 0x2a494b
testl %eax, %eax
js 0x2a3ded
movl %eax, %ecx
xorl %eax, %eax
testl %ecx, %ecx
jne 0x2a3df0
movl (%r14), %eax
shlq $0x20, %rax
movslq 0x4(%r14), %rcx
incq %rcx
orq %rax, %rcx
movl (%rbx), %eax
shlq $0x20, %rax
movslq 0x4(%rbx), %rdx
incq %rdx
orq %rax, %rdx
xorl %eax, %eax
cmpq %rdx, %rcx
setb %al
jmp 0x2a3df0
pushq $0x1
popq %rax
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O2/genometools[P]genometools/src/external/samtools-0.1.18/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, %r12d
xorl %ebp, %ebp
movl $0x1dcd6500, %r14d      # imm = 0x1DCD6500
leaq 0xb7c89(%rip), %r13     # 0x35c537
xorl %r15d, %r15d
movl %r12d, %edi
movq %rbx, %rsi
movq %r13, %rdx
callq 0x2f020
testl %eax, %eax
js 0x2a48f1
cmpl $0x6d, %eax
je 0x2a48d8
cmpl $0x6e, %eax
je 0x2a48ec
cmpl $0x6f, %eax
jne 0x2a48b1
pushq $0x1
popq %r15
jmp 0x2a48b1
movq 0x166659(%rip), %rax    # 0x40af38
movq (%rax), %rdi
callq 0x30680
movq %rax, %r14
jmp 0x2a48b1
pushq $0x1
popq %rbp
jmp 0x2a48b1
movq 0x1665f0(%rip), %rax    # 0x40aee8
movslq (%rax), %rax
leal 0x2(%rax), %ecx
cmpl %r12d, %ecx
jg 0x2a492a
movq (%rbx,%rax,8), %rsi
movq 0x8(%rbx,%rax,8), %rdx
movl %ebp, %edi
movq %r14, %rcx
movl %r15d, %r8d
callq 0x2a444c
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x16667f(%rip), %rax    # 0x40afb0
movq (%rax), %rcx
leaq 0xb7c01(%rip), %rdi     # 0x35c53c
pushq $0x3f
popq %rsi
pushq $0x1
popq %rdx
callq 0x32760
pushq $0x1
popq %rax
jmp 0x2a491b
// File: /workspace/github_c_makefile_star2_O2/genometools[P]genometools/src/external/samtools-0.1.18/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 %rsi, %r13
movq %rdi, %r15
leaq 0x8(%rsp), %rax
movq %rdi, (%rax)
movq %rsp, %rax
movq %rsi, (%rax)
pushq $0xa
popq %rbp
movq %rsi, 0x10(%rsp)
movq %rdi, %r14
movsbq (%r14), %r12
movb (%r13), %bl
testq %r12, %r12
je 0x2a49e9
testb %bl, %bl
je 0x2a49e9
callq 0x301c0
movq (%rax), %rax
testb $0x8, 0x1(%rax,%r12,2)
je 0x2a49a4
movsbq %bl, %rcx
testb $0x8, 0x1(%rax,%rcx,2)
jne 0x2a49ba
cmpb %bl, %r12b
jne 0x2a49e9
incq %r14
movq %r14, 0x8(%rsp)
incq %r13
movq %r13, (%rsp)
jmp 0x2a4978
movq %r14, %rdi
leaq 0x8(%rsp), %rsi
movl %ebp, %edx
callq 0x30c20
movq %rax, %r14
movq %r13, %rdi
movq %rsp, %rsi
movl %ebp, %edx
callq 0x30c20
cmpq %rax, %r14
jne 0x2a49fe
movq 0x8(%rsp), %r14
movq (%rsp), %r13
jmp 0x2a4978
cmpb %bl, %r12b
jne 0x2a49fb
subq %r15, %r14
subq 0x10(%rsp), %r13
cmpq %r13, %r14
jmp 0x2a49fe
cmpb %bl, %r12b
setl %al
setg %cl
movzbl %cl, %ecx
testb %al, %al
pushq $-0x1
popq %rax
cmovel %ecx, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop
// File: /workspace/github_c_makefile_star2_O2/genometools[P]genometools/src/external/samtools-0.1.18/bam_reheader.c
// Function: bam_reheader
int bam_reheader(BGZF *in, const bam_header_t *h, int fd)
{
	BGZF *fp;
	bam_header_t *old;
	int len;
	uint8_t *buf;
	if (in->open_mode != 'r') return -1;
	buf = malloc(BUF_SIZE);
	old = bam_header_read(in);
	fp = bgzf_fdopen(fd, "w");
	bam_header_write(fp, h);
	if (in->block_offset < in->block_length) {
		bgzf_write(fp, in->uncompressed_block + in->block_offset, in->block_length - in->block_offset);
		bgzf_flush(fp);
	}
#ifdef _USE_KNETFILE
	while ((len = knet_read(in->x.fpr, buf, BUF_SIZE)) > 0)
		fwrite(buf, 1, len, fp->x.fpw);
#else
	while (!feof(in->file) && (len = fread(buf, 1, BUF_SIZE, in->file)) > 0)
		fwrite(buf, 1, len, fp->file);
#endif
	free(buf);
	fp->block_offset = in->block_offset = 0;
	bgzf_close(fp);
	return 0;
}

// Assembly:
cmpb $0x72, 0x4(%rdi)
jne 0x2a5d39
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movl %edx, %ebp
movq %rsi, %r12
movq %rdi, %rbx
movl $0x10000, %edi          # imm = 0x10000
callq 0x33048
movq %rax, %r14
movq %rbx, %rdi
callq 0x294cb4
leaq 0x74151(%rip), %rsi     # 0x319deb
movl %ebp, %edi
callq 0x292c64
movq %rax, %r15
movq %rax, %rdi
movq %r12, %rsi
callq 0x294e9a
movslq 0x3c(%rbx), %rax
movl 0x38(%rbx), %edx
cmpl %eax, %edx
jle 0x2a5cd3
movq %rax, %rsi
addq 0x20(%rbx), %rsi
subl %eax, %edx
movq %r15, %rdi
callq 0x293734
movq %r15, %rdi
callq 0x2934e1
pushq $0x1
popq %r12
movq 0x10(%rbx), %rdi
callq 0x32000
testl %eax, %eax
jne 0x2a5d15
movq 0x10(%rbx), %rcx
movl $0x10000, %edx          # imm = 0x10000
movq %r14, %rdi
movq %r12, %rsi
callq 0x31380
testl %eax, %eax
jle 0x2a5d15
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
movq 0x10(%r15), %rcx
movq %r14, %rdi
movq %r12, %rsi
movq %rax, %rdx
callq 0x32760
jmp 0x2a5cd7
movq %r14, %rdi
callq 0x33058
andl $0x0, 0x3c(%rbx)
andl $0x0, 0x3c(%r15)
movq %r15, %rdi
callq 0x292a35
xorl %eax, %eax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
pushq $-0x1
popq %rax
retq
// File: /workspace/github_c_makefile_star2_O2/genometools[P]genometools/src/external/samtools-0.1.18/bam_reheader.c
// Function: main_reheader
int main_reheader(int argc, char *argv[])
{
	bam_header_t *h;
	BGZF *in;
	if (argc != 3) {
		fprintf(stderr, "Usage: samtools reheader <in.header.sam> <in.bam>\n");
		return 1;
	}
	{ // read the header
		tamFile fph = sam_open(argv[1]);
		if (fph == 0) {
			fprintf(stderr, "[%s] fail to read the header from %s.\n", __func__, argv[1]);
			return 1;
		}
		h = sam_header_read(fph);
		sam_close(fph);
	}
	in = strcmp(argv[2], "-")? bam_open(argv[2], "r") : bam_dopen(fileno(stdin), "r");
	if (in == 0) {
		fprintf(stderr, "[%s] fail to open file %s.\n", __func__, argv[2]);
		return 1;
	}
	bam_reheader(in, h, fileno(stdout));
	bgzf_close(in);
	return 0;
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
cmpl $0x3, %edi
jne 0x2a5de8
movq %rsi, %rbx
movq 0x8(%rsi), %rdi
callq 0x297c3a
testq %rax, %rax
je 0x2a5e06
movq %rax, %r15
movq %rax, %rdi
callq 0x296ae6
movq %rax, %r14
movq %r15, %rdi
callq 0x297cbb
movq 0x10(%rbx), %rdi
cmpb $0x2d, (%rdi)
jne 0x2a5d85
cmpb $0x0, 0x1(%rdi)
je 0x2a5dc9
leaq 0x3c7bf(%rip), %rsi     # 0x2e254b
callq 0x292937
movq %rax, %r15
testq %rax, %rax
je 0x2a5e1d
movq 0x165244(%rip), %rax    # 0x40afe8
movq (%rax), %rdi
callq 0x2e230
movq %r15, %rdi
movq %r14, %rsi
movl %eax, %edx
callq 0x2a5c64
movq %r15, %rdi
callq 0x292a35
xorl %eax, %eax
popq %rbx
popq %r14
popq %r15
retq
movq 0x165140(%rip), %rax    # 0x40af10
movq (%rax), %rdi
callq 0x2e230
leaq 0x3c76c(%rip), %rsi     # 0x2e254b
movl %eax, %edi
callq 0x292c64
jmp 0x2a5d91
movq 0x1651c1(%rip), %rax    # 0x40afb0
movq (%rax), %rcx
leaq 0xb6a27(%rip), %rdi     # 0x35c820
pushq $0x32
popq %rsi
pushq $0x1
popq %rdx
callq 0x32760
jmp 0x2a5e40
movq 0x1651a3(%rip), %rax    # 0x40afb0
movq (%rax), %rdi
movq 0x8(%rbx), %rcx
leaq 0xb6a38(%rip), %rsi     # 0x35c853
jmp 0x2a5e32
movq 0x16518c(%rip), %rax    # 0x40afb0
movq (%rax), %rdi
movq 0x10(%rbx), %rcx
leaq 0xb6a56(%rip), %rsi     # 0x35c888
leaq 0xb6a41(%rip), %rdx     # 0x35c87a
xorl %eax, %eax
callq 0x32960
pushq $0x1
popq %rax
jmp 0x2a5dc3
// File: /workspace/github_c_makefile_star2_O2/genometools[P]genometools/src/external/samtools-0.1.18/bam_cat.c
// Function: main_cat
int main_cat(int argc, char *argv[])
{
    bam_header_t *h = 0;
	char *outfn = 0;
	int c, ret;
	while ((c = getopt(argc, argv, "h:o:")) >= 0) {
		switch (c) {
			case 'h': {
        		tamFile fph = sam_open(optarg);
		        if (fph == 0) {
    		        fprintf(stderr, "[%s] ERROR: fail to read the header from '%s'.\n", __func__, argv[1]);
        		    return 1;
	        	}
	    	    h = sam_header_read(fph);
    	    	sam_close(fph);
				break;
			}
			case 'o': outfn = strdup(optarg); break;
		}
	}
	if (argc - optind < 2) {
        fprintf(stderr, "Usage: samtools cat [-h header.sam] [-o out.bam] <in1.bam> <in2.bam> [...]\n");
        return 1;
    }
    ret = bam_cat(argc - optind, argv + optind, h, outfn? outfn : "-");
	free(outfn);
	return ret;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rsi, %r14
movl %edi, %ebp
xorl %ebx, %ebx
leaq 0xb59a0(%rip), %r15     # 0x35c986
movq 0x163f4b(%rip), %r13    # 0x40af38
xorl %r12d, %r12d
movl %ebp, %edi
movq %r14, %rsi
movq %r15, %rdx
callq 0x2f020
testl %eax, %eax
js 0x2a7054
cmpl $0x6f, %eax
je 0x2a7046
cmpl $0x68, %eax
jne 0x2a6ff0
movq %r13, %r12
movq (%r13), %rdi
callq 0x297c3a
testq %rax, %rax
je 0x2a70bd
movq %rax, %r13
movq %rax, %rdi
callq 0x296ae6
movq %rbx, (%rsp)
movq %rax, %rbx
movq %r13, %rdi
callq 0x297cbb
movq %r12, %r13
movq %rbx, %r12
movq (%rsp), %rbx
jmp 0x2a6ff0
movq (%r13), %rdi
callq 0x316c0
movq %rax, %rbx
jmp 0x2a6ff0
movq 0x163e8d(%rip), %rax    # 0x40aee8
movslq (%rax), %rax
subl %eax, %ebp
cmpl $0x1, %ebp
jle 0x2a709c
leaq (%r14,%rax,8), %rsi
testq %rbx, %rbx
leaq 0xb10d7(%rip), %rcx     # 0x35814a
cmovneq %rbx, %rcx
movl %ebp, %edi
movq %r12, %rdx
callq 0x2a6c5c
movl %eax, %ebp
movq %rbx, %rdi
callq 0x33058
movl %ebp, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x163f0d(%rip), %rax    # 0x40afb0
movq (%rax), %rcx
leaq 0xb5917(%rip), %rdi     # 0x35c9c4
pushq $0x4b
popq %rsi
pushq $0x1
popq %rdx
callq 0x32760
pushq $0x1
popq %rax
jmp 0x2a708d
movq 0x163eec(%rip), %rax    # 0x40afb0
movq (%rax), %rdi
movq 0x8(%r14), %rcx
leaq 0xb58b9(%rip), %rsi     # 0x35c98b
leaq 0xb58e2(%rip), %rdx     # 0x35c9bb
xorl %eax, %eax
callq 0x32960
jmp 0x2a70b8
nop
// File: /workspace/github_c_makefile_star2_O2/genometools[P]genometools/src/external/tre/lib/xmalloc.c
// Function: xmalloc_init
static void
xmalloc_init(void)
{
  if (xmalloc_table == NULL)
    {
      xmalloc_table = hash_table_new();
      xmalloc_peak = 0;
      xmalloc_peak_blocks = 0;
      xmalloc_current = 0;
      xmalloc_current_blocks = 0;
      xmalloc_fail_after = -1;
    }
  assert(xmalloc_table != NULL);
  assert(xmalloc_table->table != NULL);
}

// Assembly:
pushq %rbx
movq 0x1562d0(%rip), %rbx    # 0x415898
testq %rbx, %rbx
jne 0x2bf631
pushq $0x8
popq %rdi
callq 0x33048
testq %rax, %rax
je 0x2bf5fa
movq %rax, %rbx
pushq $0x8
popq %rsi
movl $0x100, %edi            # imm = 0x100
callq 0x31f40
movq %rax, (%rbx)
testq %rax, %rax
jne 0x2bf5fc
movq %rbx, %rdi
callq 0x33058
xorl %ebx, %ebx
andl $0x0, 0x15629d(%rip)    # 0x4158a0
movq %rbx, 0x15628e(%rip)    # 0x415898
andl $0x0, 0x156293(%rip)    # 0x4158a4
leaq 0x156290(%rip), %rax    # 0x4158a8
andl $0x0, (%rax)
leaq 0x15628a(%rip), %rax    # 0x4158ac
andl $0x0, (%rax)
orl $-0x1, 0x156264(%rip)   # 0x415890
testq %rbx, %rbx
je 0x2bf658
cmpq $0x0, (%rbx)
je 0x2bf639
popq %rbx
retq
leaq 0xa089c(%rip), %rdi     # 0x35fedc
leaq 0xa06eb(%rip), %rsi     # 0x35fd32
leaq 0xa0876(%rip), %rcx     # 0x35fec4
movl $0xb8, %edx
callq 0x2edc0
leaq 0xa084f(%rip), %rdi     # 0x35feae
leaq 0xa06cc(%rip), %rsi     # 0x35fd32
leaq 0xa0857(%rip), %rcx     # 0x35fec4
movl $0xb7, %edx
callq 0x2edc0
// File: /workspace/github_c_makefile_star2_O2/genometools[P]genometools/src/external/tre/lib/xmalloc.c
// Function: xmalloc_dump_leaks
int
xmalloc_dump_leaks(void)
{
  int i;
  int num_leaks = 0;
  int leaked_bytes = 0;
  hashTableItem *item;

  xmalloc_init();

  for (i = 0; i < TABLE_SIZE; i++)
    {
      item = xmalloc_table->table[i];
      while (item != NULL)
	{
	  printf("%s:%d: %s: %d bytes at %p not freed\n",
		 item->file, item->line, item->func, item->bytes, item->ptr);
	  num_leaks++;
	  leaked_bytes += item->bytes;
	  item = item->next;
	}
    }
  if (num_leaks == 0)
    printf("No memory leaks.\n");
  else
    printf("%d unfreed memory chuncks, total %d unfreed bytes.\n",
	   num_leaks, leaked_bytes);
  printf("Peak memory consumption %d bytes (%.1f kB, %.1f MB) in %d blocks ",
	 xmalloc_peak, (double)xmalloc_peak / 1024,
	 (double)xmalloc_peak / (1024*1024), xmalloc_peak_blocks);
  printf("(average ");
  if (xmalloc_peak_blocks)
    printf("%d", ((xmalloc_peak + xmalloc_peak_blocks / 2)
		  / xmalloc_peak_blocks));
  else
    printf("N/A");
  printf(" bytes per block).\n");

  return num_leaks;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
callq 0x2bf5c0
leaq 0xa05fe(%rip), %r14     # 0x35fc89
xorl %r15d, %r15d
xorl %ebx, %ebx
xorl %ebp, %ebp
cmpq $0x100, %r15            # imm = 0x100
je 0x2bf6ea
movq 0x1561f6(%rip), %rax    # 0x415898
leaq (,%r15,8), %r12
addq (%rax), %r12
movq (%r12), %r12
testq %r12, %r12
je 0x2bf6e5
movq 0x10(%r12), %rsi
movl 0x18(%r12), %edx
movq 0x20(%r12), %rcx
movl 0x8(%r12), %r8d
movq (%r12), %r9
movq %r14, %rdi
xorl %eax, %eax
callq 0x2e300
incl %ebx
addl 0x8(%r12), %ebp
addq $0x28, %r12
jmp 0x2bf6ad
incq %r15
jmp 0x2bf692
testl %ebx, %ebx
je 0x2bf702
leaq 0xa05b9(%rip), %rdi     # 0x35fcae
movl %ebx, %esi
movl %ebp, %edx
xorl %eax, %eax
callq 0x2e300
jmp 0x2bf70e
leaq 0xa0862(%rip), %rdi     # 0x35ff6b
callq 0x2ebc0
movl 0x15618c(%rip), %esi    # 0x4158a0
cvtsi2sd %esi, %xmm1
movsd 0x98688(%rip), %xmm0    # 0x357da8
mulsd %xmm1, %xmm0
mulsd 0x2cfb4(%rip), %xmm1    # 0x2ec6e0
movl 0x156172(%rip), %edx    # 0x4158a4
leaq 0xa05a9(%rip), %rdi     # 0x35fce2
movb $0x2, %al
callq 0x2e300
leaq 0xa05dd(%rip), %rdi     # 0x35fd24
xorl %eax, %eax
callq 0x2e300
movl 0x156150(%rip), %ecx    # 0x4158a4
testl %ecx, %ecx
je 0x2bf778
movl %ecx, %eax
shrl %eax
addl 0x15613e(%rip), %eax    # 0x4158a0
xorl %edx, %edx
divl %ecx
leaq 0x9bbd2(%rip), %rdi     # 0x35b33f
movl %eax, %esi
xorl %eax, %eax
callq 0x2e300
jmp 0x2bf786
leaq 0xa05af(%rip), %rdi     # 0x35fd2e
xorl %eax, %eax
callq 0x2e300
leaq 0xa07ef(%rip), %rdi     # 0x35ff7c
callq 0x2ebc0
movl %ebx, %eax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/genometools[P]genometools/src/external/tre/lib/xmalloc.c
// Function: xmalloc_impl
void *
xmalloc_impl(size_t size, const char *file, int line, const char *func)
{
  void *ptr;

  xmalloc_init();
  assert(size > 0);

  if (xmalloc_fail_after == 0)
    {
      xmalloc_fail_after = -2;
#if 0
      printf("xmalloc: forced failure %s:%d: %s\n", file, line, func);
#endif
      return NULL;
    }
  else if (xmalloc_fail_after == -2)
    {
      printf("xmalloc: called after failure from %s:%d: %s\n",
	     file, line, func);
      assert(0);
    }
  else if (xmalloc_fail_after > 0)
    xmalloc_fail_after--;

  ptr = malloc(size);
  if (ptr != NULL)
    hash_table_add(xmalloc_table, ptr, (int)size, file, line, func);
  return ptr;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movq %rcx, %rbx
movl %edx, %ebp
movq %rsi, %r14
movq %rdi, %r15
callq 0x2bf5c0
testq %r15, %r15
je 0x2bf81b
movl 0x1560d0(%rip), %eax    # 0x415890
testl %eax, %eax
je 0x2bf802
cmpl $-0x2, %eax
je 0x2bf83a
testl %eax, %eax
jle 0x2bf7d5
decl %eax
movl %eax, 0x1560bb(%rip)    # 0x415890
movq %r15, %rdi
callq 0x33048
testq %rax, %rax
je 0x2bf80c
movq %rax, %r12
movq 0x1560ac(%rip), %rdi    # 0x415898
movq %rax, %rsi
movl %r15d, %edx
movq %r14, %rcx
movl %ebp, %r8d
movq %rbx, %r9
callq 0x2bf86f
jmp 0x2bf80f
movl $0xfffffffe, 0x156084(%rip) # imm = 0xFFFFFFFE
xorl %r12d, %r12d
movq %r12, %rax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
leaq 0x2e3c0(%rip), %rdi     # 0x2edbe2
leaq 0xa0509(%rip), %rsi     # 0x35fd32
leaq 0xa0521(%rip), %rcx     # 0x35fd51
movl $0xf7, %edx
callq 0x2edc0
leaq 0xa054c(%rip), %rdi     # 0x35fd8d
movq %r14, %rsi
movl %ebp, %edx
movq %rbx, %rcx
xorl %eax, %eax
callq 0x2e300
leaq 0x9baf9(%rip), %rdi     # 0x35b350
leaq 0xa04d4(%rip), %rsi     # 0x35fd32
leaq 0xa04ec(%rip), %rcx     # 0x35fd51
movl $0x105, %edx            # imm = 0x105
callq 0x2edc0
// File: /workspace/github_c_makefile_star2_O2/genometools[P]genometools/src/external/tre/lib/xmalloc.c
// Function: hash_table_add
static void
hash_table_add(hashTable *tbl, void *ptr, int bytes,
	       const char *file, int line, const char *func)
{
  int i;
  hashTableItem *item, *new;

  i = hash_void_ptr(ptr);

  item = tbl->table[i];
  if (item != NULL)
    while (item->next != NULL)
      item = item->next;

  new = malloc(sizeof(*new));
  assert(new != NULL);
  new->ptr = ptr;
  new->bytes = bytes;
  new->file = file;
  new->line = line;
  new->func = func;
  new->next = NULL;
  if (item != NULL)
    item->next = new;
  else
    tbl->table[i] = new;

  xmalloc_current += bytes;
  if (xmalloc_current > xmalloc_peak)
    xmalloc_peak = xmalloc_current;
  xmalloc_current_blocks++;
  if (xmalloc_current_blocks > xmalloc_peak_blocks)
    xmalloc_peak_blocks = xmalloc_current_blocks;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %r9, 0x10(%rsp)
movl %r8d, 0xc(%rsp)
movq %rcx, %r15
movl %edx, %ebx
movq %rsi, %r12
movq %rdi, %r13
movq %rsi, %rdi
callq 0x2bfc03
movq (%r13), %r13
movl %eax, %r14d
movq (%r13,%r14,8), %rax
testq %rax, %rax
je 0x2bf8b9
movq %rax, %rbp
movq 0x28(%rax), %rax
testq %rax, %rax
jne 0x2bf8ab
jmp 0x2bf8bb
xorl %ebp, %ebp
pushq $0x30
popq %rdi
callq 0x33048
testq %rax, %rax
je 0x2bf944
leaq (,%r14,8), %rcx
addq %r13, %rcx
movq %r12, (%rax)
movl %ebx, 0x8(%rax)
movq %r15, 0x10(%rax)
movl 0xc(%rsp), %edx
movl %edx, 0x18(%rax)
movq 0x10(%rsp), %rdx
movq %rdx, 0x20(%rax)
andq $0x0, 0x28(%rax)
leaq 0x28(%rbp), %rdx
testq %rbp, %rbp
cmoveq %rcx, %rdx
movq %rax, (%rdx)
leaq 0x155fa1(%rip), %rax    # 0x4158a8
addl (%rax), %ebx
movl %ebx, (%rax)
cmpl 0x155f8f(%rip), %ebx    # 0x4158a0
jle 0x2bf919
movl %ebx, 0x155f87(%rip)    # 0x4158a0
leaq 0x155f8c(%rip), %rcx    # 0x4158ac
movl (%rcx), %edx
leal 0x1(%rdx), %eax
movl %eax, (%rcx)
cmpl 0x155f77(%rip), %edx    # 0x4158a4
jl 0x2bf935
movl %eax, 0x155f6f(%rip)    # 0x4158a4
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0xa05ae(%rip), %rdi     # 0x35fef9
leaq 0xa03e0(%rip), %rsi     # 0x35fd32
leaq 0xa05ac(%rip), %rcx     # 0x35ff05
pushq $0x6c
popq %rdx
callq 0x2edc0
// File: /workspace/github_c_makefile_star2_O2/genometools[P]genometools/src/external/tre/lib/xmalloc.c
// Function: xcalloc_impl
void *
xcalloc_impl(size_t nmemb, size_t size, const char *file, int line,
	     const char *func)
{
  void *ptr;

  xmalloc_init();
  assert(size > 0);

  if (xmalloc_fail_after == 0)
    {
      xmalloc_fail_after = -2;
#if 0
      printf("xcalloc: forced failure %s:%d: %s\n", file, line, func);
#endif
      return NULL;
    }
  else if (xmalloc_fail_after == -2)
    {
      printf("xcalloc: called after failure from %s:%d: %s\n",
	     file, line, func);
      assert(0);
    }
  else if (xmalloc_fail_after > 0)
    xmalloc_fail_after--;

  ptr = calloc(nmemb, size);
  if (ptr != NULL)
    hash_table_add(xmalloc_table, ptr, (int)(nmemb * size), file, line, func);
  return ptr;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %r8, %rbx
movl %ecx, %ebp
movq %rdx, %r14
movq %rsi, %r15
movq %rdi, %r12
callq 0x2bf5c0
testq %r15, %r15
je 0x2bf9f2
movl 0x155f06(%rip), %eax    # 0x415890
testl %eax, %eax
je 0x2bf9d3
cmpl $-0x2, %eax
je 0x2bfa11
testl %eax, %eax
jle 0x2bf99f
decl %eax
movl %eax, 0x155ef1(%rip)    # 0x415890
movq %r12, %rdi
movq %r15, %rsi
callq 0x31f40
testq %rax, %rax
je 0x2bf9dd
movq %rax, %r13
movq 0x155edf(%rip), %rdi    # 0x415898
imull %r12d, %r15d
movq %rax, %rsi
movl %r15d, %edx
movq %r14, %rcx
movl %ebp, %r8d
movq %rbx, %r9
callq 0x2bf86f
jmp 0x2bf9e0
movl $0xfffffffe, 0x155eb3(%rip) # imm = 0xFFFFFFFE
xorl %r13d, %r13d
movq %r13, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x2e1e9(%rip), %rdi     # 0x2edbe2
leaq 0xa0332(%rip), %rsi     # 0x35fd32
leaq 0xa03b4(%rip), %rcx     # 0x35fdbb
movl $0x117, %edx            # imm = 0x117
callq 0x2edc0
leaq 0xa03e7(%rip), %rdi     # 0x35fdff
movq %r14, %rsi
movl %ebp, %edx
movq %rbx, %rcx
xorl %eax, %eax
callq 0x2e300
leaq 0x9b922(%rip), %rdi     # 0x35b350
leaq 0xa02fd(%rip), %rsi     # 0x35fd32
leaq 0xa037f(%rip), %rcx     # 0x35fdbb
movl $0x125, %edx            # imm = 0x125
callq 0x2edc0
// File: /workspace/github_c_makefile_star2_O2/genometools[P]genometools/src/external/tre/lib/xmalloc.c
// Function: xfree_impl
void
xfree_impl(void *ptr, const char *file, int line, const char *func)
{
  /*LINTED*/(void)&file;
  /*LINTED*/(void)&line;
  /*LINTED*/(void)&func;
  xmalloc_init();

  if (ptr != NULL)
    hash_table_del(xmalloc_table, ptr);
  free(ptr);
}

// Assembly:
pushq %rbx
movq %rdi, %rbx
callq 0x2bf5c0
testq %rbx, %rbx
je 0x2bfa63
movq 0x155e3d(%rip), %rdi    # 0x415898
movq %rbx, %rsi
callq 0x2bfa6c
movq %rbx, %rdi
popq %rbx
jmp 0x33058
// File: /workspace/github_c_makefile_star2_O2/genometools[P]genometools/src/external/tre/lib/xmalloc.c
// Function: hash_table_del
static void
hash_table_del(hashTable *tbl, void *ptr)
{
  int i;
  hashTableItem *item, *prev;

  i = hash_void_ptr(ptr);

  item = tbl->table[i];
  if (item == NULL)
    {
      printf("xfree: invalid ptr %p\n", ptr);
      abort();
    }
  prev = NULL;
  while (item->ptr != ptr)
    {
      prev = item;
      item = item->next;
    }
  if (item->ptr != ptr)
    {
      printf("xfree: invalid ptr %p\n", ptr);
      abort();
    }

  xmalloc_current -= item->bytes;
  xmalloc_current_blocks--;

  if (prev != NULL)
    {
      prev->next = item->next;
      free(item);
    }
  else
    {
      tbl->table[i] = item->next;
      free(item);
    }
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rsi, %rbx
movq %rdi, %r14
movq %rsi, %rdi
callq 0x2bfc03
movq (%r14), %rcx
movl %eax, %eax
movq (%rcx,%rax,8), %rdx
testq %rdx, %rdx
je 0x2bfad6
leaq (%rcx,%rax,8), %rax
xorl %ecx, %ecx
movq %rdx, %rdi
cmpq %rbx, (%rdx)
je 0x2bfaa3
movq 0x28(%rdi), %rdx
movq %rdi, %rcx
jmp 0x2bfa92
movl 0x8(%rdi), %edx
leaq 0x155dfb(%rip), %rsi    # 0x4158a8
subl %edx, (%rsi)
leaq 0x155df6(%rip), %rdx    # 0x4158ac
decl (%rdx)
leaq 0x28(%rcx), %rdx
testq %rcx, %rcx
movq 0x28(%rdi), %rcx
cmoveq %rax, %rdx
movq %rcx, (%rdx)
addq $0x8, %rsp
popq %rbx
popq %r14
jmp 0x33058
leaq 0xa0477(%rip), %rdi     # 0x35ff54
movq %rbx, %rsi
xorl %eax, %eax
callq 0x2e300
callq 0x2e820
// File: /workspace/github_c_makefile_star2_O2/genometools[P]genometools/src/external/tre/lib/xmalloc.c
// Function: xrealloc_impl
void *
xrealloc_impl(void *ptr, size_t new_size, const char *file, int line,
	      const char *func)
{
  void *new_ptr;

  xmalloc_init();
  assert(ptr != NULL);
  assert(new_size > 0);

  if (xmalloc_fail_after == 0)
    {
      xmalloc_fail_after = -2;
      return NULL;
    }
  else if (xmalloc_fail_after == -2)
    {
      printf("xrealloc: called after failure from %s:%d: %s\n",
	     file, line, func);
      assert(0);
    }
  else if (xmalloc_fail_after > 0)
    xmalloc_fail_after--;

  hash_table_del(xmalloc_table, ptr);
  new_ptr = realloc(ptr, new_size);
  if (new_ptr != NULL)
    {
      hash_table_add(xmalloc_table, new_ptr, (int)new_size, file, line, func);
    }
  return new_ptr;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movq %r8, %rbx
movl %ecx, %ebp
movq %rdx, %r14
movq %rsi, %r15
movq %rdi, %r12
callq 0x2bf5c0
testq %r12, %r12
je 0x2bfb90
testq %r15, %r15
je 0x2bfbaf
movl 0x155d71(%rip), %eax    # 0x415890
testl %eax, %eax
je 0x2bfb77
cmpl $-0x2, %eax
je 0x2bfbce
testl %eax, %eax
jle 0x2bfb38
decl %eax
movl %eax, 0x155d58(%rip)    # 0x415890
movq 0x155d59(%rip), %rdi    # 0x415898
movq %r12, %rsi
callq 0x2bfa6c
movq %r12, %rdi
movq %r15, %rsi
callq 0x330a8
testq %rax, %rax
je 0x2bfb81
movq %rax, %r12
movq 0x155d37(%rip), %rdi    # 0x415898
movq %rax, %rsi
movl %r15d, %edx
movq %r14, %rcx
movl %ebp, %r8d
movq %rbx, %r9
callq 0x2bf86f
jmp 0x2bfb84
movl $0xfffffffe, 0x155d0f(%rip) # imm = 0xFFFFFFFE
xorl %r12d, %r12d
movq %r12, %rax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
leaq 0x79ee1(%rip), %rdi     # 0x339a78
leaq 0xa0194(%rip), %rsi     # 0x35fd32
leaq 0xa0288(%rip), %rcx     # 0x35fe2d
movl $0x144, %edx            # imm = 0x144
callq 0x2edc0
leaq 0xa02bc(%rip), %rdi     # 0x35fe72
leaq 0xa0175(%rip), %rsi     # 0x35fd32
leaq 0xa0269(%rip), %rcx     # 0x35fe2d
movl $0x145, %edx            # imm = 0x145
callq 0x2edc0
leaq 0xa02aa(%rip), %rdi     # 0x35fe7f
movq %r14, %rsi
movl %ebp, %edx
movq %rbx, %rcx
xorl %eax, %eax
callq 0x2e300
leaq 0x9b765(%rip), %rdi     # 0x35b350
leaq 0xa0140(%rip), %rsi     # 0x35fd32
leaq 0xa0234(%rip), %rcx     # 0x35fe2d
movl $0x150, %edx            # imm = 0x150
callq 0x2edc0
// File: /workspace/github_c_makefile_star2_O2/genometools[P]genometools/src/external/zlib-1.3.0.1/compress.c
// Function: compress2
int ZEXPORT compress2(Bytef *dest, uLongf *destLen, const Bytef *source,
                      uLong sourceLen, int level) {
    z_stream stream;
    int err;
    const uInt max = (uInt)-1;
    uLong left;

    left = *destLen;
    *destLen = 0;

    stream.zalloc = (alloc_func)0;
    stream.zfree = (free_func)0;
    stream.opaque = (voidpf)0;

    err = deflateInit(&stream, level);
    if (err != Z_OK) return err;

    stream.next_out = dest;
    stream.avail_out = 0;
    stream.next_in = (z_const Bytef *)source;
    stream.avail_in = 0;

    do {
        if (stream.avail_out == 0) {
            stream.avail_out = left > (uLong)max ? max : (uInt)left;
            left -= stream.avail_out;
        }
        if (stream.avail_in == 0) {
            stream.avail_in = sourceLen > (uLong)max ? max : (uInt)sourceLen;
            sourceLen -= stream.avail_in;
        }
        err = deflate(&stream, sourceLen ? Z_NO_FLUSH : Z_FINISH);
    } while (err == Z_OK);

    *destLen = stream.total_out;
    deflateEnd(&stream);
    return err == Z_STREAM_END ? Z_OK : err;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x78, %rsp
movq %rcx, %r14
movq %rsi, %rbx
movq (%rsi), %r12
andq $0x0, (%rsi)
movq %rdx, %rbp
movq %rdi, %r13
xorps %xmm0, %xmm0
leaq 0x8(%rsp), %rdi
movups %xmm0, 0x40(%rdi)
andq $0x0, 0x50(%rdi)
leaq 0x91cc6(%rip), %rdx     # 0x35a84b
pushq $0x70
popq %rcx
movl %r8d, %esi
callq 0x2cac10
testl %eax, %eax
jne 0x2c8c20
leaq 0x8(%rsp), %r15
movq %r13, 0x18(%r15)
andl $0x0, 0x20(%r15)
movq %rbp, (%r15)
andl $0x0, 0x8(%r15)
xorl %eax, %eax
movl $0xffffffff, %r13d      # imm = 0xFFFFFFFF
testl %eax, %eax
jne 0x2c8bcd
cmpq %r13, %r12
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
cmovbq %r12, %rax
movl %eax, 0x28(%rsp)
subq %rax, %r12
cmpl $0x0, 0x10(%rsp)
jne 0x2c8be7
cmpq %r13, %r14
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
cmovbq %r14, %rax
movl %eax, 0x10(%rsp)
subq %rax, %r14
xorl %esi, %esi
testq %r14, %r14
sete %sil
shll $0x2, %esi
movq %r15, %rdi
callq 0x2cb7ee
testl %eax, %eax
jne 0x2c8c05
movl 0x28(%rsp), %eax
jmp 0x2c8bb6
movl %eax, %ebp
leaq 0x8(%rsp), %rdi
movq 0x28(%rdi), %rax
movq %rax, (%rbx)
callq 0x2caee2
xorl %eax, %eax
cmpl $0x1, %ebp
cmovnel %ebp, %eax
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/genometools[P]genometools/src/external/zlib-1.3.0.1/infback.c
// Function: inflateBackInit_
int ZEXPORT inflateBackInit_(z_streamp strm, int windowBits,
                             unsigned char FAR *window, const char *version,
                             int stream_size) {
    struct inflate_state FAR *state;

    if (version == Z_NULL || version[0] != ZLIB_VERSION[0] ||
        stream_size != (int)(sizeof(z_stream)))
        return Z_VERSION_ERROR;
    if (strm == Z_NULL || window == Z_NULL ||
        windowBits < 8 || windowBits > 15)
        return Z_STREAM_ERROR;
    strm->msg = Z_NULL;                 /* in case we return an error */
    if (strm->zalloc == (alloc_func)0) {
#ifdef Z_SOLO
        return Z_STREAM_ERROR;
#else
        strm->zalloc = zcalloc;
        strm->opaque = (voidpf)0;
#endif
    }
    if (strm->zfree == (free_func)0)
#ifdef Z_SOLO
        return Z_STREAM_ERROR;
#else
    strm->zfree = zcfree;
#endif
    state = (struct inflate_state FAR *)ZALLOC(strm, 1,
                                               sizeof(struct inflate_state));
    if (state == Z_NULL) return Z_MEM_ERROR;
    Tracev((stderr, "inflate: allocated\n"));
    strm->state = (struct internal_state FAR *)state;
    state->dmax = 32768U;
    state->wbits = (uInt)windowBits;
    state->wsize = 1U << windowBits;
    state->window = window;
    state->wnext = 0;
    state->whave = 0;
    state->sane = 1;
    return Z_OK;
}

// Assembly:
pushq $-0x6
popq %rax
testq %rcx, %rcx
je 0x2d19c9
cmpl $0x70, %r8d
jne 0x2d19c9
cmpb $0x31, (%rcx)
jne 0x2d19c9
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movl %esi, %r14d
leal -0x10(%r14), %ecx
pushq $-0x2
popq %rax
cmpl $-0x8, %ecx
jb 0x2d19bf
movq %rdi, %r15
testq %rdi, %rdi
je 0x2d19bf
movq %rdx, %rbx
testq %rdx, %rdx
je 0x2d19bf
andq $0x0, 0x30(%r15)
movq 0x40(%r15), %rax
testq %rax, %rax
jne 0x2d1967
leaq -0x2549(%rip), %rax     # 0x2cf415
movq %rax, 0x40(%r15)
andq $0x0, 0x50(%r15)
cmpq $0x0, 0x48(%r15)
jne 0x2d1979
leaq -0x2556(%rip), %rcx     # 0x2cf41f
movq %rcx, 0x48(%r15)
movq 0x50(%r15), %rdi
pushq $0x1
popq %rbp
movl %ebp, %esi
movl $0x1bf8, %edx           # imm = 0x1BF8
callq *%rax
testq %rax, %rax
je 0x2d19bc
movq %rax, 0x38(%r15)
movl $0x8000, 0x1c(%rax)     # imm = 0x8000
movl %r14d, 0x38(%rax)
movl %r14d, %ecx
shll %cl, %ebp
movl %ebp, 0x3c(%rax)
movq %rbx, 0x48(%rax)
andq $0x0, 0x40(%rax)
movl $0x1, 0x1be8(%rax)
xorl %eax, %eax
jmp 0x2d19bf
pushq $-0x4
popq %rax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/genometools[P]genometools/src/external/zlib-1.3.0.1/infback.c
// Function: inflateBackEnd
int ZEXPORT inflateBackEnd(z_streamp strm) {
    if (strm == Z_NULL || strm->state == Z_NULL || strm->zfree == (free_func)0)
        return Z_STREAM_ERROR;
    ZFREE(strm, strm->state);
    strm->state = Z_NULL;
    Tracev((stderr, "inflate: end\n"));
    return Z_OK;
}

// Assembly:
pushq $-0x2
popq %rax
testq %rdi, %rdi
je 0x2d2803
pushq %rbx
movq %rdi, %rbx
movq 0x38(%rdi), %rsi
testq %rsi, %rsi
je 0x2d2802
movq 0x48(%rbx), %rcx
testq %rcx, %rcx
je 0x2d2802
movq 0x50(%rbx), %rdi
callq *%rcx
andq $0x0, 0x38(%rbx)
xorl %eax, %eax
popq %rbx
retq
// File: /workspace/github_c_makefile_star2_O2/Tarsnap[P]kivaloo/dynamodb-kv/capacity.c
// Function: capacity_init
struct capacity_reader *
capacity_init(const char * key_id, const char * key_secret,
    const char * tname, const char * rname, struct serverpool * SP,
    struct dynamodb_request_queue * QW, struct dynamodb_request_queue * QR)
{
	struct capacity_reader * M;

	/* Allocate space for our state and copy in parameters. */
	if ((M = malloc(sizeof(struct capacity_reader))) == NULL)
		goto err0;
	if ((M->key_id = strdup(key_id)) == NULL)
		goto err1;
	if ((M->key_secret = strdup(key_secret)) == NULL)
		goto err2;
	M->tname = tname;
	M->rname = rname;
	M->SP = SP;
	M->QW = QW;
	M->QR = QR;

	/* Initialize internal state. */
	M->ddbreq = NULL;
	M->addrs[0] = M->addrs[1] = NULL;
	M->http_cookie = NULL;
	M->timer_cookie = NULL;
	M->done = 0;

	/* Start reading table metadata. */
	if (readmetadata(M))
		goto err3;

	/* Wait for response. */
	if (events_spin(&M->done))
		goto err0;

	/* Success! */
	return (M);

err3:
	insecure_memzero(M->key_secret, strlen(M->key_secret));
err2:
	free(M->key_id);
err1:
	free(M);
err0:
	/* Failure! */
	return (NULL);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %r9, (%rsp)
movq %r8, %r15
movq %rcx, %r12
movq %rdx, %r13
movq %rsi, %rbp
movq %rdi, %r14
pushq $0x68
popq %rdi
callq 0x34e0
testq %rax, %rax
je 0x42c3
movq %rax, %rbx
movq %r14, %rdi
callq 0x3620
movq %rax, (%rbx)
testq %rax, %rax
je 0x42bb
movq %rax, %r14
movq %rbp, %rdi
callq 0x3620
movq %rax, 0x8(%rbx)
testq %rax, %rax
je 0x42b3
movq 0x40(%rsp), %rax
movq %r13, 0x10(%rbx)
movq %r12, 0x18(%rbx)
movq %r15, 0x20(%rbx)
movq (%rsp), %rcx
movq %rcx, 0x28(%rbx)
movq %rax, 0x30(%rbx)
xorps %xmm0, %xmm0
movups %xmm0, 0x38(%rbx)
movups %xmm0, 0x48(%rbx)
movups %xmm0, 0x54(%rbx)
movq %rbx, %rdi
callq 0x42e9
testl %eax, %eax
je 0x42d7
movq 0x8(%rbx), %r14
movq %r14, %rdi
callq 0x3180
leaq 0x183eb(%rip), %rcx     # 0x1c690
movq (%rcx), %rcx
movq %r14, %rdi
movq %rax, %rsi
callq *%rcx
movq (%rbx), %r14
movq %r14, %rdi
callq 0x3470
movq %rbx, %rdi
callq 0x3470
xorl %ebx, %ebx
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rbx, %rdi
addq $0x60, %rdi
callq 0x54df
testl %eax, %eax
jne 0x42c3
jmp 0x42c5
// File: /workspace/github_c_makefile_star2_O2/Tarsnap[P]kivaloo/dynamodb-kv/capacity.c
// Function: readmetadata
static int
readmetadata(struct capacity_reader * M)
{

	/* Construct the DynamoDB request body. */
	if (asprintf(&M->ddbreq, "{\"TableName\":\"%s\"}", M->tname) == -1) {
		warnp("asprintf");
		goto err0;
	}

	/* Get an address. */
	if ((M->addrs[0] = serverpool_pick(M->SP)) == NULL)
		goto err1;

	/* Send the request. */
	if ((M->http_cookie = dynamodb_request(M->addrs, M->key_id,
	    M->key_secret, M->rname, "DescribeTable",
	    (const uint8_t *)M->ddbreq, strlen(M->ddbreq), 4096,
	    callback_readmetadata, M)) == NULL)
		goto err2;

	/* Success! */
	return (0);

err2:
	sock_addr_free(M->addrs[0]);
	M->addrs[0] = NULL;
err1:
	free(M->ddbreq);
	M->ddbreq = NULL;
err0:
	/* Failure! */
	return (-1);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rdi, %r14
leaq 0x38(%rdi), %rbx
movq 0x10(%rdi), %rdx
leaq 0xefff(%rip), %rsi      # 0x13308
movq %rbx, %rdi
xorl %eax, %eax
callq 0x85c0
cmpl $-0x1, %eax
je 0x43b2
movq 0x20(%r14), %rdi
callq 0xd3ec
movq %rax, 0x40(%r14)
testq %rax, %rax
je 0x43a4
leaq 0x40(%r14), %r12
movq (%r14), %rax
movq %rax, 0x10(%rsp)
movq 0x8(%r14), %r13
movq 0x18(%r14), %rbp
movq 0x38(%r14), %r15
movq %r15, %rdi
callq 0x3180
leaq 0x104(%rip), %r10       # 0x4459
leaq 0xefbf(%rip), %r8       # 0x1331b
movq %r12, 0x8(%rsp)
movq %r12, %rdi
movq 0x10(%rsp), %rsi
movq %r13, %rdx
movq %rbp, %rcx
movq %r15, %r9
pushq %r14
pushq %r10
pushq $0x1000                 # imm = 0x1000
pushq %rax
callq 0xb59b
addq $0x20, %rsp
movq %rax, %rcx
movq %rax, 0x50(%r14)
xorl %eax, %eax
testq %rcx, %rcx
jne 0x43e3
movq 0x8(%rsp), %r14
movq (%r14), %rdi
callq 0x9fff
andq $0x0, (%r14)
movq (%rbx), %rdi
callq 0x3470
andq $0x0, (%rbx)
jmp 0x43e0
callq 0x3040
cmpl $0x0, (%rax)
je 0x43d2
movq %rax, %rbx
leaq 0xed09(%rip), %rdi      # 0x130cf
xorl %eax, %eax
callq 0xa911
andl $0x0, (%rbx)
jmp 0x43e0
leaq 0xecf6(%rip), %rdi      # 0x130cf
xorl %eax, %eax
callq 0xaaa0
pushq $-0x1
popq %rax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/Tarsnap[P]kivaloo/dynamodb-kv/capacity.c
// Function: capacity_free
void
capacity_free(struct capacity_reader * M)
{

	/* Behave consistently with free(NULL). */
	if (M == NULL)
		return;

	/* Cancel HTTP request and pending timer, if they exist. */
	if (M->http_cookie)
		http_request_cancel(M->http_cookie);
	if (M->timer_cookie)
		events_timer_cancel(M->timer_cookie);

	/* Free the AWS keys. */
	insecure_memzero(M->key_secret, strlen(M->key_secret));
	free(M->key_secret);
	free(M->key_id);

	/* Free our cookie. */
	free(M);
}

// Assembly:
testq %rdi, %rdi
je 0x4458
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %rbx
movq 0x50(%rdi), %rdi
testq %rdi, %rdi
je 0x440c
callq 0x66f5
movq 0x58(%rbx), %rdi
testq %rdi, %rdi
je 0x441a
callq 0x624f
movq 0x8(%rbx), %r14
movq %r14, %rdi
callq 0x3180
leaq 0x18263(%rip), %rcx     # 0x1c690
movq (%rcx), %rcx
movq %r14, %rdi
movq %rax, %rsi
callq *%rcx
movq 0x8(%rbx), %rdi
callq 0x3470
movq (%rbx), %rdi
callq 0x3470
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %r14
jmp 0x3470
retq
// File: /workspace/github_c_makefile_star2_O2/Tarsnap[P]kivaloo/dynamodb-kv/dispatch.c
// Function: dispatch_accept
struct dispatch_state *
dispatch_accept(struct dynamodb_request_queue * QW,
    struct dynamodb_request_queue * QR, const char * table, int s)
{
	struct dispatch_state * D;

	/* Allocate space for dispatcher state. */
	if ((D = malloc(sizeof(struct dispatch_state))) == NULL)
		goto err0;

	/* Initialize dispatcher. */
	D->QW = QW;
	D->QR = QR;
	D->table = table;
	D->ip_head = D->ip_tail = NULL;

	/* Accept a connection. */
	D->accepting = 1;
	if (network_accept(s, callback_accept, D) == NULL)
		goto err1;

	/* Success! */
	return (D);

err1:
	free(D);
err0:
	/* Failure! */
	return (NULL);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movl %ecx, %ebp
movq %rdx, %r14
movq %rsi, %r15
movq %rdi, %r12
pushq $0x48
popq %rdi
callq 0x34e0
testq %rax, %rax
je 0x477e
movq %rax, %rbx
movq %r12, (%rax)
movq %r15, 0x8(%rax)
movq %r14, 0x10(%rax)
xorps %xmm0, %xmm0
movups %xmm0, 0x18(%rax)
movl $0x1, 0x28(%rax)
leaq 0x25(%rip), %rsi        # 0x478c
movl %ebp, %edi
movq %rax, %rdx
callq 0x7a6c
testq %rax, %rax
jne 0x4780
movq %rbx, %rdi
callq 0x3470
xorl %ebx, %ebx
movq %rbx, %rax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/Tarsnap[P]kivaloo/dynamodb-kv/dispatch.c
// Function: dispatch_done
int
dispatch_done(struct dispatch_state * D)
{

	/* Sanity check. */
	assert(D->accepting == 0);
	assert(D->read_cookie == NULL);
	assert(D->ip_head == NULL);
	assert(D->ip_tail == NULL);

	/* Free the buffered reader for the connection. */
	netbuf_read_free(D->readq);

	/* Free the buffered writer for the connection. */
	netbuf_write_free(D->writeq);

	/* Close the connection. */
	if (close(D->sconn))
		warnp("close");

	/* Free allocated memory. */
	free(D);

	/* Success! */
	return (0);
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
cmpl $0x0, 0x28(%rdi)
jne 0x49f6
movq %rdi, %rbx
cmpq $0x0, 0x40(%rdi)
jne 0x4a15
cmpq $0x0, 0x18(%rbx)
jne 0x4a34
cmpq $0x0, 0x20(%rbx)
jne 0x4a53
movq 0x38(%rbx), %rdi
callq 0x7553
movq 0x30(%rbx), %rdi
callq 0x7908
movl 0x2c(%rbx), %edi
callq 0x3680
testl %eax, %eax
je 0x49e4
callq 0x3040
cmpl $0x0, (%rax)
je 0x49d6
movq %rax, %r14
leaq 0xed0c(%rip), %rdi      # 0x136d5
xorl %eax, %eax
callq 0xa911
andl $0x0, (%r14)
jmp 0x49e4
leaq 0xecf8(%rip), %rdi      # 0x136d5
xorl %eax, %eax
callq 0xaaa0
movq %rbx, %rdi
callq 0x3470
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
retq
leaq 0xea50(%rip), %rdi      # 0x1344d
leaq 0xea5b(%rip), %rsi      # 0x1345f
leaq 0xea5f(%rip), %rcx      # 0x1346a
movl $0x1be, %edx            # imm = 0x1BE
callq 0x3220
leaq 0xea79(%rip), %rdi      # 0x13495
leaq 0xea3c(%rip), %rsi      # 0x1345f
leaq 0xea40(%rip), %rcx      # 0x1346a
movl $0x1bf, %edx            # imm = 0x1BF
callq 0x3220
leaq 0xea71(%rip), %rdi      # 0x134ac
leaq 0xea1d(%rip), %rsi      # 0x1345f
leaq 0xea21(%rip), %rcx      # 0x1346a
movl $0x1c0, %edx            # imm = 0x1C0
callq 0x3220
leaq 0xea65(%rip), %rdi      # 0x134bf
leaq 0xe9fe(%rip), %rsi      # 0x1345f
leaq 0xea02(%rip), %rcx      # 0x1346a
movl $0x1c1, %edx            # imm = 0x1C1
callq 0x3220