#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;
  int /*<<< orphan*/ sin_family;
};
struct hostent {
  int /*<<< orphan*/ h_length;
  scalar_t__ h_addr;
};

/* Variables and functions */
int /*<<< orphan*/ AF_INET;
int /*<<< orphan*/ bcopy(char *, char *, int /*<<< orphan*/);
int /*<<< orphan*/ bzero(char *, int);
int /*<<< orphan*/ htons(int);
void netAdrsFromHost(struct sockaddr_in *to, struct hostent *host, int port) {
  bzero((char *)to, sizeof(*to));
  to->sin_family = AF_INET;
  bcopy((char *)host->h_addr, (char *)&to->sin_addr.s_addr, host->h_length);
  to->sin_port = htons(port);
}


x86 assembly (clang, -O0):
<netAdrsFromHost>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    -0x8(%rbp),%rdi
mov    $0xc,%esi
call   1050 <bzero@plt>
mov    0x2e90(%rip),%rax
mov    (%rax),%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,0x8(%rax)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    -0x8(%rbp),%rsi
add    $0x4,%rsi
mov    -0x10(%rbp),%rax
mov    (%rax),%edx
call   1040 <bcopy@plt>
mov    -0x14(%rbp),%edi
call   1030 <htons@plt>
mov    %eax,%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,(%rax)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<netAdrsFromHost>:
push   %rbp
push   %r14
push   %rbx
mov    %edx,%r14d
mov    %rsi,%rbx
mov    %rdi,%rbp
mov    $0xc,%esi
call   1050 <bzero@plt>
mov    0x2e9a(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x8(%rbp)
mov    0x8(%rbx),%rsi
lea    0x4(%rbp),%rdi
mov    (%rbx),%edx
call   1040 <memmove@plt>
mov    %r14d,%edi
call   1030 <htons@plt>
mov    %eax,0x0(%rbp)
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
%struct.sockaddr_in = type { i32, %struct.TYPE_2__, i32 }
%struct.TYPE_2__ = type { i32 }
%struct.hostent = type { i32, i64 }
@AF_INET = global i32 0
define void @netAdrsFromHost(%struct.sockaddr_in* %0, %struct.hostent* %1, i32 %2) {
%4 = alloca %struct.sockaddr_in*
%5 = alloca %struct.hostent*
%6 = alloca i32
store %struct.sockaddr_in* %0, %struct.sockaddr_in** %4
store %struct.hostent* %1, %struct.hostent** %5
store i32 %2, i32* %6
%7 = load %struct.sockaddr_in*, %struct.sockaddr_in** %4
%8 = bitcast %struct.sockaddr_in* %7 to i8*
%9 = call i32 @bzero(i8* %8, i32 12)
%10 = load i32, i32* @AF_INET
%11 = load %struct.sockaddr_in*, %struct.sockaddr_in** %4
%12 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %11, i32 0, i32 2
store i32 %10, i32* %12
%13 = load %struct.hostent*, %struct.hostent** %5
%14 = getelementptr inbounds %struct.hostent, %struct.hostent* %13, i32 0, i32 1
%15 = load i64, i64* %14
%16 = inttoptr i64 %15 to i8*
%17 = load %struct.sockaddr_in*, %struct.sockaddr_in** %4
%18 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %17, i32 0, i32 1
%19 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %18, i32 0, i32 0
%20 = bitcast i32* %19 to i8*
%21 = load %struct.hostent*, %struct.hostent** %5
%22 = getelementptr inbounds %struct.hostent, %struct.hostent* %21, i32 0, i32 0
%23 = load i32, i32* %22
%24 = call i32 @bcopy(i8* %16, i8* %20, i32 %23)
%25 = load i32, i32* %6
%26 = call i32 @htons(i32 %25)
%27 = load %struct.sockaddr_in*, %struct.sockaddr_in** %4
%28 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %27, i32 0, i32 0
store i32 %26, i32* %28
ret void
}

LLVM IR (-O2):
%struct.sockaddr_in = type { i32, %struct.TYPE_2__, i32 }
%struct.TYPE_2__ = type { i32 }
%struct.hostent = type { i32, i64 }
@AF_INET = global i32 0
define void @netAdrsFromHost(%struct.sockaddr_in* nocapture writeonly %0, %struct.hostent* nocapture %1, i32 %2) {
%4 = bitcast %struct.sockaddr_in* %0 to i8*
%5 = tail call i32 @bzero(i8* %4, i32 12)
%6 = load i32, i32* @AF_INET
%7 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %0, i64 0, i32 2
store i32 %6, i32* %7
%8 = getelementptr inbounds %struct.hostent, %struct.hostent* %1, i64 0, i32 1
%9 = load i64, i64* %8
%10 = inttoptr i64 %9 to i8*
%11 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %0, i64 0, i32 1, i32 0
%12 = bitcast i32* %11 to i8*
%13 = getelementptr inbounds %struct.hostent, %struct.hostent* %1, i64 0, i32 0
%14 = load i32, i32* %13
tail call void @llvm.memmove.p0i8.p0i8.i32(i8* align 1 %12, i8* align 1 %10, i32 %14, i1 false)
%15 = tail call i32 @htons(i32 %2)
%16 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %0, i64 0, i32 0
store i32 %15, i32* %16
ret void
}