// File: /workspace/github_c_makefile_star2_O0/jiribenes[P]scheme/src/write.c
// Function: write
void write(FILE *f, value_t val) {
    if (IS_NUM(val)) {
        write_number(f, AS_NUM(val));
    } else if (IS_NIL(val)) {
        fprintf(f, "()");
    } else if (IS_TRUE(val)) {
        fprintf(f, "#t");
    } else if (IS_FALSE(val)) {
        fprintf(f, "#f");
    } else if (IS_UNDEFINED(val)) {
        fprintf(f, "#<undefined>");
    } else if (IS_VOID(val)) {
        fprintf(f, "#<void>");
    } else if (IS_EOF(val)) {
        fprintf(f, "#<eof>");
    } else if (IS_PTR(val)) {
        if (IS_CONS(val)) {
            cons_t *cons = AS_CONS(val);

            fprintf(f, "(");
            write_cons(f, cons);
            fprintf(f, ")");
        } else if (IS_STRING(val)) {
            string_t *str = AS_STRING(val);
            write_string(f, str);
        } else if (IS_SYMBOL(val)) {
            symbol_t *sym = AS_SYMBOL(val);
            fprintf(f, "%s", sym->name);
        } else if (IS_PRIMITIVE(val)) {
            // TODO: A lot of repetition going on here, can we shorten this?
            primitive_t *prim = AS_PRIMITIVE(val);
            fprintf(f, "#<primitive ");
            if (prim->name != NULL) {
                display(f, PTR_VAL(prim->name));
            } else {
                fprintf(f, "?");
            }
            fprintf(f, ">");
        } else if (IS_FUNCTION(val)) {
            fprintf(f, "#<function ");
            function_t *fn = AS_FUNCTION(val);
            if (fn->name != NULL) {
                display(f, PTR_VAL(fn->name));
            } else {
                fprintf(f, "?");
            }
            fprintf(f, " ");
            write(f, fn->params);
            fprintf(f, ">");
        } else if (IS_MACRO(val)) {
            fprintf(f, "#<macro ");
            function_t *mac = AS_MACRO(val);
            if (mac->name != NULL) {
                display(f, PTR_VAL(mac->name));
            } else {
                fprintf(f, "?");
            }
            fprintf(f, ">");
        } else if (IS_VECTOR(val)) {
            vector_t *vec = AS_VECTOR(val);
            write_vector(f, vec);
        } else if (IS_ENV(val)) {
            env_t *env = (env_t *) AS_PTR(val);
            fprintf(f, "#<");
            if (env == NULL) {
                fprintf(f, "top level ");
            }
            fprintf(f, "environment>");
        } else {
            fprintf(f, "#<unknown ptrvalue>");
        }
    } else {
        fprintf(f, "#<unknown value>");
    }
}

// Assembly:
subq $0x78, %rsp
movq %rdi, 0x70(%rsp)
movq %rsi, 0x68(%rsp)
movabsq $0x7ffc000000000000, %rax # imm = 0x7FFC000000000000
andq 0x68(%rsp), %rax
movabsq $0x7ffc000000000000, %rcx # imm = 0x7FFC000000000000
cmpq %rcx, %rax
je 0x8d7f
movq 0x70(%rsp), %rax
movq %rax, 0x20(%rsp)
movq 0x68(%rsp), %rdi
callq 0x9350
movq 0x20(%rsp), %rdi
callq 0x9270
jmp 0x9268
movabsq $0x7ffc000000000001, %rax # imm = 0x7FFC000000000001
cmpq %rax, 0x68(%rsp)
jne 0x8da8
movq 0x70(%rsp), %rdi
leaq 0x1ed4(%rip), %rsi      # 0xac70
movb $0x0, %al
callq 0x1120
jmp 0x9266
movabsq $0x7ffc000000000002, %rax # imm = 0x7FFC000000000002
cmpq %rax, 0x68(%rsp)
jne 0x8dd1
movq 0x70(%rsp), %rdi
leaq 0x1eae(%rip), %rsi      # 0xac73
movb $0x0, %al
callq 0x1120
jmp 0x9264
movabsq $0x7ffc000000000003, %rax # imm = 0x7FFC000000000003
cmpq %rax, 0x68(%rsp)
jne 0x8dfa
movq 0x70(%rsp), %rdi
leaq 0x1e88(%rip), %rsi      # 0xac76
movb $0x0, %al
callq 0x1120
jmp 0x9262
movabsq $0x7ffc000000000004, %rax # imm = 0x7FFC000000000004
cmpq %rax, 0x68(%rsp)
jne 0x8e23
movq 0x70(%rsp), %rdi
leaq 0x1e62(%rip), %rsi      # 0xac79
movb $0x0, %al
callq 0x1120
jmp 0x9260
movabsq $0x7ffc000000000005, %rax # imm = 0x7FFC000000000005
cmpq %rax, 0x68(%rsp)
jne 0x8e4c
movq 0x70(%rsp), %rdi
leaq 0x1e46(%rip), %rsi      # 0xac86
movb $0x0, %al
callq 0x1120
jmp 0x925e
movabsq $0x7ffc000000000006, %rax # imm = 0x7FFC000000000006
cmpq %rax, 0x68(%rsp)
jne 0x8e75
movq 0x70(%rsp), %rdi
leaq 0x1e25(%rip), %rsi      # 0xac8e
movb $0x0, %al
callq 0x1120
jmp 0x925c
movabsq $-0x4000000000000, %rax # imm = 0xFFFC000000000000
andq 0x68(%rsp), %rax
movabsq $-0x4000000000000, %rcx # imm = 0xFFFC000000000000
cmpq %rcx, %rax
jne 0x9247
movq 0x68(%rsp), %rdi
xorl %esi, %esi
callq 0x9370
testb $0x1, %al
jne 0x8ea9
jmp 0x8ef7
movabsq $0x3ffffffffffff, %rax  # imm = 0x3FFFFFFFFFFFF
andq 0x68(%rsp), %rax
movq %rax, 0x60(%rsp)
movq 0x70(%rsp), %rdi
leaq 0x1e73(%rip), %rsi      # 0xad3c
movb $0x0, %al
callq 0x1120
movq 0x70(%rsp), %rdi
movq 0x60(%rsp), %rsi
callq 0x93c0
movq 0x70(%rsp), %rdi
leaq 0x181e(%rip), %rsi      # 0xa709
movb $0x0, %al
callq 0x1120
jmp 0x9245
movq 0x68(%rsp), %rdi
movl $0x1, %esi
callq 0x9370
testb $0x1, %al
jne 0x8f0c
jmp 0x8f34
movabsq $0x3ffffffffffff, %rax  # imm = 0x3FFFFFFFFFFFF
andq 0x68(%rsp), %rax
movq %rax, 0x58(%rsp)
movq 0x70(%rsp), %rdi
movq 0x58(%rsp), %rsi
callq 0x9510
jmp 0x9243
movq 0x68(%rsp), %rdi
movl $0x2, %esi
callq 0x9370
testb $0x1, %al
jne 0x8f49
jmp 0x8f7e
movabsq $0x3ffffffffffff, %rax  # imm = 0x3FFFFFFFFFFFF
andq 0x68(%rsp), %rax
movq %rax, 0x50(%rsp)
movq 0x70(%rsp), %rdi
movq 0x50(%rsp), %rdx
addq $0x20, %rdx
leaq 0x1d23(%rip), %rsi      # 0xac95
movb $0x0, %al
callq 0x1120
jmp 0x9241
movq 0x68(%rsp), %rdi
movl $0x3, %esi
callq 0x9370
testb $0x1, %al
jne 0x8f96
jmp 0x901b
movabsq $0x3ffffffffffff, %rax  # imm = 0x3FFFFFFFFFFFF
andq 0x68(%rsp), %rax
movq %rax, 0x48(%rsp)
movq 0x70(%rsp), %rdi
leaq 0x1ce2(%rip), %rsi      # 0xac98
movb $0x0, %al
callq 0x1120
movq 0x48(%rsp), %rax
cmpq $0x0, 0x10(%rax)
je 0x8ff0
movq 0x70(%rsp), %rax
movq %rax, 0x18(%rsp)
movq 0x48(%rsp), %rax
movq 0x10(%rax), %rdi
callq 0x96a0
movq 0x18(%rsp), %rdi
movq %rax, %rsi
callq 0x9600
jmp 0x9003
movq 0x70(%rsp), %rdi
leaq 0x10fe(%rip), %rsi      # 0xa0fa
movb $0x0, %al
callq 0x1120
movq 0x70(%rsp), %rdi
leaq 0x1c75(%rip), %rsi      # 0xac84
movb $0x0, %al
callq 0x1120
jmp 0x923f
movq 0x68(%rsp), %rdi
movl $0x4, %esi
callq 0x9370
testb $0x1, %al
jne 0x9033
jmp 0x90de
movq 0x70(%rsp), %rdi
leaq 0x1c66(%rip), %rsi      # 0xaca5
movb $0x0, %al
callq 0x1120
movabsq $0x3ffffffffffff, %rax  # imm = 0x3FFFFFFFFFFFF
andq 0x68(%rsp), %rax
movq %rax, 0x40(%rsp)
movq 0x40(%rsp), %rax
cmpq $0x0, 0x10(%rax)
je 0x908d
movq 0x70(%rsp), %rax
movq %rax, 0x10(%rsp)
movq 0x40(%rsp), %rax
movq 0x10(%rax), %rdi
callq 0x96a0
movq 0x10(%rsp), %rdi
movq %rax, %rsi
callq 0x9600
jmp 0x90a0
movq 0x70(%rsp), %rdi
leaq 0x1061(%rip), %rsi      # 0xa0fa
movb $0x0, %al
callq 0x1120
movq 0x70(%rsp), %rdi
leaq 0x1c81(%rip), %rsi      # 0xad2d
movb $0x0, %al
callq 0x1120
movq 0x70(%rsp), %rdi
movq 0x40(%rsp), %rax
movq 0x20(%rax), %rsi
callq 0x8d30
movq 0x70(%rsp), %rdi
leaq 0x1bb2(%rip), %rsi      # 0xac84
movb $0x0, %al
callq 0x1120
jmp 0x923d
movq 0x68(%rsp), %rdi
movl $0x5, %esi
callq 0x9370
testb $0x1, %al
jne 0x90f6
jmp 0x917b
movq 0x70(%rsp), %rdi
leaq 0x1baf(%rip), %rsi      # 0xacb1
movb $0x0, %al
callq 0x1120
movabsq $0x3ffffffffffff, %rax  # imm = 0x3FFFFFFFFFFFF
andq 0x68(%rsp), %rax
movq %rax, 0x38(%rsp)
movq 0x38(%rsp), %rax
cmpq $0x0, 0x10(%rax)
je 0x9150
movq 0x70(%rsp), %rax
movq %rax, 0x8(%rsp)
movq 0x38(%rsp), %rax
movq 0x10(%rax), %rdi
callq 0x96a0
movq 0x8(%rsp), %rdi
movq %rax, %rsi
callq 0x9600
jmp 0x9163
movq 0x70(%rsp), %rdi
leaq 0xf9e(%rip), %rsi       # 0xa0fa
movb $0x0, %al
callq 0x1120
movq 0x70(%rsp), %rdi
leaq 0x1b15(%rip), %rsi      # 0xac84
movb $0x0, %al
callq 0x1120
jmp 0x923b
movq 0x68(%rsp), %rdi
movl $0x6, %esi
callq 0x9370
testb $0x1, %al
jne 0x9190
jmp 0x91b8
movabsq $0x3ffffffffffff, %rax  # imm = 0x3FFFFFFFFFFFF
andq 0x68(%rsp), %rax
movq %rax, 0x30(%rsp)
movq 0x70(%rsp), %rdi
movq 0x30(%rsp), %rsi
callq 0x96c0
jmp 0x9239
movq 0x68(%rsp), %rdi
movl $0x7, %esi
callq 0x9370
testb $0x1, %al
jne 0x91cd
jmp 0x9224
movabsq $0x3ffffffffffff, %rax  # imm = 0x3FFFFFFFFFFFF
andq 0x68(%rsp), %rax
movq %rax, 0x28(%rsp)
movq 0x70(%rsp), %rdi
leaq 0x1acd(%rip), %rsi      # 0xacba
movb $0x0, %al
callq 0x1120
cmpq $0x0, 0x28(%rsp)
jne 0x920f
movq 0x70(%rsp), %rdi
leaq 0x1ab5(%rip), %rsi      # 0xacbd
movb $0x0, %al
callq 0x1120
movq 0x70(%rsp), %rdi
leaq 0x1aad(%rip), %rsi      # 0xacc8
movb $0x0, %al
callq 0x1120
jmp 0x9237
movq 0x70(%rsp), %rdi
leaq 0x1aa5(%rip), %rsi      # 0xacd5
movb $0x0, %al
callq 0x1120
jmp 0x9239
jmp 0x923b
jmp 0x923d
jmp 0x923f
jmp 0x9241
jmp 0x9243
jmp 0x9245
jmp 0x925a
movq 0x70(%rsp), %rdi
leaq 0x1a96(%rip), %rsi      # 0xace9
movb $0x0, %al
callq 0x1120
jmp 0x925c
jmp 0x925e
jmp 0x9260
jmp 0x9262
jmp 0x9264
jmp 0x9266
jmp 0x9268
addq $0x78, %rsp
retq
nopl (%rax)