// File: /workspace/github_c_makefile_star2_O3/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, %r14
movq %rsi, %xmm0
movq %rsi, %r13
shrq $0x2f, %r13
movl %r13d, %eax
andl $0xf, %eax
xorl %r15d, %r15d
ucomisd %xmm0, %xmm0
movq %rdi, %rbx
cmovpl %eax, %r15d
cmpl $0x5, %r15d
ja 0x3fd87
movl $0x27, %eax
btl %r15d, %eax
jae 0x3fd87
testb $0x1, 0x10(%rbx)
je 0x3fcfc
movl %r15d, %eax
leaq 0x28843(%rip), %rcx     # 0x68530
movslq (%rcx,%rax,4), %rsi
addq %rcx, %rsi
movq (%rbx), %rdi
callq 0x17878
cmpl $0x1fffb, %r13d         # imm = 0x1FFFB
jne 0x3fd49
movq %r14, %rdi
callq 0x4ebc4
movq (%rbx), %rdi
cmpq %rdi, %rax
jne 0x3fd4c
movl 0x10(%rdi), %eax
movl 0x14(%rbx), %ecx
leal (%rax,%rcx,4), %esi
addl $0x3, %esi
movl $0x1, %edx
callq 0x1771e
movq (%rbx), %rdi
movl $0x40, %esi
callq 0x17947
movq (%rbx), %rdi
movq 0x18(%rdi), %rsi
movl 0x14(%rbx), %edx
callq 0x3fb2e
jmp 0x3fd54
movq (%rbx), %rdi
movq %r14, %rsi
callq 0x3eb9c
testb $0x1, 0x10(%rbx)
je 0x3fd69
movq (%rbx), %rdi
leaq 0x186ae(%rip), %rsi     # 0x58412
callq 0x17878
addq $0x28, %rbx
movq %rbx, %rdi
movq %r14, %rsi
callq 0x47664
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 %r14, %rsi
callq 0x474e0
movq %rax, %xmm0
ucomisd %xmm0, %xmm0
setp %cl
movabsq $0x7800000000000, %rdx  # imm = 0x7800000000000
testq %rdx, %rax
setne %al
testb %al, %cl
jne 0x3fe19
movsd %xmm0, -0x40(%rbp)
testb $0x1, 0x10(%rbx)
je 0x3fdd3
movq (%rbx), %rdi
leaq 0x287a2(%rip), %rsi     # 0x68570
callq 0x17878
movq (%rbx), %rdi
leaq 0x2889a(%rip), %rsi     # 0x68677
callq 0x17878
movq (%rbx), %r14
cvttsd2si -0x40(%rbp), %r15d
movq %r14, %rdi
movl $0x40, %esi
callq 0x177e3
movslq 0x10(%r14), %rdx
addq 0x18(%r14), %rdx
testl %r15d, %r15d
je 0x3ff08
jle 0x3ff16
negl %r15d
xorl %eax, %eax
jmp 0x3ff21
xorps %xmm0, %xmm0
cvtsi2sdl 0x38(%rbx), %xmm0
callq 0x4ee44
movq %r12, %rdi
movq %r14, %rsi
movq %rax, %rdx
callq 0x476f0
leal -0x7(%r15), %eax
cmpl $0x2, %eax
jb 0x3febc
leal -0x9(%r15), %eax
cmpl $0x2, %eax
jae 0x3fcdd
movabsq $-0x800000000000, %r13  # imm = 0xFFFF800000000000
andq %r14, %r13
movq %r14, %rdi
callq 0x4ebc4
movabsq $-0x3800000000000, %r15 # imm = 0xFFFC800000000000
cmpq %r15, %r13
jne 0x3ff84
movq 0x28(%rax), %r12
movq (%rbx), %rdi
leaq 0x28808(%rip), %rsi     # 0x68688
callq 0x17878
testq %r12, %r12
je 0x40003
leaq 0x287f5(%rip), %rdi     # 0x6868a
callq 0x47261
movabsq $-0x5000000000000, %rsi # imm = 0xFFFB000000000000
movq %rax, %rdi
callq 0x4ed39
movq %r12, %rdi
movq %rax, %rsi
callq 0x474e0
jmp 0x3ffb6
leaq -0x2c(%rbp), %rdx
movl $0x0, (%rdx)
leaq -0x38(%rbp), %rsi
movq $0x0, (%rsi)
movabsq $-0x800000000000, %r15  # imm = 0xFFFF800000000000
andq %r14, %r15
movq %r14, %rdi
callq 0x49726
movabsq $-0x4800000000000, %r13 # imm = 0xFFFB800000000000
cmpq %r13, %r15
jne 0x4005b
leaq 0x2877f(%rip), %rsi     # 0x6867f
movb $0x5d, %r12b
jmp 0x40085
movb $0x30, (%rdx)
movl 0x10(%r14), %ecx
incl %ecx
jmp 0x403ed
movb $0x2d, (%rdx)
incq %rdx
movl $0x1, %eax
movl $0x1, %ecx
cmpl $-0xa, %r15d
ja 0x403a5
movl $0x4, %ecx
movl $0xd1b71759, %esi       # imm = 0xD1B71759
movl %r15d, %edi
cmpl $-0x63, %edi
jae 0x4039e
cmpl $0xfffffc19, %edi       # imm = 0xFFFFFC19
jae 0x403a3
cmpl $0xffffd8f0, %edi       # imm = 0xFFFFD8F0
ja 0x403a5
negl %edi
movq %rdi, %r8
imulq %rsi, %r8
shrq $0x2d, %r8
negl %r8d
addl $0x4, %ecx
cmpl $0x1869f, %edi          # imm = 0x1869F
movl %r8d, %edi
ja 0x3ff3d
addl $-0x3, %ecx
jmp 0x403a5
movq -0x8(%rax), %r12
testq %r12, %r12
je 0x40003
leaq 0x286f6(%rip), %rdi     # 0x6868a
callq 0x47261
movabsq $-0x5000000000000, %rsi # imm = 0xFFFB000000000000
movq %rax, %rdi
callq 0x4ed39
movq %r12, %rdi
movq %rax, %rsi
callq 0x46988
leaq -0x38(%rbp), %rsi
leaq -0x2c(%rbp), %rdx
movq %rax, %rdi
callq 0x497a9
testl %eax, %eax
je 0x40003
testb $0x1, 0x10(%rbx)
je 0x3ffdf
movq (%rbx), %rdi
leaq 0x2859c(%rip), %rsi     # 0x68576
callq 0x17878
movq (%rbx), %rdi
movq -0x38(%rbp), %rsi
movl -0x2c(%rbp), %edx
callq 0x178c5
testb $0x1, 0x10(%rbx)
je 0x40003
movq (%rbx), %rdi
leaq 0x18414(%rip), %rsi     # 0x58412
callq 0x17878
movq (%rbx), %rdi
leaq 0x286c2(%rip), %rsi     # 0x686cf
callq 0x17878
addl $0x2, 0xc(%rbx)
decl 0x8(%rbx)
je 0x40177
xorl %eax, %eax
leaq -0x2c(%rbp), %r12
movl %eax, (%r12)
leaq -0x48(%rbp), %rcx
movl %eax, (%rcx)
leaq -0x38(%rbp), %rsi
movq $0x0, (%rsi)
movq %r14, %rdi
movq %r12, %rdx
callq 0x4985f
movl (%r12), %eax
cmpq %r15, %r13
jne 0x4019f
movl -0x40(%rbp), %r15d
jmp 0x401c7
movq -0x38(%rbp), %rax
btl $0x10, -0x20(%rax)
movl $0x29, %eax
movl $0x5d, %r12d
cmovael %eax, %r12d
leaq 0x28608(%rip), %rax     # 0x68682
leaq 0x285ff(%rip), %rsi     # 0x68680
cmovaeq %rax, %rsi
movq (%rbx), %rdi
callq 0x17878
addl $0x2, 0xc(%rbx)
decl 0x8(%rbx)
je 0x4018b
movl -0x2c(%rbp), %eax
cmpq %r13, %r15
je 0x400c6
testb $0x2, 0x10(%rbx)
sete %cl
cmpl $0xa, %eax
setge %dl
andb %cl, %dl
cmpb $0x1, %dl
jne 0x400c6
movq (%rbx), %rdi
movl $0x20, %esi
callq 0x17947
movl -0x2c(%rbp), %eax
cmpl $0x0, -0x40(%rbp)
setne %cl
cmpl $0xa, %eax
setge %dl
andb %cl, %dl
cmpb $0x1, %dl
jne 0x400e7
movq %rbx, %rdi
xorl %esi, %esi
callq 0x40425
movl -0x2c(%rbp), %eax
cmpl $0xa1, %eax
jl 0x40294
testb $0x4, 0x10(%rbx)
jne 0x40298
xorl %r15d, %r15d
testq %r15, %r15
je 0x4010e
movq %rbx, %rdi
xorl %esi, %esi
callq 0x40425
movq -0x38(%rbp), %rax
movq (%rax,%r15,8), %rsi
movq %rbx, %rdi
xorl %edx, %edx
callq 0x3fc90
incq %r15
cmpq $0x3, %r15
jne 0x400ff
movq %rbx, %rdi
xorl %esi, %esi
callq 0x40425
movq (%rbx), %rdi
leaq 0x28547(%rip), %rsi     # 0x68684
callq 0x17878
movl $0xfffffffd, %r15d      # imm = 0xFFFFFFFD
movq %rbx, %rdi
xorl %esi, %esi
callq 0x40425
movq -0x38(%rbp), %rax
movl -0x2c(%rbp), %ecx
addl %r15d, %ecx
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rsi
movq %rbx, %rdi
xorl %edx, %edx
callq 0x3fc90
incl %r15d
jne 0x40148
jmp 0x402cf
movq (%rbx), %rdi
leaq 0x28503(%rip), %rsi     # 0x68684
callq 0x17878
jmp 0x40385
movq (%rbx), %rdi
leaq 0x284ef(%rip), %rsi     # 0x68684
callq 0x17878
jmp 0x402cf
testb $0x2, 0x10(%rbx)
sete %cl
cmpl $0x4, %eax
setge %dl
andb %cl, %dl
cmpb $0x1, %dl
movl -0x40(%rbp), %r15d
jne 0x401c7
movq (%rbx), %rdi
movl $0x20, %esi
callq 0x17947
movl -0x2c(%rbp), %eax
testl %r15d, %r15d
setne %cl
cmpl $0x4, %eax
setge %dl
andb %cl, %dl
cmpb $0x1, %dl
jne 0x401e7
movq %rbx, %rdi
xorl %esi, %esi
callq 0x40425
movl -0x2c(%rbp), %eax
movl 0x24(%rbx), %r15d
cltq
movslq %r15d, %r12
addq %r12, %rax
xorl %r13d, %r13d
movl $0x80000000, %ecx       # imm = 0x80000000
cmpq %rcx, %rax
jl 0x40210
movl $0x0, -0x2c(%rbp)
movl $0x1, %r13d
movq %r12, %rax
movslq 0x20(%rbx), %rcx
cmpq %rcx, %rax
jle 0x4024b
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 0x2bc37
movq %rax, 0x18(%rbx)
testq %rax, %rax
jne 0x4024f
callq 0x13e70
movq 0x18(%rbx), %rax
movq -0x38(%rbp), %rdi
movl -0x48(%rbp), %esi
testq %rax, %rax
leaq (%rax,%r12,4), %rdx
cmoveq %rax, %rdx
callq 0x49c8f
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 0x402e2
movl $0x1e, -0x2c(%rbp)
movl $0x1e, %eax
movl $0x1, %r13d
jmp 0x402e6
testl %eax, %eax
jle 0x402cf
xorl %r15d, %r15d
testq %r15, %r15
je 0x402b1
xorl %esi, %esi
cmpl $0xa, %eax
setl %sil
movq %rbx, %rdi
callq 0x40425
movq -0x38(%rbp), %rax
movq (%rax,%r15,8), %rsi
movq %rbx, %rdi
xorl %edx, %edx
callq 0x3fc90
incq %r15
movslq -0x2c(%rbp), %rax
cmpq %rax, %r15
jl 0x4029b
addl $-0x2, 0xc(%rbx)
incl 0x8(%rbx)
movq (%rbx), %rdi
movzbl %r12b, %esi
jmp 0x40394
testl %eax, %eax
jle 0x40363
movl %r13d, -0x44(%rbp)
movl %r15d, -0x40(%rbp)
shlq $0x2, %r12
xorl %r15d, %r15d
testq %r15, %r15
je 0x4030b
xorl %esi, %esi
cmpl $0x4, %eax
setl %sil
movq %rbx, %rdi
callq 0x40425
movq 0x18(%rbx), %rax
addq %r12, %rax
movslq (%rax,%r15,4), %r13
movq -0x38(%rbp), %rax
shlq $0x4, %r13
movq (%rax,%r13), %rsi
movq %rbx, %rdi
xorl %edx, %edx
callq 0x3fc90
movq (%rbx), %rdi
movl $0x20, %esi
callq 0x17947
movq -0x38(%rbp), %rax
movq 0x8(%rax,%r13), %rsi
movq %rbx, %rdi
movl $0x1, %edx
callq 0x3fc90
incq %r15
movslq -0x2c(%rbp), %rax
cmpq %rax, %r15
jl 0x402f5
movl -0x40(%rbp), %r15d
movl -0x44(%rbp), %r13d
testl %r13d, %r13d
je 0x40381
movq %rbx, %rdi
xorl %esi, %esi
callq 0x40425
movq (%rbx), %rdi
leaq 0x28308(%rip), %rsi     # 0x68684
callq 0x17878
movl %r15d, 0x24(%rbx)
addl $-0x2, 0xc(%rbx)
incl 0x8(%rbx)
movq (%rbx), %rdi
movl $0x7d, %esi
callq 0x17947
jmp 0x3fd69
addl $-0x2, %ecx
jmp 0x403a5
decl %ecx
movslq %ecx, %rsi
addq %rsi, %rdx
decq %rdx
movslq %r15d, %rsi
imulq $0x66666667, %rsi, %r15 # imm = 0x66666667
movq %r15, %rdi
shrq $0x3f, %rdi
sarq $0x22, %r15
addl %edi, %r15d
leal (%r15,%r15), %edi
leal (%rdi,%rdi,4), %edi
movl %esi, %r8d
subl %edi, %r8d
movb $0x30, %dil
subb %r8b, %dil
movb %dil, (%rdx)
addl $0x9, %esi
decq %rdx
cmpl $0x12, %esi
ja 0x403ae
addl %eax, %ecx
addl 0x10(%r14), %ecx
movl %ecx, 0x10(%r14)
movq (%rbx), %rdi
movl $0x3e, %esi
callq 0x17947
testb $0x1, 0x10(%rbx)
je 0x3fd78
movq (%rbx), %rdi
leaq 0x18000(%rip), %rsi     # 0x58412
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x17878