// File: /workspace/github_c_makefile_star2_O2/niuyuling[P]CProxy/httpdns.c
// Function: dns_init
static void httpRequest_init()
{
    char dest[22];
    uint16_t port;

    port = ntohs(httpdns.dst.sin_port);
    sprintf(dest, "%s:%u", inet_ntoa(httpdns.dst.sin_addr), port);

    //如果设置http_req = "";则不创建请求头
    if (httpdns.http_req_len > 0) {
        httpdns.http_req_len = strlen(httpdns.http_req);
        httpdns.http_req_len += 2;
        httpdns.http_req = (char *)realloc(httpdns.http_req, httpdns.http_req_len + 1);
        if (httpdns.http_req == NULL)
            printf("out of memory.\n");
        strcat(httpdns.http_req, "\r\n");
        httpdns.http_req = replace(httpdns.http_req, &httpdns.http_req_len, "[V]", 3, "HTTP/1.1", 8);
        httpdns.http_req = replace(httpdns.http_req, &httpdns.http_req_len, "[H]", 3, dest, strlen(dest));
        httpdns.http_req = replace(httpdns.http_req, &httpdns.http_req_len, "\\0", 2, "\0", 1);
        if (httpdns.tcpDNS_mode == 0) {
            httpdns.http_req = replace(httpdns.http_req, &httpdns.http_req_len, "[M]", 3, "GET", 3);
            httpdns.http_req = replace(httpdns.http_req, &httpdns.http_req_len, "[url]", 5, "/d?dn=[D]", 9);
            httpdns.http_req = replace(httpdns.http_req, &httpdns.http_req_len, "[U]", 3, "/d?dn=[D]", 9);
            if (httpdns.http_req == NULL)
                printf("out of memory.\n");
        } else {
            httpdns.http_req = replace(httpdns.http_req, &httpdns.http_req_len, "[M]", 3, "CONNECT", 7);
            httpdns.http_req = replace(httpdns.http_req, &httpdns.http_req_len, "[url]", 5, "/", 1);
            httpdns.http_req = replace(httpdns.http_req, &httpdns.http_req_len, "[U]", 3, "/", 1);
            if (httpdns.http_req == NULL)
                printf("out of memory.\n");
            httpdns.connect_request = httpdns.http_req;
            httpdns.connect_request_len = httpdns.http_req_len;
            httpdns.http_req = NULL;
        }
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
subq $0x18, %rsp
movzwl 0x13e2f(%rip), %ebx     # 0x19682
rolw $0x8, %bx
movl 0x13e27(%rip), %edi     # 0x19684
callq 0x2100
movzwl %bx, %ecx
leaq 0x3b77(%rip), %rsi      # 0x93e3
movq %rsp, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0x24a0
cmpl $0x0, 0x13e40(%rip)     # 0x196c0
jle 0x5ac0
movq 0x13e03(%rip), %rbx     # 0x19690
movq %rbx, %rdi
callq 0x2140
leal 0x2(%rax), %ecx
movl %ecx, 0x13e22(%rip)     # 0x196c0
addl $0x3, %eax
movslq %eax, %rsi
movq %rbx, %rdi
callq 0x23d0
movq %rax, %rbx
movq %rax, 0x13dda(%rip)     # 0x19690
testq %rax, %rax
jne 0x58ce
leaq 0x3826(%rip), %rdi      # 0x90e8
callq 0x2090
movq 0x13dc2(%rip), %rbx     # 0x19690
movq %rbx, %rdi
callq 0x2140
movw $0xa0d, (%rbx,%rax)     # imm = 0xA0D
movb $0x0, 0x2(%rbx,%rax)
movq 0x13da8(%rip), %rdi     # 0x19690
leaq 0x13dd1(%rip), %rbx     # 0x196c0
leaq 0x3ab4(%rip), %rdx      # 0x93aa
leaq 0x3aec(%rip), %r8       # 0x93e9
pushq $0x3
popq %rbp
pushq $0x8
popq %r9
movq %rbx, %rsi
movl %ebp, %ecx
callq 0x3f39
movq %rax, %r14
movq %rax, 0x13d78(%rip)     # 0x19690
movq %rsp, %r15
movq %r15, %rdi
callq 0x2140
leaq 0x3a9c(%rip), %rdx      # 0x93c6
movq %r14, %rdi
movq %rbx, %rsi
movl %ebp, %ecx
movq %r15, %r8
movl %eax, %r9d
callq 0x3f39
movq %rax, 0x13d4c(%rip)     # 0x19690
leaq 0x3aa7(%rip), %rdx      # 0x93f2
leaq 0x3ab1(%rip), %r8       # 0x9403
pushq $0x2
popq %rcx
pushq $0x1
popq %r9
movq %rax, %rdi
movq %rbx, %rsi
callq 0x3f39
movq %rax, 0x13d25(%rip)     # 0x19690
testb $0x1, 0x13d6e(%rip)     # 0x196e0
jne 0x5a0f
leaq 0x13d41(%rip), %rbx     # 0x196c0
leaq 0x3a13(%rip), %rdx      # 0x9399
leaq 0x3a68(%rip), %r8       # 0x93f5
pushq $0x3
popq %rbp
movq %rax, %rdi
movq %rbx, %rsi
movl %ebp, %ecx
movl %ebp, %r9d
callq 0x3f39
movq %rax, 0x13ce9(%rip)     # 0x19690
leaq 0x3a24(%rip), %rdx      # 0x93d2
leaq 0x3a44(%rip), %r14      # 0x93f9
pushq $0x5
popq %rcx
pushq $0x9
popq %r15
movq %rax, %rdi
movq %rbx, %rsi
movq %r14, %r8
movl %r15d, %r9d
callq 0x3f39
movq %rax, 0x13cbc(%rip)     # 0x19690
leaq 0x39cb(%rip), %rdx      # 0x93a6
movq %rax, %rdi
movq %rbx, %rsi
movl %ebp, %ecx
movq %r14, %r8
movl %r15d, %r9d
callq 0x3f39
movq %rax, 0x13c9b(%rip)     # 0x19690
testq %rax, %rax
jne 0x5ac0
leaq 0x36e3(%rip), %rdi      # 0x90e8
callq 0x2090
jmp 0x5ac0
leaq 0x13caa(%rip), %rbx     # 0x196c0
leaq 0x397c(%rip), %rdx      # 0x9399
leaq 0x38e1(%rip), %r8       # 0x9305
pushq $0x3
popq %rbp
pushq $0x7
popq %r9
movq %rax, %rdi
movq %rbx, %rsi
movl %ebp, %ecx
callq 0x3f39
movq %rax, 0x13c51(%rip)     # 0x19690
leaq 0x398c(%rip), %rdx      # 0x93d2
leaq 0x3948(%rip), %r14      # 0x9395
pushq $0x5
popq %rcx
pushq $0x1
popq %r15
movq %rax, %rdi
movq %rbx, %rsi
movq %r14, %r8
movl %r15d, %r9d
callq 0x3f39
movq %rax, 0x13c24(%rip)     # 0x19690
leaq 0x3933(%rip), %rdx      # 0x93a6
movq %rax, %rdi
movq %rbx, %rsi
movl %ebp, %ecx
movq %r14, %r8
movl %r15d, %r9d
callq 0x3f39
movq %rax, 0x13c03(%rip)     # 0x19690
testq %rax, %rax
jne 0x5aa5
leaq 0x364f(%rip), %rdi      # 0x90e8
callq 0x2090
movq 0x13beb(%rip), %rax     # 0x19690
movq %rax, 0x13bf4(%rip)     # 0x196a0
movl 0x13c0e(%rip), %eax     # 0x196c0
movl %eax, 0x13c10(%rip)     # 0x196c8
andq $0x0, 0x13bd0(%rip)     # 0x19690
movl $0x201, %edi            # imm = 0x201
callq 0x2490
movl %eax, 0x5bc20(%rip)     # 0x616f0
testl %eax, %eax
js 0x5b8a
leaq 0x138a1(%rip), %rbx     # 0x19380
movl 0x4(%rbx), %edi
pushq $0x4
popq %rsi
movl $0x800, %edx            # imm = 0x800
xorl %eax, %eax
callq 0x20d0
movl 0x4(%rbx), %edx
movl %edx, 0x5bbfe(%rip)     # 0x616f8
leaq 0x5bbf3(%rip), %rcx     # 0x616f4
movl $0x1, 0x5bbe9(%rip)     # 0x616f4
movl 0x5bbdf(%rip), %edi     # 0x616f0
pushq $0x1
popq %rsi
callq 0x2220
leaq 0x13bd0(%rip), %rdi     # 0x196f0
movl $0x48000, %edx          # imm = 0x48000
xorl %esi, %esi
callq 0x21b0
cmpq $0x0, 0x13b3c(%rip)     # 0x19670
je 0x5b7f
leaq 0x61(%rip), %rbx        # 0x5b9e
pushq $0xf
popq %rdi
movq %rbx, %rsi
callq 0x22a0
pushq $0x1
popq %rdi
movq %rbx, %rsi
callq 0x22a0
pushq $0x2
popq %rdi
movq %rbx, %rsi
callq 0x22a0
pushq $0x6
popq %rdi
movq %rbx, %rsi
callq 0x22a0
pushq $0x4
popq %rdi
movq %rbx, %rsi
callq 0x22a0
pushq $0xb
popq %rdi
movq %rbx, %rsi
callq 0x22a0
addq $0x18, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
leaq 0x3600(%rip), %rdi      # 0x9191
callq 0x2460
pushq $0x1
popq %rdi
callq 0x24b0