#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;
  int /*<<< orphan*/ sin_family;
};

/* Variables and functions */
int /*<<< orphan*/ AF_INET;
int /*<<< orphan*/ htons(int /*<<< orphan*/);
int /*<<< orphan*/ memcpy(int /*<<< orphan*/ *, int /*<<< orphan*/, int);
int /*<<< orphan*/ memset(struct sockaddr_in *, int /*<<< orphan*/, int);
int /*<<< orphan*/ parse_host(char const *);
int /*<<< orphan*/ parse_port(char const *);
void make_sockaddr_in(const char *host, const char *port,
                      struct sockaddr_in *sa) {
  memset(sa, 0, sizeof *sa);
  sa->sin_family = AF_INET;
  memcpy(&sa->sin_addr, parse_host(host), 4);
  sa->sin_port = htons(parse_port(port));
}


x86 assembly (clang, -O0):
<make_sockaddr_in>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
xor    %esi,%esi
mov    $0xc,%edx
call   1040 <memset@plt>
mov    0x2e6d(%rip),%rax
mov    (%rax),%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,0x8(%rax)
mov    -0x18(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
call   1070 <parse_host@plt>
mov    -0x20(%rbp),%rdi
mov    %eax,%esi
mov    $0x4,%edx
call   1060 <memcpy@plt>
mov    -0x10(%rbp),%rdi
call   1050 <parse_port@plt>
mov    %eax,%edi
call   1030 <htons@plt>
mov    %eax,%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<make_sockaddr_in>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rdx,%rbx
mov    %rsi,%r14
mov    %rdi,%r15
mov    %rdx,%rdi
xor    %esi,%esi
mov    $0xc,%edx
call   1040 <memset@plt>
mov    0x2e71(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x8(%rbx)
lea    0x4(%rbx),%r12
mov    %r15,%rdi
call   1070 <parse_host@plt>
mov    %r12,%rdi
mov    %eax,%esi
mov    $0x4,%edx
call   1060 <memcpy@plt>
mov    %r14,%rdi
call   1050 <parse_port@plt>
mov    %eax,%edi
call   1030 <htons@plt>
mov    %eax,(%rbx)
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.sockaddr_in = type { i32, i32, i32 }
@AF_INET = global i32 0
define void @make_sockaddr_in(i8* %0, i8* %1, %struct.sockaddr_in* %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca %struct.sockaddr_in*
store i8* %0, i8** %4
store i8* %1, i8** %5
store %struct.sockaddr_in* %2, %struct.sockaddr_in** %6
%7 = load %struct.sockaddr_in*, %struct.sockaddr_in** %6
%8 = call i32 @memset(%struct.sockaddr_in* %7, i32 0, i32 12)
%9 = load i32, i32* @AF_INET
%10 = load %struct.sockaddr_in*, %struct.sockaddr_in** %6
%11 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %10, i32 0, i32 2
store i32 %9, i32* %11
%12 = load %struct.sockaddr_in*, %struct.sockaddr_in** %6
%13 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %12, i32 0, i32 1
%14 = load i8*, i8** %4
%15 = call i32 @parse_host(i8* %14)
%16 = call i32 @memcpy(i32* %13, i32 %15, i32 4)
%17 = load i8*, i8** %5
%18 = call i32 @parse_port(i8* %17)
%19 = call i32 @htons(i32 %18)
%20 = load %struct.sockaddr_in*, %struct.sockaddr_in** %6
%21 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %20, i32 0, i32 0
store i32 %19, i32* %21
ret void
}

LLVM IR (-O2):
%struct.sockaddr_in = type { i32, i32, i32 }
@AF_INET = global i32 0
define void @make_sockaddr_in(i8* %0, i8* %1, %struct.sockaddr_in* %2) {
%4 = tail call i32 @memset(%struct.sockaddr_in* %2, i32 0, i32 12)
%5 = load i32, i32* @AF_INET
%6 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %2, i64 0, i32 2
store i32 %5, i32* %6
%7 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %2, i64 0, i32 1
%8 = tail call i32 @parse_host(i8* %0)
%9 = tail call i32 @memcpy(i32* %7, i32 %8, i32 4)
%10 = tail call i32 @parse_port(i8* %1)
%11 = tail call i32 @htons(i32 %10)
%12 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %2, i64 0, i32 0
store i32 %11, i32* %12
ret void
}