#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 */
scalar_t__ inet_ntoa(int /*<<< orphan*/);
int ntohs(int /*<<< orphan*/);
int /*<<< orphan*/ strncpy(char *, char *, int);
int get_internet_address(char *host, int len, int *portp,
                         struct sockaddr_in *addrp) {
  strncpy(host, (char *)inet_ntoa(addrp->sin_addr), len);
  *portp = ntohs(addrp->sin_port);
  return 0;
}


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    %rax,%rsi
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)
xor    %eax,%eax
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    %rax,%rsi
mov    %r15d,%edx
call   1030 <strncpy@plt>
mov    (%rbx),%edi
call   1050 <ntohs@plt>
mov    %eax,(%r14)
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.sockaddr_in = type { i32, i32 }
define i32 @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 i64 @inet_ntoa(i32 %12)
%14 = inttoptr i64 %13 to i8*
%15 = load i32, i32* %6
%16 = call i32 @strncpy(i8* %9, i8* %14, i32 %15)
%17 = load %struct.sockaddr_in*, %struct.sockaddr_in** %8
%18 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %17, i32 0, i32 0
%19 = load i32, i32* %18
%20 = call i32 @ntohs(i32 %19)
%21 = load i32*, i32** %7
store i32 %20, i32* %21
ret i32 0
}

LLVM IR (-O2):
%struct.sockaddr_in = type { i32, i32 }
define i32 @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 i64 @inet_ntoa(i32 %6)
%8 = inttoptr i64 %7 to i8*
%9 = tail call i32 @strncpy(i8* %0, i8* %8, i32 %1)
%10 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i64 0, i32 0
%11 = load i32, i32* %10
%12 = tail call i32 @ntohs(i32 %11)
store i32 %12, i32* %2
ret i32 0
}