#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*/ uint8_t;
struct sockaddr_storage {
  int dummy;
};
struct sockaddr_ll {
  int *sll_addr;
  int /*<<< orphan*/ sll_halen;
};
struct sockaddr {
  int dummy;
};
struct ifreq {
  int /*<<< orphan*/ ifr_flags;
  int /*<<< orphan*/ ifr_name;
};
struct ether_header {
  int *ether_dhost;
  int /*<<< orphan*/ ether_type;
};
typedef int /*<<< orphan*/ ssize_t;

/* Variables and functions */
int /*<<< orphan*/ AF_PACKET;
int /*<<< orphan*/ ETH_ALEN;
int /*<<< orphan*/ EXIT_FAILURE;
int /*<<< orphan*/ IFF_PROMISC;
int IFNAMSIZ;
int /*<<< orphan*/ SIOCGIFFLAGS;
int /*<<< orphan*/ SIOCSIFFLAGS;
int /*<<< orphan*/ SOCK_RAW;
int /*<<< orphan*/ SOL_SOCKET;
int /*<<< orphan*/ SO_BINDTODEVICE;
int /*<<< orphan*/ SO_REUSEADDR;
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ htons(int);
int /*<<< orphan*/ ioctl(int, int /*<<< orphan*/, struct ifreq *);
int /*<<< orphan*/ ntohs(int /*<<< orphan*/);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ recvfrom(int, int /*<<< orphan*/ *, int, int /*<<< orphan*/,
                            int /*<<< orphan*/ *, int /*<<< orphan*/ *);
int /*<<< orphan*/ sendto(int, int /*<<< orphan*/ *, int /*<<< orphan*/,
                          int /*<<< orphan*/, struct sockaddr *, int);
int setsockopt(int, int /*<<< orphan*/, int /*<<< orphan*/, ...);
int socket(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ strcpy(char *, char *);
int /*<<< orphan*/ strncpy(int /*<<< orphan*/, char *, int);
int main(int argc, char *argv[]) {
  int sockfd;
  int sockopt;
  ssize_t numbytes;
  struct sockaddr_ll socket_address;
  struct ifreq ifopts;
  struct sockaddr_storage their_addr;
  uint8_t buf[1024];
  char if_name[IFNAMSIZ];
  if (argc > 1)
    strcpy(if_name, argv[1]);
  else
    strcpy(if_name, "ens32");
  struct ether_header *eh = (struct ether_header *)buf;
  sockfd = socket(AF_PACKET, SOCK_RAW, htons(0x0800));
  if (sockfd == -1) {
    perror("socket()");
    exit(EXIT_FAILURE);
  }
  strncpy(ifopts.ifr_name, if_name, IFNAMSIZ - 1);
  ioctl(sockfd, SIOCGIFFLAGS, &ifopts);
  ifopts.ifr_flags |= IFF_PROMISC;
  ioctl(sockfd, SIOCSIFFLAGS, &ifopts);
  if (setsockopt(sockfd, SOL_SOCKET, SO_REUSEADDR, &sockopt, sizeof sockopt) ==
      -1) {
    perror("setsockopt");
    close(sockfd);
    exit(EXIT_FAILURE);
  }
  if (setsockopt(sockfd, SOL_SOCKET, SO_BINDTODEVICE, if_name, IFNAMSIZ - 1) ==
      -1) {
    perror("SO_BINDTODEVICE");
    close(sockfd);
    exit(EXIT_FAILURE);
  }
  while (1) {
    printf("listener: Waiting to recvfrom...\n");
    numbytes = recvfrom(sockfd, buf, 1024, 0, NULL, NULL);
    printf("listener: got packet (0x%04hx) %lu bytes\n", ntohs(eh->ether_type),
           numbytes);
    printf("Destination MAC: %02x:%02x:%02x:%02x:%02x:%02x\n",
           eh->ether_dhost[0], eh->ether_dhost[1], eh->ether_dhost[2],
           eh->ether_dhost[3], eh->ether_dhost[4], eh->ether_dhost[5]);
    socket_address.sll_halen = ETH_ALEN;
    socket_address.sll_addr[0] = eh->ether_dhost[0];
    socket_address.sll_addr[1] = eh->ether_dhost[1];
    socket_address.sll_addr[2] = eh->ether_dhost[2];
    socket_address.sll_addr[3] = eh->ether_dhost[3];
    socket_address.sll_addr[4] = eh->ether_dhost[4];
    socket_address.sll_addr[5] = eh->ether_dhost[5];
    sendto(sockfd, buf, numbytes, 0, (struct sockaddr *)&socket_address,
           sizeof(struct sockaddr_ll) < 0);
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1070,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0x2dc0(%rip),%rax
mov    (%rax),%eax
mov    %rsp,%rcx
mov    %rcx,-0x1048(%rbp)
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x1060(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x1050(%rbp)
cmpl   $0x1,-0x8(%rbp)
jle    1241 <main+0x71>
mov    -0x1060(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
call   1040 <strcpy@plt>
jmp    1254 <main+0x84>
mov    -0x1060(%rbp),%rdi
lea    0xdb1(%rip),%rsi
call   1040 <strcpy@plt>
lea    -0x1040(%rbp),%rax
mov    %rax,-0x1058(%rbp)
mov    0x2d4f(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x1068(%rbp)
mov    0x2d60(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x1064(%rbp)
mov    $0x800,%edi
call   1060 <htons@plt>
mov    -0x1068(%rbp),%edi
mov    -0x1064(%rbp),%esi
mov    %eax,%edx
call   10f0 <socket@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0xffffffff,-0x14(%rbp)
jne    12c4 <main+0xf4>
lea    0xd55(%rip),%rdi
call   10d0 <perror@plt>
mov    0x2ceb(%rip),%rax
mov    (%rax),%edi
call   10e0 <exit@plt>
mov    -0x1060(%rbp),%rsi
mov    -0x34(%rbp),%edi
mov    0x2cdb(%rip),%rax
mov    (%rax),%edx
sub    $0x1,%edx
call   1030 <strncpy@plt>
mov    -0x14(%rbp),%edi
mov    0x2cdf(%rip),%rax
mov    (%rax),%esi
lea    -0x38(%rbp),%rdx
call   1080 <ioctl@plt>
mov    0x2ca5(%rip),%rax
mov    (%rax),%eax
or     -0x38(%rbp),%eax
mov    %eax,-0x38(%rbp)
mov    -0x14(%rbp),%edi
mov    0x2ceb(%rip),%rax
mov    (%rax),%esi
lea    -0x38(%rbp),%rdx
call   1080 <ioctl@plt>
mov    -0x14(%rbp),%edi
mov    0x2cbe(%rip),%rax
mov    (%rax),%esi
mov    0x2c6d(%rip),%rax
mov    (%rax),%edx
lea    -0x18(%rbp),%rcx
mov    $0x4,%r8d
mov    $0x0,%al
call   1050 <setsockopt@plt>
cmp    $0xffffffff,%eax
jne    1369 <main+0x199>
lea    0xcc1(%rip),%rdi
call   10d0 <perror@plt>
mov    -0x14(%rbp),%edi
call   10a0 <close@plt>
mov    0x2c46(%rip),%rax
mov    (%rax),%edi
call   10e0 <exit@plt>
mov    -0x1060(%rbp),%rcx
mov    -0x14(%rbp),%edi
mov    0x2c66(%rip),%rax
mov    (%rax),%esi
mov    0x2c0d(%rip),%rax
mov    (%rax),%edx
mov    0x2c24(%rip),%rax
mov    (%rax),%r8d
sub    $0x1,%r8d
mov    $0x0,%al
call   1050 <setsockopt@plt>
cmp    $0xffffffff,%eax
jne    13c5 <main+0x1f5>
lea    0xc70(%rip),%rdi
call   10d0 <perror@plt>
mov    -0x14(%rbp),%edi
call   10a0 <close@plt>
mov    0x2bea(%rip),%rax
mov    (%rax),%edi
call   10e0 <exit@plt>
jmp    13ca <main+0x1fa>
jmp    13cf <main+0x1ff>
lea    0xc54(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0x14(%rbp),%edi
lea    -0x1040(%rbp),%rsi
mov    $0x400,%edx
xor    %ecx,%ecx
xor    %eax,%eax
mov    %eax,%r9d
mov    %r9,%r8
call   10b0 <recvfrom@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x1058(%rbp),%rax
mov    0x8(%rax),%edi
call   10c0 <ntohs@plt>
mov    %eax,%esi
mov    -0x1c(%rbp),%edx
lea    0xc33(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0x1058(%rbp),%rax
mov    (%rax),%rax
mov    (%rax),%esi
mov    -0x1058(%rbp),%rax
mov    (%rax),%rax
mov    0x4(%rax),%edx
mov    -0x1058(%rbp),%rax
mov    (%rax),%rax
mov    0x8(%rax),%ecx
mov    -0x1058(%rbp),%rax
mov    (%rax),%rax
mov    0xc(%rax),%r8d
mov    -0x1058(%rbp),%rax
mov    (%rax),%rax
mov    0x10(%rax),%r9d
mov    -0x1058(%rbp),%rax
mov    (%rax),%rax
mov    0x14(%rax),%eax
lea    0xc00(%rip),%rdi
sub    $0x10,%rsp
mov    %eax,(%rsp)
mov    $0x0,%al
call   1070 <printf@plt>
add    $0x10,%rsp
mov    0x2b41(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x28(%rbp)
mov    -0x1058(%rbp),%rax
mov    (%rax),%rax
mov    (%rax),%ecx
mov    -0x30(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x1058(%rbp),%rax
mov    (%rax),%rax
mov    0x4(%rax),%ecx
mov    -0x30(%rbp),%rax
mov    %ecx,0x4(%rax)
mov    -0x1058(%rbp),%rax
mov    (%rax),%rax
mov    0x8(%rax),%ecx
mov    -0x30(%rbp),%rax
mov    %ecx,0x8(%rax)
mov    -0x1058(%rbp),%rax
mov    (%rax),%rax
mov    0xc(%rax),%ecx
mov    -0x30(%rbp),%rax
mov    %ecx,0xc(%rax)
mov    -0x1058(%rbp),%rax
mov    (%rax),%rax
mov    0x10(%rax),%ecx
mov    -0x30(%rbp),%rax
mov    %ecx,0x10(%rax)
mov    -0x1058(%rbp),%rax
mov    (%rax),%rax
mov    0x14(%rax),%ecx
mov    -0x30(%rbp),%rax
mov    %ecx,0x14(%rax)
mov    -0x14(%rbp),%edi
lea    -0x1040(%rbp),%rsi
mov    -0x1c(%rbp),%edx
lea    -0x30(%rbp),%r8
xor    %r9d,%r9d
mov    %r9d,%ecx
call   1090 <sendto@plt>
jmp    13ca <main+0x1fa>

x86 assembly (clang, -O2):
<main>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x1028,%rsp
mov    0x2db5(%rip),%r12
mov    (%r12),%eax
mov    %rsp,%r14
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r14
mov    %r14,%rsp
cmp    $0x2,%edi
jl     121b <main+0x3b>
mov    0x8(%rsi),%rsi
jmp    1222 <main+0x42>
lea    0xdde(%rip),%rsi
mov    %r14,%rdi
call   1040 <strcpy@plt>
mov    0x2d87(%rip),%rax
mov    (%rax),%r15d
mov    0x2d9d(%rip),%rax
mov    (%rax),%ebx
mov    $0x800,%edi
call   1070 <htons@plt>
mov    %r15d,%edi
mov    %ebx,%esi
mov    %eax,%edx
call   1100 <socket@plt>
cmp    $0xffffffff,%eax
je     13da <main+0x1fa>
mov    %eax,%r13d
mov    (%r12),%edx
add    $0xffffffff,%edx
mov    %r14,%rsi
call   1030 <strncpy@plt>
mov    0x2d53(%rip),%rax
mov    (%rax),%esi
lea    -0x30(%rbp),%r15
mov    %r13d,%edi
mov    %r15,%rdx
call   1090 <ioctl@plt>
mov    0x2d13(%rip),%rax
mov    (%rax),%eax
or     %eax,-0x30(%rbp)
mov    0x2d5f(%rip),%rax
mov    (%rax),%esi
mov    %r13d,%edi
mov    %r15,%rdx
call   1090 <ioctl@plt>
mov    0x2d33(%rip),%r15
mov    (%r15),%esi
mov    0x2ce1(%rip),%rax
mov    (%rax),%edx
lea    -0x34(%rbp),%rcx
mov    $0x4,%r8d
mov    %r13d,%edi
xor    %eax,%eax
call   1060 <setsockopt@plt>
cmp    $0xffffffff,%eax
je     13e8 <main+0x208>
mov    (%r15),%esi
mov    0x2cb0(%rip),%rax
mov    (%rax),%edx
mov    (%r12),%r8d
add    $0xffffffff,%r8d
mov    %r13d,%edi
mov    %r14,%rcx
xor    %eax,%eax
call   1060 <setsockopt@plt>
cmp    $0xffffffff,%eax
je     13f1 <main+0x211>
lea    -0x1050(%rbp),%r15
lea    -0x48(%rbp),%r14
nopl   0x0(%rax,%rax,1)
lea    0xd6d(%rip),%rdi
call   1050 <puts@plt>
mov    %r13d,%edi
mov    %r15,%rsi
mov    $0x400,%edx
xor    %ecx,%ecx
xor    %r8d,%r8d
xor    %r9d,%r9d
call   10c0 <recvfrom@plt>
mov    %eax,%r12d
mov    -0x1048(%rbp),%edi
call   10d0 <ntohs@plt>
lea    0xce1(%rip),%rdi
mov    %eax,%esi
mov    %r12d,%edx
xor    %eax,%eax
call   1080 <printf@plt>
mov    -0x1050(%rbp),%rax
mov    (%rax),%esi
mov    0x4(%rax),%edx
mov    0x8(%rax),%ecx
mov    0xc(%rax),%r8d
mov    0x10(%rax),%r9d
mov    0x14(%rax),%ebx
sub    $0x8,%rsp
lea    0xcda(%rip),%rdi
xor    %eax,%eax
push   %rbx
call   1080 <printf@plt>
add    $0x10,%rsp
mov    0x2c43(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x40(%rbp)
mov    -0x1050(%rbp),%rax
mov    (%rax),%ecx
mov    -0x48(%rbp),%rdx
mov    %ecx,(%rdx)
mov    0x4(%rax),%ecx
mov    %ecx,0x4(%rdx)
mov    0x8(%rax),%ecx
mov    %ecx,0x8(%rdx)
mov    0xc(%rax),%ecx
mov    %ecx,0xc(%rdx)
mov    0x10(%rax),%ecx
mov    %ecx,0x10(%rdx)
mov    0x14(%rax),%eax
mov    %eax,0x14(%rdx)
mov    %r13d,%edi
mov    %r15,%rsi
mov    %r12d,%edx
xor    %ecx,%ecx
mov    %r14,%r8
xor    %r9d,%r9d
call   10a0 <sendto@plt>
jmp    1310 <main+0x130>
lea    0xc25(%rip),%rdi
call   10e0 <perror@plt>
jmp    1405 <main+0x225>
lea    0xc20(%rip),%rdi
jmp    13f8 <main+0x218>
lea    0xc22(%rip),%rdi
call   10e0 <perror@plt>
mov    %r13d,%edi
call   10b0 <close@plt>
mov    0x2b9c(%rip),%rax
mov    (%rax),%edi
call   10f0 <exit@plt>

LLVM IR (-O0):
%struct.sockaddr_ll = type { i32*, i32 }
%struct.ifreq = type { i32, i32 }
%struct.sockaddr_storage = type { i32 }
%struct.ether_header = type { i32*, i32 }
%struct.sockaddr = type { i32 }
@IFNAMSIZ = global i32 0
@.str = [6 x i8] c"ens32\00"
@AF_PACKET = global i32 0
@SOCK_RAW = global i32 0
@.str.1 = [9 x i8] c"socket()\00"
@EXIT_FAILURE = global i32 0
@SIOCGIFFLAGS = global i32 0
@IFF_PROMISC = global i32 0
@SIOCSIFFLAGS = global i32 0
@SOL_SOCKET = global i32 0
@SO_REUSEADDR = global i32 0
@.str.2 = [11 x i8] c"setsockopt\00"
@SO_BINDTODEVICE = global i32 0
@.str.3 = [16 x i8] c"SO_BINDTODEVICE\00"
@.str.4 = [34 x i8] c"listener: Waiting to recvfrom...\0A\00"
@.str.5 = [42 x i8] c"listener: got packet (0x%04hx) %lu bytes\0A\00"
@.str.6 = [48 x i8] c"Destination MAC: %02x:%02x:%02x:%02x:%02x:%02x\0A\00"
@ETH_ALEN = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca %struct.sockaddr_ll
%10 = alloca %struct.ifreq
%11 = alloca %struct.sockaddr_storage
%12 = alloca [1024 x i32]
%13 = alloca i8*
%14 = alloca i64
%15 = alloca %struct.ether_header*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%16 = load i32, i32* @IFNAMSIZ
%17 = zext i32 %16 to i64
%18 = call i8* @llvm.stacksave()
store i8* %18, i8** %13
%19 = alloca i8, i64 %17
store i64 %17, i64* %14
%20 = load i32, i32* %4
%21 = icmp sgt i32 %20, 1
br i1 %21, label %22, label %27
22: ; preds = %2
%23 = load i8**, i8*** %5
%24 = getelementptr inbounds i8*, i8** %23, i64 1
%25 = load i8*, i8** %24
%26 = call i32 @strcpy(i8* %19, i8* %25)
br label %29
27: ; preds = %2
%28 = call i32 @strcpy(i8* %19, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
br label %29
29: ; preds = %27, %22
%30 = getelementptr inbounds [1024 x i32], [1024 x i32]* %12, i64 0, i64 0
%31 = bitcast i32* %30 to %struct.ether_header*
store %struct.ether_header* %31, %struct.ether_header** %15
%32 = load i32, i32* @AF_PACKET
%33 = load i32, i32* @SOCK_RAW
%34 = call i32 @htons(i32 2048)
%35 = call i32 @socket(i32 %32, i32 %33, i32 %34)
store i32 %35, i32* %6
%36 = load i32, i32* %6
%37 = icmp eq i32 %36, -1
br i1 %37, label %38, label %42
38: ; preds = %29
%39 = call i32 @perror(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
%40 = load i32, i32* @EXIT_FAILURE
%41 = call i32 @exit(i32 %40)
unreachable
42: ; preds = %29
%43 = getelementptr inbounds %struct.ifreq, %struct.ifreq* %10, i32 0, i32 1
%44 = load i32, i32* %43
%45 = load i32, i32* @IFNAMSIZ
%46 = sub nsw i32 %45, 1
%47 = call i32 @strncpy(i32 %44, i8* %19, i32 %46)
%48 = load i32, i32* %6
%49 = load i32, i32* @SIOCGIFFLAGS
%50 = call i32 @ioctl(i32 %48, i32 %49, %struct.ifreq* %10)
%51 = load i32, i32* @IFF_PROMISC
%52 = getelementptr inbounds %struct.ifreq, %struct.ifreq* %10, i32 0, i32 0
%53 = load i32, i32* %52
%54 = or i32 %53, %51
store i32 %54, i32* %52
%55 = load i32, i32* %6
%56 = load i32, i32* @SIOCSIFFLAGS
%57 = call i32 @ioctl(i32 %55, i32 %56, %struct.ifreq* %10)
%58 = load i32, i32* %6
%59 = load i32, i32* @SOL_SOCKET
%60 = load i32, i32* @SO_REUSEADDR
%61 = call i32 (i32, i32, i32, ...) @setsockopt(i32 %58, i32 %59, i32 %60, i32* %7, i64 4)
%62 = icmp eq i32 %61, -1
br i1 %62, label %63, label %69
63: ; preds = %42
%64 = call i32 @perror(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0))
%65 = load i32, i32* %6
%66 = call i32 @close(i32 %65)
%67 = load i32, i32* @EXIT_FAILURE
%68 = call i32 @exit(i32 %67)
unreachable
69: ; preds = %42
%70 = load i32, i32* %6
%71 = load i32, i32* @SOL_SOCKET
%72 = load i32, i32* @SO_BINDTODEVICE
%73 = load i32, i32* @IFNAMSIZ
%74 = sub nsw i32 %73, 1
%75 = call i32 (i32, i32, i32, ...) @setsockopt(i32 %70, i32 %71, i32 %72, i8* %19, i32 %74)
%76 = icmp eq i32 %75, -1
br i1 %76, label %77, label %83
77: ; preds = %69
%78 = call i32 @perror(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0))
%79 = load i32, i32* %6
%80 = call i32 @close(i32 %79)
%81 = load i32, i32* @EXIT_FAILURE
%82 = call i32 @exit(i32 %81)
unreachable
83: ; preds = %69
br label %84
84: ; preds = %85, %83
br label %85
85: ; preds = %84
%86 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.4, i64 0, i64 0))
%87 = load i32, i32* %6
%88 = getelementptr inbounds [1024 x i32], [1024 x i32]* %12, i64 0, i64 0
%89 = call i32 @recvfrom(i32 %87, i32* %88, i32 1024, i32 0, i32* null, i32* null)
store i32 %89, i32* %8
%90 = load %struct.ether_header*, %struct.ether_header** %15
%91 = getelementptr inbounds %struct.ether_header, %struct.ether_header* %90, i32 0, i32 1
%92 = load i32, i32* %91
%93 = call i32 @ntohs(i32 %92)
%94 = load i32, i32* %8
%95 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.5, i64 0, i64 0), i32 %93, i32 %94)
%96 = load %struct.ether_header*, %struct.ether_header** %15
%97 = getelementptr inbounds %struct.ether_header, %struct.ether_header* %96, i32 0, i32 0
%98 = load i32*, i32** %97
%99 = getelementptr inbounds i32, i32* %98, i64 0
%100 = load i32, i32* %99
%101 = load %struct.ether_header*, %struct.ether_header** %15
%102 = getelementptr inbounds %struct.ether_header, %struct.ether_header* %101, i32 0, i32 0
%103 = load i32*, i32** %102
%104 = getelementptr inbounds i32, i32* %103, i64 1
%105 = load i32, i32* %104
%106 = load %struct.ether_header*, %struct.ether_header** %15
%107 = getelementptr inbounds %struct.ether_header, %struct.ether_header* %106, i32 0, i32 0
%108 = load i32*, i32** %107
%109 = getelementptr inbounds i32, i32* %108, i64 2
%110 = load i32, i32* %109
%111 = load %struct.ether_header*, %struct.ether_header** %15
%112 = getelementptr inbounds %struct.ether_header, %struct.ether_header* %111, i32 0, i32 0
%113 = load i32*, i32** %112
%114 = getelementptr inbounds i32, i32* %113, i64 3
%115 = load i32, i32* %114
%116 = load %struct.ether_header*, %struct.ether_header** %15
%117 = getelementptr inbounds %struct.ether_header, %struct.ether_header* %116, i32 0, i32 0
%118 = load i32*, i32** %117
%119 = getelementptr inbounds i32, i32* %118, i64 4
%120 = load i32, i32* %119
%121 = load %struct.ether_header*, %struct.ether_header** %15
%122 = getelementptr inbounds %struct.ether_header, %struct.ether_header* %121, i32 0, i32 0
%123 = load i32*, i32** %122
%124 = getelementptr inbounds i32, i32* %123, i64 5
%125 = load i32, i32* %124
%126 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.6, i64 0, i64 0), i32 %100, i32 %105, i32 %110, i32 %115, i32 %120, i32 %125)
%127 = load i32, i32* @ETH_ALEN
%128 = getelementptr inbounds %struct.sockaddr_ll, %struct.sockaddr_ll* %9, i32 0, i32 1
store i32 %127, i32* %128
%129 = load %struct.ether_header*, %struct.ether_header** %15
%130 = getelementptr inbounds %struct.ether_header, %struct.ether_header* %129, i32 0, i32 0
%131 = load i32*, i32** %130
%132 = getelementptr inbounds i32, i32* %131, i64 0
%133 = load i32, i32* %132
%134 = getelementptr inbounds %struct.sockaddr_ll, %struct.sockaddr_ll* %9, i32 0, i32 0
%135 = load i32*, i32** %134
%136 = getelementptr inbounds i32, i32* %135, i64 0
store i32 %133, i32* %136
%137 = load %struct.ether_header*, %struct.ether_header** %15
%138 = getelementptr inbounds %struct.ether_header, %struct.ether_header* %137, i32 0, i32 0
%139 = load i32*, i32** %138
%140 = getelementptr inbounds i32, i32* %139, i64 1
%141 = load i32, i32* %140
%142 = getelementptr inbounds %struct.sockaddr_ll, %struct.sockaddr_ll* %9, i32 0, i32 0
%143 = load i32*, i32** %142
%144 = getelementptr inbounds i32, i32* %143, i64 1
store i32 %141, i32* %144
%145 = load %struct.ether_header*, %struct.ether_header** %15
%146 = getelementptr inbounds %struct.ether_header, %struct.ether_header* %145, i32 0, i32 0
%147 = load i32*, i32** %146
%148 = getelementptr inbounds i32, i32* %147, i64 2
%149 = load i32, i32* %148
%150 = getelementptr inbounds %struct.sockaddr_ll, %struct.sockaddr_ll* %9, i32 0, i32 0
%151 = load i32*, i32** %150
%152 = getelementptr inbounds i32, i32* %151, i64 2
store i32 %149, i32* %152
%153 = load %struct.ether_header*, %struct.ether_header** %15
%154 = getelementptr inbounds %struct.ether_header, %struct.ether_header* %153, i32 0, i32 0
%155 = load i32*, i32** %154
%156 = getelementptr inbounds i32, i32* %155, i64 3
%157 = load i32, i32* %156
%158 = getelementptr inbounds %struct.sockaddr_ll, %struct.sockaddr_ll* %9, i32 0, i32 0
%159 = load i32*, i32** %158
%160 = getelementptr inbounds i32, i32* %159, i64 3
store i32 %157, i32* %160
%161 = load %struct.ether_header*, %struct.ether_header** %15
%162 = getelementptr inbounds %struct.ether_header, %struct.ether_header* %161, i32 0, i32 0
%163 = load i32*, i32** %162
%164 = getelementptr inbounds i32, i32* %163, i64 4
%165 = load i32, i32* %164
%166 = getelementptr inbounds %struct.sockaddr_ll, %struct.sockaddr_ll* %9, i32 0, i32 0
%167 = load i32*, i32** %166
%168 = getelementptr inbounds i32, i32* %167, i64 4
store i32 %165, i32* %168
%169 = load %struct.ether_header*, %struct.ether_header** %15
%170 = getelementptr inbounds %struct.ether_header, %struct.ether_header* %169, i32 0, i32 0
%171 = load i32*, i32** %170
%172 = getelementptr inbounds i32, i32* %171, i64 5
%173 = load i32, i32* %172
%174 = getelementptr inbounds %struct.sockaddr_ll, %struct.sockaddr_ll* %9, i32 0, i32 0
%175 = load i32*, i32** %174
%176 = getelementptr inbounds i32, i32* %175, i64 5
store i32 %173, i32* %176
%177 = load i32, i32* %6
%178 = getelementptr inbounds [1024 x i32], [1024 x i32]* %12, i64 0, i64 0
%179 = load i32, i32* %8
%180 = bitcast %struct.sockaddr_ll* %9 to %struct.sockaddr*
%181 = call i32 @sendto(i32 %177, i32* %178, i32 %179, i32 0, %struct.sockaddr* %180, i32 0)
br label %84
}

LLVM IR (-O2):
%struct.sockaddr_ll = type { i32*, i32 }
%struct.ifreq = type { i32, i32 }
%struct.sockaddr = type { i32 }
@IFNAMSIZ = global i32 0
@.str = [6 x i8] c"ens32\00"
@AF_PACKET = global i32 0
@SOCK_RAW = global i32 0
@.str.1 = [9 x i8] c"socket()\00"
@EXIT_FAILURE = global i32 0
@SIOCGIFFLAGS = global i32 0
@IFF_PROMISC = global i32 0
@SIOCSIFFLAGS = global i32 0
@SOL_SOCKET = global i32 0
@SO_REUSEADDR = global i32 0
@.str.2 = [11 x i8] c"setsockopt\00"
@SO_BINDTODEVICE = global i32 0
@.str.3 = [16 x i8] c"SO_BINDTODEVICE\00"
@.str.5 = [42 x i8] c"listener: got packet (0x%04hx) %lu bytes\0A\00"
@.str.6 = [48 x i8] c"Destination MAC: %02x:%02x:%02x:%02x:%02x:%02x\0A\00"
@ETH_ALEN = global i32 0
@str = [33 x i8] c"listener: Waiting to recvfrom...\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i32
%4 = alloca %struct.sockaddr_ll
%5 = alloca %struct.ifreq
%6 = alloca [1024 x i32]
%7 = bitcast i32* %3 to i8*
%8 = bitcast %struct.sockaddr_ll* %4 to i8*
%9 = bitcast %struct.ifreq* %5 to i8*
%10 = bitcast [1024 x i32]* %6 to i8*
%11 = load i32, i32* @IFNAMSIZ
%12 = zext i32 %11 to i64
%13 = alloca i8, i64 %12
%14 = icmp sgt i32 %0, 1
br i1 %14, label %15, label %18
15: ; preds = %2
%16 = getelementptr inbounds i8*, i8** %1, i64 1
%17 = load i8*, i8** %16
br label %18
18: ; preds = %2, %15
%19 = phi i8* [ %17, %15 ], [ getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), %2 ]
%20 = call i32 @strcpy(i8* %13, i8* %19)
%21 = getelementptr inbounds [1024 x i32], [1024 x i32]* %6, i64 0, i64 0
%22 = load i32, i32* @AF_PACKET
%23 = load i32, i32* @SOCK_RAW
%24 = call i32 @htons(i32 2048)
%25 = call i32 @socket(i32 %22, i32 %23, i32 %24)
%26 = icmp eq i32 %25, -1
br i1 %26, label %27, label %31
27: ; preds = %18
%28 = call i32 @perror(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
%29 = load i32, i32* @EXIT_FAILURE
%30 = call i32 @exit(i32 %29)
unreachable
31: ; preds = %18
%32 = load i32, i32* @IFNAMSIZ
%33 = add nsw i32 %32, -1
%34 = call i32 @strncpy(i32 undef, i8* %13, i32 %33)
%35 = load i32, i32* @SIOCGIFFLAGS
%36 = call i32 @ioctl(i32 %25, i32 %35, %struct.ifreq* %5)
%37 = load i32, i32* @IFF_PROMISC
%38 = getelementptr inbounds %struct.ifreq, %struct.ifreq* %5, i64 0, i32 0
%39 = load i32, i32* %38
%40 = or i32 %39, %37
store i32 %40, i32* %38
%41 = load i32, i32* @SIOCSIFFLAGS
%42 = call i32 @ioctl(i32 %25, i32 %41, %struct.ifreq* %5)
%43 = load i32, i32* @SOL_SOCKET
%44 = load i32, i32* @SO_REUSEADDR
%45 = call i32 (i32, i32, i32, ...) @setsockopt(i32 %25, i32 %43, i32 %44, i32* %3, i64 4)
%46 = icmp eq i32 %45, -1
br i1 %46, label %47, label %52
47: ; preds = %31
%48 = call i32 @perror(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0))
%49 = call i32 @close(i32 %25)
%50 = load i32, i32* @EXIT_FAILURE
%51 = call i32 @exit(i32 %50)
unreachable
52: ; preds = %31
%53 = load i32, i32* @SOL_SOCKET
%54 = load i32, i32* @SO_BINDTODEVICE
%55 = load i32, i32* @IFNAMSIZ
%56 = add nsw i32 %55, -1
%57 = call i32 (i32, i32, i32, ...) @setsockopt(i32 %25, i32 %53, i32 %54, i8* %13, i32 %56)
%58 = icmp eq i32 %57, -1
br i1 %58, label %65, label %59
59: ; preds = %52
%60 = getelementptr inbounds [1024 x i32], [1024 x i32]* %6, i64 0, i64 2
%61 = bitcast [1024 x i32]* %6 to i32**
%62 = getelementptr inbounds %struct.sockaddr_ll, %struct.sockaddr_ll* %4, i64 0, i32 1
%63 = getelementptr inbounds %struct.sockaddr_ll, %struct.sockaddr_ll* %4, i64 0, i32 0
%64 = bitcast %struct.sockaddr_ll* %4 to %struct.sockaddr*
br label %70
65: ; preds = %52
%66 = call i32 @perror(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0))
%67 = call i32 @close(i32 %25)
%68 = load i32, i32* @EXIT_FAILURE
%69 = call i32 @exit(i32 %68)
unreachable
70: ; preds = %59, %70
%71 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @str, i64 0, i64 0))
%72 = call i32 @recvfrom(i32 %25, i32* %21, i32 1024, i32 0, i32* null, i32* null)
%73 = load i32, i32* %60
%74 = call i32 @ntohs(i32 %73)
%75 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([42 x i8], [42 x i8]* @.str.5, i64 0, i64 0), i32 %74, i32 %72)
%76 = load i32*, i32** %61
%77 = load i32, i32* %76
%78 = getelementptr inbounds i32, i32* %76, i64 1
%79 = load i32, i32* %78
%80 = getelementptr inbounds i32, i32* %76, i64 2
%81 = load i32, i32* %80
%82 = getelementptr inbounds i32, i32* %76, i64 3
%83 = load i32, i32* %82
%84 = getelementptr inbounds i32, i32* %76, i64 4
%85 = load i32, i32* %84
%86 = getelementptr inbounds i32, i32* %76, i64 5
%87 = load i32, i32* %86
%88 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([48 x i8], [48 x i8]* @.str.6, i64 0, i64 0), i32 %77, i32 %79, i32 %81, i32 %83, i32 %85, i32 %87)
%89 = load i32, i32* @ETH_ALEN
store i32 %89, i32* %62
%90 = load i32*, i32** %61
%91 = load i32, i32* %90
%92 = load i32*, i32** %63
store i32 %91, i32* %92
%93 = getelementptr inbounds i32, i32* %90, i64 1
%94 = load i32, i32* %93
%95 = getelementptr inbounds i32, i32* %92, i64 1
store i32 %94, i32* %95
%96 = getelementptr inbounds i32, i32* %90, i64 2
%97 = load i32, i32* %96
%98 = getelementptr inbounds i32, i32* %92, i64 2
store i32 %97, i32* %98
%99 = getelementptr inbounds i32, i32* %90, i64 3
%100 = load i32, i32* %99
%101 = getelementptr inbounds i32, i32* %92, i64 3
store i32 %100, i32* %101
%102 = getelementptr inbounds i32, i32* %90, i64 4
%103 = load i32, i32* %102
%104 = getelementptr inbounds i32, i32* %92, i64 4
store i32 %103, i32* %104
%105 = getelementptr inbounds i32, i32* %90, i64 5
%106 = load i32, i32* %105
%107 = getelementptr inbounds i32, i32* %92, i64 5
store i32 %106, i32* %107
%108 = call i32 @sendto(i32 %25, i32* %21, i32 %72, i32 0, %struct.sockaddr* %64, i32 0)
br label %70
}