// File: karel-brinda[P]ococo/ext/htslib/cram/mFILE.c
// Function: mfprintf
int mfprintf(mFILE *mf, char *fmt, ...) {
    int ret;
    size_t est_length;
    va_list args;

    va_start(args, fmt);
    est_length = vflen(fmt, args);
    va_end(args);
    while (est_length + mf->offset > mf->alloced) {
	size_t new_alloced = mf->alloced ? mf->alloced * 2 : 1024;
	void * new_data    = realloc(mf->data, new_alloced);
	if (NULL == new_data) return -1;
	mf->alloced = new_alloced;
	mf->data    = new_data;
    }

    va_start(args, fmt);
    ret = vsprintf(&mf->data[mf->offset], fmt, args);
    va_end(args);

    if (ret > 0) {
	mf->offset += ret;
	if (mf->size < mf->offset)
	    mf->size = mf->offset;
    }

    if (mf->fp == stderr) {
	/* Auto-flush for stderr */
	if (0 != mfflush(mf)) return -1;
    }

    return ret;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x110, %rsp            # imm = 0x110
testb %al, %al
je 0x56fbe
movaps %xmm0, -0xd0(%rbp)
movaps %xmm1, -0xc0(%rbp)
movaps %xmm2, -0xb0(%rbp)
movaps %xmm3, -0xa0(%rbp)
movaps %xmm4, -0x90(%rbp)
movaps %xmm5, -0x80(%rbp)
movaps %xmm6, -0x70(%rbp)
movaps %xmm7, -0x60(%rbp)
movq %r9, -0xd8(%rbp)
movq %r8, -0xe0(%rbp)
movq %rcx, -0xe8(%rbp)
movq %rdx, -0xf0(%rbp)
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
leaq -0x40(%rbp), %rax
leaq -0x100(%rbp), %rcx
movq %rcx, 0x10(%rax)
leaq 0x10(%rbp), %rcx
movq %rcx, 0x8(%rax)
movl $0x30, 0x4(%rax)
movl $0x10, (%rax)
movq -0x18(%rbp), %rdi
leaq -0x40(%rbp), %rsi
callq 0x61050
cltq
movq %rax, -0x28(%rbp)
leaq -0x40(%rbp), %rax
movq -0x28(%rbp), %rax
movq -0x10(%rbp), %rcx
addq 0x28(%rcx), %rax
movq -0x10(%rbp), %rcx
cmpq 0x10(%rcx), %rax
jbe 0x570b1
movq -0x10(%rbp), %rax
cmpq $0x0, 0x10(%rax)
je 0x57052
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
shlq %rax
movq %rax, -0x108(%rbp)
jmp 0x57060
movl $0x400, %eax            # imm = 0x400
movq %rax, -0x108(%rbp)
jmp 0x57060
movq -0x108(%rbp), %rax
movq %rax, -0x48(%rbp)
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdi
movq -0x48(%rbp), %rsi
callq 0x4990
movq %rax, -0x50(%rbp)
xorl %eax, %eax
cmpq -0x50(%rbp), %rax
jne 0x57094
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x57168
movq -0x48(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0x50(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x8(%rax)
jmp 0x5701d
leaq -0x40(%rbp), %rax
leaq -0x100(%rbp), %rcx
movq %rcx, 0x10(%rax)
leaq 0x10(%rbp), %rcx
movq %rcx, 0x8(%rax)
movl $0x30, 0x4(%rax)
movl $0x10, (%rax)
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdi
movq -0x10(%rbp), %rax
addq 0x28(%rax), %rdi
movq -0x18(%rbp), %rsi
leaq -0x40(%rbp), %rdx
callq 0x4260
movl %eax, -0x1c(%rbp)
leaq -0x40(%rbp), %rax
cmpl $0x0, -0x1c(%rbp)
jle 0x57133
movslq -0x1c(%rbp), %rcx
movq -0x10(%rbp), %rax
addq 0x28(%rax), %rcx
movq %rcx, 0x28(%rax)
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rax
movq -0x10(%rbp), %rcx
cmpq 0x28(%rcx), %rax
jae 0x57131
movq -0x10(%rbp), %rax
movq 0x28(%rax), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x20(%rax)
jmp 0x57133
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq 0x32e8f(%rip), %rcx     # 0x89fd0
cmpq (%rcx), %rax
jne 0x57162
movq -0x10(%rbp), %rdi
callq 0x56620
movl %eax, %ecx
xorl %eax, %eax
cmpl %ecx, %eax
je 0x57160
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x57168
jmp 0x57162
movl -0x1c(%rbp), %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x110, %rsp            # imm = 0x110
popq %rbp
retq
nopw %cs:(%rax,%rax)