// File: /workspace/github_c_makefile_star2_O0/niuyuling[P]CProxy/http_request.c
// Function: get_http_host_port_len
void get_http_host_port_len(char *head, int *host_len, int *port_len)
{
    *host_len = 0;
    *port_len = 0;
    char *_p1 = strstr(head, "Host"); // 判断Host行
    if (_p1) {                  // 为真时
        char *_p2 = strstr(_p1, "\n");
        *host_len = (int)(_p2 - _p1);

        char host[*host_len + 1];
        memcpy(host, _p1, *host_len);
        host[*host_len] = '\0';

        char *_p3 = strrchr(host, ':');
        char *_p4 = strchr(host, '\0');
        if (_p3) {
            *port_len = _p4 - (_p3 + 1);
        } else {
            *port_len = *host_len;
        }
    } else {                    // 为假时
        char *_p1 = strstr(head, "host");
        if (_p1) {
            char *_p2 = strstr(_p1, "\n");
            *host_len = (int)(_p2 - _p1);

            char host[*host_len + 1];
            memcpy(host, _p1, *host_len);
            host[*host_len] = '\0';

            char *_p3 = strrchr(host, ':');
            char *_p4 = strchr(host, '\0');
            if (_p3) {
                *port_len = _p4 - (_p3 + 1);
            } else {
                *port_len = *host_len;
            }
        } else {                // 未找到时使用HTTP_HEAD_CACHE_SIZE大小
            *host_len = HTTP_HEAD_HOST_CACHE_SIZE;
            *port_len = HTTP_HEAD_HOST_CACHE_SIZE / 10;
        }
    }

    return;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x90, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq -0x10(%rbp), %rax
movl $0x0, (%rax)
movq -0x18(%rbp), %rax
movl $0x0, (%rax)
movq -0x8(%rbp), %rdi
leaq 0x6b82(%rip), %rsi      # 0xc428
callq 0x2570
movq %rax, -0x20(%rbp)
cmpq $0x0, -0x20(%rbp)
je 0x597b
movq -0x20(%rbp), %rdi
leaq 0x6b4d(%rip), %rsi      # 0xc412
callq 0x2570
movq %rax, -0x28(%rbp)
movl -0x28(%rbp), %ecx
movl -0x20(%rbp), %eax
subl %eax, %ecx
movq -0x10(%rbp), %rax
movl %ecx, (%rax)
movq -0x10(%rbp), %rax
movl (%rax), %eax
incl %eax
movq %rsp, %rcx
movq %rcx, -0x30(%rbp)
movq %rax, %rcx
addq $0xf, %rcx
andq $-0x10, %rcx
movq %rsp, %rdi
subq %rcx, %rdi
movq %rdi, -0x80(%rbp)
movq %rdi, %rsp
movq %rax, -0x38(%rbp)
movq -0x20(%rbp), %rsi
movq -0x10(%rbp), %rax
movslq (%rax), %rdx
callq 0x2300
movq -0x80(%rbp), %rdi
movq -0x10(%rbp), %rax
movslq (%rax), %rax
movb $0x0, (%rdi,%rax)
movl $0x3a, %esi
callq 0x21a0
movq -0x80(%rbp), %rdi
movq %rax, -0x40(%rbp)
xorl %esi, %esi
callq 0x2170
movq %rax, -0x48(%rbp)
cmpq $0x0, -0x40(%rbp)
je 0x5963
movq -0x48(%rbp), %rax
movq -0x40(%rbp), %rcx
addq $0x1, %rcx
subq %rcx, %rax
movl %eax, %ecx
movq -0x18(%rbp), %rax
movl %ecx, (%rax)
jmp 0x596f
movq -0x10(%rbp), %rax
movl (%rax), %ecx
movq -0x18(%rbp), %rax
movl %ecx, (%rax)
movq -0x30(%rbp), %rax
movq %rax, %rsp
jmp 0x5a77
movq -0x8(%rbp), %rdi
leaq 0x6aa7(%rip), %rsi      # 0xc42d
callq 0x2570
movq %rax, -0x50(%rbp)
cmpq $0x0, -0x50(%rbp)
je 0x5a61
movq -0x50(%rbp), %rdi
leaq 0x6a6d(%rip), %rsi      # 0xc412
callq 0x2570
movq %rax, -0x58(%rbp)
movl -0x58(%rbp), %ecx
movl -0x50(%rbp), %eax
subl %eax, %ecx
movq -0x10(%rbp), %rax
movl %ecx, (%rax)
movq -0x10(%rbp), %rax
movl (%rax), %eax
incl %eax
movq %rsp, %rcx
movq %rcx, -0x60(%rbp)
movq %rax, %rcx
addq $0xf, %rcx
andq $-0x10, %rcx
movq %rsp, %rdi
subq %rcx, %rdi
movq %rdi, -0x88(%rbp)
movq %rdi, %rsp
movq %rax, -0x68(%rbp)
movq -0x50(%rbp), %rsi
movq -0x10(%rbp), %rax
movslq (%rax), %rdx
callq 0x2300
movq -0x88(%rbp), %rdi
movq -0x10(%rbp), %rax
movslq (%rax), %rax
movb $0x0, (%rdi,%rax)
movl $0x3a, %esi
callq 0x21a0
movq -0x88(%rbp), %rdi
movq %rax, -0x70(%rbp)
xorl %esi, %esi
callq 0x2170
movq %rax, -0x78(%rbp)
cmpq $0x0, -0x70(%rbp)
je 0x5a4c
movq -0x78(%rbp), %rax
movq -0x70(%rbp), %rcx
addq $0x1, %rcx
subq %rcx, %rax
movl %eax, %ecx
movq -0x18(%rbp), %rax
movl %ecx, (%rax)
jmp 0x5a58
movq -0x10(%rbp), %rax
movl (%rax), %ecx
movq -0x18(%rbp), %rax
movl %ecx, (%rax)
movq -0x60(%rbp), %rax
movq %rax, %rsp
jmp 0x5a75
movq -0x10(%rbp), %rax
movl $0x400, (%rax)          # imm = 0x400
movq -0x18(%rbp), %rax
movl $0x66, (%rax)
jmp 0x5a77
movq %rbp, %rsp
popq %rbp
retq
nopl (%rax)