// File: Davidc2525[P]Leaf/main.cpp
// Function: label_of_function[abi:cxx11](Obj*)
string *label_of_function(Obj *f)
{

    string *label = new string();

    label->append(f->name->c_str());
    label->append("_");

    Obj *last = f->locals;

    while (last != NULL)
    {
        label->append("@");
        Struct *last_type = last->type;
        while (last_type->kind == Struct::Pointer || last_type->kind == Struct::Arr || last_type->kind == Struct::Func)
        {
            label->append(to_string(last_type->kind));
            label->append("_");
            last_type = last_type->elemType;
        }

        label->append(to_string(last_type->kind));
        label->append("");
        label->append("_");
        last = last->next;
    }

    Struct *last_type = f->type->elemType;
    label->append("#");
    while (last_type->kind == Struct::Pointer || last_type->kind == Struct::Arr || last_type->kind == Struct::Func)
    {
        label->append(to_string(last_type->kind));
        label->append("_");
        last_type = last_type->elemType;
    }
    label->append(to_string(last_type->kind));
    label->append(":");

    return label;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x120, %rsp            # imm = 0x120
movq %rdi, -0x8(%rbp)
movl $0x20, %edi
callq 0x62e0
movq %rax, %rdi
movq %rdi, -0xc8(%rbp)
callq 0x6430
movq -0xc8(%rbp), %rax
movq %rax, -0x10(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0xc0(%rbp)
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rdi
callq 0x6120
movq -0xc0(%rbp), %rdi
movq %rax, %rsi
callq 0x6540
movq -0x10(%rbp), %rdi
leaq 0x29d22(%rip), %rsi     # 0x342b7
callq 0x6540
movq -0x8(%rbp), %rax
movq 0x40(%rax), %rax
movq %rax, -0x18(%rbp)
cmpq $0x0, -0x18(%rbp)
je 0xa714
movq -0x10(%rbp), %rdi
leaq 0x29a74(%rip), %rsi     # 0x34030
callq 0x6540
movq -0x18(%rbp), %rax
movq 0x18(%rax), %rax
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rcx
movb $0x1, %al
cmpl $0xc, 0x10(%rcx)
movb %al, -0xc9(%rbp)
je 0xa602
movq -0x20(%rbp), %rcx
movb $0x1, %al
cmpl $0x5, 0x10(%rcx)
movb %al, -0xc9(%rbp)
je 0xa602
movq -0x20(%rbp), %rax
cmpl $0x9, 0x10(%rax)
sete %al
movb %al, -0xc9(%rbp)
movb -0xc9(%rbp), %al
testb $0x1, %al
jne 0xa60e
jmp 0xa689
movq -0x10(%rbp), %rax
movq %rax, -0xe0(%rbp)
movq -0x20(%rbp), %rax
movl 0x10(%rax), %esi
leaq -0x40(%rbp), %rdi
movq %rdi, -0xd8(%rbp)
callq 0xae50
movq -0xe0(%rbp), %rdi
movq -0xd8(%rbp), %rsi
callq 0x6550
jmp 0xa645
leaq -0x40(%rbp), %rdi
callq 0x6588
movq -0x10(%rbp), %rdi
leaq 0x29c5e(%rip), %rsi     # 0x342b7
callq 0x6540
movq -0x20(%rbp), %rax
movq 0x18(%rax), %rax
movq %rax, -0x20(%rbp)
jmp 0xa5cd
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0x40(%rbp), %rdi
callq 0x6588
jmp 0xa874
movq -0x10(%rbp), %rax
movq %rax, -0xf0(%rbp)
movq -0x20(%rbp), %rax
movl 0x10(%rax), %esi
leaq -0x70(%rbp), %rdi
movq %rdi, -0xe8(%rbp)
callq 0xae50
movq -0xf0(%rbp), %rdi
movq -0xe8(%rbp), %rsi
callq 0x6550
jmp 0xa6c0
leaq -0x70(%rbp), %rdi
callq 0x6588
movq -0x10(%rbp), %rdi
leaq 0x2b499(%rip), %rsi     # 0x35b6d
callq 0x6540
movq -0x10(%rbp), %rdi
leaq 0x29bd3(%rip), %rsi     # 0x342b7
callq 0x6540
movq -0x18(%rbp), %rax
movq 0x20(%rax), %rax
movq %rax, -0x18(%rbp)
jmp 0xa5a6
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0x70(%rbp), %rdi
callq 0x6588
jmp 0xa874
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rax
movq 0x18(%rax), %rax
movq %rax, -0x78(%rbp)
movq -0x10(%rbp), %rdi
leaq 0x29903(%rip), %rsi     # 0x34032
callq 0x6540
movq -0x78(%rbp), %rcx
movb $0x1, %al
cmpl $0xc, 0x10(%rcx)
movb %al, -0xf1(%rbp)
je 0xa769
movq -0x78(%rbp), %rcx
movb $0x1, %al
cmpl $0x5, 0x10(%rcx)
movb %al, -0xf1(%rbp)
je 0xa769
movq -0x78(%rbp), %rax
cmpl $0x9, 0x10(%rax)
sete %al
movb %al, -0xf1(%rbp)
movb -0xf1(%rbp), %al
testb $0x1, %al
jne 0xa778
jmp 0xa7f9
movq -0x10(%rbp), %rax
movq %rax, -0x108(%rbp)
movq -0x78(%rbp), %rax
movl 0x10(%rax), %esi
leaq -0x98(%rbp), %rdi
movq %rdi, -0x100(%rbp)
callq 0xae50
movq -0x108(%rbp), %rdi
movq -0x100(%rbp), %rsi
callq 0x6550
jmp 0xa7b2
leaq -0x98(%rbp), %rdi
callq 0x6588
movq -0x10(%rbp), %rdi
leaq 0x29aee(%rip), %rsi     # 0x342b7
callq 0x6540
movq -0x78(%rbp), %rax
movq 0x18(%rax), %rax
movq %rax, -0x78(%rbp)
jmp 0xa734
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0x98(%rbp), %rdi
callq 0x6588
jmp 0xa874
movq -0x10(%rbp), %rax
movq %rax, -0x118(%rbp)
movq -0x78(%rbp), %rax
movl 0x10(%rax), %esi
leaq -0xb8(%rbp), %rdi
movq %rdi, -0x110(%rbp)
callq 0xae50
movq -0x118(%rbp), %rdi
movq -0x110(%rbp), %rsi
callq 0x6550
jmp 0xa833
leaq -0xb8(%rbp), %rdi
callq 0x6588
movq -0x10(%rbp), %rdi
leaq 0x297ea(%rip), %rsi     # 0x34034
callq 0x6540
movq -0x10(%rbp), %rax
addq $0x120, %rsp            # imm = 0x120
popq %rbp
retq
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0xb8(%rbp), %rdi
callq 0x6588
movq -0x48(%rbp), %rdi
callq 0x64f0
nopl (%rax)