#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 */
typedef int /*<<< orphan*/ victim_mac;
typedef unsigned char uint32_t;
struct option {
  char *member_0;
  char member_3;
  int /*<<< orphan*/ *member_2;
  int /*<<< orphan*/ const member_1;
};
struct in_addr {
  unsigned char s_addr;
  int /*<<< orphan*/ member_0;
};
struct TYPE_4__ {
  scalar_t__ sa_data;
};
struct TYPE_3__ {
  unsigned char *sa_data;
};
struct ifreq {
  TYPE_2__ ifr_addr;
  TYPE_1__ ifr_hwaddr;
};
struct ether_arp {
  unsigned char *arp_sha;
};
typedef int /*<<< orphan*/ attacker_mac;
typedef int /*<<< orphan*/ attacker_ip;

/* Variables and functions */
int /*<<< orphan*/ AF_PACKET;
int /*<<< orphan*/ ETH_P_ARP;
int EXIT_SUCCESS;
int /*<<< orphan*/ SOCK_DGRAM;
int /*<<< orphan*/ arp_spoof(int, char *, unsigned char *, unsigned char,
                             unsigned char *, unsigned char);
int /*<<< orphan*/ check_interface(char *);
int /*<<< orphan*/ die(char *);
int /*<<< orphan*/ errno;
int /*<<< orphan*/ free(char *);
unsigned char get_gateway(char *);
int /*<<< orphan*/ get_ifr_addr(int, struct ifreq *);
int /*<<< orphan*/ get_ifr_hwaddr(int, struct ifreq *);
char *get_interface();
int getopt_long(int, char **, char *, struct option const *, int *);
int /*<<< orphan*/ htons(int /*<<< orphan*/);
int /*<<< orphan*/ inet_aton(char *, struct in_addr *);
int /*<<< orphan*/ memcpy(unsigned char *, unsigned char *, int);
#define no_argument 129
char *optarg;
int optind;
int /*<<< orphan*/ print_addrs(char *, unsigned char, unsigned char *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ puts(char *);
int /*<<< orphan*/ request_mac(int, char *, struct ether_arp *, unsigned char);
#define required_argument 128
int /*<<< orphan*/ set_ifr_name(struct ifreq *, char *);
int /*<<< orphan*/ sleep(int);
int socket(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/);
char *strdup(char *);
char *strerror(int /*<<< orphan*/);
int strtoul(char *, int /*<<< orphan*/ *, int);
int main(int argc, char *argv[]) {
  struct ether_arp req;
  unsigned char attacker_mac[6];
  unsigned char victim_mac[6];
  struct in_addr ip_addr = {0};
  char *if_name = NULL;
  char *victim_ip_str = NULL;
  uint32_t attacker_ip = 0;
  uint32_t gateway_ip = 0;
  int repeat = 0;
  int verbose = 0;
  int c;
  while (1) {
    static const struct option long_options[] = {
        {"attacker-ip", required_argument, NULL, 'a'},
        {"interface", required_argument, NULL, 'i'},
        {"repeat", required_argument, NULL, 'r'},
        {"gateway-ip", required_argument, NULL, 'g'},
        {"verbose", no_argument, NULL, 'v'},
        {0, 0, 0, 0}};
    int option_index = 0;
    c = getopt_long(argc, argv, "a:i:r:g:v", long_options, &option_index);
    if (c == -1) {
      break;
    }
    switch (c) {
    case 'a':
      if (!inet_aton(optarg, &ip_addr)) {
        die("Attacker IP is invalid");
      }
      attacker_ip = ip_addr.s_addr;
      break;
    case 'i':
      if_name = strdup(optarg);
      if (!check_interface(if_name)) {
        die("Invalid interface (nonexistent or not connected?)");
      }
      break;
    case 'r':
      repeat = strtoul(optarg, NULL, 10);
      break;
    case 'g':
      if (!inet_aton(optarg, &ip_addr)) {
        die("Gateway IP is invalid");
      }
      gateway_ip = ip_addr.s_addr;
      break;
    case 'v':
      verbose = 1;
      break;
    case '?':
      break;
    default:
      die("Invalid option");
      break;
    }
  }
  if (argc > optind + 1) {
    die("Too many arguments");
  } else if (argc == optind) {
    die("Please provide a victim IP");
  } else {
    victim_ip_str = argv[optind];
  }
  if (!inet_aton(victim_ip_str, &ip_addr)) {
    die("Invalid IP address");
  }
  uint32_t victim_ip = ip_addr.s_addr;
  if (!if_name) {
    if_name = get_interface();
  }
  if (!if_name) {
    die("No valid interface found (are you not connected?)");
  }
  if (!gateway_ip) {
    gateway_ip = get_gateway(if_name);
  }
  int fd = socket(AF_PACKET, SOCK_DGRAM, htons(ETH_P_ARP));
  if (fd == -1) {
    die(strerror(errno));
  }
  if (attacker_ip) {
    request_mac(fd, if_name, &req, attacker_ip);
    memcpy(attacker_mac, req.arp_sha, sizeof(attacker_mac));
  } else {
    struct ifreq ifr;
    set_ifr_name(&ifr, if_name);
    get_ifr_hwaddr(fd, &ifr);
    memcpy(attacker_mac, ifr.ifr_hwaddr.sa_data, sizeof(attacker_mac));
    get_ifr_addr(fd, &ifr);
    memcpy(&attacker_ip, (unsigned char *)ifr.ifr_addr.sa_data + 2,
           sizeof(attacker_ip));
  }
  request_mac(fd, if_name, &req, victim_ip);
  memcpy(victim_mac, req.arp_sha, sizeof(victim_mac));
  if (verbose) {
    puts("\t\tIP address\tMAC address");
    print_addrs("Attacker", attacker_ip, attacker_mac);
    request_mac(fd, if_name, &req, gateway_ip);
    print_addrs("Gateway", gateway_ip, req.arp_sha);
    print_addrs("Victim", victim_ip, victim_mac);
    printf("\nInterface:\t%s\n", if_name);
  }
  if (repeat) {
    printf("Repeating every %d seconds (Ctrl+C to quit)\n", repeat);
  }
  do {
    arp_spoof(fd, if_name, attacker_mac, gateway_ip, victim_mac, victim_ip);
    sleep(repeat);
  } while (repeat);
  free(if_name);
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x30(%rbp),%rdi
xor    %esi,%esi
mov    $0x8,%edx
call   10d0 <memset@plt>
movq   $0x0,-0x38(%rbp)
movq   $0x0,-0x40(%rbp)
movb   $0x0,-0x41(%rbp)
movb   $0x0,-0x42(%rbp)
movl   $0x0,-0x48(%rbp)
movl   $0x0,-0x4c(%rbp)
movl   $0x0,-0x54(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xe3c(%rip),%rdx
lea    0x2a45(%rip),%rcx
lea    -0x54(%rbp),%r8
call   10a0 <getopt_long@plt>
mov    %eax,-0x50(%rbp)
cmpl   $0xffffffff,-0x50(%rbp)
jne    12f6 <main+0x86>
jmp    13fd <main+0x18d>
mov    -0x50(%rbp),%eax
add    $0xffffffc1,%eax
mov    %eax,%ecx
mov    %rcx,-0x78(%rbp)
sub    $0x37,%eax
ja     13ec <main+0x17c>
mov    -0x78(%rbp),%rax
lea    0xcea(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    0x2cca(%rip),%rax
mov    (%rax),%rdi
lea    -0x30(%rbp),%rsi
call   1110 <inet_aton@plt>
cmp    $0x0,%eax
jne    1347 <main+0xd7>
lea    0xdd8(%rip),%rdi
call   1130 <die@plt>
mov    -0x30(%rbp),%al
mov    %al,-0x41(%rbp)
jmp    13f8 <main+0x188>
mov    0x2c97(%rip),%rax
mov    (%rax),%rdi
call   1150 <strdup@plt>
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rdi
call   1120 <check_interface@plt>
cmp    $0x0,%eax
jne    1383 <main+0x113>
lea    0xdb3(%rip),%rdi
call   1130 <die@plt>
jmp    13f8 <main+0x188>
mov    0x2c61(%rip),%rax
mov    (%rax),%rdi
xor    %eax,%eax
mov    %eax,%esi
mov    $0xa,%edx
call   1140 <strtoul@plt>
mov    %eax,-0x48(%rbp)
jmp    13f8 <main+0x188>
mov    0x2c41(%rip),%rax
mov    (%rax),%rdi
lea    -0x30(%rbp),%rsi
call   1110 <inet_aton@plt>
cmp    $0x0,%eax
jne    13d0 <main+0x160>
lea    0xd98(%rip),%rdi
call   1130 <die@plt>
mov    -0x30(%rbp),%al
mov    %al,-0x42(%rbp)
jmp    13f8 <main+0x188>
movl   $0x1,-0x4c(%rbp)
jmp    13f8 <main+0x188>
jmp    13f8 <main+0x188>
lea    0xd86(%rip),%rdi
call   1130 <die@plt>
jmp    12bf <main+0x4f>
mov    -0x8(%rbp),%eax
mov    0x2bc9(%rip),%rcx
mov    (%rcx),%ecx
add    $0x1,%ecx
cmp    %ecx,%eax
jle    1425 <main+0x1b5>
lea    0xd6d(%rip),%rdi
call   1130 <die@plt>
jmp    1463 <main+0x1f3>
mov    -0x8(%rbp),%eax
mov    0x2ba1(%rip),%rcx
cmp    (%rcx),%eax
jne    1448 <main+0x1d8>
lea    0xd5d(%rip),%rdi
call   1130 <die@plt>
jmp    145e <main+0x1ee>
mov    -0x10(%rbp),%rax
mov    0x2b7d(%rip),%rcx
movslq (%rcx),%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x40(%rbp)
jmp    1463 <main+0x1f3>
mov    -0x40(%rbp),%rdi
lea    -0x30(%rbp),%rsi
call   1110 <inet_aton@plt>
cmp    $0x0,%eax
jne    1485 <main+0x215>
lea    0xd36(%rip),%rdi
call   1130 <die@plt>
mov    -0x30(%rbp),%al
mov    %al,-0x55(%rbp)
cmpq   $0x0,-0x38(%rbp)
jne    14a1 <main+0x231>
mov    $0x0,%al
call   1180 <get_interface@plt>
mov    %rax,-0x38(%rbp)
cmpq   $0x0,-0x38(%rbp)
jne    14b8 <main+0x248>
lea    0xd16(%rip),%rdi
call   1130 <die@plt>
cmpb   $0x0,-0x42(%rbp)
jne    14ce <main+0x25e>
mov    -0x38(%rbp),%rdi
call   1070 <get_gateway@plt>
mov    %al,-0x42(%rbp)
mov    0x2aeb(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x80(%rbp)
mov    0x2af7(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x7c(%rbp)
mov    0x2abb(%rip),%rax
mov    (%rax),%edi
call   10b0 <htons@plt>
mov    -0x80(%rbp),%edi
mov    -0x7c(%rbp),%esi
mov    %eax,%edx
call   1190 <socket@plt>
mov    %eax,-0x5c(%rbp)
cmpl   $0xffffffff,-0x5c(%rbp)
jne    1524 <main+0x2b4>
mov    0x2aa3(%rip),%rax
mov    (%rax),%edi
call   1160 <strerror@plt>
mov    %rax,%rdi
call   1130 <die@plt>
cmpb   $0x0,-0x41(%rbp)
je     1559 <main+0x2e9>
mov    -0x5c(%rbp),%edi
mov    -0x38(%rbp),%rsi
lea    -0x18(%rbp),%rdx
movzbl -0x41(%rbp),%ecx
call   10f0 <request_mac@plt>
lea    -0x1e(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    $0x6,%edx
call   1100 <memcpy@plt>
jmp    15a6 <main+0x336>
mov    -0x38(%rbp),%rsi
lea    -0x70(%rbp),%rdi
call   10e0 <set_ifr_name@plt>
mov    -0x5c(%rbp),%edi
lea    -0x70(%rbp),%rsi
call   1060 <get_ifr_hwaddr@plt>
lea    -0x1e(%rbp),%rdi
mov    -0x68(%rbp),%rsi
mov    $0x6,%edx
call   1100 <memcpy@plt>
mov    -0x5c(%rbp),%edi
lea    -0x70(%rbp),%rsi
call   1040 <get_ifr_addr@plt>
mov    -0x70(%rbp),%rsi
add    $0x2,%rsi
lea    -0x41(%rbp),%rdi
mov    $0x1,%edx
call   1100 <memcpy@plt>
mov    -0x5c(%rbp),%edi
mov    -0x38(%rbp),%rsi
lea    -0x18(%rbp),%rdx
movzbl -0x55(%rbp),%ecx
call   10f0 <request_mac@plt>
lea    -0x24(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    $0x6,%edx
call   1100 <memcpy@plt>
cmpl   $0x0,-0x4c(%rbp)
je     164a <main+0x3da>
lea    0xc1e(%rip),%rdi
call   1050 <puts@plt>
mov    -0x41(%rbp),%al
lea    -0x1e(%rbp),%rdx
lea    0xc24(%rip),%rdi
movzbl %al,%esi
call   1080 <print_addrs@plt>
mov    -0x5c(%rbp),%edi
mov    -0x38(%rbp),%rsi
lea    -0x18(%rbp),%rdx
movzbl -0x42(%rbp),%ecx
call   10f0 <request_mac@plt>
mov    -0x42(%rbp),%al
mov    -0x18(%rbp),%rdx
lea    0xc03(%rip),%rdi
movzbl %al,%esi
call   1080 <print_addrs@plt>
mov    -0x55(%rbp),%al
lea    -0x24(%rbp),%rdx
lea    0xbf5(%rip),%rdi
movzbl %al,%esi
call   1080 <print_addrs@plt>
mov    -0x38(%rbp),%rsi
lea    0xbe9(%rip),%rdi
mov    $0x0,%al
call   10c0 <printf@plt>
cmpl   $0x0,-0x48(%rbp)
je     1665 <main+0x3f5>
mov    -0x48(%rbp),%esi
lea    0xbde(%rip),%rdi
mov    $0x0,%al
call   10c0 <printf@plt>
jmp    166a <main+0x3fa>
mov    -0x5c(%rbp),%edi
mov    -0x38(%rbp),%rsi
lea    -0x1e(%rbp),%rdx
mov    -0x42(%rbp),%al
lea    -0x24(%rbp),%r8
movzbl %al,%ecx
movzbl -0x55(%rbp),%r9d
call   1090 <arp_spoof@plt>
mov    -0x48(%rbp),%edi
call   1170 <sleep@plt>
cmpl   $0x0,-0x48(%rbp)
jne    166a <main+0x3fa>
mov    -0x38(%rbp),%rdi
call   1030 <free@plt>
mov    0x2905(%rip),%rax
mov    (%rax),%eax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x58,%rsp
mov    %rsi,%rbp
mov    %edi,%ebx
movq   $0x0,0x10(%rsp)
movb   $0x0,0xb(%rsp)
xor    %eax,%eax
mov    %rax,0x50(%rsp)
lea    0xe81(%rip),%r13
lea    0x2a8a(%rip),%r14
lea    0x28(%rsp),%r15
lea    0xd5e(%rip),%r12
xor    %eax,%eax
mov    %rax,0x40(%rsp)
movl   $0x0,0xc(%rsp)
movl   $0x0,0x24(%rsp)
xor    %eax,%eax
mov    %rax,0x48(%rsp)
jmp    12d0 <main+0x70>
movl   $0x1,0x24(%rsp)
nopw   0x0(%rax,%rax,1)
movl   $0x0,0x28(%rsp)
mov    %ebx,%edi
mov    %rbp,%rsi
mov    %r13,%rdx
mov    %r14,%rcx
mov    %r15,%r8
call   10a0 <getopt_long@plt>
lea    -0x3f(%rax),%ecx
cmp    $0x37,%ecx
ja     13bb <main+0x15b>
movslq (%r12,%rcx,4),%rax
add    %r12,%rax
jmp    *%rax
mov    0x2ce9(%rip),%rax
mov    (%rax),%rdi
lea    0x10(%rsp),%rsi
call   1100 <inet_aton@plt>
test   %eax,%eax
jne    1324 <main+0xc4>
lea    0xdfb(%rip),%rdi
call   1120 <die@plt>
movzbl 0x10(%rsp),%eax
mov    %rax,0x50(%rsp)
mov    %al,0xb(%rsp)
jmp    12d0 <main+0x70>
mov    0x2cb5(%rip),%rax
mov    (%rax),%rdi
lea    0x10(%rsp),%rsi
call   1100 <inet_aton@plt>
test   %eax,%eax
jne    1358 <main+0xf8>
lea    0xe10(%rip),%rdi
call   1120 <die@plt>
movzbl 0x10(%rsp),%eax
mov    %rax,0x40(%rsp)
jmp    12d0 <main+0x70>
mov    0x2c82(%rip),%rax
mov    (%rax),%rdi
call   1140 <strdup@plt>
mov    %rax,0x48(%rsp)
mov    %rax,%rdi
call   1110 <check_interface@plt>
test   %eax,%eax
jne    12d0 <main+0x70>
lea    0xd9f(%rip),%rdi
call   1120 <die@plt>
jmp    12d0 <main+0x70>
mov    0x2c4d(%rip),%rax
mov    (%rax),%rdi
xor    %esi,%esi
mov    $0xa,%edx
call   1130 <strtoul@plt>
mov    %eax,0xc(%rsp)
jmp    12d0 <main+0x70>
cmp    $0xffffffff,%eax
je     13d1 <main+0x171>
lea    0xdb2(%rip),%rdi
call   1120 <die@plt>
jmp    12d0 <main+0x70>
mov    0x2bf8(%rip),%rax
movslq (%rax),%rax
lea    0x1(%rax),%ecx
cmp    %ebx,%ecx
jge    1401 <main+0x1a1>
lea    0xd9f(%rip),%rdi
call   1120 <die@plt>
xor    %edi,%edi
mov    0xc(%rsp),%r12d
mov    0x48(%rsp),%r13
mov    0x40(%rsp),%r14
jmp    1429 <main+0x1c9>
cmp    %ebx,%eax
mov    0xc(%rsp),%r12d
mov    0x48(%rsp),%r13
mov    0x40(%rsp),%r14
jne    1424 <main+0x1c4>
lea    0xd80(%rip),%rdi
call   1120 <die@plt>
xor    %edi,%edi
jmp    1429 <main+0x1c9>
mov    0x0(%rbp,%rax,8),%rdi
lea    0x10(%rsp),%rsi
call   1100 <inet_aton@plt>
test   %eax,%eax
jne    1443 <main+0x1e3>
lea    0xd78(%rip),%rdi
call   1120 <die@plt>
mov    0x10(%rsp),%r15b
test   %r13,%r13
jne    1460 <main+0x200>
xor    %eax,%eax
call   1170 <get_interface@plt>
mov    %rax,%r13
test   %rax,%rax
je     1669 <main+0x409>
test   %r14b,%r14b
jne    1470 <main+0x210>
mov    %r13,%rdi
call   1070 <get_gateway@plt>
mov    %eax,%r14d
mov    0x2b49(%rip),%rax
mov    (%rax),%ebx
mov    0x2b58(%rip),%rax
mov    (%rax),%ebp
mov    0x2b1f(%rip),%rax
mov    (%rax),%edi
call   10b0 <htons@plt>
mov    %ebx,%edi
mov    %ebp,%esi
mov    %eax,%edx
call   1180 <socket@plt>
mov    %eax,%ebp
cmp    $0xffffffff,%eax
jne    14b8 <main+0x258>
mov    0x2b0f(%rip),%rax
mov    (%rax),%edi
call   1150 <strerror@plt>
mov    %rax,%rdi
call   1120 <die@plt>
mov    0x50(%rsp),%rax
test   %al,%al
je     14e4 <main+0x284>
movzbl %al,%ecx
lea    0x28(%rsp),%rdx
mov    %ebp,%edi
mov    %r13,%rsi
call   10e0 <request_mac@plt>
mov    0x28(%rsp),%rsi
lea    0x1e(%rsp),%rdi
mov    $0x6,%edx
jmp    152f <main+0x2cf>
lea    0x28(%rsp),%rbx
mov    %rbx,%rdi
mov    %r13,%rsi
call   10d0 <set_ifr_name@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
call   1060 <get_ifr_hwaddr@plt>
mov    0x30(%rsp),%rsi
lea    0x1e(%rsp),%rdi
mov    $0x6,%edx
call   10f0 <memcpy@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
call   1040 <get_ifr_addr@plt>
mov    0x28(%rsp),%rsi
add    $0x2,%rsi
lea    0xb(%rsp),%rdi
mov    $0x1,%edx
call   10f0 <memcpy@plt>
movzbl %r15b,%r15d
lea    0x28(%rsp),%rdx
mov    %ebp,%edi
mov    %r13,%rsi
mov    %r15d,%ecx
call   10e0 <request_mac@plt>
mov    0x28(%rsp),%rsi
lea    0x3a(%rsp),%rdi
mov    $0x6,%edx
call   10f0 <memcpy@plt>
mov    %r13,%rbx
movzbl %r14b,%r13d
cmpl   $0x0,0x24(%rsp)
je     15d9 <main+0x379>
lea    0xc88(%rip),%rdi
call   1050 <puts@plt>
movzbl 0xb(%rsp),%esi
lea    0xc90(%rip),%rdi
lea    0x1e(%rsp),%rdx
call   1080 <print_addrs@plt>
lea    0x28(%rsp),%rdx
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %r13d,%ecx
call   10e0 <request_mac@plt>
mov    0x28(%rsp),%rdx
lea    0xc71(%rip),%rdi
mov    %r13d,%esi
call   1080 <print_addrs@plt>
lea    0xc6a(%rip),%rdi
lea    0x3a(%rsp),%rdx
mov    %r15d,%esi
call   1080 <print_addrs@plt>
lea    0xc5d(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   10c0 <printf@plt>
mov    %rbx,%r14
test   %r12d,%r12d
je     1627 <main+0x3c7>
lea    0xc54(%rip),%rdi
mov    %r12d,%esi
xor    %eax,%eax
call   10c0 <printf@plt>
lea    0x3a(%rsp),%rbx
nopw   0x0(%rax,%rax,1)
mov    %ebp,%edi
mov    %r14,%rsi
lea    0x1e(%rsp),%rdx
mov    %r13d,%ecx
mov    %rbx,%r8
mov    %r15d,%r9d
call   1090 <arp_spoof@plt>
mov    %r12d,%edi
call   1160 <sleep@plt>
test   %r12d,%r12d
jne    1600 <main+0x3a0>
jmp    1649 <main+0x3e9>
lea    0x1e(%rsp),%rdx
lea    0x3a(%rsp),%r8
mov    %ebp,%edi
mov    %r14,%rsi
mov    %r13d,%ecx
mov    %r15d,%r9d
call   1090 <arp_spoof@plt>
mov    %r12d,%edi
call   1160 <sleep@plt>
mov    %r14,%rdi
call   1030 <free@plt>
mov    0x2958(%rip),%rax
mov    (%rax),%eax
add    $0x58,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xb59(%rip),%rdi
call   1120 <die@plt>
xor    %r13d,%r13d
test   %r14b,%r14b
jne    1470 <main+0x210>
jmp    1465 <main+0x205>

LLVM IR (-O0):
%struct.option = type { i8*, i8, i32*, i32 }
%struct.ether_arp = type { i8* }
%struct.in_addr = type { i8, i32 }
%struct.ifreq = type { %struct.TYPE_4__, %struct.TYPE_3__ }
%struct.TYPE_4__ = type { i64 }
%struct.TYPE_3__ = type { i8* }
@main.long_options = internal constant [6 x %struct.option] [%struct.option { i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i32 0, i32 0), i8 -128, i32* null, i32 97 }, %struct.option { i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i32 0, i32 0), i8 -128, i32* null, i32 105 }, %struct.option { i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i32 0, i32 0), i8 -128, i32* null, i32 114 }, %struct.option { i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i32 0, i32 0), i8 -128, i32* null, i32 103 }, %struct.option { i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i32 0, i32 0), i8 -127, i32* null, i32 118 }, %struct.option zeroinitializer]
@.str = [12 x i8] c"attacker-ip\00"
@.str.1 = [10 x i8] c"interface\00"
@.str.2 = [7 x i8] c"repeat\00"
@.str.3 = [11 x i8] c"gateway-ip\00"
@.str.4 = [8 x i8] c"verbose\00"
@.str.5 = [10 x i8] c"a:i:r:g:v\00"
@optarg = global i8* null
@.str.6 = [23 x i8] c"Attacker IP is invalid\00"
@.str.7 = [50 x i8] c"Invalid interface (nonexistent or not connected?)\00"
@.str.8 = [22 x i8] c"Gateway IP is invalid\00"
@.str.9 = [15 x i8] c"Invalid option\00"
@optind = global i32 0
@.str.10 = [19 x i8] c"Too many arguments\00"
@.str.11 = [27 x i8] c"Please provide a victim IP\00"
@.str.12 = [19 x i8] c"Invalid IP address\00"
@.str.13 = [50 x i8] c"No valid interface found (are you not connected?)\00"
@AF_PACKET = global i32 0
@SOCK_DGRAM = global i32 0
@ETH_P_ARP = global i32 0
@errno = global i32 0
@.str.14 = [25 x i8] c"\09\09IP address\09MAC address\00"
@.str.15 = [9 x i8] c"Attacker\00"
@.str.16 = [8 x i8] c"Gateway\00"
@.str.17 = [7 x i8] c"Victim\00"
@.str.18 = [16 x i8] c"\0AInterface:\09%s\0A\00"
@.str.19 = [45 x i8] c"Repeating every %d seconds (Ctrl+C to quit)\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca %struct.ether_arp
%7 = alloca [6 x i8]
%8 = alloca [6 x i8]
%9 = alloca %struct.in_addr
%10 = alloca i8*
%11 = alloca i8*
%12 = alloca i8
%13 = alloca i8
%14 = alloca i32
%15 = alloca i32
%16 = alloca i32
%17 = alloca i32
%18 = alloca i8
%19 = alloca i32
%20 = alloca %struct.ifreq
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%21 = bitcast %struct.in_addr* %9 to i8*
store i8* null, i8** %10
store i8* null, i8** %11
store i8 0, i8* %12
store i8 0, i8* %13
store i32 0, i32* %14
store i32 0, i32* %15
br label %22
22: ; preds = %2, %65
store i32 0, i32* %17
%23 = load i32, i32* %4
%24 = load i8**, i8*** %5
%25 = call i32 @getopt_long(i32 %23, i8** %24, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.5, i64 0, i64 0), %struct.option* getelementptr inbounds ([6 x %struct.option], [6 x %struct.option]* @main.long_options, i64 0, i64 0), i32* %17)
store i32 %25, i32* %16
%26 = load i32, i32* %16
%27 = icmp eq i32 %26, -1
br i1 %27, label %28, label %29
28: ; preds = %22
br label %66
29: ; preds = %22
%30 = load i32, i32* %16
switch i32 %30, label %63 [
i32 97, label %31
i32 105, label %40
i32 114, label %49
i32 103, label %52
i32 118, label %61
i32 63, label %62
]
31: ; preds = %29
%32 = load i8*, i8** @optarg
%33 = call i32 @inet_aton(i8* %32, %struct.in_addr* %9)
%34 = icmp ne i32 %33, 0
br i1 %34, label %37, label %35
35: ; preds = %31
%36 = call i32 @die(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.6, i64 0, i64 0))
br label %37
37: ; preds = %35, %31
%38 = getelementptr inbounds %struct.in_addr, %struct.in_addr* %9, i32 0, i32 0
%39 = load i8, i8* %38
store i8 %39, i8* %12
br label %65
40: ; preds = %29
%41 = load i8*, i8** @optarg
%42 = call i8* @strdup(i8* %41)
store i8* %42, i8** %10
%43 = load i8*, i8** %10
%44 = call i32 @check_interface(i8* %43)
%45 = icmp ne i32 %44, 0
br i1 %45, label %48, label %46
46: ; preds = %40
%47 = call i32 @die(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.7, i64 0, i64 0))
br label %48
48: ; preds = %46, %40
br label %65
49: ; preds = %29
%50 = load i8*, i8** @optarg
%51 = call i32 @strtoul(i8* %50, i32* null, i32 10)
store i32 %51, i32* %14
br label %65
52: ; preds = %29
%53 = load i8*, i8** @optarg
%54 = call i32 @inet_aton(i8* %53, %struct.in_addr* %9)
%55 = icmp ne i32 %54, 0
br i1 %55, label %58, label %56
56: ; preds = %52
%57 = call i32 @die(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.8, i64 0, i64 0))
br label %58
58: ; preds = %56, %52
%59 = getelementptr inbounds %struct.in_addr, %struct.in_addr* %9, i32 0, i32 0
%60 = load i8, i8* %59
store i8 %60, i8* %13
br label %65
61: ; preds = %29
store i32 1, i32* %15
br label %65
62: ; preds = %29
br label %65
63: ; preds = %29
%64 = call i32 @die(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.9, i64 0, i64 0))
br label %65
65: ; preds = %63, %62, %61, %58, %49, %48, %37
br label %22
66: ; preds = %28
%67 = load i32, i32* %4
%68 = load i32, i32* @optind
%69 = add nsw i32 %68, 1
%70 = icmp sgt i32 %67, %69
br i1 %70, label %71, label %73
71: ; preds = %66
%72 = call i32 @die(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.10, i64 0, i64 0))
br label %86
73: ; preds = %66
%74 = load i32, i32* %4
%75 = load i32, i32* @optind
%76 = icmp eq i32 %74, %75
br i1 %76, label %77, label %79
77: ; preds = %73
%78 = call i32 @die(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.11, i64 0, i64 0))
br label %85
79: ; preds = %73
%80 = load i8**, i8*** %5
%81 = load i32, i32* @optind
%82 = sext i32 %81 to i64
%83 = getelementptr inbounds i8*, i8** %80, i64 %82
%84 = load i8*, i8** %83
store i8* %84, i8** %11
br label %85
85: ; preds = %79, %77
br label %86
86: ; preds = %85, %71
%87 = load i8*, i8** %11
%88 = call i32 @inet_aton(i8* %87, %struct.in_addr* %9)
%89 = icmp ne i32 %88, 0
br i1 %89, label %92, label %90
90: ; preds = %86
%91 = call i32 @die(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.12, i64 0, i64 0))
br label %92
92: ; preds = %90, %86
%93 = getelementptr inbounds %struct.in_addr, %struct.in_addr* %9, i32 0, i32 0
%94 = load i8, i8* %93
store i8 %94, i8* %18
%95 = load i8*, i8** %10
%96 = icmp ne i8* %95, null
br i1 %96, label %99, label %97
97: ; preds = %92
%98 = call i8* (...) @get_interface()
store i8* %98, i8** %10
br label %99
99: ; preds = %97, %92
%100 = load i8*, i8** %10
%101 = icmp ne i8* %100, null
br i1 %101, label %104, label %102
102: ; preds = %99
%103 = call i32 @die(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.13, i64 0, i64 0))
br label %104
104: ; preds = %102, %99
%105 = load i8, i8* %13
%106 = icmp ne i8 %105, 0
br i1 %106, label %110, label %107
107: ; preds = %104
%108 = load i8*, i8** %10
%109 = call zeroext i8 @get_gateway(i8* %108)
store i8 %109, i8* %13
br label %110
110: ; preds = %107, %104
%111 = load i32, i32* @AF_PACKET
%112 = load i32, i32* @SOCK_DGRAM
%113 = load i32, i32* @ETH_P_ARP
%114 = call i32 @htons(i32 %113)
%115 = call i32 @socket(i32 %111, i32 %112, i32 %114)
store i32 %115, i32* %19
%116 = load i32, i32* %19
%117 = icmp eq i32 %116, -1
br i1 %117, label %118, label %122
118: ; preds = %110
%119 = load i32, i32* @errno
%120 = call i8* @strerror(i32 %119)
%121 = call i32 @die(i8* %120)
br label %122
122: ; preds = %118, %110
%123 = load i8, i8* %12
%124 = icmp ne i8 %123, 0
br i1 %124, label %125, label %134
125: ; preds = %122
%126 = load i32, i32* %19
%127 = load i8*, i8** %10
%128 = load i8, i8* %12
%129 = call i32 @request_mac(i32 %126, i8* %127, %struct.ether_arp* %6, i8 zeroext %128)
%130 = getelementptr inbounds [6 x i8], [6 x i8]* %7, i64 0, i64 0
%131 = getelementptr inbounds %struct.ether_arp, %struct.ether_arp* %6, i32 0, i32 0
%132 = load i8*, i8** %131
%133 = call i32 @memcpy(i8* %130, i8* %132, i32 6)
br label %152
134: ; preds = %122
%135 = load i8*, i8** %10
%136 = call i32 @set_ifr_name(%struct.ifreq* %20, i8* %135)
%137 = load i32, i32* %19
%138 = call i32 @get_ifr_hwaddr(i32 %137, %struct.ifreq* %20)
%139 = getelementptr inbounds [6 x i8], [6 x i8]* %7, i64 0, i64 0
%140 = getelementptr inbounds %struct.ifreq, %struct.ifreq* %20, i32 0, i32 1
%141 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %140, i32 0, i32 0
%142 = load i8*, i8** %141
%143 = call i32 @memcpy(i8* %139, i8* %142, i32 6)
%144 = load i32, i32* %19
%145 = call i32 @get_ifr_addr(i32 %144, %struct.ifreq* %20)
%146 = getelementptr inbounds %struct.ifreq, %struct.ifreq* %20, i32 0, i32 0
%147 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %146, i32 0, i32 0
%148 = load i64, i64* %147
%149 = inttoptr i64 %148 to i8*
%150 = getelementptr inbounds i8, i8* %149, i64 2
%151 = call i32 @memcpy(i8* %12, i8* %150, i32 1)
br label %152
152: ; preds = %134, %125
%153 = load i32, i32* %19
%154 = load i8*, i8** %10
%155 = load i8, i8* %18
%156 = call i32 @request_mac(i32 %153, i8* %154, %struct.ether_arp* %6, i8 zeroext %155)
%157 = getelementptr inbounds [6 x i8], [6 x i8]* %8, i64 0, i64 0
%158 = getelementptr inbounds %struct.ether_arp, %struct.ether_arp* %6, i32 0, i32 0
%159 = load i8*, i8** %158
%160 = call i32 @memcpy(i8* %157, i8* %159, i32 6)
%161 = load i32, i32* %15
%162 = icmp ne i32 %161, 0
br i1 %162, label %163, label %181
163: ; preds = %152
%164 = call i32 @puts(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.14, i64 0, i64 0))
%165 = load i8, i8* %12
%166 = getelementptr inbounds [6 x i8], [6 x i8]* %7, i64 0, i64 0
%167 = call i32 @print_addrs(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.15, i64 0, i64 0), i8 zeroext %165, i8* %166)
%168 = load i32, i32* %19
%169 = load i8*, i8** %10
%170 = load i8, i8* %13
%171 = call i32 @request_mac(i32 %168, i8* %169, %struct.ether_arp* %6, i8 zeroext %170)
%172 = load i8, i8* %13
%173 = getelementptr inbounds %struct.ether_arp, %struct.ether_arp* %6, i32 0, i32 0
%174 = load i8*, i8** %173
%175 = call i32 @print_addrs(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.16, i64 0, i64 0), i8 zeroext %172, i8* %174)
%176 = load i8, i8* %18
%177 = getelementptr inbounds [6 x i8], [6 x i8]* %8, i64 0, i64 0
%178 = call i32 @print_addrs(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.17, i64 0, i64 0), i8 zeroext %176, i8* %177)
%179 = load i8*, i8** %10
%180 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.18, i64 0, i64 0), i8* %179)
br label %181
181: ; preds = %163, %152
%182 = load i32, i32* %14
%183 = icmp ne i32 %182, 0
br i1 %183, label %184, label %187
184: ; preds = %181
%185 = load i32, i32* %14
%186 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.19, i64 0, i64 0), i32 %185)
br label %187
187: ; preds = %184, %181
br label %188
188: ; preds = %198, %187
%189 = load i32, i32* %19
%190 = load i8*, i8** %10
%191 = getelementptr inbounds [6 x i8], [6 x i8]* %7, i64 0, i64 0
%192 = load i8, i8* %13
%193 = getelementptr inbounds [6 x i8], [6 x i8]* %8, i64 0, i64 0
%194 = load i8, i8* %18
%195 = call i32 @arp_spoof(i32 %189, i8* %190, i8* %191, i8 zeroext %192, i8* %193, i8 zeroext %194)
%196 = load i32, i32* %14
%197 = call i32 @sleep(i32 %196)
br label %198
198: ; preds = %188
%199 = load i32, i32* %14
%200 = icmp ne i32 %199, 0
br i1 %200, label %188, label %201
201: ; preds = %198
%202 = load i8*, i8** %10
%203 = call i32 @free(i8* %202)
%204 = load i32, i32* @EXIT_SUCCESS
ret i32 %204
}

LLVM IR (-O2):
%struct.option = type { i8*, i8, i32*, i32 }
%struct.ether_arp = type { i8* }
%struct.in_addr = type { i8, i32 }
%struct.ifreq = type { %struct.TYPE_4__, %struct.TYPE_3__ }
%struct.TYPE_4__ = type { i64 }
%struct.TYPE_3__ = type { i8* }
@main.long_options = internal constant [6 x %struct.option] [%struct.option { i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i32 0, i32 0), i8 -128, i32* null, i32 97 }, %struct.option { i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i32 0, i32 0), i8 -128, i32* null, i32 105 }, %struct.option { i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i32 0, i32 0), i8 -128, i32* null, i32 114 }, %struct.option { i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i32 0, i32 0), i8 -128, i32* null, i32 103 }, %struct.option { i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i32 0, i32 0), i8 -127, i32* null, i32 118 }, %struct.option zeroinitializer]
@.str = [12 x i8] c"attacker-ip\00"
@.str.1 = [10 x i8] c"interface\00"
@.str.2 = [7 x i8] c"repeat\00"
@.str.3 = [11 x i8] c"gateway-ip\00"
@.str.4 = [8 x i8] c"verbose\00"
@.str.5 = [10 x i8] c"a:i:r:g:v\00"
@optarg = global i8* null
@.str.6 = [23 x i8] c"Attacker IP is invalid\00"
@.str.7 = [50 x i8] c"Invalid interface (nonexistent or not connected?)\00"
@.str.8 = [22 x i8] c"Gateway IP is invalid\00"
@.str.9 = [15 x i8] c"Invalid option\00"
@optind = global i32 0
@.str.10 = [19 x i8] c"Too many arguments\00"
@.str.11 = [27 x i8] c"Please provide a victim IP\00"
@.str.12 = [19 x i8] c"Invalid IP address\00"
@.str.13 = [50 x i8] c"No valid interface found (are you not connected?)\00"
@AF_PACKET = global i32 0
@SOCK_DGRAM = global i32 0
@ETH_P_ARP = global i32 0
@errno = global i32 0
@.str.14 = [25 x i8] c"\09\09IP address\09MAC address\00"
@.str.15 = [9 x i8] c"Attacker\00"
@.str.16 = [8 x i8] c"Gateway\00"
@.str.17 = [7 x i8] c"Victim\00"
@.str.18 = [16 x i8] c"\0AInterface:\09%s\0A\00"
@.str.19 = [45 x i8] c"Repeating every %d seconds (Ctrl+C to quit)\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca %struct.ether_arp
%4 = alloca [6 x i8]
%5 = alloca [6 x i8]
%6 = alloca i64
%7 = bitcast i64* %6 to %struct.in_addr*
%8 = alloca i8
%9 = alloca i32
%10 = alloca %struct.ifreq
%11 = bitcast %struct.ether_arp* %3 to i8*
%12 = getelementptr inbounds [6 x i8], [6 x i8]* %4, i64 0, i64 0
%13 = getelementptr inbounds [6 x i8], [6 x i8]* %5, i64 0, i64 0
%14 = bitcast i64* %6 to i8*
store i64 0, i64* %6
store i8 0, i8* %8
%15 = bitcast i32* %9 to i8*
br label %16
16: ; preds = %52, %2
%17 = phi i8 [ 0, %2 ], [ %53, %52 ]
%18 = phi i8 [ 0, %2 ], [ %54, %52 ]
%19 = phi i32 [ 0, %2 ], [ %55, %52 ]
%20 = phi i32 [ 0, %2 ], [ %56, %52 ]
%21 = phi i8* [ null, %2 ], [ %57, %52 ]
store i32 0, i32* %9
%22 = call i32 @getopt_long(i32 %0, i8** %1, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.5, i64 0, i64 0), %struct.option* getelementptr inbounds ([6 x %struct.option], [6 x %struct.option]* @main.long_options, i64 0, i64 0), i32* %9)
switch i32 %22, label %50 [
i32 -1, label %58
i32 97, label %23
i32 105, label %31
i32 114, label %38
i32 103, label %41
i32 118, label %49
i32 63, label %52
]
23: ; preds = %16
%24 = load i8*, i8** @optarg
%25 = call i32 @inet_aton(i8* %24, %struct.in_addr* %7)
%26 = icmp eq i32 %25, 0
br i1 %26, label %27, label %29
27: ; preds = %23
%28 = call i32 @die(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.6, i64 0, i64 0))
br label %29
29: ; preds = %27, %23
%30 = load i8, i8* %14
store i8 %30, i8* %8
br label %52
31: ; preds = %16
%32 = load i8*, i8** @optarg
%33 = call i8* @strdup(i8* %32)
%34 = call i32 @check_interface(i8* %33)
%35 = icmp eq i32 %34, 0
br i1 %35, label %36, label %52
36: ; preds = %31
%37 = call i32 @die(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.7, i64 0, i64 0))
br label %52
38: ; preds = %16
%39 = load i8*, i8** @optarg
%40 = call i32 @strtoul(i8* nocapture %39, i32* null, i32 10)
br label %52
41: ; preds = %16
%42 = load i8*, i8** @optarg
%43 = call i32 @inet_aton(i8* %42, %struct.in_addr* %7)
%44 = icmp eq i32 %43, 0
br i1 %44, label %45, label %47
45: ; preds = %41
%46 = call i32 @die(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.8, i64 0, i64 0))
br label %47
47: ; preds = %45, %41
%48 = load i8, i8* %14
br label %52
49: ; preds = %16
br label %52
50: ; preds = %16
%51 = call i32 @die(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.9, i64 0, i64 0))
br label %52
52: ; preds = %29, %38, %47, %49, %50, %36, %31, %16
%53 = phi i8 [ %17, %50 ], [ %17, %49 ], [ %17, %47 ], [ %17, %38 ], [ %17, %31 ], [ %17, %36 ], [ %30, %29 ], [ %17, %16 ]
%54 = phi i8 [ %18, %50 ], [ %18, %49 ], [ %48, %47 ], [ %18, %38 ], [ %18, %31 ], [ %18, %36 ], [ %18, %29 ], [ %18, %16 ]
%55 = phi i32 [ %19, %50 ], [ %19, %49 ], [ %19, %47 ], [ %40, %38 ], [ %19, %31 ], [ %19, %36 ], [ %19, %29 ], [ %19, %16 ]
%56 = phi i32 [ %20, %50 ], [ 1, %49 ], [ %20, %47 ], [ %20, %38 ], [ %20, %31 ], [ %20, %36 ], [ %20, %29 ], [ %20, %16 ]
%57 = phi i8* [ %21, %50 ], [ %21, %49 ], [ %21, %47 ], [ %21, %38 ], [ %33, %31 ], [ %33, %36 ], [ %21, %29 ], [ %21, %16 ]
br label %16
58: ; preds = %16
%59 = load i32, i32* @optind
%60 = add nsw i32 %59, 1
%61 = icmp slt i32 %60, %0
br i1 %61, label %62, label %64
62: ; preds = %58
%63 = call i32 @die(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.10, i64 0, i64 0))
br label %72
64: ; preds = %58
%65 = icmp eq i32 %59, %0
br i1 %65, label %66, label %68
66: ; preds = %64
%67 = call i32 @die(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.11, i64 0, i64 0))
br label %72
68: ; preds = %64
%69 = sext i32 %59 to i64
%70 = getelementptr inbounds i8*, i8** %1, i64 %69
%71 = load i8*, i8** %70
br label %72
72: ; preds = %66, %68, %62
%73 = phi i8* [ null, %62 ], [ null, %66 ], [ %71, %68 ]
%74 = call i32 @inet_aton(i8* %73, %struct.in_addr* %7)
%75 = icmp eq i32 %74, 0
br i1 %75, label %76, label %78
76: ; preds = %72
%77 = call i32 @die(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.12, i64 0, i64 0))
br label %78
78: ; preds = %76, %72
%79 = load i8, i8* %14
%80 = icmp eq i8* %21, null
br i1 %80, label %81, label %86
81: ; preds = %78
%82 = call i8* (...) @get_interface()
%83 = icmp eq i8* %82, null
br i1 %83, label %84, label %86
84: ; preds = %81
%85 = call i32 @die(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.13, i64 0, i64 0))
br label %86
86: ; preds = %78, %84, %81
%87 = phi i8* [ null, %84 ], [ %82, %81 ], [ %21, %78 ]
%88 = icmp eq i8 %18, 0
br i1 %88, label %89, label %91
89: ; preds = %86
%90 = call zeroext i8 @get_gateway(i8* %87)
br label %91
91: ; preds = %89, %86
%92 = phi i8 [ %18, %86 ], [ %90, %89 ]
%93 = load i32, i32* @AF_PACKET
%94 = load i32, i32* @SOCK_DGRAM
%95 = load i32, i32* @ETH_P_ARP
%96 = call i32 @htons(i32 %95)
%97 = call i32 @socket(i32 %93, i32 %94, i32 %96)
%98 = icmp eq i32 %97, -1
br i1 %98, label %99, label %103
99: ; preds = %91
%100 = load i32, i32* @errno
%101 = call i8* @strerror(i32 %100)
%102 = call i32 @die(i8* %101)
br label %103
103: ; preds = %99, %91
%104 = icmp eq i8 %17, 0
br i1 %104, label %110, label %105
105: ; preds = %103
%106 = call i32 @request_mac(i32 %97, i8* %87, %struct.ether_arp* %3, i8 zeroext %17)
%107 = getelementptr inbounds %struct.ether_arp, %struct.ether_arp* %3, i64 0, i32 0
%108 = load i8*, i8** %107
%109 = call i32 @memcpy(i8* %12, i8* %108, i32 6)
br label %123
110: ; preds = %103
%111 = bitcast %struct.ifreq* %10 to i8*
%112 = call i32 @set_ifr_name(%struct.ifreq* %10, i8* %87)
%113 = call i32 @get_ifr_hwaddr(i32 %97, %struct.ifreq* %10)
%114 = getelementptr inbounds %struct.ifreq, %struct.ifreq* %10, i64 0, i32 1, i32 0
%115 = load i8*, i8** %114
%116 = call i32 @memcpy(i8* %12, i8* %115, i32 6)
%117 = call i32 @get_ifr_addr(i32 %97, %struct.ifreq* %10)
%118 = getelementptr inbounds %struct.ifreq, %struct.ifreq* %10, i64 0, i32 0, i32 0
%119 = load i64, i64* %118
%120 = inttoptr i64 %119 to i8*
%121 = getelementptr inbounds i8, i8* %120, i64 2
%122 = call i32 @memcpy(i8* %8, i8* %121, i32 1)
br label %123
123: ; preds = %110, %105
%124 = call i32 @request_mac(i32 %97, i8* %87, %struct.ether_arp* %3, i8 zeroext %79)
%125 = getelementptr inbounds %struct.ether_arp, %struct.ether_arp* %3, i64 0, i32 0
%126 = load i8*, i8** %125
%127 = call i32 @memcpy(i8* %13, i8* %126, i32 6)
%128 = icmp eq i32 %20, 0
br i1 %128, label %138, label %129
129: ; preds = %123
%130 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.14, i64 0, i64 0))
%131 = load i8, i8* %8
%132 = call i32 @print_addrs(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.15, i64 0, i64 0), i8 zeroext %131, i8* %12)
%133 = call i32 @request_mac(i32 %97, i8* %87, %struct.ether_arp* %3, i8 zeroext %92)
%134 = load i8*, i8** %125
%135 = call i32 @print_addrs(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.16, i64 0, i64 0), i8 zeroext %92, i8* %134)
%136 = call i32 @print_addrs(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.17, i64 0, i64 0), i8 zeroext %79, i8* %13)
%137 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.18, i64 0, i64 0), i8* %87)
br label %138
138: ; preds = %129, %123
%139 = icmp eq i32 %19, 0
br i1 %139, label %145, label %140
140: ; preds = %138
%141 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([45 x i8], [45 x i8]* @.str.19, i64 0, i64 0), i32 %19)
br label %142
142: ; preds = %140, %142
%143 = call i32 @arp_spoof(i32 %97, i8* %87, i8* %12, i8 zeroext %92, i8* %13, i8 zeroext %79)
%144 = call i32 @sleep(i32 %19)
br i1 %139, label %148, label %142
145: ; preds = %138
%146 = call i32 @arp_spoof(i32 %97, i8* %87, i8* %12, i8 zeroext %92, i8* %13, i8 zeroext %79)
%147 = call i32 @sleep(i32 %19)
br label %148
148: ; preds = %142, %145
%149 = call i32 @free(i8* %87)
%150 = load i32, i32* @EXIT_SUCCESS
ret i32 %150
}