#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 {
  TYPE_1__ sin_addr;
  int /*<<< orphan*/ sin_port;
  int /*<<< orphan*/ sin_family;
};
typedef int /*<<< orphan*/ retval;
typedef int /*<<< orphan*/ in_addr_t;

/* Variables and functions */
int /*<<< orphan*/ AF_INET;
int /*<<< orphan*/ Mmove(int /*<<< orphan*/ *, int /*<<< orphan*/ *, int);
int /*<<< orphan*/ Mzero(struct sockaddr_in *, int);
int /*<<< orphan*/ htons(int);
struct sockaddr_in Inet_sockaddr_create(in_addr_t in_addr, int port) {
  struct sockaddr_in retval;
  Mzero(&retval, sizeof(retval));
  retval.sin_family = AF_INET;
  retval.sin_port = htons(port);
  Mmove(&retval.sin_addr.s_addr, &in_addr, sizeof(retval.sin_addr.s_addr));
  return retval;
}


x86 assembly (clang, -O0):
<Inet_sockaddr_create>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x14(%rbp)
mov    %esi,-0x18(%rbp)
lea    -0x10(%rbp),%rdi
mov    %rdi,-0x30(%rbp)
mov    $0xc,%esi
call   1050 <Mzero@plt>
mov    0x2e91(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x8(%rbp)
mov    -0x18(%rbp),%edi
call   1030 <htons@plt>
mov    -0x30(%rbp),%rdi
mov    %eax,-0xc(%rbp)
lea    -0x14(%rbp),%rsi
mov    $0x4,%edx
call   1040 <Mmove@plt>
mov    -0x8(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
mov    -0x20(%rbp),%edx
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Inet_sockaddr_create>:
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    %esi,%ebx
mov    %edi,0x4(%rsp)
lea    0x8(%rsp),%r14
mov    %r14,%rdi
mov    $0xc,%esi
call   1050 <Mzero@plt>
mov    0x2e92(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x10(%rsp)
mov    %ebx,%edi
call   1030 <htons@plt>
mov    %eax,0xc(%rsp)
lea    0x4(%rsp),%rsi
mov    %r14,%rdi
mov    $0x4,%edx
call   1040 <Mmove@plt>
mov    0x8(%rsp),%rax
mov    0x10(%rsp),%edx
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.sockaddr_in = type { %struct.TYPE_2__, i32, i32 }
%struct.TYPE_2__ = type { i32 }
@AF_INET = global i32 0
define { i64, i32 } @Inet_sockaddr_create(i32 %0, i32 %1) {
%3 = alloca %struct.sockaddr_in
%4 = alloca i32
%5 = alloca i32
%6 = alloca { i64, i32 }
store i32 %0, i32* %4
store i32 %1, i32* %5
%7 = call i32 @Mzero(%struct.sockaddr_in* %3, i32 12)
%8 = load i32, i32* @AF_INET
%9 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i32 0, i32 2
store i32 %8, i32* %9
%10 = load i32, i32* %5
%11 = call i32 @htons(i32 %10)
%12 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i32 0, i32 1
store i32 %11, i32* %12
%13 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i32 0, i32 0
%14 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %13, i32 0, i32 0
%15 = call i32 @Mmove(i32* %14, i32* %4, i32 4)
%16 = bitcast { i64, i32 }* %6 to i8*
%17 = bitcast %struct.sockaddr_in* %3 to i8*
%18 = load { i64, i32 }, { i64, i32 }* %6
ret { i64, i32 } %18
}

LLVM IR (-O2):
%struct.sockaddr_in = type { %struct.TYPE_2__, i32, i32 }
%struct.TYPE_2__ = type { i32 }
@AF_INET = global i32 0
define { i64, i32 } @Inet_sockaddr_create(i32 %0, i32 %1) {
%3 = alloca %struct.sockaddr_in
%4 = alloca i32
store i32 %0, i32* %4
%5 = call i32 @Mzero(%struct.sockaddr_in* %3, i32 12)
%6 = load i32, i32* @AF_INET
%7 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i64 0, i32 2
store i32 %6, i32* %7
%8 = call i32 @htons(i32 %1)
%9 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i64 0, i32 1
store i32 %8, i32* %9
%10 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i64 0, i32 0, i32 0
%11 = call i32 @Mmove(i32* %10, i32* %4, i32 4)
%12 = bitcast %struct.sockaddr_in* %3 to i64*
%13 = load i64, i64* %12
%14 = load i32, i32* %7
%15 = insertvalue { i64, i32 } poison, i64 %13, 0
%16 = insertvalue { i64, i32 } %15, i32 %14, 1
ret { i64, i32 } %16
}