// File: /workspace/github_cpp_makefile_star2_O2/jpcima[P]faustmd/metadata.cpp
// Function: extract_widget(pugi::xml_node, bool, Metadata&)
static int extract_widget(pugi::xml_node node, bool is_active, Metadata &md)
{
    Metadata::Widget w;
    w.type = Metadata::Widget::type_from_name(node.attribute("type").value());
    if (w.type == (Metadata::Widget::Type)-1)
        return -1;

    w.id = std::stoi(node.attribute("id").value());
    w.label = node.child_value("label");
    w.var = node.child_value("varname");

    w.symbol = mangle(w.label);

    if (is_active && (w.type == Metadata::Widget::Type::HSlider ||
                      w.type == Metadata::Widget::Type::VSlider ||
                      w.type == Metadata::Widget::Type::NEntry)) {
        w.init = std::stof(node.child_value("init"));
        w.min = std::stof(node.child_value("min"));
        w.max = std::stof(node.child_value("max"));
        w.step = std::stof(node.child_value("step"));
    }
    else if (is_active && (w.type == Metadata::Widget::Type::Button ||
                           w.type == Metadata::Widget::Type::CheckBox)) {
        w.init = 0;
        w.min = 0;
        w.max = 1;
        w.step = 1;
    }
    else if (!is_active && (w.type == Metadata::Widget::Type::VBarGraph ||
                            w.type == Metadata::Widget::Type::HBarGraph)) {
        w.min = std::stof(node.child_value("min"));
        w.max = std::stof(node.child_value("max"));
    }
    else
        return -1;

    for (pugi::xml_node meta : node.children("meta")) {
        std::string key = meta.attribute("key").value();
        std::string value = meta.child_value();
        if (is_decint_string(key) && value.empty())
            continue;
        w.metadata.emplace_back(key, value);

        if (key == "unit")
            w.unit = value;
        else if (key == "scale") {
            w.scale = Metadata::Widget::scale_from_name(value);
            if (w.scale == (Metadata::Widget::Scale)-1) {
                warns() << "Unrecognized scale type `" << value << "`\n";
                w.scale = Metadata::Widget::Scale::Linear;
            }
        }
        else if (key == "tooltip")
            w.tooltip = value;
        else if (key == "md.symbol")
            w.symbol = mangle(value);
    }

    (is_active ? md.active : md.passive).push_back(std::move(w));
    return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x218, %rsp            # imm = 0x218
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
leaq 0x120(%rsp), %rcx
movq %rax, -0x18(%rcx)
movq %rcx, -0x10(%rcx)
andq $0x0, -0x8(%rcx)
movq %rdx, 0x88(%rsp)
xorl %edx, %edx
movb %dl, (%rcx)
leaq 0x140(%rsp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
movl %esi, 0x44(%rsp)
movb %dl, (%rax)
leaq 0x160(%rsp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
movb %dl, (%rax)
leaq 0x1a8(%rsp), %rax
xorps %xmm0, %xmm0
movups %xmm0, -0x38(%rax)
movups %xmm0, -0x28(%rax)
andq $0x0, -0x18(%rax)
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
movb %dl, (%rax)
andl $0x0, 0x10(%rax)
leaq 0x8(%rsp), %rax
movq %rdi, (%rax)
leaq 0x1d0(%rsp), %rcx
movq %rcx, -0x10(%rcx)
andq $0x0, -0x8(%rcx)
movb %dl, (%rcx)
leaq 0x193b7(%rip), %rsi     # 0x2e65c
movq %rax, %rdi
callq 0x185de
leaq 0x10(%rsp), %rdi
movq %rax, (%rdi)
callq 0x17d46
leaq 0xd8(%rsp), %rdi
movq %rax, %rsi
callq 0x721c
movq 0xd8(%rsp), %rdi
movq 0xe0(%rsp), %rsi
callq 0x1701a
movl %eax, 0x108(%rsp)
pushq $-0x1
popq %rbx
cmpl $-0x1, %eax
je 0x1587c
leaq 0x14ec6(%rip), %rsi     # 0x2a1bf
leaq 0x8(%rsp), %rdi
callq 0x185de
leaq 0x68(%rsp), %rdi
movq %rax, (%rdi)
callq 0x17d46
leaq 0x10(%rsp), %rdi
leaq 0xe8(%rsp), %rdx
movq %rax, %rsi
callq 0x70be
leaq 0x10(%rsp), %rdi
pushq $0xa
popq %rdx
xorl %esi, %esi
callq 0x17240
movl %eax, 0x10c(%rsp)
leaq 0x10(%rsp), %rdi
callq 0x61d0
leaq 0x16537(%rip), %rsi     # 0x2b883
leaq 0x8(%rsp), %rdi
callq 0x18864
leaq 0x110(%rsp), %r14
movq %r14, %rdi
movq %rax, %rsi
callq 0x67e0
leaq 0x1516d(%rip), %rsi     # 0x2a4dd
leaq 0x8(%rsp), %rdi
callq 0x18864
leaq 0x130(%rsp), %rdi
movq %rax, %rsi
callq 0x67e0
leaq 0xc8(%rsp), %rdi
movq %r14, %rsi
callq 0x172d6
movq 0xc8(%rsp), %rsi
movq 0xd0(%rsp), %rdx
leaq 0x10(%rsp), %rdi
callq 0x17198
leaq 0x150(%rsp), %rdi
leaq 0x10(%rsp), %rsi
callq 0x6250
leaq 0x10(%rsp), %rdi
callq 0x61d0
movl 0x108(%rsp), %eax
cmpb $0x0, 0x44(%rsp)
je 0x154f1
leal -0x2(%rax), %ecx
cmpl $0x2, %ecx
ja 0x15583
leaq 0x16494(%rip), %rsi     # 0x2b889
leaq 0x8(%rsp), %rdi
callq 0x18864
leaq 0x10(%rsp), %rdi
leaq 0x68(%rsp), %rdx
movq %rax, %rsi
callq 0x70be
leaq 0x10(%rsp), %rdi
xorl %esi, %esi
callq 0x1750a
movss %xmm0, 0x170(%rsp)
leaq 0x10(%rsp), %rdi
callq 0x61d0
leaq 0x16457(%rip), %rsi     # 0x2b88e
leaq 0x8(%rsp), %rdi
callq 0x18864
leaq 0x10(%rsp), %rdi
leaq 0x68(%rsp), %rdx
movq %rax, %rsi
callq 0x70be
leaq 0x10(%rsp), %rdi
xorl %esi, %esi
callq 0x1750a
movss %xmm0, 0x174(%rsp)
leaq 0x10(%rsp), %rdi
callq 0x61d0
leaq 0x16419(%rip), %rsi     # 0x2b892
leaq 0x8(%rsp), %rdi
callq 0x18864
leaq 0x10(%rsp), %rdi
leaq 0x68(%rsp), %rdx
movq %rax, %rsi
callq 0x70be
leaq 0x10(%rsp), %rdi
xorl %esi, %esi
callq 0x1750a
movss %xmm0, 0x178(%rsp)
leaq 0x10(%rsp), %rdi
callq 0x61d0
leaq 0x19146(%rip), %rsi     # 0x2e601
leaq 0x8(%rsp), %rdi
callq 0x18864
leaq 0x10(%rsp), %rdi
leaq 0x68(%rsp), %rdx
movq %rax, %rsi
callq 0x70be
leaq 0x10(%rsp), %rdi
xorl %esi, %esi
callq 0x1750a
movss %xmm0, 0x17c(%rsp)
jmp 0x15577
addl $-0x5, %eax
cmpl $0x1, %eax
ja 0x1587c
leaq 0x1638a(%rip), %rsi     # 0x2b88e
leaq 0x8(%rsp), %rdi
callq 0x18864
leaq 0x10(%rsp), %rdi
leaq 0x68(%rsp), %rdx
movq %rax, %rsi
callq 0x70be
leaq 0x10(%rsp), %rdi
xorl %esi, %esi
callq 0x1750a
movss %xmm0, 0x174(%rsp)
leaq 0x10(%rsp), %rdi
callq 0x61d0
leaq 0x1634c(%rip), %rsi     # 0x2b892
leaq 0x8(%rsp), %rdi
callq 0x18864
leaq 0x10(%rsp), %rdi
leaq 0x68(%rsp), %rdx
movq %rax, %rsi
callq 0x70be
leaq 0x10(%rsp), %rdi
xorl %esi, %esi
callq 0x1750a
movss %xmm0, 0x178(%rsp)
leaq 0x10(%rsp), %rdi
callq 0x61d0
jmp 0x1559b
cmpl $0x1, %eax
ja 0x1587c
movaps 0x15ded(%rip), %xmm0    # 0x2b380
movups %xmm0, 0x170(%rsp)
leaq 0x15e6d(%rip), %rdx     # 0x2b40f
leaq 0x10(%rsp), %rdi
leaq 0x8(%rsp), %rsi
callq 0x18464
movq 0x20(%rsp), %rax
leaq 0x200(%rsp), %r15
movq %rax, 0x10(%r15)
movups 0x10(%rsp), %xmm0
movaps %xmm0, (%r15)
movq 0x38(%rsp), %rax
leaq 0x1e0(%rsp), %rcx
movq %rax, 0x10(%rcx)
movups 0x28(%rsp), %xmm0
movaps %xmm0, (%rcx)
leaq 0x90(%rsp), %rbp
leaq 0xe8(%rsp), %rbx
leaq 0x68(%rsp), %r13
leaq 0x48(%rsp), %r14
movq %r15, %rdi
leaq 0x1e0(%rsp), %rsi
callq 0x1c2de
testb %al, %al
je 0x1584e
movq %r15, %rdi
callq 0x1c2fe
movq (%rax), %rax
movq %rax, 0x90(%rsp)
movq %rbp, %rdi
leaq 0x14f5f(%rip), %rsi     # 0x2a592
callq 0x185de
movq %rax, 0xe8(%rsp)
movq %rbx, %rdi
callq 0x17d46
movq %r13, %rdi
movq %rax, %rsi
movq %r14, %rdx
callq 0x70be
movq %rbp, %rdi
callq 0x18814
movq %rbx, %rdi
movq %rax, %rsi
movq %r14, %rdx
callq 0x70be
leaq 0xb8(%rsp), %rdi
movq %r13, %rsi
callq 0x172d6
movq 0xb8(%rsp), %rax
movq 0xc0(%rsp), %rcx
movq %rax, 0x48(%rsp)
movq %rcx, 0x50(%rsp)
cmpq %rax, %rcx
je 0x156ef
movq %r14, %rdi
xorl %esi, %esi
callq 0x14a6e
cmpb $0x2d, (%rax)
jne 0x156c1
movq %r14, %rdi
pushq $0x1
popq %rsi
callq 0x8eec
movq %rax, 0x48(%rsp)
movq %rdx, 0x50(%rsp)
jmp 0x156cb
movq 0x48(%rsp), %rax
movq 0x50(%rsp), %rdx
cmpq %rax, %rdx
je 0x156ef
cmpq %rdx, %rax
je 0x156e4
movb (%rax), %cl
addb $-0x30, %cl
incq %rax
cmpb $0xa, %cl
jb 0x156d0
jmp 0x156ef
cmpq $0x0, 0xf0(%rsp)
je 0x15725
leaq 0x180(%rsp), %rdi
movq %r13, %rsi
movq %rbx, %rdx
callq 0x1725c
movq %r13, %rdi
leaq 0x1618a(%rip), %rsi     # 0x2b896
callq 0xd6c9
leaq 0x198(%rsp), %rdi
testb %al, %al
je 0x15742
movq %rbx, %rsi
callq 0x6250
movq %rbx, %rdi
callq 0x61d0
movq %r13, %rdi
callq 0x61d0
movq %r15, %rdi
callq 0x1c352
jmp 0x155fe
movq %r13, %rdi
leaq 0x1614f(%rip), %rsi     # 0x2b89b
callq 0xd6c9
testb %al, %al
je 0x157d3
leaq 0xa8(%rsp), %rdi
movq %rbx, %rsi
callq 0x172d6
movq 0xa8(%rsp), %rdi
movq 0xb0(%rsp), %rsi
callq 0x170de
movl %eax, 0x1b8(%rsp)
cmpl $-0x1, %eax
jne 0x15725
movq %r14, %rdi
callq 0x17524
movq 0x2c853(%rip), %r12     # 0x41fe8
movq %r12, %rdi
leaq 0x16102(%rip), %rsi     # 0x2b8a1
callq 0x63c0
movq %r12, %rdi
movq %rbx, %rsi
callq 0x6390
movq %r12, %rdi
leaq 0x1496f(%rip), %rsi     # 0x2a128
callq 0x63c0
movq %r14, %rdi
callq 0x17538
andl $0x0, 0x1b8(%rsp)
jmp 0x15725
movq %r13, %rdi
leaq 0x160de(%rip), %rsi     # 0x2b8bb
callq 0xd6c9
leaq 0x1c0(%rsp), %rdi
testb %al, %al
jne 0x1571d
movq %r13, %rdi
leaq 0x160c7(%rip), %rsi     # 0x2b8c3
callq 0xd6c9
testb %al, %al
je 0x15725
leaq 0x98(%rsp), %rdi
movq %rbx, %rsi
callq 0x172d6
movq 0x98(%rsp), %rsi
movq 0xa0(%rsp), %rdx
movq %r14, %rdi
callq 0x17198
leaq 0x150(%rsp), %rdi
movq %r14, %rsi
callq 0x6250
movq %r14, %rdi
callq 0x61d0
jmp 0x15725
movq 0x88(%rsp), %rdi
leaq 0xf8(%rdi), %rax
addq $0xe0, %rdi
cmpb $0x0, 0x44(%rsp)
cmoveq %rax, %rdi
xorl %ebx, %ebx
leaq 0x108(%rsp), %rsi
callq 0x1760c
leaq 0x108(%rsp), %rdi
callq 0x7988
movl %ebx, %eax
addq $0x218, %rsp            # imm = 0x218
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x158c5
jmp 0x15908
jmp 0x15908
jmp 0x158c5
jmp 0x15908
jmp 0x15908
jmp 0x158c5
jmp 0x158c5
jmp 0x15908
jmp 0x15908
jmp 0x15908
jmp 0x15908
jmp 0x158c5
jmp 0x158c5
jmp 0x15908
jmp 0x15908
jmp 0x15908
jmp 0x15908
jmp 0x15908
jmp 0x158c5
movq %rax, %rbx
leaq 0x10(%rsp), %rdi
jmp 0x15922
jmp 0x15908
movq %rax, %rbx
leaq 0x48(%rsp), %rdi
callq 0x61d0
jmp 0x15910
jmp 0x1590d
jmp 0x15908
jmp 0x15908
jmp 0x1590d
jmp 0x15908
jmp 0x15908
movq %rax, %rbx
leaq 0x48(%rsp), %rdi
callq 0x17538
jmp 0x15910
jmp 0x15908
jmp 0x15908
jmp 0x15901
movq %rax, %rbx
jmp 0x1591d
jmp 0x15908
movq %rax, %rbx
jmp 0x15927
movq %rax, %rbx
leaq 0xe8(%rsp), %rdi
callq 0x61d0
leaq 0x68(%rsp), %rdi
callq 0x61d0
leaq 0x108(%rsp), %rdi
callq 0x7988
movq %rbx, %rdi
callq 0x6730