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

/* Variables and functions */
char *inet_ntop(int, int /*<<< orphan*/ *, char *, int);
int ntohs(int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, char *, char const *, int);
void util_dump_addr(char *desc, struct sockaddr_in *addr) {
  int af;
  char buf[255];
  const char *ip;
  int port;
  af = addr->sin_family;
  ip = inet_ntop(af, &addr->sin_addr, buf, 255);
  port = ntohs(addr->sin_port);
  printf("%s: ip:%s port:%d\n", desc, ip, port);
}


x86 assembly (clang, -O0):
<util_dump_addr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x130,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%edi
mov    -0x10(%rbp),%rsi
add    $0x8,%rsi
lea    -0x120(%rbp),%rdx
mov    $0xff,%ecx
call   1030 <inet_ntop@plt>
mov    %rax,-0x128(%rbp)
mov    -0x10(%rbp),%rax
mov    0x4(%rax),%edi
call   1050 <ntohs@plt>
mov    %eax,-0x12c(%rbp)
mov    -0x8(%rbp),%rsi
mov    -0x128(%rbp),%rdx
mov    -0x12c(%rbp),%ecx
lea    0xe67(%rip),%rdi
call   1040 <printf@plt>
add    $0x130,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<util_dump_addr>:
push   %r15
push   %r14
push   %rbx
sub    $0x100,%rsp
mov    %rsi,%rbx
mov    %rdi,%r14
mov    (%rsi),%edi
add    $0x8,%rsi
mov    %rsp,%rdx
mov    $0xff,%ecx
call   1030 <inet_ntop@plt>
mov    %rax,%r15
mov    0x4(%rbx),%edi
call   1050 <ntohs@plt>
lea    0xe99(%rip),%rdi
mov    %r14,%rsi
mov    %r15,%rdx
mov    %eax,%ecx
call   1040 <printf@plt>
add    $0x100,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.sockaddr_in = type { i32, i32, i32 }
@.str = [19 x i8] c"%s: ip:%s port:%d\0A\00"
define void @util_dump_addr(i8* %0, %struct.sockaddr_in* %1) {
%3 = alloca i8*
%4 = alloca %struct.sockaddr_in*
%5 = alloca i32
%6 = alloca [255 x i8]
%7 = alloca i8*
%8 = alloca i32
store i8* %0, i8** %3
store %struct.sockaddr_in* %1, %struct.sockaddr_in** %4
%9 = load %struct.sockaddr_in*, %struct.sockaddr_in** %4
%10 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %9, i32 0, i32 0
%11 = load i32, i32* %10
store i32 %11, i32* %5
%12 = load i32, i32* %5
%13 = load %struct.sockaddr_in*, %struct.sockaddr_in** %4
%14 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %13, i32 0, i32 2
%15 = getelementptr inbounds [255 x i8], [255 x i8]* %6, i64 0, i64 0
%16 = call i8* @inet_ntop(i32 %12, i32* %14, i8* %15, i32 255)
store i8* %16, i8** %7
%17 = load %struct.sockaddr_in*, %struct.sockaddr_in** %4
%18 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %17, i32 0, i32 1
%19 = load i32, i32* %18
%20 = call i32 @ntohs(i32 %19)
store i32 %20, i32* %8
%21 = load i8*, i8** %3
%22 = load i8*, i8** %7
%23 = load i32, i32* %8
%24 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i8* %21, i8* %22, i32 %23)
ret void
}

LLVM IR (-O2):
%struct.sockaddr_in = type { i32, i32, i32 }
@.str = [19 x i8] c"%s: ip:%s port:%d\0A\00"
define void @util_dump_addr(i8* %0, %struct.sockaddr_in* %1) {
%3 = alloca [255 x i8]
%4 = getelementptr inbounds [255 x i8], [255 x i8]* %3, i64 0, i64 0
%5 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %1, i64 0, i32 0
%6 = load i32, i32* %5
%7 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %1, i64 0, i32 2
%8 = call i8* @inet_ntop(i32 %6, i32* %7, i8* %4, i32 255)
%9 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %1, i64 0, i32 1
%10 = load i32, i32* %9
%11 = call i32 @ntohs(i32 %10)
%12 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i8* %0, i8* %8, i32 %11)
ret void
}