// File: /workspace/github_c_makefile_star2_O2/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 0x904a
movq %rdi, %rbx
addq 0x8(%rdi), %r13
callq 0x57e0
testq %rax, %rax
je 0x904a
movq %rax, %r14
addq $0x58, %r13
pushq $0x4
popq %rbp
pushq $-0x1
popq %r15
incq %r15
cmpq 0x30(%rbx), %r15
jae 0x904d
movq 0x10(%rbx), %rdi
movq -0x58(%r13), %rsi
movq -0x50(%r13), %rdx
leaq (%rdx,%rsi), %rax
cmpq %rdi, %rax
ja 0x9042
movq -0x20(%r13), %rcx
movq -0x18(%r13), %rax
leaq (%rax,%rcx), %r8
cmpq %rdi, %r8
ja 0x9042
leaq 0x70(%r13), %r12
movq 0x28(%rbx), %rdi
movl (%rdi,%rbp), %edi
addq $0x18, %rbp
movl %edi, 0x38(%rsp)
movq -0x40(%r13), %xmm0
pshufd $0xe1, %xmm0, %xmm0     # xmm0 = xmm0[1,0,2,3]
movq %xmm0, 0x3c(%rsp)
leaq -0x38(%r13), %rdi
movq %rdi, 0x48(%rsp)
movq 0x8(%rbx), %rdi
addq %rdi, %rsi
movq %rsi, 0x50(%rsp)
movq %rdx, 0x58(%rsp)
movq -0x48(%r13), %rdx
movq %rdx, 0x60(%rsp)
andl $0x0, 0x8(%rsp)
movq -0x8(%r13), %xmm0
pshufd $0xe1, %xmm0, %xmm0     # xmm0 = xmm0[1,0,2,3]
movq %xmm0, 0xc(%rsp)
movq %r13, 0x18(%rsp)
addq %rdi, %rcx
movq %rcx, 0x20(%rsp)
movq %rax, 0x28(%rsp)
movq -0x10(%r13), %rax
movq %rax, 0x30(%rsp)
movq %r14, %rdi
leaq 0x38(%rsp), %rsi
leaq 0x8(%rsp), %rdx
callq 0x52d0
movq %r12, %r13
testb %al, %al
jne 0x8f72
movq %r14, %rdi
callq 0x58b0
xorl %r14d, %r14d
movq %r14, %rax
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop