LLM4Binary/decompile-bench-makefile huggingface dataset:
// File: /workspace/github_c_makefile_star2_O2/niuyuling[P]CProxy/main.c
// Function: accept_client6
void accept_client6()
{
    struct epoll_event epollEvent;
    struct sockaddr_in6 addr;
    conn_t *client;
    socklen_t addr_len = sizeof(addr);

    // 偶数为客户端,奇数为服务端
    for (client = cts; client - cts < MAX_CONNECTION; client += 2)
        if (client->fd < 0)
            break;
    if (client - cts >= MAX_CONNECTION)
        return;
    client->timer = (client + 1)->timer = 0;
    client->fd = accept(server_sock6, (struct sockaddr *)&addr, &addr_len);
    if (client->fd < 0)
        return;
    fcntl(client->fd, F_SETFL, O_NONBLOCK);
    epollEvent.events = EPOLLIN | EPOLLET;
    epollEvent.data.ptr = client;
    epoll_ctl(epollfd, EPOLL_CTL_ADD, client->fd, &epollEvent);
}

// Assembly:
pushq %r14
pushq %rbx
subq $0x38, %rsp
movl $0x1c, 0xc(%rsp)
xorl %r14d, %r14d
leaq 0x9b7b(%rip), %rbx      # 0xc420
cmpq $0x9f5f, %r14           # imm = 0x9F5F
jg 0x2923
cmpl $0x0, 0x10(%r14,%rbx)
js 0x28bc
addq $0x50, %r14
jmp 0x28a5
cmpq $0x9f38, %r14           # imm = 0x9F38
jg 0x2923
andl $0x0, 0x48(%r14,%rbx)
andl $0x0, 0x20(%r14,%rbx)
movl 0x13ab1(%rip), %edi     # 0x16388
leaq 0x1c(%rsp), %rsi
leaq 0xc(%rsp), %rdx
callq 0x2470
movl %eax, 0x10(%r14,%rbx)
testl %eax, %eax
js 0x2923
addq %r14, %rbx
pushq $0x4
popq %rsi
movl %eax, %edi
movl $0x800, %edx            # imm = 0x800
xorl %eax, %eax
callq 0x20d0
leaq 0x10(%rsp), %rcx
movl $0x80000001, (%rcx)     # imm = 0x80000001
movq %rbx, 0x4(%rcx)
movl 0x13a6c(%rip), %edi     # 0x16384
movl 0x10(%rbx), %edx
pushq $0x1
popq %rsi
callq 0x2220
addq $0x38, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O2/niuyuling[P]CProxy/main.c
// Function: tcp_loop
void *tcp_loop(void *p)
{
    conf *configure = (conf *) p;
    int n;

    ev.events = EPOLLIN;
    ev.data.fd = server_sock;
    if (-1 == epoll_ctl(epollfd, EPOLL_CTL_ADD, server_sock, &ev)) {
        exit(1);
    }

    ev.events = EPOLLIN;
    ev.data.fd = server_sock6;
    if (-1 == epoll_ctl(epollfd, EPOLL_CTL_ADD, server_sock6, &ev)) {
        exit(1);
    }

    while (1) {
        n = epoll_wait(epollfd, events, MAX_CONNECTION, -1);
        while (n-- > 0) {
            if (events[n].data.fd == server_sock6) {
                accept_client6();
            } else if (events[n].data.fd == server_sock) {
                accept_client();
            } else {
                if (events[n].events & EPOLLIN) {
                    tcp_in((conn_t *) events[n].data.ptr, configure);
                }
                if (events[n].events & EPOLLOUT) {
                    tcp_out((conn_t *) events[n].data.ptr);
                }
            }
        }
    }

    return NULL;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movq %rdi, %rbx
movl $0x1, 0x13a4c(%rip)     # 0x1638c
leaq 0x13a45(%rip), %rcx     # 0x1638c
movl 0x13a33(%rip), %edx     # 0x16380
movl %edx, 0x13a3d(%rip)     # 0x16390
movl 0x13a2b(%rip), %edi     # 0x16384
pushq $0x1
popq %rsi
callq 0x2220
cmpl $-0x1, %eax
je 0x2a25
movl $0x1, 0x13a18(%rip)     # 0x1638c
leaq 0x13a11(%rip), %rcx     # 0x1638c
movl 0x13a07(%rip), %edx     # 0x16388
movl %edx, 0x13a09(%rip)     # 0x16390
movl 0x139f7(%rip), %edi     # 0x16384
pushq $0x1
popq %rsi
callq 0x2220
cmpl $-0x1, %eax
je 0x2a25
leaq 0x139fb(%rip), %r14     # 0x163a0
pushq $-0x1
popq %rbp
movl 0x139d6(%rip), %edi     # 0x16384
movq %r14, %rsi
movl $0x3fc, %edx            # imm = 0x3FC
movl %ebp, %ecx
callq 0x23f0
movl %eax, %r15d
movl %eax, %eax
imulq $0xc, %rax, %rax
leaq (%rax,%r14), %r12
addq $-0x8, %r12
testl %r15d, %r15d
jle 0x29a8
movl (%r12), %eax
cmpl 0x139ab(%rip), %eax     # 0x16388
jne 0x29e6
callq 0x288c
jmp 0x2a1c
cmpl 0x13994(%rip), %eax     # 0x16380
jne 0x29f5
callq 0x27ed
jmp 0x2a1c
movl -0x4(%r12), %eax
testb $0x1, %al
je 0x2a0f
movq (%r12), %rdi
movq %rbx, %rsi
callq 0x38c2
movl -0x4(%r12), %eax
testb $0x4, %al
je 0x2a1c
movq (%r12), %rdi
callq 0x3d9e
decl %r15d
addq $-0xc, %r12
jmp 0x29ce
pushq $0x1
popq %rdi
callq 0x24b0
// File: /workspace/github_c_makefile_star2_O2/niuyuling[P]CProxy/main.c
// Function: get_executable_path
int get_executable_path(char *processdir, char *processname, int len)
{
    char *filename;
    if (readlink("/proc/self/exe", processdir, len) <= 0)
        return -1;
    filename = strrchr(processdir, '/');
    if (filename == NULL)
        return -1;
    ++filename;
    strcpy(processname, filename);
    *filename = '\0';
    return (int)(filename - processdir);
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
movq %rsi, %r15
movq %rdi, %rbx
movslq %edx, %rdx
leaq 0x64f5(%rip), %rdi      # 0x90be
movq %rbx, %rsi
callq 0x20c0
pushq $-0x1
popq %r14
testq %rax, %rax
jle 0x2c07
pushq $0x2f
popq %rsi
movq %rbx, %rdi
callq 0x2190
testq %rax, %rax
je 0x2c07
movq %rax, %r12
movq %rax, %r14
incq %r14
movq %r15, %rdi
movq %r14, %rsi
callq 0x2080
movb $0x0, 0x1(%r12)
subl %ebx, %r14d
movl %r14d, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O2/niuyuling[P]CProxy/main.c
// Function: server_ini
void server_ini()
{
    signal(SIGPIPE, SIG_IGN);   // 忽略PIPE信号

    if (daemon(1, 1)) {
        perror("daemon");
        return;
    }

    while (process-- > 1 && fork() == 0);
}

// Assembly:
pushq %rax
pushq $0xd
popq %rdi
pushq $0x1
popq %rsi
callq 0x22a0
pushq $0x1
popq %rdi
movl %edi, %esi
callq 0x23a0
testl %eax, %eax
jne 0x2c4f
movl 0x16746(%rip), %eax     # 0x1937c
leal -0x1(%rax), %ecx
movl %ecx, 0x1673d(%rip)     # 0x1937c
cmpl $0x2, %eax
jl 0x2c4d
callq 0x2530
testl %eax, %eax
je 0x2c30
popq %rax
retq
leaq 0x6477(%rip), %rdi      # 0x90cd
popq %rax
jmp 0x2460
// File: /workspace/github_c_makefile_star2_O2/niuyuling[P]CProxy/main.c
// Function: udp_listen
int udp_listen(char *ip, int port)
{
    struct sockaddr_in addr;
    int fd, opt = 1;

    if ((fd = socket(AF_INET, SOCK_DGRAM, 0)) < 0) {
        perror("udp socket");
        exit(1);
    }
    setsockopt(fd, SOL_IP, IP_TRANSPARENT, &opt, sizeof(opt));
    setsockopt(fd, SOL_IP, IP_RECVORIGDSTADDR, &opt, sizeof(opt));
    memset(&addr, 0, sizeof(addr));
    addr.sin_addr.s_addr = inet_addr(ip);
    addr.sin_port = htons(port);
    addr.sin_family = AF_INET;
    if (bind(fd, (struct sockaddr *)&addr, sizeof(addr)) != 0) {
        perror("udp bind");
        exit(1);
    }

    return fd;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x20, %rsp
movl %esi, %ebp
movq %rdi, %r14
movl $0x1, 0xc(%rsp)
pushq $0x2
popq %rdi
movl %edi, %esi
xorl %edx, %edx
callq 0x2550
testl %eax, %eax
js 0x2cf9
movl %eax, %ebx
pushq $0x13
popq %rdx
leaq 0xc(%rsp), %r15
pushq $0x4
popq %r12
movl %eax, %edi
xorl %esi, %esi
movq %r15, %rcx
movl %r12d, %r8d
callq 0x20b0
pushq $0x14
popq %rdx
movl %ebx, %edi
xorl %esi, %esi
movq %r15, %rcx
movl %r12d, %r8d
callq 0x20b0
leaq 0x10(%rsp), %r15
andq $0x0, 0x8(%r15)
movq %r14, %rdi
callq 0x2280
movl %eax, 0x4(%r15)
rolw $0x8, %bp
movw %bp, 0x2(%r15)
movw $0x2, (%r15)
pushq $0x10
popq %rdx
movl %ebx, %edi
movq %r15, %rsi
callq 0x2410
testl %eax, %eax
jne 0x2d02
movl %ebx, %eax
addq $0x20, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
leaq 0x63d4(%rip), %rdi      # 0x90d4
jmp 0x2d09
leaq 0x63d6(%rip), %rdi      # 0x90df
callq 0x2460
pushq $0x1
popq %rdi
callq 0x24b0
// File: /workspace/github_c_makefile_star2_O2/niuyuling[P]CProxy/main.c
// Function: timeout_check
void *timeout_check(void *nullPtr)
{
    while (1) {
        sleep(60);
        if (server_sock >= 0 || server_sock6 >= 0)
            tcp_timeout_check(NULL);
        if (global.dns_listen_fd >= 0)
            dns_timeout_check();
        if (global.udp_listen_fd >= 0)
            udp_timeout_check();
    }

    return NULL;
}

// Assembly:
pushq %rbx
pushq $0x3c
popq %rbx
movl %ebx, %edi
callq 0x2500
cmpl $0x0, 0x13658(%rip)     # 0x16380
jns 0x2d33
cmpl $0x0, 0x13657(%rip)     # 0x16388
js 0x2d3a
xorl %edi, %edi
callq 0x366c
cmpl $0x0, 0x16643(%rip)     # 0x19384
js 0x2d4a
xorl %eax, %eax
callq 0x5784
cmpl $0x0, 0x16637(%rip)     # 0x19388
js 0x2d1a
xorl %eax, %eax
callq 0x66c8
jmp 0x2d1a
// File: /workspace/github_c_makefile_star2_O2/niuyuling[P]CProxy/main.c
// Function: thread_loop
void thread_loop(conf * configure)
{
    pthread_t thread_id = 0;
    /*
    sigset_t signal_mask;
    sigemptyset(&signal_mask);
    sigaddset(&signal_mask, SIGPIPE); // 忽略PIPE信号
    if (pthread_sigmask(SIG_BLOCK, &signal_mask, NULL) != 0) {
        printf("block sigpipe error\n");
    }
    */
    
    if (global.timeout_m)
        pthread_create(&thread_id, NULL, &timeout_check, NULL);
    
    if (server_sock >= 0)
    {
        if (global.dns_listen_fd >= 0) {
            dns_init();
            pthread_create(&thread_id, NULL, &dns_loop, NULL);
        }
        if (global.udp_listen_fd >= 0) {
            udp_init();
            //udp_loop(NULL);
            pthread_create(&thread_id, NULL, &udp_loop, NULL);
        }
        
        if (pthread_create(&thread_id, NULL, &tcp_loop, (void *)configure) != 0)
            perror("pthread_create");
    }
    
    if (global.dns_listen_fd >= 0)
    {
        dns_init();
        if (global.udp_listen_fd >= 0)
        {
            udp_init();
            pthread_create(&thread_id, NULL, &udp_loop, NULL);
        }
        dns_loop(NULL);
    }

    udp_init();
    udp_loop(NULL);

    //pthread_join(thread_id, NULL);
    //pthread_exit(NULL);

    /*  线程分离
       pthread_attr_t attr;
       pthread_attr_init(&attr);
       pthread_attr_setscope(&attr, PTHREAD_SCOPE_SYSTEM);
       pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
       pthread_create(&thread_id, &attr, &tcp_timeout_check, NULL);
       pthread_create(&thread_id, &attr, &tcp_loop, (void *)configure);
       pthread_exit(NULL);
     */
}

// Assembly:
pushq %rbx
subq $0x10, %rsp
andq $0x0, 0x8(%rsp)
movq %rdi, %rbx
cmpl $0x0, 0x163fc(%rip)     # 0x19394
je 0x2faf
leaq -0x28b(%rip), %rdx      # 0x2d16
leaq 0x8(%rsp), %rdi
xorl %esi, %esi
xorl %ecx, %ecx
callq 0x2420
cmpl $0x0, 0x133ca(%rip)     # 0x16380
js 0x301c
cmpl $0x0, 0x163c5(%rip)     # 0x19384
js 0x2fdd
xorl %eax, %eax
callq 0x5842
leaq 0x2c4f(%rip), %rdx      # 0x5c1e
leaq 0x8(%rsp), %rdi
xorl %esi, %esi
xorl %ecx, %ecx
callq 0x2420
cmpl $0x0, 0x163a4(%rip)     # 0x19388
js 0x3002
xorl %eax, %eax
callq 0x67a4
leaq 0x3ae7(%rip), %rdx      # 0x6adb
leaq 0x8(%rsp), %rdi
xorl %esi, %esi
xorl %ecx, %ecx
callq 0x2420
leaq -0x6de(%rip), %rdx      # 0x292b
leaq 0x8(%rsp), %rdi
xorl %esi, %esi
movq %rbx, %rcx
callq 0x2420
testl %eax, %eax
jne 0x306c
cmpl $0x0, 0x16361(%rip)     # 0x19384
js 0x3058
xorl %eax, %eax
callq 0x5842
cmpl $0x0, 0x16355(%rip)     # 0x19388
js 0x3051
xorl %eax, %eax
callq 0x67a4
leaq 0x3a98(%rip), %rdx      # 0x6adb
leaq 0x8(%rsp), %rdi
xorl %esi, %esi
xorl %ecx, %ecx
callq 0x2420
xorl %edi, %edi
callq 0x5c1e
xorl %eax, %eax
callq 0x67a4
xorl %edi, %edi
callq 0x6adb
addq $0x10, %rsp
popq %rbx
retq
leaq 0x6096(%rip), %rdi      # 0x9109
callq 0x2460
jmp 0x301c
// File: /workspace/github_c_makefile_star2_O2/niuyuling[P]CProxy/main.c
// Function: help_information
static char help_information(void)
{
    static const char name[] = "C";
    static const char subject[] = "Proxy Server";
    static const struct {
        const char *email;
    } author = {
        "AIXIAO@AIXIAO.ME",
    };

    static const char usage[] = "Usage: [-?h] [-s signal] [-c filename]";
    static const char *s_help[] = {
        "",
        "Options:",
        "    -s --signal            : send signal to a master process: stop, quit, restart, reload, status",
        "    -c --config            : set configuration file, default: CProxy.conf",
        "    -? -h --? --help       : help information",
        "",
        0
    };

    fprintf(stderr, "%s %s\n", name, subject);
    fprintf(stderr, "Author: %s\n", author.email);
    fprintf(stderr, "%s\n", usage);

    int l;
    for (l = 0; s_help[l]; l++) {
        fprintf(stderr, "%s\n", s_help[l]);
    }

    BUILD("Compile、link.\n");

    return 0;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
movq 0x8a5e(%rip), %r14      # 0xbff8
movq (%r14), %rdi
leaq 0x5cee(%rip), %rsi      # 0x9292
leaq 0x5aad(%rip), %rdx      # 0x9058
leaq 0x5aa8(%rip), %rcx      # 0x905a
xorl %eax, %eax
callq 0x22b0
movq (%r14), %rdi
leaq 0x5cd6(%rip), %rsi      # 0x9299
leaq 0x5bd4(%rip), %rdx      # 0x919e
xorl %eax, %eax
callq 0x22b0
movq (%r14), %rdi
leaq 0x5cc6(%rip), %rbx      # 0x92a1
leaq 0x5a8e(%rip), %rdx      # 0x9070
movq %rbx, %rsi
xorl %eax, %eax
callq 0x22b0
leaq 0x875d(%rip), %r15      # 0xbd50
xorl %r12d, %r12d
cmpq $0x30, %r12
je 0x3613
movq (%r12,%r15), %rdx
movq (%r14), %rdi
movq %rbx, %rsi
xorl %eax, %eax
callq 0x22b0
addq $0x8, %r12
jmp 0x35f6
movq (%r14), %rdi
leaq 0x5c88(%rip), %rsi      # 0x92a5
leaq 0x5c88(%rip), %rdx      # 0x92ac
leaq 0x5c8d(%rip), %rcx      # 0x92b8
xorl %eax, %eax
callq 0x22b0
movq (%r14), %rcx
leaq 0x5c85(%rip), %rdi      # 0x92c1
pushq $0x10
popq %rsi
pushq $0x1
popq %rdx
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
jmp 0x24d0
// File: /workspace/github_c_makefile_star2_O2/niuyuling[P]CProxy/http_proxy.c
// Function: tcp_timeout_check
void *tcp_timeout_check(void *nullPtr)
{
    int i;

    for (i = 0; i < MAX_CONNECTION; i += 2) {
        if (cts[i].fd > -1) {
            if (cts[i].timer >= timeout_minute) {
                printf("关闭连接\n");
                close_connection(cts + i);
            } else
                cts[i].timer++;
        }
    }

    return NULL;
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
leaq 0x8da8(%rip), %rbx      # 0xc420
xorl %r15d, %r15d
leaq 0x5cc4(%rip), %r14      # 0x9346
cmpq $0x3fb, %r15            # imm = 0x3FB
ja 0x36bd
cmpl $0x0, 0x10(%rbx)
js 0x36b3
movl 0x20(%rbx), %eax
cmpl 0x15ea6(%rip), %eax     # 0x19540
jge 0x36a3
incl %eax
movl %eax, 0x20(%rbx)
jmp 0x36b3
movq %r14, %rdi
callq 0x2090
movq %rbx, %rdi
callq 0x36c5
addq $0x2, %r15
addq $0x50, %rbx
jmp 0x3682
xorl %eax, %eax
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O2/niuyuling[P]CProxy/http_proxy.c
// Function: close_connection
void close_connection(conn_t * conn)
{
    epoll_ctl(epollfd, EPOLL_CTL_DEL, conn->fd, NULL);
    close(conn->fd);
    if ((conn - cts) & 1) {
        char *server_data;

        server_data = conn->ready_data;
        memset(conn, 0, sizeof(conn_t));
        conn->ready_data = server_data;
        conn--->fd = -1;
    } else {
        free(conn->ready_data);
        free(conn->incomplete_data);
        memset(conn, 0, sizeof(conn_t));
        conn++->fd = -1;
    }
    if (conn->fd >= 0)
        close_connection(conn);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %rbx
movl 0x10(%rdi), %edx
leaq 0x12ca7(%rip), %r14     # 0x16384
pushq $0x2
popq %rbp
leaq 0x8d39(%rip), %r15      # 0xc420
pushq $0x28
popq %r12
pushq $-0x28
popq %r13
movl (%r14), %edi
movl %ebp, %esi
xorl %ecx, %ecx
callq 0x2220
movl 0x10(%rbx), %edi
callq 0x21e0
movq %rbx, %rax
subq %r15, %rax
cqto
idivq %r12
movq (%rbx), %rdi
testb $0x1, %al
jne 0x3737
callq 0x2030
movq 0x8(%rbx), %rdi
callq 0x2030
xorps %xmm0, %xmm0
movups %xmm0, 0x10(%rbx)
movups %xmm0, (%rbx)
andq $0x0, 0x20(%rbx)
movq %r12, %rax
jmp 0x3748
xorps %xmm0, %xmm0
movups %xmm0, 0x18(%rbx)
movups %xmm0, 0x8(%rbx)
movq %rdi, (%rbx)
movq %r13, %rax
orl $-0x1, 0x10(%rbx)
movl 0x10(%rbx,%rax), %edx
addq %rax, %rbx
testl %edx, %edx
jns 0x36ef
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/niuyuling[P]CProxy/http_proxy.c
// Function: clientToserver
void clientToserver(conn_t * in)
{
    int write_len;
    conn_t *remote;
    remote = in + 1;

    write_len = write(remote->fd, in->ready_data, in->ready_data_len);
    if (write_len == in->ready_data_len) {
        in->ready_data_len = 0;
        in->ready_data = NULL;
    } else {
        close_connection(remote);
    }

    return;

}

// Assembly:
pushq %rbx
movq %rdi, %rbx
movl 0x38(%rdi), %edi
movq (%rbx), %rsi
movslq 0x14(%rbx), %rdx
callq 0x20e0
cmpl %eax, 0x14(%rbx)
jne 0x3788
andl $0x0, 0x14(%rbx)
andq $0x0, (%rbx)
popq %rbx
retq
addq $0x28, %rbx
movq %rbx, %rdi
popq %rbx
jmp 0x36c5
// File: /workspace/github_c_makefile_star2_O2/niuyuling[P]CProxy/http_proxy.c
// Function: serverToClient
static void serverToClient(conn_t * server)
{
    conn_t *client;
    int write_len;

    client = server - 1;
    while ((server->ready_data_len = read(server->fd, server->ready_data, BUFFER_SIZE)) > 0) {
        dataEncode(server->ready_data, server->ready_data_len, sslEncodeCode);
        write_len = write(client->fd, server->ready_data, server->ready_data_len);
        if (write_len <= 0) {
            if (write_len == 0 || errno != EAGAIN)
                close_connection(server);
            else
                server->sent_len = 0;
            return;
        } else if (write_len < server->ready_data_len) {
            server->sent_len = write_len;
            ev.events = EPOLLIN | EPOLLOUT | EPOLLET;
            ev.data.ptr = client;
            epoll_ctl(epollfd, EPOLL_CTL_MOD, client->fd, &ev);
            return;
        }
        if (server->ready_data_len < BUFFER_SIZE)
            break;
    }
    //判断是否关闭连接
    if (server->ready_data_len == 0 || (server->ready_data_len == -1 && errno != EAGAIN))
        close_connection(server);
    else
        server->ready_data_len = server->sent_len = 0;
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %rbx
leaq -0x28(%rdi), %r14
movl 0x10(%rbx), %edi
movq (%rbx), %rsi
movl $0x2000, %edx           # imm = 0x2000
callq 0x2240
movl %eax, 0x14(%rbx)
testl %eax, %eax
jle 0x3c98
movq (%rbx), %rdi
movl 0x159f7(%rip), %edx     # 0x19664
movl %eax, %esi
callq 0x365c
movl -0x18(%rbx), %edi
movq (%rbx), %rsi
movslq 0x14(%rbx), %rdx
callq 0x20e0
movq %rax, %rcx
testl %ecx, %ecx
jle 0x3cb5
movl 0x14(%rbx), %eax
cmpl %ecx, %eax
jg 0x3cdc
cmpl $0x1fff, %eax           # imm = 0x1FFF
jg 0x3c4d
testl %eax, %eax
je 0x3ccd
cmpl $-0x1, %eax
jne 0x3cab
callq 0x2050
cmpl $0xb, (%rax)
jne 0x3ccd
andl $0x0, 0x1c(%rbx)
andl $0x0, 0x14(%rbx)
jmp 0x3cc5
je 0x3ccd
callq 0x2050
cmpl $0xb, (%rax)
jne 0x3ccd
andl $0x0, 0x1c(%rbx)
addq $0x8, %rsp
popq %rbx
popq %r14
retq
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %r14
jmp 0x36c5
movl %ecx, 0x1c(%rbx)
leaq 0x126a6(%rip), %rcx     # 0x1638c
movl $0x80000005, (%rcx)     # imm = 0x80000005
movq %r14, 0x4(%rcx)
leaq 0x1268d(%rip), %rax     # 0x16384
movl (%rax), %edi
movl -0x18(%rbx), %edx
pushq $0x3
popq %rsi
addq $0x8, %rsp
popq %rbx
popq %r14
jmp 0x2220
// File: /workspace/github_c_makefile_star2_O2/niuyuling[P]CProxy/http_proxy.c
// Function: copy_data
static int8_t copy_data(conn_t * ct)
{
    dataEncode(ct->incomplete_data, ct->incomplete_data_len, sslEncodeCode);

    if (ct->ready_data) {
        char *new_data;

        new_data = (char *)realloc(ct->ready_data, ct->ready_data_len + ct->incomplete_data_len);
        if (new_data == NULL)
            return 1;
        ct->ready_data = new_data;
        memcpy(new_data + ct->ready_data_len, ct->incomplete_data, ct->incomplete_data_len);
        ct->ready_data_len += ct->incomplete_data_len;
        free(ct->incomplete_data);
    } else {
        ct->ready_data = ct->incomplete_data;
        ct->ready_data_len = ct->incomplete_data_len;
    }
    ct->incomplete_data = NULL;
    ct->incomplete_data_len = 0;

    return 0;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %rbx
movq 0x8(%rdi), %rdi
movl 0x18(%rbx), %esi
movl 0x15941(%rip), %edx     # 0x19664
callq 0x365c
movq (%rbx), %rdi
testq %rdi, %rdi
je 0x3d76
movslq 0x14(%rbx), %rax
movslq 0x18(%rbx), %rsi
addq %rax, %rsi
callq 0x23d0
testq %rax, %rax
je 0x3d90
movq %rax, (%rbx)
movslq 0x14(%rbx), %r12
addq %r12, %rax
movq 0x8(%rbx), %r14
movslq 0x18(%rbx), %r15
movq %rax, %rdi
movq %r14, %rsi
movq %r15, %rdx
callq 0x22e0
leal (%r15,%r12), %eax
movl %eax, 0x14(%rbx)
movq %r14, %rdi
callq 0x2030
jmp 0x3d83
movq 0x8(%rbx), %rax
movq %rax, (%rbx)
movl 0x18(%rbx), %eax
movl %eax, 0x14(%rbx)
andq $0x0, 0x8(%rbx)
andl $0x0, 0x18(%rbx)
xorl %eax, %eax
jmp 0x3d92
movb $0x1, %al
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O2/niuyuling[P]CProxy/http_proxy.c
// Function: tcp_out
void tcp_out(conn_t * to)
{
    conn_t *from;
    int write_len;

    if (to->fd == -1)
        return;
    else if ((to - cts) & 1)
        from = to - 1;
    else
        from = to + 1;
    from->timer = to->timer = 0;

    write_len = write(to->fd, from->ready_data + from->sent_len, from->ready_data_len - from->sent_len);
    if (write_len == from->ready_data_len - from->sent_len) {
        //服务端的数据可能没全部写入到客户端
        if ((from - cts) & 1) {
            serverToClient(from);
            if (from->fd >= 0 && from->ready_data_len == 0) {
                ev.events = EPOLLIN | EPOLLET;
                ev.data.ptr = to;
                epoll_ctl(epollfd, EPOLL_CTL_MOD, to->fd, &ev);
            }
        } else {
            ev.events = EPOLLIN | EPOLLET;
            ev.data.ptr = to;
            epoll_ctl(epollfd, EPOLL_CTL_MOD, to->fd, &ev);
            free(from->ready_data);
            from->ready_data = NULL;
            from->ready_data_len = 0;
        }
    } else if (write_len > 0) {
        from->sent_len += write_len;
        ev.events = EPOLLIN | EPOLLOUT | EPOLLET;
        ev.data.ptr = to;
        epoll_ctl(epollfd, EPOLL_CTL_MOD, to->fd, &ev);
    } else if (errno != EAGAIN) {
        close_connection(to);
    }
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movq %rdi, %rbx
movl 0x10(%rdi), %edi
cmpl $-0x1, %edi
je 0x3eae
movq %rbx, %rax
subq 0x8224(%rip), %rax      # 0xbfe0
pushq $0x28
popq %r15
cqto
idivq %r15
leaq -0x28(%rbx), %r14
leaq 0x28(%rbx), %rcx
testb $0x1, %al
cmoveq %rcx, %r14
andl $0x0, 0x20(%rbx)
andl $0x0, 0x20(%r14)
movslq 0x1c(%r14), %rax
movq (%r14), %rsi
addq %rax, %rsi
movslq 0x14(%r14), %rdx
subq %rax, %rdx
callq 0x20e0
movl 0x14(%r14), %edx
movl 0x1c(%r14), %ecx
subl %ecx, %edx
cmpl %eax, %edx
jne 0x3e4b
movq %r14, %rax
subq 0x81d6(%rip), %rax      # 0xbfe0
cqto
idivq %r15
testb $0x1, %al
jne 0x3e7f
leaq 0x12572(%rip), %rcx     # 0x1638c
movl $0x80000001, (%rcx)     # imm = 0x80000001
movq %rbx, 0x4(%rcx)
leaq 0x12559(%rip), %rax     # 0x16384
movl (%rax), %edi
movl 0x10(%rbx), %edx
pushq $0x3
popq %rsi
callq 0x2220
movq (%r14), %rdi
callq 0x2030
andq $0x0, (%r14)
andl $0x0, 0x14(%r14)
jmp 0x3eae
testl %eax, %eax
jle 0x3ea4
addl %eax, %ecx
movl %ecx, 0x1c(%r14)
leaq 0x12530(%rip), %rcx     # 0x1638c
movl $0x80000005, (%rcx)     # imm = 0x80000005
movq %rbx, 0x4(%rcx)
leaq 0x12517(%rip), %rax     # 0x16384
movl (%rax), %edi
movl 0x10(%rbx), %edx
pushq $0x3
popq %rsi
popq %rbx
popq %r14
popq %r15
jmp 0x2220
movq %r14, %rdi
callq 0x3c42
cmpl $0x0, 0x10(%r14)
js 0x3eae
cmpl $0x0, 0x14(%r14)
jne 0x3eae
leaq 0x124f0(%rip), %rcx     # 0x1638c
movl $0x80000001, (%rcx)     # imm = 0x80000001
jmp 0x3e62
callq 0x2050
cmpl $0xb, (%rax)
jne 0x3eb4
popq %rbx
popq %r14
popq %r15
retq
movq %rbx, %rdi
popq %rbx
popq %r14
popq %r15
jmp 0x36c5
nopl (%rax)
// File: /workspace/github_c_makefile_star2_O2/niuyuling[P]CProxy/http_request.c
// Function: copy_new_mem
int8_t copy_new_mem(char *src, int src_len, char **dest)
{
    *dest = (char *)malloc(src_len + 1);
    if (*dest == NULL)
        return 1;
    memcpy(*dest, src, src_len);
    *((*dest) + src_len) = '\0';

    return 0;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
movq %rdx, %r12
movl %esi, %r14d
movq %rdi, %rbx
leal 0x1(%r14), %eax
movslq %eax, %rdi
callq 0x2330
movq %rax, (%r12)
testq %rax, %rax
je 0x3f2b
movq %rax, %r15
movslq %r14d, %r14
movq %rax, %rdi
movq %rbx, %rsi
movq %r14, %rdx
callq 0x22e0
movb $0x0, (%r15,%r14)
xorl %eax, %eax
jmp 0x3f2d
movb $0x1, %al
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O2/niuyuling[P]CProxy/http_request.c
// Function: get_http_path
char *get_http_path(char *url, int url_len, char *path)
{
    char *_p0, *_p1;
    _p0 = _p1 = NULL;

    _p1 = strchr(url, '\0');

    if (url_len > 7) {
        if (url) {
            _p0 = strstr(url + 7, "/");
            if (_p0)
                return memcpy(path, _p0, _p1 - _p0);
            else
                return memcpy(path, "/", 1); // 如果没有资源路径就默认"/"
        }
    } else {
        return memcpy(path, "/", 1);
    }

    return NULL;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movq %rdx, %rbx
movl %esi, %ebp
movq %rdi, %r14
callq 0x2140
cmpl $0x8, %ebp
jl 0x45e2
testq %r14, %r14
je 0x45e7
movq %rax, %r15
leaq 0x7(%r14), %rdi
pushq $0x2f
popq %rsi
callq 0x2160
testq %rax, %rax
je 0x45e2
addq %r15, %r14
subq %rax, %r14
movq %rbx, %rdi
movq %rax, %rsi
movq %r14, %rdx
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x22e0
movb $0x2f, (%rbx)
jmp 0x45e9
xorl %ebx, %ebx
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/niuyuling[P]CProxy/http_request.c
// Function: get_http_host_port_len
void get_http_host_port_len(char *head, int *host_len, int *port_len)
{
    *host_len = 0;
    *port_len = 0;
    char *_p1 = strstr(head, "Host"); // 判断Host行
    if (_p1) {                  // 为真时
        char *_p2 = strstr(_p1, "\n");
        *host_len = (int)(_p2 - _p1);

        char host[*host_len + 1];
        memcpy(host, _p1, *host_len);
        host[*host_len] = '\0';

        char *_p3 = strrchr(host, ':');
        char *_p4 = strchr(host, '\0');
        if (_p3) {
            *port_len = _p4 - (_p3 + 1);
        } else {
            *port_len = *host_len;
        }
    } else {                    // 为假时
        char *_p1 = strstr(head, "host");
        if (_p1) {
            char *_p2 = strstr(_p1, "\n");
            *host_len = (int)(_p2 - _p1);

            char host[*host_len + 1];
            memcpy(host, _p1, *host_len);
            host[*host_len] = '\0';

            char *_p3 = strrchr(host, ':');
            char *_p4 = strchr(host, '\0');
            if (_p3) {
                *port_len = _p4 - (_p3 + 1);
            } else {
                *port_len = *host_len;
            }
        } else {                // 未找到时使用HTTP_HEAD_CACHE_SIZE大小
            *host_len = HTTP_HEAD_HOST_CACHE_SIZE;
            *port_len = HTTP_HEAD_HOST_CACHE_SIZE / 10;
        }
    }

    return;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdx, %rbx
movq %rsi, %r14
andl $0x0, (%rsi)
movq %rdi, %r12
andl $0x0, (%rdx)
leaq 0x4d60(%rip), %rsi      # 0x937b
callq 0x2540
testq %rax, %rax
jne 0x463d
leaq 0x4d54(%rip), %rsi      # 0x9380
movq %r12, %rdi
callq 0x2540
testq %rax, %rax
je 0x46c3
movq %rax, %r15
movq %rbx, -0x30(%rbp)
pushq $0xa
popq %rsi
movq %rax, %rdi
callq 0x2160
movq %rsp, %r13
subl %r15d, %eax
movl %eax, (%r14)
incl %eax
addq $0xf, %rax
andq $-0x10, %rax
movq %rsp, %r12
subq %rax, %r12
movq %r12, %rsp
movl (%r14), %ebx
movslq %ebx, %r14
movq %r12, %rdi
movq %r15, %rsi
movq %r14, %rdx
callq 0x22e0
movb $0x0, (%r14,%r12)
pushq $0x3a
popq %rsi
movq %r12, %rdi
callq 0x2190
testq %rax, %rax
je 0x46ab
movq %rax, %r14
movq %r12, %rdi
callq 0x2140
addl %r12d, %eax
notl %r14d
addl %eax, %r14d
movl %r14d, %ebx
movq -0x30(%rbp), %rax
movl %ebx, (%rax)
movq %r13, %rsp
leaq -0x28(%rbp), %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl $0x400, (%r14)          # imm = 0x400
movl $0x66, (%rbx)
jmp 0x46b4
// File: /workspace/github_c_makefile_star2_O2/niuyuling[P]CProxy/http_request.c
// Function: free_http_request
void free_http_request(struct http_request *http_request)
{
    if (http_request->method)
        free(http_request->method);
    if (http_request->U)
        free(http_request->U);
    if (http_request->version)
        free(http_request->version);
    if (http_request->host)
        free(http_request->host);
    if (http_request->port)
        free(http_request->port);
    if (http_request->H)
        free(http_request->H);
    if (http_request->url)
        free(http_request->url);
    if (http_request->uri)
        free(http_request->uri);
}

// Assembly:
pushq %rbx
movq %rdi, %rbx
movq (%rdi), %rdi
callq 0x2030
movq 0x8(%rbx), %rdi
callq 0x2030
movq 0x10(%rbx), %rdi
callq 0x2030
movq 0x18(%rbx), %rdi
callq 0x2030
movq 0x20(%rbx), %rdi
callq 0x2030
movq 0x28(%rbx), %rdi
callq 0x2030
movq 0x30(%rbx), %rdi
callq 0x2030
movq 0x38(%rbx), %rdi
popq %rbx
jmp 0x2030
// File: /workspace/github_c_makefile_star2_O2/niuyuling[P]CProxy/http_request.c
// Function: delete_head
static char *delete_head(char *head, int *head_len, const char *needle, int string)
{
    char *temp_stack;
    char *_p1, *_p2, *_p3;
    _p1 = _p2 = _p3 = NULL;
    int temp_stack_len;

    _p1 = strstr(head, needle); // _p1指向head字符串中的"needle"字符处(needle字符串的第一个字符)
    if (_p1 == NULL) {
        //perror("_p1 HEAD NULL");
        return head;
    }
    _p2 = strchr(_p1, string);  // _p2指向head字符串中"string"字符到末尾中的'\0'
    if (_p2 == NULL) {
        //perror("_p2 HEAD NULL");
        return head;
    }
    _p3 = strchr(_p1, '\0');    // _p3指向head字符串末尾的'\0'
    if (_p3 == NULL) {
        //perror("_p3 HEAD NULL");
        return head;
    }
    temp_stack_len = (_p1 - head) + (_p3 - _p2);
    temp_stack = (char *)alloca(temp_stack_len + 1); // 分配临时栈内存，长度是去除needle到string处
    if (temp_stack == NULL) {
        perror("alloca");
        return head;
    }
    memset(temp_stack, 0, temp_stack_len + 1);
    memmove(temp_stack, head, (_p1 - head) - 1);
    strncat(temp_stack, _p2, _p3 - _p2);

    memset(head, 0, *head_len);
    *head_len = temp_stack_len;
    return memmove(head, temp_stack, temp_stack_len);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rsi, %r14
movq %rdi, %rbx
movq %rdx, %rsi
callq 0x2540
testq %rax, %rax
je 0x520c
movq %rax, %r15
pushq $0xa
popq %rsi
movq %rax, %rdi
callq 0x2160
testq %rax, %rax
je 0x520c
movq %rax, %r12
movq %r15, %rdi
callq 0x2140
leaq (%rax,%r15), %r13
subq %rbx, %r15
subq %r12, %r13
leaq (%r15,%r13), %rax
movq %rax, -0x38(%rbp)
incl %eax
movslq %eax, %rdx
leaq 0xf(%rdx), %rax
andq $-0x10, %rax
movq %r14, -0x30(%rbp)
movq %rsp, %r14
subq %rax, %r14
movq %r14, %rsp
movq %r14, %rdi
xorl %esi, %esi
callq 0x21b0
decq %r15
movq %r14, %rdi
movq %rbx, %rsi
movq %r15, %rdx
callq 0x22e0
movq %r14, %rdi
movq %r12, %rsi
movq %r13, %rdx
callq 0x21d0
movq -0x30(%rbp), %r15
movslq (%r15), %rdx
movq %rbx, %rdi
xorl %esi, %esi
callq 0x21b0
movq -0x38(%rbp), %rax
movl %eax, (%r15)
movslq %eax, %rdx
movq %rbx, %rdi
movq %r14, %rsi
callq 0x22e0
movq %rbx, %rax
leaq -0x28(%rbp), %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/niuyuling[P]CProxy/http_request.c
// Function: splice_head
static char *splice_head(char *head, int *head_len, const char *needle, char *string, int string_len)
{
    char *tail_head;
    char *_p0;
    char *_p1;

    _p1 = strstr(head, needle);
    if (_p1 == NULL) {
        return head;
    }
    _p1 = _p1 + 1;
    _p0 = strchr(_p1, '\0');

    tail_head = (char *)alloca((_p0 - _p1) + 1);
    if (tail_head == NULL) {
        perror("alloca");
        return head;
    }
    memset(tail_head, 0, (_p0 - _p1) + 1);
    memcpy(tail_head, _p1, (_p0 - _p1));

    memset(head, 0, *head_len);
    memcpy(head, string, string_len);
    strncat(head, tail_head, (_p0 - _p1));
    *head_len = string_len + (_p0 - _p1);
    return head;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movl %ecx, %r13d
movq %rdx, %r15
movq %rsi, %r14
movq %rdi, %rbx
pushq $0xa
popq %rsi
callq 0x2160
testq %rax, %rax
je 0x52c2
movq %rax, %r12
incq %r12
movq %r12, %rdi
callq 0x2140
movl %r13d, -0x2c(%rbp)
movq %rax, %r13
leaq 0x1(%rax), %rdx
movq %r15, -0x38(%rbp)
movq %rsp, %r15
addq $0x10, %rax
andq $-0x10, %rax
subq %rax, %r15
movq %r15, %rsp
movq %r15, %rdi
xorl %esi, %esi
callq 0x21b0
movq %r15, %rdi
movq %r12, %rsi
movq %r13, %rdx
callq 0x22e0
movslq (%r14), %rdx
movq %rbx, %rdi
xorl %esi, %esi
callq 0x21b0
movslq -0x2c(%rbp), %r12
movq %rbx, %rdi
movq -0x38(%rbp), %rsi
movq %r12, %rdx
callq 0x22e0
movq %rbx, %rdi
movq %r15, %rsi
movq %r13, %rdx
callq 0x21d0
addl %r13d, %r12d
movl %r12d, (%r14)
movq %rbx, %rax
leaq -0x28(%rbp), %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/niuyuling[P]CProxy/http_request.c
// Function: conf_handle_strrep
static char *conf_handle_strrep(char *str, int *str_len, tcp * temp)
{
    tcp *p = temp;

    while (p) {
        if (p->strrep) {
            str = replace(str, str_len, p->strrep_s, p->strrep_s_len, p->strrep_t, p->strrep_t_len);
        }

        p = p->next;
    }

    return str;
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rdx, %rbx
movq %rsi, %r14
movq %rdi, %rax
testq %rbx, %rbx
je 0x530c
cmpq $0x0, (%rbx)
je 0x5306
movl 0x20(%rbx), %ecx
movq 0x10(%rbx), %rdx
movq 0x18(%rbx), %r8
movl 0x24(%rbx), %r9d
movq %rax, %rdi
movq %r14, %rsi
callq 0x3f39
movq 0x50(%rbx), %rbx
jmp 0x52e1
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O2/niuyuling[P]CProxy/httpdns.c
// Function: dns_timeout_check
void dns_timeout_check()
{
    int i;

    for (i = 0; i < DNS_MAX_CONCURRENT; i++) {
        if (dns_list[i].fd > -1) {
            if (dns_list[i].timer >= global.timeout_m) {
                dnsProxyStop(dns_list + i);
            } else {
                dns_list[i].timer++;
            }
        }
    }
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
xorl %ebx, %ebx
leaq 0x13f5e(%rip), %r14     # 0x196f0
leaq 0x13be7(%rip), %r15     # 0x19380
cmpq $0x48000, %rbx          # imm = 0x48000
je 0x57d9
cmpl $0x0, 0x22c(%rbx,%r14)
js 0x57d0
movl 0x230(%rbx,%r14), %eax
cmpl 0x14(%r15), %eax
jge 0x57c7
incl %eax
movl %eax, 0x230(%rbx,%r14)
jmp 0x57d0
leaq (%r14,%rbx), %rdi
callq 0x57df
addq $0x240, %rbx            # imm = 0x240
jmp 0x5799
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O2/niuyuling[P]CProxy/httpdns.c
// Function: dnsProxyStop
static void dnsProxyStop(dns_t * dns)
{
    epoll_ctl(dns_efd, EPOLL_CTL_DEL, dns->fd, NULL);
    close(dns->fd);
    if (httpdns.tcpDNS_mode == 0)
        free(dns->out_request);
    memset(((char *)dns) + DNS_REQUEST_MAX_SIZE + sizeof(struct sockaddr_in), 0, sizeof(dns_t) - DNS_REQUEST_MAX_SIZE + -sizeof(struct sockaddr_in));
    dns->fd = -1;
}

// Assembly:
pushq %rbx
movq %rdi, %rbx
movl 0x5bf07(%rip), %edi     # 0x616f0
movl 0x22c(%rbx), %edx
pushq $0x2
popq %rsi
xorl %ecx, %ecx
callq 0x2220
movl 0x22c(%rbx), %edi
callq 0x21e0
testb $0x1, 0x13ed5(%rip)     # 0x196e0
jne 0x5819
movq 0x218(%rbx), %rdi
callq 0x2030
xorps %xmm0, %xmm0
movups %xmm0, 0x222(%rbx)
movups %xmm0, 0x232(%rbx)
andw $0x0, 0x242(%rbx)
movups %xmm0, 0x212(%rbx)
orl $-0x1, 0x22c(%rbx)
popq %rbx
retq
// File: /workspace/github_c_makefile_star2_O2/niuyuling[P]CProxy/httpdns.c
// Function: write_dns_cache
static void write_dns_cache(int sig)
{
    //子进程先写入缓存
    if (child_pid) {
        wait(NULL);
        cfp = fopen(httpdns.cachePath, "a");
    } else {
        cfp = fopen(httpdns.cachePath, "w");
    }
    while (cache) {
        fwrite(cache->dns_cache, *(uint16_t *) cache->dns_cache + *(uint16_t *) (cache->dns_cache + *(uint16_t *) cache->dns_cache + 2) + 4, 1, cfp);
        cache = cache->next;
    }

    exit(0);
}

// Assembly:
pushq %rbx
cmpl $0x0, 0x13ad2(%rip)     # 0x19678
jne 0x5bb1
leaq 0x3832(%rip), %rsi      # 0x93e1
jmp 0x5bbf
xorl %edi, %edi
callq 0x2510
leaq 0x3984(%rip), %rsi      # 0x9543
movq 0x13aea(%rip), %rdi     # 0x196b0
callq 0x2450
movq %rax, 0x13a9e(%rip)     # 0x19670
movq 0x13b0f(%rip), %rax     # 0x196e8
pushq $0x1
popq %rbx
testq %rax, %rax
je 0x5c17
movq (%rax), %rdi
movzwl (%rdi), %eax
movzwl 0x2(%rdi,%rax), %ecx
leaq (%rax,%rcx), %rsi
addq $0x4, %rsi
movq 0x13a75(%rip), %rcx     # 0x19670
movq %rbx, %rdx
callq 0x24d0
movq 0x13ade(%rip), %rax     # 0x196e8
movq 0x8(%rax), %rax
movq %rax, 0x13ad3(%rip)     # 0x196e8
jmp 0x5bdc
xorl %edi, %edi
callq 0x24b0
// File: /workspace/github_c_makefile_star2_O2/niuyuling[P]CProxy/httpdns.c
// Function: cache_record
static void cache_record(char *request, uint16_t request_len, char *response, uint16_t response_len)
{
    struct dns_cache *cache_temp;

    cache_temp = (struct dns_cache *)malloc(sizeof(struct dns_cache));
    if (cache_temp == NULL)
        return;
    cache_temp->dns_cache = (char *)malloc(request_len + response_len + 2);
    if (cache_temp->dns_cache == NULL) {
        free(cache_temp);
        return;
    }
    cache_temp->next = cache;
    cache = cache_temp;
    //不缓存dnsid
    request += 2;
    request_len -= 2;
    memcpy(cache_temp->dns_cache, &request_len, 2);
    memcpy(cache_temp->dns_cache + 2, request, request_len);
    memcpy(cache_temp->dns_cache + request_len + 2, &response_len, 2);
    memcpy(cache_temp->dns_cache + request_len + 4, response, response_len);
    if (httpdns.cacheLimit) {
        //到达缓存记录条目限制则释放前一半缓存
        if (cache_using >= httpdns.cacheLimit) {
            struct dns_cache *free_c;
            int i;
            for (i = cache_using = httpdns.cacheLimit >> 1; i--; cache_temp = cache_temp->next) ;
            for (free_c = cache_temp->next, cache_temp->next = NULL; free_c; free_c = cache_temp) {
                cache_temp = free_c->next;
                free(free_c->dns_cache);
                free(free_c);
            }
        }
        cache_using++;
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl %ecx, %ebp
movq %rdx, %r14
movl %esi, %r12d
movq %rdi, %r15
pushq $0x10
popq %rdi
callq 0x2330
testq %rax, %rax
je 0x66b9
movq %rax, %rbx
movq %r14, (%rsp)
movzwl %r12w, %eax
movzwl %bp, %r13d
leaq (%rax,%r13), %rdi
addq $0x2, %rdi
callq 0x2330
movq %rax, (%rbx)
testq %rax, %rax
je 0x666e
movq %rax, %r14
movq 0x130e5(%rip), %rax     # 0x196e8
movq %rax, 0x8(%rbx)
movq %rbx, 0x130da(%rip)     # 0x196e8
addq $0x2, %r15
addl $-0x2, %r12d
movw %r12w, (%r14)
leaq 0x2(%r14), %rdi
movzwl %r12w, %r12d
movq %r15, %rsi
movq %r12, %rdx
callq 0x22e0
movw %bp, 0x2(%r14,%r12)
leaq (%r14,%r12), %rdi
addq $0x4, %rdi
movq (%rsp), %rsi
movq %r13, %rdx
callq 0x22e0
movl 0x13083(%rip), %eax     # 0x196d0
testl %eax, %eax
je 0x66b9
movl 0x13025(%rip), %ecx     # 0x1967c
cmpl %eax, %ecx
jl 0x66b1
sarl %eax
movl %eax, 0x13019(%rip)     # 0x1967c
subl $0x1, %eax
jb 0x6684
movq 0x8(%rbx), %rbx
jmp 0x6663
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x2030
movq 0x8(%rbx), %r14
andq $0x0, 0x8(%rbx)
testq %r14, %r14
je 0x66ab
movq (%r14), %rdi
movq 0x8(%r14), %rbx
callq 0x2030
movq %r14, %rdi
callq 0x2030
movq %rbx, %r14
jmp 0x668d
movl 0x12fcb(%rip), %ecx     # 0x1967c
incl %ecx
movl %ecx, 0x12fc3(%rip)     # 0x1967c
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/niuyuling[P]CProxy/httpudp.c
// Function: udp_timeout_check
void udp_timeout_check()
{
    int i;

    for (i = 0; i < MAX_CLIENT_INFO; i++) {
        if (client_info_list[i].server_fd > -1) {
            if (client_info_list[i].timer >= global.timeout_m)
                proxyStop(client_info_list + i);
            else
                client_info_list[i].timer = 0;
        }
    }
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
xorl %ebx, %ebx
leaq 0x5d26a(%rip), %r14     # 0x63940
leaq 0x12ca3(%rip), %r15     # 0x19380
cmpq $0x200d000, %rbx        # imm = 0x200D000
je 0x671c
cmpl $0x0, 0x1005c(%rbx,%r14)
js 0x6713
movl 0x10064(%rbx,%r14), %eax
cmpl 0x14(%r15), %eax
jge 0x670a
andl $0x0, 0x10064(%rbx,%r14)
jmp 0x6713
leaq (%r14,%rbx), %rdi
callq 0x6722
addq $0x10068, %rbx          # imm = 0x10068
jmp 0x66dd
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O2/niuyuling[P]CProxy/httpudp.c
// Function: proxyStop
static void proxyStop(info_t * info)
{
    epoll_ctl(udp_efd, EPOLL_CTL_DEL, info->server_fd, NULL);
    epoll_ctl(udp_efd, EPOLL_CTL_DEL, info->responseClientFd, NULL);
    close(info->server_fd);
    close(info->responseClientFd);
    free(info->rsp_data);
    info->rsp_data = NULL;
    do {
        info->server_fd = info->responseClientFd = -1;
        info->rsp_data_len = info->rsp_data_sent_len = info->client_data_sent_len = info->http_request_sent_len = 0;
    } while ((info = info->next) != NULL);
}

// Assembly:
pushq %rbp
pushq %rbx
pushq %rax
movq %rdi, %rbx
movl 0x206a212(%rip), %edi   # 0x2070940
movl 0x1005c(%rbx), %edx
pushq $0x2
popq %rbp
movl %ebp, %esi
xorl %ecx, %ecx
callq 0x2220
movl 0x206a1fa(%rip), %edi   # 0x2070940
movl 0x10060(%rbx), %edx
movl %ebp, %esi
xorl %ecx, %ecx
callq 0x2220
movl 0x1005c(%rbx), %edi
callq 0x21e0
movl 0x10060(%rbx), %edi
callq 0x21e0
movq 0x10040(%rbx), %rdi
callq 0x2030
andq $0x0, 0x10040(%rbx)
xorps %xmm0, %xmm0
orq $-0x1, 0x1005c(%rbx)
movups %xmm0, 0x1004c(%rbx)
movq 0x10038(%rbx), %rbx
testq %rbx, %rbx
jne 0x6782
addq $0x8, %rsp
popq %rbx
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/niuyuling[P]CProxy/conf.c
// Function: print_tcp
void print_tcp(tcp * p)
{
    tcp *temp = p;
    while (temp) {
        if (temp->strrep)
            printf("%s %d\n", temp->strrep, temp->strrep_len);
        if (temp->strrep_s)
            printf("%s %d\n", temp->strrep_s, temp->strrep_s_len);
        if (temp->strrep_t)
            printf("%s %d\n", temp->strrep_t, temp->strrep_t_len);

        if (temp->regrep)
            printf("%s %d\n", temp->regrep, temp->regrep_len);
        if (temp->regrep_s)
            printf("%s %d\n", temp->regrep_s, temp->regrep_s_len);
        if (temp->regrep_t)
            printf("%s %d\n", temp->regrep_t, temp->regrep_t_len);

        temp = temp->next;
    }
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %rbx
leaq 0x20b6(%rip), %r14      # 0x9454
testq %rbx, %rbx
je 0x7433
movq (%rbx), %rsi
testq %rsi, %rsi
je 0x73bc
movl 0x8(%rbx), %edx
movq %r14, %rdi
xorl %eax, %eax
callq 0x2170
movq 0x10(%rbx), %rsi
testq %rsi, %rsi
je 0x73d2
movl 0x20(%rbx), %edx
movq %r14, %rdi
xorl %eax, %eax
callq 0x2170
movq 0x18(%rbx), %rsi
testq %rsi, %rsi
je 0x73e8
movl 0x24(%rbx), %edx
movq %r14, %rdi
xorl %eax, %eax
callq 0x2170
movq 0x28(%rbx), %rsi
testq %rsi, %rsi
je 0x73fe
movl 0x30(%rbx), %edx
movq %r14, %rdi
xorl %eax, %eax
callq 0x2170
movq 0x38(%rbx), %rsi
testq %rsi, %rsi
je 0x7414
movl 0x48(%rbx), %edx
movq %r14, %rdi
xorl %eax, %eax
callq 0x2170
movq 0x40(%rbx), %rsi
testq %rsi, %rsi
je 0x742a
movl 0x4c(%rbx), %edx
movq %r14, %rdi
xorl %eax, %eax
callq 0x2170
movq 0x50(%rbx), %rbx
jmp 0x739e
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O2/niuyuling[P]CProxy/conf.c
// Function: local_reverse
tcp *local_reverse(tcp * head)
{
    tcp *beg = NULL;
    tcp *end = NULL;
    if (head == NULL || head->next == NULL) {
        return head;
    }
    beg = head;
    end = head->next;
    while (end != NULL) {
        //将 end 从链表中摘除
        beg->next = end->next;
        //将 end 移动至链表头
        end->next = head;
        head = end;
        //调整 end 的指向，另其指向 beg 后的一个节点，为反转下一个节点做准备
        end = beg->next;
    }
    return head;
}

// Assembly:
testq %rdi, %rdi
je 0x746d
movq %rdi, %rax
movq 0x50(%rdi), %rcx
testq %rcx, %rcx
je 0x746c
movq %rax, %rdx
testq %rcx, %rcx
je 0x7469
movq 0x50(%rcx), %rsi
movq %rsi, 0x50(%rax)
movq %rdx, 0x50(%rcx)
movq %rcx, %rdx
movq 0x50(%rax), %rcx
jmp 0x744f
movq %rdx, %rax
retq
xorl %eax, %eax
retq
// File: /workspace/github_c_makefile_star2_O2/niuyuling[P]CProxy/conf.c
// Function: free_tcp
void free_tcp(tcp ** conf_head)
{
    tcp *t;
    while (*conf_head != NULL) {
        t = *conf_head;
        *conf_head = t->next;

        if (t->strrep)
            free(t->strrep);
        if (t->strrep_s)
            free(t->strrep_s);
        if (t->strrep_t)
            free(t->strrep_t);

        if (t->regrep)
            free(t->regrep);
        if (t->regrep_s)
            free(t->regrep_s);
        if (t->regrep_t)
            free(t->regrep_t);
        if (t)
            free(t);
    }
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %rbx
movq (%rbx), %r14
testq %r14, %r14
je 0x74c5
movq 0x50(%r14), %rax
movq %rax, (%rbx)
movq (%r14), %rdi
callq 0x2030
movq 0x10(%r14), %rdi
callq 0x2030
movq 0x18(%r14), %rdi
callq 0x2030
movq 0x28(%r14), %rdi
callq 0x2030
movq 0x38(%r14), %rdi
callq 0x2030
movq 0x40(%r14), %rdi
callq 0x2030
movq %r14, %rdi
callq 0x2030
jmp 0x7477
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O2/niuyuling[P]CProxy/conf.c
// Function: read_module
static char *read_module(char *buff, const char *module_name)
{
    int len;
    char *p, *p0;

    len = strlen(module_name);
    p = buff;
    while (1) {
        while (*p == ' ' || *p == '\t' || *p == '\r' || *p == '\n')
            p++;
        if (strncasecmp(p, module_name, len) == 0) {
            p += len;
            while (*p == ' ' || *p == '\t' || *p == '\r' || *p == '\n')
                p++;
            if (*p == '{')
                break;
        }
        if ((p = strchr(p, '\n')) == NULL)
            return NULL;
    }
    if ((p0 = strchr(++p, '}')) == NULL)
        return NULL;

    return strndup(p, p0 - p);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rsi, %r14
movq %rdi, %rbx
movq %rsi, %rdi
callq 0x2140
movslq %eax, %r15
leaq 0x1(%r15), %r12
movabsq $0x100002600, %r13      # imm = 0x100002600
pushq $0xa
popq %rbp
movzbl (%rbx), %eax
cmpq $0x20, %rax
ja 0x8087
btq %rax, %r13
jae 0x8087
incq %rbx
jmp 0x8073
movq %rbx, %rdi
movq %r14, %rsi
movq %r15, %rdx
callq 0x2340
testl %eax, %eax
jne 0x80c0
movl %ebp, %ecx
leaq (%r12,%rbx), %rbp
addq %r15, %rbx
movzbl (%rbx), %eax
cmpq $0x20, %rax
ja 0x80b9
btq %rax, %r13
jae 0x80b9
incq %rbx
incq %rbp
jmp 0x80a2
cmpl $0x7b, %eax
je 0x80d4
movl %ecx, %ebp
movq %rbx, %rdi
movl %ebp, %esi
callq 0x2160
movq %rax, %rbx
testq %rax, %rax
jne 0x8073
jmp 0x8103
incq %rbx
pushq $0x7d
popq %rsi
movq %rbx, %rdi
callq 0x2160
testq %rax, %rax
je 0x8103
subq %rbp, %rax
movq %rbx, %rdi
movq %rax, %rsi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x2250
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/ebiggers[P]mysh/mysh_builtin.c
// Function: maybe_execute_builtin
bool maybe_execute_builtin(const struct list_head *cmd_args,
			   const struct list_head *redirs,
			   unsigned cmd_nargs, int *status_ret)
{
	const char *name;
	size_t i;

	mysh_assert(!list_empty(cmd_args));
	mysh_assert(cmd_nargs == list_size(cmd_args));
	name = list_entry(cmd_args->next, struct string, list)->chars;
	for (i = 0; i < NUM_BUILTINS; i++) {
		if (strcmp(builtins[i].name, name) == 0) {
			/* The command matched a builtin.  Execute it. */
			*status_ret = execute_builtin(&builtins[i],
						      cmd_args->next,
						      redirs, cmd_nargs - 1);
			return true;
		}
	}
	/* Not a builtin command */
	return false;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq (%rdi), %r15
cmpq %rdi, %r15
je 0x255d
movl %edx, %ebp
movl %edx, %eax
incq %rax
movq %rdi, %rdx
movq (%rdx), %rdx
decq %rax
cmpq %rdi, %rdx
jne 0x24e9
movq %rcx, (%rsp)
testq %rax, %rax
jne 0x257c
movq %rsi, %r14
movq -0x18(%r15), %r13
leaq 0x82ed(%rip), %r12      # 0xa7f8
xorl %ecx, %ecx
movq %rcx, %rbx
cmpq $0x11, %rcx
je 0x2547
movq 0x18(%r12), %rdi
addq $0x18, %r12
movq %r13, %rsi
callq 0x2230
leaq 0x1(%rbx), %rcx
testl %eax, %eax
jne 0x250d
decl %ebp
movq %r12, %rdi
movq %r15, %rsi
movq %r14, %rdx
movl %ebp, %ecx
callq 0x259b
movq (%rsp), %rcx
movl %eax, (%rcx)
cmpq $0x11, %rbx
setb %al
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x4aa0(%rip), %rdi      # 0x7004
leaq 0x4aaf(%rip), %rsi      # 0x701a
leaq 0x4ab7(%rip), %rcx      # 0x7029
movl $0x1da, %edx            # imm = 0x1DA
callq 0x2160
leaq 0x4b0b(%rip), %rdi      # 0x708e
leaq 0x4a90(%rip), %rsi      # 0x701a
leaq 0x4a98(%rip), %rcx      # 0x7029
movl $0x1db, %edx            # imm = 0x1DB
callq 0x2160