#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;
  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_ANY;
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_ANY);
  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;
  sendmsg(sfd, &msg, 0);
  return 0;
}


x86 assembly (clang, -O0):
<execute_sendmsg>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    0x2e79(%rip),%rax
mov    (%rax),%edi
mov    0x2e60(%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    0x2e32(%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,-0x40(%rbp)
lea    -0x10(%rbp),%rax
mov    %rax,-0x18(%rbp)
movl   $0xc,-0x28(%rbp)
lea    -0x38(%rbp),%rax
mov    %rax,-0x20(%rbp)
movl   $0x1,-0x24(%rbp)
mov    -0x40(%rbp),%rcx
mov    -0x20(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x40(%rbp),%rdi
call   1040 <strlen@plt>
mov    %rax,%rcx
add    $0x1,%rcx
mov    -0x20(%rbp),%rax
mov    %rcx,0x8(%rax)
mov    -0x4(%rbp),%edi
lea    -0x28(%rbp),%rsi
xor    %edx,%edx
call   1030 <sendmsg@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<execute_sendmsg>:
push   %r15
push   %r14
push   %rbx
sub    $0x40,%rsp
mov    0x2e88(%rip),%r15
mov    (%r15),%edi
mov    0x2e6e(%rip),%rax
mov    (%rax),%esi
mov    0x2e4d(%rip),%rax
mov    (%rax),%edx
call   1070 <socket@plt>
mov    %eax,%ebx
lea    0x8(%rsp),%r14
mov    %r14,%rdi
xor    %esi,%esi
mov    $0xc,%edx
call   1060 <memset@plt>
mov    (%r15),%eax
mov    %eax,0x10(%rsp)
mov    0x2e42(%rip),%rax
mov    (%rax),%edi
call   1050 <htonl@plt>
mov    %eax,0xc(%rsp)
mov    $0x63f4,%edi
call   1040 <htons@plt>
mov    %eax,0x8(%rsp)
mov    %r14,0x38(%rsp)
movabs $0x10000000c,%rax
mov    %rax,0x28(%rsp)
lea    0x18(%rsp),%rax
mov    %rax,0x30(%rsp)
lea    0xe24(%rip),%rax
mov    %rax,0x18(%rsp)
movq   $0x15,0x20(%rsp)
lea    0x28(%rsp),%rsi
mov    %ebx,%edi
xor    %edx,%edx
call   1030 <sendmsg@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.sockaddr_in = type { i32, %struct.TYPE_2__, i32 }
%struct.TYPE_2__ = type { i32 }
%struct.msghdr = type { i32, i32, %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_ANY = 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_ANY
%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 3
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 2
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 2
%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 2
%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 = load i32, i32* %1
%35 = call i32 @sendmsg(i32 %34, %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, %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_ANY = 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_ANY
%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 3
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 2
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 = call i32 @sendmsg(i32 %7, %struct.msghdr* %2, i32 0)
ret i32 0
}