// File: /workspace/github_c_makefile_star2_O2/jeff-1amstudios[P]carmageddon-1-cheat-code-disassembly/src/log/zf_log.c
// Function: zf_log_write_imp
static void _zf_log_write_imp(
        const zf_log_spec *log,
        const src_location *const src, const mem_block *const mem,
        const int lvl, const char *const tag, const char *const fmt, va_list va)
{
    zf_log_message msg;
    char buf[ZF_LOG_BUF_SZ];
    const unsigned mask = log->output->mask;
    msg.lvl = lvl;
    msg.tag = tag;
    g_buffer_cb(&msg, buf);
    if (ZF_LOG_PUT_CTX & mask)
    {
        put_ctx(&msg);
    }
    if (ZF_LOG_PUT_TAG & mask)
    {
        put_tag(&msg, tag);
    }
    if (0 != src && ZF_LOG_PUT_SRC & mask)
    {
        put_src(&msg, src);
    }
    if (ZF_LOG_PUT_MSG & mask)
    {
        put_msg(&msg, fmt, va);
    }
    log->output->callback(&msg, log->output->arg);
    if (0 != mem && ZF_LOG_PUT_MSG & mask)
    {
        output_mem(log, &msg, mem);
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x2f8, %rsp            # imm = 0x2F8
movq %r9, 0x48(%rsp)
movq %r8, %rbp
movq %rdx, %r15
movq %rsi, %r14
movq %rdi, 0x68(%rsp)
movq 0x8(%rdi), %rax
movl (%rax), %r12d
movl %ecx, 0x8(%rsp)
movq %r8, 0x10(%rsp)
leaq 0xf0(%rsp), %r13
movq %r13, 0x18(%rsp)
movq %r13, 0x28(%rsp)
leaq 0x2ee(%rsp), %rbx
movq %rbx, 0x20(%rsp)
testb $0x1, %r12b
je 0x303c
leaq 0xb0(%rsp), %r13
movq %r13, %rdi
xorl %esi, %esi
callq 0x20e0
movl 0x8d38(%rip), %eax      # 0xbb18
cmpl $0x3fffffff, %eax       # imm = 0x3FFFFFFF
movq %r15, 0x60(%rsp)
movq %r14, 0x50(%rsp)
ja 0x2e6b
pushq $0x1
popq %rax
lock
xaddl %eax, 0x8d1c(%rip)      # 0xbb18
cmpl $0x3fffffff, %eax       # imm = 0x3FFFFFFF
ja 0x2e64
movq 0x8fee(%rip), %rax      # 0xbdf8
cmpq 0xb0(%rsp), %rax
jne 0x2e59
movq 0x901d(%rip), %rax      # 0xbe38
movq %rax, 0xa0(%rsp)
movups 0x8ffe(%rip), %xmm0     # 0xbe28
movaps %xmm0, 0x90(%rsp)
movups 0x8fdf(%rip), %xmm0     # 0xbe18
movaps %xmm0, 0x80(%rsp)
movups 0x8fc0(%rip), %xmm0     # 0xbe08
movaps %xmm0, 0x70(%rsp)
lock
decl 0x8cc4(%rip)            # 0xbb18
jmp 0x2ee4
lock
orl $0x40000000, 0x8cb4(%rip) # imm = 0x40000000
lock
decl 0x8cad(%rip)            # 0xbb18
leaq 0xb0(%rsp), %rdi
leaq 0x70(%rsp), %rsi
callq 0x2060
movl $0xc0000000, %ecx       # imm = 0xC0000000
movl $0x40000000, %eax       # imm = 0x40000000
lock
cmpxchgl %ecx, 0x8c89(%rip)      # 0xbb18
jne 0x2ee4
movups 0xb0(%rsp), %xmm0
movups %xmm0, 0x8f58(%rip)     # 0xbdf8
movups 0x70(%rsp), %xmm0
movups 0x80(%rsp), %xmm1
movups 0x90(%rsp), %xmm2
movups %xmm0, 0x8f4c(%rip)     # 0xbe08
movups %xmm1, 0x8f55(%rip)     # 0xbe18
movups %xmm2, 0x8f5e(%rip)     # 0xbe28
movq 0xa0(%rsp), %rax
movq %rax, 0x8f5f(%rip)      # 0xbe38
lock
andl $0x3fffffff, 0x8c34(%rip) # imm = 0x3FFFFFFF
movl %r12d, 0x58(%rsp)
movq 0xb8(%rsp), %r14
callq 0x20b0
movl %eax, %r15d
movl $0xba, %edi
xorl %eax, %eax
callq 0x2180
movb $0x20, 0xef(%rsp)
movl 0x8(%rsp), %ecx
decl %ecx
cmpl $0x6, %ecx
jae 0x339e
movq %rax, %rdi
shll $0x3, %ecx
movabsq $0x464557494456, %r8    # imm = 0x464557494456
shrq %cl, %r8
movl $0x3e8, %ecx            # imm = 0x3E8
movl %r14d, %eax
xorl %edx, %edx
divl %ecx
movl %eax, %r14d
leaq 0xed(%rsp), %rsi
movb %r8b, 0x1(%rsi)
movb $0x20, %bl
movb %bl, (%rsi)
callq 0x3869
movb %bl, -0x1(%rax)
leaq -0x1(%rax), %rsi
movl %r15d, %edi
callq 0x3869
movb %bl, -0x1(%rax)
leaq -0x1(%rax), %rcx
pushq $0x3
popq %rsi
pushq $0x30
popq %r15
movl %r14d, %edi
movl %r15d, %edx
callq 0x3887
movb $0x2e, -0x1(%rax)
leaq -0x1(%rax), %rcx
movl 0x70(%rsp), %edi
pushq $0x2
popq %r14
movl %r14d, %esi
movl %r15d, %edx
callq 0x3887
movb $0x3a, %r12b
movb %r12b, -0x1(%rax)
leaq -0x1(%rax), %rcx
movl 0x74(%rsp), %edi
movl %r14d, %esi
movl %r15d, %edx
callq 0x3887
movb %r12b, -0x1(%rax)
leaq -0x1(%rax), %rcx
movl 0x78(%rsp), %edi
movl %r14d, %esi
movl %r15d, %edx
callq 0x3887
movb %bl, -0x1(%rax)
leaq -0x1(%rax), %rcx
movl 0x7c(%rsp), %edi
movl %r14d, %esi
movl %r15d, %edx
callq 0x3887
movb $0x2d, -0x1(%rax)
leaq -0x1(%rax), %rcx
movl 0x80(%rsp), %edi
incl %edi
movl %r14d, %esi
movl %r15d, %edx
callq 0x3887
movq 0x20(%rsp), %rbx
movq 0x28(%rsp), %r14
movq %rbx, %rcx
subq %r14, %rcx
subq %rax, %r13
addq $0x40, %r13
cmpq %rcx, %r13
cmovgeq %rcx, %r13
movq %r14, %rdi
movq %rax, %rsi
movq %r13, %rdx
callq 0x21a0
addq %r14, %r13
movq %r13, 0x28(%rsp)
movq 0x60(%rsp), %r15
movl 0x58(%rsp), %r12d
movq 0x50(%rsp), %r14
testb $0x2, %r12b
je 0x30f8
movq %r13, 0x30(%rsp)
movq 0x8d96(%rip), %rax      # 0xbde8
testq %rax, %rax
je 0x307d
cmpq %r13, %rbx
je 0x307d
movb (%rax), %cl
movb %cl, (%r13)
testb %cl, %cl
je 0x307d
movq 0x20(%rsp), %rbx
movq 0x28(%rsp), %r13
incq %r13
movq %r13, 0x28(%rsp)
incq %rax
jmp 0x3057
testq %rbp, %rbp
je 0x30cc
cmpb $0x0, (%rbp)
je 0x30cc
movq 0x28(%rsp), %rax
cmpq %rax, 0x30(%rsp)
je 0x30c5
cmpq %rax, 0x20(%rsp)
jbe 0x30c5
leaq 0x1(%rax), %rcx
movq %rcx, 0x28(%rsp)
movb $0x2e, (%rax)
movq %rcx, %rax
jmp 0x30c5
movb (%rbp), %cl
movb %cl, (%rax)
testb %cl, %cl
je 0x30cc
movq 0x28(%rsp), %rax
incq %rax
movq %rax, 0x28(%rsp)
incq %rbp
cmpq %rax, 0x20(%rsp)
jne 0x30ac
movq 0x20(%rsp), %rax
movq 0x28(%rsp), %r13
movq %r13, 0x38(%rsp)
cmpq %r13, 0x30(%rsp)
je 0x30f8
cmpq %r13, %rax
jbe 0x30f8
leaq 0x1(%r13), %rax
movq %rax, 0x28(%rsp)
movb $0x20, (%r13)
movq %rax, %r13
testq %r14, %r14
sete %al
testb $0x4, %r12b
sete %cl
orb %al, %cl
jne 0x31ea
movq (%r14), %rax
testq %rax, %rax
leaq 0x4101(%rip), %rdi      # 0x721b
cmovneq %rax, %rdi
movq 0x20(%rsp), %rdx
movq %r13, %rsi
callq 0x390f
movq %rax, 0x28(%rsp)
movq 0x20(%rsp), %rbp
cmpq %rax, %rbp
jbe 0x314b
movq %rax, %rcx
incq %rcx
movq %rcx, 0x28(%rsp)
movb $0x40, (%rax)
movq %rcx, %rax
movq 0x8(%r14), %rdi
leaq 0x1(%rdi), %rcx
movzbl -0x1(%rcx), %edx
cmpl $0x2f, %edx
je 0x3167
cmpl $0x5c, %edx
je 0x3167
testl %edx, %edx
jne 0x316a
jmp 0x316f
movq %rcx, %rdi
incq %rcx
jmp 0x3153
movq %r14, %rbx
movq %rax, %rsi
movq %rbp, %rdx
callq 0x390f
movq %rax, %r14
cmpq %rax, %rbp
jbe 0x3197
movq %r14, %rax
incq %rax
movq %rax, 0x28(%rsp)
movb $0x3a, (%r14)
movq %rax, %r14
movl 0x10(%rbx), %edi
leaq 0xc0(%rsp), %r13
xorl %esi, %esi
xorl %edx, %edx
movq %r13, %rcx
callq 0x3887
movq %rbp, %rcx
subq %r14, %rcx
subq %rax, %r13
cmpq %rcx, %r13
cmovgeq %rcx, %r13
movq %r14, %rdi
movq %rax, %rsi
movq %r13, %rdx
callq 0x21a0
addq %r14, %r13
movq %r13, 0x28(%rsp)
cmpq %r13, %rbp
jbe 0x31ea
leaq 0x1(%r13), %rax
movq %rax, 0x28(%rsp)
movb $0x20, (%r13)
movq %rax, %r13
testb $0x8, %r12b
je 0x323a
movq 0x330(%rsp), %rcx
movq %r13, 0x40(%rsp)
movq 0x20(%rsp), %rsi
subq %r13, %rsi
incq %rsi
movq %r13, %rdi
movq 0x48(%rsp), %rdx
callq 0x2080
testl %eax, %eax
jle 0x323a
movl %eax, %eax
movq 0x20(%rsp), %rcx
movq 0x28(%rsp), %rdx
movq %rcx, %rsi
subq %rdx, %rsi
addq %rax, %rdx
cmpq %rax, %rsi
cmovleq %rcx, %rdx
movq %rdx, 0x28(%rsp)
testb $0x8, %r12b
sete %bl
movq 0x68(%rsp), %rax
movq 0x8(%rax), %rax
movq 0x8(%rax), %rsi
leaq 0x8(%rsp), %rdi
callq *0x10(%rax)
testq %r15, %r15
sete %al
orb %bl, %al
jne 0x329e
movq (%r15), %rbx
testq %rbx, %rbx
je 0x329e
movl 0x8(%r15), %ecx
testq %rcx, %rcx
je 0x329e
movq 0x68(%rsp), %rax
movq (%rax), %rax
movl (%rax), %edx
movq 0x40(%rsp), %rbp
leaq (,%rdx,2), %rax
addq %rbp, %rax
movq %rdx, 0x48(%rsp)
addq %rdx, %rax
addq $0x2, %rax
cmpq %rax, 0x20(%rsp)
jae 0x32b0
addq $0x2f8, %rsp            # imm = 0x2F8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
addq %rbx, %rcx
movq 0x48(%rsp), %rax
leaq (%rax,%rax), %rdx
leaq 0x2(,%rax,2), %rax
addq %rbp, %rax
movq %rax, 0xa8(%rsp)
addq $0x2, %rdx
movq %rdx, 0x50(%rsp)
movq %rcx, 0x60(%rsp)
movq %rbp, 0x58(%rsp)
cmpq %rcx, %rbx
je 0x329e
movq %rcx, %rax
subq %rbx, %rax
movq 0x48(%rsp), %rdx
leaq (%rbx,%rdx), %r15
cmpq %rdx, %rax
cmovleq %rcx, %r15
xorl %r12d, %r12d
movq 0xa8(%rsp), %r13
cmpq %r15, %rbx
je 0x335d
movzbl (%rbx), %r14d
movl %r14d, %eax
shrl $0x4, %eax
leaq 0x3f42(%rip), %rcx      # 0x7260
movb (%rax,%rcx), %al
movb %al, (%rbp)
movl %r14d, %eax
andl $0xf, %eax
movb (%rax,%rcx), %al
movb %al, 0x1(%rbp)
callq 0x2250
movq (%rax), %rax
movzwl (%rax,%r14,2), %eax
btl $0xe, %eax
pushq $0x3f
popq %rax
jae 0x3349
movl %r14d, %eax
addq $0x2, %rbp
movb %al, (%r13)
incq %r13
incq %rbx
addq $0x2, %r12
jmp 0x3308
movq 0x58(%rsp), %rbp
movq 0x50(%rsp), %rax
cmpq %r12, %rax
je 0x3377
movb $0x20, (%rbp,%r12)
incq %r12
jmp 0x3367
movq %r13, 0x28(%rsp)
movq 0x68(%rsp), %rax
movq 0x8(%rax), %rax
movq 0x8(%rax), %rsi
leaq 0x8(%rsp), %rdi
callq *0x10(%rax)
movq %r15, %rbx
movq 0x60(%rsp), %rcx
jmp 0x32e2
leaq 0x3e77(%rip), %rdi      # 0x721c
leaq 0x3e89(%rip), %rsi      # 0x7235
leaq 0x3e93(%rip), %rcx      # 0x7246
movl $0x2b9, %edx            # imm = 0x2B9
callq 0x20f0