// File: /workspace/github_cpp_makefile_star2_O1/sjtuwrk[P]SunwayMR/include/Utils.hpp
// Function: getLocalHost[abi:cxx11]()
string getLocalHost() {
	string ret = "";

    struct ifaddrs * ifAddrStruct=NULL;
    struct ifaddrs * ifa=NULL;
    void * tmpAddrPtr=NULL;

    getifaddrs(&ifAddrStruct);

    for (ifa = ifAddrStruct; ifa != NULL; ifa = ifa->ifa_next) {
        if (!ifa->ifa_addr) {
            continue;
        }
        if (ifa->ifa_addr->sa_family == AF_INET) { // check it is IP4
            // is a valid IP4 Address
            tmpAddrPtr=&((struct sockaddr_in *)ifa->ifa_addr)->sin_addr;
            char addressBuffer[INET_ADDRSTRLEN];
            inet_ntop(AF_INET, tmpAddrPtr, addressBuffer, INET_ADDRSTRLEN);
            //printf("%s IP Address %s\n", ifa->ifa_name, addressBuffer);

            string temp = string(addressBuffer);
            string lo = "127.0.0.1";
            if (temp.compare(0, lo.size(), lo)!=0) {
            	ret = temp;
            	break;
            }

        } else if (ifa->ifa_addr->sa_family == AF_INET6) { // check it is IP6
            // is a valid IP6 Address
            tmpAddrPtr=&((struct sockaddr_in6 *)ifa->ifa_addr)->sin6_addr;
            char addressBuffer[INET6_ADDRSTRLEN];
            inet_ntop(AF_INET6, tmpAddrPtr, addressBuffer, INET6_ADDRSTRLEN);
            //printf("%s IP Address %s\n", ifa->ifa_name, addressBuffer);
        }
    }
    if (ifAddrStruct!=NULL) freeifaddrs(ifAddrStruct);

    return ret;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x78, %rsp
movq %rdi, %rbx
leaq 0x10(%rdi), %rax
movq %rax, (%rsp)
movq %rax, (%rdi)
leaq 0x9d27(%rip), %rdx      # 0xe09b
movq %rdx, %rsi
callq 0xc5c2
leaq 0x28(%rsp), %r14
movq $0x0, (%r14)
movq %r14, %rdi
callq 0x36b0
movq (%r14), %r13
testq %r13, %r13
je 0x44ae
leaq 0x30(%rsp), %r14
leaq 0x60(%rsp), %r15
leaq 0x8(%rsp), %rbp
movq 0x18(%r13), %rsi
testq %rsi, %rsi
je 0x44a1
movzwl (%rsi), %eax
cmpl $0xa, %eax
je 0x448b
cmpl $0x2, %eax
jne 0x44a1
addq $0x4, %rsi
movl $0x2, %edi
movq %r15, %rdx
movl $0x10, %ecx
callq 0x33d0
leaq 0x40(%rsp), %rax
movq %rax, 0x30(%rsp)
movq %r15, %rdi
callq 0x3180
leaq (%rsp,%rax), %rdx
addq $0x60, %rdx
movq %r14, %rdi
movq %r15, %rsi
callq 0xc5c2
leaq 0x18(%rsp), %rax
movq %rax, 0x8(%rsp)
movq %rbp, %rdi
leaq 0x9c13(%rip), %rsi      # 0xe02f
leaq 0x9c15(%rip), %rdx      # 0xe038
callq 0xc5c2
movq 0x10(%rsp), %rdx
movq %r14, %rdi
xorl %esi, %esi
movq %rbp, %rcx
callq 0x3490
movl %eax, %r12d
testl %eax, %eax
je 0x444c
movq %rbx, %rdi
movq %r14, %rsi
callq 0x31e0
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x4468
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x3390
movq 0x30(%rsp), %rdi
leaq 0x40(%rsp), %rax
cmpq %rax, %rdi
je 0x4484
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x3390
testl %r12d, %r12d
je 0x44a1
jmp 0x44ae
addq $0x8, %rsi
movl $0xa, %edi
movq %r14, %rdx
movl $0x2e, %ecx
callq 0x33d0
movq (%r13), %r13
testq %r13, %r13
jne 0x43ab
movq 0x28(%rsp), %rdi
testq %rdi, %rdi
je 0x44bd
callq 0x3640
movq %rbx, %rax
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %r14
jmp 0x44f8
movq %rax, %r14
jmp 0x4514
movq %rax, %r14
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x44f8
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x3390
movq 0x30(%rsp), %rdi
leaq 0x40(%rsp), %rax
cmpq %rax, %rdi
je 0x4514
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x3390
movq (%rbx), %rdi
cmpq (%rsp), %rdi
je 0x452c
movq (%rsp), %rax
movq (%rax), %rsi
incq %rsi
callq 0x3390
movq %r14, %rdi
callq 0x3650