// File: /workspace/github_c_makefile_star2_O1/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 $0x1b8, %rsp            # imm = 0x1B8
movq %rcx, 0x88(%rsp)
movl %edx, 0x24(%rsp)
movl %esi, %r13d
movq %rdi, %rbp
leaq 0xf0(%rsp), %rdi
movq %rbp, %rsi
callq 0xef81
leaq 0xb0(%rsp), %rdi
movq %rbp, %rsi
callq 0xf5d8
leaq 0x140(%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 0x178(%rsp), %rax
movq %rax, -0x30(%rax)
movq %rcx, -0x28(%rax)
movups %xmm0, -0x20(%rax)
movl %edx, -0x10(%rax)
movups %xmm0, -0x8(%rax)
leaq 0x1b0(%rsp), %rax
movq %rax, -0x30(%rax)
movq %rcx, -0x28(%rax)
movups %xmm0, -0x20(%rax)
movl %edx, -0x10(%rax)
movups %xmm0, -0x8(%rax)
movq %rbp, %rdi
callq 0xef24
movl %eax, %r15d
testb %al, %al
jne 0x28a4d
movq %rsp, %rdi
movq %rbp, %rsi
callq 0xefe6
movq 0x8(%rsp), %r14
testq %r14, %r14
je 0x289d1
leaq 0x110(%rsp), %rdi
callq 0x11bfe
movq %rax, %rbx
leaq 0x4aec4(%rip), %rsi     # 0x73840
leaq 0xd0(%rsp), %rdi
movq %rsp, %rdx
callq 0x11c7f
leaq 0x4b10c(%rip), %rsi     # 0x73a9f
leaq 0xd0(%rsp), %rdi
callq 0xc790
leaq 0xa0(%rsp), %r12
movq %r12, -0x10(%r12)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0x289d5
movq %rdx, 0x90(%rsp)
movq (%rcx), %rdx
movq %rdx, 0xa0(%rsp)
jmp 0x289dd
xorl %ebx, %ebx
jmp 0x28a06
movups (%rcx), %xmm0
movups %xmm0, (%r12)
movq 0x8(%rax), %rdx
leaq 0x90(%rsp), %rsi
movq %rdx, 0x8(%rsi)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
movq %rbx, %rdi
callq 0x18460
movl %eax, %ebx
testq %r14, %r14
je 0x28a37
leaq 0xa0(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x28a21
callq 0xc640
leaq 0xe0(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x28a37
callq 0xc640
leaq 0x10(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x28a4a
callq 0xc640
orb %bl, %r15b
cmpq $0x0, 0xb8(%rsp)
je 0x28e10
leaq 0x10(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x4af31(%rip), %rsi     # 0x7399d
leaq 0x4af35(%rip), %rdx     # 0x739a8
movq %rsp, %rdi
callq 0xedfa
leaq 0x6e2a6(%rip), %rdi     # 0x96d28
movq %rsp, %rsi
callq 0x1852c
movq %rax, %rbx
leaq 0x38(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x4b6d4(%rip), %rsi     # 0x74171
leaq 0x4b6d9(%rip), %rdx     # 0x7417d
leaq 0x28(%rsp), %rdi
callq 0xedfa
leaq 0x1c8(%rbx), %r14
leaq 0x28(%rsp), %rsi
movq %r14, %rdi
callq 0x1c82a
movb $0x1, (%rax)
leaq 0x60(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x4b3df(%rip), %rsi     # 0x73eb4
leaq 0x4b3e0(%rip), %rdx     # 0x73ebc
leaq 0x50(%rsp), %rdi
callq 0xedfa
leaq 0x50(%rsp), %rsi
movq %r14, %rdi
callq 0x1c82a
movb %r15b, (%rax)
movq %rbx, %rdi
movq %rbp, %rsi
callq 0x18672
movq %rax, %rbx
movq %rax, %rdi
callq 0x1a17a
movq %rbx, %rdi
callq 0xc640
movq 0x50(%rsp), %rdi
leaq 0x60(%rsp), %rax
cmpq %rax, %rdi
je 0x28b28
callq 0xc640
movq 0x28(%rsp), %rdi
leaq 0x38(%rsp), %rax
cmpq %rax, %rdi
je 0x28b3c
callq 0xc640
movq (%rsp), %rdi
leaq 0x10(%rsp), %rax
cmpq %rax, %rdi
je 0x28b4f
callq 0xc640
leaq 0x6e0a2(%rip), %rax     # 0x96bf8
movq (%rax), %rdi
xorl %esi, %esi
callq 0xe181
movq %rax, %r14
callq 0xc050
movq %rax, 0x78(%rsp)
leaq 0x110(%rsp), %rdi
callq 0x11bfe
movq %rax, %rbx
movq %rsp, %rdi
leaq 0x10(%rsp), %rax
movq %rax, (%rdi)
leaq 0x4b5ef(%rip), %rsi     # 0x7417e
leaq 0x4b5fc(%rip), %rdx     # 0x74192
callq 0xedfa
movq %rbp, %r12
addq $0x38, %rbx
movq %rsp, %rsi
movq %rbx, %rdi
callq 0x12426
movl (%rax), %ebp
movq (%rsp), %rdi
leaq 0x10(%rsp), %rax
cmpq %rax, %rdi
je 0x28bc2
callq 0xc640
movq %r14, 0x70(%rsp)
movl 0xcc(%r14), %r14d
testl %r14d, %r14d
jle 0x28cd9
movl 0x24(%rsp), %eax
orb %r13b, %al
movl %eax, 0x24(%rsp)
xorb $0x1, %r13b
movzbl %r13b, %eax
shll $0x6, %eax
addq $0x51, %rax
movq %rax, 0x80(%rsp)
movl %r14d, %r13d
negl %r13d
movzbl %r15b, %eax
movl %eax, 0x4c(%rsp)
leaq 0x6dfea(%rip), %rax     # 0x96bf8
movq (%rax), %rdi
movl %r14d, %esi
callq 0xe181
movq %rax, %rbx
movq 0x70(%rsp), %rax
movl 0xcc(%rax), %eax
addl %r13d, %eax
cmpl %ebp, %eax
setle %al
orb %r15b, %al
je 0x28cd9
cmpb $0x0, 0x24(%rsp)
je 0x28c61
je 0x28cb8
movq 0x80(%rsp), %rax
leaq (%rbx,%rax), %rdi
movq 0x88(%rsp), %rsi
callq 0xc950
testl %eax, %eax
sete %cl
jmp 0x28c7c
movq 0xb0(%rsp), %rdi
leaq 0x91(%rbx), %rsi
callq 0xc950
movl %r15d, %ecx
testl %eax, %eax
je 0x28c80
testb %cl, %cl
je 0x28cb8
movb (%rbx), %al
andb $0x4, %al
cmpb $0x1, %al
movl $0x0, %edx
adcl $0xc, %edx
movq %r12, %rdi
movq %rbx, %rsi
movl 0x4c(%rsp), %ecx
leaq 0x509c8(%rip), %r8      # 0x79667
movq %r8, %r9
callq 0x2331c
movq %r12, %rdi
leaq 0x4b3fb(%rip), %rsi     # 0x740ac
xorl %eax, %eax
callq 0x6a0f7
testq %rbx, %rbx
je 0x28cc5
movq %rbx, %rdi
callq 0xc640
leal -0x1(%r14), %eax
incl %r13d
cmpl $0x1, %r14d
movl %eax, %r14d
jg 0x28c07
callq 0xc050
movq %rax, %rbx
movq %rsp, %rdi
leaq 0x10(%rsp), %rax
movq %rax, (%rdi)
leaq 0x4ad2a(%rip), %rsi     # 0x73a1d
leaq 0x4ad2e(%rip), %rdx     # 0x73a28
callq 0xedfa
leaq 0x6e022(%rip), %rdi     # 0x96d28
movq %rsp, %rsi
callq 0x1852c
movq %rax, %r14
leaq 0x28(%rsp), %rdi
leaq 0x38(%rsp), %rax
movq %rax, (%rdi)
leaq 0x4add9(%rip), %rsi     # 0x73afe
leaq 0x4addc(%rip), %rdx     # 0x73b08
callq 0xedfa
leaq 0x198(%r14), %rdi
leaq 0x28(%rsp), %rsi
callq 0x183b2
leaq 0xf0(%rsp), %rsi
movq %rax, %rdi
callq 0xcc40
leaq 0x50(%rsp), %rdi
leaq 0x60(%rsp), %rax
movq %rax, (%rdi)
leaq 0x4ac7e(%rip), %rsi     # 0x739e4
leaq 0x4ac7b(%rip), %rdx     # 0x739e8
callq 0xedfa
subq 0x78(%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 0x186f6
movq %rax, %rdi
movq %r12, %rsi
callq 0x18672
movq %rax, %rbx
movq %rax, %rdi
callq 0x1a17a
movq %rbx, %rdi
callq 0xc640
movq 0x50(%rsp), %rdi
leaq 0x60(%rsp), %rax
cmpq %rax, %rdi
movq 0x70(%rsp), %rbx
je 0x28dd8
callq 0xc640
movq 0x28(%rsp), %rdi
leaq 0x38(%rsp), %rax
cmpq %rax, %rdi
je 0x28dec
callq 0xc640
movq (%rsp), %rdi
leaq 0x10(%rsp), %rax
cmpq %rax, %rdi
je 0x28dff
callq 0xc640
testq %rbx, %rbx
je 0x28f41
movq %rbx, %rdi
jmp 0x28f3c
leaq 0x10(%rsp), %r14
movq %r14, -0x10(%r14)
leaq 0x4ab7d(%rip), %rsi     # 0x7399d
leaq 0x4ab81(%rip), %rdx     # 0x739a8
movq %rsp, %rdi
callq 0xedfa
leaq 0x6def2(%rip), %rdi     # 0x96d28
movq %rsp, %rsi
callq 0x1852c
movq %rax, %rbx
leaq 0x38(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0x4b320(%rip), %rsi     # 0x74171
leaq 0x4b325(%rip), %rdx     # 0x7417d
leaq 0x28(%rsp), %rdi
callq 0xedfa
leaq 0x1c8(%rbx), %rdi
leaq 0x28(%rsp), %rsi
callq 0x1c82a
movb $0x1, (%rax)
movq %rbx, %rdi
movq %rbp, %rsi
callq 0x18672
movq %rax, %rbx
movq %rax, %rdi
callq 0x1a17a
movq %rbx, %rdi
callq 0xc640
movq 0x28(%rsp), %rdi
cmpq %r15, %rdi
je 0x28ea3
callq 0xc640
movq (%rsp), %rdi
cmpq %r14, %rdi
je 0x28eb1
callq 0xc640
movq %rsp, %rdi
movq %r14, (%rdi)
leaq 0x4ab5f(%rip), %rsi     # 0x73a1d
leaq 0x4ab63(%rip), %rdx     # 0x73a28
callq 0xedfa
leaq 0x6de57(%rip), %rdi     # 0x96d28
movq %rsp, %rsi
callq 0x1852c
movq %rax, %rbx
leaq 0x28(%rsp), %rdi
movq %r15, (%rdi)
leaq 0x4aaf9(%rip), %rsi     # 0x739e4
leaq 0x4aaf6(%rip), %rdx     # 0x739e8
callq 0xedfa
leaq 0x28(%rsp), %rsi
movq %rbx, %rdi
xorl %edx, %edx
callq 0x186f6
movq %rax, %rdi
movq %rbp, %rsi
callq 0x18672
movq %rax, %rbx
movq %rax, %rdi
callq 0x1a17a
movq %rbx, %rdi
callq 0xc640
movq 0x28(%rsp), %rdi
cmpq %r15, %rdi
je 0x28f33
callq 0xc640
movq (%rsp), %rdi
cmpq %r14, %rdi
je 0x28f41
callq 0xc640
leaq 0x148(%rsp), %rbx
leaq 0x180(%rsp), %rdi
callq 0x11d00
movq %rbx, %rdi
callq 0x11d96
leaq 0x110(%rsp), %rdi
callq 0x11e2c
leaq 0xc0(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x28f81
callq 0xc640
leaq 0x100(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x28f97
callq 0xc640
addq $0x1b8, %rsp            # imm = 0x1B8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
movq 0x90(%rsp), %rdi
cmpq %r12, %rdi
je 0x28fc3
callq 0xc640
jmp 0x28fc3
movq %rax, %rbx
leaq 0xe0(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x28fde
callq 0xc640
jmp 0x28fde
movq %rax, %rbx
leaq 0x10(%rsp), %rax
movq -0x10(%rax), %rdi
jmp 0x29085
jmp 0x28ff7
jmp 0x28ff7
jmp 0x29093
jmp 0x28ff7
movq %rax, %rbx
jmp 0x29038
jmp 0x29093
jmp 0x29093
jmp 0x2904c
jmp 0x2901d
jmp 0x2901d
jmp 0x29093
jmp 0x2901d
jmp 0x29093
jmp 0x29093
jmp 0x2904c
jmp 0x2904c
jmp 0x2901d
movq %rax, %rbx
jmp 0x2907c
jmp 0x29093
jmp 0x29026
movq %rax, %rbx
movq 0x28(%rsp), %rdi
cmpq %r15, %rdi
je 0x29038
callq 0xc640
movq (%rsp), %rdi
cmpq %r14, %rdi
jne 0x2908a
jmp 0x29096
jmp 0x29093
movq %rax, %rbx
jmp 0x290b9
jmp 0x29051
movq %rax, %rbx
jmp 0x29068
movq %rax, %rbx
movq 0x50(%rsp), %rdi
leaq 0x60(%rsp), %rax
cmpq %rax, %rdi
je 0x29068
callq 0xc640
movq 0x28(%rsp), %rdi
leaq 0x38(%rsp), %rax
cmpq %rax, %rdi
je 0x2907c
callq 0xc640
movq (%rsp), %rdi
leaq 0x10(%rsp), %rax
cmpq %rax, %rdi
je 0x29096
callq 0xc640
jmp 0x29096
jmp 0x29093
movq %rax, %rbx
leaq 0x110(%rsp), %rdi
callq 0x11c1c
leaq 0xc0(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x290b9
callq 0xc640
leaq 0x100(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x290cf
callq 0xc640
movq %rbx, %rdi
callq 0xc760
nop