#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 sockaddr {
  int dummy;
};
typedef int /*<<< orphan*/ dst;

/* Variables and functions */
int /*<<< orphan*/ PF_INET;
int /*<<< orphan*/ atoi(int /*<<< orphan*/);
int /*<<< orphan*/ htons(int /*<<< orphan*/);
int /*<<< orphan*/ inet_addr(int /*<<< orphan*/);
int sendto(int, unsigned char *, int, int /*<<< orphan*/, struct sockaddr *,
           int);
int /*<<< orphan*/ strcpy(char *, char *);
int /*<<< orphan*/ strtok(char *, char *);
int udp_sendto(int sock, char *dest, unsigned char *data, int len) {
  struct sockaddr_in dst;
  char buf[256];
  strcpy(buf, dest);
  dst.sin_family = PF_INET;
  dst.sin_addr.s_addr = inet_addr(strtok(buf, "/"));
  dst.sin_port = htons(atoi(strtok(NULL, "/")));
  return sendto(sock, data, len, 0, (struct sockaddr *)&dst, sizeof(dst));
}


x86 assembly (clang, -O0):
<udp_sendto>:
push   %rbp
mov    %rsp,%rbp
sub    $0x130,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
lea    -0x130(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1030 <strcpy@plt>
mov    0x2e50(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x20(%rbp)
lea    -0x130(%rbp),%rdi
lea    0xe5d(%rip),%rsi
call   1070 <strtok@plt>
mov    %eax,%edi
call   1060 <inet_addr@plt>
mov    %eax,-0x24(%rbp)
xor    %eax,%eax
mov    %eax,%edi
lea    0xe43(%rip),%rsi
call   1070 <strtok@plt>
mov    %eax,%edi
call   1080 <atoi@plt>
mov    %eax,%edi
call   1040 <htons@plt>
mov    %eax,-0x28(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x18(%rbp),%rsi
mov    -0x1c(%rbp),%edx
lea    -0x28(%rbp),%r8
xor    %ecx,%ecx
mov    $0xc,%r9d
call   1050 <sendto@plt>
add    $0x130,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<udp_sendto>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x110,%rsp
mov    %ecx,%r14d
mov    %rdx,%r15
mov    %edi,%r12d
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
call   1030 <strcpy@plt>
mov    0x2e54(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x8(%rsp)
lea    0xe67(%rip),%rbp
mov    %rbx,%rdi
mov    %rbp,%rsi
call   1070 <strtok@plt>
mov    %eax,%edi
call   1060 <inet_addr@plt>
mov    %eax,0x4(%rsp)
xor    %edi,%edi
mov    %rbp,%rsi
call   1070 <strtok@plt>
mov    %eax,%edi
call   1080 <atoi@plt>
mov    %eax,%edi
call   1040 <htons@plt>
mov    %eax,(%rsp)
mov    %rsp,%r8
mov    %r12d,%edi
mov    %r15,%rsi
mov    %r14d,%edx
xor    %ecx,%ecx
mov    $0xc,%r9d
call   1050 <sendto@plt>
add    $0x110,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.sockaddr_in = type { i32, %struct.TYPE_2__, i32 }
%struct.TYPE_2__ = type { i32 }
%struct.sockaddr = type { i32 }
@PF_INET = global i32 0
@.str = [2 x i8] c"/\00"
define i32 @udp_sendto(i32 %0, i8* %1, i8* %2, i32 %3) {
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i32
%9 = alloca %struct.sockaddr_in
%10 = alloca [256 x i8]
store i32 %0, i32* %5
store i8* %1, i8** %6
store i8* %2, i8** %7
store i32 %3, i32* %8
%11 = getelementptr inbounds [256 x i8], [256 x i8]* %10, i64 0, i64 0
%12 = load i8*, i8** %6
%13 = call i32 @strcpy(i8* %11, i8* %12)
%14 = load i32, i32* @PF_INET
%15 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %9, i32 0, i32 2
store i32 %14, i32* %15
%16 = getelementptr inbounds [256 x i8], [256 x i8]* %10, i64 0, i64 0
%17 = call i32 @strtok(i8* %16, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%18 = call i32 @inet_addr(i32 %17)
%19 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %9, i32 0, i32 1
%20 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %19, i32 0, i32 0
store i32 %18, i32* %20
%21 = call i32 @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%22 = call i32 @atoi(i32 %21)
%23 = call i32 @htons(i32 %22)
%24 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %9, i32 0, i32 0
store i32 %23, i32* %24
%25 = load i32, i32* %5
%26 = load i8*, i8** %7
%27 = load i32, i32* %8
%28 = bitcast %struct.sockaddr_in* %9 to %struct.sockaddr*
%29 = call i32 @sendto(i32 %25, i8* %26, i32 %27, i32 0, %struct.sockaddr* %28, i32 12)
ret i32 %29
}

LLVM IR (-O2):
%struct.sockaddr_in = type { i32, %struct.TYPE_2__, i32 }
%struct.TYPE_2__ = type { i32 }
%struct.sockaddr = type { i32 }
@PF_INET = global i32 0
@.str = [2 x i8] c"/\00"
define i32 @udp_sendto(i32 %0, i8* %1, i8* %2, i32 %3) {
%5 = alloca %struct.sockaddr_in
%6 = alloca [256 x i8]
%7 = bitcast %struct.sockaddr_in* %5 to i8*
%8 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i64 0, i64 0
%9 = call i32 @strcpy(i8* %8, i8* %1)
%10 = load i32, i32* @PF_INET
%11 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %5, i64 0, i32 2
store i32 %10, i32* %11
%12 = call i32 @strtok(i8* %8, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%13 = call i32 @inet_addr(i32 %12)
%14 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %5, i64 0, i32 1, i32 0
store i32 %13, i32* %14
%15 = call i32 @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%16 = call i32 @atoi(i32 %15)
%17 = call i32 @htons(i32 %16)
%18 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %5, i64 0, i32 0
store i32 %17, i32* %18
%19 = bitcast %struct.sockaddr_in* %5 to %struct.sockaddr*
%20 = call i32 @sendto(i32 %0, i8* %2, i32 %3, i32 0, %struct.sockaddr* %19, i32 12)
ret i32 %20
}