// File: /workspace/github_c_makefile_star2_O3/theandrew168[P]squeaky/src/value.c
// Function: value_print
void
value_print(FILE* fp, const struct value* value)
{
    switch (value->type) {
        case VALUE_EMPTY_LIST:
            fprintf(fp, "'()");
            break;
        case VALUE_BOOLEAN:
            fprintf(fp, "#%c", value->as.boolean ? 't' : 'f');
            break;
        case VALUE_CHARACTER:
            // TODO: how to support UTF-8 here?
            if (value->as.character == ' ') {
                fprintf(fp, "#\\space");
            } else if (value->as.character == '\n') {
                fprintf(fp, "#\\newline");
            } else {
                fprintf(fp, "#\\%c", value->as.character);
            }
            break;
        case VALUE_NUMBER:
            fprintf(fp, "%ld", value->as.number);
            break;
        case VALUE_STRING:
            // TODO: handle escapes
            fprintf(fp, "\"%s\"", value->as.string);
            break;
        case VALUE_SYMBOL:
            fprintf(fp, "%s", value->as.symbol);
            break;
        case VALUE_PAIR: {
            fprintf(fp, "(");
            value_print(fp, value->as.pair.car);
            fprintf(fp, " . ");
            value_print(fp, value->as.pair.cdr);
            fprintf(fp, ")");
            break;
        }
        case VALUE_BUILTIN:
            fprintf(fp, "<builtin>");
            break;
        case VALUE_LAMBDA:
            fprintf(fp, "<lambda>");
            break;
        case VALUE_INPUT_PORT:
            fprintf(fp, "<input port>");
            break;
        case VALUE_OUTPUT_PORT:
            fprintf(fp, "<output port>");
            break;
        case VALUE_WINDOW:
            fprintf(fp, "<window>");
            break;
        case VALUE_EVENT: {
            switch (value->as.event->type) {
                case SDL_KEYDOWN:
                case SDL_KEYUP:
                    fprintf(fp, "<event:%s>", "keyboard");
                    break;
                case SDL_MOUSEMOTION:
                    fprintf(fp, "<event:%s>", "mouse-motion");
                    break;
                case SDL_MOUSEBUTTONDOWN:
                case SDL_MOUSEBUTTONUP:
                    fprintf(fp, "<event:%s>", "mouse-button");
                    break;
                case SDL_QUIT:
                    fprintf(fp, "<event:%s>", "quit");
                    break;
                case SDL_WINDOWEVENT:
                    fprintf(fp, "<event:%s>", "window");
                    break;
                default:
                    fprintf(fp, "<event:%s>", "undefined");
            }
            break;
        }
        case VALUE_EOF:
            fprintf(fp, "<EOF>");
            break;
        default:
            fprintf(fp, "<undefined>");
    }
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %rbx
movl (%rsi), %eax
decl %eax
cmpl $0xd, %eax
ja 0x6c0d
movq %rsi, %r14
leaq 0x21bf(%rip), %rcx      # 0x8c40
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
leaq 0x22f3(%rip), %rdi      # 0x8d84
movl $0x3, %esi
jmp 0x6c45
leaq 0x233c(%rip), %rdi      # 0x8dde
jmp 0x6c06
movq 0x10(%r14), %rdx
leaq 0x22f5(%rip), %rsi      # 0x8da7
jmp 0x6b40
movq 0x10(%r14), %rax
movl (%rax), %eax
cmpl $0x3ff, %eax            # imm = 0x3FF
jg 0x6c1b
leal -0x300(%rax), %ecx
cmpl $0x2, %ecx
jb 0x6c71
cmpl $0x100, %eax            # imm = 0x100
je 0x6cb1
cmpl $0x200, %eax            # imm = 0x200
jne 0x6c9e
leaq 0x22f3(%rip), %rsi      # 0x8de7
leaq 0x1697(%rip), %rdx      # 0x8192
jmp 0x6b40
leaq 0x22bf(%rip), %rdi      # 0x8dc3
movl $0xc, %esi
jmp 0x6c45
movl 0x10(%r14), %edx
cmpl $0xa, %edx
je 0x6c39
cmpl $0x20, %edx
jne 0x6c59
leaq 0x2261(%rip), %rdi      # 0x8d8c
movl $0x7, %esi
jmp 0x6c45
movq 0x10(%r14), %rdx
leaq 0x2263(%rip), %rsi      # 0x8da3
movq %rbx, %rdi
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
jmp 0x1220
leaq 0x2258(%rip), %rdi      # 0x8db0
jmp 0x6c40
cmpb $0x0, 0x10(%r14)
movl $0x74, %eax
movl $0x66, %edx
cmovnel %eax, %edx
leaq 0x2212(%rip), %rsi      # 0x8d88
jmp 0x6c60
movq 0x10(%r14), %rdi
movq %rbx, %rsi
addq $0x8, %rsp
popq %rbx
popq %r14
jmp 0x1180
leaq 0x2277(%rip), %rdi      # 0x8e0c
movl $0x5, %esi
jmp 0x6c45
movl $0x28, %edi
movq %rbx, %rsi
callq 0x11c0
movq 0x10(%r14), %rsi
movq %rbx, %rdi
callq 0x6a63
leaq 0x21ed(%rip), %rdi      # 0x8dac
movl $0x3, %esi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x1260
movq 0x18(%r14), %rsi
movq %rbx, %rdi
callq 0x6a63
movl $0x29, %edi
movq %rbx, %rsi
addq $0x8, %rsp
popq %rbx
popq %r14
jmp 0x11c0
leaq 0x21d8(%rip), %rdi      # 0x8dd0
movl $0xd, %esi
jmp 0x6c45
leaq 0x21b4(%rip), %rdi      # 0x8dba
movl $0x8, %esi
jmp 0x6c45
leaq 0x21fe(%rip), %rdi      # 0x8e12
movl $0xb, %esi
jmp 0x6c45
leal -0x401(%rax), %ecx
cmpl $0x2, %ecx
jae 0x6c84
leaq 0x21ba(%rip), %rsi      # 0x8de7
leaq 0x21cb(%rip), %rdx      # 0x8dff
jmp 0x6b40
leaq 0x2154(%rip), %rdi      # 0x8d94
movl $0x9, %esi
movl $0x1, %edx
movq %rbx, %rcx
addq $0x8, %rsp
popq %rbx
popq %r14
jmp 0x1260
leaq 0x213e(%rip), %rsi      # 0x8d9e
movq %rbx, %rdi
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
jmp 0x1220
leaq 0x216f(%rip), %rsi      # 0x8de7
leaq 0x170d(%rip), %rdx      # 0x838c
jmp 0x6b40
cmpl $0x400, %eax            # imm = 0x400
jne 0x6c9e
leaq 0x2155(%rip), %rsi      # 0x8de7
leaq 0x2159(%rip), %rdx      # 0x8df2
jmp 0x6b40
leaq 0x2142(%rip), %rsi      # 0x8de7
leaq 0x172b(%rip), %rdx      # 0x83d7
jmp 0x6b40
leaq 0x212f(%rip), %rsi      # 0x8de7
leaq 0x1700(%rip), %rdx      # 0x83bf
jmp 0x6b40