// File: /workspace/github_c_makefile_star2_O1/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 %rbx
pushq %rax
movq %rdi, %rbx
leaq 0x948f(%rip), %r14      # 0xc410
movl $0x9f60, %edx           # imm = 0x9F60
movq %r14, %rdi
xorl %esi, %esi
callq 0x21b0
movl $0x9f48, %eax           # imm = 0x9F48
movl $0xffffffff, (%rax,%r14) # imm = 0xFFFFFFFF
addq $-0x28, %rax
cmpq $-0x18, %rax
jne 0x2f95
movq $-0x1, %r14
leaq 0x9483(%rip), %r15      # 0xc438
movl $0x2000, %edi           # imm = 0x2000
callq 0x2320
movq %rax, (%r15)
testq %rax, %rax
je 0x3178
addq $0x2, %r14
addq $0x50, %r15
cmpq $0x3f9, %r14            # imm = 0x3F9
jbe 0x2fb5
pxor %xmm0, %xmm0
movdqu %xmm0, 0x16394(%rip)    # 0x1937c
movdqu %xmm0, 0x16380(%rip)    # 0x19370
leaq 0x16679(%rip), %r15     # 0x19670
movdqu %xmm0, (%r15)
movdqu %xmm0, 0x10(%r15)
movdqu %xmm0, 0x20(%r15)
movdqu %xmm0, 0x30(%r15)
movdqu %xmm0, 0x40(%r15)
movdqu %xmm0, 0x50(%r15)
xorl %eax, %eax
movq %rax, 0x60(%r15)
movdqu %xmm0, 0x16368(%rip)    # 0x19390
movdqu %xmm0, 0x16370(%rip)    # 0x193a0
leaq 0x2070921(%rip), %r14   # 0x2073958
movdqu %xmm0, (%r14)
movdqu %xmm0, 0x10(%r14)
movdqu %xmm0, 0x20(%r14)
movq %rax, 0x16361(%rip)     # 0x193b0
movw $0x2, %ax
movw %ax, (%r15)
movw %ax, (%r14)
pcmpeqd %xmm0, %xmm0
movdqu %xmm0, 0x16309(%rip)    # 0x19370
movl 0x18(%rbx), %esi
leaq 0x6089(%rip), %rdi      # 0x90fa
callq 0x2e78
movl %eax, 0x162f8(%rip)     # 0x19374
movq 0x80(%rbx), %rdi
movl $0x3a, %esi
callq 0x2160
movw $0x5000, %bp            # imm = 0x5000
movw $0x5000, %cx            # imm = 0x5000
testq %rax, %rax
je 0x30ae
movb $0x0, (%rax)
incq %rax
movq %rax, %rdi
callq 0x2470
movl %eax, %ecx
rolw $0x8, %cx
movw %cx, 0x2(%r15)
movq 0x80(%rbx), %rdi
callq 0x2270
movl %eax, 0x4(%r15)
movl 0x94(%rbx), %esi
movl %esi, 0x40(%r15)
movq 0x88(%rbx), %rdi
addq $0x10, %r15
movq %r15, %rdx
callq 0x407e
movl 0x1c(%rbx), %esi
leaq 0x601a(%rip), %rdi      # 0x9104
callq 0x2e78
movl %eax, 0x16283(%rip)     # 0x19378
movq 0xa0(%rbx), %rdi
movl $0x3a, %esi
callq 0x2160
testq %rax, %rax
je 0x311f
movb $0x0, (%rax)
incq %rax
movq %rax, %rdi
callq 0x2470
movl %eax, %ebp
rolw $0x8, %bp
movw %bp, 0x2(%r14)
movq 0xa0(%rbx), %rdi
callq 0x2270
movl %eax, 0x4(%r14)
movl 0xb4(%rbx), %esi
movl %esi, 0x20(%r14)
movq 0xa8(%rbx), %rdi
addq $0x10, %r14
movq %r14, %rdx
callq 0x407e
movl 0x10(%rbx), %edi
callq 0x27cc
movl %eax, 0x13211(%rip)     # 0x16370
movl 0x10(%rbx), %edi
callq 0x2887
movl %eax, 0x1320b(%rip)     # 0x16378
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
callq 0x265f