// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x8(%rbp)
movl $0x38, %edi
callq 0x16720
movq %rax, -0x10(%rbp)
movq -0x8(%rbp), %rax
movl (%rax), %ecx
movq -0x10(%rbp), %rax
movl %ecx, (%rax)
movq -0x8(%rbp), %rax
movl (%rax), %eax
movq %rax, -0x20(%rbp)
subq $0xe, %rax
ja 0x1749b
movq -0x20(%rbp), %rax
leaq 0x47df(%rip), %rcx      # 0x1b9f4
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x18(%rax)
movq -0x8(%rbp), %rax
movq 0x20(%rax), %rdi
callq 0x20f0
movq %rax, %rdi
addq $0x1, %rdi
callq 0x16720
movq %rax, %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x20(%rax)
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rdi
movq -0x8(%rbp), %rax
movq 0x20(%rax), %rsi
callq 0x2070
jmp 0x1749b
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
callq 0x17c20
movq %rax, %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x18(%rax)
movq -0x8(%rbp), %rax
movq 0x20(%rax), %rdi
callq 0x171d0
movq %rax, %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x20(%rax)
movq -0x8(%rbp), %rax
movq 0x28(%rax), %rdi
callq 0x171d0
movq %rax, %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x28(%rax)
movq -0x8(%rbp), %rax
movb 0x30(%rax), %cl
movq -0x10(%rbp), %rax
andb $0x1, %cl
movb %cl, 0x30(%rax)
jmp 0x1749b
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x18(%rax)
jmp 0x1749b
movq -0x8(%rbp), %rax
movsd 0x18(%rax), %xmm0
movq -0x10(%rbp), %rax
movsd %xmm0, 0x18(%rax)
jmp 0x1749b
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
callq 0x20f0
movq %rax, %rdi
addq $0x1, %rdi
callq 0x16720
movq %rax, %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x18(%rax)
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rdi
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rsi
callq 0x2070
jmp 0x1749b
movq -0x8(%rbp), %rax
movl 0x10(%rax), %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x10(%rax)
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
callq 0x20f0
movq %rax, %rdi
addq $0x1, %rdi
callq 0x16720
movq %rax, %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x18(%rax)
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rdi
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rsi
callq 0x2070
jmp 0x1749b
movq -0x8(%rbp), %rax
movl 0x10(%rax), %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x10(%rax)
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
callq 0x20f0
movq %rax, %rdi
addq $0x1, %rdi
callq 0x16720
movq %rax, %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x18(%rax)
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rdi
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rsi
callq 0x2070
jmp 0x1749b
movq -0x8(%rbp), %rax
movb 0x18(%rax), %cl
movq -0x10(%rbp), %rax
andb $0x1, %cl
movb %cl, 0x18(%rax)
jmp 0x1749b
movq -0x8(%rbp), %rax
movl 0x4(%rax), %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x4(%rax)
movq -0x8(%rbp), %rax
movl 0x10(%rax), %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x10(%rax)
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
callq 0x7350
movq %rax, %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x18(%rax)
jmp 0x1749b
movq -0x8(%rbp), %rax
movl 0x4(%rax), %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x4(%rax)
movq -0x8(%rbp), %rax
movl 0x10(%rax), %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x10(%rax)
movq -0x10(%rbp), %rax
movslq 0x4(%rax), %rdi
shlq $0x3, %rdi
callq 0x16720
movq %rax, %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x8(%rax)
movl $0x0, -0x14(%rbp)
movl -0x14(%rbp), %eax
movq -0x10(%rbp), %rcx
cmpl 0x4(%rcx), %eax
jge 0x17499
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rax
movslq -0x14(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
callq 0x171d0
movq %rax, %rdx
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movslq -0x14(%rbp), %rcx
movq %rdx, (%rax,%rcx,8)
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0x1745a
jmp 0x1749b
movq -0x10(%rbp), %rax
addq $0x20, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)