#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 */
struct sockaddr {
  int dummy;
};
typedef int /*<<< orphan*/ socklen_t;
typedef int /*<<< orphan*/ servbuf;
typedef int /*<<< orphan*/ hostbuf;

/* Variables and functions */
int NI_NUMERICHOST;
int NI_NUMERICSERV;
int /*<<< orphan*/ getnameinfo(struct sockaddr const *, int /*<<< orphan*/,
                               char *, int, char *, int, int);
int /*<<< orphan*/ snprintf(char *, size_t, char *, char *, char *);
void make_name(char *buf, size_t buflen, const struct sockaddr *sa,
               socklen_t salen) {
  char hostbuf[64], servbuf[32];
  getnameinfo(sa, salen, hostbuf, sizeof(hostbuf), servbuf, sizeof(servbuf),
              NI_NUMERICHOST | NI_NUMERICSERV);
  snprintf(buf, buflen, "%s:%s", hostbuf, servbuf);
}


x86 assembly (clang, -O0):
<make_name>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x1c(%rbp),%esi
lea    -0x60(%rbp),%rdx
lea    -0x80(%rbp),%r8
mov    0x2e88(%rip),%rax
mov    (%rax),%eax
mov    0x2e8f(%rip),%rcx
or     (%rcx),%eax
mov    $0x40,%ecx
mov    $0x20,%r9d
mov    %eax,(%rsp)
call   1040 <getnameinfo@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
lea    -0x60(%rbp),%rcx
lea    -0x80(%rbp),%r8
lea    0xe7b(%rip),%rdx
call   1030 <snprintf@plt>
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<make_name>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x78,%rsp
mov    %rsi,%r14
mov    %rdi,%rbx
mov    0x2ea0(%rip),%rax
mov    0x2ea9(%rip),%rsi
mov    (%rsi),%esi
or     (%rax),%esi
mov    %esi,(%rsp)
lea    0x30(%rsp),%r15
lea    0x10(%rsp),%r12
mov    %rdx,%rdi
mov    %ecx,%esi
mov    %r15,%rdx
mov    $0x40,%ecx
mov    %r12,%r8
mov    $0x20,%r9d
call   1040 <getnameinfo@plt>
lea    0xe8e(%rip),%rdx
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %r15,%rcx
mov    %r12,%r8
call   1030 <snprintf@plt>
add    $0x78,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.sockaddr = type { i32 }
@NI_NUMERICHOST = global i32 0
@NI_NUMERICSERV = global i32 0
@.str = [6 x i8] c"%s:%s\00"
define void @make_name(i8* %0, i64 %1, %struct.sockaddr* %2, i32 %3) {
%5 = alloca i8*
%6 = alloca i64
%7 = alloca %struct.sockaddr*
%8 = alloca i32
%9 = alloca [64 x i8]
%10 = alloca [32 x i8]
store i8* %0, i8** %5
store i64 %1, i64* %6
store %struct.sockaddr* %2, %struct.sockaddr** %7
store i32 %3, i32* %8
%11 = load %struct.sockaddr*, %struct.sockaddr** %7
%12 = load i32, i32* %8
%13 = getelementptr inbounds [64 x i8], [64 x i8]* %9, i64 0, i64 0
%14 = getelementptr inbounds [32 x i8], [32 x i8]* %10, i64 0, i64 0
%15 = load i32, i32* @NI_NUMERICHOST
%16 = load i32, i32* @NI_NUMERICSERV
%17 = or i32 %15, %16
%18 = call i32 @getnameinfo(%struct.sockaddr* %11, i32 %12, i8* %13, i32 64, i8* %14, i32 32, i32 %17)
%19 = load i8*, i8** %5
%20 = load i64, i64* %6
%21 = getelementptr inbounds [64 x i8], [64 x i8]* %9, i64 0, i64 0
%22 = getelementptr inbounds [32 x i8], [32 x i8]* %10, i64 0, i64 0
%23 = call i32 @snprintf(i8* %19, i64 %20, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* %21, i8* %22)
ret void
}

LLVM IR (-O2):
%struct.sockaddr = type { i32 }
@NI_NUMERICHOST = global i32 0
@NI_NUMERICSERV = global i32 0
@.str = [6 x i8] c"%s:%s\00"
define void @make_name(i8* %0, i64 %1, %struct.sockaddr* %2, i32 %3) {
%5 = alloca [64 x i8]
%6 = alloca [32 x i8]
%7 = getelementptr inbounds [64 x i8], [64 x i8]* %5, i64 0, i64 0
%8 = getelementptr inbounds [32 x i8], [32 x i8]* %6, i64 0, i64 0
%9 = load i32, i32* @NI_NUMERICHOST
%10 = load i32, i32* @NI_NUMERICSERV
%11 = or i32 %10, %9
%12 = call i32 @getnameinfo(%struct.sockaddr* %2, i32 %3, i8* %7, i32 64, i8* %8, i32 32, i32 %11)
%13 = call i32 @snprintf(i8* %0, i64 %1, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* %7, i8* %8)
ret void
}