// File: /workspace/github_c_makefile_star2_O3/bloomsource[P]dns_update/dns.c
// Function: dns_resove_query
int dns_resove_query( char* data, int len, char* domain, int* query_type, int* query_class, int* query_len )
{
    char* pdata;
    unsigned char *blen;
    int namelen= 0;
    int seclen;
    int left;
    char *pname;
    unsigned short shortlen;
    
    domain[0] = 0;
    pdata = data;
    pname = domain;
    left = len;
    
    if( left < 3+ 4 )
    {
        write_log( "[WRN] query length not enough." );
        return 1;
    }
    
    while( 1 )
    {
        blen = (unsigned char*)pdata;
        seclen = *blen;
        if( seclen == 0 )
        {
            if( namelen == 0 )
            {
                write_log( "[WRN] domain length is 0" );
                return 1;
            }
            
            if( domain[namelen-1] == '.' )
            {
                domain[namelen-1] = 0;
                namelen--;
            }
            pdata++;
            left --;
            break;
        }
        
        namelen += ( seclen + 1 );
        if( namelen > 255 )
        {
            write_log( "[WRN] domain name over length." );
            return 1;
        }
        
        if( seclen + 1 > left )
        {
            write_log( "[WRN] domain name not enough length." );
            return 1;
        }
        
        if( check_domain_char( pdata+1, seclen ) )
        {
            write_log( "[WRN] invalid domain char." );
            return 1;
        }
        
        memcpy( pname, pdata+1, seclen );
        pname[ seclen ] = '.';
        pname += ( seclen + 1 );
        left -= ( seclen+1 );
        pdata += ( seclen + 1 );
    }
    
    if( namelen == 0 )
    {
        write_log( "[WRN] domain name length is zero." );
    }
    
    if( left < sizeof(short)* 2 )
    {
        write_log( "[WRN] query length is not enough." );
        return 1;
    }
    
    memcpy( &shortlen, pdata, 2 );
    shortlen = ntohs( shortlen );
    *query_type = shortlen;
    
    memcpy( &shortlen, pdata+2, 2 );
    shortlen = ntohs( shortlen );
    *query_class = shortlen;
    
    left -= 4;
    
    *query_len = len - left;
    
    return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movb $0x0, (%rdx)
cmpl $0x7, %esi
jge 0x2e7f
leaq 0x6405(%rip), %rdi      # 0x927f
jmp 0x2f64
movq %rdi, %r13
movb (%rdi), %dil
testb %dil, %dil
je 0x2f42
movq %rcx, 0x10(%rsp)
movq %r8, 0x18(%rsp)
movq %r9, 0x20(%rsp)
xorl %r8d, %r8d
movq %rdx, 0x28(%rsp)
movq %rdx, %r12
movl %esi, 0xc(%rsp)
movl %esi, %ebp
movzbl %dil, %r14d
movl %r8d, %eax
leaq (%r14,%rax), %rbx
incq %rbx
cmpl $0x100, %ebx            # imm = 0x100
jae 0x2f4b
cmpl %r14d, %ebp
jle 0x2f54
leaq 0x1(%r13), %r15
movq %r15, %rdi
movl %r14d, %esi
callq 0x30ab
testl %eax, %eax
jne 0x2f5d
movq %rbx, 0x30(%rsp)
leaq 0x1(%r14), %rbx
movl %r14d, %r14d
movq %r12, %rdi
movq %r15, %rsi
movq %r14, %rdx
callq 0x21e0
movb $0x2e, (%r12,%r14)
addq %rbx, %r12
subl %ebx, %ebp
leaq (%rbx,%r13), %rax
movb (%r13,%rbx), %dil
movq 0x30(%rsp), %r8
movq %rax, %r13
testb %dil, %dil
jne 0x2eae
movq 0x28(%rsp), %rcx
cmpb $0x2e, -0x1(%rcx,%r8)
jne 0x2f31
movb $0x0, -0x1(%rcx,%r8)
leal -0x1(%rbp), %ecx
cmpl $0x3, %ecx
ja 0x2f7f
leaq 0x63d6(%rip), %rdi      # 0x9316
jmp 0x2f64
leaq 0x6355(%rip), %rdi      # 0x929e
jmp 0x2f64
leaq 0x6365(%rip), %rdi      # 0x92b7
jmp 0x2f64
leaq 0x637b(%rip), %rdi      # 0x92d6
jmp 0x2f64
leaq 0x6397(%rip), %rdi      # 0x92fb
xorl %eax, %eax
callq 0x32b8
movl $0x1, %eax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movzwl 0x1(%rax), %ecx
rolw $0x8, %cx
movzwl %cx, %ecx
movq 0x10(%rsp), %rdx
movl %ecx, (%rdx)
movzwl 0x3(%rax), %eax
rolw $0x8, %ax
movzwl %ax, %eax
movq 0x18(%rsp), %rcx
movl %eax, (%rcx)
movl 0xc(%rsp), %ecx
subl %ebp, %ecx
addl $0x5, %ecx
movq 0x20(%rsp), %rax
movl %ecx, (%rax)
xorl %eax, %eax
jmp 0x2f70