#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 */
struct sockaddr_ll {
  int sll_ifindex;
};
struct sockaddr {
  int dummy;
};
typedef int /*<<< orphan*/ sll;

/* Variables and functions */
int /*<<< orphan*/ memset(struct sockaddr_ll *, int /*<<< orphan*/, int);
int sendto(int, void const *, size_t, int /*<<< orphan*/, struct sockaddr *,
           int);
int sendto_l2(int ifidx, int sock, const void *data, size_t len) {
  struct sockaddr_ll sll;
  memset(&sll, 0, sizeof(sll));
  sll.sll_ifindex = ifidx;
  return sendto(sock, data, len, 0, (struct sockaddr *)&sll, sizeof(sll));
}


x86 assembly (clang, -O0):
<sendto_l2>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %rdx,-0x10(%rbp)
mov    %rcx,-0x18(%rbp)
lea    -0x20(%rbp),%rdi
xor    %esi,%esi
mov    $0x4,%edx
call   1030 <memset@plt>
mov    -0x4(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
lea    -0x20(%rbp),%r8
xor    %ecx,%ecx
mov    $0x4,%r9d
call   1040 <sendto@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sendto_l2>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
mov    %rcx,%r14
mov    %rdx,%r15
mov    %esi,%ebp
mov    %edi,%ebx
lea    0x8(%rsp),%r12
mov    %r12,%rdi
xor    %esi,%esi
mov    $0x4,%edx
call   1030 <memset@plt>
mov    %ebx,0x8(%rsp)
mov    %ebp,%edi
mov    %r15,%rsi
mov    %r14,%rdx
xor    %ecx,%ecx
mov    %r12,%r8
mov    $0x4,%r9d
call   1040 <sendto@plt>
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.sockaddr_ll = type { i32 }
%struct.sockaddr = type { i32 }
define i32 @sendto_l2(i32 %0, i32 %1, i8* %2, i64 %3) {
%5 = alloca i32
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i64
%9 = alloca %struct.sockaddr_ll
store i32 %0, i32* %5
store i32 %1, i32* %6
store i8* %2, i8** %7
store i64 %3, i64* %8
%10 = call i32 @memset(%struct.sockaddr_ll* %9, i32 0, i32 4)
%11 = load i32, i32* %5
%12 = getelementptr inbounds %struct.sockaddr_ll, %struct.sockaddr_ll* %9, i32 0, i32 0
store i32 %11, i32* %12
%13 = load i32, i32* %6
%14 = load i8*, i8** %7
%15 = load i64, i64* %8
%16 = bitcast %struct.sockaddr_ll* %9 to %struct.sockaddr*
%17 = call i32 @sendto(i32 %13, i8* %14, i64 %15, i32 0, %struct.sockaddr* %16, i32 4)
ret i32 %17
}

LLVM IR (-O2):
%struct.sockaddr_ll = type { i32 }
%struct.sockaddr = type { i32 }
define i32 @sendto_l2(i32 %0, i32 %1, i8* %2, i64 %3) {
%5 = alloca %struct.sockaddr_ll
%6 = bitcast %struct.sockaddr_ll* %5 to i8*
%7 = call i32 @memset(%struct.sockaddr_ll* %5, i32 0, i32 4)
%8 = getelementptr inbounds %struct.sockaddr_ll, %struct.sockaddr_ll* %5, i64 0, i32 0
store i32 %0, i32* %8
%9 = bitcast %struct.sockaddr_ll* %5 to %struct.sockaddr*
%10 = call i32 @sendto(i32 %1, i8* %2, i64 %3, i32 0, %struct.sockaddr* %9, i32 4)
ret i32 %10
}