// File: /workspace/github_c_makefile_star2_O2/janet-lang[P]janet/src/core/pp.c
// Function: janet_pretty_one
static void janet_pretty_one(struct pretty *S, Janet x, int is_dict_value) {
    /* Add to seen */
    switch (janet_type(x)) {
        case JANET_NIL:
        case JANET_NUMBER:
        case JANET_SYMBOL:
        case JANET_BOOLEAN:
            break;
        default: {
            Janet seenid = janet_table_get(&S->seen, x);
            if (janet_checktype(seenid, JANET_NUMBER)) {
                if (S->flags & JANET_PRETTY_COLOR) {
                    janet_buffer_push_cstring(S->buffer, janet_cycle_color);
                }
                janet_buffer_push_cstring(S->buffer, "<cycle ");
                integer_to_string_b(S->buffer, janet_unwrap_integer(seenid));
                janet_buffer_push_u8(S->buffer, '>');
                if (S->flags & JANET_PRETTY_COLOR) {
                    janet_buffer_push_cstring(S->buffer, "\x1B[0m");
                }
                return;
            } else {
                janet_table_put(&S->seen, x, janet_wrap_integer(S->seen.count));
                break;
            }
        }
    }

    switch (janet_type(x)) {
        default: {
            const char *color = janet_pretty_colors[janet_type(x)];
            if (color && (S->flags & JANET_PRETTY_COLOR)) {
                janet_buffer_push_cstring(S->buffer, color);
            }
            if (janet_checktype(x, JANET_BUFFER) && janet_unwrap_buffer(x) == S->buffer) {
                janet_buffer_ensure(S->buffer, S->buffer->count + S->bufstartlen * 4 + 3, 1);
                janet_buffer_push_u8(S->buffer, '@');
                janet_escape_string_impl(S->buffer, S->buffer->data, S->bufstartlen);
            } else {
                janet_description_b(S->buffer, x);
            }
            if (color && (S->flags & JANET_PRETTY_COLOR)) {
                janet_buffer_push_cstring(S->buffer, "\x1B[0m");
            }
            break;
        }
        case JANET_ARRAY:
        case JANET_TUPLE: {
            int32_t i = 0, len = 0;
            const Janet *arr = NULL;
            int isarray = janet_checktype(x, JANET_ARRAY);
            janet_indexed_view(x, &arr, &len);
            int hasbrackets = !isarray && (janet_tuple_flag(arr) & JANET_TUPLE_FLAG_BRACKETCTOR);
            const char *startstr = isarray ? "@[" : hasbrackets ? "[" : "(";
            const char endchar = isarray ? ']' : hasbrackets ? ']' : ')';
            janet_buffer_push_cstring(S->buffer, startstr);
            S->depth--;
            S->indent += 2;
            if (S->depth == 0) {
                janet_buffer_push_cstring(S->buffer, "...");
            } else {
                if (!isarray && !(S->flags & JANET_PRETTY_ONELINE) && len >= JANET_PRETTY_IND_ONELINE)
                    janet_buffer_push_u8(S->buffer, ' ');
                if (is_dict_value && len >= JANET_PRETTY_IND_ONELINE) print_newline(S, 0);
                if (len > JANET_PRETTY_ARRAY_LIMIT && !(S->flags & JANET_PRETTY_NOTRUNC)) {
                    for (i = 0; i < 3; i++) {
                        if (i) print_newline(S, 0);
                        janet_pretty_one(S, arr[i], 0);
                    }
                    print_newline(S, 0);
                    janet_buffer_push_cstring(S->buffer, "...");
                    for (i = 0; i < 3; i++) {
                        print_newline(S, 0);
                        janet_pretty_one(S, arr[len - 3 + i], 0);
                    }
                } else {
                    for (i = 0; i < len; i++) {
                        if (i) print_newline(S, len < JANET_PRETTY_IND_ONELINE);
                        janet_pretty_one(S, arr[i], 0);
                    }
                }
            }
            S->indent -= 2;
            S->depth++;
            janet_buffer_push_u8(S->buffer, endchar);
            break;
        }
        case JANET_STRUCT:
        case JANET_TABLE: {
            int istable = janet_checktype(x, JANET_TABLE);

            /* For object-like tables, print class name */
            if (istable) {
                JanetTable *t = janet_unwrap_table(x);
                JanetTable *proto = t->proto;
                janet_buffer_push_cstring(S->buffer, "@");
                if (NULL != proto) {
                    Janet name = janet_table_get(proto, janet_ckeywordv("_name"));
                    const uint8_t *n;
                    int32_t len;
                    if (janet_bytes_view(name, &n, &len)) {
                        if (S->flags & JANET_PRETTY_COLOR) {
                            janet_buffer_push_cstring(S->buffer, janet_class_color);
                        }
                        janet_buffer_push_bytes(S->buffer, n, len);
                        if (S->flags & JANET_PRETTY_COLOR) {
                            janet_buffer_push_cstring(S->buffer, "\x1B[0m");
                        }
                    }
                }
            } else {
                JanetStruct st = janet_unwrap_struct(x);
                JanetStruct proto = janet_struct_proto(st);
                if (NULL != proto) {
                    Janet name = janet_struct_get(proto, janet_ckeywordv("_name"));
                    const uint8_t *n;
                    int32_t len;
                    if (janet_bytes_view(name, &n, &len)) {
                        if (S->flags & JANET_PRETTY_COLOR) {
                            janet_buffer_push_cstring(S->buffer, janet_class_color);
                        }
                        janet_buffer_push_bytes(S->buffer, n, len);
                        if (S->flags & JANET_PRETTY_COLOR) {
                            janet_buffer_push_cstring(S->buffer, "\x1B[0m");
                        }
                    }
                }
            }
            janet_buffer_push_cstring(S->buffer, "{");

            S->depth--;
            S->indent += 2;
            if (S->depth == 0) {
                janet_buffer_push_cstring(S->buffer, "...");
            } else {
                int32_t i = 0, len = 0, cap = 0;
                const JanetKV *kvs = NULL;
                janet_dictionary_view(x, &kvs, &len, &cap);
                if (!istable && !(S->flags & JANET_PRETTY_ONELINE) && len >= JANET_PRETTY_DICT_ONELINE)
                    janet_buffer_push_u8(S->buffer, ' ');
                if (is_dict_value && len >= JANET_PRETTY_DICT_ONELINE) print_newline(S, 0);
                int32_t ks_start = S->keysort_start;

                /* Ensure buffer is large enough to sort keys. */
                int truncated = 0;
                int64_t mincap = (int64_t) len + (int64_t) ks_start;
                if (mincap > INT32_MAX) {
                    truncated = 1;
                    len = 0;
                    mincap = ks_start;
                }

                if (S->keysort_capacity < mincap) {
                    if (mincap >= INT32_MAX / 2) {
                        S->keysort_capacity = INT32_MAX;
                    } else {
                        S->keysort_capacity = (int32_t)(mincap * 2);
                    }
                    S->keysort_buffer = janet_srealloc(S->keysort_buffer, sizeof(int32_t) * S->keysort_capacity);
                    if (NULL == S->keysort_buffer) {
                        JANET_OUT_OF_MEMORY;
                    }
                }

                janet_sorted_keys(kvs, cap, S->keysort_buffer == NULL ? NULL : S->keysort_buffer + ks_start);
                S->keysort_start += len;
                if (!(S->flags & JANET_PRETTY_NOTRUNC) && (len > JANET_PRETTY_DICT_LIMIT)) {
                    len = JANET_PRETTY_DICT_LIMIT;
                    truncated = 1;
                }

                for (i = 0; i < len; i++) {
                    if (i) print_newline(S, len < JANET_PRETTY_DICT_ONELINE);
                    int32_t j = S->keysort_buffer[i + ks_start];
                    janet_pretty_one(S, kvs[j].key, 0);
                    janet_buffer_push_u8(S->buffer, ' ');
                    janet_pretty_one(S, kvs[j].value, 1);
                }

                if (truncated) {
                    print_newline(S, 0);
                    janet_buffer_push_cstring(S->buffer, "...");
                }

                S->keysort_start = ks_start;
            }
            S->indent -= 2;
            S->depth++;
            janet_buffer_push_u8(S->buffer, '}');
            break;
        }
    }
    /* Remove from seen */
    janet_table_remove(&S->seen, x);
    return;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rsi, %r15
movq %rsi, %xmm0
movq %rsi, %r14
shrq $0x2f, %r14
movl %r14d, %eax
andl $0xf, %eax
xorl %r13d, %r13d
ucomisd %xmm0, %xmm0
movq %rdi, %rbx
cmovpl %eax, %r13d
cmpl $0x5, %r13d
ja 0x3c7d8
pushq $0x27
popq %rax
btl %r13d, %eax
jae 0x3c7d8
testb $0x1, 0x10(%rbx)
je 0x3c751
movl %r13d, %eax
leaq 0x27e0e(%rip), %rcx     # 0x64550
movslq (%rcx,%rax,4), %rsi
addq %rcx, %rsi
movq (%rbx), %rdi
callq 0x1614c
cmpl $0x1fffb, %r14d         # imm = 0x1FFFB
jne 0x3c79a
movq %r15, %rdi
callq 0x4b1f1
movq (%rbx), %rdi
cmpq %rdi, %rax
jne 0x3c79d
movl 0x10(%rdi), %eax
movl 0x14(%rbx), %ecx
leal (%rax,%rcx,4), %esi
addl $0x3, %esi
pushq $0x1
popq %rdx
callq 0x15f9b
movq (%rbx), %rdi
pushq $0x40
popq %rsi
callq 0x161be
movq (%rbx), %rdi
movq 0x18(%rdi), %rsi
movl 0x14(%rbx), %edx
callq 0x3c58f
jmp 0x3c7a5
movq (%rbx), %rdi
movq %r15, %rsi
callq 0x3b65f
testb $0x1, 0x10(%rbx)
je 0x3c7ba
movq (%rbx), %rdi
leaq 0x17c5d(%rip), %rsi     # 0x54412
callq 0x1614c
addq $0x28, %rbx
movq %rbx, %rdi
movq %r15, %rsi
callq 0x43d98
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl %edx, -0x40(%rbp)
leaq 0x28(%rbx), %r12
movq %r12, %rdi
movq %r15, %rsi
callq 0x43c35
movq %rax, %xmm0
ucomisd %xmm0, %xmm0
setp %cl
movabsq $0x7800000000000, %rdx  # imm = 0x7800000000000
testq %rdx, %rax
setne %al
testb %al, %cl
jne 0x3c868
movsd %xmm0, -0x40(%rbp)
testb $0x1, 0x10(%rbx)
je 0x3c824
movq (%rbx), %rdi
leaq 0x27d71(%rip), %rsi     # 0x64590
callq 0x1614c
movq (%rbx), %rdi
leaq 0x27e69(%rip), %rsi     # 0x64697
callq 0x1614c
movq (%rbx), %r14
cvttsd2si -0x40(%rbp), %r15d
pushq $0x40
popq %rsi
movq %r14, %rdi
callq 0x16095
movslq 0x10(%r14), %rdi
addq 0x18(%r14), %rdi
testl %r15d, %r15d
je 0x3c944
jle 0x3c952
negl %r15d
xorl %ecx, %ecx
jmp 0x3c95b
cvtsi2sdl 0x38(%rbx), %xmm0
callq 0x4b471
movq %r12, %rdi
movq %r15, %rsi
movq %rax, %rdx
callq 0x43e19
leal -0x7(%r13), %eax
movabsq $-0x800000000000, %r12  # imm = 0xFFFF800000000000
cmpl $0x2, %eax
jb 0x3c908
leal -0x9(%r13), %eax
cmpl $0x2, %eax
jae 0x3c732
andq %r15, %r12
movq %r15, %rdi
callq 0x4b1f1
movabsq $-0x3800000000000, %r13 # imm = 0xFFFC800000000000
cmpq %r13, %r12
jne 0x3c99d
movq 0x28(%rax), %r14
movq (%rbx), %rdi
leaq 0x27ddc(%rip), %rsi     # 0x646a8
callq 0x1614c
testq %r14, %r14
je 0x3ca1c
leaq 0x27dc9(%rip), %rdi     # 0x646aa
callq 0x439c6
movabsq $-0x5000000000000, %rsi # imm = 0xFFFB000000000000
movq %rax, %rdi
callq 0x4b366
movq %r14, %rdi
movq %rax, %rsi
callq 0x43c35
jmp 0x3c9cf
leaq -0x2c(%rbp), %rdx
andl $0x0, (%rdx)
leaq -0x38(%rbp), %rsi
andq $0x0, (%rsi)
andq %r15, %r12
movq %r15, %rdi
callq 0x45c58
movabsq $-0x4800000000000, %r13 # imm = 0xFFFB800000000000
cmpq %r13, %r12
jne 0x3cb39
leaq 0x27d63(%rip), %rsi     # 0x6469f
movb $0x5d, %r14b
jmp 0x3cb5f
movb $0x30, (%rdi)
movl 0x10(%r14), %esi
incl %esi
jmp 0x3cc7a
movb $0x2d, (%rdi)
incq %rdi
pushq $0x1
popq %rcx
pushq $0x4
popq %rsi
movl $0x2710, %r8d           # imm = 0x2710
movl %r15d, %eax
cmpl $-0xa, %eax
ja 0x3cc3e
cmpl $-0x63, %eax
jae 0x3cc43
cmpl $0xfffffc19, %eax       # imm = 0xFFFFFC19
jae 0x3cc48
cmpl $0xffffd8f0, %eax       # imm = 0xFFFFD8F0
ja 0x3cc4a
negl %eax
xorl %edx, %edx
divl %r8d
negl %eax
addl $0x4, %esi
jmp 0x3c967
movq -0x8(%rax), %r14
testq %r14, %r14
je 0x3ca1c
leaq 0x27cfd(%rip), %rdi     # 0x646aa
callq 0x439c6
movabsq $-0x5000000000000, %rsi # imm = 0xFFFB000000000000
movq %rax, %rdi
callq 0x4b366
movq %r14, %rdi
movq %rax, %rsi
callq 0x430d3
leaq -0x38(%rbp), %rsi
leaq -0x2c(%rbp), %rdx
movq %rax, %rdi
callq 0x45cd2
testl %eax, %eax
je 0x3ca1c
testb $0x1, 0x10(%rbx)
je 0x3c9f8
movq (%rbx), %rdi
leaq 0x27ba3(%rip), %rsi     # 0x64596
callq 0x1614c
movq (%rbx), %rdi
movq -0x38(%rbp), %rsi
movl -0x2c(%rbp), %edx
callq 0x16172
testb $0x1, 0x10(%rbx)
je 0x3ca1c
movq (%rbx), %rdi
leaq 0x179fb(%rip), %rsi     # 0x54412
callq 0x1614c
movq (%rbx), %rdi
leaq 0x27cc9(%rip), %rsi     # 0x646ef
callq 0x1614c
addl $0x2, 0xc(%rbx)
decl 0x8(%rbx)
je 0x3ccb0
leaq -0x2c(%rbp), %r14
andl $0x0, (%r14)
leaq -0x48(%rbp), %rcx
andl $0x0, (%rcx)
leaq -0x38(%rbp), %rsi
andq $0x0, (%rsi)
movq %r15, %rdi
movq %r14, %rdx
callq 0x45d86
movl (%r14), %eax
cmpq %r13, %r12
je 0x3ca84
testb $0x2, 0x10(%rbx)
sete %cl
cmpl $0x4, %eax
setge %dl
andb %cl, %dl
cmpb $0x1, %dl
jne 0x3ca84
movq (%rbx), %rdi
pushq $0x20
popq %rsi
callq 0x161be
movl -0x2c(%rbp), %eax
cmpl $0x0, -0x40(%rbp)
setne %cl
cmpl $0x4, %eax
setge %dl
andb %cl, %dl
cmpb $0x1, %dl
jne 0x3caa5
movq %rbx, %rdi
xorl %esi, %esi
callq 0x3ce23
movl -0x2c(%rbp), %eax
movl 0x24(%rbx), %r14d
cltq
movslq %r14d, %r13
addq %r13, %rax
movl $0x0, -0x40(%rbp)
movl $0x80000000, %ecx       # imm = 0x80000000
cmpq %rcx, %rax
jl 0x3cacf
andl $0x0, -0x2c(%rbp)
pushq $0x1
popq %rax
movl %eax, -0x40(%rbp)
movq %r13, %rax
movslq 0x20(%rbx), %rcx
cmpq %rcx, %rax
jle 0x3cce6
leal (%rax,%rax), %ecx
cmpq $0x3fffffff, %rax       # imm = 0x3FFFFFFF
movl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
cmovll %ecx, %eax
movl %eax, 0x20(%rbx)
movq 0x18(%rbx), %rdi
movslq %eax, %rsi
shlq $0x2, %rsi
callq 0x297c9
movq %rax, 0x18(%rbx)
testq %rax, %rax
jne 0x3ccea
movq 0x434dc(%rip), %rax     # 0x7fff0
movq (%rax), %rdi
leaq 0x104e6(%rip), %rsi     # 0x4d004
leaq 0x27b8b(%rip), %rdx     # 0x646b0
movl $0x28d, %ecx            # imm = 0x28D
xorl %eax, %eax
callq 0x125e0
pushq $0x1
popq %rdi
callq 0x12a60
movq -0x38(%rbp), %rax
btl $0x10, -0x20(%rax)
pushq $0x29
popq %rax
pushq $0x5d
popq %r14
cmovael %eax, %r14d
leaq 0x27b4e(%rip), %rax     # 0x646a2
leaq 0x27b45(%rip), %rsi     # 0x646a0
cmovaeq %rax, %rsi
movq (%rbx), %rdi
callq 0x1614c
addl $0x2, 0xc(%rbx)
decl 0x8(%rbx)
je 0x3ccc4
movl -0x2c(%rbp), %eax
cmpq %r13, %r12
je 0x3cb9e
testb $0x2, 0x10(%rbx)
sete %cl
cmpl $0xa, %eax
setge %dl
andb %cl, %dl
cmpb $0x1, %dl
jne 0x3cb9e
movq (%rbx), %rdi
pushq $0x20
popq %rsi
callq 0x161be
movl -0x2c(%rbp), %eax
cmpl $0x0, -0x40(%rbp)
setne %cl
cmpl $0xa, %eax
setge %dl
andb %cl, %dl
cmpb $0x1, %dl
jne 0x3cbbf
movq %rbx, %rdi
xorl %esi, %esi
callq 0x3ce23
movl -0x2c(%rbp), %eax
cmpl $0xa0, %eax
jle 0x3cbff
testb $0x4, 0x10(%rbx)
jne 0x3cbff
xorl %r12d, %r12d
testq %r12, %r12
je 0x3cbe8
movq %rbx, %rdi
xorl %esi, %esi
cmpq $0x3, %r12
je 0x3cdd8
callq 0x3ce23
movq -0x38(%rbp), %rax
movq (%rax,%r12,8), %rsi
movq %rbx, %rdi
xorl %edx, %edx
callq 0x3c6e7
incq %r12
jmp 0x3cbcf
xorl %r12d, %r12d
movslq %eax, %rcx
cmpq %rcx, %r12
jge 0x3ccd3
testq %r12, %r12
je 0x3cc24
xorl %esi, %esi
cmpl $0xa, %eax
setl %sil
movq %rbx, %rdi
callq 0x3ce23
movq -0x38(%rbp), %rax
movq (%rax,%r12,8), %rsi
movq %rbx, %rdi
xorl %edx, %edx
callq 0x3c6e7
incq %r12
movl -0x2c(%rbp), %eax
jmp 0x3cc02
addl $-0x3, %esi
jmp 0x3cc4a
addl $-0x2, %esi
jmp 0x3cc4a
decl %esi
movslq %esi, %rax
addq %rax, %rdi
decq %rdi
pushq $0xa
popq %r8
testl %r15d, %r15d
je 0x3cc74
movl %r15d, %eax
cltd
idivl %r8d
movb $0x30, %r9b
subb %dl, %r9b
movb %r9b, (%rdi)
decq %rdi
movl %eax, %r15d
jmp 0x3cc57
addl %ecx, %esi
addl 0x10(%r14), %esi
movl %esi, 0x10(%r14)
movq (%rbx), %rdi
pushq $0x3e
popq %rsi
callq 0x161be
testb $0x1, 0x10(%rbx)
je 0x3c7c9
movq (%rbx), %rdi
leaq 0x17775(%rip), %rsi     # 0x54412
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x1614c
movq (%rbx), %rdi
leaq 0x279ea(%rip), %rsi     # 0x646a4
callq 0x1614c
jmp 0x3cdc1
movq (%rbx), %rdi
leaq 0x279d6(%rip), %rsi     # 0x646a4
callq 0x1614c
addl $-0x2, 0xc(%rbx)
incl 0x8(%rbx)
movq (%rbx), %rdi
movzbl %r14b, %esi
jmp 0x3cdce
movq 0x18(%rbx), %rax
movl %r14d, -0x44(%rbp)
movq -0x38(%rbp), %rdi
movl -0x48(%rbp), %esi
testq %rax, %rax
leaq (%rax,%r13,4), %rdx
cmoveq %rax, %rdx
callq 0x4619f
movl -0x2c(%rbp), %eax
addl %eax, 0x24(%rbx)
testb $0x4, 0x10(%rbx)
sete %cl
cmpl $0x1f, %eax
setge %dl
andb %cl, %dl
cmpb $0x1, %dl
jne 0x3cd2f
movl $0x1e, -0x2c(%rbp)
pushq $0x1
popq %rax
movl %eax, -0x40(%rbp)
pushq $0x1e
popq %rax
shlq $0x2, %r13
xorl %r14d, %r14d
movslq %eax, %rcx
cmpq %rcx, %r14
jge 0x3cd9c
testq %r14, %r14
je 0x3cd54
xorl %esi, %esi
cmpl $0x4, %eax
setl %sil
movq %rbx, %rdi
callq 0x3ce23
movq 0x18(%rbx), %rax
addq %r13, %rax
movslq (%rax,%r14,4), %r12
movq -0x38(%rbp), %rax
shlq $0x4, %r12
movq (%rax,%r12), %rsi
movq %rbx, %rdi
xorl %edx, %edx
callq 0x3c6e7
movq (%rbx), %rdi
pushq $0x20
popq %rsi
callq 0x161be
movq -0x38(%rbp), %rax
movq 0x8(%rax,%r12), %rsi
movq %rbx, %rdi
pushq $0x1
popq %rdx
callq 0x3c6e7
incq %r14
movl -0x2c(%rbp), %eax
jmp 0x3cd36
cmpl $0x0, -0x40(%rbp)
je 0x3cdbb
movq %rbx, %rdi
xorl %esi, %esi
callq 0x3ce23
movq (%rbx), %rdi
leaq 0x278ee(%rip), %rsi     # 0x646a4
callq 0x1614c
movl -0x44(%rbp), %eax
movl %eax, 0x24(%rbx)
addl $-0x2, 0xc(%rbx)
incl 0x8(%rbx)
movq (%rbx), %rdi
pushq $0x7d
popq %rsi
callq 0x161be
jmp 0x3c7ba
callq 0x3ce23
movq (%rbx), %rdi
leaq 0x278bd(%rip), %rsi     # 0x646a4
callq 0x1614c
pushq $-0x3
popq %r12
testl %r12d, %r12d
je 0x3ccd3
movq %rbx, %rdi
xorl %esi, %esi
callq 0x3ce23
movq -0x38(%rbp), %rax
movl -0x2c(%rbp), %ecx
addl %r12d, %ecx
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rsi
movq %rbx, %rdi
xorl %edx, %edx
callq 0x3c6e7
incl %r12d
jmp 0x3cdf0