// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0xc0, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq -0x10(%rbp), %rax
movq 0x38(%rax), %rax
movq -0x18(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq %rax, -0x20(%rbp)
movq -0x10(%rbp), %rax
imulq $0x38, 0x30(%rax), %rax
movq %rax, -0x28(%rbp)
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rax
movq -0x20(%rbp), %rcx
addq (%rcx), %rax
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rax
addq -0x28(%rbp), %rax
movq -0x10(%rbp), %rcx
cmpq 0x10(%rcx), %rax
jbe 0xc9b9
movq $0x0, -0x8(%rbp)
jmp 0xcb93
movq -0x10(%rbp), %rdi
movq -0x30(%rbp), %rsi
callq 0xc7d0
movq %rax, -0x38(%rbp)
callq 0x5830
movq %rax, -0x40(%rbp)
cmpq $0x0, -0x40(%rbp)
jne 0xc9e7
movq $0x0, -0x8(%rbp)
jmp 0xcb93
movq $0x0, -0x48(%rbp)
movq -0x48(%rbp), %rax
movq -0x10(%rbp), %rcx
cmpq 0x30(%rcx), %rax
jae 0xcb78
movq -0x10(%rbp), %rax
movq 0x28(%rax), %rax
imulq $0x18, -0x48(%rbp), %rcx
addq %rcx, %rax
movq %rax, -0x50(%rbp)
movq -0x38(%rbp), %rax
movq -0x48(%rbp), %rcx
shlq %rcx
imulq $0x38, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x58(%rbp)
movq -0x58(%rbp), %rax
movq (%rax), %rax
movq -0x58(%rbp), %rcx
addq 0x8(%rcx), %rax
movq -0x10(%rbp), %rcx
cmpq 0x10(%rcx), %rax
jbe 0xca49
jmp 0xcb82
movq -0x38(%rbp), %rax
movq -0x48(%rbp), %rcx
shlq %rcx
addq $0x1, %rcx
imulq $0x38, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x60(%rbp)
movq -0x60(%rbp), %rax
movq (%rax), %rax
movq -0x60(%rbp), %rcx
addq 0x8(%rcx), %rax
movq -0x10(%rbp), %rcx
cmpq 0x10(%rcx), %rax
jbe 0xca81
jmp 0xcb82
movq -0x50(%rbp), %rax
movl 0x4(%rax), %eax
movl %eax, -0x90(%rbp)
movq -0x58(%rbp), %rax
movl 0x1c(%rax), %eax
movl %eax, -0x8c(%rbp)
movq -0x58(%rbp), %rax
movl 0x18(%rax), %eax
movl %eax, -0x88(%rbp)
movq -0x58(%rbp), %rax
addq $0x20, %rax
movq %rax, -0x80(%rbp)
movq -0x10(%rbp), %rdi
movq -0x58(%rbp), %rax
movq (%rax), %rsi
callq 0xc7d0
movq %rax, -0x78(%rbp)
movq -0x58(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x70(%rbp)
movq -0x58(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x68(%rbp)
movl $0x0, -0xc0(%rbp)
movq -0x60(%rbp), %rax
movl 0x1c(%rax), %eax
movl %eax, -0xbc(%rbp)
movq -0x60(%rbp), %rax
movl 0x18(%rax), %eax
movl %eax, -0xb8(%rbp)
movq -0x60(%rbp), %rax
addq $0x20, %rax
movq %rax, -0xb0(%rbp)
movq -0x10(%rbp), %rdi
movq -0x60(%rbp), %rax
movq (%rax), %rsi
callq 0xc7d0
movq %rax, -0xa8(%rbp)
movq -0x60(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0xa0(%rbp)
movq -0x60(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x98(%rbp)
movq -0x40(%rbp), %rdi
leaq -0x90(%rbp), %rsi
leaq -0xc0(%rbp), %rdx
callq 0x52e0
testb $0x1, %al
jne 0xcb65
jmp 0xcb82
jmp 0xcb67
movq -0x48(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x48(%rbp)
jmp 0xc9ef
movq -0x40(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0xcb93
movq -0x40(%rbp), %rdi
callq 0x5900
movq $0x0, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0xc0, %rsp
popq %rbp
retq