// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x8(%rbp)
leaq 0xc2dd(%rip), %rdi      # 0xf470
xorl %esi, %esi
movl $0x9f60, %edx           # imm = 0x9F60
callq 0x21c0
movl $0x3fc, -0xc(%rbp)      # imm = 0x3FC
movl -0xc(%rbp), %eax
movl %eax, %ecx
addl $-0x1, %ecx
movl %ecx, -0xc(%rbp)
cmpl $0x0, %eax
je 0x31d1
movslq -0xc(%rbp), %rcx
leaq 0xc2af(%rip), %rax      # 0xf470
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movl $0xffffffff, 0x10(%rax) # imm = 0xFFFFFFFF
jmp 0x31a6
movl $0x1, -0xc(%rbp)
cmpl $0x3fc, -0xc(%rbp)      # imm = 0x3FC
jge 0x3248
movl $0x2000, %edi           # imm = 0x2000
callq 0x2350
movq %rax, %rcx
movslq -0xc(%rbp), %rdx
leaq 0xc277(%rip), %rax      # 0xf470
imulq $0x28, %rdx, %rdx
addq %rdx, %rax
movq %rcx, (%rax)
movslq -0xc(%rbp), %rcx
leaq 0xc262(%rip), %rax      # 0xf470
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
cmpq $0x0, (%rax)
jne 0x323b
movq 0xbdce(%rip), %rax      # 0xeff0
movq (%rax), %rsi
leaq 0x8f4f(%rip), %rdi      # 0xc17b
callq 0x21b0
movl $0x1, %edi
callq 0x24e0
jmp 0x323d
movl -0xc(%rbp), %eax
addl $0x2, %eax
movl %eax, -0xc(%rbp)
jmp 0x31d8
leaq 0x19181(%rip), %rdi     # 0x1c3d0
xorl %esi, %esi
movl $0x1c, %edx
callq 0x21c0
leaq 0x1946e(%rip), %rdi     # 0x1c6d0
xorl %esi, %esi
movl $0x68, %edx
callq 0x21c0
leaq 0x1917b(%rip), %rdi     # 0x1c3f0
xorl %esi, %esi
movl $0x20, %edx
callq 0x21c0
leaq 0x2073730(%rip), %rdi   # 0x20769b8
xorl %esi, %esi
movl $0x30, %edx
callq 0x21c0
movq $0x0, 0x19171(%rip) # 0x1c410
leaq 0x1942a(%rip), %rax     # 0x1c6d0
movw $0x2, (%rax)
leaq 0x2073706(%rip), %rax   # 0x20769b8
movw $0x2, (%rax)
movl $0xffffffff, 0x1911b(%rip) # imm = 0xFFFFFFFF
movl $0xffffffff, 0x1910d(%rip) # imm = 0xFFFFFFFF
movl $0xffffffff, 0x190ff(%rip) # imm = 0xFFFFFFFF
movl $0xffffffff, 0x190f1(%rip) # imm = 0xFFFFFFFF
movq -0x8(%rbp), %rax
movl 0x18(%rax), %esi
leaq 0x8e9d(%rip), %rdi      # 0xc18a
callq 0x3040
movl %eax, 0x190dc(%rip)     # 0x1c3d4
movq -0x8(%rbp), %rax
movq 0x80(%rax), %rdi
movl $0x3a, %esi
callq 0x2170
movq %rax, -0x18(%rbp)
cmpq $0x0, %rax
je 0x3343
movq -0x18(%rbp), %rax
movb $0x0, (%rax)
movq -0x18(%rbp), %rdi
addq $0x1, %rdi
callq 0x24a0
movzwl %ax, %edi
callq 0x2160
movw %ax, %cx
leaq 0x19393(%rip), %rax     # 0x1c6d0
movw %cx, 0x2(%rax)
jmp 0x335b
movl $0x50, %edi
callq 0x2160
movw %ax, %cx
leaq 0x19379(%rip), %rax     # 0x1c6d0
movw %cx, 0x2(%rax)
movq -0x8(%rbp), %rax
movq 0x80(%rax), %rdi
callq 0x22a0
movl %eax, %ecx
leaq 0x1935c(%rip), %rax     # 0x1c6d0
movl %ecx, 0x4(%rax)
movq -0x8(%rbp), %rax
movl 0x94(%rax), %ecx
leaq 0x19348(%rip), %rax     # 0x1c6d0
movl %ecx, 0x40(%rax)
movq -0x8(%rbp), %rax
movq 0x88(%rax), %rdi
leaq 0x19333(%rip), %rax     # 0x1c6d0
movl 0x40(%rax), %esi
leaq 0x19329(%rip), %rdx     # 0x1c6d0
addq $0x10, %rdx
callq 0x4c90
movq -0x8(%rbp), %rax
movl 0x1c(%rax), %esi
leaq 0x8dd6(%rip), %rdi      # 0xc194
callq 0x3040
movl %eax, 0x1900f(%rip)     # 0x1c3d8
movq -0x8(%rbp), %rax
movq 0xa0(%rax), %rdi
movl $0x3a, %esi
callq 0x2170
movq %rax, -0x18(%rbp)
cmpq $0x0, %rax
je 0x3414
movq -0x18(%rbp), %rax
movb $0x0, (%rax)
movq -0x18(%rbp), %rdi
addq $0x1, %rdi
callq 0x24a0
movzwl %ax, %edi
callq 0x2160
movw %ax, %cx
leaq 0x20735aa(%rip), %rax   # 0x20769b8
movw %cx, 0x2(%rax)
jmp 0x342c
movl $0x50, %edi
callq 0x2160
movw %ax, %cx
leaq 0x2073590(%rip), %rax   # 0x20769b8
movw %cx, 0x2(%rax)
movq -0x8(%rbp), %rax
movq 0xa0(%rax), %rdi
callq 0x22a0
movl %eax, %ecx
leaq 0x2073573(%rip), %rax   # 0x20769b8
movl %ecx, 0x4(%rax)
movq -0x8(%rbp), %rax
movl 0xb4(%rax), %ecx
leaq 0x207355f(%rip), %rax   # 0x20769b8
movl %ecx, 0x20(%rax)
movq -0x8(%rbp), %rax
movq 0xa8(%rax), %rdi
leaq 0x207354a(%rip), %rax   # 0x20769b8
movl 0x20(%rax), %esi
leaq 0x2073540(%rip), %rdx   # 0x20769b8
addq $0x10, %rdx
callq 0x4c90
movq -0x8(%rbp), %rax
movl 0x10(%rax), %edi
callq 0x26a0
movl %eax, 0x15f3d(%rip)     # 0x193d0
movq -0x8(%rbp), %rax
movl 0x10(%rax), %edi
callq 0x27b0
movl %eax, 0x15f33(%rip)     # 0x193d8
addq $0x20, %rsp
popq %rbp
retq
nopl (%rax,%rax)