#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 */
typedef int /*<<< orphan*/ u_short;
typedef int /*<<< orphan*/ u_long;
struct TYPE_2__ {
  int /*<<< orphan*/ s_addr;
};
struct sockaddr_in {
  int /*<<< orphan*/ sin_port;
  TYPE_1__ sin_addr;
  int /*<<< orphan*/ sin_family;
};

/* Variables and functions */
int /*<<< orphan*/ AF_INET;
int /*<<< orphan*/ memset(struct sockaddr_in *, int /*<<< orphan*/, int);
void fill_sockaddr_in(struct sockaddr_in *buffer, u_long addr, u_short port) {
  memset(buffer, 0, sizeof *buffer);
  buffer->sin_family = AF_INET;
  buffer->sin_addr.s_addr = addr;
  buffer->sin_port = port;
}


x86 assembly (clang, -O0):
<fill_sockaddr_in>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
xor    %esi,%esi
mov    $0xc,%edx
call   1030 <memset@plt>
mov    0x2eaf(%rip),%rax
mov    (%rax),%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,0x8(%rax)
mov    -0xc(%rbp),%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,0x4(%rax)
mov    -0x10(%rbp),%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,(%rax)
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fill_sockaddr_in>:
push   %rbp
push   %r14
push   %rbx
mov    %edx,%r14d
mov    %esi,%ebp
mov    %rdi,%rbx
xor    %esi,%esi
mov    $0xc,%edx
call   1030 <memset@plt>
mov    0x2eb9(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x8(%rbx)
mov    %ebp,0x4(%rbx)
mov    %r14d,(%rbx)
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
%struct.sockaddr_in = type { i32, %struct.TYPE_2__, i32 }
%struct.TYPE_2__ = type { i32 }
@AF_INET = global i32 0
define void @fill_sockaddr_in(%struct.sockaddr_in* %0, i32 %1, i32 %2) {
%4 = alloca %struct.sockaddr_in*
%5 = alloca i32
%6 = alloca i32
store %struct.sockaddr_in* %0, %struct.sockaddr_in** %4
store i32 %1, i32* %5
store i32 %2, i32* %6
%7 = load %struct.sockaddr_in*, %struct.sockaddr_in** %4
%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** %4
%11 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %10, i32 0, i32 2
store i32 %9, i32* %11
%12 = load i32, i32* %5
%13 = load %struct.sockaddr_in*, %struct.sockaddr_in** %4
%14 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %13, i32 0, i32 1
%15 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %14, i32 0, i32 0
store i32 %12, i32* %15
%16 = load i32, i32* %6
%17 = load %struct.sockaddr_in*, %struct.sockaddr_in** %4
%18 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %17, i32 0, i32 0
store i32 %16, i32* %18
ret void
}

LLVM IR (-O2):
%struct.sockaddr_in = type { i32, %struct.TYPE_2__, i32 }
%struct.TYPE_2__ = type { i32 }
@AF_INET = global i32 0
define void @fill_sockaddr_in(%struct.sockaddr_in* %0, i32 %1, i32 %2) {
%4 = tail call i32 @memset(%struct.sockaddr_in* %0, i32 0, i32 12)
%5 = load i32, i32* @AF_INET
%6 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %0, i64 0, i32 2
store i32 %5, i32* %6
%7 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %0, i64 0, i32 1, i32 0
store i32 %1, i32* %7
%8 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %0, i64 0, i32 0
store i32 %2, i32* %8
ret void
}