#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_in6 {
  int dummy;
};
struct msghdr {
  int iov_len;
  int msg_iovlen;
  int msg_namelen;
  int msg_controllen;
  void *msg_control;
  struct sockaddr_in6 *msg_name;
  struct msghdr *msg_iov;
  void *iov_base;
};
struct iovec {
  int iov_len;
  int msg_iovlen;
  int msg_namelen;
  int msg_controllen;
  void *msg_control;
  struct sockaddr_in6 *msg_name;
  struct iovec *msg_iov;
  void *iov_base;
};

/* Variables and functions */
int /*<<< orphan*/ memset(struct msghdr *, int /*<<< orphan*/, int);
void msghdr_create(struct msghdr *m, struct iovec *iov, void *buffer,
                   int buflen, void *control_buf, int control_len,
                   struct sockaddr_in6 *saddr) {
  memset(m, 0, sizeof(struct msghdr));
  memset(iov, 0, sizeof(struct iovec));
  iov[0].iov_base = buffer;
  iov[0].iov_len = buflen;
  m->msg_iov = iov;
  m->msg_iovlen = 1;
  m->msg_name = saddr;
  m->msg_namelen = sizeof(struct sockaddr_in6);
  m->msg_control = control_buf;
  m->msg_controllen = control_len;
}


x86 assembly (clang, -O0):
<msghdr_create>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    0x10(%rbp),%rax
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    %r8,-0x28(%rbp)
mov    %r9d,-0x2c(%rbp)
mov    -0x8(%rbp),%rdi
xor    %esi,%esi
mov    $0x30,%edx
call   1030 <memset@plt>
mov    -0x10(%rbp),%rdi
xor    %esi,%esi
mov    $0x30,%edx
call   1030 <memset@plt>
mov    -0x18(%rbp),%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,0x28(%rax)
mov    -0x1c(%rbp),%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x10(%rbp),%rcx
mov    -0x8(%rbp),%rax
mov    %rcx,0x20(%rax)
mov    -0x8(%rbp),%rax
movl   $0x1,0x4(%rax)
mov    0x10(%rbp),%rcx
mov    -0x8(%rbp),%rax
mov    %rcx,0x18(%rax)
mov    -0x8(%rbp),%rax
movl   $0x4,0x8(%rax)
mov    -0x28(%rbp),%rcx
mov    -0x8(%rbp),%rax
mov    %rcx,0x10(%rax)
mov    -0x2c(%rbp),%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,0xc(%rax)
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<msghdr_create>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %r9d,%r14d
mov    %r8,%r15
mov    %ecx,%r12d
mov    %rdx,%r13
mov    %rsi,%rbp
mov    %rdi,%rbx
xor    %esi,%esi
mov    $0x30,%edx
call   1030 <memset@plt>
mov    %rbp,%rdi
xor    %esi,%esi
mov    $0x30,%edx
call   1030 <memset@plt>
mov    %r13,0x28(%rbp)
mov    %r12d,0x0(%rbp)
mov    %rbp,0x20(%rbx)
movabs $0x400000001,%rax
mov    %rax,0x4(%rbx)
mov    0x40(%rsp),%rax
mov    %rax,0x18(%rbx)
mov    %r15,0x10(%rbx)
mov    %r14d,0xc(%rbx)
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.msghdr = type { i32, i32, i32, i32, i8*, %struct.sockaddr_in6*, %struct.msghdr*, i8* }
%struct.iovec = type { i32, i32, i32, i32, i8*, %struct.sockaddr_in6*, %struct.iovec*, i8* }
%struct.sockaddr_in6 = type { i32 }
define void @msghdr_create(%struct.msghdr* %0, %struct.iovec* %1, i8* %2, i32 %3, i8* %4, i32 %5, %struct.sockaddr_in6* %6) {
%8 = alloca %struct.msghdr*
%9 = alloca %struct.iovec*
%10 = alloca i8*
%11 = alloca i32
%12 = alloca i8*
%13 = alloca i32
%14 = alloca %struct.sockaddr_in6*
store %struct.msghdr* %0, %struct.msghdr** %8
store %struct.iovec* %1, %struct.iovec** %9
store i8* %2, i8** %10
store i32 %3, i32* %11
store i8* %4, i8** %12
store i32 %5, i32* %13
store %struct.sockaddr_in6* %6, %struct.sockaddr_in6** %14
%15 = load %struct.msghdr*, %struct.msghdr** %8
%16 = call i32 @memset(%struct.msghdr* %15, i32 0, i32 48)
%17 = load %struct.iovec*, %struct.iovec** %9
%18 = bitcast %struct.iovec* %17 to %struct.msghdr*
%19 = call i32 @memset(%struct.msghdr* %18, i32 0, i32 48)
%20 = load i8*, i8** %10
%21 = load %struct.iovec*, %struct.iovec** %9
%22 = getelementptr inbounds %struct.iovec, %struct.iovec* %21, i64 0
%23 = getelementptr inbounds %struct.iovec, %struct.iovec* %22, i32 0, i32 7
store i8* %20, i8** %23
%24 = load i32, i32* %11
%25 = load %struct.iovec*, %struct.iovec** %9
%26 = getelementptr inbounds %struct.iovec, %struct.iovec* %25, i64 0
%27 = getelementptr inbounds %struct.iovec, %struct.iovec* %26, i32 0, i32 0
store i32 %24, i32* %27
%28 = load %struct.iovec*, %struct.iovec** %9
%29 = bitcast %struct.iovec* %28 to %struct.msghdr*
%30 = load %struct.msghdr*, %struct.msghdr** %8
%31 = getelementptr inbounds %struct.msghdr, %struct.msghdr* %30, i32 0, i32 6
store %struct.msghdr* %29, %struct.msghdr** %31
%32 = load %struct.msghdr*, %struct.msghdr** %8
%33 = getelementptr inbounds %struct.msghdr, %struct.msghdr* %32, i32 0, i32 1
store i32 1, i32* %33
%34 = load %struct.sockaddr_in6*, %struct.sockaddr_in6** %14
%35 = load %struct.msghdr*, %struct.msghdr** %8
%36 = getelementptr inbounds %struct.msghdr, %struct.msghdr* %35, i32 0, i32 5
store %struct.sockaddr_in6* %34, %struct.sockaddr_in6** %36
%37 = load %struct.msghdr*, %struct.msghdr** %8
%38 = getelementptr inbounds %struct.msghdr, %struct.msghdr* %37, i32 0, i32 2
store i32 4, i32* %38
%39 = load i8*, i8** %12
%40 = load %struct.msghdr*, %struct.msghdr** %8
%41 = getelementptr inbounds %struct.msghdr, %struct.msghdr* %40, i32 0, i32 4
store i8* %39, i8** %41
%42 = load i32, i32* %13
%43 = load %struct.msghdr*, %struct.msghdr** %8
%44 = getelementptr inbounds %struct.msghdr, %struct.msghdr* %43, i32 0, i32 3
store i32 %42, i32* %44
ret void
}

LLVM IR (-O2):
%struct.msghdr = type { i32, i32, i32, i32, i8*, %struct.sockaddr_in6*, %struct.msghdr*, i8* }
%struct.iovec = type { i32, i32, i32, i32, i8*, %struct.sockaddr_in6*, %struct.iovec*, i8* }
%struct.sockaddr_in6 = type { i32 }
define void @msghdr_create(%struct.msghdr* %0, %struct.iovec* %1, i8* %2, i32 %3, i8* %4, i32 %5, %struct.sockaddr_in6* %6) {
%8 = tail call i32 @memset(%struct.msghdr* %0, i32 0, i32 48)
%9 = bitcast %struct.iovec* %1 to %struct.msghdr*
%10 = tail call i32 @memset(%struct.msghdr* %9, i32 0, i32 48)
%11 = getelementptr inbounds %struct.iovec, %struct.iovec* %1, i64 0, i32 7
store i8* %2, i8** %11
%12 = getelementptr inbounds %struct.iovec, %struct.iovec* %1, i64 0, i32 0
store i32 %3, i32* %12
%13 = getelementptr inbounds %struct.msghdr, %struct.msghdr* %0, i64 0, i32 6
%14 = bitcast %struct.msghdr** %13 to %struct.iovec**
store %struct.iovec* %1, %struct.iovec** %14
%15 = getelementptr inbounds %struct.msghdr, %struct.msghdr* %0, i64 0, i32 1
store i32 1, i32* %15
%16 = getelementptr inbounds %struct.msghdr, %struct.msghdr* %0, i64 0, i32 5
store %struct.sockaddr_in6* %6, %struct.sockaddr_in6** %16
%17 = getelementptr inbounds %struct.msghdr, %struct.msghdr* %0, i64 0, i32 2
store i32 4, i32* %17
%18 = getelementptr inbounds %struct.msghdr, %struct.msghdr* %0, i64 0, i32 4
store i8* %4, i8** %18
%19 = getelementptr inbounds %struct.msghdr, %struct.msghdr* %0, i64 0, i32 3
store i32 %5, i32* %19
ret void
}