// File: /workspace/github_c_makefile_star2_O0/00pauln00[P]yapio/yapio.c
// Function: yapio_md_buffer_io
static int
yapio_md_buffer_io(const yapio_test_group_t *ytg, const bool dump)
{
    int rc = snprintf(yapioRestartFileName, PATH_MAX, "%s/.%s%s.%d.md",
                      yapioTestRootDir, ytg->ytg_prefix, ytg->ytg_suffix,
                      yapio_relative_rank_get(ytg, 0));
    if (rc >= PATH_MAX || rc == -1)
    {
        log_msg(YAPIO_LL_ERROR, "Md filename is too long");
        return -ENAMETOOLONG;
    }

    const size_t nblks_per_rank = ytg->ytg_num_blks_per_rank;

    FILE *file = fopen(yapioRestartFileName, dump ? "w" : "r");
    if (!file)
    {
        int rc = -errno;
        log_msg(YAPIO_LL_ERROR, "fopen(`%s'): %s", yapioRestartFileName,
                strerror(errno));
        return rc;
    }

    yapio_blk_md_t *md_array;
    if (dump)
    {
        /* use metadata from last iteration */
        int test_ctx_idf = ytg->ytg_last_writer_ctx;
        const yapio_test_ctx_t *ytc = &ytg->ytg_contexts[test_ctx_idf];

        md_array = yapio_test_ctx_to_md_array(ytc, YAPIO_TEST_CTX_MDH_OUT,
                                              NULL);
        if (!md_array)
            md_array = yapio_test_ctx_to_md_array(ytc, YAPIO_TEST_CTX_MDH_IN,
                                                  NULL);
    }
    else
    {
        md_array = yapioSourceBlkMd;
    }

    log_msg(YAPIO_LL_DEBUG, "%p %d lc=%d", md_array, ytg->ytg_num_contexts,
            ytg->ytg_last_writer_ctx);

    size_t io_rc = dump ?
        fwrite(md_array, sizeof(yapio_blk_md_t), nblks_per_rank, file) :
        fread(md_array, sizeof(yapio_blk_md_t), nblks_per_rank, file);

    if (io_rc != nblks_per_rank)
    {
        int rc = -errno;
        log_msg(YAPIO_LL_ERROR, "%s(`%s'): %s (%zu / %zu)",
                dump ? "fwrite" : "fread", yapioRestartFileName,
                strerror(errno), io_rc, nblks_per_rank);

        return rc;
    }

    if (fclose(file))
    {
        int rc = -errno;
        log_msg(YAPIO_LL_ERROR, "fclose(`%s'): %s", yapioRestartFileName,
                strerror(errno));
        return rc;
    }

    return 0;
}

// Assembly:
pushq %r14
pushq %rbx
subq $0xf8, %rsp
movb %sil, %al
movq %rdi, 0xe8(%rsp)
andb $0x1, %al
movb %al, 0xe7(%rsp)
movq 0x20906b(%rip), %rax    # 0x20f2c0
movq %rax, 0x88(%rsp)
movq 0xe8(%rsp), %rax
addq $0xb03f, %rax           # imm = 0xB03F
movq %rax, 0x90(%rsp)
movq 0xe8(%rsp), %rax
addq $0xb038, %rax           # imm = 0xB038
movq %rax, 0x98(%rsp)
movq 0xe8(%rsp), %rdi
xorl %esi, %esi
callq 0x61d0
movq 0x88(%rsp), %rcx
movq 0x90(%rsp), %r8
movq 0x98(%rsp), %r9
leaq 0xe11829(%rip), %rdi    # 0xe17ae0
movl $0x1000, %esi           # imm = 0x1000
leaq 0x5e29(%rip), %rdx      # 0xc0ec
movl %eax, (%rsp)
movb $0x0, %al
callq 0x2070
movl %eax, 0xe0(%rsp)
cmpl $0x1000, 0xe0(%rsp) # imm = 0x1000
jge 0x62eb
cmpl $-0x1, 0xe0(%rsp)
jne 0x6351
movl $0x1, %eax
cmpl 0x8f1a(%rip), %eax      # 0xf210
jg 0x6341
movq 0x8ce1(%rip), %rax      # 0xefe0
movq (%rax), %rax
movq %rax, 0x80(%rsp)
movl $0x1, %edi
callq 0x4890
movq 0x80(%rsp), %rdi
movq %rax, %rdx
movl 0x8f6a(%rip), %r8d      # 0xf290
leaq 0x5dce(%rip), %rsi      # 0xc0fb
leaq 0x5dee(%rip), %rcx      # 0xc122
movl $0x5a2, %r9d            # imm = 0x5A2
movb $0x0, %al
callq 0x2370
movl $0xffffffdc, 0xf4(%rsp) # imm = 0xFFFFFFDC
jmp 0x6787
movq 0xe8(%rsp), %rax
movq 0xb020(%rax), %rax
movq %rax, 0xd8(%rsp)
movb 0xe7(%rsp), %cl
leaq 0x686d(%rip), %rsi      # 0xcbe3
leaq 0x5db8(%rip), %rax      # 0xc135
testb $0x1, %cl
cmovneq %rax, %rsi
leaq 0xe11755(%rip), %rdi    # 0xe17ae0
callq 0x2100
movq %rax, 0xd0(%rsp)
cmpq $0x0, 0xd0(%rsp)
jne 0x6448
callq 0x2230
movq %rax, %rcx
xorl %eax, %eax
subl (%rcx), %eax
movl %eax, 0xcc(%rsp)
movl $0x1, %eax
cmpl 0x8e4b(%rip), %eax      # 0xf210
jg 0x6435
movq 0x8c12(%rip), %rax      # 0xefe0
movq (%rax), %rax
movq %rax, 0x68(%rsp)
movl $0x1, %edi
callq 0x4890
movq %rax, 0x70(%rsp)
movl 0x8ea5(%rip), %eax      # 0xf290
movl %eax, 0x7c(%rsp)
callq 0x2230
movl (%rax), %edi
callq 0x21e0
movq 0x68(%rsp), %rdi
movq 0x70(%rsp), %rdx
movl 0x7c(%rsp), %r8d
leaq 0x5d26(%rip), %rsi      # 0xc137
leaq 0x5d0a(%rip), %rcx      # 0xc122
movl $0x5ad, %r9d            # imm = 0x5AD
leaq 0xe116bb(%rip), %r10    # 0xe17ae0
movq %r10, (%rsp)
movq %rax, 0x8(%rsp)
movb $0x0, %al
callq 0x2370
movl 0xcc(%rsp), %eax
movl %eax, 0xf4(%rsp)
jmp 0x6787
testb $0x1, 0xe7(%rsp)
je 0x64d7
movq 0xe8(%rsp), %rax
movl 0xb034(%rax), %eax
movl %eax, 0xbc(%rsp)
movq 0xe8(%rsp), %rax
addq $0x10, %rax
movslq 0xbc(%rsp), %rcx
imulq $0xb0, %rcx, %rcx
addq %rcx, %rax
movq %rax, 0xb0(%rsp)
movq 0xb0(%rsp), %rdi
movl $0x1, %esi
xorl %eax, %eax
movl %eax, %edx
callq 0x24f0
movq %rax, 0xc0(%rsp)
cmpq $0x0, 0xc0(%rsp)
jne 0x64d5
movq 0xb0(%rsp), %rdi
xorl %esi, %esi
xorl %eax, %eax
movl %eax, %edx
callq 0x24f0
movq %rax, 0xc0(%rsp)
jmp 0x64e6
movq 0x8d82(%rip), %rax      # 0xf260
movq %rax, 0xc0(%rsp)
movl $0x3, %eax
cmpl 0x8d1f(%rip), %eax      # 0xf210
jg 0x6568
movq 0x8ae6(%rip), %rax      # 0xefe0
movq (%rax), %rax
movq %rax, 0x60(%rsp)
movl $0x3, %edi
callq 0x4890
movq 0x60(%rsp), %rdi
movq %rax, %rdx
movl 0x8d75(%rip), %r8d      # 0xf290
movq 0xc0(%rsp), %r11
movq 0xe8(%rsp), %rax
movl 0xb010(%rax), %r10d
movq 0xe8(%rsp), %rax
movl 0xb034(%rax), %eax
leaq 0x5c0f(%rip), %rsi      # 0xc156
leaq 0x5bd4(%rip), %rcx      # 0xc122
movl $0x5c4, %r9d            # imm = 0x5C4
movq %r11, (%rsp)
movl %r10d, 0x8(%rsp)
movl %eax, 0x10(%rsp)
movb $0x0, %al
callq 0x2370
testb $0x1, 0xe7(%rsp)
je 0x659b
movq 0xc0(%rsp), %rdi
movq 0xd8(%rsp), %rdx
movq 0xd0(%rsp), %rcx
movl $0x10, %esi
callq 0x2340
movq %rax, 0x58(%rsp)
jmp 0x65c2
movq 0xc0(%rsp), %rdi
movq 0xd8(%rsp), %rdx
movq 0xd0(%rsp), %rcx
movl $0x10, %esi
callq 0x2220
movq %rax, 0x58(%rsp)
movq 0x58(%rsp), %rax
movq %rax, 0xa8(%rsp)
movq 0xa8(%rsp), %rax
cmpq 0xd8(%rsp), %rax
je 0x66c8
callq 0x2230
movq %rax, %rcx
xorl %eax, %eax
subl (%rcx), %eax
movl %eax, 0xa4(%rsp)
movl $0x1, %eax
cmpl 0x8c0d(%rip), %eax      # 0xf210
jg 0x66b5
movq 0x89d0(%rip), %rax      # 0xefe0
movq (%rax), %rax
movq %rax, 0x40(%rsp)
movl $0x1, %edi
callq 0x4890
movq %rax, 0x48(%rsp)
movl 0x8c63(%rip), %eax      # 0xf290
movl %eax, 0x54(%rsp)
movb 0xe7(%rsp), %cl
leaq 0x5b61(%rip), %r14      # 0xc1a0
leaq 0x5b53(%rip), %rax      # 0xc199
testb $0x1, %cl
cmovneq %rax, %r14
callq 0x2230
movl (%rax), %edi
callq 0x21e0
movq 0x40(%rsp), %rdi
movq 0x48(%rsp), %rdx
movl 0x54(%rsp), %r8d
movq %rax, %r11
movq 0xa8(%rsp), %r10
movq 0xd8(%rsp), %rax
leaq 0x5aef(%rip), %rsi      # 0xc171
leaq 0x5a99(%rip), %rcx      # 0xc122
movl $0x5cf, %r9d            # imm = 0x5CF
leaq 0xe1144a(%rip), %rbx    # 0xe17ae0
movq %r14, (%rsp)
movq %rbx, 0x8(%rsp)
movq %r11, 0x10(%rsp)
movq %r10, 0x18(%rsp)
movq %rax, 0x20(%rsp)
movb $0x0, %al
callq 0x2370
movl 0xa4(%rsp), %eax
movl %eax, 0xf4(%rsp)
jmp 0x6787
movq 0xd0(%rsp), %rdi
callq 0x2300
cmpl $0x0, %eax
je 0x677c
callq 0x2230
movq %rax, %rcx
xorl %eax, %eax
subl (%rcx), %eax
movl %eax, 0xa0(%rsp)
movl $0x1, %eax
cmpl 0x8b14(%rip), %eax      # 0xf210
jg 0x676c
movq 0x88db(%rip), %rax      # 0xefe0
movq (%rax), %rax
movq %rax, 0x28(%rsp)
movl $0x1, %edi
callq 0x4890
movq %rax, 0x30(%rsp)
movl 0x8b6e(%rip), %eax      # 0xf290
movl %eax, 0x3c(%rsp)
callq 0x2230
movl (%rax), %edi
callq 0x21e0
movq 0x28(%rsp), %rdi
movq 0x30(%rsp), %rdx
movl 0x3c(%rsp), %r8d
leaq 0x5a5e(%rip), %rsi      # 0xc1a6
leaq 0x59d3(%rip), %rcx      # 0xc122
movl $0x5d8, %r9d            # imm = 0x5D8
leaq 0xe11384(%rip), %r10    # 0xe17ae0
movq %r10, (%rsp)
movq %rax, 0x8(%rsp)
movb $0x0, %al
callq 0x2370
movl 0xa0(%rsp), %eax
movl %eax, 0xf4(%rsp)
jmp 0x6787
movl $0x0, 0xf4(%rsp)
movl 0xf4(%rsp), %eax
addq $0xf8, %rsp
popq %rbx
popq %r14
retq
nopl (%rax)