// File: /workspace/github_cpp_makefile_star2_O1/karel-brinda[P]ococo/src/stats.h
// Function: ococo::stats_t<unsigned short, 3, 4>::export_stats(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&) const
int stats_t<T, counter_size, refbase_size>::export_stats(
    const std::string &stats_fn) const {
    assert(check_allocation());

    int error_code = 0;

    FILE *fo = fopen(stats_fn.c_str(), "w+");
    if (fo == nullptr) {
        ococo::error("File with statistics could not be opened ('%s').\n",
                     stats_fn.c_str());
        return -1;
    }

    /* number of seqs */
    fwrite(&n_seqs, sizeof(int32_t), 1, fo);

    for (int seqid = 0; seqid < n_seqs; seqid++) {
        /* sequence */
        single_seq_serial_t seq_ser = {0};
        seq_ser.seq_active          = seq_active[seqid];
        seq_ser.seq_len             = seq_len[seqid];
        strncpy(seq_ser.seq_name, seq_name[seqid].c_str(), 999);
        strncpy(seq_ser.seq_name, seq_name[seqid].c_str(), 999);
        uint64_t written = 0;
        written += fwrite(&seq_ser, sizeof(single_seq_serial_t), 1, fo);
        written += fwrite(seq_stats[seqid], sizeof(T), seq_len[seqid], fo);
        if (written != 1 + static_cast<uint64_t>(seq_len[seqid])) {
            ococo::error(
                "Problem with writting to the file with statistics ('%s').\n",
                stats_fn.c_str());
            return -1;
        }
    }

    error_code = fclose(fo);
    if (error_code != 0) {
        ococo::error("File with statistics could not be closed ('%s').\n",
                     stats_fn.c_str());
        return -1;
    }
    return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x7f8, %rsp            # imm = 0x7F8
movq %rsi, %rbx
movq %rdi, %r14
callq 0x902a
testb %al, %al
je 0x9e1b
movq (%rbx), %rdi
leaq 0x465af(%rip), %rsi     # 0x50277
callq 0x4600
testq %rax, %rax
je 0x9dde
movq %rax, %r15
movq %rbx, 0x8(%rsp)
movl $0x4, %esi
movl $0x1, %edx
movq %r14, %rdi
movq %rax, %rcx
callq 0x4a30
cmpl $0x0, (%r14)
jle 0x9dc1
xorl %ebx, %ebx
xorl %r12d, %r12d
movq %r15, 0x10(%rsp)
movl $0x7e0, %edx            # imm = 0x7E0
leaq 0x18(%rsp), %r15
movq %r15, %rdi
xorl %esi, %esi
callq 0x42d0
movq 0x8(%r14), %rax
movb (%rax,%r12), %al
movb %al, 0x18(%rsp)
movq 0x10(%r14), %rax
movq (%rax,%rbx), %rax
movq %rax, 0x20(%rsp)
movq 0x18(%r14), %rbp
movq (%rbp,%rbx,4), %rsi
movl $0x3e7, %edx            # imm = 0x3E7
leaq 0x28(%rsp), %r13
movq %r13, %rdi
callq 0x42b0
movq (%rbp,%rbx,4), %rsi
movl $0x3e7, %edx            # imm = 0x3E7
movq %r13, %rdi
callq 0x42b0
movl $0x7e0, %esi            # imm = 0x7E0
movl $0x1, %edx
movq %r15, %rdi
movq 0x10(%rsp), %r15
movq %r15, %rcx
callq 0x4a30
movq %rax, %rbp
movq 0x10(%r14), %rax
movq 0x28(%r14), %rcx
movq (%rcx,%rbx), %rdi
movq (%rax,%rbx), %rdx
movl $0x2, %esi
movq %r15, %rcx
callq 0x4a30
addq %rbp, %rax
movq 0x10(%r14), %rcx
movq (%rcx,%rbx), %rcx
incq %rcx
cmpq %rcx, %rax
jne 0x9dea
incq %r12
movslq (%r14), %rax
addq $0x8, %rbx
cmpq %rax, %r12
jl 0x9d07
movq %r15, %rdi
callq 0x4530
testl %eax, %eax
je 0x9e17
movq 0x8(%rsp), %rax
movq (%rax), %rsi
leaq 0x4679a(%rip), %rdi     # 0x50576
jmp 0x9df9
movq (%rbx), %rsi
leaq 0x46633(%rip), %rdi     # 0x5041b
jmp 0x9df9
movq 0x8(%rsp), %rax
movq (%rax), %rsi
leaq 0x470e5(%rip), %rdi     # 0x50ede
xorl %eax, %eax
callq 0x4b3a
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
addq $0x7f8, %rsp            # imm = 0x7F8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
xorl %eax, %eax
jmp 0x9e05
leaq 0x46555(%rip), %rdi     # 0x50377
leaq 0x46561(%rip), %rsi     # 0x5038a
leaq 0x47023(%rip), %rcx     # 0x50e53
movl $0x151, %edx            # imm = 0x151
callq 0x4350