// File: /workspace/github_c_makefile_star2_O3/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 %r15
pushq %r14
pushq %rbx
subq $0x20, %rsp
movzwl 0x13b83(%rip), %ebx     # 0x19682
rolw $0x8, %bx
movl 0x13b7b(%rip), %edi     # 0x19684
callq 0x2100
movzwl %bx, %ecx
leaq 0x38cb(%rip), %rsi      # 0x93e3
movq %rsp, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0x24a0
cmpl $0x0, 0x13b94(%rip)     # 0x196c0
jle 0x5d8b
movq 0x13b57(%rip), %rbx     # 0x19690
movq %rbx, %rdi
callq 0x2140
leal 0x2(%rax), %ecx
movl %ecx, 0x13b76(%rip)     # 0x196c0
addl $0x3, %eax
movslq %eax, %rsi
movq %rbx, %rdi
callq 0x23d0
movq %rax, %rbx
movq %rax, 0x13b2e(%rip)     # 0x19690
testq %rax, %rax
jne 0x5b7a
leaq 0x357a(%rip), %rdi      # 0x90e8
callq 0x2090
movq 0x13b16(%rip), %rbx     # 0x19690
movq %rbx, %rdi
callq 0x2140
movw $0xa0d, (%rbx,%rax)     # imm = 0xA0D
movb $0x0, 0x2(%rbx,%rax)
movq 0x13afc(%rip), %rdi     # 0x19690
leaq 0x13b25(%rip), %rbx     # 0x196c0
leaq 0x3808(%rip), %rdx      # 0x93aa
leaq 0x3840(%rip), %r8       # 0x93e9
movq %rbx, %rsi
movl $0x3, %ecx
movl $0x8, %r9d
callq 0x40c3
movq %rax, %r14
movq %rax, 0x13aca(%rip)     # 0x19690
movq %rsp, %r15
movq %r15, %rdi
callq 0x2140
leaq 0x37ee(%rip), %rdx      # 0x93c6
movq %r14, %rdi
movq %rbx, %rsi
movl $0x3, %ecx
movq %r15, %r8
movl %eax, %r9d
callq 0x40c3
movq %rax, 0x13a9b(%rip)     # 0x19690
leaq 0x37f6(%rip), %rdx      # 0x93f2
leaq 0x3800(%rip), %r8       # 0x9403
movq %rax, %rdi
movq %rbx, %rsi
movl $0x2, %ecx
movl $0x1, %r9d
callq 0x40c3
movq %rax, 0x13a70(%rip)     # 0x19690
testb $0x1, 0x13ab9(%rip)     # 0x196e0
jne 0x5cce
leaq 0x13a8c(%rip), %rbx     # 0x196c0
leaq 0x375e(%rip), %rdx      # 0x9399
leaq 0x37b3(%rip), %r8       # 0x93f5
movq %rax, %rdi
movq %rbx, %rsi
movl $0x3, %ecx
movl $0x3, %r9d
callq 0x40c3
movq %rax, 0x13a31(%rip)     # 0x19690
leaq 0x376c(%rip), %rdx      # 0x93d2
leaq 0x378c(%rip), %r14      # 0x93f9
movq %rax, %rdi
movq %rbx, %rsi
movl $0x5, %ecx
movq %r14, %r8
movl $0x9, %r9d
callq 0x40c3
movq %rax, 0x13a03(%rip)     # 0x19690
leaq 0x3712(%rip), %rdx      # 0x93a6
movq %rax, %rdi
movq %rbx, %rsi
movl $0x3, %ecx
movq %r14, %r8
movl $0x9, %r9d
callq 0x40c3
movq %rax, 0x139dc(%rip)     # 0x19690
testq %rax, %rax
jne 0x5d8b
leaq 0x3424(%rip), %rdi      # 0x90e8
callq 0x2090
jmp 0x5d8b
leaq 0x139eb(%rip), %rbx     # 0x196c0
leaq 0x36bd(%rip), %rdx      # 0x9399
leaq 0x3622(%rip), %r8       # 0x9305
movq %rax, %rdi
movq %rbx, %rsi
movl $0x3, %ecx
movl $0x7, %r9d
callq 0x40c3
movq %rax, 0x13990(%rip)     # 0x19690
leaq 0x36cb(%rip), %rdx      # 0x93d2
leaq 0x3687(%rip), %r14      # 0x9395
movq %rax, %rdi
movq %rbx, %rsi
movl $0x5, %ecx
movq %r14, %r8
movl $0x1, %r9d
callq 0x40c3
movq %rax, 0x13962(%rip)     # 0x19690
leaq 0x3671(%rip), %rdx      # 0x93a6
movq %rax, %rdi
movq %rbx, %rsi
movl $0x3, %ecx
movq %r14, %r8
movl $0x1, %r9d
callq 0x40c3
movq %rax, 0x1393b(%rip)     # 0x19690
testq %rax, %rax
jne 0x5d6d
leaq 0x3387(%rip), %rdi      # 0x90e8
callq 0x2090
movq 0x13923(%rip), %rax     # 0x19690
movq %rax, 0x1392c(%rip)     # 0x196a0
movl 0x13946(%rip), %eax     # 0x196c0
movl %eax, 0x13948(%rip)     # 0x196c8
movq $0x0, 0x13905(%rip) # 0x19690
movl $0x201, %edi            # imm = 0x201
callq 0x2490
movl %eax, 0x5b955(%rip)     # 0x616f0
testl %eax, %eax
js 0x5e64
leaq 0x135d6(%rip), %rbx     # 0x19380
movl 0x4(%rbx), %edi
movl $0x4, %esi
movl $0x800, %edx            # imm = 0x800
xorl %eax, %eax
callq 0x20d0
movl 0x4(%rbx), %edx
movl %edx, 0x5b931(%rip)     # 0x616f8
leaq 0x5b926(%rip), %rcx     # 0x616f4
movl $0x1, 0x5b91c(%rip)     # 0x616f4
movl 0x5b912(%rip), %edi     # 0x616f0
movl $0x1, %esi
callq 0x2220
leaq 0x13901(%rip), %rdi     # 0x196f0
movl $0x48000, %edx          # imm = 0x48000
xorl %esi, %esi
callq 0x21b0
cmpq $0x0, 0x1386d(%rip)     # 0x19670
je 0x5e5a
leaq 0x5d(%rip), %rbx        # 0x5e69
movl $0xf, %edi
movq %rbx, %rsi
callq 0x22a0
movl $0x1, %edi
movq %rbx, %rsi
callq 0x22a0
movl $0x2, %edi
movq %rbx, %rsi
callq 0x22a0
movl $0x6, %edi
movq %rbx, %rsi
callq 0x22a0
movl $0x4, %edi
movq %rbx, %rsi
callq 0x22a0
movl $0xb, %edi
movq %rbx, %rsi
callq 0x22a0
addq $0x20, %rsp
popq %rbx
popq %r14
popq %r15
retq
callq 0x26a3