// File: /workspace/github_c_makefile_star2_O1/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 0x13ade(%rip), %ebx     # 0x19672
rolw $0x8, %bx
movl 0x13ad6(%rip), %edi     # 0x19674
callq 0x2100
movzwl %bx, %ecx
leaq 0x383e(%rip), %rsi      # 0x93eb
movq %rsp, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0x2490
cmpl $0x0, 0x13aef(%rip)     # 0x196b0
jle 0x5e1d
movq 0x13ab2(%rip), %rbx     # 0x19680
movq %rbx, %rdi
callq 0x2140
leal 0x2(%rax), %ecx
movl %ecx, 0x13ad1(%rip)     # 0x196b0
addl $0x3, %eax
movslq %eax, %rsi
movq %rbx, %rdi
callq 0x23c0
movq %rax, 0x13a8c(%rip)     # 0x19680
testq %rax, %rax
jne 0x5c05
leaq 0x34eb(%rip), %rdi      # 0x90eb
callq 0x2090
movq 0x13a74(%rip), %rbx     # 0x19680
movq %rbx, %rdi
callq 0x2140
movw $0xa0d, (%rbx,%rax)     # imm = 0xA0D
movb $0x0, 0x2(%rbx,%rax)
movq 0x13a5a(%rip), %rdi     # 0x19680
leaq 0x13a83(%rip), %rbx     # 0x196b0
leaq 0x377e(%rip), %rdx      # 0x93b2
leaq 0x37b6(%rip), %r8       # 0x93f1
movq %rbx, %rsi
movl $0x3, %ecx
movl $0x8, %r9d
callq 0x40cf
movq %rax, %r14
movq %rax, 0x13a28(%rip)     # 0x19680
movq %rsp, %r15
movq %r15, %rdi
callq 0x2140
leaq 0x3764(%rip), %rdx      # 0x93ce
movq %r14, %rdi
movq %rbx, %rsi
movl $0x3, %ecx
movq %r15, %r8
movl %eax, %r9d
callq 0x40cf
movq %rax, 0x139f9(%rip)     # 0x19680
leaq 0x376c(%rip), %rdx      # 0x93fa
leaq 0x3772(%rip), %r8       # 0x9407
movq %rax, %rdi
movq %rbx, %rsi
movl $0x2, %ecx
movl $0x1, %r9d
callq 0x40cf
movq %rax, 0x139ce(%rip)     # 0x19680
testb $0x1, 0x13a17(%rip)     # 0x196d0
jne 0x5d60
leaq 0x139ea(%rip), %rbx     # 0x196b0
leaq 0x36d4(%rip), %rdx      # 0x93a1
leaq 0x362c(%rip), %r8       # 0x9300
movq %rax, %rdi
movq %rbx, %rsi
movl $0x3, %ecx
movl $0x3, %r9d
callq 0x40cf
movq %rax, 0x1398f(%rip)     # 0x19680
leaq 0x36e2(%rip), %rdx      # 0x93da
leaq 0x36fe(%rip), %r14      # 0x93fd
movq %rax, %rdi
movq %rbx, %rsi
movl $0x5, %ecx
movq %r14, %r8
movl $0x9, %r9d
callq 0x40cf
movq %rax, 0x13961(%rip)     # 0x19680
leaq 0x3688(%rip), %rdx      # 0x93ae
movq %rax, %rdi
movq %rbx, %rsi
movl $0x3, %ecx
movq %r14, %r8
movl $0x9, %r9d
callq 0x40cf
movq %rax, 0x1393a(%rip)     # 0x19680
testq %rax, %rax
jne 0x5e1d
leaq 0x3395(%rip), %rdi      # 0x90eb
callq 0x2090
jmp 0x5e1d
leaq 0x13949(%rip), %rbx     # 0x196b0
leaq 0x3633(%rip), %rdx      # 0x93a1
leaq 0x3594(%rip), %r8       # 0x9309
movq %rax, %rdi
movq %rbx, %rsi
movl $0x3, %ecx
movl $0x7, %r9d
callq 0x40cf
movq %rax, 0x138ee(%rip)     # 0x19680
leaq 0x3641(%rip), %rdx      # 0x93da
leaq 0x35fd(%rip), %r14      # 0x939d
movq %rax, %rdi
movq %rbx, %rsi
movl $0x5, %ecx
movq %r14, %r8
movl $0x1, %r9d
callq 0x40cf
movq %rax, 0x138c0(%rip)     # 0x19680
leaq 0x35e7(%rip), %rdx      # 0x93ae
movq %rax, %rdi
movq %rbx, %rsi
movl $0x3, %ecx
movq %r14, %r8
movl $0x1, %r9d
callq 0x40cf
movq %rax, 0x13899(%rip)     # 0x19680
testq %rax, %rax
jne 0x5df8
leaq 0x32f8(%rip), %rdi      # 0x90eb
callq 0x2090
movq 0x13881(%rip), %rax     # 0x19680
movq %rax, 0x1388a(%rip)     # 0x19690
movl 0x138a4(%rip), %eax     # 0x196b0
movl %eax, 0x138a6(%rip)     # 0x196b8
movq $0x0, 0x13863(%rip) # 0x19680
movl $0x201, %edi            # imm = 0x201
callq 0x2480
movl %eax, 0x5b8b3(%rip)     # 0x616e0
testl %eax, %eax
js 0x5ef6
leaq 0x13534(%rip), %rbx     # 0x19370
movl 0x4(%rbx), %edi
movl $0x4, %esi
movl $0x800, %edx            # imm = 0x800
xorl %eax, %eax
callq 0x20d0
movl 0x4(%rbx), %edx
movl %edx, 0x5b88f(%rip)     # 0x616e8
leaq 0x5b884(%rip), %rcx     # 0x616e4
movl $0x1, 0x5b87a(%rip)     # 0x616e4
movl 0x5b870(%rip), %edi     # 0x616e0
movl $0x1, %esi
callq 0x2220
leaq 0x1385f(%rip), %rdi     # 0x196e0
movl $0x48000, %edx          # imm = 0x48000
xorl %esi, %esi
callq 0x21b0
cmpq $0x0, 0x137cb(%rip)     # 0x19660
je 0x5eec
leaq 0x5d(%rip), %rbx        # 0x5efb
movl $0xf, %edi
movq %rbx, %rsi
callq 0x2290
movl $0x1, %edi
movq %rbx, %rsi
callq 0x2290
movl $0x2, %edi
movq %rbx, %rsi
callq 0x2290
movl $0x6, %edi
movq %rbx, %rsi
callq 0x2290
movl $0x4, %edi
movq %rbx, %rsi
callq 0x2290
movl $0xb, %edi
movq %rbx, %rsi
callq 0x2290
addq $0x20, %rsp
popq %rbx
popq %r14
popq %r15
retq
callq 0x2693