#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_in {
  int /*<<< orphan*/ sin_port;
  int /*<<< orphan*/ sin_addr;
};

/* Variables and functions */
int /*<<< orphan*/ asprintf(char **, char *, char *, unsigned int);
int /*<<< orphan*/ assert(struct sockaddr_in const *);
char *inet_ntoa(int /*<<< orphan*/);
unsigned int ntohs(int /*<<< orphan*/);
char *tow_internet_socket_address_alloc_description(
    struct sockaddr_in const *socket_address) {
  assert(socket_address);
  char *address = inet_ntoa(socket_address->sin_addr);
  unsigned port = ntohs(socket_address->sin_port);
  char *description;
  asprintf(&description, "%s:%u", address, port);
  return description;
}


x86 assembly (clang, -O0):
<tow_internet_socket_address_alloc_description>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <assert@plt>
mov    -0x8(%rbp),%rax
mov    0x4(%rax),%edi
call   1030 <inet_ntoa@plt>
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%edi
call   1060 <ntohs@plt>
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rdx
mov    -0x14(%rbp),%ecx
lea    -0x20(%rbp),%rdi
lea    0xe7b(%rip),%rsi
call   1050 <asprintf@plt>
mov    -0x20(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<tow_internet_socket_address_alloc_description>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rbx
call   1040 <assert@plt>
mov    0x4(%rbx),%edi
call   1030 <inet_ntoa@plt>
mov    %rax,%r14
mov    (%rbx),%edi
call   1060 <ntohs@plt>
lea    0xe9b(%rip),%rsi
mov    %rsp,%rdi
mov    %r14,%rdx
mov    %eax,%ecx
call   1050 <asprintf@plt>
mov    (%rsp),%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.sockaddr_in = type { i32, i32 }
@.str = [6 x i8] c"%s:%u\00"
define i8* @tow_internet_socket_address_alloc_description(%struct.sockaddr_in* %0) {
%2 = alloca %struct.sockaddr_in*
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i8*
store %struct.sockaddr_in* %0, %struct.sockaddr_in** %2
%6 = load %struct.sockaddr_in*, %struct.sockaddr_in** %2
%7 = call i32 @assert(%struct.sockaddr_in* %6)
%8 = load %struct.sockaddr_in*, %struct.sockaddr_in** %2
%9 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %8, i32 0, i32 1
%10 = load i32, i32* %9
%11 = call i8* @inet_ntoa(i32 %10)
store i8* %11, i8** %3
%12 = load %struct.sockaddr_in*, %struct.sockaddr_in** %2
%13 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %12, i32 0, i32 0
%14 = load i32, i32* %13
%15 = call i32 @ntohs(i32 %14)
store i32 %15, i32* %4
%16 = load i8*, i8** %3
%17 = load i32, i32* %4
%18 = call i32 @asprintf(i8** %5, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* %16, i32 %17)
%19 = load i8*, i8** %5
ret i8* %19
}

LLVM IR (-O2):
%struct.sockaddr_in = type { i32, i32 }
@.str = [6 x i8] c"%s:%u\00"
define i8* @tow_internet_socket_address_alloc_description(%struct.sockaddr_in* %0) {
%2 = alloca i8*
%3 = tail call i32 @assert(%struct.sockaddr_in* %0)
%4 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %0, i64 0, i32 1
%5 = load i32, i32* %4
%6 = tail call i8* @inet_ntoa(i32 %5)
%7 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %0, i64 0, i32 0
%8 = load i32, i32* %7
%9 = tail call i32 @ntohs(i32 %8)
%10 = bitcast i8** %2 to i8*
%11 = call i32 @asprintf(i8** %2, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* %6, i32 %9)
%12 = load i8*, i8** %2
ret i8* %12
}