// File: /workspace/github_c_makefile_star2_O0/gplessis[P]dotdeb-redis/src/anet.c
// Function: anetPeerToString
int anetPeerToString(int fd, char *ip, size_t ip_len, int *port) {
    struct sockaddr_storage sa;
    socklen_t salen = sizeof(sa);

    if (getpeername(fd,(struct sockaddr*)&sa,&salen) == -1) goto error;
    if (ip_len == 0) goto error;

    if (sa.ss_family == AF_INET) {
        struct sockaddr_in *s = (struct sockaddr_in *)&sa;
        if (ip) inet_ntop(AF_INET,(void*)&(s->sin_addr),ip,ip_len);
        if (port) *port = ntohs(s->sin_port);
    } else if (sa.ss_family == AF_INET6) {
        struct sockaddr_in6 *s = (struct sockaddr_in6 *)&sa;
        if (ip) inet_ntop(AF_INET6,(void*)&(s->sin6_addr),ip,ip_len);
        if (port) *port = ntohs(s->sin6_port);
    } else if (sa.ss_family == AF_UNIX) {
        if (ip) strncpy(ip,"/unixsocket",ip_len);
        if (port) *port = 0;
    } else {
        goto error;
    }
    return 0;

error:
    if (ip) {
        if (ip_len >= 2) {
            ip[0] = '?';
            ip[1] = '\0';
        } else if (ip_len == 1) {
            ip[0] = '\0';
        }
    }
    if (port) *port = 0;
    return -1;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xc0, %rsp
movl %edi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movl $0x80, -0xa4(%rbp)
movl -0x8(%rbp), %edi
leaq -0xa0(%rbp), %rax
movq %rax, -0xb0(%rbp)
movq -0xb0(%rbp), %rsi
leaq -0xa4(%rbp), %rdx
callq 0x10180
cmpl $-0x1, %eax
jne 0x11d92
jmp 0x11eae
cmpq $0x0, -0x18(%rbp)
jne 0x11d9e
jmp 0x11eae
movzwl -0xa0(%rbp), %eax
cmpl $0x2, %eax
jne 0x11e03
leaq -0xa0(%rbp), %rax
movq %rax, -0xb8(%rbp)
cmpq $0x0, -0x10(%rbp)
je 0x11dde
movq -0xb8(%rbp), %rsi
addq $0x4, %rsi
movq -0x10(%rbp), %rdx
movq -0x18(%rbp), %rax
movl %eax, %ecx
movl $0x2, %edi
callq 0x10030
cmpq $0x0, -0x20(%rbp)
je 0x11dfe
movq -0xb8(%rbp), %rax
movzwl 0x2(%rax), %edi
callq 0x10480
movzwl %ax, %ecx
movq -0x20(%rbp), %rax
movl %ecx, (%rax)
jmp 0x11ea5
movzwl -0xa0(%rbp), %eax
cmpl $0xa, %eax
jne 0x11e65
leaq -0xa0(%rbp), %rax
movq %rax, -0xc0(%rbp)
cmpq $0x0, -0x10(%rbp)
je 0x11e43
movq -0xc0(%rbp), %rsi
addq $0x8, %rsi
movq -0x10(%rbp), %rdx
movq -0x18(%rbp), %rax
movl %eax, %ecx
movl $0xa, %edi
callq 0x10030
cmpq $0x0, -0x20(%rbp)
je 0x11e63
movq -0xc0(%rbp), %rax
movzwl 0x2(%rax), %edi
callq 0x10480
movzwl %ax, %ecx
movq -0x20(%rbp), %rax
movl %ecx, (%rax)
jmp 0x11ea3
movzwl -0xa0(%rbp), %eax
cmpl $0x1, %eax
jne 0x11e9f
cmpq $0x0, -0x10(%rbp)
je 0x11e8c
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rdx
leaq 0x75261(%rip), %rsi     # 0x870e8
callq 0x10090
cmpq $0x0, -0x20(%rbp)
je 0x11e9d
movq -0x20(%rbp), %rax
movl $0x0, (%rax)
jmp 0x11ea1
jmp 0x11eae
jmp 0x11ea3
jmp 0x11ea5
movl $0x0, -0x4(%rbp)
jmp 0x11ef7
cmpq $0x0, -0x10(%rbp)
je 0x11edf
cmpq $0x2, -0x18(%rbp)
jb 0x11ecd
movq -0x10(%rbp), %rax
movb $0x3f, (%rax)
movq -0x10(%rbp), %rax
movb $0x0, 0x1(%rax)
jmp 0x11edd
cmpq $0x1, -0x18(%rbp)
jne 0x11edb
movq -0x10(%rbp), %rax
movb $0x0, (%rax)
jmp 0x11edd
jmp 0x11edf
cmpq $0x0, -0x20(%rbp)
je 0x11ef0
movq -0x20(%rbp), %rax
movl $0x0, (%rax)
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
movl -0x4(%rbp), %eax
addq $0xc0, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)