LLM4Binary/decompile-bench-makefile huggingface dataset:
// File: /workspace/github_c_makefile_star2_O3/jsummers[P]deark/src/deark-tar.c
// Function: set_common_header_fields
static void set_common_header_fields(deark *c, struct tar_ctx *tctx,
	dbuf *hdr)
{
	struct tar_md *md = tctx->md;

	// uid
	format_and_write_ascii_octal_field(c, tctx, 0, 8, hdr, 108);
	// gid
	format_and_write_ascii_octal_field(c, tctx, 0, 8, hdr, 116);
	// mtime
	format_and_write_ascii_octal_field(c, tctx, md->tsdata[DE_TIMESTAMPIDX_MODIFY].timestamp_unix, 12, hdr, 136);
	// magic/version
	dbuf_write_at(hdr, 257, (const u8*)"ustar\0" "00", 8);
	format_and_write_ascii_field(c, tctx, "root", 32, hdr, 265); // uname
	format_and_write_ascii_field(c, tctx, "root", 32, hdr, 297); // gname
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
subq $0x10, %rsp
movq %rsi, %rbx
movq %rdi, %r14
leaq 0x4(%rsp), %r15
movl $0x8, %edx
xorl %edi, %edi
movq %r15, %rsi
callq 0xee6d7
movl $0x6c, %esi
movl $0x8, %ecx
movq %rbx, %rdi
movq %r15, %rdx
callq 0xf0c11
leaq 0x4(%rsp), %r15
movl $0x8, %edx
xorl %edi, %edi
movq %r15, %rsi
callq 0xee6d7
movl $0x74, %esi
movl $0x8, %ecx
movq %rbx, %rdi
movq %r15, %rdx
callq 0xf0c11
movq 0x50(%r14), %rdi
leaq 0x4(%rsp), %r14
movl $0xc, %edx
movq %r14, %rsi
callq 0xee6d7
movl $0x88, %esi
movl $0xc, %ecx
movq %rbx, %rdi
movq %r14, %rdx
callq 0xf0c11
leaq 0x5ab4e(%rip), %rdx     # 0x14912b
movl $0x101, %esi            # imm = 0x101
movl $0x8, %ecx
movq %rbx, %rdi
callq 0xf0c11
leaq 0x2b940(%rip), %r14     # 0x119f36
movl $0x109, %esi            # imm = 0x109
movl $0x4, %ecx
movq %rbx, %rdi
movq %r14, %rdx
callq 0xf0c11
movl $0x129, %esi            # imm = 0x129
movl $0x4, %ecx
movq %rbx, %rdi
movq %r14, %rdx
callq 0xf0c11
addq $0x10, %rsp
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O3/jsummers[P]deark/src/deark-tar.c
// Function: set_checksum_field
static void set_checksum_field(deark *c, struct tar_ctx *tctx,
	dbuf *hdr)
{
	u8 buf[8];

	calc_checksum(c, tctx, hdr);
	format_ascii_octal_field(c, tctx, tctx->checksum_calc, buf, 7);
	buf[6] = 0x00;
	buf[7] = 0x20;
	dbuf_write_at(hdr, 148, buf, 8);
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rdx, %rbx
movq %rsi, %r14
movq 0x10(%rsi), %rax
testq %rax, %rax
je 0xee64b
movq %rax, %rdi
callq 0xeb7fe
movq 0x10(%r14), %rdi
jmp 0xee65c
movl $0x30, %esi
callq 0xeb499
movq %rax, %rdi
movq %rax, 0x10(%r14)
movl $0x94, %ecx
movq %rbx, %rsi
xorl %edx, %edx
callq 0xeb944
movq 0x10(%r14), %rdi
movl $0x8, %edx
movl $0x20, %esi
callq 0xeb8be
movq 0x10(%r14), %rdi
movl $0x9c, %edx
movl $0x164, %ecx            # imm = 0x164
movq %rbx, %rsi
callq 0xeb944
movq 0x10(%r14), %rdi
callq 0xeb865
movl %eax, %edi
movq %rdi, 0x18(%r14)
movq %rsp, %r14
movl $0x7, %edx
movq %r14, %rsi
callq 0xee6d7
movw $0x2000, 0x6(%r14)      # imm = 0x2000
movl $0x94, %esi
movl $0x8, %ecx
movq %rbx, %rdi
movq %r14, %rdx
callq 0xf0c11
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O3/jsummers[P]deark/src/deark-tar.c
// Function: format_ascii_octal_field
static int format_ascii_octal_field(deark *c, struct tar_ctx *tctx,
	i64 val, u8 *buf2, size_t buf2len)
{
	char buf1[32]; // The largest field we need to support is 12 bytes
	size_t k;
	size_t len_in_octal;

	de_zeromem(buf2, buf2len);
	if(buf2len>12) return 0;
	if(val<0) val = 0;

	de_snprintf(buf1, sizeof(buf1), "%"U64_FMTo, (u64)val);
	len_in_octal = de_strlen(buf1);
	if(len_in_octal > buf2len) {
		for(k=0; k<buf2len; k++) {
			buf2[k] = '7';
		}
	}
	else if(len_in_octal == buf2len) {
		de_memcpy(buf2, buf1, buf2len);
	}
	else {
		size_t num_leading_0s = buf2len - 1 - len_in_octal;

		for(k=0; k<buf2len; k++) {
			if(k < num_leading_0s) {
				buf2[k] = '0';
			}
			else if(k < buf2len - 1) {
				buf2[k] = buf1[k-num_leading_0s];
			}
			else {
				buf2[k] = '\0';
			}
		}
	}

	return 1;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rdx, %rbx
movq %rsi, %r14
movq %rdi, %r12
xorl %r15d, %r15d
movq %rsi, %rdi
xorl %esi, %esi
callq 0x18140
testq %r12, %r12
cmovleq %r15, %r12
leaq 0x5aa09(%rip), %rdx     # 0x14910f
movq %rsp, %r15
movl $0x20, %esi
movq %r15, %rdi
movq %r12, %rcx
xorl %eax, %eax
callq 0xe8193
movq %r15, %rdi
callq 0x180e0
movq %rax, %rsi
subq %rbx, %rsi
jbe 0xee742
testq %rbx, %rbx
je 0xee78e
movq %r14, %rdi
movl $0x37, %esi
movq %rbx, %rdx
callq 0x18140
jmp 0xee78e
jne 0xee754
movq %rsp, %rsi
movq %r14, %rdi
movq %rbx, %rdx
callq 0x181e0
jmp 0xee78e
leaq -0x1(%rbx), %rcx
movq %rbx, %rdx
subq $0x1, %rdx
jb 0xee78e
subq %rax, %rcx
leaq (%rsi,%r15), %rax
incq %rax
xorl %esi, %esi
movb $0x30, %dil
cmpq %rcx, %rsi
jb 0xee782
cmpq %rdx, %rsi
jae 0xee780
movb (%rax,%rsi), %dil
jmp 0xee782
xorl %edi, %edi
movb %dil, (%r14,%rsi)
incq %rsi
cmpq %rsi, %rbx
jne 0xee76d
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O3/jsummers[P]deark/src/deark-tar.c
// Function: add_exthdr_item
static void add_exthdr_item(deark *c, struct tar_ctx *tctx,
	dbuf *extdata, const char *name, const char *val, i64 *ppos)
{
	i64 len1;
	i64 item_len = 0;
	char *tmps = NULL;

	len1 = (i64)de_strlen(name) + (i64)de_strlen(val) + 3;
	// This size of the size field depends on itself. Ugh.
	if(len1<=8) item_len = len1+1;
	else if(len1<=97) item_len = len1+2;
	else if(len1<=996) item_len = len1+3;
	else if(len1<=9995) item_len = len1+4;
	else if(len1<=99994) item_len = len1+5;
	else if(len1<=999993) item_len = len1+6;
	else { // Error
		(*ppos)++;
		goto done;
	}

	tmps = de_malloc(c, item_len+1);
	de_snprintf(tmps, (size_t)(item_len+1), "%"I64_FMT" %s=%s\n", item_len, name, val);
	dbuf_write_at(extdata, *ppos, (const u8*)tmps, item_len);
	(*ppos) += item_len;

done:
	de_free(c, tmps);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %r8, %rbx
movq %rcx, %r13
movq %rdx, %rbp
movq %rsi, %r12
movq %rdi, %r14
movq %rdx, %rdi
callq 0x180e0
movq %rax, %r15
movq %r13, %rdi
callq 0x180e0
addq %r15, %rax
movl $0x4, %ecx
cmpq $0x6, %rax
jl 0xee817
movl $0x5, %ecx
cmpq $0x5f, %rax
jb 0xee817
movl $0x6, %ecx
cmpq $0x3e2, %rax            # imm = 0x3E2
jb 0xee817
movl $0x7, %ecx
cmpq $0x2709, %rax           # imm = 0x2709
jb 0xee817
movl $0x8, %ecx
cmpq $0x18698, %rax          # imm = 0x18698
jb 0xee817
movl $0x9, %ecx
cmpq $0xf4236, %rax          # imm = 0xF4236
ja 0xee88f
movq %rbp, 0x8(%rsp)
leaq (%rax,%rcx), %rbp
movq %r12, 0x10(%rsp)
movq %rbx, %r12
leaq (%rax,%rcx), %rbx
incq %rbx
movq %r14, %rdi
movq %rbx, %rsi
callq 0xe8b2b
movq %rax, %r15
leaq 0x5a8dc(%rip), %rdx     # 0x149120
movq %rax, %rdi
movq %rbx, %rsi
movq %r12, %rbx
movq %rbp, %rcx
movq 0x8(%rsp), %r8
movq %r13, %r9
xorl %eax, %eax
callq 0xe8193
movq (%r12), %rsi
movq 0x10(%rsp), %rdi
movq %r15, %rdx
movq %rbp, %rcx
callq 0xf0c11
addq %rbp, (%rbx)
movq %r14, %rdi
movq %r15, %rsi
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0xe8be2
movl $0x1, %ebp
xorl %r15d, %r15d
jmp 0xee873
nopl (%rax)
// File: /workspace/github_c_makefile_star2_O3/jsummers[P]deark/src/deark-dbuf.c
// Function: dbuf_standard_read
i64 dbuf_standard_read(dbuf *f, u8 *buf, i64 n, i64 *fpos)
{
	i64 amt_to_read;

	if(*fpos < 0 || *fpos >= f->len) return 0;

	amt_to_read = n;
	if(*fpos + amt_to_read > f->len) amt_to_read = f->len - *fpos;
	dbuf_read(f, buf, *fpos, amt_to_read);
	*fpos += amt_to_read;
	return amt_to_read;
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rdx, %rax
movq (%rcx), %rdx
testq %rdx, %rdx
js 0xeeac6
movq %rcx, %r14
movq 0x18(%rdi), %rcx
movq %rcx, %rbx
subq %rdx, %rbx
jle 0xeeac6
leaq (%rdx,%rax), %r8
cmpq %rcx, %r8
cmovleq %rax, %rbx
movq %rbx, %rcx
callq 0xee8d4
addq %rbx, (%r14)
jmp 0xeeac8
xorl %ebx, %ebx
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O3/jsummers[P]deark/src/deark-dbuf.c
// Function: dbuf_getbyte
u8 dbuf_getbyte(dbuf *f, i64 pos)
{
	u8 b;

	if(pos<0 || pos>=f->len) return 0x00;

	if(pos<f->rcache_bytes_used) {
		return f->rcache[pos];
	}
	if(f->btype==DBUF_TYPE_MEMBUF) {
		return f->membuf_buf[pos];
	}

	dbuf_read(f, &b, pos, 1);
	return b;
}

// Assembly:
testq %rsi, %rsi
js 0xeeaf3
movq %rsi, %rdx
cmpq %rsi, 0x18(%rdi)
jle 0xeeaf3
cmpq %rdx, 0xc0(%rdi)
jle 0xeeaf6
movq 0xc8(%rdi), %rax
jmp 0xeeaff
xorl %eax, %eax
retq
cmpl $0x3, (%rdi)
jne 0xeeb03
movq 0x78(%rdi), %rax
movb (%rax,%rdx), %al
retq
pushq %rbx
subq $0x10, %rsp
leaq 0xf(%rsp), %rbx
movl $0x1, %ecx
movq %rbx, %rsi
callq 0xee8d4
movb (%rbx), %al
addq $0x10, %rsp
popq %rbx
retq
// File: /workspace/github_c_makefile_star2_O3/jsummers[P]deark/src/deark-dbuf.c
// Function: dbuf_getu16be_p
i64 dbuf_getu16be_p(dbuf *f, i64 *ppos)
{
	u8 m[2];
	dbuf_read(f, m, *ppos, 2);
	(*ppos) += 2;
	return de_getu16be_direct(m);
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rsi, %rbx
movq (%rsi), %rdx
leaq 0x6(%rsp), %r14
movl $0x2, %ecx
movq %r14, %rsi
callq 0xee8d4
addq $0x2, (%rbx)
movzwl (%r14), %eax
rolw $0x8, %ax
movzwl %ax, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O3/jsummers[P]deark/src/deark-dbuf.c
// Function: dbuf_getu16le_p
i64 dbuf_getu16le_p(dbuf *f, i64 *ppos)
{
	u8 m[2];
	dbuf_read(f, m, *ppos, 2);
	(*ppos) += 2;
	return de_getu16le_direct(m);
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rsi, %rbx
movq (%rsi), %rdx
leaq 0x6(%rsp), %r14
movl $0x2, %ecx
movq %r14, %rsi
callq 0xee8d4
addq $0x2, (%rbx)
movzwl (%r14), %eax
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O3/jsummers[P]deark/src/deark-dbuf.c
// Function: dbuf_geti16be
i64 dbuf_geti16be(dbuf *f, i64 pos)
{
	i64 n;
	n = dbuf_getu16be(f, pos);
	if(n>=32768) n -= 65536;
	return n;
}

// Assembly:
pushq %rbx
subq $0x10, %rsp
movq %rsi, %rdx
leaq 0xe(%rsp), %rbx
movl $0x2, %ecx
movq %rbx, %rsi
callq 0xee8d4
movzbl 0x1(%rbx), %eax
movzbl (%rbx), %ecx
movl %ecx, %edx
shll $0x8, %edx
leaq (%rdx,%rax), %rsi
testb %cl, %cl
leaq -0x10000(%rdx,%rax), %rax
cmovnsq %rsi, %rax
addq $0x10, %rsp
popq %rbx
retq
// File: /workspace/github_c_makefile_star2_O3/jsummers[P]deark/src/deark-dbuf.c
// Function: dbuf_geti16le
i64 dbuf_geti16le(dbuf *f, i64 pos)
{
	i64 n;
	n = dbuf_getu16le(f, pos);
	if(n>=32768) n -= 65536;
	return n;
}

// Assembly:
pushq %rbx
subq $0x10, %rsp
movq %rsi, %rdx
leaq 0xe(%rsp), %rbx
movl $0x2, %ecx
movq %rbx, %rsi
callq 0xee8d4
movzwl (%rbx), %ecx
leaq -0x10000(%rcx), %rax
testw %cx, %cx
cmovnsq %rcx, %rax
addq $0x10, %rsp
popq %rbx
retq
// File: /workspace/github_c_makefile_star2_O3/jsummers[P]deark/src/deark-dbuf.c
// Function: dbuf_geti16le_p
i64 dbuf_geti16le_p(dbuf *f, i64 *ppos)
{
	i64 n;
	n = dbuf_geti16le(f, *ppos);
	(*ppos) += 2;
	return n;
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rsi, %rbx
movq (%rsi), %rdx
leaq 0x6(%rsp), %r14
movl $0x2, %ecx
movq %r14, %rsi
callq 0xee8d4
movzwl (%r14), %ecx
leaq -0x10000(%rcx), %rax
testw %cx, %cx
cmovnsq %rcx, %rax
addq $0x2, (%rbx)
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O3/jsummers[P]deark/src/deark-dbuf.c
// Function: dbuf_getu32be_p
i64 dbuf_getu32be_p(dbuf *f, i64 *ppos)
{
	u8 m[4];
	dbuf_read(f, m, *ppos, 4);
	(*ppos) += 4;
	return de_getu32be_direct(m);
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rsi, %rbx
movq (%rsi), %rdx
leaq 0x4(%rsp), %r14
movl $0x4, %ecx
movq %r14, %rsi
callq 0xee8d4
addq $0x4, (%rbx)
movl (%r14), %eax
bswapl %eax
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O3/jsummers[P]deark/src/deark-dbuf.c
// Function: dbuf_getu32le_p
i64 dbuf_getu32le_p(dbuf *f, i64 *ppos)
{
	u8 m[4];
	dbuf_read(f, m, *ppos, 4);
	(*ppos) += 4;
	return de_getu32le_direct(m);
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rsi, %rbx
movq (%rsi), %rdx
leaq 0x4(%rsp), %r14
movl $0x4, %ecx
movq %r14, %rsi
callq 0xee8d4
addq $0x4, (%rbx)
movl (%r14), %eax
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O3/jsummers[P]deark/src/deark-dbuf.c
// Function: dbuf_geti32le_p
i64 dbuf_geti32le_p(dbuf *f, i64 *ppos)
{
	i64 n;
	n = dbuf_geti32le(f, *ppos);
	(*ppos) += 4;
	return n;
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rsi, %rbx
movq (%rsi), %rdx
leaq 0x4(%rsp), %r14
movl $0x4, %ecx
movq %r14, %rsi
callq 0xee8d4
movslq (%r14), %rax
addq $0x4, (%rbx)
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O3/jsummers[P]deark/src/deark-dbuf.c
// Function: dbuf_getint_ext
i64 dbuf_getint_ext(dbuf *f, i64 pos, unsigned int nbytes,
	int is_le, int is_signed)
{
	if(is_signed) {
		// TODO: Extend this to any number of bytes, 1-8.
		switch(nbytes) {
		case 1: return (i64)(signed char)dbuf_getbyte(f, pos); break;
		case 2: return dbuf_geti16x(f, pos, is_le); break;
		case 4: return dbuf_geti32x(f, pos, is_le); break;
		case 8: return dbuf_geti64x(f, pos, is_le); break;
		default:
			return dbuf_getint_ext_x(f, pos, nbytes, is_le);
		}
	}
	else {
		switch(nbytes) {
		case 1: return (i64)dbuf_getbyte(f, pos); break;
		case 2: return dbuf_getu16x(f, pos, is_le); break;
		case 4: return dbuf_getu32x(f, pos, is_le); break;
		case 8: return dbuf_geti64x(f, pos, is_le); break;
		default:
			return dbuf_getuint_ext_x(f, pos, nbytes, is_le);
		}
	}
	return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
subq $0x18, %rsp
movl %ecx, %ebp
movl %edx, %ebx
movq %rsi, %rdx
testl %r8d, %r8d
je 0xef13b
leal -0x1(%rbx), %r15d
cmpl $0x7, %r15d
ja 0xef1a9
leaq 0x5a017(%rip), %rax     # 0x149138
movslq (%rax,%r15,4), %rcx
addq %rax, %rcx
jmpq *%rcx
movq %rdx, %rsi
callq 0xeead3
movsbq %al, %rax
jmp 0xef24b
leal -0x1(%rbx), %eax
cmpl $0x7, %eax
ja 0xef244
leaq 0x5a00a(%rip), %rcx     # 0x149158
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq %rdx, %rsi
callq 0xeead3
movzbl %al, %eax
jmp 0xef24b
movq %rdx, %rsi
addq $0x18, %rsp
testl %ebp, %ebp
je 0xef239
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0xeef09
movq %rdx, %rsi
movl %ebp, %edx
addq $0x18, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0xeef8a
movq %rdx, %rsi
movl %ebp, %edx
addq $0x18, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0xef033
cmpl $0x18, %ebx
ja 0xef249
movl %ebx, %r14d
movq %rsp, %rsi
movq %r14, %rcx
callq 0xee8d4
testl %ebp, %ebp
jne 0xef249
cmpl $0x8, %ebx
jbe 0xef1e2
addl $-0x8, %ebx
xorl %eax, %eax
xorl %ecx, %ecx
cmpb $-0x1, (%rsp,%rcx)
jne 0xef24b
incq %rcx
cmpq %rcx, %rbx
jne 0xef1d4
xorl %ecx, %ecx
xorl %edx, %edx
xorl %eax, %eax
movl $0xff, %esi
cmpq %r14, %rdx
jae 0xef1f9
movl %r15d, %esi
movzbl (%rsp,%rsi), %esi
shlq %cl, %rsi
orq %rsi, %rax
incq %rdx
decl %r15d
addq $0x8, %rcx
cmpq $0x8, %rdx
jne 0xef1e8
jmp 0xef24b
movq %rdx, %rsi
movl %ebp, %edx
addq $0x18, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0xeeff3
movq %rdx, %rsi
movl %ebp, %edx
addq $0x18, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0xeef43
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0xeee96
cmpl $0x18, %ebx
jbe 0xef256
xorl %eax, %eax
addq $0x18, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
movl %ebx, %r14d
movq %rsp, %rsi
movq %r14, %rcx
callq 0xee8d4
testl %ebp, %ebp
je 0xef295
testl %ebx, %ebx
je 0xef249
xorl %ecx, %ecx
xorl %edx, %edx
xorl %eax, %eax
movzbl (%rsp,%rdx), %esi
testq %rsi, %rsi
je 0xef287
cmpq $0x7, %rdx
ja 0xef249
shlq %cl, %rsi
orq %rsi, %rax
incq %rdx
addq $0x8, %rcx
cmpq %rdx, %r14
jne 0xef272
jmp 0xef24b
testl %ebx, %ebx
je 0xef249
xorl %ecx, %ecx
xorl %eax, %eax
movq %rax, %rdx
shrq $0x38, %rdx
jne 0xef249
shlq $0x8, %rax
movzbl (%rsp,%rcx), %edx
orq %rdx, %rax
incq %rcx
cmpq %rcx, %r14
jne 0xef29d
jmp 0xef24b
// File: /workspace/github_c_makefile_star2_O3/jsummers[P]deark/src/deark-dbuf.c
// Function: de_getfloat64x_direct
double de_getfloat64x_direct(deark *c, const u8 *m, int is_le)
{
	char buf[8];
	double val = 0.0;

	if(c->can_decode_fltpt<0) {
		init_fltpt_decoder(c);
	}
	if(!c->can_decode_fltpt) return 0.0;

	de_memcpy(buf, m, 8);

	if(is_le != c->host_is_le) {
		int i;
		char tmpc;
		// Reverse order of bytes
		for(i=0; i<4; i++) {
			tmpc = buf[i]; buf[i] = buf[7-i]; buf[7-i] = tmpc;
		}
	}

	de_memcpy(&val, buf, 8);
	return (double)val;
}

// Assembly:
cmpl $0x0, 0xf0(%rdi)
js 0xef34a
je 0xef39a
movl 0xf4(%rdi), %eax
jmp 0xef360
movabsq $0x100000001, %rax      # imm = 0x100000001
movq %rax, 0xf0(%rdi)
movl $0x1, %eax
movq (%rsi), %rcx
movq %rcx, -0x8(%rsp)
cmpl %edx, %eax
jne 0xef372
movq %rcx, %xmm0
retq
leaq -0x1(%rsp), %rax
xorl %ecx, %ecx
movb -0x8(%rsp,%rcx), %dl
movb (%rax), %sil
movb %sil, -0x8(%rsp,%rcx)
movb %dl, (%rax)
incq %rcx
decq %rax
cmpq $0x4, %rcx
jne 0xef379
movsd -0x8(%rsp), %xmm0
retq
xorps %xmm0, %xmm0
retq
// File: /workspace/github_c_makefile_star2_O3/jsummers[P]deark/src/deark-dbuf.c
// Function: dbuf_read_ascii_number
int dbuf_read_ascii_number(dbuf *f, i64 pos, i64 fieldsize,
	int base, i64 *value)
{
	char buf[32];

	*value = 0;
	if(fieldsize>(i64)(sizeof(buf)-1)) return 0;

	dbuf_read(f, (u8*)buf, pos, fieldsize);
	buf[fieldsize] = '\0';

	*value = de_strtoll(buf, NULL, base);
	return 1;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
subq $0x28, %rsp
movq %rdx, %r14
movq $0x0, (%r8)
xorl %eax, %eax
cmpq $0x1f, %rdx
jg 0xef424
movq %r8, %rbx
movl %ecx, %ebp
movq %rsi, %rdx
movq %rsp, %r15
movq %r15, %rsi
movq %r14, %rcx
callq 0xee8d4
movb $0x0, (%rsp,%r14)
movq %r15, %rdi
xorl %esi, %esi
movl %ebp, %edx
callq 0x10937d
movq %rax, (%rbx)
movl $0x1, %eax
addq $0x28, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/jsummers[P]deark/src/deark-dbuf.c
// Function: dbuf_getRGB
de_color dbuf_getRGB(dbuf *f, i64 pos, unsigned int flags)
{
	u8 buf[3];
	dbuf_read(f, buf, pos, 3);
	if(flags&DE_GETRGBFLAG_BGR)
		return DE_MAKE_RGB(buf[2], buf[1], buf[0]);
	return DE_MAKE_RGB(buf[0], buf[1], buf[2]);
}

// Assembly:
pushq %rbx
subq $0x10, %rsp
movl %edx, %ebx
movq %rsi, %rdx
leaq 0xd(%rsp), %rsi
movl $0x3, %ecx
callq 0xee8d4
testb $0x1, %bl
jne 0xef465
movzbl 0xd(%rsp), %ecx
shll $0x10, %ecx
movzbl 0xe(%rsp), %eax
shll $0x8, %eax
orl %ecx, %eax
movb 0xf(%rsp), %cl
jmp 0xef471
movzwl 0xe(%rsp), %eax
shll $0x8, %eax
movb 0xd(%rsp), %cl
movzbl %cl, %ecx
addl %ecx, %eax
addl $0xff000000, %eax       # imm = 0xFF000000
addq $0x10, %rsp
popq %rbx
retq
// File: /workspace/github_c_makefile_star2_O3/jsummers[P]deark/src/deark-dbuf.c
// Function: dbuf_copy
void dbuf_copy(dbuf *inf, i64 input_offset, i64 input_len, dbuf *outf)
{
	u8 tmpbuf[256];

	// Fast paths, if the data to copy is all in memory

	if(inf->rcache &&
		(input_offset>=0) && (input_offset+input_len<=inf->rcache_bytes_used))
	{
		dbuf_write(outf, &inf->rcache[input_offset], input_len);
		return;
	}

	if(inf->btype==DBUF_TYPE_MEMBUF &&
		(input_offset>=0) && (input_offset+input_len<=inf->len))
	{
		dbuf_write(outf, &inf->membuf_buf[input_offset], input_len);
		return;
	}

	if(input_len<=(i64)sizeof(tmpbuf)) {
		// Fast path for small sizes
		dbuf_read(inf, tmpbuf, input_offset, input_len);
		dbuf_write(outf, tmpbuf, input_len);
		return;
	}

	dbuf_buffered_read(inf, input_offset, input_len, copy_cbfn, (void*)outf);
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
subq $0x100, %rsp            # imm = 0x100
movq %rcx, %r14
movq %rdx, %rbx
movq %rsi, %rdx
movq 0xc8(%rdi), %rsi
testq %rsi, %rsi
sete %al
testq %rdx, %rdx
sets %cl
orb %al, %cl
jne 0xef4ba
leaq (%rbx,%rdx), %rax
cmpq 0xc0(%rdi), %rax
jle 0xef521
testq %rdx, %rdx
js 0xef4ce
cmpl $0x3, (%rdi)
jne 0xef4ce
leaq (%rbx,%rdx), %rax
cmpq 0x18(%rdi), %rax
jle 0xef529
cmpq $0x100, %rbx            # imm = 0x100
jg 0xef500
movq %rsp, %r15
movq %r15, %rsi
movq %rbx, %rcx
callq 0xee8d4
movq %r14, %rdi
movq %r15, %rsi
movq %rbx, %rdx
callq 0xef547
addq $0x100, %rsp            # imm = 0x100
popq %rbx
popq %r14
popq %r15
retq
leaq 0x314(%rip), %rcx       # 0xef81b
movq %rdx, %rsi
movq %rbx, %rdx
movq %r14, %r8
addq $0x100, %rsp            # imm = 0x100
popq %rbx
popq %r14
popq %r15
jmp 0xef5e4
addq %rdx, %rsi
movq %r14, %rdi
jmp 0xef533
addq 0x78(%rdi), %rdx
movq %r14, %rdi
movq %rdx, %rsi
movq %rbx, %rdx
addq $0x100, %rsp            # imm = 0x100
popq %rbx
popq %r14
popq %r15
jmp 0xef547
// File: /workspace/github_c_makefile_star2_O3/jsummers[P]deark/src/deark-dbuf.c
// Function: dbuf_write
void dbuf_write(dbuf *f, const u8 *m, i64 len)
{
	if(!f->wbuffer) {
		dbuf_write_unbuffered(f, m, len);
		return;
	}

	if(len<=0) return;

	if(len > DE_WBUFFER_SIZE/2) {
		// This item doesn't fit in the buffer, even by itself, or we
		// consider it "large".
		// Flush the buffer, write the item, done.
		// TODO: Decide what the "large" threshold should be, or if there should
		// even be one.
		if(f->wbuffer_bytes_used!=0) dbuf_flush(f);
		dbuf_write_unbuffered(f, m, len);
		return;
	}

	if(f->wbuffer_bytes_used + len > DE_WBUFFER_SIZE) {
		// This item fits in the buffer by itself, but currently the buffer
		// is too full.
		// Flush the buffer, copy the item to the buffer, done.
		dbuf_flush(f);
		de_memcpy(f->wbuffer, m, (size_t)len);
		f->wbuffer_bytes_used = len;
		return;
	}

	// There is room for this item in the buffer, even without flushing it first.
	de_memcpy(&f->wbuffer[f->wbuffer_bytes_used], m, (size_t)len);
	f->wbuffer_bytes_used += len;
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movq %rdx, %rbx
movq %rsi, %r15
movq %rdi, %r14
movq 0x48(%rdi), %rsi
testq %rsi, %rsi
je 0xef585
testq %rbx, %rbx
jle 0xef5de
movq 0x40(%r14), %rdx
cmpq $0x101, %rbx            # imm = 0x101
jb 0xef598
testq %rdx, %rdx
je 0xef585
movq %r14, %rdi
callq 0xf0a88
movq $0x0, 0x40(%r14)
movq %r14, %rdi
movq %r15, %rsi
movq %rbx, %rdx
popq %rbx
popq %r14
popq %r15
jmp 0xf0a88
leaq (%rdx,%rbx), %rax
cmpq $0x201, %rax            # imm = 0x201
jl 0xef5c9
movq %r14, %rdi
callq 0xf0a88
movq $0x0, 0x40(%r14)
movq 0x48(%r14), %rdi
movq %r15, %rsi
movq %rbx, %rdx
callq 0x181e0
movq %rbx, 0x40(%r14)
jmp 0xef5de
addq %rdx, %rsi
movq %rsi, %rdi
movq %r15, %rsi
movq %rbx, %rdx
callq 0x181e0
addq %rbx, 0x40(%r14)
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O3/jsummers[P]deark/src/deark-dbuf.c
// Function: copy_at_cbfn
static int copy_at_cbfn(struct de_bufferedreadctx *brctx, const u8 *buf,
	i64 buf_len)
{
	struct copy_at_ctx *ctx = (struct copy_at_ctx*)brctx->userdata;

	dbuf_write_at(ctx->outf, ctx->outpos, buf, buf_len);
	ctx->outpos += buf_len;
	return 1;
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rdx, %rbx
movq %rsi, %rdx
movq (%rdi), %r14
movq (%r14), %rdi
movq 0x8(%r14), %rsi
movq %rbx, %rcx
callq 0xf0c11
addq %rbx, 0x8(%r14)
movl $0x1, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O3/jsummers[P]deark/src/deark-dbuf.c
// Function: dbuf_search_byte
int dbuf_search_byte(dbuf *f, const u8 b, i64 startpos,
	i64 haystack_len, i64 *foundpos)
{
	i64 i;

	for(i=0; i<haystack_len; i++) {
		if(b == dbuf_getbyte(f, startpos+i)) {
			*foundpos = startpos+i;
			return 1;
		}
	}
	return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
xorl %ebx, %ebx
testq %rcx, %rcx
jle 0xefab9
movq %r8, %r14
movq %rcx, %r12
movq %rdx, %r15
movl %esi, %ebp
movq %rdi, %r13
movq %r13, %rdi
movq %r15, %rsi
callq 0xeead3
cmpb %bpl, %al
je 0xefab1
incq %r15
decq %r12
jne 0xefa97
jmp 0xefab9
movq %r15, (%r14)
movl $0x1, %ebx
movl %ebx, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/jsummers[P]deark/src/deark-dbuf.c
// Function: de_destroy_stringreaderdata
void de_destroy_stringreaderdata(deark *c, struct de_stringreaderdata *srd)
{
	if(!srd) return;
	de_free(c, srd->sz);
	de_free(c, srd->sz_utf8);
	ucstring_destroy(srd->str);
	de_free(c, srd);
}

// Assembly:
testq %rsi, %rsi
je 0xefb09
pushq %r14
pushq %rbx
pushq %rax
movq %rsi, %rbx
movq %rdi, %r14
movq 0x8(%rsi), %rsi
callq 0xe8be2
movq 0x20(%rbx), %rsi
movq %r14, %rdi
callq 0xe8be2
movq 0x18(%rbx), %rdi
callq 0xf6753
movq %r14, %rdi
movq %rbx, %rsi
addq $0x8, %rsp
popq %rbx
popq %r14
jmp 0xe8be2
retq
// File: /workspace/github_c_makefile_star2_O3/jsummers[P]deark/src/deark-dbuf.c
// Function: dbuf_read_to_ucstring_ex
void dbuf_read_to_ucstring_ex(dbuf *f, i64 pos1, i64 len,
	de_ucstring *s, unsigned int conv_flags, struct de_encconv_state *es)
{
	i64 nbytes_remaining;
	i64 pos = pos1;
	int stop_at_nul = 0;
#define READTOUCSTRING_BUFLEN 256
	u8 buf[READTOUCSTRING_BUFLEN];

	if(conv_flags & DE_CONVFLAG_STOP_AT_NUL) {
		stop_at_nul = 1;
		// We handle STOP_AT_NUL ourselves, so don't pass it on.
		conv_flags -= DE_CONVFLAG_STOP_AT_NUL;
	}

	// Note: It might be sensible to use dbuf_buffered_read() here, but I've
	// decided against it for now.
	nbytes_remaining = len;
	do {
		i64 nbytes_to_read;
		i64 nbytes_in_buf;
		unsigned int conv_flags_to_use_this_time;

		// Lack of DE_CONVFLAG_PARTIAL_DATA flag signals end of data, which
		// isn't necessarily a no-op even with len=0.
		// That's why we always do this loop at least once.

		nbytes_to_read = de_min_int(nbytes_remaining, READTOUCSTRING_BUFLEN);
		dbuf_read(f, buf, pos, nbytes_to_read);
		pos += nbytes_to_read;
		nbytes_in_buf = nbytes_to_read;
		nbytes_remaining -= nbytes_to_read;

		if(stop_at_nul) {
			char *tmpp;

			tmpp = de_memchr(buf, 0x00, (size_t)nbytes_in_buf);
			if(tmpp) {
				nbytes_in_buf = (const u8*)tmpp - buf;
				nbytes_remaining = 0;
			}
		}

		conv_flags_to_use_this_time = conv_flags;
		if(nbytes_remaining>0) {
			// The caller may have already set this flag, in which case we will use
			// it every time.
			// If not, we still use it for all but the final call to ucstring_append_bytes_ex().
			conv_flags_to_use_this_time |= DE_CONVFLAG_PARTIAL_DATA;
		}

		ucstring_append_bytes_ex(s, buf, nbytes_in_buf, conv_flags_to_use_this_time, es);
	} while(nbytes_remaining>0);

}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x128, %rsp            # imm = 0x128
movq %r9, 0x10(%rsp)
movl %r8d, %ebx
movq %rcx, 0x8(%rsp)
movq %rdx, %r12
movq %rsi, %r13
movq %rdi, 0x18(%rsp)
movl %r8d, 0x4(%rsp)
andl $-0x2, %ebx
movl %ebx, %ebp
orl $0x40, %ebp
leaq 0x20(%rsp), %r14
movl $0x100, %esi            # imm = 0x100
movq %r12, %rdi
callq 0xe9c3b
movq %rax, %r15
movq 0x18(%rsp), %rdi
movq %r14, %rsi
movq %r13, %rdx
movq %rax, %rcx
callq 0xee8d4
testb $0x1, 0x4(%rsp)
je 0xefb81
movq %r14, %rdi
xorl %esi, %esi
movq %r15, %rdx
callq 0x18150
testq %rax, %rax
jne 0xefbab
addq %r15, %r13
subq %r15, %r12
testq %r12, %r12
movl %ebx, %ecx
cmovgl %ebp, %ecx
movq 0x8(%rsp), %rdi
movq %r14, %rsi
movq %r15, %rdx
movq 0x10(%rsp), %r8
callq 0xf67b3
testq %r12, %r12
jg 0xefb45
jmp 0xefbc5
subq %r14, %rax
movq 0x8(%rsp), %rdi
movq %r14, %rsi
movq %rax, %rdx
movl %ebx, %ecx
movq 0x10(%rsp), %r8
callq 0xf67b3
addq $0x128, %rsp            # imm = 0x128
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/jsummers[P]deark/src/deark-dbuf.c
// Function: dbuf_memcmp
int dbuf_memcmp(dbuf *f, i64 pos, const void *s, size_t n)
{
	u8 buf1[128];

	if(f->rcache &&
		pos >= 0 &&
		pos + (i64)n <= f->rcache_bytes_used)
	{
		// Fastest path: Compare directly to cache.
		return de_memcmp(s, &f->rcache[pos], n);
	}

	if(n<=sizeof(buf1)) {
		// Use a stack buffer if small enough.
		dbuf_read(f, buf1, pos, n);
		return de_memcmp(buf1, s, n);
	}

	// Fallback method.
	return !dbuf_buffered_read(f, pos, n, dbufmemcmp_cbfn, (void*)s);
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
subq $0x80, %rsp
movq %rcx, %rbx
movq %rdx, %r14
movq %rsi, %rdx
movq 0xc8(%rdi), %rsi
testq %rsi, %rsi
sete %al
testq %rdx, %rdx
sets %cl
orb %al, %cl
jne 0xefcbe
leaq (%rbx,%rdx), %rax
cmpq 0xc0(%rdi), %rax
jle 0xefd10
cmpq $0x80, %rbx
ja 0xefce5
movq %rsp, %r15
movq %r15, %rsi
movq %rbx, %rcx
callq 0xee8d4
movq %r15, %rdi
movq %r14, %rsi
movq %rbx, %rdx
callq 0x18170
jmp 0xefd03
leaq 0x3e(%rip), %rcx        # 0xefd2a
movq %rdx, %rsi
movq %rbx, %rdx
movq %r14, %r8
callq 0xef5e4
movl %eax, %ecx
xorl %eax, %eax
testl %ecx, %ecx
sete %al
addq $0x80, %rsp
popq %rbx
popq %r14
popq %r15
retq
addq %rdx, %rsi
movq %r14, %rdi
movq %rbx, %rdx
addq $0x80, %rsp
popq %rbx
popq %r14
popq %r15
jmp 0x18170
// File: /workspace/github_c_makefile_star2_O3/jsummers[P]deark/src/deark-dbuf.c
// Function: dbuf_create_file_from_slice
int dbuf_create_file_from_slice(dbuf *inf, i64 pos, i64 data_size,
	const char *ext, de_finfo *fi, unsigned int createflags)
{
	dbuf *f;
	f = dbuf_create_output_file(inf->c, ext, fi, createflags);
	if(!f) return 0;
	dbuf_copy(inf, pos, data_size, f);
	dbuf_close(f);
	return 1;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
movq %rdx, %rbx
movq %rsi, %r14
movq %rdi, %r15
movq 0x8(%rdi), %rdi
movq %rcx, %rsi
movq %r8, %rdx
movl %r9d, %ecx
callq 0xefda1
testq %rax, %rax
je 0xefd93
movq %rax, %r12
movq %r15, %rdi
movq %r14, %rsi
movq %rbx, %rdx
movq %rax, %rcx
callq 0xef481
movq %r12, %rdi
callq 0xf052b
movl $0x1, %eax
jmp 0xefd95
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O3/jsummers[P]deark/src/deark-dbuf.c
// Function: dbuf_create_unmanaged_file
dbuf *dbuf_create_unmanaged_file(deark *c, const char *fname, int overwrite_mode,
	unsigned int flags)
{
	dbuf *f;
	char msgbuf[200];

	f = create_dbuf_lowlevel(c);
	f->is_managed = 0;
	f->name = de_strdup(c, fname);

	f->btype = DBUF_TYPE_OFILE;
	f->max_len_hard = c->max_output_file_size;
	f->fp = de_fopen_for_write(c, f->name, msgbuf, sizeof(msgbuf),
		c->overwrite_mode, flags);

	if(!f->fp) {
		de_err(c, "Failed to write %s: %s", f->name, msgbuf);
		f->btype = DBUF_TYPE_NULL;
		c->serious_error_flag = 1;
	}

	return f;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
subq $0xc8, %rsp
movl %ecx, %ebp
movq %rsi, %r15
movq %rdi, %rbx
movl $0xd8, %esi
callq 0xe8b2b
movq %rax, %r14
movq %rbx, 0x8(%rax)
movl $0xffffffff, 0x64(%rax) # imm = 0xFFFFFFFF
movb $0x0, 0x4(%rax)
movq %rbx, %rdi
movq %r15, %rsi
callq 0xe9865
movq %rax, 0x68(%r14)
movl $0x2, (%r14)
movq 0xb0(%rbx), %rcx
movq %rcx, 0x20(%r14)
movl 0xd8(%rbx), %r8d
movq %rsp, %rdx
movl $0xc8, %ecx
movq %rbx, %rdi
movq %rax, %rsi
movl %ebp, %r9d
callq 0x1094ab
movq %rax, 0x10(%r14)
testq %rax, %rax
jne 0xf07e5
movq 0x68(%r14), %rdx
leaq 0x58a4d(%rip), %rsi     # 0x14921a
movq %rsp, %rcx
movq %rbx, %rdi
xorl %eax, %eax
callq 0xe9295
movl $0x0, (%r14)
movb $0x1, 0x4c(%rbx)
movq %r14, %rax
addq $0xc8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/jsummers[P]deark/src/deark-dbuf.c
// Function: dbuf_create_unmanaged_file_stdout
dbuf *dbuf_create_unmanaged_file_stdout(deark *c, const char *name)
{
	dbuf *f;

	f = create_dbuf_lowlevel(c);
	f->is_managed = 0;
	f->name = de_strdup(c, name);
	f->btype = DBUF_TYPE_STDOUT;
	f->max_len_hard = c->max_output_file_size;
	f->fp = stdout;
	return f;
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movq %rsi, %rbx
movq %rdi, %r14
movl $0xd8, %esi
callq 0xe8b2b
movq %rax, %r15
movq %r14, 0x8(%rax)
movl $0xffffffff, 0x64(%rax) # imm = 0xFFFFFFFF
movb $0x0, 0x4(%rax)
movq %r14, %rdi
movq %rbx, %rsi
callq 0xe9865
movq %rax, 0x68(%r15)
movl $0x5, (%r15)
movq 0xb0(%r14), %rax
movq %rax, 0x20(%r15)
movq 0x9e78b(%rip), %rax     # 0x18efd0
movq (%rax), %rax
movq %rax, 0x10(%r15)
movq %r15, %rax
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O3/jsummers[P]deark/src/deark-dbuf.c
// Function: dbuf_disable_wbuffer
void dbuf_disable_wbuffer(dbuf *f)
{
	if(!f->wbuffer) return;
	dbuf_flush(f);
	de_free(f->c, f->wbuffer);
	f->wbuffer = NULL;
}

// Assembly:
movq 0x48(%rdi), %rsi
testq %rsi, %rsi
je 0xf08b9
pushq %rbx
movq %rdi, %rbx
movq 0x40(%rdi), %rdx
testq %rdx, %rdx
je 0xf08a7
movq %rbx, %rdi
callq 0xf0a88
movq $0x0, 0x40(%rbx)
movq 0x48(%rbx), %rsi
movq 0x8(%rbx), %rdi
callq 0xe8be2
movq $0x0, 0x48(%rbx)
popq %rbx
retq
// File: /workspace/github_c_makefile_star2_O3/jsummers[P]deark/src/deark-dbuf.c
// Function: dbuf_create_membuf
dbuf *dbuf_create_membuf(deark *c, i64 initialsize, unsigned int flags)
{
	dbuf *f;

	f = create_dbuf_lowlevel(c);
	f->btype = DBUF_TYPE_MEMBUF;
	f->max_len_hard = DE_MAX_MEMBUF_SIZE;

	if(initialsize>0) {
		if(initialsize > f->max_len_hard) {
			do_on_dbuf_size_exceeded(f);
		}
		f->membuf_buf = de_malloc(c, initialsize);
		f->membuf_alloc = initialsize;
	}

	if(flags&0x01) {
		dbuf_set_length_limit(f, initialsize);
	}

	return f;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movl %edx, %ebp
movq %rsi, %rbx
movq %rdi, %r15
movl $0xd8, %esi
callq 0xe8b2b
movq %rax, %r14
movq %r15, 0x8(%rax)
movl $0xffffffff, 0x64(%rax) # imm = 0xFFFFFFFF
movl $0x3, (%rax)
movq $0x77359400, 0x20(%rax) # imm = 0x77359400
testq %rbx, %rbx
jle 0xf0a23
cmpq $0x77359401, %rbx       # imm = 0x77359401
jb 0xf0a10
movq %r14, %rdi
callq 0xf0a43
movq %r15, %rdi
movq %rbx, %rsi
callq 0xe8b2b
movq %rax, 0x78(%r14)
movq %rbx, 0x70(%r14)
testb $0x1, %bpl
je 0xf0a35
movl $0x1, 0x30(%r14)
movq %rbx, 0x28(%r14)
movq %r14, %rax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/jsummers[P]deark/src/deark-dbuf.c
// Function: do_on_dbuf_size_exceeded
static void do_on_dbuf_size_exceeded(dbuf *f)
{
	de_err(f->c, "Maximum %s size of %"I64_FMT" bytes exceeded",
		(f->btype==DBUF_TYPE_MEMBUF)?"membuf":"output file",
		f->max_len_hard);
	de_fatalerror(f->c);
}

// Assembly:
pushq %rbx
movq %rdi, %rbx
movq 0x8(%rdi), %rdi
cmpl $0x3, (%rbx)
leaq 0x58a47(%rip), %rax     # 0x14949c
leaq 0x3e88c(%rip), %rdx     # 0x12f2e8
cmoveq %rax, %rdx
movq 0x20(%rbx), %rcx
leaq 0x58a0b(%rip), %rsi     # 0x149476
xorl %eax, %eax
callq 0xe9295
movq 0x8(%rbx), %rdi
popq %rbx
jmp 0xe9522
// File: /workspace/github_c_makefile_star2_O3/jsummers[P]deark/src/deark-dbuf.c
// Function: dbuf_write_unbuffered
static void dbuf_write_unbuffered(dbuf *f, const u8 *m, i64 len)
{
	if(len<=0) return;
	if(f->len + len > f->max_len_hard) {
		do_on_dbuf_size_exceeded(f);
	}

	if(f->crco_for_oinfo) {
		de_crcobj_addbuf(f->crco_for_oinfo, m, len);
	}
	if(f->writelistener_cb) {
		f->writelistener_cb(f, f->userdata_for_writelistener, m, len);
	}

	switch(f->btype) {
	case DBUF_TYPE_OFILE:
	case DBUF_TYPE_STDOUT:
		if(!f->fp) return;
		if(f->c->debug_level>=4) {
			de_dbgx(f->c, 4, "writing %"I64_FMT" bytes to %s", len, f->name);
		}
		fwrite(m, 1, (size_t)len, f->fp);
		f->len += len;
		return;
	case DBUF_TYPE_MEMBUF:
		if(f->c->debug_level>=4 && f->name) {
			de_dbgx(f->c, 4, "appending %"I64_FMT" bytes to membuf %s", len, f->name);
		}
		membuf_append(f, m, len);
		return;
	case DBUF_TYPE_ODBUF:
		dbuf_write(f->parent_dbuf, m, len);
		f->len += len;
		return;
	case DBUF_TYPE_CUSTOM:
		if(f->customwrite_fn) {
			f->customwrite_fn(f, f->userdata_for_customwrite, m, len);
		}
		f->len += len;
		return;
	case DBUF_TYPE_NULL:
		f->len += len;
		return;
	}

	de_internal_err_fatal(f->c, "Invalid output file type (%d)", f->btype);
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
testq %rdx, %rdx
jle 0xf0bd0
movq %rdx, %rbx
movq %rsi, %r15
movq %rdi, %r14
movq 0x18(%rdi), %rax
addq %rdx, %rax
cmpq 0x20(%rdi), %rax
jle 0xf0ab4
movq %r14, %rdi
callq 0xf0a43
movq 0x80(%r14), %rdi
testq %rdi, %rdi
je 0xf0acb
movq %r15, %rsi
movq %rbx, %rdx
callq 0xeb8ad
movq 0x90(%r14), %rax
testq %rax, %rax
je 0xf0ae9
movq 0x88(%r14), %rsi
movq %r14, %rdi
movq %r15, %rdx
movq %rbx, %rcx
callq *%rax
movl (%r14), %edx
cmpq $0x9, %rdx
ja 0xf0b6b
leaq 0x586a7(%rip), %rax     # 0x1491a0
movslq (%rax,%rdx,4), %rcx
addq %rax, %rcx
jmpq *%rcx
movq 0x10(%r14), %rcx
testq %rcx, %rcx
je 0xf0bd0
movq 0x8(%r14), %rdi
cmpl $0x4, (%rdi)
jl 0xf0b36
movq 0x68(%r14), %r8
leaq 0x58980(%rip), %rdx     # 0x1494a3
movl $0x4, %esi
movq %rbx, %rcx
xorl %eax, %eax
callq 0xe895a
movq 0x10(%r14), %rcx
movl $0x1, %esi
movq %r15, %rdi
movq %rbx, %rdx
callq 0x182a0
jmp 0xf0bcc
movq 0xb0(%r14), %rax
testq %rax, %rax
je 0xf0bcc
movq 0xa8(%r14), %rsi
movq %r14, %rdi
movq %r15, %rdx
movq %rbx, %rcx
callq *%rax
jmp 0xf0bcc
movq 0x8(%r14), %rdi
leaq 0x58966(%rip), %rsi     # 0x1494dc
xorl %eax, %eax
popq %rbx
popq %r14
popq %r15
jmp 0xe9544
movq 0x8(%r14), %rdi
cmpl $0x4, (%rdi)
jl 0xf0baa
movq 0x68(%r14), %r8
testq %r8, %r8
je 0xf0baa
leaq 0x58920(%rip), %rdx     # 0x1494bb
movl $0x4, %esi
movq %rbx, %rcx
xorl %eax, %eax
callq 0xe895a
movq %r14, %rdi
movq %r15, %rsi
movq %rbx, %rdx
popq %rbx
popq %r14
popq %r15
jmp 0xf0da0
movq 0x50(%r14), %rdi
movq %r15, %rsi
movq %rbx, %rdx
callq 0xef547
addq %rbx, 0x18(%r14)
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O3/jsummers[P]deark/src/deark-dbuf.c
// Function: dbuf_writebyte
void dbuf_writebyte(dbuf *f, u8 n)
{
	// Optimization
	if(f->wbuffer && f->wbuffer_bytes_used<DE_WBUFFER_SIZE) {
		f->wbuffer[f->wbuffer_bytes_used++] = n;
		return;
	}

	dbuf_write(f, &n, 1);
}

// Assembly:
pushq %rax
movb %sil, 0x7(%rsp)
movq 0x48(%rdi), %rax
testq %rax, %rax
je 0xf0c00
movq 0x40(%rdi), %rcx
cmpq $0x1ff, %rcx            # imm = 0x1FF
jg 0xf0c00
leaq 0x1(%rcx), %rdx
movq %rdx, 0x40(%rdi)
movb %sil, (%rax,%rcx)
jmp 0xf0c0f
leaq 0x7(%rsp), %rsi
movl $0x1, %edx
callq 0xef547
popq %rax
retq
// File: /workspace/github_c_makefile_star2_O3/jsummers[P]deark/src/deark-dbuf.c
// Function: dbuf_write_at
void dbuf_write_at(dbuf *f, i64 pos, const u8 *m, i64 len)
{
	if(len<1 || pos<0) return;

	if(pos + len > f->max_len_hard) {
		do_on_dbuf_size_exceeded(f);
	}

	if(f->btype==DBUF_TYPE_MEMBUF) {
		i64 amt_overwrite, amt_newzeroes, amt_append;

		if(pos+len <= f->len) { // entirely within the current file
			amt_overwrite = len;
			amt_newzeroes = 0;
			amt_append = 0;
		}
		else if(pos >= f->len) { // starts after the end of the current file
			amt_overwrite = 0;
			amt_newzeroes = pos - f->len;
			amt_append = len;
		}
		else { // overlaps the end of the current file
			amt_overwrite = f->len - pos;
			amt_newzeroes = 0;
			amt_append = len - amt_overwrite;
		}

		if(amt_overwrite>0) {
			de_memcpy(&f->membuf_buf[pos], m, (size_t)amt_overwrite);
		}
		if(amt_newzeroes>0) {
			dbuf_write_zeroes(f, amt_newzeroes);
		}
		if(amt_append>0) {
			membuf_append(f, &m[amt_overwrite], amt_append);
		}
	}
	else if(f->btype==DBUF_TYPE_OFILE && !f->is_managed) {
		i64 curpos = de_ftell(f->fp);
		if(pos != curpos) {
			de_fseek(f->fp, pos, SEEK_SET);
		}
		fwrite(m, 1, (size_t)len, f->fp);
		if(pos+len > f->len) {
			f->len = pos+len;
		}
	}
	else if(f->btype==DBUF_TYPE_NULL) {
		if(pos+len > f->len) {
			f->len = pos+len;
		}
	}
	else {
		de_internal_err_fatal(f->c, "Attempt to seek on non-seekable stream");
	}
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
movq %rcx, %r14
testq %rcx, %rcx
setle %al
testq %rsi, %rsi
sets %cl
orb %al, %cl
je 0xf0c37
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
movq %rdx, %r15
movq %rsi, %r12
movq %rdi, %rbx
leaq (%r14,%rsi), %r13
cmpq 0x20(%rdi), %r13
jle 0xf0c52
movq %rbx, %rdi
callq 0xf0a43
movl (%rbx), %eax
testl %eax, %eax
je 0xf0cf8
cmpl $0x2, %eax
je 0xf0c85
cmpl $0x3, %eax
jne 0xf0c8b
movq 0x18(%rbx), %rax
cmpq %rax, %r13
jle 0xf0ca6
movq %rax, %r13
subq %r12, %r13
jle 0xf0d0b
subq %r13, %r14
testq %r13, %r13
jg 0xf0cac
jmp 0xf0cbe
cmpb $0x0, 0x4(%rbx)
je 0xf0cc8
movq 0x8(%rbx), %rdi
leaq 0x586ba(%rip), %rsi     # 0x149350
xorl %eax, %eax
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
jmp 0xe9544
movq %r14, %r13
xorl %r14d, %r14d
addq 0x78(%rbx), %r12
movq %r12, %rdi
movq %r15, %rsi
movq %r13, %rdx
callq 0x181e0
testq %r14, %r14
jg 0xf0d1e
jmp 0xf0c2d
movq 0x10(%rbx), %rdi
callq 0x1095b9
cmpq %r12, %rax
je 0xf0ce4
movq 0x10(%rbx), %rdi
movq %r12, %rsi
xorl %edx, %edx
callq 0x1095b4
movq 0x10(%rbx), %rcx
movl $0x1, %esi
movq %r15, %rdi
movq %r14, %rdx
callq 0x182a0
cmpq 0x18(%rbx), %r13
jle 0xf0c2d
movq %r13, 0x18(%rbx)
jmp 0xf0c2d
subq %rax, %r12
jle 0xf0d1b
movq %rbx, %rdi
movq %r12, %rsi
callq 0xf0d35
xorl %r13d, %r13d
addq %r13, %r15
movq %rbx, %rdi
movq %r15, %rsi
movq %r14, %rdx
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
jmp 0xf0da0
// File: /workspace/github_c_makefile_star2_O3/jsummers[P]deark/src/deark-dbuf.c
// Function: dbuf_write_run
void dbuf_write_run(dbuf *f, u8 n, i64 len)
{
	u8 buf[1024];
	i64 amt_left;
	i64 amt_to_write;

	if(len<=0) return;
	de_memset(buf, n, (size_t)len<sizeof(buf) ? (size_t)len : sizeof(buf));
	amt_left = len;
	while(amt_left > 0) {
		if(amt_left < (i64)sizeof(buf))
			amt_to_write = amt_left;
		else
			amt_to_write = (i64)sizeof(buf);
		dbuf_write(f, buf, amt_to_write);
		amt_left -= amt_to_write;
	}
}

// Assembly:
testq %rdx, %rdx
jle 0xf0f26
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x400, %rsp            # imm = 0x400
movq %rdx, %rbx
movq %rdi, %r14
movl $0x400, %r13d           # imm = 0x400
cmpq %r13, %rdx
movl $0x400, %edx            # imm = 0x400
cmovbq %rbx, %rdx
movzbl %sil, %esi
movq %rsp, %r15
movq %r15, %rdi
callq 0x18140
cmpq %r13, %rbx
movl $0x400, %r12d           # imm = 0x400
cmovbq %rbx, %r12
movq %r14, %rdi
movq %r15, %rsi
movq %r12, %rdx
callq 0xef547
subq %r12, %rbx
jg 0xf0ef6
addq $0x400, %rsp            # imm = 0x400
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O3/jsummers[P]deark/src/deark-dbuf.c
// Function: membuf_append
static void membuf_append(dbuf *f, const u8 *m, i64 mlen)
{
	i64 new_alloc_size;

	if(f->has_len_limit) {
		if(f->len + mlen > f->len_limit) {
			mlen = f->len_limit - f->len;
		}
	}

	if(mlen<=0) return;

	if(mlen > f->membuf_alloc - f->len) {
		// Need to allocate more space
		new_alloc_size = (f->membuf_alloc + mlen)*2;
		if(new_alloc_size<1024) new_alloc_size=1024;
		if(new_alloc_size > f->max_len_hard) new_alloc_size = f->max_len_hard;
		if(f->c->debug_level>=4) {
			de_dbgx(f->c, 4, "increasing membuf size %"I64_FMT" -> %"I64_FMT,
				f->membuf_alloc, new_alloc_size);
		}
		if(f->len + mlen > f->max_len_hard) {
			do_on_dbuf_size_exceeded(f);
		}
		f->membuf_buf = de_realloc(f->c, f->membuf_buf, f->membuf_alloc, new_alloc_size);
		f->membuf_alloc = new_alloc_size;
	}

	de_memcpy(&f->membuf_buf[f->len], m, (size_t)mlen);
	f->len += mlen;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
movq %rdx, %rbx
movq %rsi, %r15
movq %rdi, %r14
cmpl $0x0, 0x30(%rdi)
je 0xf0dcf
movq 0x18(%r14), %rax
movq 0x28(%r14), %rcx
movq %rcx, %rdx
subq %rax, %rdx
addq %rbx, %rax
cmpq %rcx, %rax
cmovgq %rdx, %rbx
testq %rbx, %rbx
jle 0xf0e7f
movq 0x18(%r14), %rdi
movq 0x70(%r14), %rcx
movq %rcx, %rax
subq %rdi, %rax
cmpq %rax, %rbx
jle 0xf0e69
leaq (%rcx,%rbx), %rax
addq %rax, %rax
cmpq $0x401, %rax            # imm = 0x401
movl $0x400, %r12d           # imm = 0x400
cmovgeq %rax, %r12
movq 0x8(%r14), %rax
movq 0x20(%r14), %rdx
cmpq %rdx, %r12
cmovgeq %rdx, %r12
cmpl $0x4, (%rax)
jl 0xf0e37
leaq 0x586dd(%rip), %rdx     # 0x1494fa
movq %rax, %rdi
movl $0x4, %esi
movq %r12, %r8
xorl %eax, %eax
callq 0xe895a
movq 0x18(%r14), %rdi
movq 0x20(%r14), %rdx
addq %rbx, %rdi
cmpq %rdx, %rdi
jle 0xf0e47
movq %r14, %rdi
callq 0xf0a43
movq 0x78(%r14), %rsi
movq 0x8(%r14), %rdi
movq 0x70(%r14), %rdx
movq %r12, %rcx
callq 0xe97c6
movq %rax, 0x78(%r14)
movq %r12, 0x70(%r14)
movq 0x18(%r14), %rdi
jmp 0xf0e6d
movq 0x78(%r14), %rax
addq %rax, %rdi
movq %r15, %rsi
movq %rbx, %rdx
callq 0x181e0
addq %rbx, 0x18(%r14)
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O3/jsummers[P]deark/src/deark-dbuf.c
// Function: dbuf_writebyte_at
void dbuf_writebyte_at(dbuf *f, i64 pos, u8 n)
{
	if(f->btype==DBUF_TYPE_MEMBUF && pos>=0 && pos<f->len) {
		// Fast path when overwriting a byte in a membuf
		f->membuf_buf[pos] = n;
		return;
	}

	dbuf_write_at(f, pos, &n, 1);
}

// Assembly:
pushq %rax
movb %dl, 0x7(%rsp)
testq %rsi, %rsi
js 0xf0ea9
cmpl $0x3, (%rdi)
jne 0xf0ea9
cmpq %rsi, 0x18(%rdi)
jle 0xf0ea9
movq 0x78(%rdi), %rax
movb %dl, (%rax,%rsi)
jmp 0xf0eb8
leaq 0x7(%rsp), %rdx
movl $0x1, %ecx
callq 0xf0c11
popq %rax
retq
// File: /workspace/github_c_makefile_star2_O3/jsummers[P]deark/src/deark-dbuf.c
// Function: dbuf_truncate
void dbuf_truncate(dbuf *f, i64 desired_len)
{
	dbuf_flush(f);
	if(desired_len<0) desired_len=0;
	if(desired_len>f->len) {
		dbuf_write_zeroes(f, desired_len - f->len);
	}
	else if(desired_len<f->len) {
		if(f->btype==DBUF_TYPE_MEMBUF || f->btype==DBUF_TYPE_CUSTOM) {
			f->len = desired_len;
		}
	}
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rsi, %r14
movq %rdi, %rbx
movq 0x40(%rdi), %rdx
testq %rdx, %rdx
je 0xf0f4e
movq 0x48(%rbx), %rsi
movq %rbx, %rdi
callq 0xf0a88
movq $0x0, 0x40(%rbx)
xorl %eax, %eax
testq %r14, %r14
cmovgq %r14, %rax
movq %rax, %rsi
subq 0x18(%rbx), %rsi
jle 0xf0f6f
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %r14
jmp 0xf0d35
jae 0xf0f81
movl (%rbx), %ecx
cmpl $0x9, %ecx
je 0xf0f7d
cmpl $0x3, %ecx
jne 0xf0f81
movq %rax, 0x18(%rbx)
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O3/jsummers[P]deark/src/deark-dbuf.c
// Function: dbuf_writei16le
void dbuf_writei16le(dbuf *f, i64 n)
{
	if(n<0) {
		dbuf_writeu16le(f, n+65536);
	}
	else {
		dbuf_writeu16le(f, n);
	}
}

// Assembly:
pushq %rax
movl %esi, %ecx
shrl $0x8, %ecx
testq %rsi, %rsi
js 0xf0fdb
leaq 0x6(%rsp), %rax
jmp 0xf0fe0
leaq 0x4(%rsp), %rax
movb %sil, (%rax)
movb %cl, 0x1(%rax)
movl $0x2, %edx
movq %rax, %rsi
callq 0xef547
popq %rax
retq
// File: /workspace/github_c_makefile_star2_O3/jsummers[P]deark/src/deark-dbuf.c
// Function: dbuf_writei16be
void dbuf_writei16be(dbuf *f, i64 n)
{
	if(n<0) {
		dbuf_writeu16be(f, n+65536);
	}
	else {
		dbuf_writeu16be(f, n);
	}
}

// Assembly:
pushq %rax
movl %esi, %ecx
shrl $0x8, %ecx
testq %rsi, %rsi
js 0xf1007
leaq 0x6(%rsp), %rax
jmp 0xf100c
leaq 0x4(%rsp), %rax
movb %cl, (%rax)
movb %sil, 0x1(%rax)
movl $0x2, %edx
movq %rax, %rsi
callq 0xef547
popq %rax
retq
// File: /workspace/github_c_makefile_star2_O3/jsummers[P]deark/src/deark-dbuf.c
// Function: dbuf_writei32le
void dbuf_writei32le(dbuf *f, i64 n)
{
	if(n<0) {
		dbuf_writeu32le(f, n+0x100000000LL);
	}
	else {
		dbuf_writeu32le(f, n);
	}}

// Assembly:
pushq %rax
movl %esi, %ecx
shrl $0x8, %ecx
movl %esi, %edx
shrl $0x10, %edx
movl %esi, %r8d
shrl $0x18, %r8d
testq %rsi, %rsi
js 0xf1077
leaq 0x4(%rsp), %rax
jmp 0xf107a
movq %rsp, %rax
movb %sil, (%rax)
movb %cl, 0x1(%rax)
movb %dl, 0x2(%rax)
movb %r8b, 0x3(%rax)
movl $0x4, %edx
movq %rax, %rsi
callq 0xef547
popq %rax
retq
// File: /workspace/github_c_makefile_star2_O3/jsummers[P]deark/src/deark-dbuf.c
// Function: dbuf_writei32be
void dbuf_writei32be(dbuf *f, i64 n)
{
	if(n<0) {
		dbuf_writeu32be(f, n+0x100000000LL);
	}
	else {
		dbuf_writeu32be(f, n);
	}
}

// Assembly:
pushq %rax
movl %esi, %ecx
shrl $0x18, %ecx
movl %esi, %edx
shrl $0x10, %edx
movl %esi, %r8d
shrl $0x8, %r8d
testq %rsi, %rsi
js 0xf10b4
leaq 0x4(%rsp), %rax
jmp 0xf10b7
movq %rsp, %rax
movb %cl, (%rax)
movb %dl, 0x1(%rax)
movb %r8b, 0x2(%rax)
movb %sil, 0x3(%rax)
movl $0x4, %edx
movq %rax, %rsi
callq 0xef547
popq %rax
retq