#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;
  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 /*<<< orphan*/, int);
int /*<<< orphan*/ sendmsg(int, struct msghdr *, int /*<<< orphan*/);
void sender(int fd) {
  struct msghdr mh;
  struct iovec iov[1];
  memset(&mh, 0, sizeof(mh));
  iov[0].iov_base = "123456789+";
  iov[0].iov_len = sizeof("123456789+");
  mh.msg_iov = &iov[0];
  mh.msg_iovlen = 1;
  (void)sendmsg(fd, &mh, 0);
  (void)sendmsg(fd, &mh, 0);
}


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

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

LLVM IR (-O0):
%struct.msghdr = type { i32, %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 16)
%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 1
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 = load i32, i32* %2
%14 = call i32 @sendmsg(i32 %13, %struct.msghdr* %3, i32 0)
%15 = load i32, i32* %2
%16 = call i32 @sendmsg(i32 %15, %struct.msghdr* %3, i32 0)
ret void
}

LLVM IR (-O2):
%struct.msghdr = type { i32, %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 16)
%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 1
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 = call i32 @sendmsg(i32 %0, %struct.msghdr* %2, i32 0)
%13 = call i32 @sendmsg(i32 %0, %struct.msghdr* %2, i32 0)
ret void
}