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

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


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

x86 assembly (clang, -O2):
<debug_dump_addr>:
push   %r15
push   %r14
push   %rbx
sub    $0x100,%rsp
mov    %rsi,%rbx
mov    %rdi,%r14
mov    0x8(%rsi),%edi
add    $0x4,%rsi
mov    %rsp,%rdx
mov    $0xff,%ecx
call   1030 <inet_ntop@plt>
mov    %rax,%r15
mov    (%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 @debug_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*
store i8* %0, i8** %3
store %struct.sockaddr_in* %1, %struct.sockaddr_in** %4
%8 = load %struct.sockaddr_in*, %struct.sockaddr_in** %4
%9 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %8, i32 0, i32 2
%10 = load i32, i32* %9
%11 = load %struct.sockaddr_in*, %struct.sockaddr_in** %4
%12 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %11, i32 0, i32 1
%13 = getelementptr inbounds [255 x i8], [255 x i8]* %6, i64 0, i64 0
%14 = call i8* @inet_ntop(i32 %10, i32* %12, i8* %13, i32 255)
store i8* %14, i8** %7
%15 = load %struct.sockaddr_in*, %struct.sockaddr_in** %4
%16 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %15, i32 0, i32 0
%17 = load i32, i32* %16
%18 = call i32 @ntohs(i32 %17)
store i32 %18, i32* %5
%19 = load i8*, i8** %3
%20 = load i8*, i8** %7
%21 = load i32, i32* %5
%22 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i8* %19, i8* %20, i32 %21)
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 @debug_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 2
%6 = load i32, i32* %5
%7 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %1, i64 0, i32 1
%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 0
%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
}