// File: /workspace/github_c_makefile_star2_O2/niuyuling[P]CProxy/main.c
// Function: initialize
void initialize(conf * configure)
{
    int i;
    char *p;

    memset(cts, 0, sizeof(cts));
    for (i = MAX_CONNECTION; i--;)
        cts[i].fd = -1;
    // 为服务端的结构体分配内存
    for (i = 1; i < MAX_CONNECTION; i += 2) {
        cts[i].ready_data = (char *)malloc(BUFFER_SIZE);
        if (cts[i].ready_data == NULL) {
            fputs("out of memory.", stderr);
            exit(1);
        }
    }

    memset(&global, 0, sizeof(global));
    memset(&httpdns, 0, sizeof(httpdns));
    memset(&https, 0, sizeof(https));
    memset(&udp, 0, sizeof(udp));
    saveHdrs = NULL;
    httpdns.dst.sin_family = AF_INET;
    udp.dst.sin_family = AF_INET;
    global.tcp_listen_fd = global.dns_listen_fd = global.udp_listen_fd = global.uid = -1;

    // httpdns module
    global.dns_listen_fd = udp_listen((char *)"127.0.0.1", configure->dns_listen);
    if ((p = strchr(configure->httpdns_addr, ':')) != NULL) {
        *p = '\0';
        httpdns.dst.sin_port = htons(atoi(p + 1));
    } else {
        httpdns.dst.sin_port = htons(80);
    }
    httpdns.dst.sin_addr.s_addr = inet_addr(configure->httpdns_addr);
    httpdns.http_req_len = configure->httpdns_http_req_len;
    copy_new_mem(configure->httpdns_http_req, httpdns.http_req_len, &httpdns.http_req);

    // httpudp module
    global.udp_listen_fd = udp_listen((char *)"0.0.0.0", configure->udp_listen);
    if ((p = strchr(configure->httpudp_addr, ':')) != NULL) {
        *p = '\0';
        udp.dst.sin_port = htons(atoi(p + 1));
    } else {
        udp.dst.sin_port = htons(80);
    }
    udp.dst.sin_addr.s_addr = inet_addr(configure->httpudp_addr);
    udp.http_request_len = configure->httpudp_http_req_len;
    copy_new_mem(configure->httpudp_http_req, udp.http_request_len, &udp.http_request);

    // global module
    server_sock = create_server_socket(configure->tcp_listen); // IPV4
    server_sock6 = create_server_socket6(configure->tcp_listen); // IPV6

}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movq %rdi, %rbx
leaq 0x96b2(%rip), %r14      # 0xc420
movl $0x9f60, %edx           # imm = 0x9F60
movq %r14, %rdi
xorl %esi, %esi
callq 0x21b0
movl $0x9f48, %eax           # imm = 0x9F48
cmpq $-0x18, %rax
je 0x2d93
orl $-0x1, (%rax,%r14)
addq $-0x28, %rax
jmp 0x2d82
leaq 0x96ae(%rip), %r15      # 0xc448
pushq $-0x1
popq %r14
addq $0x2, %r14
cmpq $0x3fb, %r14            # imm = 0x3FB
ja 0x2de2
leaq 0x50(%r15), %r12
movl $0x2000, %edi           # imm = 0x2000
callq 0x2330
movq %rax, (%r15)
movq %r12, %r15
testq %rax, %rax
jne 0x2d9e
movq 0x922d(%rip), %rax      # 0xbff8
movq (%rax), %rsi
leaq 0x6313(%rip), %rdi      # 0x90e8
callq 0x21a0
pushq $0x1
popq %rdi
callq 0x24b0
andl $0x0, 0x165af(%rip)     # 0x19398
andq $0x0, 0x1659f(%rip)     # 0x19390
pxor %xmm0, %xmm0
leaq 0x16884(%rip), %r15     # 0x19680
movdqu %xmm0, (%r15)
movdqu %xmm0, 0x10(%r15)
movdqu %xmm0, 0x20(%r15)
movdqu %xmm0, 0x30(%r15)
movdqu %xmm0, 0x40(%r15)
andq $0x0, 0x60(%r15)
movdqu %xmm0, 0x50(%r15)
movdqu %xmm0, 0x16574(%rip)    # 0x193a0
movdqu %xmm0, 0x1657c(%rip)    # 0x193b0
leaq 0x2070b2d(%rip), %r14   # 0x2073968
movdqu %xmm0, (%r14)
andq $0x0, 0x16578(%rip)     # 0x193c0
movdqu %xmm0, 0x10(%r14)
movdqu %xmm0, 0x20(%r14)
movw $0x2, %ax
movw %ax, (%r15)
movw %ax, (%r14)
pcmpeqd %xmm0, %xmm0
movdqu %xmm0, 0x16514(%rip)    # 0x19380
movl 0x18(%rbx), %esi
leaq 0x6281(%rip), %rdi      # 0x90f7
callq 0x2c5c
movl %eax, 0x16503(%rip)     # 0x19384
movq 0x80(%rbx), %r12
pushq $0x3a
popq %rsi
movq %r12, %rdi
callq 0x2160
movw $0x5000, %bp            # imm = 0x5000
movw $0x5000, %cx            # imm = 0x5000
testq %rax, %rax
je 0x2ebb
movb $0x0, (%rax)
incq %rax
movq %rax, %rdi
callq 0x2480
movl %eax, %ecx
rolw $0x8, %cx
movq 0x80(%rbx), %r12
movw %cx, 0x2(%r15)
movq %r12, %rdi
callq 0x2280
movl %eax, 0x4(%r15)
movl 0x94(%rbx), %esi
movl %esi, 0x40(%r15)
movq 0x88(%rbx), %rdi
addq $0x10, %r15
movq %r15, %rdx
callq 0x3ee8
movl 0x1c(%rbx), %esi
leaq 0x620e(%rip), %rdi      # 0x9101
callq 0x2c5c
movl %eax, 0x1648a(%rip)     # 0x19388
movq 0xa0(%rbx), %r15
pushq $0x3a
popq %rsi
movq %r15, %rdi
callq 0x2160
testq %rax, %rax
je 0x2f30
movb $0x0, (%rax)
incq %rax
movq %rax, %rdi
callq 0x2480
movl %eax, %ebp
rolw $0x8, %bp
movq 0xa0(%rbx), %r15
movw %bp, 0x2(%r14)
movq %r15, %rdi
callq 0x2280
movl %eax, 0x4(%r14)
movl 0xb4(%rbx), %esi
movl %esi, 0x20(%r14)
movq 0xa8(%rbx), %rdi
addq $0x10, %r14
movq %r14, %rdx
callq 0x3ee8
movl 0x10(%rbx), %edi
callq 0x266c
movl %eax, 0x13414(%rip)     # 0x16380
movl 0x10(%rbx), %edi
callq 0x2715
movl %eax, 0x1340e(%rip)     # 0x16388
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq