// File: /workspace/github_cpp_makefile_star2_O3/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), %r15
movq %r15, (%rdi)
leaq 0x9d55(%rip), %rdx      # 0xe0cb
movq %rdx, %rsi
callq 0xc5ec
leaq 0x28(%rsp), %r14
movq $0x0, (%r14)
movq %r14, %rdi
callq 0x36a0
movq (%r14), %r13
testq %r13, %r13
je 0x44c3
movq %r15, (%rsp)
leaq 0x30(%rsp), %r14
leaq 0x60(%rsp), %r15
leaq 0x8(%rsp), %rbp
movq 0x18(%r13), %rsi
testq %rsi, %rsi
je 0x44a7
movzwl (%rsi), %eax
cmpl $0xa, %eax
je 0x4491
cmpl $0x2, %eax
jne 0x44a7
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 0xc5ec
leaq 0x18(%rsp), %rax
movq %rax, 0x8(%rsp)
movq %rbp, %rdi
leaq 0x9c3d(%rip), %rsi      # 0xe05f
leaq 0x9c3f(%rip), %rdx      # 0xe068
callq 0xc5ec
movq 0x10(%rsp), %rdx
movq %r14, %rdi
xorl %esi, %esi
movq %rbp, %rcx
callq 0x3490
movl %eax, %r12d
testl %eax, %eax
je 0x4452
movq %rbx, %rdi
movq %r14, %rsi
callq 0x31e0
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x446e
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x3390
movq 0x30(%rsp), %rdi
leaq 0x40(%rsp), %rax
cmpq %rax, %rdi
je 0x448a
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x3390
testl %r12d, %r12d
je 0x44a7
jmp 0x44b4
addq $0x8, %rsi
movl $0xa, %edi
movq %r14, %rdx
movl $0x2e, %ecx
callq 0x33d0
movq (%r13), %r13
testq %r13, %r13
jne 0x43b1
movq 0x28(%rsp), %rdi
testq %rdi, %rdi
je 0x44c3
callq 0x3630
movq %rbx, %rax
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %r14
jmp 0x44fe
movq %rax, %r14
jmp 0x451a
movq %rax, %r14
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x44fe
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x3390
movq 0x30(%rsp), %rdi
leaq 0x40(%rsp), %rax
cmpq %rax, %rdi
je 0x451a
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x3390
movq (%rbx), %rdi
cmpq (%rsp), %rdi
je 0x4532
movq (%rsp), %rax
movq (%rax), %rsi
incq %rsi
callq 0x3390
movq %r14, %rdi
callq 0x3640