// File: /workspace/github_c_makefile_star2_O1/chriso[P]columnix/lib/reader.c
// Function: cx_row_group_reader_get
struct cx_row_group *cx_row_group_reader_get(
    const struct cx_row_group_reader *reader, size_t index)
{
    const struct cx_row_group_header *row_group_header =
        &reader->row_groups.headers[index];
    size_t headers_size =
        reader->columns.count * sizeof(struct cx_column_header);
    size_t headers_offset = row_group_header->offset + row_group_header->size;
    if (headers_offset + headers_size > reader->file_size)
        return NULL;
    const struct cx_column_header *columns_headers =
        cx_row_group_reader_at(reader, headers_offset);
    struct cx_row_group *row_group = cx_row_group_new();
    if (!row_group)
        return NULL;
    for (size_t i = 0; i < reader->columns.count; i++) {
        const struct cx_column_descriptor *descriptor =
            &reader->columns.descriptors[i];
        const struct cx_column_header *header = &columns_headers[i * 2];
        if (header->offset + header->size > reader->file_size)
            goto error;
        const struct cx_column_header *null_header =
            &columns_headers[i * 2 + 1];
        if (null_header->offset + null_header->size > reader->file_size)
            goto error;

        struct cx_lazy_column column = {
            .type = descriptor->type,
            .encoding = header->encoding,
            .compression = header->compression,
            .index = &header->index,
            .ptr = cx_row_group_reader_at(reader, header->offset),
            .size = header->size,
            .decompressed_size = header->decompressed_size};

        struct cx_lazy_column nulls = {
            .type = CX_COLUMN_BIT,
            .encoding = null_header->encoding,
            .compression = null_header->compression,
            .index = &null_header->index,
            .ptr = cx_row_group_reader_at(reader, null_header->offset),
            .size = null_header->size,
            .decompressed_size = null_header->decompressed_size};

        if (!cx_row_group_add_lazy_column(row_group, &column, &nulls))
            goto error;
    }
    return row_group;
error:
    cx_row_group_free(row_group);
    return NULL;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x68, %rsp
movq 0x38(%rdi), %rax
imulq $0x38, 0x30(%rdi), %rcx
shlq $0x4, %rsi
movq (%rax,%rsi), %r13
addq 0x8(%rax,%rsi), %r13
addq %r13, %rcx
cmpq 0x10(%rdi), %rcx
ja 0x9736
movq %rdi, %r14
addq 0x8(%rdi), %r13
callq 0x5790
testq %rax, %rax
je 0x9736
movq %rax, %rbx
cmpq $0x0, 0x30(%r14)
je 0x9738
addq $0x58, %r13
movl $0x4, %ebp
xorl %r15d, %r15d
leaq 0x8(%rsp), %r12
movq 0x10(%r14), %rcx
movq -0x50(%r13), %rdx
addq -0x58(%r13), %rdx
movl $0x5, %eax
cmpq %rcx, %rdx
ja 0x970b
movq -0x18(%r13), %rdx
addq -0x20(%r13), %rdx
cmpq %rcx, %rdx
ja 0x970b
movq 0x28(%r14), %rax
movl (%rax,%rbp), %eax
movl %eax, 0x38(%rsp)
movl -0x3c(%r13), %eax
movl %eax, 0x3c(%rsp)
movl -0x40(%r13), %eax
movl %eax, 0x40(%rsp)
leaq -0x38(%r13), %rax
movq %rax, 0x48(%rsp)
movq 0x8(%r14), %rax
movq -0x58(%r13), %rcx
addq %rax, %rcx
movq %rcx, 0x50(%rsp)
movq -0x50(%r13), %rcx
movq %rcx, 0x58(%rsp)
movq -0x48(%r13), %rcx
movq %rcx, 0x60(%rsp)
movl $0x0, 0x8(%rsp)
movl -0x4(%r13), %ecx
movl %ecx, 0xc(%rsp)
movl -0x8(%r13), %ecx
movl %ecx, 0x10(%rsp)
movq %r13, 0x18(%rsp)
addq -0x20(%r13), %rax
movq %rax, 0x20(%rsp)
movq -0x18(%r13), %rax
movq %rax, 0x28(%rsp)
movq -0x10(%r13), %rax
movq %rax, 0x30(%rsp)
movq %rbx, %rdi
leaq 0x38(%rsp), %rsi
movq %r12, %rdx
callq 0x52a0
xorb $0x1, %al
movzbl %al, %eax
leal (%rax,%rax,4), %eax
testl %eax, %eax
jne 0x9729
incq %r15
addq $0x70, %r13
addq $0x18, %rbp
cmpq 0x30(%r14), %r15
jb 0x964a
movl $0x2, %eax
cmpl $0x5, %eax
jne 0x9738
movq %rbx, %rdi
callq 0x5860
xorl %ebx, %ebx
movq %rbx, %rax
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop