#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 */
struct TYPE_2__ {
  int /*<<< orphan*/ s_addr;
};
struct sockaddr_in {
  int /*<<< orphan*/ sin_port;
  TYPE_1__ sin_addr;
  int /*<<< orphan*/ sin_family;
};
struct msghdr {
  int msg_namelen;
  int msg_iovlen;
  scalar_t__ msg_flags;
  scalar_t__ msg_controllen;
  scalar_t__ msg_control;
  struct iovec *msg_iov;
  struct sockaddr_in *msg_name;
};
struct iovec {
  char *iov_base;
  scalar_t__ iov_len;
};
typedef int /*<<< orphan*/ sin;

/* Variables and functions */
int /*<<< orphan*/ AF_INET;
int /*<<< orphan*/ INADDR_LOOPBACK;
int /*<<< orphan*/ IPPROTO_UDP;
int /*<<< orphan*/ SOCK_DGRAM;
int /*<<< orphan*/ htonl(int /*<<< orphan*/);
int /*<<< orphan*/ htons(int);
int /*<<< orphan*/ memset(void *, int /*<<< orphan*/, int);
int /*<<< orphan*/ sendmsg(int, struct msghdr *, int /*<<< orphan*/);
int socket(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/);
scalar_t__ strlen(char *);
int execute_sendmsg() {
  int sfd = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
  struct sockaddr_in sin;
  memset((void *)&sin, 0, sizeof(sin));
  sin.sin_family = AF_INET;
  sin.sin_addr.s_addr = htonl(INADDR_LOOPBACK);
  sin.sin_port = htons(25588);
  struct msghdr msg;
  struct iovec iov;
  char *message = "Message for sendmsg.";
  msg.msg_name = &sin;
  msg.msg_namelen = sizeof(sin);
  msg.msg_iov = &iov;
  msg.msg_iovlen = 1;
  msg.msg_iov->iov_base = message;
  msg.msg_iov->iov_len = strlen(message) + 1;
  msg.msg_control = 0;
  msg.msg_controllen = 0;
  msg.msg_flags = 0;
  sendmsg(sfd, &msg, 0);
  return 0;
}


x86 assembly (clang, -O0):
<execute_sendmsg>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    0x2e79(%rip),%rax
mov    (%rax),%edi
mov    0x2e68(%rip),%rax
mov    (%rax),%esi
mov    0x2e3f(%rip),%rax
mov    (%rax),%edx
call   1080 <socket@plt>
mov    %eax,-0x4(%rbp)
lea    -0x10(%rbp),%rdi
xor    %esi,%esi
mov    $0xc,%edx
call   1070 <memset@plt>
mov    0x2e46(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x8(%rbp)
mov    0x2e2a(%rip),%rax
mov    (%rax),%edi
call   1060 <htonl@plt>
mov    %eax,-0xc(%rbp)
mov    $0x63f4,%edi
call   1050 <htons@plt>
mov    %eax,-0x10(%rbp)
lea    0xe34(%rip),%rax
mov    %rax,-0x58(%rbp)
lea    -0x10(%rbp),%rax
mov    %rax,-0x18(%rbp)
movl   $0xc,-0x40(%rbp)
lea    -0x50(%rbp),%rax
mov    %rax,-0x20(%rbp)
movl   $0x1,-0x3c(%rbp)
mov    -0x58(%rbp),%rcx
mov    -0x20(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x58(%rbp),%rdi
call   1040 <strlen@plt>
mov    %rax,%rcx
add    $0x1,%rcx
mov    -0x20(%rbp),%rax
mov    %rcx,0x8(%rax)
movq   $0x0,-0x28(%rbp)
movq   $0x0,-0x30(%rbp)
movq   $0x0,-0x38(%rbp)
mov    -0x4(%rbp),%edi
lea    -0x40(%rbp),%rsi
xor    %edx,%edx
call   1030 <sendmsg@plt>
xor    %eax,%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<execute_sendmsg>:
push   %rbp
push   %r14
push   %rbx
sub    $0x50,%rsp
mov    0x2e89(%rip),%rbx
mov    (%rbx),%edi
mov    0x2e78(%rip),%rax
mov    (%rax),%esi
mov    0x2e4f(%rip),%rax
mov    (%rax),%edx
call   1070 <socket@plt>
mov    %eax,%ebp
mov    %rsp,%r14
mov    %r14,%rdi
xor    %esi,%esi
mov    $0xc,%edx
call   1060 <memset@plt>
mov    (%rbx),%eax
mov    %eax,0x8(%rsp)
mov    0x2e3f(%rip),%rax
mov    (%rax),%edi
call   1050 <htonl@plt>
mov    %eax,0x4(%rsp)
mov    $0x63f4,%edi
call   1040 <htons@plt>
mov    %eax,(%rsp)
mov    %r14,0x48(%rsp)
movabs $0x10000000c,%rax
mov    %rax,0x20(%rsp)
lea    0x10(%rsp),%rax
mov    %rax,0x40(%rsp)
lea    0xe2a(%rip),%rax
mov    %rax,0x10(%rsp)
movq   $0x15,0x18(%rsp)
xorps  %xmm0,%xmm0
movups %xmm0,0x28(%rsp)
movq   $0x0,0x38(%rsp)
lea    0x20(%rsp),%rsi
mov    %ebp,%edi
xor    %edx,%edx
call   1030 <sendmsg@plt>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
%struct.sockaddr_in = type { i32, %struct.TYPE_2__, i32 }
%struct.TYPE_2__ = type { i32 }
%struct.msghdr = type { i32, i32, i64, i64, i64, %struct.iovec*, %struct.sockaddr_in* }
%struct.iovec = type { i8*, i64 }
@AF_INET = global i32 0
@SOCK_DGRAM = global i32 0
@IPPROTO_UDP = global i32 0
@INADDR_LOOPBACK = global i32 0
@.str = [21 x i8] c"Message for sendmsg.\00"
define i32 @execute_sendmsg() {
%1 = alloca i32
%2 = alloca %struct.sockaddr_in
%3 = alloca %struct.msghdr
%4 = alloca %struct.iovec
%5 = alloca i8*
%6 = load i32, i32* @AF_INET
%7 = load i32, i32* @SOCK_DGRAM
%8 = load i32, i32* @IPPROTO_UDP
%9 = call i32 @socket(i32 %6, i32 %7, i32 %8)
store i32 %9, i32* %1
%10 = bitcast %struct.sockaddr_in* %2 to i8*
%11 = call i32 @memset(i8* %10, i32 0, i32 12)
%12 = load i32, i32* @AF_INET
%13 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %2, i32 0, i32 2
store i32 %12, i32* %13
%14 = load i32, i32* @INADDR_LOOPBACK
%15 = call i32 @htonl(i32 %14)
%16 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %2, i32 0, i32 1
%17 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %16, i32 0, i32 0
store i32 %15, i32* %17
%18 = call i32 @htons(i32 25588)
%19 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %2, i32 0, i32 0
store i32 %18, i32* %19
store i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i8** %5
%20 = getelementptr inbounds %struct.msghdr, %struct.msghdr* %3, i32 0, i32 6
store %struct.sockaddr_in* %2, %struct.sockaddr_in** %20
%21 = getelementptr inbounds %struct.msghdr, %struct.msghdr* %3, i32 0, i32 0
store i32 12, i32* %21
%22 = getelementptr inbounds %struct.msghdr, %struct.msghdr* %3, i32 0, i32 5
store %struct.iovec* %4, %struct.iovec** %22
%23 = getelementptr inbounds %struct.msghdr, %struct.msghdr* %3, i32 0, i32 1
store i32 1, i32* %23
%24 = load i8*, i8** %5
%25 = getelementptr inbounds %struct.msghdr, %struct.msghdr* %3, i32 0, i32 5
%26 = load %struct.iovec*, %struct.iovec** %25
%27 = getelementptr inbounds %struct.iovec, %struct.iovec* %26, i32 0, i32 0
store i8* %24, i8** %27
%28 = load i8*, i8** %5
%29 = call i64 @strlen(i8* %28)
%30 = add nsw i64 %29, 1
%31 = getelementptr inbounds %struct.msghdr, %struct.msghdr* %3, i32 0, i32 5
%32 = load %struct.iovec*, %struct.iovec** %31
%33 = getelementptr inbounds %struct.iovec, %struct.iovec* %32, i32 0, i32 1
store i64 %30, i64* %33
%34 = getelementptr inbounds %struct.msghdr, %struct.msghdr* %3, i32 0, i32 4
store i64 0, i64* %34
%35 = getelementptr inbounds %struct.msghdr, %struct.msghdr* %3, i32 0, i32 3
store i64 0, i64* %35
%36 = getelementptr inbounds %struct.msghdr, %struct.msghdr* %3, i32 0, i32 2
store i64 0, i64* %36
%37 = load i32, i32* %1
%38 = call i32 @sendmsg(i32 %37, %struct.msghdr* %3, i32 0)
ret i32 0
}

LLVM IR (-O2):
%struct.sockaddr_in = type { i32, %struct.TYPE_2__, i32 }
%struct.TYPE_2__ = type { i32 }
%struct.msghdr = type { i32, i32, i64, i64, i64, %struct.iovec*, %struct.sockaddr_in* }
%struct.iovec = type { i8*, i64 }
@AF_INET = global i32 0
@SOCK_DGRAM = global i32 0
@IPPROTO_UDP = global i32 0
@INADDR_LOOPBACK = global i32 0
@.str = [21 x i8] c"Message for sendmsg.\00"
define i32 @execute_sendmsg() {
%1 = alloca %struct.sockaddr_in
%2 = alloca %struct.msghdr
%3 = alloca %struct.iovec
%4 = load i32, i32* @AF_INET
%5 = load i32, i32* @SOCK_DGRAM
%6 = load i32, i32* @IPPROTO_UDP
%7 = tail call i32 @socket(i32 %4, i32 %5, i32 %6)
%8 = bitcast %struct.sockaddr_in* %1 to i8*
%9 = call i32 @memset(i8* %8, i32 0, i32 12)
%10 = load i32, i32* @AF_INET
%11 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %1, i64 0, i32 2
store i32 %10, i32* %11
%12 = load i32, i32* @INADDR_LOOPBACK
%13 = call i32 @htonl(i32 %12)
%14 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %1, i64 0, i32 1, i32 0
store i32 %13, i32* %14
%15 = call i32 @htons(i32 25588)
%16 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %1, i64 0, i32 0
store i32 %15, i32* %16
%17 = bitcast %struct.msghdr* %2 to i8*
%18 = bitcast %struct.iovec* %3 to i8*
%19 = getelementptr inbounds %struct.msghdr, %struct.msghdr* %2, i64 0, i32 6
store %struct.sockaddr_in* %1, %struct.sockaddr_in** %19
%20 = getelementptr inbounds %struct.msghdr, %struct.msghdr* %2, i64 0, i32 0
store i32 12, i32* %20
%21 = getelementptr inbounds %struct.msghdr, %struct.msghdr* %2, i64 0, i32 5
store %struct.iovec* %3, %struct.iovec** %21
%22 = getelementptr inbounds %struct.msghdr, %struct.msghdr* %2, i64 0, i32 1
store i32 1, i32* %22
%23 = getelementptr inbounds %struct.iovec, %struct.iovec* %3, i64 0, i32 0
store i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i8** %23
%24 = getelementptr inbounds %struct.iovec, %struct.iovec* %3, i64 0, i32 1
store i64 21, i64* %24
%25 = getelementptr inbounds %struct.msghdr, %struct.msghdr* %2, i64 0, i32 2
%26 = bitcast i64* %25 to i8*
%27 = call i32 @sendmsg(i32 %7, %struct.msghdr* %2, i32 0)
ret i32 0
}