// File: /workspace/github_cpp_makefile_star2_O2/lega911[P]ijson/src/exception.cpp
// Function: get_traceback(Buffer&)
void get_traceback(Buffer &r) {
        void *addr[32];
        char **names;

        int n = backtrace(addr, 32);
        names = backtrace_symbols(addr, n);
        if(!names) return;

        size_t funcsize = 256;
        char *func = (char*)malloc(funcsize);

        Buffer bname(256);
        for(int i = 1; i<n; i++) {
            Slice line(names[i]);
            Slice file = line.split_left('(');
            Slice _name = line.split_left('+');
            line = line.split_left(')');
            bname.set(_name);
            bname.add("\0", 1);

            int status;
	        char* ret = abi::__cxa_demangle(bname.ptr(), func, &funcsize, &status);
            if(status == 0) {
                func = ret;
                r.add(file);
                r.add(": ");
                r.add(func);
                r.add(" +");
                r.add(line);
            } else {
                r.add((char*)names[i]);
            }
            r.add("\n");
        }
        r.add("\0", 1);
        free(func);
        free(names);
    }

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x168, %rsp            # imm = 0x168
movq %rdi, %rbx
leaq -0x190(%rbp), %r14
pushq $0x20
popq %rsi
movq %r14, %rdi
callq 0xa3e0
movl %eax, %r15d
movq %r14, %rdi
movl %eax, %esi
callq 0xa3f0
movq %rax, -0x30(%rbp)
testq %rax, %rax
je 0xe35f
leaq -0x68(%rbp), %rax
movq $0x100, (%rax)          # imm = 0x100
movl $0x100, %edi            # imm = 0x100
callq 0xa380
movq %rax, %r12
leaq -0x58(%rbp), %rdi
movl $0x100, %esi            # imm = 0x100
callq 0xd53a
movslq %r15d, %rax
movq %rax, -0x60(%rbp)
pushq $0x1
popq %r14
leaq -0x48(%rbp), %r13
cmpq -0x60(%rbp), %r14
jge 0xe333
movq -0x30(%rbp), %rax
movq (%rax,%r14,8), %rdi
andl $0x0, -0x40(%rbp)
movq %rdi, -0x48(%rbp)
callq 0xa120
movl %eax, -0x40(%rbp)
movq %r13, %rdi
pushq $0x28
popq %rsi
callq 0xe552
movq %rax, -0x88(%rbp)
movl %edx, -0x80(%rbp)
movq %r13, %rdi
pushq $0x2b
popq %rsi
callq 0xe552
movq %rax, -0x78(%rbp)
movl %edx, -0x70(%rbp)
movq %r13, %rdi
pushq $0x29
popq %rsi
callq 0xe552
movq %rax, -0x48(%rbp)
movl %edx, -0x40(%rbp)
leaq -0x58(%rbp), %rdi
leaq -0x78(%rbp), %rsi
callq 0xd3d0
leaq -0x58(%rbp), %rdi
leaq 0xa885(%rip), %rsi      # 0x18b21
pushq $0x1
popq %rdx
callq 0xd24c
movq -0x58(%rbp), %rdi
movq %r12, %rsi
leaq -0x68(%rbp), %rdx
leaq -0x34(%rbp), %rcx
callq 0xa260
cmpl $0x0, -0x34(%rbp)
je 0xe2d3
movq -0x30(%rbp), %rax
movq (%rax,%r14,8), %rsi
movq %rbx, %rdi
callq 0xd5ee
movq %r12, %r15
jmp 0xe319
movq %rax, %r15
movq %rbx, %rdi
leaq -0x88(%rbp), %rsi
callq 0xd300
movq %rbx, %rdi
leaq 0xb128(%rip), %rsi      # 0x19417
callq 0xd5ee
movq %rbx, %rdi
movq %r15, %rsi
callq 0xd5ee
movq %rbx, %rdi
leaq 0xa815(%rip), %rsi      # 0x18b1e
callq 0xd5ee
movq %rbx, %rdi
movq %r13, %rsi
callq 0xd300
movq %rbx, %rdi
leaq 0xa37f(%rip), %rsi      # 0x186a2
callq 0xd5ee
incq %r14
movq %r15, %r12
jmp 0xe229
leaq 0xa7e7(%rip), %rsi      # 0x18b21
pushq $0x1
popq %rdx
movq %rbx, %rdi
callq 0xd24c
movq %r12, %rdi
callq 0xa340
movq -0x30(%rbp), %rdi
callq 0xa340
leaq -0x58(%rbp), %rdi
callq 0xd6dc
addq $0x168, %rsp            # imm = 0x168
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0xe379
jmp 0xe379
jmp 0xe379
jmp 0xe379
movq %rax, %rbx
leaq -0x58(%rbp), %rdi
callq 0xd6dc
movq %rbx, %rdi
callq 0xa470
nop