#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_4__ TYPE_2__;
typedef struct TYPE_3__ TYPE_1__;

/* Type definitions */
struct TYPE_3__ {
  int /*<<< orphan*/ s_addr;
};
struct sockaddr_in {
  TYPE_1__ sin_addr;
  int /*<<< orphan*/ sin_family;
};
struct TYPE_4__ {
  int /*<<< orphan*/ *sa_data;
};
struct arpreq {
  int arp_flags;
  TYPE_2__ arp_ha;
  int /*<<< orphan*/ arp_pa;
};
typedef int /*<<< orphan*/ arpreq;

/* Variables and functions */
int /*<<< orphan*/ AF_INET;
int /*<<< orphan*/ SIOCGARP;
int /*<<< orphan*/ SOCK_DGRAM;
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ inet_addr(char *);
scalar_t__ ioctl(int, int /*<<< orphan*/, struct arpreq *);
int /*<<< orphan*/ memset(struct arpreq *, int /*<<< orphan*/, int);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, ...);
int socket(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/);
main(int argc, char *argv[]) {
  int s;
  struct arpreq arpreq;
  struct sockaddr_in *sin;
  unsigned char *eap;
  if (argc < 2)
    exit(0);
  memset(&arpreq, 0, sizeof(arpreq));
  sin = (struct sockaddr_in *)&arpreq.arp_pa;
  sin->sin_family = AF_INET;
  sin->sin_addr.s_addr = inet_addr(argv[1]);
  s = socket(AF_INET, SOCK_DGRAM, 0);
  if (s < 0) {
    perror("socket");
    exit(0);
  }
  if (ioctl(s, SIOCGARP, &arpreq) < 0) {
    perror("ioctl");
    exit(0);
  }
  if (arpreq.arp_flags & 0x02) {
    eap = (unsigned char *)&arpreq.arp_ha.sa_data[0];
    printf("Ethernet address: %02X:%02X:%02X:%02X:%02X:%02X", eap[0], eap[1],
           eap[2], eap[3], eap[4], eap[5]);
    if (arpreq.arp_flags & 0x04)
      printf(" PERM");
    if (arpreq.arp_flags & 0x08)
      printf(" PUBLISHED");
    if (arpreq.arp_flags & 0x10)
      printf(" TRAILERS");
    if (arpreq.arp_flags & 0x20)
      printf(" PROXY");
    printf("\n");
  } else {
    printf("*** INCOMPLETE ***\n");
  }
  close(s);
  exit(0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
jge    11a7 <main+0x27>
xor    %edi,%edi
call   1090 <exit@plt>
lea    -0x30(%rbp),%rdi
xor    %esi,%esi
mov    $0x18,%edx
call   1040 <memset@plt>
lea    -0x30(%rbp),%rax
add    $0x10,%rax
mov    %rax,-0x38(%rbp)
mov    0x2e1e(%rip),%rax
mov    (%rax),%ecx
mov    -0x38(%rbp),%rax
mov    %ecx,0x4(%rax)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1070 <inet_addr@plt>
mov    %eax,%ecx
mov    -0x38(%rbp),%rax
mov    %ecx,(%rax)
mov    0x2df9(%rip),%rax
mov    (%rax),%edi
mov    0x2de8(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   10a0 <socket@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jge    1221 <main+0xa1>
lea    0xdeb(%rip),%rdi
call   1080 <perror@plt>
xor    %edi,%edi
call   1090 <exit@plt>
mov    -0x14(%rbp),%edi
mov    0x2da5(%rip),%rax
mov    (%rax),%esi
lea    -0x30(%rbp),%rdx
call   1050 <ioctl@plt>
cmp    $0x0,%rax
jge    1253 <main+0xd3>
lea    0xdc0(%rip),%rdi
call   1080 <perror@plt>
xor    %edi,%edi
call   1090 <exit@plt>
mov    -0x30(%rbp),%eax
and    $0x2,%eax
cmp    $0x0,%eax
je     1333 <main+0x1b3>
mov    -0x28(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    -0x40(%rbp),%rax
movzbl (%rax),%esi
mov    -0x40(%rbp),%rax
movzbl 0x1(%rax),%edx
mov    -0x40(%rbp),%rax
movzbl 0x2(%rax),%ecx
mov    -0x40(%rbp),%rax
movzbl 0x3(%rax),%r8d
mov    -0x40(%rbp),%rax
movzbl 0x4(%rax),%r9d
mov    -0x40(%rbp),%rax
movzbl 0x5(%rax),%eax
lea    0xd6b(%rip),%rdi
mov    %eax,(%rsp)
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x30(%rbp),%eax
and    $0x4,%eax
cmp    $0x0,%eax
je     12c9 <main+0x149>
lea    0xd7b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x30(%rbp),%eax
and    $0x8,%eax
cmp    $0x0,%eax
je     12e6 <main+0x166>
lea    0xd64(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x30(%rbp),%eax
and    $0x10,%eax
cmp    $0x0,%eax
je     1303 <main+0x183>
lea    0xd52(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x30(%rbp),%eax
and    $0x20,%eax
cmp    $0x0,%eax
je     1320 <main+0x1a0>
lea    0xd3f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xd4a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1341 <main+0x1c1>
lea    0xd25(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%edi
call   1060 <close@plt>
xor    %edi,%edi
call   1090 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x28,%rsp
cmp    $0x1,%edi
jle    12a5 <main+0x105>
mov    %rsi,%rbx
lea    0x10(%rsp),%rdi
xor    %esi,%esi
mov    $0x18,%edx
call   1060 <memset@plt>
mov    0x2e1d(%rip),%r14
mov    (%r14),%eax
mov    %eax,0x24(%rsp)
mov    0x8(%rbx),%rdi
call   1090 <inet_addr@plt>
mov    %eax,0x20(%rsp)
mov    (%r14),%edi
mov    0x2df7(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   10c0 <socket@plt>
test   %eax,%eax
jns    11ff <main+0x5f>
lea    0xe03(%rip),%rdi
jmp    1222 <main+0x82>
mov    %eax,%ebx
mov    0x2dc8(%rip),%rax
mov    (%rax),%esi
lea    0x10(%rsp),%rdx
mov    %ebx,%edi
call   1070 <ioctl@plt>
test   %rax,%rax
jns    122e <main+0x8e>
lea    0xde5(%rip),%rdi
call   10a0 <perror@plt>
xor    %edi,%edi
call   10b0 <exit@plt>
testb  $0x2,0x10(%rsp)
jne    1243 <main+0xa3>
lea    0xe23(%rip),%rdi
call   1040 <puts@plt>
jmp    129e <main+0xfe>
mov    0x18(%rsp),%rax
movzbl (%rax),%esi
movzbl 0x1(%rax),%edx
movzbl 0x2(%rax),%ecx
movzbl 0x3(%rax),%r8d
movzbl 0x4(%rax),%r9d
movzbl 0x5(%rax),%eax
mov    %eax,(%rsp)
lea    0xda2(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x10(%rsp),%eax
test   $0x4,%al
jne    12ac <main+0x10c>
test   $0x8,%al
jne    12c2 <main+0x122>
test   $0x10,%al
jne    12d8 <main+0x138>
test   $0x20,%al
je     1294 <main+0xf4>
lea    0xdcb(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    %ebx,%edi
call   1080 <close@plt>
xor    %edi,%edi
call   10b0 <exit@plt>
lea    0xd8a(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x10(%rsp),%eax
test   $0x8,%al
je     127e <main+0xde>
lea    0xd7a(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x10(%rsp),%eax
test   $0x10,%al
je     1282 <main+0xe2>
lea    0xd6f(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x10(%rsp),%eax
test   $0x20,%al
jne    1286 <main+0xe6>
jmp    1294 <main+0xf4>

LLVM IR (-O0):
%struct.arpreq = type { i32, %struct.TYPE_4__, i32 }
%struct.TYPE_4__ = type { i32* }
%struct.sockaddr_in = type { %struct.TYPE_3__, i32 }
%struct.TYPE_3__ = type { i32 }
@AF_INET = global i32 0
@SOCK_DGRAM = global i32 0
@.str = [7 x i8] c"socket\00"
@SIOCGARP = global i32 0
@.str.1 = [6 x i8] c"ioctl\00"
@.str.2 = [48 x i8] c"Ethernet address: %02X:%02X:%02X:%02X:%02X:%02X\00"
@.str.3 = [6 x i8] c" PERM\00"
@.str.4 = [11 x i8] c" PUBLISHED\00"
@.str.5 = [10 x i8] c" TRAILERS\00"
@.str.6 = [7 x i8] c" PROXY\00"
@.str.7 = [2 x i8] c"\0A\00"
@.str.8 = [20 x i8] c"*** INCOMPLETE ***\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca %struct.arpreq
%8 = alloca %struct.sockaddr_in*
%9 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%10 = load i32, i32* %4
%11 = icmp slt i32 %10, 2
br i1 %11, label %12, label %14
12: ; preds = %2
%13 = call i32 @exit(i32 0)
unreachable
14: ; preds = %2
%15 = call i32 @memset(%struct.arpreq* %7, i32 0, i32 24)
%16 = getelementptr inbounds %struct.arpreq, %struct.arpreq* %7, i32 0, i32 2
%17 = bitcast i32* %16 to %struct.sockaddr_in*
store %struct.sockaddr_in* %17, %struct.sockaddr_in** %8
%18 = load i32, i32* @AF_INET
%19 = load %struct.sockaddr_in*, %struct.sockaddr_in** %8
%20 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %19, i32 0, i32 1
store i32 %18, i32* %20
%21 = load i8**, i8*** %5
%22 = getelementptr inbounds i8*, i8** %21, i64 1
%23 = load i8*, i8** %22
%24 = call i32 @inet_addr(i8* %23)
%25 = load %struct.sockaddr_in*, %struct.sockaddr_in** %8
%26 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %25, i32 0, i32 0
%27 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %26, i32 0, i32 0
store i32 %24, i32* %27
%28 = load i32, i32* @AF_INET
%29 = load i32, i32* @SOCK_DGRAM
%30 = call i32 @socket(i32 %28, i32 %29, i32 0)
store i32 %30, i32* %6
%31 = load i32, i32* %6
%32 = icmp slt i32 %31, 0
br i1 %32, label %33, label %36
33: ; preds = %14
%34 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%35 = call i32 @exit(i32 0)
unreachable
36: ; preds = %14
%37 = load i32, i32* %6
%38 = load i32, i32* @SIOCGARP
%39 = call i64 @ioctl(i32 %37, i32 %38, %struct.arpreq* %7)
%40 = icmp slt i64 %39, 0
br i1 %40, label %41, label %44
41: ; preds = %36
%42 = call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%43 = call i32 @exit(i32 0)
unreachable
44: ; preds = %36
%45 = getelementptr inbounds %struct.arpreq, %struct.arpreq* %7, i32 0, i32 0
%46 = load i32, i32* %45
%47 = and i32 %46, 2
%48 = icmp ne i32 %47, 0
br i1 %48, label %49, label %109
49: ; preds = %44
%50 = getelementptr inbounds %struct.arpreq, %struct.arpreq* %7, i32 0, i32 1
%51 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %50, i32 0, i32 0
%52 = load i32*, i32** %51
%53 = getelementptr inbounds i32, i32* %52, i64 0
%54 = bitcast i32* %53 to i8*
store i8* %54, i8** %9
%55 = load i8*, i8** %9
%56 = getelementptr inbounds i8, i8* %55, i64 0
%57 = load i8, i8* %56
%58 = zext i8 %57 to i32
%59 = load i8*, i8** %9
%60 = getelementptr inbounds i8, i8* %59, i64 1
%61 = load i8, i8* %60
%62 = zext i8 %61 to i32
%63 = load i8*, i8** %9
%64 = getelementptr inbounds i8, i8* %63, i64 2
%65 = load i8, i8* %64
%66 = zext i8 %65 to i32
%67 = load i8*, i8** %9
%68 = getelementptr inbounds i8, i8* %67, i64 3
%69 = load i8, i8* %68
%70 = zext i8 %69 to i32
%71 = load i8*, i8** %9
%72 = getelementptr inbounds i8, i8* %71, i64 4
%73 = load i8, i8* %72
%74 = zext i8 %73 to i32
%75 = load i8*, i8** %9
%76 = getelementptr inbounds i8, i8* %75, i64 5
%77 = load i8, i8* %76
%78 = zext i8 %77 to i32
%79 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.2, i64 0, i64 0), i32 %58, i32 %62, i32 %66, i32 %70, i32 %74, i32 %78)
%80 = getelementptr inbounds %struct.arpreq, %struct.arpreq* %7, i32 0, i32 0
%81 = load i32, i32* %80
%82 = and i32 %81, 4
%83 = icmp ne i32 %82, 0
br i1 %83, label %84, label %86
84: ; preds = %49
%85 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
br label %86
86: ; preds = %84, %49
%87 = getelementptr inbounds %struct.arpreq, %struct.arpreq* %7, i32 0, i32 0
%88 = load i32, i32* %87
%89 = and i32 %88, 8
%90 = icmp ne i32 %89, 0
br i1 %90, label %91, label %93
91: ; preds = %86
%92 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0))
br label %93
93: ; preds = %91, %86
%94 = getelementptr inbounds %struct.arpreq, %struct.arpreq* %7, i32 0, i32 0
%95 = load i32, i32* %94
%96 = and i32 %95, 16
%97 = icmp ne i32 %96, 0
br i1 %97, label %98, label %100
98: ; preds = %93
%99 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.5, i64 0, i64 0))
br label %100
100: ; preds = %98, %93
%101 = getelementptr inbounds %struct.arpreq, %struct.arpreq* %7, i32 0, i32 0
%102 = load i32, i32* %101
%103 = and i32 %102, 32
%104 = icmp ne i32 %103, 0
br i1 %104, label %105, label %107
105: ; preds = %100
%106 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0))
br label %107
107: ; preds = %105, %100
%108 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0))
br label %111
109: ; preds = %44
%110 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.8, i64 0, i64 0))
br label %111
111: ; preds = %109, %107
%112 = load i32, i32* %6
%113 = call i32 @close(i32 %112)
%114 = call i32 @exit(i32 0)
unreachable
}

LLVM IR (-O2):
%struct.arpreq = type { i32, %struct.TYPE_4__, i32 }
%struct.TYPE_4__ = type { i32* }
@AF_INET = global i32 0
@SOCK_DGRAM = global i32 0
@.str = [7 x i8] c"socket\00"
@SIOCGARP = global i32 0
@.str.1 = [6 x i8] c"ioctl\00"
@.str.2 = [48 x i8] c"Ethernet address: %02X:%02X:%02X:%02X:%02X:%02X\00"
@.str.3 = [6 x i8] c" PERM\00"
@.str.4 = [11 x i8] c" PUBLISHED\00"
@.str.5 = [10 x i8] c" TRAILERS\00"
@.str.6 = [7 x i8] c" PROXY\00"
@str = [19 x i8] c"*** INCOMPLETE ***\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca %struct.arpreq
%4 = bitcast %struct.arpreq* %3 to i8*
%5 = icmp slt i32 %0, 2
br i1 %5, label %6, label %8
6: ; preds = %2
%7 = tail call i32 @exit(i32 0)
unreachable
8: ; preds = %2
%9 = call i32 @memset(%struct.arpreq* %3, i32 0, i32 24)
%10 = getelementptr inbounds %struct.arpreq, %struct.arpreq* %3, i64 0, i32 2
%11 = load i32, i32* @AF_INET
%12 = getelementptr inbounds i32, i32* %10, i64 1
store i32 %11, i32* %12
%13 = getelementptr inbounds i8*, i8** %1, i64 1
%14 = load i8*, i8** %13
%15 = call i32 @inet_addr(i8* %14)
store i32 %15, i32* %10
%16 = load i32, i32* @AF_INET
%17 = load i32, i32* @SOCK_DGRAM
%18 = call i32 @socket(i32 %16, i32 %17, i32 0)
%19 = icmp slt i32 %18, 0
br i1 %19, label %20, label %23
20: ; preds = %8
%21 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%22 = call i32 @exit(i32 0)
unreachable
23: ; preds = %8
%24 = load i32, i32* @SIOCGARP
%25 = call i64 @ioctl(i32 %18, i32 %24, %struct.arpreq* %3)
%26 = icmp slt i64 %25, 0
br i1 %26, label %27, label %30
27: ; preds = %23
%28 = call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%29 = call i32 @exit(i32 0)
unreachable
30: ; preds = %23
%31 = getelementptr inbounds %struct.arpreq, %struct.arpreq* %3, i64 0, i32 0
%32 = load i32, i32* %31
%33 = and i32 %32, 2
%34 = icmp eq i32 %33, 0
br i1 %34, label %85, label %35
35: ; preds = %30
%36 = getelementptr inbounds %struct.arpreq, %struct.arpreq* %3, i64 0, i32 1, i32 0
%37 = bitcast i32** %36 to i8**
%38 = load i8*, i8** %37
%39 = load i8, i8* %38
%40 = zext i8 %39 to i32
%41 = getelementptr inbounds i8, i8* %38, i64 1
%42 = load i8, i8* %41
%43 = zext i8 %42 to i32
%44 = getelementptr inbounds i8, i8* %38, i64 2
%45 = load i8, i8* %44
%46 = zext i8 %45 to i32
%47 = getelementptr inbounds i8, i8* %38, i64 3
%48 = load i8, i8* %47
%49 = zext i8 %48 to i32
%50 = getelementptr inbounds i8, i8* %38, i64 4
%51 = load i8, i8* %50
%52 = zext i8 %51 to i32
%53 = getelementptr inbounds i8, i8* %38, i64 5
%54 = load i8, i8* %53
%55 = zext i8 %54 to i32
%56 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([48 x i8], [48 x i8]* @.str.2, i64 0, i64 0), i32 %40, i32 %43, i32 %46, i32 %49, i32 %52, i32 %55)
%57 = load i32, i32* %31
%58 = and i32 %57, 4
%59 = icmp eq i32 %58, 0
br i1 %59, label %63, label %60
60: ; preds = %35
%61 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
%62 = load i32, i32* %31
br label %63
63: ; preds = %60, %35
%64 = phi i32 [ %62, %60 ], [ %57, %35 ]
%65 = and i32 %64, 8
%66 = icmp eq i32 %65, 0
br i1 %66, label %70, label %67
67: ; preds = %63
%68 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0))
%69 = load i32, i32* %31
br label %70
70: ; preds = %67, %63
%71 = phi i32 [ %69, %67 ], [ %64, %63 ]
%72 = and i32 %71, 16
%73 = icmp eq i32 %72, 0
br i1 %73, label %77, label %74
74: ; preds = %70
%75 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.5, i64 0, i64 0))
%76 = load i32, i32* %31
br label %77
77: ; preds = %74, %70
%78 = phi i32 [ %76, %74 ], [ %71, %70 ]
%79 = and i32 %78, 32
%80 = icmp eq i32 %79, 0
br i1 %80, label %83, label %81
81: ; preds = %77
%82 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0))
br label %83
83: ; preds = %81, %77
%84 = call i32 @putchar(i32 10)
br label %87
85: ; preds = %30
%86 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @str, i64 0, i64 0))
br label %87
87: ; preds = %85, %83
%88 = call i32 @close(i32 %18)
%89 = call i32 @exit(i32 0)
unreachable
}