#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 {
  unsigned int *sll_addr;
  int /*<<< orphan*/ sll_protocol;
  int /*<<< orphan*/ sll_halen;
  int /*<<< orphan*/ sll_ifindex;
  int /*<<< orphan*/ sll_family;
};
struct sockaddr {
  int dummy;
};
struct ifreq {
  int /*<<< orphan*/ ifr_ifindex;
  int /*<<< orphan*/ ifr_name;
};

/* Variables and functions */
int /*<<< orphan*/ AF_PACKET;
int /*<<< orphan*/ ETHER_ADDR_LEN;
int IFNAMSIZ;
int /*<<< orphan*/ SIOCGIFHWADDR;
int /*<<< orphan*/ SIOCGIFINDEX;
int /*<<< orphan*/ SOCK_DGRAM;
scalar_t__ feof(int /*<<< orphan*/);
int fread(void *, int, int, int /*<<< orphan*/);
int /*<<< orphan*/ htons(int);
scalar_t__ ioctl(int, int /*<<< orphan*/, struct ifreq *);
int /*<<< orphan*/ memset(struct ifreq *, int /*<<< orphan*/, int);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, ...);
scalar_t__ sendto(int, char *, int, int /*<<< orphan*/, struct sockaddr *, int);
int socket(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ sscanf(char *, char *, unsigned int *, unsigned int *,
                          unsigned int *, unsigned int *, unsigned int *,
                          unsigned int *);
int /*<<< orphan*/ stdin;
int /*<<< orphan*/ strcpy(char *, char *);
int /*<<< orphan*/ strncpy(int /*<<< orphan*/, char *, int);
int main(int argc, char *argv[]) {
  int sockfd;
  struct ifreq if_idx;
  struct ifreq if_mac;
  char sendbuf[64];
  struct sockaddr_ll socket_address;
  char ifName[IFNAMSIZ];
  unsigned int mac[6] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
  if (argc > 1) {
    strcpy(ifName, argv[1]);
    if (argc > 2) {
      sscanf(argv[2], "%02x:%02x:%02x:%02x:%02x:%02x", &mac[0], &mac[1],
             &mac[2], &mac[3], &mac[4], &mac[5]);
    }
  } else
    strcpy(ifName, "eth0");
  printf("Broadcasting from STDIN to MAC address ");
  printf("%2x:%2x:%2x:%2x:%2x:%2x\n", mac[0], mac[1], mac[2], mac[3], mac[4],
         mac[5]);
  if ((sockfd = socket(AF_PACKET, SOCK_DGRAM, htons(0x88b5))) == -1) {
    perror("Error opening socket");
    return -1;
  }
  memset(&if_idx, 0, sizeof(struct ifreq));
  strncpy(if_idx.ifr_name, ifName, IFNAMSIZ - 1);
  if (ioctl(sockfd, SIOCGIFINDEX, &if_idx) < 0) {
    perror("Error getting interface index");
    return -1;
  }
  memset(&if_mac, 0, sizeof(struct ifreq));
  strncpy(if_mac.ifr_name, ifName, IFNAMSIZ - 1);
  if (ioctl(sockfd, SIOCGIFHWADDR, &if_mac) < 0) {
    perror("Error getting interface MAC address");
    return -1;
  }
  socket_address.sll_family = AF_PACKET;
  socket_address.sll_ifindex = if_idx.ifr_ifindex;
  socket_address.sll_halen = ETHER_ADDR_LEN;
  socket_address.sll_protocol = htons(0x88b5);
  socket_address.sll_addr[0] = mac[0];
  socket_address.sll_addr[1] = mac[1];
  socket_address.sll_addr[2] = mac[2];
  socket_address.sll_addr[3] = mac[3];
  socket_address.sll_addr[4] = mac[4];
  socket_address.sll_addr[5] = mac[5];
  while (1) {
    if (fread((void *)sendbuf, 1, 64, stdin) != 64) {
      if (feof(stdin)) {
        printf("End of input reached\n");
        return 0;
      } else {
        perror("Error reading from stdin");
        return -1;
      }
    }
    if (sendto(sockfd, sendbuf, 64, 0, (struct sockaddr *)&socket_address,
               sizeof(struct sockaddr_ll)) < 0) {
      perror("Error sending packet");
      return -1;
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xd0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0x2dd8(%rip),%rax
mov    (%rax),%eax
mov    %rsp,%rcx
mov    %rcx,-0x90(%rbp)
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0xc0(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x98(%rbp)
mov    0xdeb(%rip),%rax
mov    %rax,-0xb0(%rbp)
mov    0xde5(%rip),%rax
mov    %rax,-0xa8(%rbp)
mov    0xddf(%rip),%rax
mov    %rax,-0xa0(%rbp)
cmpl   $0x1,-0x8(%rbp)
jle    12c8 <main+0x108>
mov    -0xc0(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
call   1040 <strcpy@plt>
cmpl   $0x2,-0x8(%rbp)
jle    12c3 <main+0x103>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    -0xb0(%rbp),%rdx
lea    -0xb0(%rbp),%rcx
add    $0x4,%rcx
lea    -0xb0(%rbp),%r8
add    $0x8,%r8
lea    -0xb0(%rbp),%r9
add    $0xc,%r9
lea    -0xb0(%rbp),%r10
add    $0x10,%r10
lea    -0xb0(%rbp),%rax
add    $0x14,%rax
lea    0xd6b(%rip),%rsi
sub    $0x10,%rsp
mov    %r10,(%rsp)
mov    %rax,0x8(%rsp)
call   10c0 <sscanf@plt>
add    $0x10,%rsp
jmp    12db <main+0x11b>
mov    -0xc0(%rbp),%rdi
lea    0xd60(%rip),%rsi
call   1040 <strcpy@plt>
lea    0xd59(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0xb0(%rbp),%esi
mov    -0xac(%rbp),%edx
mov    -0xa8(%rbp),%ecx
mov    -0xa4(%rbp),%r8d
mov    -0xa0(%rbp),%r9d
mov    -0x9c(%rbp),%eax
lea    0xd4d(%rip),%rdi
sub    $0x10,%rsp
mov    %eax,(%rsp)
mov    $0x0,%al
call   1070 <printf@plt>
add    $0x10,%rsp
mov    0x2c99(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0xc8(%rbp)
mov    0x2c9a(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0xc4(%rbp)
mov    $0x88b5,%edi
call   1060 <htons@plt>
mov    -0xc8(%rbp),%edi
mov    -0xc4(%rbp),%esi
mov    %eax,%edx
call   10e0 <socket@plt>
mov    %eax,-0x14(%rbp)
cmp    $0xffffffff,%eax
jne    1391 <main+0x1d1>
lea    0xd06(%rip),%rdi
call   10d0 <perror@plt>
movl   $0xffffffff,-0x4(%rbp)
movl   $0x1,-0xb4(%rbp)
jmp    15cc <main+0x40c>
lea    -0x20(%rbp),%rdi
xor    %esi,%esi
mov    $0x8,%edx
call   1080 <memset@plt>
mov    -0xc0(%rbp),%rsi
mov    -0x1c(%rbp),%edi
mov    0x2c06(%rip),%rax
mov    (%rax),%edx
sub    $0x1,%edx
call   1030 <strncpy@plt>
mov    -0x14(%rbp),%edi
mov    0x2be2(%rip),%rax
mov    (%rax),%esi
lea    -0x20(%rbp),%rdx
call   1090 <ioctl@plt>
cmp    $0x0,%rax
jge    13fd <main+0x23d>
lea    0xcaf(%rip),%rdi
call   10d0 <perror@plt>
movl   $0xffffffff,-0x4(%rbp)
movl   $0x1,-0xb4(%rbp)
jmp    15cc <main+0x40c>
lea    -0x28(%rbp),%rdi
xor    %esi,%esi
mov    $0x8,%edx
call   1080 <memset@plt>
mov    -0xc0(%rbp),%rsi
mov    -0x24(%rbp),%edi
mov    0x2b9a(%rip),%rax
mov    (%rax),%edx
sub    $0x1,%edx
call   1030 <strncpy@plt>
mov    -0x14(%rbp),%edi
mov    0x2b8e(%rip),%rax
mov    (%rax),%esi
lea    -0x28(%rbp),%rdx
call   1090 <ioctl@plt>
cmp    $0x0,%rax
jge    1469 <main+0x2a9>
lea    0xc61(%rip),%rdi
call   10d0 <perror@plt>
movl   $0xffffffff,-0x4(%rbp)
movl   $0x1,-0xb4(%rbp)
jmp    15cc <main+0x40c>
mov    0x2b58(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x74(%rbp)
mov    -0x20(%rbp),%eax
mov    %eax,-0x78(%rbp)
mov    0x2b6e(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x7c(%rbp)
mov    $0x88b5,%edi
call   1060 <htons@plt>
mov    %eax,-0x80(%rbp)
mov    -0xb0(%rbp),%ecx
mov    -0x88(%rbp),%rax
mov    %ecx,(%rax)
mov    -0xac(%rbp),%ecx
mov    -0x88(%rbp),%rax
mov    %ecx,0x4(%rax)
mov    -0xa8(%rbp),%ecx
mov    -0x88(%rbp),%rax
mov    %ecx,0x8(%rax)
mov    -0xa4(%rbp),%ecx
mov    -0x88(%rbp),%rax
mov    %ecx,0xc(%rax)
mov    -0xa0(%rbp),%ecx
mov    -0x88(%rbp),%rax
mov    %ecx,0x10(%rax)
mov    -0x9c(%rbp),%ecx
mov    -0x88(%rbp),%rax
mov    %ecx,0x14(%rax)
jmp    14f8 <main+0x338>
lea    -0x70(%rbp),%rdi
mov    0x2add(%rip),%rax
mov    (%rax),%ecx
mov    $0x1,%esi
mov    $0x40,%edx
call   1050 <fread@plt>
cmp    $0x40,%eax
je     157b <main+0x3bb>
mov    0x2abc(%rip),%rax
mov    (%rax),%edi
call   10b0 <feof@plt>
cmp    $0x0,%rax
je     1559 <main+0x399>
lea    0xb97(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0xb4(%rbp)
jmp    15cc <main+0x40c>
lea    0xb89(%rip),%rdi
call   10d0 <perror@plt>
movl   $0xffffffff,-0x4(%rbp)
movl   $0x1,-0xb4(%rbp)
jmp    15cc <main+0x40c>
mov    -0x14(%rbp),%edi
lea    -0x70(%rbp),%rsi
lea    -0x88(%rbp),%r8
mov    $0x40,%edx
xor    %ecx,%ecx
mov    $0x18,%r9d
call   10a0 <sendto@plt>
cmp    $0x0,%rax
jge    15c7 <main+0x407>
lea    0xb56(%rip),%rdi
call   10d0 <perror@plt>
movl   $0xffffffff,-0x4(%rbp)
movl   $0x1,-0xb4(%rbp)
jmp    15cc <main+0x40c>
jmp    14f3 <main+0x333>
mov    -0x90(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %rsp,%r12
mov    0x2e1d(%rip),%r13
mov    0x0(%r13),%eax
mov    %rsp,%r15
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r15
mov    %r15,%rsp
mov    0xe49(%rip),%rax
mov    %rax,-0x30(%rbp)
movaps 0xe2e(%rip),%xmm0
movaps %xmm0,-0x40(%rbp)
cmp    $0x2,%edi
jl     1221 <main+0x91>
mov    %rsi,%r14
mov    %edi,%ebx
mov    0x8(%rsi),%rsi
mov    %r15,%rdi
call   1040 <strcpy@plt>
cmp    $0x2,%ebx
je     1230 <main+0xa0>
mov    0x10(%r14),%rdi
lea    -0x3c(%rbp),%rcx
lea    -0x38(%rbp),%r8
lea    -0x34(%rbp),%r9
lea    -0x30(%rbp),%rax
lea    -0x2c(%rbp),%rbx
lea    0xe08(%rip),%rsi
lea    -0x40(%rbp),%rdx
push   %rbx
push   %rax
call   1090 <sscanf@plt>
add    $0x10,%rsp
jmp    1230 <main+0xa0>
lea    0xe0e(%rip),%rsi
mov    %r15,%rdi
call   1040 <strcpy@plt>
lea    0xe04(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    -0x40(%rbp),%esi
mov    -0x3c(%rbp),%edx
mov    -0x38(%rbp),%ecx
mov    -0x34(%rbp),%r8d
mov    -0x30(%rbp),%r9d
mov    -0x2c(%rbp),%ebx
sub    $0x8,%rsp
lea    0xe06(%rip),%rdi
xor    %eax,%eax
push   %rbx
call   1060 <printf@plt>
add    $0x10,%rsp
mov    0x2d68(%rip),%rax
mov    (%rax),%r14d
mov    0x2d6e(%rip),%rax
mov    (%rax),%ebx
mov    $0x88b5,%edi
call   1050 <htons@plt>
mov    %r14d,%edi
mov    %ebx,%esi
mov    %eax,%edx
call   10b0 <socket@plt>
cmp    $0xffffffff,%eax
jne    12a3 <main+0x113>
lea    0xdde(%rip),%rdi
jmp    1332 <main+0x1a2>
mov    %eax,%r14d
lea    -0x50(%rbp),%rbx
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x8,%edx
call   1070 <memset@plt>
mov    -0x4c(%rbp),%edi
mov    0x0(%r13),%edx
add    $0xffffffff,%edx
mov    %r15,%rsi
call   1030 <strncpy@plt>
mov    0x2ce6(%rip),%rax
mov    (%rax),%esi
mov    %r14d,%edi
mov    %rbx,%rdx
call   1080 <ioctl@plt>
test   %rax,%rax
jns    12ed <main+0x15d>
lea    0xda6(%rip),%rdi
jmp    1332 <main+0x1a2>
lea    -0x48(%rbp),%rbx
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x8,%edx
call   1070 <memset@plt>
mov    -0x44(%rbp),%edi
mov    0x0(%r13),%edx
add    $0xffffffff,%edx
mov    %r15,%rsi
call   1030 <strncpy@plt>
mov    0x2cb7(%rip),%rax
mov    (%rax),%esi
mov    %r14d,%edi
mov    %rbx,%rdx
call   1080 <ioctl@plt>
test   %rax,%rax
jns    134e <main+0x1be>
lea    0xd7d(%rip),%rdi
call   10a0 <perror@plt>
mov    %r12,%rsp
mov    $0xffffffff,%eax
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    $0x88b5,%edi
call   1050 <htons@plt>

LLVM IR (-O0):
%struct.ifreq = type { i32, i32 }
%struct.sockaddr_ll = type { i32*, i32, i32, i32, i32 }
%struct.sockaddr = type { i32 }
@IFNAMSIZ = global i32 0
@__const.main.mac = [6 x i32] [i32 255, i32 255, i32 255, i32 255, i32 255, i32 255]
@.str = [30 x i8] c"%02x:%02x:%02x:%02x:%02x:%02x\00"
@.str.1 = [5 x i8] c"eth0\00"
@.str.2 = [40 x i8] c"Broadcasting from STDIN to MAC address \00"
@.str.3 = [25 x i8] c"%2x:%2x:%2x:%2x:%2x:%2x\0A\00"
@AF_PACKET = global i32 0
@SOCK_DGRAM = global i32 0
@.str.4 = [21 x i8] c"Error opening socket\00"
@SIOCGIFINDEX = global i32 0
@.str.5 = [30 x i8] c"Error getting interface index\00"
@SIOCGIFHWADDR = global i32 0
@.str.6 = [36 x i8] c"Error getting interface MAC address\00"
@ETHER_ADDR_LEN = global i32 0
@stdin = global i32 0
@.str.7 = [22 x i8] c"End of input reached\0A\00"
@.str.8 = [25 x i8] c"Error reading from stdin\00"
@.str.9 = [21 x i8] c"Error sending packet\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca %struct.ifreq
%8 = alloca %struct.ifreq
%9 = alloca [64 x i8]
%10 = alloca %struct.sockaddr_ll
%11 = alloca i8*
%12 = alloca i64
%13 = alloca [6 x i32]
%14 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%15 = load i32, i32* @IFNAMSIZ
%16 = zext i32 %15 to i64
%17 = call i8* @llvm.stacksave()
store i8* %17, i8** %11
%18 = alloca i8, i64 %16
store i64 %16, i64* %12
%19 = bitcast [6 x i32]* %13 to i8*
%20 = load i32, i32* %4
%21 = icmp sgt i32 %20, 1
br i1 %21, label %22, label %41
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* %18, i8* %25)
%27 = load i32, i32* %4
%28 = icmp sgt i32 %27, 2
br i1 %28, label %29, label %40
29: ; preds = %22
%30 = load i8**, i8*** %5
%31 = getelementptr inbounds i8*, i8** %30, i64 2
%32 = load i8*, i8** %31
%33 = getelementptr inbounds [6 x i32], [6 x i32]* %13, i64 0, i64 0
%34 = getelementptr inbounds [6 x i32], [6 x i32]* %13, i64 0, i64 1
%35 = getelementptr inbounds [6 x i32], [6 x i32]* %13, i64 0, i64 2
%36 = getelementptr inbounds [6 x i32], [6 x i32]* %13, i64 0, i64 3
%37 = getelementptr inbounds [6 x i32], [6 x i32]* %13, i64 0, i64 4
%38 = getelementptr inbounds [6 x i32], [6 x i32]* %13, i64 0, i64 5
%39 = call i32 @sscanf(i8* %32, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), i32* %33, i32* %34, i32* %35, i32* %36, i32* %37, i32* %38)
br label %40
40: ; preds = %29, %22
br label %43
41: ; preds = %2
%42 = call i32 @strcpy(i8* %18, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
br label %43
43: ; preds = %41, %40
%44 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.2, i64 0, i64 0))
%45 = getelementptr inbounds [6 x i32], [6 x i32]* %13, i64 0, i64 0
%46 = load i32, i32* %45
%47 = getelementptr inbounds [6 x i32], [6 x i32]* %13, i64 0, i64 1
%48 = load i32, i32* %47
%49 = getelementptr inbounds [6 x i32], [6 x i32]* %13, i64 0, i64 2
%50 = load i32, i32* %49
%51 = getelementptr inbounds [6 x i32], [6 x i32]* %13, i64 0, i64 3
%52 = load i32, i32* %51
%53 = getelementptr inbounds [6 x i32], [6 x i32]* %13, i64 0, i64 4
%54 = load i32, i32* %53
%55 = getelementptr inbounds [6 x i32], [6 x i32]* %13, i64 0, i64 5
%56 = load i32, i32* %55
%57 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.3, i64 0, i64 0), i32 %46, i32 %48, i32 %50, i32 %52, i32 %54, i32 %56)
%58 = load i32, i32* @AF_PACKET
%59 = load i32, i32* @SOCK_DGRAM
%60 = call i32 @htons(i32 34997)
%61 = call i32 @socket(i32 %58, i32 %59, i32 %60)
store i32 %61, i32* %6
%62 = icmp eq i32 %61, -1
br i1 %62, label %63, label %65
63: ; preds = %43
%64 = call i32 @perror(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.4, i64 0, i64 0))
store i32 -1, i32* %3
store i32 1, i32* %14
br label %154
65: ; preds = %43
%66 = call i32 @memset(%struct.ifreq* %7, i32 0, i32 8)
%67 = getelementptr inbounds %struct.ifreq, %struct.ifreq* %7, i32 0, i32 1
%68 = load i32, i32* %67
%69 = load i32, i32* @IFNAMSIZ
%70 = sub nsw i32 %69, 1
%71 = call i32 @strncpy(i32 %68, i8* %18, i32 %70)
%72 = load i32, i32* %6
%73 = load i32, i32* @SIOCGIFINDEX
%74 = call i64 @ioctl(i32 %72, i32 %73, %struct.ifreq* %7)
%75 = icmp slt i64 %74, 0
br i1 %75, label %76, label %78
76: ; preds = %65
%77 = call i32 @perror(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.5, i64 0, i64 0))
store i32 -1, i32* %3
store i32 1, i32* %14
br label %154
78: ; preds = %65
%79 = call i32 @memset(%struct.ifreq* %8, i32 0, i32 8)
%80 = getelementptr inbounds %struct.ifreq, %struct.ifreq* %8, i32 0, i32 1
%81 = load i32, i32* %80
%82 = load i32, i32* @IFNAMSIZ
%83 = sub nsw i32 %82, 1
%84 = call i32 @strncpy(i32 %81, i8* %18, i32 %83)
%85 = load i32, i32* %6
%86 = load i32, i32* @SIOCGIFHWADDR
%87 = call i64 @ioctl(i32 %85, i32 %86, %struct.ifreq* %8)
%88 = icmp slt i64 %87, 0
br i1 %88, label %89, label %91
89: ; preds = %78
%90 = call i32 @perror(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.6, i64 0, i64 0))
store i32 -1, i32* %3
store i32 1, i32* %14
br label %154
91: ; preds = %78
%92 = load i32, i32* @AF_PACKET
%93 = getelementptr inbounds %struct.sockaddr_ll, %struct.sockaddr_ll* %10, i32 0, i32 4
store i32 %92, i32* %93
%94 = getelementptr inbounds %struct.ifreq, %struct.ifreq* %7, i32 0, i32 0
%95 = load i32, i32* %94
%96 = getelementptr inbounds %struct.sockaddr_ll, %struct.sockaddr_ll* %10, i32 0, i32 3
store i32 %95, i32* %96
%97 = load i32, i32* @ETHER_ADDR_LEN
%98 = getelementptr inbounds %struct.sockaddr_ll, %struct.sockaddr_ll* %10, i32 0, i32 2
store i32 %97, i32* %98
%99 = call i32 @htons(i32 34997)
%100 = getelementptr inbounds %struct.sockaddr_ll, %struct.sockaddr_ll* %10, i32 0, i32 1
store i32 %99, i32* %100
%101 = getelementptr inbounds [6 x i32], [6 x i32]* %13, i64 0, i64 0
%102 = load i32, i32* %101
%103 = getelementptr inbounds %struct.sockaddr_ll, %struct.sockaddr_ll* %10, i32 0, i32 0
%104 = load i32*, i32** %103
%105 = getelementptr inbounds i32, i32* %104, i64 0
store i32 %102, i32* %105
%106 = getelementptr inbounds [6 x i32], [6 x i32]* %13, i64 0, i64 1
%107 = load i32, i32* %106
%108 = getelementptr inbounds %struct.sockaddr_ll, %struct.sockaddr_ll* %10, i32 0, i32 0
%109 = load i32*, i32** %108
%110 = getelementptr inbounds i32, i32* %109, i64 1
store i32 %107, i32* %110
%111 = getelementptr inbounds [6 x i32], [6 x i32]* %13, i64 0, i64 2
%112 = load i32, i32* %111
%113 = getelementptr inbounds %struct.sockaddr_ll, %struct.sockaddr_ll* %10, i32 0, i32 0
%114 = load i32*, i32** %113
%115 = getelementptr inbounds i32, i32* %114, i64 2
store i32 %112, i32* %115
%116 = getelementptr inbounds [6 x i32], [6 x i32]* %13, i64 0, i64 3
%117 = load i32, i32* %116
%118 = getelementptr inbounds %struct.sockaddr_ll, %struct.sockaddr_ll* %10, i32 0, i32 0
%119 = load i32*, i32** %118
%120 = getelementptr inbounds i32, i32* %119, i64 3
store i32 %117, i32* %120
%121 = getelementptr inbounds [6 x i32], [6 x i32]* %13, i64 0, i64 4
%122 = load i32, i32* %121
%123 = getelementptr inbounds %struct.sockaddr_ll, %struct.sockaddr_ll* %10, i32 0, i32 0
%124 = load i32*, i32** %123
%125 = getelementptr inbounds i32, i32* %124, i64 4
store i32 %122, i32* %125
%126 = getelementptr inbounds [6 x i32], [6 x i32]* %13, i64 0, i64 5
%127 = load i32, i32* %126
%128 = getelementptr inbounds %struct.sockaddr_ll, %struct.sockaddr_ll* %10, i32 0, i32 0
%129 = load i32*, i32** %128
%130 = getelementptr inbounds i32, i32* %129, i64 5
store i32 %127, i32* %130
br label %131
131: ; preds = %153, %91
br label %132
132: ; preds = %131
%133 = getelementptr inbounds [64 x i8], [64 x i8]* %9, i64 0, i64 0
%134 = load i32, i32* @stdin
%135 = call i32 @fread(i8* %133, i32 1, i32 64, i32 %134)
%136 = icmp ne i32 %135, 64
br i1 %136, label %137, label %145
137: ; preds = %132
%138 = load i32, i32* @stdin
%139 = call i64 @feof(i32 %138)
%140 = icmp ne i64 %139, 0
br i1 %140, label %141, label %143
141: ; preds = %137
%142 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.7, i64 0, i64 0))
store i32 0, i32* %3
store i32 1, i32* %14
br label %154
143: ; preds = %137
%144 = call i32 @perror(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.8, i64 0, i64 0))
store i32 -1, i32* %3
store i32 1, i32* %14
br label %154
145: ; preds = %132
%146 = load i32, i32* %6
%147 = getelementptr inbounds [64 x i8], [64 x i8]* %9, i64 0, i64 0
%148 = bitcast %struct.sockaddr_ll* %10 to %struct.sockaddr*
%149 = call i64 @sendto(i32 %146, i8* %147, i32 64, i32 0, %struct.sockaddr* %148, i32 24)
%150 = icmp slt i64 %149, 0
br i1 %150, label %151, label %153
151: ; preds = %145
%152 = call i32 @perror(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.9, i64 0, i64 0))
store i32 -1, i32* %3
store i32 1, i32* %14
br label %154
153: ; preds = %145
br label %131
154: ; preds = %151, %143, %141, %89, %76, %63
%155 = load i8*, i8** %11
%156 = load i32, i32* %3
ret i32 %156
}

LLVM IR (-O2):
%struct.ifreq = type { i32, i32 }
@IFNAMSIZ = global i32 0
@__const.main.mac = [6 x i32] [i32 255, i32 255, i32 255, i32 255, i32 255, i32 255]
@.str = [30 x i8] c"%02x:%02x:%02x:%02x:%02x:%02x\00"
@.str.1 = [5 x i8] c"eth0\00"
@.str.2 = [40 x i8] c"Broadcasting from STDIN to MAC address \00"
@.str.3 = [25 x i8] c"%2x:%2x:%2x:%2x:%2x:%2x\0A\00"
@AF_PACKET = global i32 0
@SOCK_DGRAM = global i32 0
@.str.4 = [21 x i8] c"Error opening socket\00"
@SIOCGIFINDEX = global i32 0
@.str.5 = [30 x i8] c"Error getting interface index\00"
@SIOCGIFHWADDR = global i32 0
@.str.6 = [36 x i8] c"Error getting interface MAC address\00"
@ETHER_ADDR_LEN = global i32 0
@stdin = global i32 0
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca %struct.ifreq
%4 = alloca %struct.ifreq
%5 = alloca [6 x i32]
%6 = bitcast %struct.ifreq* %3 to i8*
%7 = bitcast %struct.ifreq* %4 to i8*
%8 = load i32, i32* @IFNAMSIZ
%9 = zext i32 %8 to i64
%10 = tail call i8* @llvm.stacksave()
%11 = alloca i8, i64 %9
%12 = bitcast [6 x i32]* %5 to i8*
%13 = icmp sgt i32 %0, 1
br i1 %13, label %14, label %29
14: ; preds = %2
%15 = getelementptr inbounds i8*, i8** %1, i64 1
%16 = load i8*, i8** %15
%17 = call i32 @strcpy(i8* %11, i8* %16)
%18 = icmp eq i32 %0, 2
br i1 %18, label %31, label %19
19: ; preds = %14
%20 = getelementptr inbounds i8*, i8** %1, i64 2
%21 = load i8*, i8** %20
%22 = getelementptr inbounds [6 x i32], [6 x i32]* %5, i64 0, i64 0
%23 = getelementptr inbounds [6 x i32], [6 x i32]* %5, i64 0, i64 1
%24 = getelementptr inbounds [6 x i32], [6 x i32]* %5, i64 0, i64 2
%25 = getelementptr inbounds [6 x i32], [6 x i32]* %5, i64 0, i64 3
%26 = getelementptr inbounds [6 x i32], [6 x i32]* %5, i64 0, i64 4
%27 = getelementptr inbounds [6 x i32], [6 x i32]* %5, i64 0, i64 5
%28 = call i32 @sscanf(i8* %21, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), i32* %22, i32* %23, i32* %24, i32* %25, i32* %26, i32* %27)
br label %31
29: ; preds = %2
%30 = call i32 @strcpy(i8* %11, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
br label %31
31: ; preds = %14, %19, %29
%32 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @.str.2, i64 0, i64 0))
%33 = getelementptr inbounds [6 x i32], [6 x i32]* %5, i64 0, i64 0
%34 = load i32, i32* %33
%35 = getelementptr inbounds [6 x i32], [6 x i32]* %5, i64 0, i64 1
%36 = load i32, i32* %35
%37 = getelementptr inbounds [6 x i32], [6 x i32]* %5, i64 0, i64 2
%38 = load i32, i32* %37
%39 = getelementptr inbounds [6 x i32], [6 x i32]* %5, i64 0, i64 3
%40 = load i32, i32* %39
%41 = getelementptr inbounds [6 x i32], [6 x i32]* %5, i64 0, i64 4
%42 = load i32, i32* %41
%43 = getelementptr inbounds [6 x i32], [6 x i32]* %5, i64 0, i64 5
%44 = load i32, i32* %43
%45 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.3, i64 0, i64 0), i32 %34, i32 %36, i32 %38, i32 %40, i32 %42, i32 %44)
%46 = load i32, i32* @AF_PACKET
%47 = load i32, i32* @SOCK_DGRAM
%48 = call i32 @htons(i32 34997)
%49 = call i32 @socket(i32 %46, i32 %47, i32 %48)
%50 = icmp eq i32 %49, -1
br i1 %50, label %73, label %51
51: ; preds = %31
%52 = call i32 @memset(%struct.ifreq* %3, i32 0, i32 8)
%53 = getelementptr inbounds %struct.ifreq, %struct.ifreq* %3, i64 0, i32 1
%54 = load i32, i32* %53
%55 = load i32, i32* @IFNAMSIZ
%56 = add nsw i32 %55, -1
%57 = call i32 @strncpy(i32 %54, i8* %11, i32 %56)
%58 = load i32, i32* @SIOCGIFINDEX
%59 = call i64 @ioctl(i32 %49, i32 %58, %struct.ifreq* %3)
%60 = icmp slt i64 %59, 0
br i1 %60, label %73, label %61
61: ; preds = %51
%62 = call i32 @memset(%struct.ifreq* %4, i32 0, i32 8)
%63 = getelementptr inbounds %struct.ifreq, %struct.ifreq* %4, i64 0, i32 1
%64 = load i32, i32* %63
%65 = load i32, i32* @IFNAMSIZ
%66 = add nsw i32 %65, -1
%67 = call i32 @strncpy(i32 %64, i8* %11, i32 %66)
%68 = load i32, i32* @SIOCGIFHWADDR
%69 = call i64 @ioctl(i32 %49, i32 %68, %struct.ifreq* %4)
%70 = icmp slt i64 %69, 0
br i1 %70, label %73, label %71
71: ; preds = %61
%72 = call i32 @htons(i32 34997)
unreachable
73: ; preds = %61, %51, %31
%74 = phi i8* [ getelementptr inbounds ([21 x i8], [21 x i8]* @.str.4, i64 0, i64 0), %31 ], [ getelementptr inbounds ([30 x i8], [30 x i8]* @.str.5, i64 0, i64 0), %51 ], [ getelementptr inbounds ([36 x i8], [36 x i8]* @.str.6, i64 0, i64 0), %61 ]
%75 = call i32 @perror(i8* %74)
ret i32 -1
}