// File: stevedonovan[P]outstreams/outstream.cpp
// Function: stream::Writer::formatted_write(char const*, char const*, ...)
Writer& Writer::formatted_write(const char *def, const char *fmt,...) {
    char copy_def[30];
    if (fmt!=nullptr && fmt[1]==0) { // one-character special shortcut format codes
        if (def[1] == 's') { // 'quote' or "quote" strings
            if (fmt[0] == 'q') fmt = "'%s'"; else
            if (fmt[0] == 'Q') fmt = "\"%s\"";
        } else {
            if (fmt[0] == 'x' || fmt[0] == 'X') { // numbers as hex
                const char *in = def;
                char *out = copy_def;
                while (*(in+1))  *out++ = *in++;
                if (*in == 'c') { // special case - characters as bytes
                    *out++ = 'h';   *out++ = 'h';
                }
                *out++ = fmt[0];
                *out = 0;
                fmt = copy_def;
            } else {
                fmt = nullptr;
            }
        }
    }
    sep_out();
    va_list ap;
    va_start(ap,fmt);
    write_out(fmt ? fmt : def,ap);
    va_end(ap);
    return *this;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x130, %rsp            # imm = 0x130
testb %al, %al
je 0x62c4
movaps %xmm0, -0xf0(%rbp)
movaps %xmm1, -0xe0(%rbp)
movaps %xmm2, -0xd0(%rbp)
movaps %xmm3, -0xc0(%rbp)
movaps %xmm4, -0xb0(%rbp)
movaps %xmm5, -0xa0(%rbp)
movaps %xmm6, -0x90(%rbp)
movaps %xmm7, -0x80(%rbp)
movq %r9, -0xf8(%rbp)
movq %r8, -0x100(%rbp)
movq %rcx, -0x108(%rbp)
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x128(%rbp)
cmpq $0x0, -0x18(%rbp)
je 0x640e
movq -0x18(%rbp), %rax
movsbl 0x1(%rax), %eax
cmpl $0x0, %eax
jne 0x640e
movq -0x10(%rbp), %rax
movsbl 0x1(%rax), %eax
cmpl $0x73, %eax
jne 0x6350
movq -0x18(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x71, %eax
jne 0x6332
leaq 0xf3d(%rip), %rax       # 0x7269
movq %rax, -0x18(%rbp)
jmp 0x634b
movq -0x18(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x51, %eax
jne 0x6349
leaq 0xf29(%rip), %rax       # 0x726e
movq %rax, -0x18(%rbp)
jmp 0x634b
jmp 0x640c
movq -0x18(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x78, %eax
je 0x636c
movq -0x18(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x58, %eax
jne 0x6402
movq -0x10(%rbp), %rax
movq %rax, -0x48(%rbp)
leaq -0x40(%rbp), %rax
movq %rax, -0x50(%rbp)
movq -0x48(%rbp), %rax
cmpb $0x0, 0x1(%rax)
je 0x63aa
movq -0x48(%rbp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, -0x48(%rbp)
movb (%rax), %cl
movq -0x50(%rbp), %rax
movq %rax, %rdx
addq $0x1, %rdx
movq %rdx, -0x50(%rbp)
movb %cl, (%rax)
jmp 0x637c
movq -0x48(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x63, %eax
jne 0x63da
movq -0x50(%rbp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, -0x50(%rbp)
movb $0x68, (%rax)
movq -0x50(%rbp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, -0x50(%rbp)
movb $0x68, (%rax)
movq -0x18(%rbp), %rax
movb (%rax), %cl
movq -0x50(%rbp), %rax
movq %rax, %rdx
addq $0x1, %rdx
movq %rdx, -0x50(%rbp)
movb %cl, (%rax)
movq -0x50(%rbp), %rax
movb $0x0, (%rax)
leaq -0x40(%rbp), %rax
movq %rax, -0x18(%rbp)
jmp 0x640a
movq $0x0, -0x18(%rbp)
jmp 0x640c
jmp 0x640e
movq -0x128(%rbp), %rdi
callq 0x6210
leaq -0x70(%rbp), %rax
leaq -0x120(%rbp), %rcx
movq %rcx, 0x10(%rax)
leaq 0x10(%rbp), %rcx
movq %rcx, 0x8(%rax)
movl $0x30, 0x4(%rax)
movl $0x18, (%rax)
cmpq $0x0, -0x18(%rbp)
je 0x6452
movq -0x18(%rbp), %rax
movq %rax, -0x130(%rbp)
jmp 0x645d
movq -0x10(%rbp), %rax
movq %rax, -0x130(%rbp)
movq -0x128(%rbp), %rdi
movq -0x130(%rbp), %rsi
movq (%rdi), %rax
movq 0x8(%rax), %rax
leaq -0x70(%rbp), %rdx
callq *%rax
movq -0x128(%rbp), %rax
addq $0x130, %rsp            # imm = 0x130
popq %rbp
retq
nopl (%rax,%rax)