// File: /workspace/github_c_makefile_star2_O2/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, 0x28(%rsp)
movl %esi, 0x2c(%rsp)
movq %rdi, %r14
leaq 0xb0(%rsp), %rdi
movq %r14, %rsi
callq 0xe0b8
leaq 0x90(%rsp), %rdi
movq %r14, %rsi
callq 0xe580
leaq 0x100(%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 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 %r14, %rdi
callq 0xe080
movb $0x1, %cl
movl %ecx, 0x4(%rsp)
testb %al, %al
jne 0x23058
leaq 0x8(%rsp), %rdi
movq %r14, %rsi
callq 0xe111
cmpq $0x0, 0x10(%rsp)
je 0x23046
leaq 0xd0(%rsp), %rdi
callq 0x1008c
movq %rax, %rbx
leaq 0x3e816(%rip), %rsi     # 0x61810
leaq 0x60(%rsp), %rdi
leaq 0x8(%rsp), %rdx
callq 0x10196
leaq 0x3ea5c(%rip), %rdx     # 0x61a6c
leaq 0x30(%rsp), %rdi
leaq 0x60(%rsp), %rsi
callq 0x100f2
leaq 0x30(%rsp), %rsi
movq %rbx, %rdi
callq 0x14efa
movl %eax, 0x4(%rsp)
leaq 0x30(%rsp), %rdi
callq 0xcd88
leaq 0x60(%rsp), %rdi
callq 0xcd88
jmp 0x2304e
movl $0x0, 0x4(%rsp)
leaq 0x8(%rsp), %rdi
callq 0xcd88
cmpq $0x0, 0x98(%rsp)
je 0x23363
leaq 0x3e8ff(%rip), %rsi     # 0x6196d
leaq 0x8(%rsp), %rdi
leaq 0x1(%rsp), %rdx
callq 0xcb10
leaq 0x64cc4(%rip), %rdi     # 0x87d48
leaq 0x8(%rsp), %rsi
callq 0x14fb0
movq %rax, %rbx
leaq 0x3f0c9(%rip), %rsi     # 0x62161
leaq 0x30(%rsp), %rdi
leaq 0x3(%rsp), %rdx
callq 0xcb10
leaq 0x1c8(%rbx), %rdi
leaq 0x30(%rsp), %rsi
callq 0x189cc
movb $0x1, (%rax)
leaq 0x3ede2(%rip), %rsi     # 0x61ea4
leaq 0x60(%rsp), %rdi
leaq 0x2(%rsp), %rdx
callq 0xcb10
movzbl 0x4(%rsp), %edx
leaq 0x60(%rsp), %rsi
movq %rbx, %rdi
movl %edx, 0x5c(%rsp)
callq 0x14ffa
movq %rax, %rdi
movq %r14, %rsi
callq 0x151b6
movq %rax, %rdi
callq 0x15224
leaq 0x60(%rsp), %rdi
callq 0xcd88
leaq 0x30(%rsp), %rdi
callq 0xcd88
leaq 0x8(%rsp), %rdi
callq 0xcd88
leaq 0x64af9(%rip), %rax     # 0x87c18
movq (%rax), %rdi
xorl %esi, %esi
callq 0xd515
movq %rax, %r15
callq 0xc060
movq %rax, %r12
leaq 0xd0(%rsp), %rdi
callq 0x1008c
movq %rax, %rbx
leaq 0x3f023(%rip), %rsi     # 0x6216e
leaq 0x8(%rsp), %rdi
leaq 0x30(%rsp), %rdx
callq 0xcb10
movq %r12, 0x88(%rsp)
movq %r14, 0x50(%rsp)
leaq 0x8(%rsp), %rsi
movq %rbx, %rdi
callq 0x100e4
movl %eax, %r14d
leaq 0x8(%rsp), %rdi
callq 0xcd88
movq %r15, %r12
movl 0xcc(%r15), %r15d
movl 0x2c(%rsp), %eax
movl %eax, %ebp
orb 0x28(%rsp), %bpl
movl %r15d, %r13d
negl %r13d
testl %r15d, %r15d
jle 0x2327d
leaq 0x64a6c(%rip), %rax     # 0x87c18
movq (%rax), %rdi
movl %r15d, %esi
callq 0xd515
movq %rax, %rbx
movl 0xcc(%r12), %eax
addl %r13d, %eax
cmpl %r14d, %eax
setle %al
orb 0x4(%rsp), %al
je 0x2327d
testb %bpl, %bpl
je 0x231e7
cmpb $0x0, 0x2c(%rsp)
je 0x23208
leaq 0x51(%rbx), %rdi
jmp 0x23216
movq 0x90(%rsp), %rdi
leaq 0x91(%rbx), %rsi
callq 0xc970
testl %eax, %eax
sete %al
orb 0x4(%rsp), %al
je 0x23227
jmp 0x2322e
cmpb $0x0, 0x28(%rsp)
je 0x23227
leaq 0x91(%rbx), %rdi
movq 0x80(%rsp), %rsi
callq 0xc970
testl %eax, %eax
je 0x2322e
testq %rbx, %rbx
jne 0x2326a
jmp 0x23272
movb (%rbx), %al
andb $0x4, %al
cmpb $0x1, %al
movl $0x0, %edx
adcl $0xc, %edx
movq 0x50(%rsp), %rdi
movq %rbx, %rsi
movl 0x5c(%rsp), %ecx
leaq 0x44403(%rip), %r8      # 0x67652
movq %r8, %r9
callq 0x1e914
movq 0x50(%rsp), %rdi
leaq 0x3ee39(%rip), %rsi     # 0x6209c
xorl %eax, %eax
callq 0x59649
movq %rbx, %rdi
callq 0xc660
decl %r15d
incl %r13d
jmp 0x2319c
callq 0xc060
movq %rax, %rbx
leaq 0x3e761(%rip), %rsi     # 0x619ed
leaq 0x8(%rsp), %rdi
leaq 0x1(%rsp), %rdx
callq 0xcb10
leaq 0x64aa6(%rip), %rdi     # 0x87d48
leaq 0x8(%rsp), %rsi
callq 0x14fb0
movq 0x50(%rsp), %r15
movq %rax, %r14
leaq 0x3e810(%rip), %rsi     # 0x61acb
leaq 0x30(%rsp), %rdi
leaq 0x3(%rsp), %rdx
callq 0xcb10
leaq 0x30(%rsp), %rsi
leaq 0xb0(%rsp), %rdx
movq %r14, %rdi
callq 0x1505c
movq %rax, %r14
leaq 0x3e6cb(%rip), %rsi     # 0x619b4
leaq 0x60(%rsp), %rdi
leaq 0x2(%rsp), %rdx
callq 0xcb10
subq 0x88(%rsp), %rbx
movl $0x3e8, %ecx            # imm = 0x3E8
movq %rbx, %rax
cqto
idivq %rcx
leaq 0x60(%rsp), %rsi
movq %r14, %rdi
movl %eax, %edx
callq 0x15236
movq %rax, %rdi
movq %r15, %rsi
callq 0x151b6
movq %rax, %rdi
callq 0x15224
leaq 0x60(%rsp), %rdi
callq 0xcd88
leaq 0x30(%rsp), %rdi
callq 0xcd88
leaq 0x8(%rsp), %rdi
callq 0xcd88
testq %r12, %r12
je 0x23454
movq %r12, %rdi
callq 0xc660
jmp 0x23454
leaq 0x3e603(%rip), %rsi     # 0x6196d
leaq 0x8(%rsp), %rdi
leaq 0x60(%rsp), %rdx
callq 0xcb10
leaq 0x649c8(%rip), %rdi     # 0x87d48
leaq 0x8(%rsp), %rsi
callq 0x14fb0
movq %rax, %rbx
leaq 0x3edcd(%rip), %rsi     # 0x62161
leaq 0x30(%rsp), %rdi
leaq 0x1(%rsp), %rdx
callq 0xcb10
leaq 0x1c8(%rbx), %rdi
leaq 0x30(%rsp), %rsi
callq 0x189cc
movb $0x1, (%rax)
movq %rbx, %rdi
movq %r14, %rsi
callq 0x151b6
movq %rax, %rdi
callq 0x15224
leaq 0x30(%rsp), %rdi
callq 0xcd88
leaq 0x8(%rsp), %rdi
callq 0xcd88
leaq 0x3e608(%rip), %rsi     # 0x619ed
leaq 0x8(%rsp), %rdi
leaq 0x60(%rsp), %rdx
callq 0xcb10
leaq 0x6494d(%rip), %rdi     # 0x87d48
leaq 0x8(%rsp), %rsi
callq 0x14fb0
movq %rax, %rbx
leaq 0x3e5a5(%rip), %rsi     # 0x619b4
leaq 0x30(%rsp), %rdi
leaq 0x1(%rsp), %rdx
callq 0xcb10
leaq 0x30(%rsp), %rsi
movq %rbx, %rdi
xorl %edx, %edx
callq 0x15236
movq %rax, %rdi
movq %r14, %rsi
callq 0x151b6
movq %rax, %rdi
callq 0x15224
leaq 0x30(%rsp), %rdi
callq 0xcd88
leaq 0x8(%rsp), %rdi
callq 0xcd88
leaq 0xd0(%rsp), %rdi
callq 0x10136
leaq 0x90(%rsp), %rdi
callq 0xcd88
leaq 0xb0(%rsp), %rdi
callq 0xcd88
addq $0x178, %rsp            # imm = 0x178
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
leaq 0x30(%rsp), %rdi
callq 0xcd88
jmp 0x2349f
movq %rax, %rbx
leaq 0x60(%rsp), %rdi
jmp 0x234f5
jmp 0x234cc
jmp 0x234cc
jmp 0x234cc
jmp 0x23508
jmp 0x234cc
jmp 0x234cc
jmp 0x23508
jmp 0x23508
jmp 0x234d5
jmp 0x234d5
jmp 0x234cc
jmp 0x234cc
jmp 0x23508
jmp 0x234cc
jmp 0x23508
jmp 0x23508
jmp 0x234d5
jmp 0x234d5
jmp 0x234cc
movq %rax, %rbx
jmp 0x234fa
jmp 0x23508
jmp 0x234d5
movq %rax, %rbx
jmp 0x234f0
jmp 0x23508
movq %rax, %rbx
jmp 0x23525
jmp 0x234e3
movq %rax, %rbx
leaq 0x60(%rsp), %rdi
callq 0xcd88
leaq 0x30(%rsp), %rdi
callq 0xcd88
leaq 0x8(%rsp), %rdi
callq 0xcd88
jmp 0x2350b
jmp 0x23508
movq %rax, %rbx
leaq 0xd0(%rsp), %rdi
callq 0x10136
leaq 0x90(%rsp), %rdi
callq 0xcd88
leaq 0xb0(%rsp), %rdi
callq 0xcd88
movq %rbx, %rdi
callq 0xc790
nop