// File: /workspace/github_c_makefile_star2_O0/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 %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
cmpq $0x0, -0x18(%rbp)
jg 0x168170
jmp 0x168370
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rax
addq -0x18(%rbp), %rax
movq -0x8(%rbp), %rcx
cmpq 0x20(%rcx), %rax
jle 0x16818f
movq -0x8(%rbp), %rdi
callq 0x1680c0
movq -0x8(%rbp), %rax
cmpq $0x0, 0x80(%rax)
je 0x1681b5
movq -0x8(%rbp), %rax
movq 0x80(%rax), %rdi
movq -0x10(%rbp), %rsi
movq -0x18(%rbp), %rdx
callq 0x15f430
movq -0x8(%rbp), %rax
cmpq $0x0, 0x90(%rax)
je 0x1681e7
movq -0x8(%rbp), %rax
movq 0x90(%rax), %rax
movq -0x8(%rbp), %rdi
movq -0x8(%rbp), %rcx
movq 0x88(%rcx), %rsi
movq -0x10(%rbp), %rdx
movq -0x18(%rbp), %rcx
callq *%rax
movq -0x8(%rbp), %rax
movl (%rax), %eax
movq %rax, -0x20(%rbp)
subq $0x9, %rax
ja 0x168354
movq -0x20(%rbp), %rax
leaq 0x6caf6(%rip), %rcx     # 0x1d4cfc
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq -0x8(%rbp), %rax
cmpq $0x0, 0x10(%rax)
jne 0x16821f
jmp 0x168370
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rax
cmpl $0x4, (%rax)
jl 0x168253
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rdi
movq -0x18(%rbp), %rcx
movq -0x8(%rbp), %rax
movq 0x68(%rax), %r8
movl $0x4, %esi
leaq 0x6cd9b(%rip), %rdx     # 0x1d4fe7
movb $0x0, %al
callq 0x15b4b0
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rdx
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rcx
movl $0x1, %esi
callq 0x19290
movq -0x18(%rbp), %rcx
movq -0x8(%rbp), %rax
addq 0x18(%rax), %rcx
movq %rcx, 0x18(%rax)
jmp 0x168370
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rax
cmpl $0x4, (%rax)
jl 0x1682c1
movq -0x8(%rbp), %rax
cmpq $0x0, 0x68(%rax)
je 0x1682c1
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rdi
movq -0x18(%rbp), %rcx
movq -0x8(%rbp), %rax
movq 0x68(%rax), %r8
movl $0x4, %esi
leaq 0x6cd45(%rip), %rdx     # 0x1d4fff
movb $0x0, %al
callq 0x15b4b0
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x18(%rbp), %rdx
callq 0x168620
jmp 0x168370
movq -0x8(%rbp), %rax
movq 0x50(%rax), %rdi
movq -0x10(%rbp), %rsi
movq -0x18(%rbp), %rdx
callq 0x166170
movq -0x18(%rbp), %rcx
movq -0x8(%rbp), %rax
addq 0x18(%rax), %rcx
movq %rcx, 0x18(%rax)
jmp 0x168370
movq -0x8(%rbp), %rax
cmpq $0x0, 0xb0(%rax)
je 0x168330
movq -0x8(%rbp), %rax
movq 0xb0(%rax), %rax
movq -0x8(%rbp), %rdi
movq -0x8(%rbp), %rcx
movq 0xa8(%rcx), %rsi
movq -0x10(%rbp), %rdx
movq -0x18(%rbp), %rcx
callq *%rax
movq -0x18(%rbp), %rcx
movq -0x8(%rbp), %rax
addq 0x18(%rax), %rcx
movq %rcx, 0x18(%rax)
jmp 0x168370
movq -0x18(%rbp), %rcx
movq -0x8(%rbp), %rax
addq 0x18(%rax), %rcx
movq %rcx, 0x18(%rax)
jmp 0x168370
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rdi
movq -0x8(%rbp), %rax
movl (%rax), %edx
leaq 0x6ccb7(%rip), %rsi     # 0x1d5020
movb $0x0, %al
callq 0x15c2a0
addq $0x20, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)