// File: /workspace/github_c_makefile_star2_O2/niuyuling[P]CProxy/httpudp.c
// Function: udp_init
static void http_udp_req_init()
{
    char dest[22];

    sprintf(dest, "%s:%u", inet_ntoa(udp.dst.sin_addr), ntohs(udp.dst.sin_port));
    if (udp.http_request) {
        udp.http_request_len = strlen(udp.http_request) + 2;
        udp.http_request = (char *)realloc(udp.http_request, udp.http_request_len + 1);
        if (udp.http_request == NULL)
            errors("httpudp http request initializate failed.");
        strcat(udp.http_request, "\r\n");
        udp.http_request = replace(udp.http_request, &udp.http_request_len, "[V]", 3, "HTTP/1.1", 8);
        udp.http_request = replace(udp.http_request, &udp.http_request_len, "[H]", 3, dest, strlen(dest));
        udp.http_request = replace(udp.http_request, &udp.http_request_len, "\\0", 2, "\0", 1);
        udp.http_request = replace(udp.http_request, &udp.http_request_len, "[M]", 3, "CONNECT", 7);
        udp.http_request = replace(udp.http_request, &udp.http_request_len, "[url]", 5, "/", 1);
        udp.http_request = replace(udp.http_request, &udp.http_request_len, "[U]", 3, "/", 1);
    } else {                    /* 默认使用CONNECT请求 */
        if (https.encodeCode) {
            dataEncode(dest, strlen(dest), https.encodeCode);
            udp.httpsProxy_encodeCode = https.encodeCode;
        }
        udp.http_request_len = default_ssl_request_len;
        copy_new_mem(default_ssl_request, default_ssl_request_len, &udp.http_request);
        udp.http_request = replace(udp.http_request, &udp.http_request_len, "[H]", 3, dest, strlen(dest));
        memcpy(&udp.dst, &https.dst, sizeof(udp.dst));
    }
    if (udp.http_request == NULL)
        errors("out of memory.");
    /* 保存原始生成的请求头，配合usr_hdr使用 */
    if (saveHdrs) {
        if (copy_new_mem(udp.http_request, udp.http_request_len, &udp.original_http_request) != 0)
            errors("out of memory.");
        udp.original_http_request_len = udp.http_request_len;
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x20, %rsp
movl 0x206d1b6(%rip), %edi   # 0x207396c
callq 0x2100
movzwl 0x206d1a8(%rip), %ecx   # 0x207396a
rolw $0x8, %cx
movzwl %cx, %ecx
leaq 0x2c13(%rip), %rsi      # 0x93e3
movq %rsp, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0x24a0
movq 0x206d194(%rip), %rbx   # 0x2073978
testq %rbx, %rbx
je 0x6943
movq %rbx, %rdi
callq 0x2140
leal 0x2(%rax), %ecx
movl %ecx, 0x206d18a(%rip)   # 0x2073988
addl $0x3, %eax
movslq %eax, %rsi
movq %rbx, %rdi
callq 0x23d0
movq %rax, %rbx
movq %rax, 0x206d162(%rip)   # 0x2073978
testq %rax, %rax
jne 0x682e
leaq 0x2bf6(%rip), %rdi      # 0x9418
callq 0x3ec4
movq 0x206d14a(%rip), %rbx   # 0x2073978
movq %rbx, %rdi
callq 0x2140
movw $0xa0d, (%rbx,%rax)     # imm = 0xA0D
movb $0x0, 0x2(%rbx,%rax)
movq 0x206d130(%rip), %rdi   # 0x2073978
leaq 0x206d139(%rip), %rbx   # 0x2073988
leaq 0x2b54(%rip), %rdx      # 0x93aa
leaq 0x2b8c(%rip), %r8       # 0x93e9
pushq $0x3
popq %rbp
pushq $0x8
popq %r9
movq %rbx, %rsi
movl %ebp, %ecx
callq 0x3f39
movq %rax, %r14
movq %rax, 0x206d100(%rip)   # 0x2073978
movq %rsp, %r15
movq %r15, %rdi
callq 0x2140
leaq 0x2b3c(%rip), %rdx      # 0x93c6
movq %r14, %rdi
movq %rbx, %rsi
movl %ebp, %ecx
movq %r15, %r8
movl %eax, %r9d
callq 0x3f39
movq %rax, 0x206d0d4(%rip)   # 0x2073978
leaq 0x2b47(%rip), %rdx      # 0x93f2
leaq 0x2ba0(%rip), %r8       # 0x9452
pushq $0x2
popq %rcx
pushq $0x1
popq %r14
movq %rax, %rdi
movq %rbx, %rsi
movl %r14d, %r9d
callq 0x3f39
movq %rax, 0x206d0aa(%rip)   # 0x2073978
leaq 0x2ac4(%rip), %rdx      # 0x9399
leaq 0x2a29(%rip), %r8       # 0x9305
pushq $0x7
popq %r9
movq %rax, %rdi
movq %rbx, %rsi
movl %ebp, %ecx
callq 0x3f39
movq %rax, 0x206d084(%rip)   # 0x2073978
leaq 0x2ad7(%rip), %rdx      # 0x93d2
leaq 0x2a93(%rip), %r15      # 0x9395
pushq $0x5
popq %rcx
movq %rax, %rdi
movq %rbx, %rsi
movq %r15, %r8
movl %r14d, %r9d
callq 0x3f39
movq %rax, 0x206d05b(%rip)   # 0x2073978
leaq 0x2a82(%rip), %rdx      # 0x93a6
movq %rax, %rdi
movq %rbx, %rsi
movl %ebp, %ecx
movq %r15, %r8
movl %r14d, %r9d
callq 0x3f39
movq %rax, 0x206d03a(%rip)   # 0x2073978
jmp 0x69e1
leaq 0x12a56(%rip), %r12     # 0x193a0
movl 0x18(%r12), %ebx
testl %ebx, %ebx
je 0x6975
movq %rsp, %r14
movq %r14, %rdi
callq 0x2140
movq %r14, %rdi
movl %eax, %esi
movl %ebx, %edx
callq 0x365c
movl 0x18(%r12), %eax
movl %eax, 0x206d01f(%rip)   # 0x2073994
leaq 0x12bb4(%rip), %rax     # 0x19530
movl (%rax), %esi
movl %esi, 0x206d004(%rip)   # 0x2073988
leaq 0x206cffd(%rip), %rbx   # 0x2073988
leaq 0x12b96(%rip), %rax     # 0x19528
movq (%rax), %rdi
leaq 0x206cfdc(%rip), %rdx   # 0x2073978
callq 0x3ee8
movq 0x206cfd0(%rip), %r14   # 0x2073978
movq %rsp, %r15
movq %r15, %rdi
callq 0x2140
leaq 0x2a0c(%rip), %rdx      # 0x93c6
pushq $0x3
popq %rcx
movq %r14, %rdi
movq %rbx, %rsi
movq %r15, %r8
movl %eax, %r9d
callq 0x3f39
movq %rax, 0x206cfa3(%rip)   # 0x2073978
movups (%r12), %xmm0
movups %xmm0, 0x206cf87(%rip)  # 0x2073968
testq %rax, %rax
jne 0x69f2
leaq 0x26fb(%rip), %rdi      # 0x90e8
callq 0x3ec4
leaq 0x129c7(%rip), %rax     # 0x193c0
cmpq $0x0, (%rax)
je 0x6a34
movq 0x206cf72(%rip), %rdi   # 0x2073978
movl 0x206cf7c(%rip), %esi   # 0x2073988
leaq 0x206cf6d(%rip), %rdx   # 0x2073980
callq 0x3ee8
testb %al, %al
je 0x6a28
leaq 0x26c5(%rip), %rdi      # 0x90e8
callq 0x3ec4
movl 0x206cf5a(%rip), %eax   # 0x2073988
movl %eax, 0x206cf58(%rip)   # 0x207398c
leaq 0x5cf05(%rip), %rbx     # 0x63940
movl $0x200d000, %edx        # imm = 0x200D000
movq %rbx, %rdi
xorl %esi, %esi
callq 0x21b0
movl $0x10060, %eax          # imm = 0x10060
cmpq $0x201d060, %rax        # imm = 0x201D060
je 0x6a65
orq $-0x1, -0x4(%rax,%rbx)
addq $0x10068, %rax          # imm = 0x10068
jmp 0x6a4f
movl $0x401, %edi            # imm = 0x401
callq 0x2490
movl %eax, 0x2069ecb(%rip)   # 0x2070940
testl %eax, %eax
js 0x6ac7
leaq 0x12900(%rip), %rbx     # 0x19380
movl 0x8(%rbx), %edi
pushq $0x4
popq %rsi
movl $0x800, %edx            # imm = 0x800
xorl %eax, %eax
callq 0x20d0
movl 0x8(%rbx), %edx
movl %edx, 0x2069ead(%rip)   # 0x2070948
leaq 0x2069ea2(%rip), %rcx   # 0x2070944
movl $0x1, 0x2069e98(%rip)   # 0x2070944
movl 0x2069e8e(%rip), %edi   # 0x2070940
pushq $0x1
popq %rsi
callq 0x2220
addq $0x20, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
leaq 0x2937(%rip), %rdi      # 0x9405
callq 0x2460
pushq $0x1
popq %rdi
callq 0x24b0