// File: /workspace/github_c_makefile_star2_O2/voithos[P]awl/src/types.c
// Function: awlval_copy
awlval* awlval_copy(const awlval* v) {
    awlval* x = safe_malloc(sizeof(awlval));
    x->type = v->type;

    switch (v->type) {
        case AWLVAL_BUILTIN:
            x->builtin = v->builtin;
            x->builtin_name = safe_malloc(strlen(v->builtin_name) + 1);
            strcpy(x->builtin_name, v->builtin_name);
            break;

        case AWLVAL_FN:
        case AWLVAL_MACRO:
            x->env = awlenv_copy(v->env);
            x->formals = awlval_copy(v->formals);
            x->body = awlval_copy(v->body);
            x->called = v->called;
            break;

        case AWLVAL_INT:
            x->lng = v->lng;
            break;

        case AWLVAL_FLOAT:
            x->dbl = v->dbl;
            break;

        case AWLVAL_ERR:
            x->err = safe_malloc(strlen(v->err) + 1);
            strcpy(x->err, v->err);
            break;

        case AWLVAL_SYM:
        case AWLVAL_QSYM:
            x->length = v->length;
            x->sym = safe_malloc(strlen(v->sym) + 1);
            strcpy(x->sym, v->sym);
            break;

        case AWLVAL_STR:
            x->length = v->length;
            x->str = safe_malloc(strlen(v->str) + 1);
            strcpy(x->str, v->str);
            break;

        case AWLVAL_BOOL:
            x->bln = v->bln;
            break;

        case AWLVAL_DICT:
            x->count = v->count;
            x->length = v->length;
            x->d = dict_copy(v->d);
            break;

        case AWLVAL_SEXPR:
        case AWLVAL_QEXPR:
        case AWLVAL_EEXPR:
        case AWLVAL_CEXPR:
            x->count = v->count;
            x->length = v->length;
            x->cell = safe_malloc(sizeof(awlval*) * x->count);
            for (int i = 0; i < x->count; i++) {
                x->cell[i] = awlval_copy(v->cell[i]);
            }
            break;
    }

    return x;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %r14
pushq $0x38
popq %rdi
callq 0xdc33
movq %rax, %rbx
movl (%r14), %eax
movl %eax, (%rbx)
cmpq $0xe, %rax
ja 0xe2ad
leaq 0x34e8(%rip), %rcx      # 0x11684
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movslq 0x4(%r14), %rbp
movl %ebp, 0x4(%rbx)
movl 0x10(%r14), %eax
movl %eax, 0x10(%rbx)
movq %rbp, %rdi
shlq $0x3, %rdi
callq 0xdc33
movq %rax, %r15
movq %rax, 0x8(%rbx)
xorl %r12d, %r12d
testl %ebp, %ebp
movl $0x0, %r13d
cmovgl %ebp, %r13d
cmpq %r12, %r13
je 0xe2ad
movq 0x8(%r14), %rax
movq (%rax,%r12,8), %rdi
callq 0xe16d
movq %rax, (%r15,%r12,8)
incq %r12
jmp 0xe1d5
movl 0x10(%r14), %eax
movl %eax, 0x10(%rbx)
movq 0x18(%r14), %rdi
callq 0x2110
leaq 0x1(%rax), %rdi
callq 0xdc33
movq %rax, 0x18(%rbx)
movq 0x18(%r14), %rsi
movq %rax, %rdi
callq 0x2080
jmp 0xe2ad
movq 0x18(%r14), %rdi
callq 0xe5f3
movq %rax, 0x18(%rbx)
movq 0x20(%r14), %rdi
callq 0xe16d
movq %rax, 0x20(%rbx)
movq 0x28(%r14), %rdi
callq 0xe16d
movq %rax, 0x28(%rbx)
movb 0x30(%r14), %al
movb %al, 0x30(%rbx)
jmp 0xe2ad
movb 0x18(%r14), %al
movb %al, 0x18(%rbx)
jmp 0xe2ad
movq 0x18(%r14), %rax
jmp 0xe2a9
movsd 0x18(%r14), %xmm0
movsd %xmm0, 0x18(%rbx)
jmp 0xe2ad
movq 0x18(%r14), %rax
movq %rax, 0x18(%rbx)
movq 0x20(%r14), %rdi
callq 0x2110
leaq 0x1(%rax), %rdi
callq 0xdc33
movq %rax, 0x20(%rbx)
movq 0x20(%r14), %rsi
jmp 0xe215
movl 0x4(%r14), %eax
movl %eax, 0x4(%rbx)
movl 0x10(%r14), %eax
movl %eax, 0x10(%rbx)
movq 0x18(%r14), %rdi
callq 0x5186
movq %rax, 0x18(%rbx)
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq