// File: /workspace/github_c_makefile_star2_O0/niuyuling[P]CProxy/httpudp.c
// Function: sendToServer
static int sendToServer(info_t * out)
{
    info_t *send_info;
    int len;

    out->timer = 0;
    /* 发送http请求头到服务器 */
    if (udp.http_request_len > out->http_request_sent_len) {
        len = write(out->server_fd, udp.http_request + out->http_request_sent_len, udp.http_request_len - out->http_request_sent_len);
        if (len <= 0) {
            if (len == 0 || errno != EAGAIN)
                return 1;
            return 0;
        }
        if (len > 0) {
            out->http_request_sent_len += len;
            if (udp.http_request_len == out->http_request_sent_len) {
                udp_ev.data.ptr = out;
                udp_ev.events = EPOLLIN | EPOLLET;
                epoll_ctl(udp_efd, EPOLL_CTL_MOD, out->server_fd, &udp_ev);
            }
        }
        return 0;
    }

    /* 发送UDP目标地址,UDP数据长度和UDP真实数据到服务器 */
    for (send_info = out; send_info; send_info = send_info->next) {
        if (send_info->client_data_len == send_info->client_data_sent_len)
            continue;

        len = write(out->server_fd, send_info->client_data + send_info->client_data_sent_len, send_info->client_data_len - send_info->client_data_sent_len);
        //printf("server_fd: %d, write_len: %d, udp_len: %d, sent_le: %d\n", out->server_fd, len, send_info->client_data_len - send_info->client_data_sent_len, send_info->client_data_sent_len);
        if (len <= 0) {
            if (len == 0 || errno != EAGAIN)
                return 1;
            break;
        }
        send_info->client_data_sent_len += len;
        if (send_info->client_data_sent_len < send_info->client_data_len)
            break;
        if (send_info != out) {
            //此结构体已用完
            send_info->server_fd = -1;
            send_info->client_data_sent_len = 0;
        }
    }
    if (send_info == NULL) {
        udp_ev.data.ptr = out;
        udp_ev.events = EPOLLIN | EPOLLET;
        epoll_ctl(udp_efd, EPOLL_CTL_MOD, out->server_fd, &udp_ev);
    }
    out->next = send_info;

    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x10(%rbp)
movq -0x10(%rbp), %rax
movl $0x0, 0x10064(%rax)
movl 0x206ca48(%rip), %eax   # 0x20769d8
movq -0x10(%rbp), %rcx
cmpl 0x10050(%rcx), %eax
jle 0xa077
movq -0x10(%rbp), %rax
movl 0x1005c(%rax), %edi
movq 0x206ca17(%rip), %rsi   # 0x20769c8
movq -0x10(%rbp), %rax
movslq 0x10050(%rax), %rax
addq %rax, %rsi
movl 0x206ca13(%rip), %eax   # 0x20769d8
movq -0x10(%rbp), %rcx
subl 0x10050(%rcx), %eax
movslq %eax, %rdx
callq 0x20d0
movl %eax, -0x1c(%rbp)
cmpl $0x0, -0x1c(%rbp)
jg 0xa008
cmpl $0x0, -0x1c(%rbp)
je 0x9ff0
callq 0x2050
cmpl $0xb, (%rax)
je 0x9ffc
movl $0x1, -0x4(%rbp)
jmp 0xa1be
movl $0x0, -0x4(%rbp)
jmp 0xa1be
cmpl $0x0, -0x1c(%rbp)
jle 0xa06b
movl -0x1c(%rbp), %ecx
movq -0x10(%rbp), %rax
addl 0x10050(%rax), %ecx
movl %ecx, 0x10050(%rax)
movl 0x206c9b1(%rip), %eax   # 0x20769d8
movq -0x10(%rbp), %rcx
cmpl 0x10050(%rcx), %eax
jne 0xa069
movq -0x10(%rbp), %rax
movq %rax, 0x206995a(%rip)   # 0x2073998
movl $0x80000001, 0x206994c(%rip) # imm = 0x80000001
movl 0x2069942(%rip), %edi   # 0x2073990
movq -0x10(%rbp), %rax
movl 0x1005c(%rax), %edx
movl $0x3, %esi
leaq 0x2069930(%rip), %rcx   # 0x2073994
callq 0x2240
jmp 0xa06b
movl $0x0, -0x4(%rbp)
jmp 0xa1be
movq -0x10(%rbp), %rax
movq %rax, -0x18(%rbp)
cmpq $0x0, -0x18(%rbp)
je 0xa16b
movq -0x18(%rbp), %rax
movl 0x10048(%rax), %eax
movq -0x18(%rbp), %rcx
cmpl 0x1004c(%rcx), %eax
jne 0xa0a5
jmp 0xa157
movq -0x10(%rbp), %rax
movl 0x1005c(%rax), %edi
movq -0x18(%rbp), %rsi
movq -0x18(%rbp), %rax
movslq 0x1004c(%rax), %rax
addq %rax, %rsi
movq -0x18(%rbp), %rax
movl 0x10048(%rax), %eax
movq -0x18(%rbp), %rcx
subl 0x1004c(%rcx), %eax
movslq %eax, %rdx
callq 0x20d0
movl %eax, -0x1c(%rbp)
cmpl $0x0, -0x1c(%rbp)
jg 0xa104
cmpl $0x0, -0x1c(%rbp)
je 0xa0f6
callq 0x2050
cmpl $0xb, (%rax)
je 0xa102
movl $0x1, -0x4(%rbp)
jmp 0xa1be
jmp 0xa16b
movl -0x1c(%rbp), %ecx
movq -0x18(%rbp), %rax
addl 0x1004c(%rax), %ecx
movl %ecx, 0x1004c(%rax)
movq -0x18(%rbp), %rax
movl 0x1004c(%rax), %eax
movq -0x18(%rbp), %rcx
cmpl 0x10048(%rcx), %eax
jge 0xa12f
jmp 0xa16b
movq -0x18(%rbp), %rax
cmpq -0x10(%rbp), %rax
je 0xa155
movq -0x18(%rbp), %rax
movl $0xffffffff, 0x1005c(%rax) # imm = 0xFFFFFFFF
movq -0x18(%rbp), %rax
movl $0x0, 0x1004c(%rax)
jmp 0xa157
movq -0x18(%rbp), %rax
movq 0x10038(%rax), %rax
movq %rax, -0x18(%rbp)
jmp 0xa07f
cmpq $0x0, -0x18(%rbp)
jne 0xa1a8
movq -0x10(%rbp), %rax
movq %rax, 0x206981b(%rip)   # 0x2073998
movl $0x80000001, 0x206980d(%rip) # imm = 0x80000001
movl 0x2069803(%rip), %edi   # 0x2073990
movq -0x10(%rbp), %rax
movl 0x1005c(%rax), %edx
movl $0x3, %esi
leaq 0x20697f1(%rip), %rcx   # 0x2073994
callq 0x2240
movq -0x18(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x10038(%rax)
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x20, %rsp
popq %rbp
retq
nopw (%rax,%rax)