#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*/ inet_ntoa(int /*<<< orphan*/);
int ntohs(int /*<<< orphan*/);
int /*<<< orphan*/ strncpy(char *, int /*<<< orphan*/, int);
extern void get_internet_address(char *host, int hostlen, int *portp,
                                 struct sockaddr_in *saddrp) {
  strncpy(host, inet_ntoa(saddrp->sin_addr), hostlen);
  *portp = ntohs(saddrp->sin_port);
}


x86 assembly (clang, -O0):
<get_internet_address>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x20(%rbp),%rax
mov    0x4(%rax),%edi
call   1040 <inet_ntoa@plt>
mov    -0x28(%rbp),%rdi
mov    %eax,%esi
mov    -0xc(%rbp),%edx
call   1030 <strncpy@plt>
mov    -0x20(%rbp),%rax
mov    (%rax),%edi
call   1050 <ntohs@plt>
mov    %eax,%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_internet_address>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rcx,%rbx
mov    %rdx,%r14
mov    %esi,%r15d
mov    %rdi,%rbp
mov    0x4(%rcx),%edi
call   1040 <inet_ntoa@plt>
mov    %rbp,%rdi
mov    %eax,%esi
mov    %r15d,%edx
call   1030 <strncpy@plt>
mov    (%rbx),%edi
call   1050 <ntohs@plt>
mov    %eax,(%r14)
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.sockaddr_in = type { i32, i32 }
define void @get_internet_address(i8* %0, i32 %1, i32* %2, %struct.sockaddr_in* %3) {
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i32*
%8 = alloca %struct.sockaddr_in*
store i8* %0, i8** %5
store i32 %1, i32* %6
store i32* %2, i32** %7
store %struct.sockaddr_in* %3, %struct.sockaddr_in** %8
%9 = load i8*, i8** %5
%10 = load %struct.sockaddr_in*, %struct.sockaddr_in** %8
%11 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %10, i32 0, i32 1
%12 = load i32, i32* %11
%13 = call i32 @inet_ntoa(i32 %12)
%14 = load i32, i32* %6
%15 = call i32 @strncpy(i8* %9, i32 %13, i32 %14)
%16 = load %struct.sockaddr_in*, %struct.sockaddr_in** %8
%17 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %16, i32 0, i32 0
%18 = load i32, i32* %17
%19 = call i32 @ntohs(i32 %18)
%20 = load i32*, i32** %7
store i32 %19, i32* %20
ret void
}

LLVM IR (-O2):
%struct.sockaddr_in = type { i32, i32 }
define void @get_internet_address(i8* %0, i32 %1, i32* nocapture writeonly %2, %struct.sockaddr_in* nocapture %3) {
%5 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i64 0, i32 1
%6 = load i32, i32* %5
%7 = tail call i32 @inet_ntoa(i32 %6)
%8 = tail call i32 @strncpy(i8* %0, i32 %7, i32 %1)
%9 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i64 0, i32 0
%10 = load i32, i32* %9
%11 = tail call i32 @ntohs(i32 %10)
store i32 %11, i32* %2
ret void
}