// File: /workspace/github_c_makefile_star2_O2/coyove[P]chann/./src/views/list/gallery.cpp
// Function: views::gallery::render(mg_connection*)
void render(mg_connection* conn){
            ConfigManager configs;
            int num = cc_extract_uri_num(conn);

            templates.invoke("site_header").var("CURRENT_PAGE", num).toggle("is_admin", is_admin(conn)) \
                .toggle("gallery_page").pipe_to(conn).destory();

            if(!configs.global().get<bool>("archive")) 
                templates.invoke("post_form").toggle("is_admin", is_admin(conn) || !is_assist(conn).empty()) \
                .toggle("post_new_thread").pipe_to(conn).destory();

            clock_t startc = clock();
            int max_page_viewable = configs.global().get<int>("user::viewable_pages");
            int threads_per_page = configs.global().get<int>("user::threads_per_page");

            bool admin_view = is_admin(conn);
            int start_no = 1, end_no = threads_per_page;

            cclong cp = cc_extract_uri_num(conn);
            if(cp <= max_page_viewable || max_page_viewable == 0 || admin_view){
                end_no = cp * threads_per_page;
                start_no = end_no - threads_per_page + 1;
                showGallery(conn, start_no, end_no);
            }
            
            cclong current_page = end_no / threads_per_page;
            queue<string> before, after;
            for (cclong i = 1; i <= (max_page_viewable == 0 || admin_view ? 10000 : max_page_viewable); ++i){
                if (current_page - i < 4 && current_page - i > 0) before.push(to_string(i));
                else if (i - current_page < 4 && i - current_page > 0) after.push(to_string(i));
                else if (i - current_page > 4) break;
            }
            
            templates.invoke("pager").toggle("gallery_page") \
                .var("CURRENT_PAGE", current_page) \
                .var("PREVIOUS_PAGE", current_page > 1 ? (current_page - 1) : 1) \
                .var("NEXT_PAGE", current_page + 1) \
                .loop("before_pages", before).loop("after_pages", after).pipe_to(conn).destory();

            clock_t endc = clock();
            templates.invoke("site_footer").var("TIME", (int)((endc-startc) * 1000 / CLOCKS_PER_SEC)).pipe_to(conn).destory();
        }

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x308, %rsp            # imm = 0x308
movq %rdi, %rbx
leaq 0x290(%rsp), %rax
movq %rax, -0x30(%rax)
pushq $0x1
popq %rcx
movq %rcx, -0x28(%rax)
xorps %xmm0, %xmm0
movups %xmm0, -0x20(%rax)
movl $0x3f800000, %edx       # imm = 0x3F800000
movl %edx, -0x10(%rax)
movups %xmm0, -0x8(%rax)
leaq 0x2c8(%rsp), %rax
movq %rax, -0x30(%rax)
movq %rcx, -0x28(%rax)
movups %xmm0, -0x20(%rax)
movl %edx, -0x10(%rax)
movups %xmm0, -0x8(%rax)
leaq 0x300(%rsp), %rax
movq %rax, -0x30(%rax)
movq %rcx, -0x28(%rax)
movups %xmm0, -0x20(%rax)
movl %edx, -0x10(%rax)
movups %xmm0, -0x8(%rax)
callq 0xf80a
movl %eax, %ebp
leaq 0x40ec5(%rip), %rsi     # 0x6196d
leaq 0x48(%rsp), %rdi
leaq 0x28(%rsp), %rdx
callq 0xcb10
leaq 0x6728a(%rip), %rdi     # 0x87d48
leaq 0x48(%rsp), %rsi
callq 0x14fb0
movq %rax, %r14
leaq 0x41601(%rip), %rsi     # 0x620d3
leaq 0x110(%rsp), %rdi
leaq 0xf0(%rsp), %rdx
callq 0xcb10
leaq 0x110(%rsp), %rsi
movq %r14, %rdi
movl %ebp, %edx
callq 0x15236
movq %rax, %r14
leaq 0x413a1(%rip), %rsi     # 0x61ea4
leaq 0xb0(%rsp), %rdi
leaq 0xd0(%rsp), %rdx
callq 0xcb10
movq %rbx, %rdi
callq 0xe080
movzbl %al, %edx
leaq 0xb0(%rsp), %rsi
movq %r14, %rdi
callq 0x14ffa
movq %rax, %r14
leaq 0x415a3(%rip), %rsi     # 0x620e0
leaq 0x8(%rsp), %rdi
leaq 0x160(%rsp), %rdx
callq 0xcb10
leaq 0x1c8(%r14), %rdi
leaq 0x8(%rsp), %rsi
callq 0x189cc
movb $0x1, (%rax)
movq %r14, %rdi
movq %rbx, %rsi
callq 0x151b6
movq %rax, %rdi
callq 0x15224
leaq 0x8(%rsp), %rdi
callq 0xcd88
leaq 0xb0(%rsp), %rdi
callq 0xcd88
leaq 0x110(%rsp), %rdi
callq 0xcd88
leaq 0x48(%rsp), %rdi
callq 0xcd88
leaq 0x260(%rsp), %rdi
callq 0x1008c
movq %rax, %r14
leaq 0x46aad(%rip), %rsi     # 0x67668
leaq 0x48(%rsp), %rdi
leaq 0x110(%rsp), %rdx
callq 0xcb10
leaq 0x48(%rsp), %rsi
movq %r14, %rdi
callq 0x14efa
movl %eax, %ebp
leaq 0x48(%rsp), %rdi
callq 0xcd88
testb %bpl, %bpl
jne 0x20ceb
leaq 0x40ef2(%rip), %rsi     # 0x61ae8
leaq 0x48(%rsp), %rdi
leaq 0x28(%rsp), %rdx
callq 0xcb10
leaq 0x6713c(%rip), %rdi     # 0x87d48
leaq 0x48(%rsp), %rsi
callq 0x14fb0
movq %rax, %r14
leaq 0x41284(%rip), %rsi     # 0x61ea4
leaq 0x110(%rsp), %rdi
leaq 0xf0(%rsp), %rdx
callq 0xcb10
movq %rbx, %rdi
callq 0xe080
movl %eax, %ebp
movb $0x1, %al
testb %bpl, %bpl
jne 0x20c62
leaq 0xb0(%rsp), %rdi
movq %rbx, %rsi
callq 0xe111
cmpq $0x0, 0xb8(%rsp)
setne %al
movzbl %al, %edx
leaq 0x110(%rsp), %rsi
movq %r14, %rdi
callq 0x14ffa
movq %rax, %r14
leaq 0x4146e(%rip), %rsi     # 0x620ed
leaq 0x8(%rsp), %rdi
leaq 0xd0(%rsp), %rdx
callq 0xcb10
leaq 0x1c8(%r14), %rdi
leaq 0x8(%rsp), %rsi
callq 0x189cc
movb $0x1, (%rax)
movq %r14, %rdi
movq %rbx, %rsi
callq 0x151b6
movq %rax, %rdi
callq 0x15224
leaq 0x8(%rsp), %rdi
callq 0xcd88
testb %bpl, %bpl
jne 0x20cd4
leaq 0xb0(%rsp), %rdi
callq 0xcd88
leaq 0x110(%rsp), %rdi
callq 0xcd88
leaq 0x48(%rsp), %rdi
callq 0xcd88
callq 0xc060
movq %rax, 0x98(%rsp)
leaq 0x260(%rsp), %rdi
callq 0x1008c
movq %rax, %r14
leaq 0x413ee(%rip), %rsi     # 0x620fd
leaq 0x48(%rsp), %rdi
leaq 0x110(%rsp), %rdx
callq 0xcb10
leaq 0x48(%rsp), %rsi
movq %r14, %rdi
callq 0x100e4
movl %eax, %ebp
leaq 0x48(%rsp), %rdi
callq 0xcd88
leaq 0x260(%rsp), %rdi
callq 0x1008c
movq %rax, %r14
leaq 0x413c1(%rip), %rsi     # 0x62112
leaq 0x48(%rsp), %rdi
leaq 0x110(%rsp), %rdx
callq 0xcb10
leaq 0x48(%rsp), %rsi
movq %r14, %rdi
callq 0x100e4
movl %eax, %r15d
leaq 0x48(%rsp), %rdi
callq 0xcd88
movq %rbx, %rdi
callq 0xe080
movl %eax, %r14d
movq %rbx, %rdi
callq 0xf80a
movl %eax, %r12d
cmpl %ebp, %eax
setle %al
testl %ebp, %ebp
sete %cl
orb %al, %cl
orb %r14b, %cl
movl %r15d, %eax
cmpb $0x1, %cl
jne 0x20dc4
imull %r15d, %r12d
movl %r12d, %esi
subl %r15d, %esi
incl %esi
movq %rbx, %rdi
movl %r12d, %edx
callq 0x208c8
movl %r12d, %eax
cltd
idivl %r15d
movl %eax, %r15d
leaq 0x48(%rsp), %rdi
callq 0x19f2a
movq %rbx, 0xa8(%rsp)
leaq 0x110(%rsp), %rdi
callq 0x19f2a
xorl %ebx, %ebx
testl %ebp, %ebp
cmovgl %ebp, %ebx
incl %ebx
testb %r14b, %r14b
movl $0x2711, %eax           # imm = 0x2711
cmovnel %eax, %ebx
testl %ebp, %ebp
cmovel %eax, %ebx
decl %ebx
movq %r15, 0xa0(%rsp)
movl %r15d, %eax
negl %eax
pushq $0x1
popq %rbp
leaq 0x8(%rsp), %r12
leaq 0x48(%rsp), %r13
leaq 0x110(%rsp), %r14
subl $0x1, %ebx
jb 0x20e7e
leal 0x1(%rax), %r15d
cmpl $-0x3, %r15d
jb 0x20e4d
movq %r12, %rdi
movl %ebp, %esi
callq 0x10273
movq %r13, %rdi
movq %r12, %rsi
callq 0x22e70
jmp 0x20e67
cmpl $0x2, %eax
ja 0x20e71
movq %r12, %rdi
movl %ebp, %esi
callq 0x10273
movq %r14, %rdi
movq %r12, %rsi
callq 0x22e70
movq %r12, %rdi
callq 0xcd88
jmp 0x20e77
cmpl $0x4, %r15d
jg 0x20e7e
incl %ebp
movl %r15d, %eax
jmp 0x20e27
leaq 0x412a4(%rip), %rsi     # 0x62129
leaq 0x8(%rsp), %rdi
leaq 0x7(%rsp), %rdx
callq 0xcb10
leaq 0x66ead(%rip), %rdi     # 0x87d48
leaq 0x8(%rsp), %rsi
callq 0x14fb0
movq 0xa8(%rsp), %rbx
movq 0xa0(%rsp), %r15
movq %rax, %r14
leaq 0x41221(%rip), %rsi     # 0x620e0
leaq 0x28(%rsp), %rdi
leaq 0x6(%rsp), %rdx
callq 0xcb10
leaq 0x1c8(%r14), %rdi
leaq 0x28(%rsp), %rsi
callq 0x189cc
movb $0x1, (%rax)
leaq 0x411ea(%rip), %rsi     # 0x620d3
leaq 0xf0(%rsp), %rdi
leaq 0x5(%rsp), %rdx
callq 0xcb10
leaq 0xf0(%rsp), %rsi
movq %r14, %rdi
movl %r15d, %edx
callq 0x15236
movq %rax, %r14
leaq 0x41217(%rip), %rsi     # 0x6212f
leaq 0xd0(%rsp), %rdi
leaq 0x4(%rsp), %rdx
callq 0xcb10
leal -0x1(%r15), %eax
cmpl $0x2, %r15d
pushq $0x1
popq %rdx
cmovgel %eax, %edx
leaq 0xd0(%rsp), %rsi
movq %r14, %rdi
callq 0x15236
movq %rax, %r14
leaq 0x411eb(%rip), %rsi     # 0x6213d
leaq 0x160(%rsp), %rdi
leaq 0x3(%rsp), %rdx
callq 0xcb10
incl %r15d
leaq 0x160(%rsp), %rsi
movq %r14, %rdi
movl %r15d, %edx
callq 0x15236
movq %rax, %r14
leaq 0x411c3(%rip), %rsi     # 0x62147
leaq 0x1a0(%rsp), %rdi
leaq 0x2(%rsp), %rdx
callq 0xcb10
leaq 0x210(%rsp), %rdi
leaq 0x48(%rsp), %rsi
callq 0x184e2
leaq 0x1a0(%rsp), %rsi
leaq 0x210(%rsp), %rdx
movq %r14, %rdi
callq 0x21318
movq %rax, %r14
leaq 0x4118a(%rip), %rsi     # 0x62154
leaq 0x180(%rsp), %rdi
leaq 0x1(%rsp), %rdx
callq 0xcb10
leaq 0x1c0(%rsp), %rdi
leaq 0x110(%rsp), %rsi
callq 0x184e2
leaq 0x180(%rsp), %rsi
leaq 0x1c0(%rsp), %rdx
movq %r14, %rdi
callq 0x21318
movq %rax, %rdi
movq %rbx, %rsi
callq 0x151b6
movq %rax, %rdi
callq 0x15224
leaq 0x1c0(%rsp), %rdi
callq 0x1642a
leaq 0x180(%rsp), %rdi
callq 0xcd88
leaq 0x210(%rsp), %rdi
callq 0x1642a
leaq 0x1a0(%rsp), %rdi
callq 0xcd88
leaq 0x160(%rsp), %rdi
callq 0xcd88
leaq 0xd0(%rsp), %rdi
callq 0xcd88
leaq 0xf0(%rsp), %rdi
callq 0xcd88
leaq 0x28(%rsp), %rdi
callq 0xcd88
leaq 0x8(%rsp), %rdi
callq 0xcd88
callq 0xc060
movq %rax, %r14
leaq 0x40953(%rip), %rsi     # 0x619ed
leaq 0x8(%rsp), %rdi
leaq 0xf0(%rsp), %rdx
callq 0xcb10
leaq 0x66c95(%rip), %rdi     # 0x87d48
leaq 0x8(%rsp), %rsi
callq 0x14fb0
movq %rax, %r15
leaq 0x408ed(%rip), %rsi     # 0x619b4
leaq 0x28(%rsp), %rdi
leaq 0xd0(%rsp), %rdx
callq 0xcb10
subq 0x98(%rsp), %r14
movl $0x3e8, %ecx            # imm = 0x3E8
movq %r14, %rax
cqto
idivq %rcx
leaq 0x28(%rsp), %rsi
movq %r15, %rdi
movl %eax, %edx
callq 0x15236
movq %rax, %rdi
movq %rbx, %rsi
callq 0x151b6
movq %rax, %rdi
callq 0x15224
leaq 0x28(%rsp), %rdi
callq 0xcd88
leaq 0x8(%rsp), %rdi
callq 0xcd88
leaq 0x110(%rsp), %rdi
callq 0x1642a
leaq 0x48(%rsp), %rdi
callq 0x1642a
leaq 0x260(%rsp), %rdi
callq 0x10136
addq $0x308, %rsp            # imm = 0x308
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x21211
jmp 0x21161
movq %rax, %rbx
jmp 0x211f2
jmp 0x21211
jmp 0x2121b
jmp 0x2121b
jmp 0x21227
jmp 0x212df
jmp 0x212df
jmp 0x212da
movq %rax, %rbx
jmp 0x21244
jmp 0x21196
movq %rax, %rbx
jmp 0x21251
movq %rax, %rbx
jmp 0x2125e
jmp 0x211a8
movq %rax, %rbx
jmp 0x2126b
jmp 0x211b2
movq %rax, %rbx
jmp 0x21278
jmp 0x211bc
movq %rax, %rbx
jmp 0x21285
jmp 0x2122f
jmp 0x2122f
jmp 0x212df
jmp 0x212df
jmp 0x212da
movq %rax, %rbx
jmp 0x212f9
jmp 0x21227
jmp 0x21227
jmp 0x2121b
movq %rax, %rbx
leaq 0x8(%rsp), %rdi
callq 0xcd88
testb %bpl, %bpl
je 0x212b0
jmp 0x212bd
jmp 0x21227
jmp 0x2121b
jmp 0x21227
jmp 0x2121b
jmp 0x21227
jmp 0x212ad
jmp 0x21211
movq %rax, %rbx
jmp 0x212bd
jmp 0x2121b
movq %rax, %rbx
jmp 0x212ca
jmp 0x21227
jmp 0x21227
movq %rax, %rbx
jmp 0x21303
movq %rax, %rbx
jmp 0x21292
movq %rax, %rbx
leaq 0x1c0(%rsp), %rdi
callq 0x1642a
leaq 0x180(%rsp), %rdi
callq 0xcd88
leaq 0x210(%rsp), %rdi
callq 0x1642a
leaq 0x1a0(%rsp), %rdi
callq 0xcd88
leaq 0x160(%rsp), %rdi
callq 0xcd88
leaq 0xd0(%rsp), %rdi
callq 0xcd88
leaq 0xf0(%rsp), %rdi
callq 0xcd88
leaq 0x28(%rsp), %rdi
callq 0xcd88
jmp 0x212e2
movq %rax, %rbx
leaq 0x8(%rsp), %rdi
callq 0xcd88
jmp 0x212b0
movq %rax, %rbx
leaq 0xb0(%rsp), %rdi
callq 0xcd88
leaq 0x110(%rsp), %rdi
callq 0xcd88
leaq 0x48(%rsp), %rdi
callq 0xcd88
jmp 0x21303
jmp 0x212df
jmp 0x212da
movq %rax, %rbx
jmp 0x212ec
movq %rax, %rbx
leaq 0x8(%rsp), %rdi
callq 0xcd88
leaq 0x110(%rsp), %rdi
callq 0x1642a
leaq 0x48(%rsp), %rdi
callq 0x1642a
leaq 0x260(%rsp), %rdi
callq 0x10136
movq %rbx, %rdi
callq 0xc790