#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */
typedef int /*<<< orphan*/ ip;

/* Variables and functions */
int INET6_ADDRSTRLEN;
int /*<<< orphan*/ anetFdToString(int, char *, int, int *, int);
int anetFormatAddr(char *, size_t, char *, int);
int anetFormatFdAddr(int fd, char *buf, size_t buf_len, int fd_to_str_type) {
  char ip[INET6_ADDRSTRLEN];
  int port;
  anetFdToString(fd, ip, sizeof(ip), &port, fd_to_str_type);
  return anetFormatAddr(buf, buf_len, ip, port);
}


x86 assembly (clang, -O0):
<anetFormatFdAddr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    0x2eab(%rip),%rax
mov    (%rax),%eax
mov    %rsp,%rcx
mov    %rcx,-0x28(%rbp)
mov    %rax,%rcx
add    $0xf,%rcx
and    $0xfffffffffffffff0,%rcx
mov    %rsp,%rsi
sub    %rcx,%rsi
mov    %rsi,-0x40(%rbp)
mov    %rsi,%rsp
mov    %rax,-0x30(%rbp)
mov    -0x4(%rbp),%edi
mov    %eax,%edx
mov    -0x1c(%rbp),%r8d
lea    -0x34(%rbp),%rcx
call   1040 <anetFdToString@plt>
mov    -0x40(%rbp),%rdx
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x34(%rbp),%ecx
call   1030 <anetFormatAddr@plt>
mov    -0x28(%rbp),%rcx
mov    %rcx,%rsp
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<anetFormatFdAddr>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %ecx,%r8d
mov    %rdx,%r14
mov    %rsi,%r15
mov    0x2eae(%rip),%rax
mov    (%rax),%edx
mov    %rsp,%rbx
mov    %rdx,%rax
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%rbx
mov    %rbx,%rsp
lea    -0x1c(%rbp),%rcx
mov    %rbx,%rsi
call   1040 <anetFdToString@plt>
mov    -0x1c(%rbp),%ecx
mov    %r15,%rdi
mov    %r14,%rsi
mov    %rbx,%rdx
call   1030 <anetFormatAddr@plt>
lea    -0x18(%rbp),%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@INET6_ADDRSTRLEN = global i32 0
define i32 @anetFormatFdAddr(i32 %0, i8* %1, i64 %2, i32 %3) {
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i64
%8 = alloca i32
%9 = alloca i8*
%10 = alloca i64
%11 = alloca i32
store i32 %0, i32* %5
store i8* %1, i8** %6
store i64 %2, i64* %7
store i32 %3, i32* %8
%12 = load i32, i32* @INET6_ADDRSTRLEN
%13 = zext i32 %12 to i64
%14 = call i8* @llvm.stacksave()
store i8* %14, i8** %9
%15 = alloca i8, i64 %13
store i64 %13, i64* %10
%16 = load i32, i32* %5
%17 = trunc i64 %13 to i32
%18 = load i32, i32* %8
%19 = call i32 @anetFdToString(i32 %16, i8* %15, i32 %17, i32* %11, i32 %18)
%20 = load i8*, i8** %6
%21 = load i64, i64* %7
%22 = load i32, i32* %11
%23 = call i32 @anetFormatAddr(i8* %20, i64 %21, i8* %15, i32 %22)
%24 = load i8*, i8** %9
ret i32 %23
}

LLVM IR (-O2):
@INET6_ADDRSTRLEN = global i32 0
define i32 @anetFormatFdAddr(i32 %0, i8* %1, i64 %2, i32 %3) {
%5 = alloca i32
%6 = load i32, i32* @INET6_ADDRSTRLEN
%7 = zext i32 %6 to i64
%8 = alloca i8, i64 %7
%9 = bitcast i32* %5 to i8*
%10 = call i32 @anetFdToString(i32 %0, i8* %8, i32 %6, i32* %5, i32 %3)
%11 = load i32, i32* %5
%12 = call i32 @anetFormatAddr(i8* %1, i64 %2, i8* %8, i32 %11)
ret i32 %12
}