#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 {
  TYPE_1__ sin_addr;
  int /*<<< orphan*/ sin_port;
  int /*<<< orphan*/ sin_family;
};
struct sockaddr {
  int dummy;
};
typedef int /*<<< orphan*/ address;

/* Variables and functions */
int /*<<< orphan*/ AF_INET;
int /*<<< orphan*/ bzero(struct sockaddr_in *, int);
int /*<<< orphan*/ htons(int);
int /*<<< orphan*/ inet_addr(char *);
scalar_t__ sendto(int, char *, size_t, int /*<<< orphan*/, struct sockaddr *,
                  int);
int srcUdpSocket_sent_to(int socketFD, char *msg, int len, char *desAddress,
                         int desPort) {
  struct sockaddr_in address;
  bzero(&address, sizeof(struct sockaddr_in));
  address.sin_family = AF_INET;
  address.sin_port = htons(desPort);
  address.sin_addr.s_addr = inet_addr(desAddress);
  int sendLen = (int)sendto(socketFD, msg, (size_t)len, 0,
                            (struct sockaddr *)&address, sizeof(address));
  return sendLen;
}


x86 assembly (clang, -O0):
<srcUdpSocket_sent_to>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8d,-0x24(%rbp)
lea    -0x30(%rbp),%rdi
mov    $0xc,%esi
call   1060 <bzero@plt>
mov    0x2e79(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x28(%rbp)
mov    -0x24(%rbp),%edi
call   1030 <htons@plt>
mov    %eax,-0x2c(%rbp)
mov    -0x20(%rbp),%rdi
call   1050 <inet_addr@plt>
mov    %eax,-0x30(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%rsi
movslq -0x14(%rbp),%rdx
lea    -0x30(%rbp),%r8
xor    %ecx,%ecx
mov    $0xc,%r9d
call   1040 <sendto@plt>
mov    %eax,-0x34(%rbp)
mov    -0x34(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<srcUdpSocket_sent_to>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %r8d,%ebx
mov    %rcx,%r14
mov    %edx,%ebp
mov    %rsi,%r15
mov    %edi,%r12d
lea    0x8(%rsp),%r13
mov    %r13,%rdi
mov    $0xc,%esi
call   1060 <bzero@plt>
mov    0x2e73(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x10(%rsp)
mov    %ebx,%edi
call   1030 <htons@plt>
mov    %eax,0xc(%rsp)
mov    %r14,%rdi
call   1050 <inet_addr@plt>
mov    %eax,0x8(%rsp)
movslq %ebp,%rdx
mov    %r12d,%edi
mov    %r15,%rsi
xor    %ecx,%ecx
mov    %r13,%r8
mov    $0xc,%r9d
call   1040 <sendto@plt>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.sockaddr_in = type { %struct.TYPE_2__, i32, i32 }
%struct.TYPE_2__ = type { i32 }
%struct.sockaddr = type { i32 }
@AF_INET = global i32 0
define i32 @srcUdpSocket_sent_to(i32 %0, i8* %1, i32 %2, i8* %3, i32 %4) {
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i32
%9 = alloca i8*
%10 = alloca i32
%11 = alloca %struct.sockaddr_in
%12 = alloca i32
store i32 %0, i32* %6
store i8* %1, i8** %7
store i32 %2, i32* %8
store i8* %3, i8** %9
store i32 %4, i32* %10
%13 = call i32 @bzero(%struct.sockaddr_in* %11, i32 12)
%14 = load i32, i32* @AF_INET
%15 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %11, i32 0, i32 2
store i32 %14, i32* %15
%16 = load i32, i32* %10
%17 = call i32 @htons(i32 %16)
%18 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %11, i32 0, i32 1
store i32 %17, i32* %18
%19 = load i8*, i8** %9
%20 = call i32 @inet_addr(i8* %19)
%21 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %11, i32 0, i32 0
%22 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %21, i32 0, i32 0
store i32 %20, i32* %22
%23 = load i32, i32* %6
%24 = load i8*, i8** %7
%25 = load i32, i32* %8
%26 = sext i32 %25 to i64
%27 = bitcast %struct.sockaddr_in* %11 to %struct.sockaddr*
%28 = call i64 @sendto(i32 %23, i8* %24, i64 %26, i32 0, %struct.sockaddr* %27, i32 12)
%29 = trunc i64 %28 to i32
store i32 %29, i32* %12
%30 = load i32, i32* %12
ret i32 %30
}

LLVM IR (-O2):
%struct.sockaddr_in = type { %struct.TYPE_2__, i32, i32 }
%struct.TYPE_2__ = type { i32 }
%struct.sockaddr = type { i32 }
@AF_INET = global i32 0
define i32 @srcUdpSocket_sent_to(i32 %0, i8* %1, i32 %2, i8* %3, i32 %4) {
%6 = alloca %struct.sockaddr_in
%7 = bitcast %struct.sockaddr_in* %6 to i8*
%8 = call i32 @bzero(%struct.sockaddr_in* %6, i32 12)
%9 = load i32, i32* @AF_INET
%10 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %6, i64 0, i32 2
store i32 %9, i32* %10
%11 = tail call i32 @htons(i32 %4)
%12 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %6, i64 0, i32 1
store i32 %11, i32* %12
%13 = tail call i32 @inet_addr(i8* %3)
%14 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %6, i64 0, i32 0, i32 0
store i32 %13, i32* %14
%15 = sext i32 %2 to i64
%16 = bitcast %struct.sockaddr_in* %6 to %struct.sockaddr*
%17 = call i64 @sendto(i32 %0, i8* %1, i64 %15, i32 0, %struct.sockaddr* %16, i32 12)
%18 = trunc i64 %17 to i32
ret i32 %18
}