// File: /workspace/github_c_makefile_star2_O3/coyove[P]chann/./src/views/list/linear.cpp
// Function: views::linear::render(mg_connection*, bool, bool, char const*)
void render(mg_connection* conn, 
            bool ip_based,
            bool id_based,
            const char* needle){

            string ssid = cck_extract_ssid(conn);
            string username = cck_verify_ssid(conn);
            ConfigManager configs;

            bool admin_view = is_admin(conn);
            if(!admin_view){
                string ass = is_assist(conn);
                if(!ass.empty() && configs.global().get<bool>("security::assist::" + ass + "::list")) admin_view = true;
            }

            if (!username.empty()){
                templates.invoke("site_header").toggle("my_post_page").toggle("is_admin", admin_view).pipe_to(conn).destory();

                struct Thread *r = unq_read_thread(pDb, 0); 
                struct Thread *t;

                clock_t startc = clock();

                int limit = configs.global().get<int>("user::linear_threads");

                for(int i = r->childCount; i > 0; i--){
                    t = unq_read_thread(pDb, i);
                    if(r->childCount - i > limit && !admin_view) break; // only search the most recent 500 threads/replies
                    // cout << i << endl;
                    bool flag = false;

                    if(!ip_based && !id_based){ //list the threads only based on username, admin can see all
                        if(admin_view) flag = true;
                        if(strcmp(username.c_str(), t->ssid) == 0) flag = true;
                    }else if(ip_based){ // list the threads based on ip
                        if(strcmp(t->email, needle) == 0) flag = true;
                    }else if(id_based){ // list the threads based on id
                        if(strcmp(t->ssid, needle) == 0) flag = true;
                    }

                    if(flag){
                        if(t->state & MAIN_THREAD)
                            views::each_thread(conn, t, SEND_CUT_LONG_COMMENT + SEND_CUT_IMAGE, admin_view);
                        else    
                            views::each_thread(conn, t, SEND_IS_REPLY + SEND_CUT_LONG_COMMENT + SEND_CUT_IMAGE, admin_view);
                        mg_printf_data(conn, "<hr>");
                    }

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

                if(r) delete r;
            }else{
                templates.invoke("site_header").toggle("my_post_page").pipe_to(conn).destory();
                templates.invoke("site_footer").var("TIME", 0).pipe_to(conn).destory();
            }
        }

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x178, %rsp            # imm = 0x178
movq %rcx, 0x80(%rsp)
movl %edx, 0x48(%rsp)
movl %esi, 0x4c(%rsp)
movq %rdi, %r12
leaq 0xb0(%rsp), %rdi
movq %r12, %rsi
callq 0xef7f
leaq 0x90(%rsp), %rdi
movq %r12, %rsi
callq 0xf5d5
leaq 0x100(%rsp), %rax
movq %rax, -0x30(%rax)
movl $0x1, %ecx
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 0x138(%rsp), %rax
movq %rax, -0x30(%rax)
movq %rcx, -0x28(%rax)
movups %xmm0, -0x20(%rax)
movl %edx, -0x10(%rax)
movups %xmm0, -0x8(%rax)
leaq 0x170(%rsp), %rax
movq %rax, -0x30(%rax)
movq %rcx, -0x28(%rax)
movups %xmm0, -0x20(%rax)
movl %edx, -0x10(%rax)
movups %xmm0, -0x8(%rax)
movq %r12, %rdi
callq 0xef14
movb $0x1, %cl
movl %ecx, 0x4(%rsp)
testb %al, %al
jne 0x28645
leaq 0x8(%rsp), %rdi
movq %r12, %rsi
callq 0xefe4
cmpq $0x0, 0x10(%rsp)
je 0x285d7
leaq 0xd0(%rsp), %rdi
callq 0x11bec
movq %rax, %rbx
leaq 0x492b0(%rip), %rsi     # 0x71840
leaq 0x50(%rsp), %rdi
leaq 0x8(%rsp), %rdx
callq 0x11c73
leaq 0x494f6(%rip), %rsi     # 0x71a9c
leaq 0x50(%rsp), %rdi
callq 0xc790
leaq 0x38(%rsp), %r14
movq %r14, -0x10(%r14)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0x285e1
movq %rdx, 0x28(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x38(%rsp)
jmp 0x285e8
movl $0x0, 0x4(%rsp)
jmp 0x28632
movups (%rcx), %xmm0
movups %xmm0, (%r14)
movq 0x8(%rax), %rdx
leaq 0x28(%rsp), %rsi
movq %rdx, 0x8(%rsi)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
movq %rbx, %rdi
callq 0x180f2
movl %eax, 0x4(%rsp)
movq 0x28(%rsp), %rdi
cmpq %r14, %rdi
je 0x2861f
callq 0xc640
leaq 0x60(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x28632
callq 0xc640
leaq 0x18(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x28645
callq 0xc640
cmpq $0x0, 0x98(%rsp)
je 0x289f1
leaq 0x18(%rsp), %rbp
movq %rbp, -0x10(%rbp)
leaq 0x49339(%rip), %rsi     # 0x7199d
leaq 0x4933d(%rip), %rdx     # 0x719a8
leaq 0x8(%rsp), %rdi
callq 0xedf0
leaq 0x6c6ac(%rip), %rdi     # 0x94d28
leaq 0x8(%rsp), %rsi
callq 0x181be
movq %rax, %rbx
leaq 0x38(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0x49ac8(%rip), %rsi     # 0x72161
leaq 0x49acd(%rip), %rdx     # 0x7216d
leaq 0x28(%rsp), %rdi
callq 0xedf0
leaq 0x1c8(%rbx), %r14
leaq 0x28(%rsp), %rsi
movq %r14, %rdi
callq 0x1c4c8
movb $0x1, (%rax)
leaq 0x60(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x497d3(%rip), %rsi     # 0x71ea4
leaq 0x497d4(%rip), %rdx     # 0x71eac
leaq 0x50(%rsp), %rdi
callq 0xedf0
leaq 0x50(%rsp), %rsi
movq %r14, %rdi
callq 0x1c4c8
movl 0x4(%rsp), %ecx
movb %cl, (%rax)
movq %rbx, %rdi
movq %r12, %rsi
callq 0x18304
movq %rax, %rbx
movq %rax, %rdi
callq 0x19de2
movq %rbx, %rdi
callq 0xc640
movq 0x50(%rsp), %rdi
leaq 0x60(%rsp), %rax
cmpq %rax, %rdi
je 0x28727
callq 0xc640
movq 0x28(%rsp), %rdi
cmpq %r15, %rdi
je 0x28736
callq 0xc640
movq 0x8(%rsp), %rdi
cmpq %rbp, %rdi
je 0x28745
callq 0xc640
leaq 0x6c4ac(%rip), %rax     # 0x94bf8
movq (%rax), %rdi
xorl %esi, %esi
callq 0xe181
movq %rax, 0x70(%rsp)
callq 0xc050
movq %rax, %r14
leaq 0xd0(%rsp), %rdi
callq 0x11bec
movq %rax, %rbx
leaq 0x8(%rsp), %rdi
movq %rbp, (%rdi)
leaq 0x499ec(%rip), %rsi     # 0x7216e
leaq 0x499f9(%rip), %rdx     # 0x72182
callq 0xedf0
movq %r14, 0x88(%rsp)
addq $0x38, %rbx
leaq 0x8(%rsp), %rsi
movq %rbx, %rdi
callq 0x12416
movl (%rax), %r15d
movq 0x8(%rsp), %rdi
cmpq %rbp, %rdi
je 0x287b9
callq 0xc640
movq 0x70(%rsp), %rax
movl 0xcc(%rax), %ebp
testl %ebp, %ebp
jle 0x288c3
movl 0x4c(%rsp), %eax
movl %eax, %r14d
orb 0x48(%rsp), %r14b
movl %ebp, %r13d
negl %r13d
movzbl 0x4(%rsp), %eax
movl %eax, 0x7c(%rsp)
leaq 0x6c40a(%rip), %rax     # 0x94bf8
movq (%rax), %rdi
movl %ebp, %esi
callq 0xe181
movq %rax, %rbx
movq 0x70(%rsp), %rax
movl 0xcc(%rax), %eax
addl %r13d, %eax
cmpl %r15d, %eax
setle %al
orb 0x4(%rsp), %al
je 0x288c3
testb %r14b, %r14b
je 0x2882b
cmpb $0x0, 0x4c(%rsp)
je 0x2884c
leaq 0x51(%rbx), %rdi
jmp 0x2885a
movq 0x90(%rsp), %rdi
leaq 0x91(%rbx), %rsi
callq 0xc950
testl %eax, %eax
sete %al
orb 0x4(%rsp), %al
je 0x2886b
jmp 0x28872
cmpb $0x0, 0x48(%rsp)
je 0x2886b
leaq 0x91(%rbx), %rdi
movq 0x80(%rsp), %rsi
callq 0xc950
testl %eax, %eax
je 0x28872
testq %rbx, %rbx
jne 0x288aa
jmp 0x288b2
movb (%rbx), %al
andb $0x4, %al
cmpb $0x1, %al
movl $0x0, %edx
adcl $0xc, %edx
movq %r12, %rdi
movq %rbx, %rsi
movl 0x7c(%rsp), %ecx
leaq 0x4ede1(%rip), %r8      # 0x77672
movq %r8, %r9
callq 0x22fc8
movq %r12, %rdi
leaq 0x497f9(%rip), %rsi     # 0x7209c
xorl %eax, %eax
callq 0x68533
movq %rbx, %rdi
callq 0xc640
leal -0x1(%rbp), %eax
incl %r13d
cmpl $0x1, %ebp
movl %eax, %ebp
jg 0x287e7
callq 0xc050
movq %rax, %rbx
leaq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %r15
movq %r15, (%rdi)
leaq 0x4913e(%rip), %rsi     # 0x71a1d
leaq 0x49142(%rip), %rdx     # 0x71a28
callq 0xedf0
leaq 0x6c436(%rip), %rdi     # 0x94d28
leaq 0x8(%rsp), %rsi
callq 0x181be
movq %rax, %r14
leaq 0x28(%rsp), %rdi
leaq 0x38(%rsp), %rax
movq %rax, (%rdi)
leaq 0x491e8(%rip), %rsi     # 0x71afb
leaq 0x491eb(%rip), %rdx     # 0x71b05
callq 0xedf0
leaq 0x198(%r14), %rdi
leaq 0x28(%rsp), %rsi
callq 0x18044
leaq 0xb0(%rsp), %rsi
movq %rax, %rdi
callq 0xcc40
leaq 0x50(%rsp), %rdi
leaq 0x60(%rsp), %rax
movq %rax, (%rdi)
leaq 0x49090(%rip), %rsi     # 0x719e4
leaq 0x4908d(%rip), %rdx     # 0x719e8
callq 0xedf0
subq 0x88(%rsp), %rbx
movabsq $0x20c49ba5e353f7cf, %rcx # imm = 0x20C49BA5E353F7CF
movq %rbx, %rax
imulq %rcx
movq %rdx, %rax
shrq $0x3f, %rax
shrq $0x7, %rdx
addl %eax, %edx
leaq 0x50(%rsp), %rsi
movq %r14, %rdi
callq 0x18388
movq %rax, %rdi
movq %r12, %rsi
callq 0x18304
movq %rax, %rbx
movq %rax, %rdi
callq 0x19de2
movq %rbx, %rdi
callq 0xc640
movq 0x50(%rsp), %rdi
leaq 0x60(%rsp), %rax
cmpq %rax, %rdi
je 0x289c4
callq 0xc640
movq 0x28(%rsp), %rdi
leaq 0x38(%rsp), %rax
cmpq %rax, %rdi
je 0x289d8
callq 0xc640
movq 0x8(%rsp), %rdi
cmpq %r15, %rdi
je 0x289e7
callq 0xc640
movq 0x70(%rsp), %rdi
jmp 0x28b27
leaq 0x18(%rsp), %r14
movq %r14, -0x10(%r14)
leaq 0x48f9c(%rip), %rsi     # 0x7199d
leaq 0x48fa0(%rip), %rdx     # 0x719a8
leaq 0x8(%rsp), %rdi
callq 0xedf0
leaq 0x6c30f(%rip), %rdi     # 0x94d28
leaq 0x8(%rsp), %rsi
callq 0x181be
movq %rax, %rbx
leaq 0x38(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0x4972b(%rip), %rsi     # 0x72161
leaq 0x49730(%rip), %rdx     # 0x7216d
leaq 0x28(%rsp), %rdi
callq 0xedf0
leaq 0x1c8(%rbx), %rdi
leaq 0x28(%rsp), %rsi
callq 0x1c4c8
movb $0x1, (%rax)
movq %rbx, %rdi
movq %r12, %rsi
callq 0x18304
movq %rax, %rbx
movq %rax, %rdi
callq 0x19de2
movq %rbx, %rdi
callq 0xc640
movq 0x28(%rsp), %rdi
cmpq %r15, %rdi
je 0x28a88
callq 0xc640
movq 0x8(%rsp), %rdi
cmpq %r14, %rdi
je 0x28a97
callq 0xc640
leaq 0x8(%rsp), %rdi
movq %r14, (%rdi)
leaq 0x48f77(%rip), %rsi     # 0x71a1d
leaq 0x48f7b(%rip), %rdx     # 0x71a28
callq 0xedf0
leaq 0x6c26f(%rip), %rdi     # 0x94d28
leaq 0x8(%rsp), %rsi
callq 0x181be
movq %rax, %rbx
leaq 0x28(%rsp), %rdi
movq %r15, (%rdi)
leaq 0x48f0f(%rip), %rsi     # 0x719e4
leaq 0x48f0c(%rip), %rdx     # 0x719e8
callq 0xedf0
leaq 0x28(%rsp), %rsi
movq %rbx, %rdi
xorl %edx, %edx
callq 0x18388
movq %rax, %rdi
movq %r12, %rsi
callq 0x18304
movq %rax, %rbx
movq %rax, %rdi
callq 0x19de2
movq %rbx, %rdi
callq 0xc640
movq 0x28(%rsp), %rdi
cmpq %r15, %rdi
je 0x28b1d
callq 0xc640
movq 0x8(%rsp), %rdi
cmpq %r14, %rdi
je 0x28b2c
callq 0xc640
leaq 0x108(%rsp), %rbx
leaq 0x140(%rsp), %rdi
callq 0x11cf4
movq %rbx, %rdi
callq 0x11d8a
leaq 0xd0(%rsp), %rdi
callq 0x11e20
leaq 0xa0(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x28b6c
callq 0xc640
leaq 0xc0(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x28b82
callq 0xc640
addq $0x178, %rsp            # imm = 0x178
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
movq 0x28(%rsp), %rdi
cmpq %r14, %rdi
je 0x28bab
callq 0xc640
jmp 0x28bab
movq %rax, %rbx
leaq 0x60(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x28bc3
callq 0xc640
jmp 0x28bc3
movq %rax, %rbx
leaq 0x18(%rsp), %rax
movq -0x10(%rax), %rdi
jmp 0x28c92
jmp 0x28bdc
jmp 0x28bdc
jmp 0x28cd2
jmp 0x28bdc
movq %rax, %rbx
jmp 0x28c38
jmp 0x28cd2
jmp 0x28cd2
jmp 0x28c71
jmp 0x28bf2
movq %rax, %rbx
jmp 0x28c88
jmp 0x28cd2
jmp 0x28c17
jmp 0x28cd2
jmp 0x28cd2
jmp 0x28c0d
movq %rax, %rbx
jmp 0x28cb0
jmp 0x28c17
movq %rax, %rbx
jmp 0x28cbf
jmp 0x28cd2
jmp 0x28c26
movq %rax, %rbx
movq 0x28(%rsp), %rdi
cmpq %r15, %rdi
je 0x28c38
callq 0xc640
movq 0x8(%rsp), %rdi
cmpq %r14, %rdi
jne 0x28cc9
jmp 0x28cd5
jmp 0x28cd2
movq %rax, %rbx
jmp 0x28cf8
movq %rax, %rbx
movq 0x50(%rsp), %rdi
leaq 0x60(%rsp), %rax
cmpq %rax, %rdi
je 0x28c74
callq 0xc640
jmp 0x28c74
movq %rax, %rbx
movq 0x28(%rsp), %rdi
leaq 0x38(%rsp), %rax
cmpq %rax, %rdi
je 0x28c88
callq 0xc640
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
jne 0x28cc9
jmp 0x28cd5
movq %rax, %rbx
movq 0x50(%rsp), %rdi
leaq 0x60(%rsp), %rax
cmpq %rax, %rdi
je 0x28cb0
callq 0xc640
movq 0x28(%rsp), %rdi
cmpq %r15, %rdi
je 0x28cbf
callq 0xc640
movq 0x8(%rsp), %rdi
cmpq %rbp, %rdi
je 0x28cd5
callq 0xc640
jmp 0x28cd5
jmp 0x28cd2
movq %rax, %rbx
leaq 0xd0(%rsp), %rdi
callq 0x11c0a
leaq 0xa0(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x28cf8
callq 0xc640
leaq 0xc0(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x28d0e
callq 0xc640
movq %rbx, %rdi
callq 0xc760
nop