#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 */
typedef int /*<<< orphan*/ uint32_t;
typedef int /*<<< orphan*/ uint16_t;
struct sockaddr_in {
  int /*<<< orphan*/ sin_addr;
  int /*<<< orphan*/ sin_port;
  int /*<<< orphan*/ sin_family;
};

/* Variables and functions */
int /*<<< orphan*/ AF_INET;
int /*<<< orphan*/ bz(struct sockaddr_in *, int);
size_t sendto(int, char const *, size_t, int /*<<< orphan*/, void *, int);
int /*<<< orphan*/ u16_pb(char *, int /*<<< orphan*/);
size_t sck_send4(int s, const char *b, size_t l, const char ip[4], uint16_t p) {
  struct sockaddr_in si;
  bz(&si, sizeof si);
  si.sin_family = AF_INET;
  u16_pb((char *)&si.sin_port, p);
  *((uint32_t *)&si.sin_addr) = *((uint32_t *)ip);
  return sendto(s, b, l, 0, (void *)&si, sizeof si);
}


x86 assembly (clang, -O0):
<sck_send4>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8d,-0x24(%rbp)
lea    -0x30(%rbp),%rdi
mov    $0xc,%esi
call   1050 <bz@plt>
mov    0x2e88(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x28(%rbp)
lea    -0x30(%rbp),%rdi
add    $0x4,%rdi
mov    -0x24(%rbp),%esi
call   1040 <u16_pb@plt>
mov    -0x20(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x30(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
lea    -0x30(%rbp),%r8
xor    %ecx,%ecx
mov    $0xc,%r9d
call   1030 <sendto@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sck_send4>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %r8d,%ebx
mov    %rcx,%r14
mov    %rdx,%r15
mov    %rsi,%r12
mov    %edi,%ebp
lea    0x8(%rsp),%r13
mov    %r13,%rdi
mov    $0xc,%esi
call   1050 <bz@plt>
mov    0x2e83(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x10(%rsp)
lea    0xc(%rsp),%rdi
mov    %ebx,%esi
call   1040 <u16_pb@plt>
mov    (%r14),%eax
mov    %eax,0x8(%rsp)
mov    %ebp,%edi
mov    %r12,%rsi
mov    %r15,%rdx
xor    %ecx,%ecx
mov    %r13,%r8
mov    $0xc,%r9d
call   1030 <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 { i32, i32, i32 }
@AF_INET = global i32 0
define i64 @sck_send4(i32 %0, i8* %1, i64 %2, i8* %3, i32 %4) {
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i64
%9 = alloca i8*
%10 = alloca i32
%11 = alloca %struct.sockaddr_in
store i32 %0, i32* %6
store i8* %1, i8** %7
store i64 %2, i64* %8
store i8* %3, i8** %9
store i32 %4, i32* %10
%12 = call i32 @bz(%struct.sockaddr_in* %11, i32 12)
%13 = load i32, i32* @AF_INET
%14 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %11, i32 0, i32 2
store i32 %13, i32* %14
%15 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %11, i32 0, i32 1
%16 = bitcast i32* %15 to i8*
%17 = load i32, i32* %10
%18 = call i32 @u16_pb(i8* %16, i32 %17)
%19 = load i8*, i8** %9
%20 = bitcast i8* %19 to i32*
%21 = load i32, i32* %20
%22 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %11, i32 0, i32 0
store i32 %21, i32* %22
%23 = load i32, i32* %6
%24 = load i8*, i8** %7
%25 = load i64, i64* %8
%26 = bitcast %struct.sockaddr_in* %11 to i8*
%27 = call i64 @sendto(i32 %23, i8* %24, i64 %25, i32 0, i8* %26, i32 12)
ret i64 %27
}

LLVM IR (-O2):
%struct.sockaddr_in = type { i32, i32, i32 }
@AF_INET = global i32 0
define i64 @sck_send4(i32 %0, i8* %1, i64 %2, i8* nocapture %3, i32 %4) {
%6 = alloca %struct.sockaddr_in
%7 = bitcast %struct.sockaddr_in* %6 to i8*
%8 = call i32 @bz(%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 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %6, i64 0, i32 1
%12 = bitcast i32* %11 to i8*
%13 = call i32 @u16_pb(i8* %12, i32 %4)
%14 = bitcast i8* %3 to i32*
%15 = load i32, i32* %14
%16 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %6, i64 0, i32 0
store i32 %15, i32* %16
%17 = call i64 @sendto(i32 %0, i8* %1, i64 %2, i32 0, i8* %7, i32 12)
ret i64 %17
}