// File: /workspace/github_c_makefile_star2_O0/neosploit[P]compiler/libfort/lib/fort.c
// Function: buffer_printf
FT_INTERNAL
int buffer_printf(f_string_buffer_t *buffer, size_t buffer_row, f_conv_context_t *cntx, size_t vis_width,
                  const char *content_style_tag, const char *reset_content_style_tag)
{
    const f_context_t *context = cntx->cntx;
    f_table_properties_t *props = context->table_properties;
    size_t row = context->row;
    size_t column = context->column;

    if (buffer == NULL || buffer->str.data == NULL
        || buffer_row >= buffer_text_visible_height(buffer)) {
        return -1;
    }

    size_t content_width = buffer_text_visible_width(buffer);
    if (vis_width < content_width)
        return -1;

    size_t left = 0;
    size_t right = 0;
    switch (get_cell_property_hierarchically(props, row, column, FT_CPROP_TEXT_ALIGN)) {
        case FT_ALIGNED_LEFT:
            left = 0;
            right = (vis_width) - content_width;
            break;
        case FT_ALIGNED_CENTER:
            left = ((vis_width) - content_width) / 2;
            right = ((vis_width) - content_width) - left;
            break;
        case FT_ALIGNED_RIGHT:
            left = (vis_width) - content_width;
            right = 0;
            break;
        default:
            assert(0);
            break;
    }

    size_t  written = 0;
    int tmp = 0;
    ptrdiff_t str_it_width = 0;
    const void *beg = NULL;
    const void *end = NULL;
    buffer_substring(buffer, buffer_row, &beg, &end, &str_it_width);
    if (beg == NULL || end == NULL)
        return -1;
    if (str_it_width < 0 || content_width < (size_t)str_it_width)
        return -1;

    size_t padding = content_width - (size_t)str_it_width;

    CHCK_RSLT_ADD_TO_WRITTEN(print_n_strings(cntx, left, FT_SPACE));
    CHCK_RSLT_ADD_TO_WRITTEN(print_n_strings(cntx, 1, content_style_tag));
    CHCK_RSLT_ADD_TO_WRITTEN(buffer_print_range(cntx, beg, end));
    CHCK_RSLT_ADD_TO_WRITTEN(print_n_strings(cntx, 1, reset_content_style_tag));
    CHCK_RSLT_ADD_TO_WRITTEN(print_n_strings(cntx, padding, FT_SPACE));
    CHCK_RSLT_ADD_TO_WRITTEN(print_n_strings(cntx, right, FT_SPACE));
    return (int)written;

clear:
    return -1;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xb0, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
movq %r8, -0x30(%rbp)
movq %r9, -0x38(%rbp)
movq -0x20(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x40(%rbp)
movq -0x40(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x48(%rbp)
movq -0x40(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x50(%rbp)
movq -0x40(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x58(%rbp)
cmpq $0x0, -0x10(%rbp)
je 0x1d576
movq -0x10(%rbp), %rax
cmpq $0x0, (%rax)
je 0x1d576
movq -0x18(%rbp), %rax
movq %rax, -0xa8(%rbp)
movq -0x10(%rbp), %rdi
callq 0x1b560
movq %rax, %rcx
movq -0xa8(%rbp), %rax
cmpq %rcx, %rax
jb 0x1d582
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x1d82d
movq -0x10(%rbp), %rdi
callq 0x1aa90
movq %rax, -0x60(%rbp)
movq -0x28(%rbp), %rax
cmpq -0x60(%rbp), %rax
jae 0x1d5a5
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x1d82d
movq $0x0, -0x68(%rbp)
movq $0x0, -0x70(%rbp)
movq -0x48(%rbp), %rdi
movq -0x50(%rbp), %rsi
movq -0x58(%rbp), %rdx
movl $0x2, %ecx
callq 0x1a550
movl %eax, %ecx
movl %ecx, -0xac(%rbp)
testl %eax, %eax
je 0x1d5f3
jmp 0x1d5d9
movl -0xac(%rbp), %eax
subl $0x1, %eax
je 0x1d609
jmp 0x1d5e6
movl -0xac(%rbp), %eax
subl $0x2, %eax
je 0x1d62a
jmp 0x1d640
movq $0x0, -0x68(%rbp)
movq -0x28(%rbp), %rax
subq -0x60(%rbp), %rax
movq %rax, -0x70(%rbp)
jmp 0x1d65f
movq -0x28(%rbp), %rax
subq -0x60(%rbp), %rax
shrq %rax
movq %rax, -0x68(%rbp)
movq -0x28(%rbp), %rax
subq -0x60(%rbp), %rax
subq -0x68(%rbp), %rax
movq %rax, -0x70(%rbp)
jmp 0x1d65f
movq -0x28(%rbp), %rax
subq -0x60(%rbp), %rax
movq %rax, -0x68(%rbp)
movq $0x0, -0x70(%rbp)
jmp 0x1d65f
leaq 0x5e37(%rip), %rdi      # 0x2347e
leaq 0x5548(%rip), %rsi      # 0x22b96
movl $0x1a91, %edx           # imm = 0x1A91
leaq 0x6bd5(%rip), %rcx      # 0x2422f
callq 0x7120
movq $0x0, -0x78(%rbp)
movl $0x0, -0x7c(%rbp)
movq $0x0, -0x88(%rbp)
movq $0x0, -0x90(%rbp)
movq $0x0, -0x98(%rbp)
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
leaq -0x90(%rbp), %rdx
leaq -0x98(%rbp), %rcx
leaq -0x88(%rbp), %r8
callq 0x1d840
cmpq $0x0, -0x90(%rbp)
je 0x1d6c5
cmpq $0x0, -0x98(%rbp)
jne 0x1d6d1
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x1d82d
cmpq $0x0, -0x88(%rbp)
jl 0x1d6e8
movq -0x60(%rbp), %rax
cmpq -0x88(%rbp), %rax
jae 0x1d6f4
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x1d82d
movq -0x60(%rbp), %rax
subq -0x88(%rbp), %rax
movq %rax, -0xa0(%rbp)
movq -0x20(%rbp), %rdi
movq -0x68(%rbp), %rsi
leaq 0x4f14(%rip), %rdx      # 0x22629
callq 0x19700
movl %eax, -0x7c(%rbp)
cmpl $0x0, -0x7c(%rbp)
jge 0x1d728
jmp 0x1d826
movslq -0x7c(%rbp), %rax
addq -0x78(%rbp), %rax
movq %rax, -0x78(%rbp)
jmp 0x1d736
movq -0x20(%rbp), %rdi
movq -0x30(%rbp), %rdx
movl $0x1, %esi
callq 0x19700
movl %eax, -0x7c(%rbp)
cmpl $0x0, -0x7c(%rbp)
jge 0x1d756
jmp 0x1d826
movslq -0x7c(%rbp), %rax
addq -0x78(%rbp), %rax
movq %rax, -0x78(%rbp)
jmp 0x1d764
movq -0x20(%rbp), %rdi
movq -0x90(%rbp), %rsi
movq -0x98(%rbp), %rdx
callq 0x1d9a0
movl %eax, -0x7c(%rbp)
cmpl $0x0, -0x7c(%rbp)
jge 0x1d789
jmp 0x1d826
movslq -0x7c(%rbp), %rax
addq -0x78(%rbp), %rax
movq %rax, -0x78(%rbp)
jmp 0x1d797
movq -0x20(%rbp), %rdi
movq -0x38(%rbp), %rdx
movl $0x1, %esi
callq 0x19700
movl %eax, -0x7c(%rbp)
cmpl $0x0, -0x7c(%rbp)
jge 0x1d7b4
jmp 0x1d826
movslq -0x7c(%rbp), %rax
addq -0x78(%rbp), %rax
movq %rax, -0x78(%rbp)
jmp 0x1d7c2
movq -0x20(%rbp), %rdi
movq -0xa0(%rbp), %rsi
leaq 0x4e55(%rip), %rdx      # 0x22629
callq 0x19700
movl %eax, -0x7c(%rbp)
cmpl $0x0, -0x7c(%rbp)
jge 0x1d7e4
jmp 0x1d826
movslq -0x7c(%rbp), %rax
addq -0x78(%rbp), %rax
movq %rax, -0x78(%rbp)
jmp 0x1d7f2
movq -0x20(%rbp), %rdi
movq -0x70(%rbp), %rsi
leaq 0x4e28(%rip), %rdx      # 0x22629
callq 0x19700
movl %eax, -0x7c(%rbp)
cmpl $0x0, -0x7c(%rbp)
jge 0x1d811
jmp 0x1d826
movslq -0x7c(%rbp), %rax
addq -0x78(%rbp), %rax
movq %rax, -0x78(%rbp)
movq -0x78(%rbp), %rax
movl %eax, -0x4(%rbp)
jmp 0x1d82d
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
movl -0x4(%rbp), %eax
addq $0xb0, %rsp
popq %rbp
retq
nopl (%rax)