// File: oknenavin[P]cxon/test/src/cbor/cbor.node-main.cxx
// Function: test::kind::roundtrip(std::vector<test::fixture, std::allocator<test::fixture>> const&)
int roundtrip(const fixture::vector& fs) {
        using JSON = cxon::JSON<>;
        using CBOR = cxon::CBOR<>;

        static auto const name = [](const std::string& p) {
            auto f = p.find_last_of("/\\"); f = f != p.npos ? f + 1 : 0;
            auto l = p.rfind('.'); if (l == p.npos) l = p.size();
            return std::string(p, f, l - f);
        };

        int err = 0;
        std::vector<std::string> diff;

        for (auto& fixture : fs) for (auto& file: fixture.group) {
            std::ifstream is(file);
                if (!is) {
                    CXON_ASSERT(0, "unexpected");
                    ++err, std::fprintf(stderr, "error: cannot be opened: '%s'\n", file.c_str());
                    continue;
                }
            std::string f0 = "cbor.round-trip." + name(file) + ".(0).json";
            std::string f1 = "cbor.round-trip." + name(file) + ".(1).json";
            {   // 0
                std::ofstream os(f0, std::ofstream::binary);
                    if (!os) {
                        ++err, std::fprintf(stderr, "error: cannot be opened: %s\n", f0.c_str());
                        continue;
                    }
                cxon::json::tidy<JSON>(
                    std::ostreambuf_iterator<char>(os),
                    std::istreambuf_iterator<char>(is), std::istreambuf_iterator<char>()
                );
            }
            {   // json => cbor => json
                is.seekg(0);
                cxon::cbor::ordered_node n0;
                    {   auto const r = cxon::from_bytes<JSON>(n0, std::istreambuf_iterator<char>(is), std::istreambuf_iterator<char>());
                        if (!r) {
                            ++err, std::fprintf(stderr, "error: %s: %s\n", r.ec.category().name(), r.ec.message().c_str());
                            continue;
                        }
                    }
                std::string cbor;
                    {   auto const r = cxon::to_bytes<CBOR>(cbor, n0);
                        if (!r) {
                            ++err, std::fprintf(stderr, "error: %s: %s\n", r.ec.category().name(), r.ec.message().c_str());
                            continue;
                        }
                    }
                cxon::json::ordered_node n1;
                    {   auto const r = cxon::from_bytes<CBOR>(n1, cbor);
                        if (!r) {
                            ++err, std::fprintf(stderr, "error: %s: %s\n", r.ec.category().name(), r.ec.message().c_str());
                            continue;
                        }
                    }
                {   // 1
                    std::ofstream os(f1, std::ofstream::binary);
                    if (!os) {
                        ++err, std::fprintf(stderr, "error: cannot be opened: %s\n", f1.c_str());
                        continue;
                    }
                    auto const r = cxon::to_bytes<JSON>(cxon::json::make_indenter<JSON>(std::ostreambuf_iterator<char>(os)), n1);
                    if (!r) {
                        ++err, std::fprintf(stderr, "error: %s: %s\n", r.ec.category().name(), r.ec.message().c_str());
                        continue;
                    }
                }
                diff.push_back(std::move(f0)), diff.push_back(std::move(f1));
            }
        }
        for (auto& d : diff)
            std::fprintf(stdout, "%s ", d.c_str());
        std::fputc('\n', stdout);

        return err;
    }

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xa50, %rsp            # imm = 0xA50
movq %rdi, -0x8(%rbp)
movl $0x0, -0xc(%rbp)
leaq -0x28(%rbp), %rdi
callq 0xaff0
movq -0x8(%rbp), %rax
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rdi
callq 0xa850
movq %rax, -0x38(%rbp)
movq -0x30(%rbp), %rdi
callq 0xa880
movq %rax, -0x40(%rbp)
leaq -0x38(%rbp), %rdi
leaq -0x40(%rbp), %rsi
callq 0xa8b0
testb $0x1, %al
jne 0x6d87
jmp 0x77a6
leaq -0x38(%rbp), %rdi
callq 0xa8f0
movq %rax, -0x48(%rbp)
movq -0x48(%rbp), %rax
addq $0x20, %rax
movq %rax, -0x50(%rbp)
movq -0x50(%rbp), %rdi
callq 0xa910
movq %rax, -0x58(%rbp)
movq -0x50(%rbp), %rdi
callq 0xa940
movq %rax, -0x60(%rbp)
leaq -0x58(%rbp), %rdi
leaq -0x60(%rbp), %rsi
callq 0xa970
testb $0x1, %al
jne 0x6dd0
jmp 0x7796
leaq -0x58(%rbp), %rdi
callq 0xa9b0
movq %rax, -0x68(%rbp)
movq -0x68(%rbp), %rsi
leaq -0x270(%rbp), %rdi
movl $0x8, %edx
callq 0x55f0
jmp 0x6df4
movq -0x270(%rbp), %rax
movq -0x18(%rax), %rax
leaq -0x270(%rbp,%rax), %rdi
callq 0x51b0
movb %al, -0x971(%rbp)
jmp 0x6e14
movb -0x971(%rbp), %al
testb $0x1, %al
jne 0x6e20
jmp 0x6e98
movl -0xc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xc(%rbp)
movq 0x10f1b0(%rip), %rax    # 0x115fe0
movq (%rax), %rax
movq %rax, -0x980(%rbp)
movq -0x68(%rbp), %rdi
callq 0x5150
movq -0x980(%rbp), %rdi
movq %rax, %rdx
leaq 0xbbaa8(%rip), %rsi     # 0xc28fc
movb $0x0, %al
callq 0x5540
movl $0x5, -0x280(%rbp)
jmp 0x771f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x278(%rbp)
movl %eax, -0x27c(%rbp)
jmp 0x7887
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x278(%rbp)
movl %eax, -0x27c(%rbp)
jmp 0x7785
movq -0x68(%rbp), %rdx
leaq 0xbbf8d(%rip), %rsi     # 0xc2e30
leaq -0x2e0(%rbp), %rdi
callq 0x9220
jmp 0x6eb1
leaq 0xbbaf6(%rip), %rsi     # 0xc29ae
leaq -0x2c0(%rbp), %rdi
leaq -0x2e0(%rbp), %rdx
callq 0xb060
jmp 0x6ecd
leaq 0xbbaeb(%rip), %rdx     # 0xc29bf
leaq -0x2a0(%rbp), %rdi
leaq -0x2c0(%rbp), %rsi
callq 0xb010
jmp 0x6ee9
leaq -0x2c0(%rbp), %rdi
callq 0x5260
leaq -0x2e0(%rbp), %rdi
callq 0x5260
movq -0x68(%rbp), %rdx
leaq 0xbbf24(%rip), %rsi     # 0xc2e30
leaq -0x340(%rbp), %rdi
callq 0x9220
jmp 0x6f1a
leaq 0xbba8d(%rip), %rsi     # 0xc29ae
leaq -0x320(%rbp), %rdi
leaq -0x340(%rbp), %rdx
callq 0xb060
jmp 0x6f36
leaq 0xbba8c(%rip), %rdx     # 0xc29c9
leaq -0x300(%rbp), %rdi
leaq -0x320(%rbp), %rsi
callq 0xb010
jmp 0x6f52
leaq -0x320(%rbp), %rdi
callq 0x5260
leaq -0x340(%rbp), %rdi
callq 0x5260
leaq -0x540(%rbp), %rdi
leaq -0x2a0(%rbp), %rsi
movl $0x4, %edx
callq 0x56d0
jmp 0x6f84
movq -0x540(%rbp), %rax
movq -0x18(%rax), %rax
leaq -0x540(%rbp,%rax), %rdi
callq 0x51b0
movb %al, -0x981(%rbp)
jmp 0x6fa4
movb -0x981(%rbp), %al
testb $0x1, %al
jne 0x6fb3
jmp 0x70d7
movl -0xc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xc(%rbp)
movq 0x10f01d(%rip), %rax    # 0x115fe0
movq (%rax), %rax
movq %rax, -0x990(%rbp)
leaq -0x2a0(%rbp), %rdi
callq 0x5150
movq -0x990(%rbp), %rdi
movq %rax, %rdx
leaq 0xbb9e9(%rip), %rsi     # 0xc29d3
movb $0x0, %al
callq 0x5540
movl $0x5, -0x280(%rbp)
jmp 0x7152
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x278(%rbp)
movl %eax, -0x27c(%rbp)
jmp 0x7032
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x278(%rbp)
movl %eax, -0x27c(%rbp)
leaq -0x2c0(%rbp), %rdi
callq 0x5260
leaq -0x2e0(%rbp), %rdi
callq 0x5260
jmp 0x7785
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x278(%rbp)
movl %eax, -0x27c(%rbp)
jmp 0x7779
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x278(%rbp)
movl %eax, -0x27c(%rbp)
jmp 0x708c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x278(%rbp)
movl %eax, -0x27c(%rbp)
leaq -0x320(%rbp), %rdi
callq 0x5260
leaq -0x340(%rbp), %rdi
callq 0x5260
jmp 0x7779
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x278(%rbp)
movl %eax, -0x27c(%rbp)
jmp 0x776d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x278(%rbp)
movl %eax, -0x27c(%rbp)
leaq -0x540(%rbp), %rdi
callq 0x5560
jmp 0x776d
leaq -0x550(%rbp), %rdi
leaq -0x540(%rbp), %rsi
callq 0xb170
leaq -0x560(%rbp), %rdi
leaq -0x270(%rbp), %rsi
callq 0x9de0
leaq -0x570(%rbp), %rdi
callq 0x9e40
movq -0x550(%rbp), %rdi
movq -0x560(%rbp), %rdx
movl -0x558(%rbp), %ecx
movq -0x570(%rbp), %r8
movl -0x568(%rbp), %r9d
movl -0x548(%rbp), %esi
movq %rsp, %rax
movl $0x9, 0x8(%rax)
movl $0x1, (%rax)
callq 0xb0b0
jmp 0x7148
movl $0x0, -0x280(%rbp)
leaq -0x540(%rbp), %rdi
callq 0x5560
movl -0x280(%rbp), %eax
testl %eax, %eax
jne 0x7707
jmp 0x716e
xorl %eax, %eax
movl %eax, %esi
leaq -0x580(%rbp), %rdi
callq 0xb1e0
jmp 0x7180
movq -0x580(%rbp), %rsi
movq -0x578(%rbp), %rdx
leaq -0x270(%rbp), %rdi
callq 0x5480
jmp 0x719c
leaq -0x5a8(%rbp), %rdi
movq %rdi, -0x998(%rbp)
callq 0xb220
leaq -0x5d8(%rbp), %rdi
leaq -0x270(%rbp), %rsi
callq 0x9de0
leaq -0x5e8(%rbp), %rdi
callq 0x9e40
movq -0x998(%rbp), %rsi
movq -0x5d8(%rbp), %rdx
movl -0x5d0(%rbp), %ecx
movq -0x5e8(%rbp), %r8
movl -0x5e0(%rbp), %r9d
leaq -0x5c8(%rbp), %rdi
callq 0xb250
jmp 0x71fe
leaq -0x5c8(%rbp), %rdi
callq 0xaa60
testb $0x1, %al
jne 0x72c3
movl -0xc(%rbp), %eax
incl %eax
movl %eax, -0xc(%rbp)
movq 0x10edbf(%rip), %rax    # 0x115fe0
movq (%rax), %rax
movq %rax, -0x9b0(%rbp)
leaq -0x5c8(%rbp), %rdi
movq %rdi, -0x9a8(%rbp)
callq 0xb2e0
movq %rax, %rdi
movq (%rdi), %rax
movq 0x10(%rax), %rax
callq *%rax
movq -0x9a8(%rbp), %rsi
movq %rax, -0x9a0(%rbp)
leaq -0x608(%rbp), %rdi
callq 0xaa80
jmp 0x7266
leaq -0x608(%rbp), %rdi
callq 0x5150
movq -0x9b0(%rbp), %rdi
movq -0x9a0(%rbp), %rdx
movq %rax, %rcx
leaq 0xbb766(%rip), %rsi     # 0xc29f0
movb $0x0, %al
callq 0x5540
leaq -0x608(%rbp), %rdi
callq 0x5260
movl $0x5, -0x280(%rbp)
jmp 0x76e5
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x278(%rbp)
movl %eax, -0x27c(%rbp)
jmp 0x7761
leaq -0x628(%rbp), %rdi
movq %rdi, -0x9b8(%rbp)
callq 0x5510
movq -0x9b8(%rbp), %rsi
leaq -0x640(%rbp), %rdi
leaq -0x5a8(%rbp), %rdx
callq 0xb300
jmp 0x72f2
leaq -0x640(%rbp), %rdi
callq 0xb360
testb $0x1, %al
jne 0x73b7
movl -0xc(%rbp), %eax
incl %eax
movl %eax, -0xc(%rbp)
movq 0x10eccb(%rip), %rax    # 0x115fe0
movq (%rax), %rax
movq %rax, -0x9d0(%rbp)
leaq -0x640(%rbp), %rdi
movq %rdi, -0x9c8(%rbp)
callq 0xb2e0
movq %rax, %rdi
movq (%rdi), %rax
movq 0x10(%rax), %rax
callq *%rax
movq -0x9c8(%rbp), %rsi
movq %rax, -0x9c0(%rbp)
leaq -0x660(%rbp), %rdi
callq 0xaa80
jmp 0x735a
leaq -0x660(%rbp), %rdi
callq 0x5150
movq -0x9d0(%rbp), %rdi
movq -0x9c0(%rbp), %rdx
movq %rax, %rcx
leaq 0xbb672(%rip), %rsi     # 0xc29f0
movb $0x0, %al
callq 0x5540
leaq -0x660(%rbp), %rdi
callq 0x5260
movl $0x5, -0x280(%rbp)
jmp 0x76d9
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x278(%rbp)
movl %eax, -0x27c(%rbp)
jmp 0x7755
leaq -0x688(%rbp), %rdi
movq %rdi, -0x9d8(%rbp)
callq 0xb380
movq -0x9d8(%rbp), %rsi
leaq -0x6a0(%rbp), %rdi
leaq -0x628(%rbp), %rdx
callq 0xb3b0
jmp 0x73e6
leaq -0x6a0(%rbp), %rdi
callq 0x9f30
testb $0x1, %al
jne 0x74ab
movl -0xc(%rbp), %eax
incl %eax
movl %eax, -0xc(%rbp)
movq 0x10ebd7(%rip), %rax    # 0x115fe0
movq (%rax), %rax
movq %rax, -0x9f0(%rbp)
leaq -0x6a0(%rbp), %rdi
movq %rdi, -0x9e8(%rbp)
callq 0xb2e0
movq %rax, %rdi
movq (%rdi), %rax
movq 0x10(%rax), %rax
callq *%rax
movq -0x9e8(%rbp), %rsi
movq %rax, -0x9e0(%rbp)
leaq -0x6c0(%rbp), %rdi
callq 0xaa80
jmp 0x744e
leaq -0x6c0(%rbp), %rdi
callq 0x5150
movq -0x9f0(%rbp), %rdi
movq -0x9e0(%rbp), %rdx
movq %rax, %rcx
leaq 0xbb57e(%rip), %rsi     # 0xc29f0
movb $0x0, %al
callq 0x5540
leaq -0x6c0(%rbp), %rdi
callq 0x5260
movl $0x5, -0x280(%rbp)
jmp 0x76cd
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x278(%rbp)
movl %eax, -0x27c(%rbp)
jmp 0x7749
leaq -0x8c0(%rbp), %rdi
leaq -0x300(%rbp), %rsi
movl $0x4, %edx
callq 0x56d0
jmp 0x74c5
movq -0x8c0(%rbp), %rax
movq -0x18(%rax), %rax
leaq -0x8c0(%rbp,%rax), %rdi
callq 0x51b0
movb %al, -0x9f1(%rbp)
jmp 0x74e5
movb -0x9f1(%rbp), %al
testb $0x1, %al
jne 0x74f1
jmp 0x7561
movl -0xc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xc(%rbp)
movq 0x10eadf(%rip), %rax    # 0x115fe0
movq (%rax), %rax
movq %rax, -0xa00(%rbp)
leaq -0x300(%rbp), %rdi
callq 0x5150
movq -0xa00(%rbp), %rdi
movq %rax, %rdx
leaq 0xbb4ab(%rip), %rsi     # 0xc29d3
movb $0x0, %al
callq 0x5540
movl $0x5, -0x280(%rbp)
jmp 0x7687
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x278(%rbp)
movl %eax, -0x27c(%rbp)
leaq -0x8c0(%rbp), %rdi
callq 0x5560
jmp 0x7749
leaq -0x930(%rbp), %rdi
leaq -0x8c0(%rbp), %rsi
callq 0xb170
movq -0x930(%rbp), %rsi
movl -0x928(%rbp), %edx
leaq -0x920(%rbp), %rdi
movl $0x1, %ecx
movl $0x9, %r8d
callq 0xb490
jmp 0x759a
movq -0x900(%rbp), %rcx
movq %rsp, %rax
movq %rcx, 0x20(%rax)
movups -0x920(%rbp), %xmm0
movups -0x910(%rbp), %xmm1
movups %xmm1, 0x10(%rax)
movups %xmm0, (%rax)
leaq -0x8f8(%rbp), %rdi
leaq -0x688(%rbp), %rsi
callq 0xb410
jmp 0x75d2
leaq -0x8f8(%rbp), %rdi
callq 0xb4e0
testb $0x1, %al
jne 0x767d
movl -0xc(%rbp), %eax
incl %eax
movl %eax, -0xc(%rbp)
movq 0x10e9eb(%rip), %rax    # 0x115fe0
movq (%rax), %rax
movq %rax, -0xa18(%rbp)
leaq -0x8f8(%rbp), %rdi
movq %rdi, -0xa10(%rbp)
callq 0xb2e0
movq %rax, %rdi
movq (%rdi), %rax
movq 0x10(%rax), %rax
callq *%rax
movq -0xa10(%rbp), %rsi
movq %rax, -0xa08(%rbp)
leaq -0x950(%rbp), %rdi
callq 0xaa80
jmp 0x763a
leaq -0x950(%rbp), %rdi
callq 0x5150
movq -0xa18(%rbp), %rdi
movq -0xa08(%rbp), %rdx
movq %rax, %rcx
leaq 0xbb392(%rip), %rsi     # 0xc29f0
movb $0x0, %al
callq 0x5540
leaq -0x950(%rbp), %rdi
callq 0x5260
movl $0x5, -0x280(%rbp)
jmp 0x7687
movl $0x0, -0x280(%rbp)
leaq -0x8c0(%rbp), %rdi
callq 0x5560
movl -0x280(%rbp), %eax
testl %eax, %eax
jne 0x76cd
jmp 0x769f
leaq -0x28(%rbp), %rdi
leaq -0x2a0(%rbp), %rsi
callq 0xb500
jmp 0x76b1
leaq -0x28(%rbp), %rdi
leaq -0x300(%rbp), %rsi
callq 0xb500
jmp 0x76c3
movl $0x0, -0x280(%rbp)
leaq -0x688(%rbp), %rdi
callq 0xb530
leaq -0x628(%rbp), %rdi
callq 0x5260
leaq -0x5a8(%rbp), %rdi
callq 0xb560
movl -0x280(%rbp), %eax
testl %eax, %eax
jne 0x7707
jmp 0x76fd
movl $0x0, -0x280(%rbp)
leaq -0x300(%rbp), %rdi
callq 0x5260
leaq -0x2a0(%rbp), %rdi
callq 0x5260
leaq -0x270(%rbp), %rdi
callq 0x50d0
movl -0x280(%rbp), %eax
testl %eax, %eax
je 0x7739
jmp 0x7737
jmp 0x773b
jmp 0x773b
leaq -0x58(%rbp), %rdi
callq 0xafb0
jmp 0x6dba
leaq -0x688(%rbp), %rdi
callq 0xb530
leaq -0x628(%rbp), %rdi
callq 0x5260
leaq -0x5a8(%rbp), %rdi
callq 0xb560
leaq -0x300(%rbp), %rdi
callq 0x5260
leaq -0x2a0(%rbp), %rdi
callq 0x5260
leaq -0x270(%rbp), %rdi
callq 0x50d0
jmp 0x7887
jmp 0x7798
leaq -0x38(%rbp), %rdi
callq 0xafd0
jmp 0x6d71
leaq -0x28(%rbp), %rax
movq %rax, -0x958(%rbp)
movq -0x958(%rbp), %rdi
callq 0xa3a0
movq %rax, -0x960(%rbp)
movq -0x958(%rbp), %rdi
callq 0xa3d0
movq %rax, -0x968(%rbp)
leaq -0x960(%rbp), %rdi
leaq -0x968(%rbp), %rsi
callq 0xa400
testb $0x1, %al
jne 0x77f0
jmp 0x7846
leaq -0x960(%rbp), %rdi
callq 0xa440
movq %rax, -0x970(%rbp)
movq 0x10e7b6(%rip), %rax    # 0x115fc0
movq (%rax), %rax
movq %rax, -0xa20(%rbp)
movq -0x970(%rbp), %rdi
callq 0x5150
movq -0xa20(%rbp), %rdi
movq %rax, %rdx
leaq 0xbb1ce(%rip), %rsi     # 0xc29ff
movb $0x0, %al
callq 0x5540
leaq -0x960(%rbp), %rdi
callq 0xa550
jmp 0x77d7
movq 0x10e773(%rip), %rax    # 0x115fc0
movq (%rax), %rsi
movl $0xa, %edi
callq 0x5460
jmp 0x785c
movl -0xc(%rbp), %eax
movl %eax, -0xa24(%rbp)
movl $0x1, -0x280(%rbp)
leaq -0x28(%rbp), %rdi
callq 0xb590
movl -0xa24(%rbp), %eax
addq $0xa50, %rsp            # imm = 0xA50
popq %rbp
retq
leaq -0x28(%rbp), %rdi
callq 0xb590
movq -0x278(%rbp), %rdi
callq 0x5660
nopl (%rax)