// File: /workspace/github_c_makefile_star2_O0/aremmell[P]libsir/src/sirinternal.c
// Function: sir_format
const char* _sir_format(bool styling, sir_options opts, sirbuf* buf) {
    if (_sir_validptr(buf)) {
        bool first = true;

        _sir_resetstr(buf->output);

        if (styling)
            (void)_sir_strncat(buf->output, SIR_MAXOUTPUT, buf->style, SIR_MAXSTYLE);

        if (!_sir_bittest(opts, SIRO_NOTIME)) {
            (void)_sir_strncat(buf->output, SIR_MAXOUTPUT, buf->timestamp, SIR_MAXTIME);
            first = false;

#if defined(SIR_MSEC_TIMER)
            if (!_sir_bittest(opts, SIRO_NOMSEC))
                (void)_sir_strncat(buf->output, SIR_MAXOUTPUT, buf->msec, SIR_MAXMSEC);
#endif
        }

        if (!_sir_bittest(opts, SIRO_NOHOST) && _sir_validstrnofail(buf->hostname)) {
            if (!first)
                (void)_sir_strncat(buf->output, SIR_MAXOUTPUT, " ", 1);
            (void)_sir_strncat(buf->output, SIR_MAXOUTPUT, buf->hostname, SIR_MAXHOST);
            first = false;
        }

        if (!_sir_bittest(opts, SIRO_NOLEVEL)) {
            if (!first)
                (void)_sir_strncat(buf->output, SIR_MAXOUTPUT, " ", 1);
            (void)_sir_strncat(buf->output, SIR_MAXOUTPUT, buf->level, SIR_MAXLEVEL);
            first = false;
        }

        bool name = false;
        if (!_sir_bittest(opts, SIRO_NONAME) && _sir_validstrnofail(buf->name)) {
            if (!first)
                (void)_sir_strncat(buf->output, SIR_MAXOUTPUT, " ", 1);
            (void)_sir_strncat(buf->output, SIR_MAXOUTPUT, buf->name, SIR_MAXNAME);
            first = false;
            name  = true;
        }

        bool wantpid = !_sir_bittest(opts, SIRO_NOPID) && _sir_validstrnofail(buf->pid);
        bool wanttid = !_sir_bittest(opts, SIRO_NOTID) && _sir_validstrnofail(buf->tid);

        if (wantpid || wanttid) {
            if (name)
                (void)_sir_strncat(buf->output, SIR_MAXOUTPUT, SIR_PIDPREFIX, 1);
            else if (!first)
                (void)_sir_strncat(buf->output, SIR_MAXOUTPUT, " ", 1);

            if (wantpid)
                (void)_sir_strncat(buf->output, SIR_MAXOUTPUT, buf->pid, SIR_MAXPID);

            if (wanttid) {
                if (wantpid)
                    (void)_sir_strncat(buf->output, SIR_MAXOUTPUT, SIR_PIDSEPARATOR, 1);
                (void)_sir_strncat(buf->output, SIR_MAXOUTPUT, buf->tid, SIR_MAXPID);
            }

            if (name)
                (void)_sir_strncat(buf->output, SIR_MAXOUTPUT, SIR_PIDSUFFIX, 1);

            first = false;
        }

        if (!first)
            (void)_sir_strncat(buf->output, SIR_MAXOUTPUT, ": ", 2);

        (void)_sir_strncat(buf->output, SIR_MAXOUTPUT, buf->message, SIR_MAXMESSAGE);

        if (styling)
            (void)_sir_strncat(buf->output, SIR_MAXOUTPUT, SIR_ESC_RST, SIR_MAXSTYLE);

#if defined(SIR_USE_EOL_CRLF)
        (void)_sir_strncat(buf->output, SIR_MAXOUTPUT, SIR_EOL, 2);
#else
        (void)_sir_strncat(buf->output, SIR_MAXOUTPUT, SIR_EOL, 1);
#endif

        buf->output_len = strnlen(buf->output, SIR_MAXOUTPUT);

        return buf->output;
    }

    return NULL;
}

// Assembly:
subq $0x28, %rsp
movb %dil, %al
andb $0x1, %al
movb %al, 0x1f(%rsp)
movl %esi, 0x18(%rsp)
movq %rdx, 0x10(%rsp)
movq 0x10(%rsp), %rdi
movl $0x1, %esi
leaq 0x545d(%rip), %rdx      # 0x113d4
leaq 0x5118(%rip), %rcx      # 0x11096
movl $0x30d, %r8d            # imm = 0x30D
callq 0x8f70
testb $0x1, %al
jne 0xbf92
jmp 0xc44e
movb $0x1, 0xf(%rsp)
movq 0x10(%rsp), %rdi
addq $0x1070, %rdi           # imm = 0x1070
callq 0x9e20
testb $0x1, 0x1f(%rsp)
je 0xbfcf
movq 0x10(%rsp), %rdi
addq $0x1070, %rdi           # imm = 0x1070
movq 0x10(%rsp), %rdx
movl $0x10e7, %esi           # imm = 0x10E7
movl $0x2b, %ecx
callq 0x8530
movl 0x18(%rsp), %edi
movl $0x100, %esi            # imm = 0x100
callq 0xbf30
testb $0x1, %al
jne 0xc042
movq 0x10(%rsp), %rdi
addq $0x1070, %rdi           # imm = 0x1070
movq 0x10(%rsp), %rax
movq 0x30(%rax), %rdx
movl $0x10e7, %esi           # imm = 0x10E7
movl $0x40, %ecx
callq 0x8530
movb $0x0, 0xf(%rsp)
movl 0x18(%rsp), %edi
movl $0x200, %esi            # imm = 0x200
callq 0xbf30
testb $0x1, %al
jne 0xc040
movq 0x10(%rsp), %rdi
addq $0x1070, %rdi           # imm = 0x1070
movq 0x10(%rsp), %rdx
addq $0x38, %rdx
movl $0x10e7, %esi           # imm = 0x10E7
movl $0x5, %ecx
callq 0x8530
jmp 0xc042
movl 0x18(%rsp), %edi
movl $0x400, %esi            # imm = 0x400
callq 0xbf30
testb $0x1, %al
jne 0xc0d0
movq 0x10(%rsp), %rax
movq 0x40(%rax), %rdi
xorl %esi, %esi
leaq 0x536e(%rip), %rdx      # 0x113d4
leaq 0x5029(%rip), %rcx      # 0x11096
movl $0x31f, %r8d            # imm = 0x31F
callq 0xa720
testb $0x1, %al
jne 0xc07e
jmp 0xc0d0
testb $0x1, 0xf(%rsp)
jne 0xc0a7
movq 0x10(%rsp), %rdi
addq $0x1070, %rdi           # imm = 0x1070
movl $0x10e7, %esi           # imm = 0x10E7
leaq 0x5346(%rip), %rdx      # 0x113e3
movl $0x1, %ecx
callq 0x8530
movq 0x10(%rsp), %rdi
addq $0x1070, %rdi           # imm = 0x1070
movq 0x10(%rsp), %rax
movq 0x40(%rax), %rdx
movl $0x10e7, %esi           # imm = 0x10E7
movl $0x100, %ecx            # imm = 0x100
callq 0x8530
movb $0x0, 0xf(%rsp)
movl 0x18(%rsp), %edi
movl $0x800, %esi            # imm = 0x800
callq 0xbf30
testb $0x1, %al
jne 0xc134
testb $0x1, 0xf(%rsp)
jne 0xc10b
movq 0x10(%rsp), %rdi
addq $0x1070, %rdi           # imm = 0x1070
movl $0x10e7, %esi           # imm = 0x10E7
leaq 0x52e2(%rip), %rdx      # 0x113e3
movl $0x1, %ecx
callq 0x8530
movq 0x10(%rsp), %rdi
addq $0x1070, %rdi           # imm = 0x1070
movq 0x10(%rsp), %rax
movq 0x50(%rax), %rdx
movl $0x10e7, %esi           # imm = 0x10E7
movl $0x7, %ecx
callq 0x8530
movb $0x0, 0xf(%rsp)
movb $0x0, 0xe(%rsp)
movl 0x18(%rsp), %edi
movl $0x1000, %esi           # imm = 0x1000
callq 0xbf30
testb $0x1, %al
jne 0xc1d0
movq 0x10(%rsp), %rax
movq 0x58(%rax), %rdi
xorl %esi, %esi
leaq 0x5273(%rip), %rdx      # 0x113d4
leaq 0x4f2e(%rip), %rcx      # 0x11096
movl $0x32e, %r8d            # imm = 0x32E
callq 0xa720
testb $0x1, %al
jne 0xc179
jmp 0xc1d0
testb $0x1, 0xf(%rsp)
jne 0xc1a2
movq 0x10(%rsp), %rdi
addq $0x1070, %rdi           # imm = 0x1070
movl $0x10e7, %esi           # imm = 0x10E7
leaq 0x524b(%rip), %rdx      # 0x113e3
movl $0x1, %ecx
callq 0x8530
movq 0x10(%rsp), %rdi
addq $0x1070, %rdi           # imm = 0x1070
movq 0x10(%rsp), %rax
movq 0x58(%rax), %rdx
movl $0x10e7, %esi           # imm = 0x10E7
movl $0x20, %ecx
callq 0x8530
movb $0x0, 0xf(%rsp)
movb $0x1, 0xe(%rsp)
movl 0x18(%rsp), %edi
movl $0x2000, %esi           # imm = 0x2000
callq 0xbf30
movb %al, %cl
xorl %eax, %eax
testb $0x1, %cl
movb %al, 0xb(%rsp)
jne 0xc213
movq 0x10(%rsp), %rax
movq 0x48(%rax), %rdi
xorl %esi, %esi
leaq 0x51d7(%rip), %rdx      # 0x113d4
leaq 0x4e92(%rip), %rcx      # 0x11096
movl $0x336, %r8d            # imm = 0x336
callq 0xa720
movb %al, 0xb(%rsp)
movb 0xb(%rsp), %al
andb $0x1, %al
movb %al, 0xd(%rsp)
movl 0x18(%rsp), %edi
movl $0x4000, %esi           # imm = 0x4000
callq 0xbf30
movb %al, %cl
xorl %eax, %eax
testb $0x1, %cl
movb %al, 0xa(%rsp)
jne 0xc260
movq 0x10(%rsp), %rdi
addq $0x60, %rdi
xorl %esi, %esi
leaq 0x518a(%rip), %rdx      # 0x113d4
leaq 0x4e45(%rip), %rcx      # 0x11096
movl $0x337, %r8d            # imm = 0x337
callq 0xa720
movb %al, 0xa(%rsp)
movb 0xa(%rsp), %al
andb $0x1, %al
movb %al, 0xc(%rsp)
testb $0x1, 0xd(%rsp)
jne 0xc27c
testb $0x1, 0xc(%rsp)
je 0xc37f
testb $0x1, 0xe(%rsp)
je 0xc2a7
movq 0x10(%rsp), %rdi
addq $0x1070, %rdi           # imm = 0x1070
movl $0x10e7, %esi           # imm = 0x10E7
leaq 0x5145(%rip), %rdx      # 0x113e0
movl $0x1, %ecx
callq 0x8530
jmp 0xc2d2
testb $0x1, 0xf(%rsp)
jne 0xc2d0
movq 0x10(%rsp), %rdi
addq $0x1070, %rdi           # imm = 0x1070
movl $0x10e7, %esi           # imm = 0x10E7
leaq 0x511d(%rip), %rdx      # 0x113e3
movl $0x1, %ecx
callq 0x8530
jmp 0xc2d2
testb $0x1, 0xd(%rsp)
je 0xc2fd
movq 0x10(%rsp), %rdi
addq $0x1070, %rdi           # imm = 0x1070
movq 0x10(%rsp), %rax
movq 0x48(%rax), %rdx
movl $0x10e7, %esi           # imm = 0x10E7
movl $0x10, %ecx
callq 0x8530
testb $0x1, 0xc(%rsp)
je 0xc351
testb $0x1, 0xd(%rsp)
je 0xc32d
movq 0x10(%rsp), %rdi
addq $0x1070, %rdi           # imm = 0x1070
movl $0x10e7, %esi           # imm = 0x10E7
leaq 0x4032(%rip), %rdx      # 0x10355
movl $0x1, %ecx
callq 0x8530
movq 0x10(%rsp), %rdi
addq $0x1070, %rdi           # imm = 0x1070
movq 0x10(%rsp), %rdx
addq $0x60, %rdx
movl $0x10e7, %esi           # imm = 0x10E7
movl $0x10, %ecx
callq 0x8530
testb $0x1, 0xe(%rsp)
je 0xc37a
movq 0x10(%rsp), %rdi
addq $0x1070, %rdi           # imm = 0x1070
movl $0x10e7, %esi           # imm = 0x10E7
leaq 0x5190(%rip), %rdx      # 0x11500
movl $0x1, %ecx
callq 0x8530
movb $0x0, 0xf(%rsp)
testb $0x1, 0xf(%rsp)
jne 0xc3a8
movq 0x10(%rsp), %rdi
addq $0x1070, %rdi           # imm = 0x1070
movl $0x10e7, %esi           # imm = 0x10E7
leaq 0x5044(%rip), %rdx      # 0x113e2
movl $0x2, %ecx
callq 0x8530
movq 0x10(%rsp), %rdi
addq $0x1070, %rdi           # imm = 0x1070
movq 0x10(%rsp), %rdx
addq $0x70, %rdx
movl $0x10e7, %esi           # imm = 0x10E7
movl $0x1000, %ecx           # imm = 0x1000
callq 0x8530
testb $0x1, 0x1f(%rsp)
je 0xc3f5
movq 0x10(%rsp), %rdi
addq $0x1070, %rdi           # imm = 0x1070
movl $0x10e7, %esi           # imm = 0x10E7
leaq 0x4ffa(%rip), %rdx      # 0x113e5
movl $0x2b, %ecx
callq 0x8530
movq 0x10(%rsp), %rdi
addq $0x1070, %rdi           # imm = 0x1070
movl $0x10e7, %esi           # imm = 0x10E7
leaq 0x451b(%rip), %rdx      # 0x10928
movl $0x1, %ecx
callq 0x8530
movq 0x10(%rsp), %rdi
addq $0x1070, %rdi           # imm = 0x1070
movl $0x10e7, %esi           # imm = 0x10E7
callq 0x21d0
movq %rax, %rcx
movq 0x10(%rsp), %rax
movq %rcx, 0x2158(%rax)
movq 0x10(%rsp), %rax
addq $0x1070, %rax           # imm = 0x1070
movq %rax, 0x20(%rsp)
jmp 0xc457
movq $0x0, 0x20(%rsp)
movq 0x20(%rsp), %rax
addq $0x28, %rsp
retq
nopw %cs:(%rax,%rax)