#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 msghdr {
  int msg_iovlen;
  scalar_t__ msg_controllen;
  int /*<<< orphan*/ *msg_control;
  scalar_t__ msg_flags;
  struct iovec *msg_iov;
};
struct iovec {
  char *iov_base;
  int iov_len;
};
typedef int /*<<< orphan*/ mh;

/* Variables and functions */
int /*<<< orphan*/ memset(struct msghdr *, int, int);
int /*<<< orphan*/ sendmsg(int, struct msghdr *, int /*<<< orphan*/);
void sender(int fd) {
  struct msghdr mh;
  struct iovec iov[1];
  memset(&mh, 0x00, sizeof(mh));
  iov[0].iov_base = "123456789+";
  iov[0].iov_len = sizeof("123456789+");
  mh.msg_iov = iov;
  mh.msg_iovlen = 1;
  mh.msg_flags = 0;
  mh.msg_control = NULL;
  mh.msg_controllen = 0;
  (void)sendmsg(fd, &mh, 0);
}


x86 assembly (clang, -O0):
<sender>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0x4(%rbp)
lea    -0x30(%rbp),%rdi
xor    %esi,%esi
mov    $0x28,%edx
call   1040 <memset@plt>
lea    0xebe(%rip),%rax
mov    %rax,-0x40(%rbp)
movl   $0xb,-0x38(%rbp)
lea    -0x40(%rbp),%rax
mov    %rax,-0x10(%rbp)
movl   $0x1,-0x30(%rbp)
movq   $0x0,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
movq   $0x0,-0x28(%rbp)
mov    -0x4(%rbp),%edi
lea    -0x30(%rbp),%rsi
xor    %edx,%edx
call   1030 <sendmsg@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sender>:
push   %r14
push   %rbx
sub    $0x38,%rsp
mov    %edi,%ebx
lea    0x10(%rsp),%r14
mov    %r14,%rdi
xor    %esi,%esi
mov    $0x28,%edx
call   1040 <memset@plt>
lea    0xebc(%rip),%rax
mov    %rax,(%rsp)
movl   $0xb,0x8(%rsp)
mov    %rsp,%rax
mov    %rax,0x30(%rsp)
movl   $0x1,0x10(%rsp)
xorps  %xmm0,%xmm0
movups %xmm0,0x18(%rsp)
movq   $0x0,0x28(%rsp)
mov    %ebx,%edi
mov    %r14,%rsi
xor    %edx,%edx
call   1030 <sendmsg@plt>
add    $0x38,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.msghdr = type { i32, i64, i32*, i64, %struct.iovec* }
%struct.iovec = type { i8*, i32 }
@.str = [11 x i8] c"123456789+\00"
define void @sender(i32 %0) {
%2 = alloca i32
%3 = alloca %struct.msghdr
%4 = alloca [1 x %struct.iovec]
store i32 %0, i32* %2
%5 = call i32 @memset(%struct.msghdr* %3, i32 0, i32 40)
%6 = getelementptr inbounds [1 x %struct.iovec], [1 x %struct.iovec]* %4, i64 0, i64 0
%7 = getelementptr inbounds %struct.iovec, %struct.iovec* %6, i32 0, i32 0
store i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8** %7
%8 = getelementptr inbounds [1 x %struct.iovec], [1 x %struct.iovec]* %4, i64 0, i64 0
%9 = getelementptr inbounds %struct.iovec, %struct.iovec* %8, i32 0, i32 1
store i32 11, i32* %9
%10 = getelementptr inbounds [1 x %struct.iovec], [1 x %struct.iovec]* %4, i64 0, i64 0
%11 = getelementptr inbounds %struct.msghdr, %struct.msghdr* %3, i32 0, i32 4
store %struct.iovec* %10, %struct.iovec** %11
%12 = getelementptr inbounds %struct.msghdr, %struct.msghdr* %3, i32 0, i32 0
store i32 1, i32* %12
%13 = getelementptr inbounds %struct.msghdr, %struct.msghdr* %3, i32 0, i32 3
store i64 0, i64* %13
%14 = getelementptr inbounds %struct.msghdr, %struct.msghdr* %3, i32 0, i32 2
store i32* null, i32** %14
%15 = getelementptr inbounds %struct.msghdr, %struct.msghdr* %3, i32 0, i32 1
store i64 0, i64* %15
%16 = load i32, i32* %2
%17 = call i32 @sendmsg(i32 %16, %struct.msghdr* %3, i32 0)
ret void
}

LLVM IR (-O2):
%struct.msghdr = type { i32, i64, i32*, i64, %struct.iovec* }
%struct.iovec = type { i8*, i32 }
@.str = [11 x i8] c"123456789+\00"
define void @sender(i32 %0) {
%2 = alloca %struct.msghdr
%3 = alloca [1 x %struct.iovec]
%4 = bitcast %struct.msghdr* %2 to i8*
%5 = bitcast [1 x %struct.iovec]* %3 to i8*
%6 = call i32 @memset(%struct.msghdr* %2, i32 0, i32 40)
%7 = getelementptr inbounds [1 x %struct.iovec], [1 x %struct.iovec]* %3, i64 0, i64 0
%8 = getelementptr inbounds [1 x %struct.iovec], [1 x %struct.iovec]* %3, i64 0, i64 0, i32 0
store i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8** %8
%9 = getelementptr inbounds [1 x %struct.iovec], [1 x %struct.iovec]* %3, i64 0, i64 0, i32 1
store i32 11, i32* %9
%10 = getelementptr inbounds %struct.msghdr, %struct.msghdr* %2, i64 0, i32 4
store %struct.iovec* %7, %struct.iovec** %10
%11 = getelementptr inbounds %struct.msghdr, %struct.msghdr* %2, i64 0, i32 0
store i32 1, i32* %11
%12 = getelementptr inbounds %struct.msghdr, %struct.msghdr* %2, i64 0, i32 1
%13 = bitcast i64* %12 to i8*
%14 = call i32 @sendmsg(i32 %0, %struct.msghdr* %2, i32 0)
ret void
}