// File: /workspace/github_c_makefile_star2_O1/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 $0x38, %rsp
movq %rsi, %rbx
movq %rsi, %xmm0
movq %rsi, %r13
shrq $0x2f, %r13
movl %r13d, %eax
andl $0xf, %eax
xorl %r15d, %r15d
ucomisd %xmm0, %xmm0
movq %rdi, %r14
cmovpl %eax, %r15d
cmpl $0x5, %r15d
ja 0x40493
movl $0x27, %eax
btl %r15d, %eax
jae 0x40493
testb $0x1, 0x10(%r14)
je 0x40437
movl %r15d, %eax
leaq 0x29128(%rip), %rcx     # 0x69550
movslq (%rcx,%rax,4), %rsi
addq %rcx, %rsi
movq (%r14), %rdi
callq 0x178d8
cmpl $0x1fffb, %r13d         # imm = 0x1FFFB
jne 0x40454
movq %rbx, %rdi
callq 0x4f838
movq (%r14), %rdi
cmpq %rdi, %rax
je 0x40528
movq (%r14), %rdi
movq %rbx, %rsi
callq 0x3f295
testb $0x1, 0x10(%r14)
je 0x40475
movq (%r14), %rdi
leaq 0x18fa2(%rip), %rsi     # 0x59412
callq 0x178d8
addq $0x28, %r14
movq %r14, %rdi
movq %rbx, %rsi
callq 0x48127
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl %edx, -0x3c(%rbp)
leaq 0x28(%r14), %r12
movq %r12, %rdi
movq %rbx, %rsi
callq 0x47f51
movq %rax, %xmm0
ucomisd %xmm0, %xmm0
setnp %cl
movabsq $0x7800000000000, %rdx  # imm = 0x7800000000000
testq %rdx, %rax
sete %al
orb %cl, %al
movb %al, -0x40(%rbp)
cmpb $0x1, %al
jne 0x40561
movsd %xmm0, -0x50(%rbp)
movq %rbx, -0x58(%rbp)
testb $0x1, 0x10(%r14)
je 0x404ed
movq (%r14), %rdi
leaq 0x290a8(%rip), %rsi     # 0x69590
callq 0x178d8
movq (%r14), %rdi
leaq 0x291a0(%rip), %rsi     # 0x69697
callq 0x178d8
movq (%r14), %rbx
cvttsd2si -0x50(%rbp), %r12d
movq %rbx, %rdi
movl $0x40, %esi
callq 0x17843
movslq 0x10(%rbx), %rdx
addq 0x18(%rbx), %rdx
testl %r12d, %r12d
je 0x40582
jle 0x4058f
negl %r12d
xorl %eax, %eax
jmp 0x4059a
movl 0x10(%rdi), %eax
movl 0x14(%r14), %ecx
leal (%rax,%rcx,4), %esi
addl $0x3, %esi
movl $0x1, %edx
callq 0x1777e
movq (%r14), %rdi
movl $0x40, %esi
callq 0x179a7
movq (%r14), %rdi
movq 0x18(%rdi), %rsi
movl 0x14(%r14), %edx
callq 0x4026c
jmp 0x4045f
xorps %xmm0, %xmm0
cvtsi2sdl 0x38(%r14), %xmm0
callq 0x4fab8
movq %r12, %rdi
movq %rbx, %rsi
movq %rax, %rdx
callq 0x481b3
jmp 0x40664
movb $0x30, (%rdx)
movl 0x10(%rbx), %ecx
incl %ecx
jmp 0x4063a
movb $0x2d, (%rdx)
incq %rdx
movl $0x1, %eax
movl $0x1, %ecx
cmpl $-0xa, %r12d
jg 0x405f3
movl $0x4, %ecx
movl %r12d, %esi
cmpl $-0x63, %esi
jae 0x405ec
cmpl $0xfffffc19, %esi       # imm = 0xFFFFFC19
jae 0x405f1
cmpl $0xffffd8f0, %esi       # imm = 0xFFFFD8F0
ja 0x405f3
movslq %esi, %rdi
imulq $0x68db8bad, %rdi, %rdi # imm = 0x68DB8BAD
movq %rdi, %r8
shrq $0x3f, %r8
sarq $0x2c, %rdi
addl %r8d, %edi
addl $0x4, %ecx
cmpl $0xfffe7961, %esi       # imm = 0xFFFE7961
movl %edi, %esi
jl 0x405ad
addl $-0x3, %ecx
jmp 0x405f3
addl $-0x2, %ecx
jmp 0x405f3
decl %ecx
movslq %ecx, %rsi
addq %rsi, %rdx
decq %rdx
movslq %r12d, %rsi
imulq $0x66666667, %rsi, %r12 # imm = 0x66666667
movq %r12, %rdi
shrq $0x3f, %rdi
sarq $0x22, %r12
addl %edi, %r12d
leal (%r12,%r12), %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 0x405fc
addl %eax, %ecx
addl 0x10(%rbx), %ecx
movl %ecx, 0x10(%rbx)
movq (%r14), %rdi
movl $0x3e, %esi
callq 0x179a7
testb $0x1, 0x10(%r14)
movq -0x58(%rbp), %rbx
je 0x40664
movq (%r14), %rdi
leaq 0x18db3(%rip), %rsi     # 0x59412
callq 0x178d8
cmpb $0x0, -0x40(%rbp)
jne 0x40484
leal -0x7(%r15), %eax
cmpl $0x2, %eax
jb 0x406f3
leal -0x9(%r15), %eax
cmpl $0x2, %eax
jae 0x40417
movabsq $-0x800000000000, %r15  # imm = 0xFFFF800000000000
andq %rbx, %r15
movq %rbx, %rdi
callq 0x4f838
movabsq $-0x3800000000000, %r13 # imm = 0xFFFC800000000000
cmpq %r13, %r15
jne 0x4073f
movq 0x28(%rax), %r12
movq (%r14), %rdi
leaq 0x28fee(%rip), %rsi     # 0x696a8
callq 0x178d8
testq %r12, %r12
je 0x407c0
leaq 0x28fdb(%rip), %rdi     # 0x696aa
callq 0x47cd3
movabsq $-0x5000000000000, %rsi # imm = 0xFFFB000000000000
movq %rax, %rdi
callq 0x4f9ad
movq %r12, %rdi
movq %rax, %rsi
callq 0x47f51
jmp 0x40771
leaq -0x2c(%rbp), %rdx
movl $0x0, (%rdx)
leaq -0x38(%rbp), %rsi
movq $0x0, (%rsi)
movabsq $-0x800000000000, %r12  # imm = 0xFFFF800000000000
andq %rbx, %r12
movq %rbx, %rdi
callq 0x4a23e
movabsq $-0x4800000000000, %r13 # imm = 0xFFFB800000000000
cmpq %r13, %r12
jne 0x40984
movb $0x5d, %r15b
leaq 0x28f65(%rip), %rsi     # 0x6969f
jmp 0x409ad
movq -0x8(%rax), %r12
testq %r12, %r12
je 0x407c0
leaq 0x28f5b(%rip), %rdi     # 0x696aa
callq 0x47cd3
movabsq $-0x5000000000000, %rsi # imm = 0xFFFB000000000000
movq %rax, %rdi
callq 0x4f9ad
movq %r12, %rdi
movq %rax, %rsi
callq 0x47388
leaq -0x38(%rbp), %rsi
leaq -0x2c(%rbp), %rdx
movq %rax, %rdi
callq 0x4a2c1
testl %eax, %eax
je 0x407c0
testb $0x1, 0x10(%r14)
je 0x4079b
movq (%r14), %rdi
leaq 0x28e00(%rip), %rsi     # 0x69596
callq 0x178d8
movq (%r14), %rdi
movq -0x38(%rbp), %rsi
movl -0x2c(%rbp), %edx
callq 0x17925
testb $0x1, 0x10(%r14)
je 0x407c0
movq (%r14), %rdi
leaq 0x18c57(%rip), %rsi     # 0x59412
callq 0x178d8
movq (%r14), %rdi
leaq 0x28f25(%rip), %rsi     # 0x696ef
callq 0x178d8
addl $0x2, 0xc(%r14)
decl 0x8(%r14)
je 0x40ac1
xorl %eax, %eax
leaq -0x2c(%rbp), %rdx
movl %eax, (%rdx)
leaq -0x44(%rbp), %rcx
movl %eax, (%rcx)
leaq -0x38(%rbp), %rsi
movq $0x0, (%rsi)
movq %rbx, %rdi
callq 0x4a377
cmpq %r13, %r15
je 0x4081e
testb $0x2, 0x10(%r14)
jne 0x4081e
cmpl $0x4, -0x2c(%rbp)
jl 0x4081e
movq (%r14), %rdi
movl $0x20, %esi
callq 0x179a7
cmpl $0x0, -0x3c(%rbp)
je 0x40834
cmpl $0x4, -0x2c(%rbp)
jl 0x40834
movq %r14, %rdi
xorl %esi, %esi
callq 0x40b11
movl 0x24(%r14), %r15d
movslq %r15d, %r12
movslq -0x2c(%rbp), %rax
addq %r12, %rax
xorl %r13d, %r13d
movl $0x80000000, %ecx       # imm = 0x80000000
cmpq %rcx, %rax
jl 0x4085f
movl $0x0, -0x2c(%rbp)
movl $0x1, %r13d
movq %r12, %rax
movslq 0x20(%r14), %rcx
cmpq %rcx, %rax
jle 0x4089a
leal (%rax,%rax), %ecx
cmpq $0x3fffffff, %rax       # imm = 0x3FFFFFFF
movl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
cmovll %ecx, %eax
movl %eax, 0x20(%r14)
movq 0x18(%r14), %rdi
movslq %eax, %rsi
shlq $0x2, %rsi
callq 0x2c0cf
movq %rax, 0x18(%r14)
testq %rax, %rax
je 0x40b0c
movl %r15d, -0x40(%rbp)
movq -0x38(%rbp), %rdi
movl -0x44(%rbp), %esi
movq 0x18(%r14), %rax
testq %rax, %rax
leaq (%rax,%r12,4), %rdx
cmoveq %rax, %rdx
callq 0x4a79c
movl -0x2c(%rbp), %eax
addl %eax, 0x24(%r14)
testb $0x4, 0x10(%r14)
sete %cl
cmpl $0x1f, %eax
setge %al
andb %cl, %al
cmpb $0x1, %al
jne 0x408e1
movl $0x1e, -0x2c(%rbp)
movl $0x1, %r13d
movl %r13d, -0x3c(%rbp)
movl -0x2c(%rbp), %eax
testl %eax, %eax
jle 0x40959
shlq $0x2, %r12
xorl %r15d, %r15d
testq %r15, %r15
je 0x40909
xorl %esi, %esi
cmpl $0x4, %eax
setl %sil
movq %r14, %rdi
callq 0x40b11
movq 0x18(%r14), %rax
addq %r12, %rax
movslq (%rax,%r15,4), %r13
movq -0x38(%rbp), %rax
shlq $0x4, %r13
movq (%rax,%r13), %rsi
movq %r14, %rdi
xorl %edx, %edx
callq 0x403ce
movq (%r14), %rdi
movl $0x20, %esi
callq 0x179a7
movq -0x38(%rbp), %rax
movq 0x8(%rax,%r13), %rsi
movq %r14, %rdi
movl $0x1, %edx
callq 0x403ce
incq %r15
movslq -0x2c(%rbp), %rax
cmpq %rax, %r15
jl 0x408f3
cmpl $0x0, -0x3c(%rbp)
je 0x40978
movq %r14, %rdi
xorl %esi, %esi
callq 0x40b11
movq (%r14), %rdi
leaq 0x28d31(%rip), %rsi     # 0x696a4
callq 0x178d8
movl -0x40(%rbp), %eax
movl %eax, 0x24(%r14)
jmp 0x40ad0
movq -0x38(%rbp), %rax
testb $0x1, -0x1e(%rax)
leaq 0x28d0f(%rip), %rax     # 0x696a2
leaq 0x28d06(%rip), %rsi     # 0x696a0
cmoveq %rax, %rsi
movl $0x29, %eax
movl $0x5d, %r15d
cmovel %eax, %r15d
movq (%r14), %rdi
callq 0x178d8
addl $0x2, 0xc(%r14)
decl 0x8(%r14)
je 0x40ae3
cmpq %r13, %r12
je 0x409e3
testb $0x2, 0x10(%r14)
jne 0x409e3
cmpl $0xa, -0x2c(%rbp)
jl 0x409e3
movq (%r14), %rdi
movl $0x20, %esi
callq 0x179a7
cmpl $0x0, -0x3c(%rbp)
je 0x409f9
cmpl $0xa, -0x2c(%rbp)
jl 0x409f9
movq %r14, %rdi
xorl %esi, %esi
callq 0x40b11
cmpl $0xa1, -0x2c(%rbp)
jl 0x40a81
testb $0x4, 0x10(%r14)
jne 0x40a81
xorl %r12d, %r12d
testq %r12, %r12
je 0x40a1b
movq %r14, %rdi
xorl %esi, %esi
callq 0x40b11
movq -0x38(%rbp), %rax
movq (%rax,%r12,8), %rsi
movq %r14, %rdi
xorl %edx, %edx
callq 0x403ce
incq %r12
cmpq $0x3, %r12
jne 0x40a0c
movq %r14, %rdi
xorl %esi, %esi
callq 0x40b11
movq (%r14), %rdi
leaq 0x28c5a(%rip), %rsi     # 0x696a4
callq 0x178d8
movl $0xfffffffd, %r12d      # imm = 0xFFFFFFFD
movq %r14, %rdi
xorl %esi, %esi
callq 0x40b11
movq -0x38(%rbp), %rax
movl -0x2c(%rbp), %ecx
addl %r12d, %ecx
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rsi
movq %r14, %rdi
xorl %edx, %edx
callq 0x403ce
incl %r12d
jne 0x40a55
jmp 0x40af2
movl -0x2c(%rbp), %eax
testl %eax, %eax
jle 0x40af2
xorl %r12d, %r12d
testq %r12, %r12
je 0x40aa1
xorl %esi, %esi
cmpl $0xa, %eax
setl %sil
movq %r14, %rdi
callq 0x40b11
movq -0x38(%rbp), %rax
movq (%rax,%r12,8), %rsi
movq %r14, %rdi
xorl %edx, %edx
callq 0x403ce
incq %r12
movslq -0x2c(%rbp), %rax
cmpq %rax, %r12
jl 0x40a8b
jmp 0x40af2
movq (%r14), %rdi
leaq 0x28bd9(%rip), %rsi     # 0x696a4
callq 0x178d8
addl $-0x2, 0xc(%r14)
incl 0x8(%r14)
movq (%r14), %rdi
movl $0x7d, %esi
jmp 0x40b02
movq (%r14), %rdi
leaq 0x28bb7(%rip), %rsi     # 0x696a4
callq 0x178d8
addl $-0x2, 0xc(%r14)
incl 0x8(%r14)
movq (%r14), %rdi
movzbl %r15b, %esi
callq 0x179a7
jmp 0x40475
callq 0x13e80