// File: /workspace/github_c_makefile_star2_O3/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 %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
movq %rdi, %r14
movl $0x38, %edi
callq 0x2290
testq %rax, %rax
je 0x10747
movq %rax, %rbx
movl (%r14), %eax
movl %eax, (%rbx)
cmpq $0xe, %rax
ja 0x1073a
leaq 0x30bd(%rip), %rcx      # 0x1368c
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movslq 0x4(%r14), %r12
movl %r12d, 0x4(%rbx)
movl 0x10(%r14), %eax
movl %eax, 0x10(%rbx)
leaq (,%r12,8), %rdi
callq 0x2290
testq %rax, %rax
je 0x1074c
movq %rax, %r15
movq %rax, 0x8(%rbx)
testl %r12d, %r12d
jle 0x1073a
xorl %r13d, %r13d
movq 0x8(%r14), %rax
movq (%rax,%r13,8), %rdi
callq 0x10597
movq %rax, (%r15,%r13,8)
incq %r13
cmpq %r13, %r12
jne 0x10610
jmp 0x1073a
movq 0x18(%r14), %rdi
callq 0x10b56
movq %rax, 0x18(%rbx)
movq 0x20(%r14), %rdi
callq 0x10597
movq %rax, 0x20(%rbx)
movq 0x28(%r14), %rdi
callq 0x10597
movq %rax, 0x28(%rbx)
movb 0x30(%r14), %al
movb %al, 0x30(%rbx)
jmp 0x1073a
movl 0x10(%r14), %eax
movl %eax, 0x10(%rbx)
movq 0x18(%r14), %r14
movq %r14, %rdi
callq 0x2110
leaq 0x1(%rax), %rdi
callq 0x2290
testq %rax, %rax
jne 0x106d3
callq 0x2959
movb 0x18(%r14), %al
movb %al, 0x18(%rbx)
jmp 0x1073a
movl 0x10(%r14), %eax
movl %eax, 0x10(%rbx)
movq 0x18(%r14), %r14
movq %r14, %rdi
callq 0x2110
leaq 0x1(%rax), %rdi
callq 0x2290
testq %rax, %rax
jne 0x106d3
callq 0x2934
movq 0x18(%r14), %r14
movq %r14, %rdi
callq 0x2110
leaq 0x1(%rax), %rdi
callq 0x2290
testq %rax, %rax
je 0x10751
movq %rax, 0x18(%rbx)
movq %rax, %rdi
movq %r14, %rsi
callq 0x2080
jmp 0x1073a
movq 0x18(%r14), %rax
jmp 0x10736
movsd 0x18(%r14), %xmm0
movsd %xmm0, 0x18(%rbx)
jmp 0x1073a
movq 0x18(%r14), %rax
movq %rax, 0x18(%rbx)
movq 0x20(%r14), %r14
movq %r14, %rdi
callq 0x2110
leaq 0x1(%rax), %rdi
callq 0x2290
testq %rax, %rax
je 0x10756
movq %rax, 0x20(%rbx)
jmp 0x106d7
movl 0x4(%r14), %eax
movl %eax, 0x4(%rbx)
movl 0x10(%r14), %eax
movl %eax, 0x10(%rbx)
movq 0x18(%r14), %rdi
callq 0x5a6c
movq %rax, 0x18(%rbx)
movq %rbx, %rax
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
callq 0x29c8
callq 0x290f
callq 0x297e
callq 0x29a3