#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 */
typedef struct TYPE_2__ TYPE_1__;

/* Type definitions */
struct TYPE_2__ {
  int /*<<< orphan*/ s_addr;
};
struct sockaddr_in {
  int /*<<< orphan*/ sin_port;
  TYPE_1__ sin_addr;
};
typedef int /*<<< orphan*/ clientaddr;

/* Variables and functions */
int /*<<< orphan*/ AF_INET;
int /*<<< orphan*/ inet_ntop(int /*<<< orphan*/, int /*<<< orphan*/ *, char *,
                             int);
unsigned short ntohs(int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, char *, unsigned short);
void out_client(struct sockaddr_in clientaddr) {
  char buffer[16];
  inet_ntop(AF_INET, &clientaddr.sin_addr.s_addr, buffer, sizeof(clientaddr));
  unsigned short port = ntohs(clientaddr.sin_port);
  printf("client ip:%s (%d)\n", buffer, port);
}


x86 assembly (clang, -O0):
<out_client>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    0x2ea5(%rip),%rax
mov    (%rax),%edi
lea    -0x8(%rbp),%rsi
add    $0x4,%rsi
lea    -0x20(%rbp),%rdx
mov    $0x8,%ecx
call   1030 <inet_ntop@plt>
mov    -0x8(%rbp),%edi
call   1050 <ntohs@plt>
mov    %ax,-0x22(%rbp)
lea    -0x20(%rbp),%rsi
lea    0xe8e(%rip),%rdi
movzwl -0x22(%rbp),%edx
call   1040 <printf@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<out_client>:
push   %rbx
sub    $0x20,%rsp
mov    %rdi,0x8(%rsp)
mov    0x2ea7(%rip),%rax
mov    (%rax),%edi
lea    0xc(%rsp),%rsi
lea    0x10(%rsp),%rbx
mov    %rbx,%rdx
mov    $0x8,%ecx
call   1030 <inet_ntop@plt>
mov    0x8(%rsp),%edi
call   1050 <ntohs@plt>
movzwl %ax,%edx
lea    0xe93(%rip),%rdi
mov    %rbx,%rsi
call   1040 <printf@plt>
add    $0x20,%rsp
pop    %rbx
ret

LLVM IR (-O0):
%struct.sockaddr_in = type { i32, %struct.TYPE_2__ }
%struct.TYPE_2__ = type { i32 }
@AF_INET = global i32 0
@.str = [19 x i8] c"client ip:%s (%d)\0A\00"
define void @out_client(i64 %0) {
%2 = alloca %struct.sockaddr_in
%3 = alloca [16 x i8]
%4 = alloca i16
%5 = bitcast %struct.sockaddr_in* %2 to i64*
store i64 %0, i64* %5
%6 = load i32, i32* @AF_INET
%7 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %2, i32 0, i32 1
%8 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %7, i32 0, i32 0
%9 = getelementptr inbounds [16 x i8], [16 x i8]* %3, i64 0, i64 0
%10 = call i32 @inet_ntop(i32 %6, i32* %8, i8* %9, i32 8)
%11 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %2, i32 0, i32 0
%12 = load i32, i32* %11
%13 = call zeroext i16 @ntohs(i32 %12)
store i16 %13, i16* %4
%14 = getelementptr inbounds [16 x i8], [16 x i8]* %3, i64 0, i64 0
%15 = load i16, i16* %4
%16 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i8* %14, i16 zeroext %15)
ret void
}

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