#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_2__ TYPE_1__;

/* Type definitions */
struct TYPE_2__ {
  unsigned int name_type;
  unsigned int VID;
  unsigned int skb_priority;
};
struct vlan_ioctl_args {
  unsigned short vlan_qos;
  int /*<<< orphan*/ cmd;
  TYPE_1__ u;
  int /*<<< orphan*/ device1;
};

/* Variables and functions */
int /*<<< orphan*/ ADD_VLAN_CMD;
int /*<<< orphan*/ AF_INET;
int /*<<< orphan*/ DEL_VLAN_CMD;
int /*<<< orphan*/ O_RDONLY;
int /*<<< orphan*/ SET_VLAN_EGRESS_PRIORITY_CMD;
int /*<<< orphan*/ SET_VLAN_FLAG_CMD;
int /*<<< orphan*/ SET_VLAN_INGRESS_PRIORITY_CMD;
int /*<<< orphan*/ SET_VLAN_NAME_TYPE_CMD;
int /*<<< orphan*/ SIOCSIFVLAN;
int /*<<< orphan*/ SOCK_STREAM;
unsigned int VLAN_NAME_TYPE_PLUS_VID;
unsigned int VLAN_NAME_TYPE_PLUS_VID_NO_PAD;
unsigned int VLAN_NAME_TYPE_RAW_PLUS_VID;
unsigned int VLAN_NAME_TYPE_RAW_PLUS_VID_NO_PAD;
void *atoi(char *);
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ errno;
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
scalar_t__ ioctl(int, int /*<<< orphan*/, struct vlan_ioctl_args *);
int /*<<< orphan*/ memset(struct vlan_ioctl_args *, int /*<<< orphan*/, int);
int open(char *, int /*<<< orphan*/);
int /*<<< orphan*/ show_usage();
int socket(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdout;
scalar_t__ strcasecmp(char *, char *);
int /*<<< orphan*/ strcpy(int /*<<< orphan*/, char *);
char *strerror(int /*<<< orphan*/);
int strlen(char *);
int main(int argc, char **argv) {
  int fd;
  struct vlan_ioctl_args if_request;
  char *cmd = NULL;
  char *if_name = NULL;
  unsigned int vid = 0;
  unsigned int skb_priority;
  unsigned short vlan_qos;
  unsigned int nm_type = VLAN_NAME_TYPE_PLUS_VID;
  char *conf_file_name = "/proc/net/vlan/config";
  memset(&if_request, 0, sizeof(struct vlan_ioctl_args));
  if ((argc < 3) || (argc > 5)) {
    fprintf(stdout, "Expecting argc to be 3-5, inclusive.  Was: %d\n", argc);
    show_usage();
    exit(1);
  } else {
    cmd = argv[1];
    if (strcasecmp(cmd, "set_name_type") == 0) {
      if (strcasecmp(argv[2], "VLAN_PLUS_VID") == 0) {
        nm_type = VLAN_NAME_TYPE_PLUS_VID;
      } else if (strcasecmp(argv[2], "VLAN_PLUS_VID_NO_PAD") == 0) {
        nm_type = VLAN_NAME_TYPE_PLUS_VID_NO_PAD;
      } else if (strcasecmp(argv[2], "DEV_PLUS_VID") == 0) {
        nm_type = VLAN_NAME_TYPE_RAW_PLUS_VID;
      } else if (strcasecmp(argv[2], "DEV_PLUS_VID_NO_PAD") == 0) {
        nm_type = VLAN_NAME_TYPE_RAW_PLUS_VID_NO_PAD;
      } else {
        fprintf(stderr, "Invalid name type.\n");
        show_usage();
        exit(1);
      }
      if_request.u.name_type = nm_type;
    } else {
      if_name = argv[2];
      if (strlen(if_name) > 15) {
        fprintf(stderr, "ERROR:  if_name must be 15 characters or less.\n");
        exit(1);
      }
      strcpy(if_request.device1, if_name);
    }
    if (argc == 4) {
      vid = atoi(argv[3]);
      if_request.u.VID = vid;
    }
    if (argc == 5) {
      skb_priority = atoi(argv[3]);
      vlan_qos = atoi(argv[4]);
      if_request.u.skb_priority = skb_priority;
      if_request.vlan_qos = vlan_qos;
    }
  }
  if ((fd = open(conf_file_name, O_RDONLY)) < 0) {
    fprintf(stderr,
            "WARNING:  Could not open /proc/net/vlan/config.  Maybe you need "
            "to load the 8021q module, or maybe you are not using PROCFS??\n");
  } else {
    close(fd);
  }
  if ((fd = socket(AF_INET, SOCK_STREAM, 0)) < 0) {
    fprintf(stderr, "FATAL:  Couldn't open a socket..go figure!\n");
    exit(2);
  }
  if (strcasecmp(cmd, "add") == 0) {
    if_request.cmd = ADD_VLAN_CMD;
    if (ioctl(fd, SIOCSIFVLAN, &if_request) < 0) {
      fprintf(stderr, "ERROR: trying to add VLAN #%u to IF -:%s:-  error: %s\n",
              vid, if_name, strerror(errno));
    }
  } else if (strcasecmp(cmd, "rem") == 0) {
    if_request.cmd = DEL_VLAN_CMD;
    if (ioctl(fd, SIOCSIFVLAN, &if_request) < 0) {
      fprintf(stderr, "ERROR: trying to remove VLAN -:%s:- error: %s\n",
              if_name, strerror(errno));
    }
  } else if (strcasecmp(cmd, "set_egress_map") == 0) {
    if_request.cmd = SET_VLAN_EGRESS_PRIORITY_CMD;
    if (ioctl(fd, SIOCSIFVLAN, &if_request) < 0) {
      fprintf(stderr,
              "ERROR: trying to set egress map on device -:%s:- error: %s\n",
              if_name, strerror(errno));
    }
  } else if (strcasecmp(cmd, "set_ingress_map") == 0) {
    if_request.cmd = SET_VLAN_INGRESS_PRIORITY_CMD;
    if (ioctl(fd, SIOCSIFVLAN, &if_request) < 0) {
      fprintf(stderr,
              "ERROR: trying to set ingress map on device -:%s:- error: %s\n",
              if_name, strerror(errno));
    }
  } else if (strcasecmp(cmd, "set_flag") == 0) {
    if_request.cmd = SET_VLAN_FLAG_CMD;
    if (ioctl(fd, SIOCSIFVLAN, &if_request) < 0) {
      fprintf(stderr, "ERROR: trying to set flag on device -:%s:- error: %s\n",
              if_name, strerror(errno));
    }
  } else if (strcasecmp(cmd, "set_name_type") == 0) {
    if_request.cmd = SET_VLAN_NAME_TYPE_CMD;
    if (ioctl(fd, SIOCSIFVLAN, &if_request) < 0) {
      fprintf(stderr,
              "ERROR: trying to set name type for VLAN subsystem, error: %s\n",
              strerror(errno));
    }
  } else {
    fprintf(stderr, "Unknown command -:%s:-\n", cmd);
    show_usage();
    exit(5);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xb0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x38(%rbp)
movq   $0x0,-0x40(%rbp)
movl   $0x0,-0x44(%rbp)
mov    0x2d81(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x50(%rbp)
lea    0xded(%rip),%rax
mov    %rax,-0x58(%rbp)
lea    -0x30(%rbp),%rdi
xor    %esi,%esi
mov    $0x18,%edx
call   1060 <memset@plt>
cmpl   $0x3,-0x8(%rbp)
jl     123b <main+0x6b>
cmpl   $0x5,-0x8(%rbp)
jle    1266 <main+0x96>
mov    0x2d1e(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%edx
lea    0xdc8(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
mov    $0x0,%al
call   10a0 <show_usage@plt>
mov    $0x1,%edi
call   10d0 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rdi
lea    0xdc8(%rip),%rsi
call   1030 <strcasecmp@plt>
cmp    $0x0,%rax
jne    138a <main+0x1ba>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xdb8(%rip),%rsi
call   1030 <strcasecmp@plt>
cmp    $0x0,%rax
jne    12bb <main+0xeb>
mov    0x2cd7(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x50(%rbp)
jmp    137f <main+0x1af>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xd97(%rip),%rsi
call   1030 <strcasecmp@plt>
cmp    $0x0,%rax
jne    12ea <main+0x11a>
mov    0x2d00(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x50(%rbp)
jmp    137a <main+0x1aa>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xd7d(%rip),%rsi
call   1030 <strcasecmp@plt>
cmp    $0x0,%rax
jne    1319 <main+0x149>
mov    0x2c91(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x50(%rbp)
jmp    1375 <main+0x1a5>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xd5b(%rip),%rsi
call   1030 <strcasecmp@plt>
cmp    $0x0,%rax
jne    1348 <main+0x178>
mov    0x2c5a(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x50(%rbp)
jmp    1370 <main+0x1a0>
mov    0x2c41(%rip),%rax
mov    (%rax),%edi
lea    0xd3f(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
mov    $0x0,%al
call   10a0 <show_usage@plt>
mov    $0x1,%edi
call   10d0 <exit@plt>
jmp    1375 <main+0x1a5>
jmp    137a <main+0x1aa>
jmp    137f <main+0x1af>
mov    -0x50(%rbp),%eax
mov    %eax,-0x28(%rbp)
jmp    13d5 <main+0x205>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rax
mov    %rax,-0x40(%rbp)
mov    -0x40(%rbp),%rdi
call   1050 <strlen@plt>
cmp    $0xf,%eax
jle    13c9 <main+0x1f9>
mov    0x2be1(%rip),%rax
mov    (%rax),%edi
lea    0xcf3(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
mov    $0x1,%edi
call   10d0 <exit@plt>
mov    -0x1c(%rbp),%edi
mov    -0x40(%rbp),%rsi
call   1040 <strcpy@plt>
cmpl   $0x4,-0x8(%rbp)
jne    13f5 <main+0x225>
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
call   10c0 <atoi@plt>
mov    %eax,-0x44(%rbp)
mov    -0x44(%rbp),%eax
mov    %eax,-0x24(%rbp)
cmpl   $0x5,-0x8(%rbp)
jne    142e <main+0x25e>
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
call   10c0 <atoi@plt>
mov    %eax,-0x48(%rbp)
mov    -0x10(%rbp),%rax
mov    0x20(%rax),%rdi
call   10c0 <atoi@plt>
mov    %ax,-0x4a(%rbp)
mov    -0x48(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0x4a(%rbp),%ax
mov    %ax,-0x30(%rbp)
jmp    1433 <main+0x263>
mov    -0x58(%rbp),%rdi
mov    0x2b92(%rip),%rax
mov    (%rax),%esi
call   10b0 <open@plt>
mov    %eax,-0x14(%rbp)
cmp    $0x0,%eax
jge    146d <main+0x29d>
mov    0x2b38(%rip),%rax
mov    (%rax),%edi
lea    0xc7a(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
jmp    1475 <main+0x2a5>
mov    -0x14(%rbp),%edi
call   1080 <close@plt>
mov    0x2b5c(%rip),%rax
mov    (%rax),%edi
mov    0x2afb(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   10f0 <socket@plt>
mov    %eax,-0x14(%rbp)
cmp    $0x0,%eax
jge    14bb <main+0x2eb>
mov    0x2aef(%rip),%rax
mov    (%rax),%edi
lea    0xcb0(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
mov    $0x2,%edi
call   10d0 <exit@plt>
mov    -0x38(%rbp),%rdi
lea    0xcc0(%rip),%rsi
call   1030 <strcasecmp@plt>
cmp    $0x0,%rax
jne    1548 <main+0x378>
mov    0x2a8c(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x2c(%rbp)
mov    -0x14(%rbp),%edi
mov    0x2acd(%rip),%rax
mov    (%rax),%esi
lea    -0x30(%rbp),%rdx
call   1070 <ioctl@plt>
cmp    $0x0,%rax
jge    1543 <main+0x373>
mov    0x2a89(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x68(%rbp)
mov    -0x44(%rbp),%eax
mov    %eax,-0x64(%rbp)
mov    -0x40(%rbp),%rax
mov    %rax,-0x60(%rbp)
mov    0x2a57(%rip),%rax
mov    (%rax),%edi
call   10e0 <strerror@plt>
mov    -0x68(%rbp),%edi
mov    -0x64(%rbp),%edx
mov    -0x60(%rbp),%rcx
mov    %rax,%r8
lea    0xc4e(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
jmp    1839 <main+0x669>
mov    -0x38(%rbp),%rdi
lea    0xc6e(%rip),%rsi
call   1030 <strcasecmp@plt>
cmp    $0x0,%rax
jne    15cc <main+0x3fc>
mov    0x2a57(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x2c(%rbp)
mov    -0x14(%rbp),%edi
mov    0x2a40(%rip),%rax
mov    (%rax),%esi
lea    -0x30(%rbp),%rdx
call   1070 <ioctl@plt>
cmp    $0x0,%rax
jge    15c7 <main+0x3f7>
mov    0x29fc(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x74(%rbp)
mov    -0x40(%rbp),%rax
mov    %rax,-0x70(%rbp)
mov    0x29d0(%rip),%rax
mov    (%rax),%edi
call   10e0 <strerror@plt>
mov    -0x74(%rbp),%edi
mov    -0x70(%rbp),%rdx
mov    %rax,%rcx
lea    0xc05(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
jmp    1834 <main+0x664>
mov    -0x38(%rbp),%rdi
lea    0xc1d(%rip),%rsi
call   1030 <strcasecmp@plt>
cmp    $0x0,%rax
jne    1656 <main+0x486>
mov    0x2983(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x2c(%rbp)
mov    -0x14(%rbp),%edi
mov    0x29bc(%rip),%rax
mov    (%rax),%esi
lea    -0x30(%rbp),%rdx
call   1070 <ioctl@plt>
cmp    $0x0,%rax
jge    1651 <main+0x481>
mov    0x2978(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x84(%rbp)
mov    -0x40(%rbp),%rax
mov    %rax,-0x80(%rbp)
mov    0x2949(%rip),%rax
mov    (%rax),%edi
call   10e0 <strerror@plt>
mov    -0x84(%rbp),%edi
mov    -0x80(%rbp),%rdx
mov    %rax,%rcx
lea    0xbb9(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
jmp    182f <main+0x65f>
mov    -0x38(%rbp),%rdi
lea    0xbde(%rip),%rsi
call   1030 <strcasecmp@plt>
cmp    $0x0,%rax
jne    16e6 <main+0x516>
mov    0x2951(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x2c(%rbp)
mov    -0x14(%rbp),%edi
mov    0x2932(%rip),%rax
mov    (%rax),%esi
lea    -0x30(%rbp),%rdx
call   1070 <ioctl@plt>
cmp    $0x0,%rax
jge    16e1 <main+0x511>
mov    0x28ee(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x94(%rbp)
mov    -0x40(%rbp),%rax
mov    %rax,-0x90(%rbp)
mov    0x28bc(%rip),%rax
mov    (%rax),%edi
call   10e0 <strerror@plt>
mov    -0x94(%rbp),%edi
mov    -0x90(%rbp),%rdx
mov    %rax,%rcx
lea    0xb75(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
jmp    182a <main+0x65a>
mov    -0x38(%rbp),%rdi
lea    0xb9b(%rip),%rsi
call   1030 <strcasecmp@plt>
cmp    $0x0,%rax
jne    1776 <main+0x5a6>
mov    0x28f1(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x2c(%rbp)
mov    -0x14(%rbp),%edi
mov    0x28a2(%rip),%rax
mov    (%rax),%esi
lea    -0x30(%rbp),%rdx
call   1070 <ioctl@plt>
cmp    $0x0,%rax
jge    1771 <main+0x5a1>
mov    0x285e(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0xa4(%rbp)
mov    -0x40(%rbp),%rax
mov    %rax,-0xa0(%rbp)
mov    0x282c(%rip),%rax
mov    (%rax),%edi
call   10e0 <strerror@plt>
mov    -0xa4(%rbp),%edi
mov    -0xa0(%rbp),%rdx
mov    %rax,%rcx
lea    0xb2b(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
jmp    1825 <main+0x655>
mov    -0x38(%rbp),%rdi
lea    0x8c4(%rip),%rsi
call   1030 <strcasecmp@plt>
cmp    $0x0,%rax
jne    17f4 <main+0x624>
mov    0x2819(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x2c(%rbp)
mov    -0x14(%rbp),%edi
mov    0x2812(%rip),%rax
mov    (%rax),%esi
lea    -0x30(%rbp),%rdx
call   1070 <ioctl@plt>
cmp    $0x0,%rax
jge    17ef <main+0x61f>
mov    0x27ce(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0xa8(%rbp)
mov    0x27a7(%rip),%rax
mov    (%rax),%edi
call   10e0 <strerror@plt>
mov    -0xa8(%rbp),%edi
mov    %rax,%rdx
lea    0xae3(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
jmp    1820 <main+0x650>
mov    0x2795(%rip),%rax
mov    (%rax),%edi
mov    -0x38(%rbp),%rdx
lea    0xb01(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
mov    $0x0,%al
call   10a0 <show_usage@plt>
mov    $0x5,%edi
call   10d0 <exit@plt>
jmp    1825 <main+0x655>
jmp    182a <main+0x65a>
jmp    182f <main+0x65f>
jmp    1834 <main+0x664>
jmp    1839 <main+0x669>
xor    %eax,%eax
add    $0xb0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x20,%rsp
mov    %rsi,%rbx
mov    %edi,%r13d
lea    0x8(%rsp),%rdi
xor    %esi,%esi
mov    $0x18,%edx
call   1060 <memset@plt>
lea    -0x6(%r13),%eax
cmp    $0xfffffffc,%eax
jbe    15e9 <main+0x419>
mov    0x8(%rbx),%r15
lea    0xe39(%rip),%rsi
mov    %r15,%rdi
call   1030 <strcasecmp@plt>
mov    0x10(%rbx),%r14
test   %rax,%rax
je     123c <main+0x6c>
mov    %r14,%rdi
call   1050 <strlen@plt>
cmp    $0x10,%eax
jge    1635 <main+0x465>
mov    0x1c(%rsp),%edi
mov    %r14,%rsi
call   1040 <strcpy@plt>
jmp    12bb <main+0xeb>
lea    0xe10(%rip),%rsi
mov    %r14,%rdi
call   1030 <strcasecmp@plt>
test   %rax,%rax
je     1299 <main+0xc9>
lea    0xe0a(%rip),%rsi
mov    %r14,%rdi
call   1030 <strcasecmp@plt>
test   %rax,%rax
je     12a2 <main+0xd2>
lea    0xe0b(%rip),%rsi
mov    %r14,%rdi
call   1030 <strcasecmp@plt>
test   %rax,%rax
je     12ab <main+0xdb>
lea    0xe04(%rip),%rsi
mov    %r14,%rdi
call   1030 <strcasecmp@plt>
test   %rax,%rax
jne    1656 <main+0x486>
mov    0x2d01(%rip),%rax
jmp    12b2 <main+0xe2>
mov    0x2ce8(%rip),%rax
jmp    12b2 <main+0xe2>
mov    0x2d37(%rip),%rax
jmp    12b2 <main+0xe2>
mov    0x2cee(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x10(%rsp)
xor    %r14d,%r14d
xor    %r12d,%r12d
cmp    $0x5,%r13d
je     12dd <main+0x10d>
cmp    $0x4,%r13d
jne    12fc <main+0x12c>
mov    0x18(%rbx),%rdi
call   10c0 <atoi@plt>
mov    %rax,%r12
mov    %r12d,0x14(%rsp)
jmp    12fc <main+0x12c>
mov    0x18(%rbx),%rdi
call   10c0 <atoi@plt>
mov    %rax,%r13
mov    0x20(%rbx),%rdi
call   10c0 <atoi@plt>
mov    %r13d,0x18(%rsp)
mov    %ax,0x8(%rsp)
mov    0x2ccd(%rip),%rax
mov    (%rax),%esi
lea    0xcf4(%rip),%rdi
call   10b0 <open@plt>
test   %eax,%eax
js     131e <main+0x14e>
mov    %eax,%edi
call   1080 <close@plt>
jmp    1335 <main+0x165>
mov    0x2c6b(%rip),%rax
mov    (%rax),%edi
lea    0xdad(%rip),%rsi
xor    %eax,%eax
call   1090 <fprintf@plt>
mov    0x2c9c(%rip),%rax
mov    (%rax),%edi
mov    0x2c3b(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   10f0 <socket@plt>
test   %eax,%eax
js     1614 <main+0x444>
mov    %eax,%ebx
lea    0xe27(%rip),%rsi
mov    %r15,%rdi
call   1030 <strcasecmp@plt>
test   %rax,%rax
je     1442 <main+0x272>
lea    0xe4a(%rip),%rsi
mov    %r15,%rdi
call   1030 <strcasecmp@plt>
test   %rax,%rax
je     14a2 <main+0x2d2>
lea    0xe65(%rip),%rsi
mov    %r15,%rdi
call   1030 <strcasecmp@plt>
test   %rax,%rax
je     14f0 <main+0x320>
lea    0xe98(%rip),%rsi
mov    %r15,%rdi
call   1030 <strcasecmp@plt>
test   %rax,%rax
je     153e <main+0x36e>
lea    0xecd(%rip),%rsi
mov    %r15,%rdi
call   1030 <strcasecmp@plt>
test   %rax,%rax
je     1585 <main+0x3b5>
lea    0xc6e(%rip),%rsi
mov    %r15,%rdi
call   1030 <strcasecmp@plt>
test   %rax,%rax
jne    166f <main+0x49f>
mov    0x2bc1(%rip),%rax
mov    (%rax),%eax
mov    %eax,0xc(%rsp)
mov    0x2bbc(%rip),%rax
mov    (%rax),%esi
lea    0x8(%rsp),%rdx
mov    %ebx,%edi
call   1070 <ioctl@plt>
test   %rax,%rax
jns    15d9 <main+0x409>
mov    0x2b76(%rip),%rax
mov    (%rax),%ebx
mov    0x2b55(%rip),%rax
mov    (%rax),%edi
call   10e0 <strerror@plt>
lea    0xe9a(%rip),%rsi
mov    %ebx,%edi
mov    %rax,%rdx
xor    %eax,%eax
call   1090 <fprintf@plt>
jmp    15d9 <main+0x409>
mov    0x2b1f(%rip),%rax
mov    (%rax),%eax
mov    %eax,0xc(%rsp)
mov    0x2b62(%rip),%rax
mov    (%rax),%esi
lea    0x8(%rsp),%rdx
mov    %ebx,%edi
call   1070 <ioctl@plt>
test   %rax,%rax
jns    15d9 <main+0x409>
mov    0x2b1c(%rip),%rax
mov    (%rax),%ebx
mov    0x2afb(%rip),%rax
mov    (%rax),%edi
call   10e0 <strerror@plt>
lea    0xcff(%rip),%rsi
mov    %ebx,%edi
mov    %r12d,%edx
mov    %r14,%rcx
mov    %rax,%r8
xor    %eax,%eax
call   1090 <fprintf@plt>
jmp    15d9 <main+0x409>
mov    0x2b17(%rip),%rax
mov    (%rax),%eax
mov    %eax,0xc(%rsp)
mov    0x2b02(%rip),%rax
mov    (%rax),%esi
lea    0x8(%rsp),%rdx
mov    %ebx,%edi
call   1070 <ioctl@plt>
test   %rax,%rax
jns    15d9 <main+0x409>
mov    0x2abc(%rip),%rax
mov    (%rax),%ebx
mov    0x2a9b(%rip),%rax
mov    (%rax),%edi
call   10e0 <strerror@plt>
lea    0xcda(%rip),%rsi
jmp    15ca <main+0x3fa>
mov    0x2a79(%rip),%rax
mov    (%rax),%eax
mov    %eax,0xc(%rsp)
mov    0x2ab4(%rip),%rax
mov    (%rax),%esi
lea    0x8(%rsp),%rdx
mov    %ebx,%edi
call   1070 <ioctl@plt>
test   %rax,%rax
jns    15d9 <main+0x409>
mov    0x2a6e(%rip),%rax
mov    (%rax),%ebx
mov    0x2a4d(%rip),%rax
mov    (%rax),%edi
call   10e0 <strerror@plt>
lea    0xcca(%rip),%rsi
jmp    15ca <main+0x3fa>
mov    0x2a83(%rip),%rax
mov    (%rax),%eax
mov    %eax,0xc(%rsp)
mov    0x2a66(%rip),%rax
mov    (%rax),%esi
lea    0x8(%rsp),%rdx
mov    %ebx,%edi
call   1070 <ioctl@plt>
test   %rax,%rax
jns    15d9 <main+0x409>
mov    0x2a24(%rip),%rax
mov    (%rax),%ebx
mov    0x2a03(%rip),%rax
mov    (%rax),%edi
call   10e0 <strerror@plt>
lea    0xccc(%rip),%rsi
jmp    15ca <main+0x3fa>
mov    0x2a6c(%rip),%rax
mov    (%rax),%eax
mov    %eax,0xc(%rsp)
mov    0x2a1f(%rip),%rax
mov    (%rax),%esi
lea    0x8(%rsp),%rdx
mov    %ebx,%edi
call   1070 <ioctl@plt>
test   %rax,%rax
jns    15d9 <main+0x409>
mov    0x29dd(%rip),%rax
mov    (%rax),%ebx
mov    0x29bc(%rip),%rax
mov    (%rax),%edi
call   10e0 <strerror@plt>
lea    0xccb(%rip),%rsi
mov    %ebx,%edi
mov    %r14,%rdx
mov    %rax,%rcx
xor    %eax,%eax
call   1090 <fprintf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret
mov    0x2970(%rip),%rax
mov    (%rax),%edi
lea    0xa1d(%rip),%rsi
mov    %r13d,%edx
xor    %eax,%eax
call   1090 <fprintf@plt>
xor    %eax,%eax
call   10a0 <show_usage@plt>
mov    $0x1,%edi
call   10d0 <exit@plt>
mov    0x2975(%rip),%rax
mov    (%rax),%edi
lea    0xb36(%rip),%rsi
xor    %eax,%eax
call   1090 <fprintf@plt>
mov    $0x2,%edi
call   10d0 <exit@plt>
mov    0x2954(%rip),%rax
mov    (%rax),%edi
lea    0xa66(%rip),%rsi
xor    %eax,%eax
call   1090 <fprintf@plt>
mov    $0x1,%edi
call   10d0 <exit@plt>
mov    0x2933(%rip),%rax
mov    (%rax),%edi
lea    0xa31(%rip),%rsi
xor    %eax,%eax
call   1090 <fprintf@plt>
jmp    1603 <main+0x433>
mov    0x291a(%rip),%rax
mov    (%rax),%edi
lea    0xc8a(%rip),%rsi
mov    %r15,%rdx
xor    %eax,%eax
call   1090 <fprintf@plt>
xor    %eax,%eax
call   10a0 <show_usage@plt>
mov    $0x5,%edi
call   10d0 <exit@plt>

LLVM IR (-O0):
%struct.vlan_ioctl_args = type { i16, i32, %struct.TYPE_2__, i32 }
%struct.TYPE_2__ = type { i32, i32, i32 }
@VLAN_NAME_TYPE_PLUS_VID = global i32 0
@.str = [22 x i8] c"/proc/net/vlan/config\00"
@stdout = global i32 0
@.str.1 = [47 x i8] c"Expecting argc to be 3-5, inclusive. Was: %d\0A\00"
@.str.2 = [14 x i8] c"set_name_type\00"
@.str.3 = [14 x i8] c"VLAN_PLUS_VID\00"
@.str.4 = [21 x i8] c"VLAN_PLUS_VID_NO_PAD\00"
@VLAN_NAME_TYPE_PLUS_VID_NO_PAD = global i32 0
@.str.5 = [13 x i8] c"DEV_PLUS_VID\00"
@VLAN_NAME_TYPE_RAW_PLUS_VID = global i32 0
@.str.6 = [20 x i8] c"DEV_PLUS_VID_NO_PAD\00"
@VLAN_NAME_TYPE_RAW_PLUS_VID_NO_PAD = global i32 0
@stderr = global i32 0
@.str.7 = [20 x i8] c"Invalid name type.\0A\00"
@.str.8 = [48 x i8] c"ERROR: if_name must be 15 characters or less.\0A\00"
@O_RDONLY = global i32 0
@.str.9 = [127 x i8] c"WARNING: Could not open /proc/net/vlan/config. Maybe you need to load the 8021q module, or maybe you are not using PROCFS??\0A\00"
@AF_INET = global i32 0
@SOCK_STREAM = global i32 0
@.str.10 = [44 x i8] c"FATAL: Couldn't open a socket..go figure!\0A\00"
@.str.11 = [4 x i8] c"add\00"
@ADD_VLAN_CMD = global i32 0
@SIOCSIFVLAN = global i32 0
@.str.12 = [55 x i8] c"ERROR: trying to add VLAN #%u to IF -:%s:- error: %s\0A\00"
@errno = global i32 0
@.str.13 = [4 x i8] c"rem\00"
@DEL_VLAN_CMD = global i32 0
@.str.14 = [47 x i8] c"ERROR: trying to remove VLAN -:%s:- error: %s\0A\00"
@.str.15 = [15 x i8] c"set_egress_map\00"
@SET_VLAN_EGRESS_PRIORITY_CMD = global i32 0
@.str.16 = [60 x i8] c"ERROR: trying to set egress map on device -:%s:- error: %s\0A\00"
@.str.17 = [16 x i8] c"set_ingress_map\00"
@SET_VLAN_INGRESS_PRIORITY_CMD = global i32 0
@.str.18 = [61 x i8] c"ERROR: trying to set ingress map on device -:%s:- error: %s\0A\00"
@.str.19 = [9 x i8] c"set_flag\00"
@SET_VLAN_FLAG_CMD = global i32 0
@.str.20 = [54 x i8] c"ERROR: trying to set flag on device -:%s:- error: %s\0A\00"
@SET_VLAN_NAME_TYPE_CMD = global i32 0
@.str.21 = [62 x i8] c"ERROR: trying to set name type for VLAN subsystem, error: %s\0A\00"
@.str.22 = [24 x i8] c"Unknown command -:%s:-\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca %struct.vlan_ioctl_args
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i32
%11 = alloca i32
%12 = alloca i16
%13 = alloca i32
%14 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i8* null, i8** %8
store i8* null, i8** %9
store i32 0, i32* %10
%15 = load i32, i32* @VLAN_NAME_TYPE_PLUS_VID
store i32 %15, i32* %13
store i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i8** %14
%16 = call i32 @memset(%struct.vlan_ioctl_args* %7, i32 0, i32 24)
%17 = load i32, i32* %4
%18 = icmp slt i32 %17, 3
br i1 %18, label %22, label %19
19: ; preds = %2
%20 = load i32, i32* %4
%21 = icmp sgt i32 %20, 5
br i1 %21, label %22, label %28
22: ; preds = %19, %2
%23 = load i32, i32* @stdout
%24 = load i32, i32* %4
%25 = call i32 (i32, i8*, ...) @fprintf(i32 %23, i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.1, i64 0, i64 0), i32 %24)
%26 = call i32 (...) @show_usage()
%27 = call i32 @exit(i32 1)
unreachable
28: ; preds = %19
%29 = load i8**, i8*** %5
%30 = getelementptr inbounds i8*, i8** %29, i64 1
%31 = load i8*, i8** %30
store i8* %31, i8** %8
%32 = load i8*, i8** %8
%33 = call i64 @strcasecmp(i8* %32, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0))
%34 = icmp eq i64 %33, 0
br i1 %34, label %35, label %79
35: ; preds = %28
%36 = load i8**, i8*** %5
%37 = getelementptr inbounds i8*, i8** %36, i64 2
%38 = load i8*, i8** %37
%39 = call i64 @strcasecmp(i8* %38, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0))
%40 = icmp eq i64 %39, 0
br i1 %40, label %41, label %43
41: ; preds = %35
%42 = load i32, i32* @VLAN_NAME_TYPE_PLUS_VID
store i32 %42, i32* %13
br label %75
43: ; preds = %35
%44 = load i8**, i8*** %5
%45 = getelementptr inbounds i8*, i8** %44, i64 2
%46 = load i8*, i8** %45
%47 = call i64 @strcasecmp(i8* %46, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.4, i64 0, i64 0))
%48 = icmp eq i64 %47, 0
br i1 %48, label %49, label %51
49: ; preds = %43
%50 = load i32, i32* @VLAN_NAME_TYPE_PLUS_VID_NO_PAD
store i32 %50, i32* %13
br label %74
51: ; preds = %43
%52 = load i8**, i8*** %5
%53 = getelementptr inbounds i8*, i8** %52, i64 2
%54 = load i8*, i8** %53
%55 = call i64 @strcasecmp(i8* %54, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.5, i64 0, i64 0))
%56 = icmp eq i64 %55, 0
br i1 %56, label %57, label %59
57: ; preds = %51
%58 = load i32, i32* @VLAN_NAME_TYPE_RAW_PLUS_VID
store i32 %58, i32* %13
br label %73
59: ; preds = %51
%60 = load i8**, i8*** %5
%61 = getelementptr inbounds i8*, i8** %60, i64 2
%62 = load i8*, i8** %61
%63 = call i64 @strcasecmp(i8* %62, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.6, i64 0, i64 0))
%64 = icmp eq i64 %63, 0
br i1 %64, label %65, label %67
65: ; preds = %59
%66 = load i32, i32* @VLAN_NAME_TYPE_RAW_PLUS_VID_NO_PAD
store i32 %66, i32* %13
br label %72
67: ; preds = %59
%68 = load i32, i32* @stderr
%69 = call i32 (i32, i8*, ...) @fprintf(i32 %68, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.7, i64 0, i64 0))
%70 = call i32 (...) @show_usage()
%71 = call i32 @exit(i32 1)
unreachable
72: ; preds = %65
br label %73
73: ; preds = %72, %57
br label %74
74: ; preds = %73, %49
br label %75
75: ; preds = %74, %41
%76 = load i32, i32* %13
%77 = getelementptr inbounds %struct.vlan_ioctl_args, %struct.vlan_ioctl_args* %7, i32 0, i32 2
%78 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %77, i32 0, i32 0
store i32 %76, i32* %78
br label %95
79: ; preds = %28
%80 = load i8**, i8*** %5
%81 = getelementptr inbounds i8*, i8** %80, i64 2
%82 = load i8*, i8** %81
store i8* %82, i8** %9
%83 = load i8*, i8** %9
%84 = call i32 @strlen(i8* %83)
%85 = icmp sgt i32 %84, 15
br i1 %85, label %86, label %90
86: ; preds = %79
%87 = load i32, i32* @stderr
%88 = call i32 (i32, i8*, ...) @fprintf(i32 %87, i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.8, i64 0, i64 0))
%89 = call i32 @exit(i32 1)
unreachable
90: ; preds = %79
%91 = getelementptr inbounds %struct.vlan_ioctl_args, %struct.vlan_ioctl_args* %7, i32 0, i32 3
%92 = load i32, i32* %91
%93 = load i8*, i8** %9
%94 = call i32 @strcpy(i32 %92, i8* %93)
br label %95
95: ; preds = %90, %75
%96 = load i32, i32* %4
%97 = icmp eq i32 %96, 4
br i1 %97, label %98, label %107
98: ; preds = %95
%99 = load i8**, i8*** %5
%100 = getelementptr inbounds i8*, i8** %99, i64 3
%101 = load i8*, i8** %100
%102 = call i8* @atoi(i8* %101)
%103 = ptrtoint i8* %102 to i32
store i32 %103, i32* %10
%104 = load i32, i32* %10
%105 = getelementptr inbounds %struct.vlan_ioctl_args, %struct.vlan_ioctl_args* %7, i32 0, i32 2
%106 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %105, i32 0, i32 1
store i32 %104, i32* %106
br label %107
107: ; preds = %98, %95
%108 = load i32, i32* %4
%109 = icmp eq i32 %108, 5
br i1 %109, label %110, label %126
110: ; preds = %107
%111 = load i8**, i8*** %5
%112 = getelementptr inbounds i8*, i8** %111, i64 3
%113 = load i8*, i8** %112
%114 = call i8* @atoi(i8* %113)
%115 = ptrtoint i8* %114 to i32
store i32 %115, i32* %11
%116 = load i8**, i8*** %5
%117 = getelementptr inbounds i8*, i8** %116, i64 4
%118 = load i8*, i8** %117
%119 = call i8* @atoi(i8* %118)
%120 = ptrtoint i8* %119 to i16
store i16 %120, i16* %12
%121 = load i32, i32* %11
%122 = getelementptr inbounds %struct.vlan_ioctl_args, %struct.vlan_ioctl_args* %7, i32 0, i32 2
%123 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %122, i32 0, i32 2
store i32 %121, i32* %123
%124 = load i16, i16* %12
%125 = getelementptr inbounds %struct.vlan_ioctl_args, %struct.vlan_ioctl_args* %7, i32 0, i32 0
store i16 %124, i16* %125
br label %126
126: ; preds = %110, %107
br label %127
127: ; preds = %126
%128 = load i8*, i8** %14
%129 = load i32, i32* @O_RDONLY
%130 = call i32 @open(i8* %128, i32 %129)
store i32 %130, i32* %6
%131 = icmp slt i32 %130, 0
br i1 %131, label %132, label %135
132: ; preds = %127
%133 = load i32, i32* @stderr
%134 = call i32 (i32, i8*, ...) @fprintf(i32 %133, i8* getelementptr inbounds ([127 x i8], [127 x i8]* @.str.9, i64 0, i64 0))
br label %138
135: ; preds = %127
%136 = load i32, i32* %6
%137 = call i32 @close(i32 %136)
br label %138
138: ; preds = %135, %132
%139 = load i32, i32* @AF_INET
%140 = load i32, i32* @SOCK_STREAM
%141 = call i32 @socket(i32 %139, i32 %140, i32 0)
store i32 %141, i32* %6
%142 = icmp slt i32 %141, 0
br i1 %142, label %143, label %147
143: ; preds = %138
%144 = load i32, i32* @stderr
%145 = call i32 (i32, i8*, ...) @fprintf(i32 %144, i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.10, i64 0, i64 0))
%146 = call i32 @exit(i32 2)
unreachable
147: ; preds = %138
%148 = load i8*, i8** %8
%149 = call i64 @strcasecmp(i8* %148, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.11, i64 0, i64 0))
%150 = icmp eq i64 %149, 0
br i1 %150, label %151, label %166
151: ; preds = %147
%152 = load i32, i32* @ADD_VLAN_CMD
%153 = getelementptr inbounds %struct.vlan_ioctl_args, %struct.vlan_ioctl_args* %7, i32 0, i32 1
store i32 %152, i32* %153
%154 = load i32, i32* %6
%155 = load i32, i32* @SIOCSIFVLAN
%156 = call i64 @ioctl(i32 %154, i32 %155, %struct.vlan_ioctl_args* %7)
%157 = icmp slt i64 %156, 0
br i1 %157, label %158, label %165
158: ; preds = %151
%159 = load i32, i32* @stderr
%160 = load i32, i32* %10
%161 = load i8*, i8** %9
%162 = load i32, i32* @errno
%163 = call i8* @strerror(i32 %162)
%164 = call i32 (i32, i8*, ...) @fprintf(i32 %159, i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str.12, i64 0, i64 0), i32 %160, i8* %161, i8* %163)
br label %165
165: ; preds = %158, %151
br label %266
166: ; preds = %147
%167 = load i8*, i8** %8
%168 = call i64 @strcasecmp(i8* %167, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.13, i64 0, i64 0))
%169 = icmp eq i64 %168, 0
br i1 %169, label %170, label %184
170: ; preds = %166
%171 = load i32, i32* @DEL_VLAN_CMD
%172 = getelementptr inbounds %struct.vlan_ioctl_args, %struct.vlan_ioctl_args* %7, i32 0, i32 1
store i32 %171, i32* %172
%173 = load i32, i32* %6
%174 = load i32, i32* @SIOCSIFVLAN
%175 = call i64 @ioctl(i32 %173, i32 %174, %struct.vlan_ioctl_args* %7)
%176 = icmp slt i64 %175, 0
br i1 %176, label %177, label %183
177: ; preds = %170
%178 = load i32, i32* @stderr
%179 = load i8*, i8** %9
%180 = load i32, i32* @errno
%181 = call i8* @strerror(i32 %180)
%182 = call i32 (i32, i8*, ...) @fprintf(i32 %178, i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.14, i64 0, i64 0), i8* %179, i8* %181)
br label %183
183: ; preds = %177, %170
br label %265
184: ; preds = %166
%185 = load i8*, i8** %8
%186 = call i64 @strcasecmp(i8* %185, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.15, i64 0, i64 0))
%187 = icmp eq i64 %186, 0
br i1 %187, label %188, label %202
188: ; preds = %184
%189 = load i32, i32* @SET_VLAN_EGRESS_PRIORITY_CMD
%190 = getelementptr inbounds %struct.vlan_ioctl_args, %struct.vlan_ioctl_args* %7, i32 0, i32 1
store i32 %189, i32* %190
%191 = load i32, i32* %6
%192 = load i32, i32* @SIOCSIFVLAN
%193 = call i64 @ioctl(i32 %191, i32 %192, %struct.vlan_ioctl_args* %7)
%194 = icmp slt i64 %193, 0
br i1 %194, label %195, label %201
195: ; preds = %188
%196 = load i32, i32* @stderr
%197 = load i8*, i8** %9
%198 = load i32, i32* @errno
%199 = call i8* @strerror(i32 %198)
%200 = call i32 (i32, i8*, ...) @fprintf(i32 %196, i8* getelementptr inbounds ([60 x i8], [60 x i8]* @.str.16, i64 0, i64 0), i8* %197, i8* %199)
br label %201
201: ; preds = %195, %188
br label %264
202: ; preds = %184
%203 = load i8*, i8** %8
%204 = call i64 @strcasecmp(i8* %203, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.17, i64 0, i64 0))
%205 = icmp eq i64 %204, 0
br i1 %205, label %206, label %220
206: ; preds = %202
%207 = load i32, i32* @SET_VLAN_INGRESS_PRIORITY_CMD
%208 = getelementptr inbounds %struct.vlan_ioctl_args, %struct.vlan_ioctl_args* %7, i32 0, i32 1
store i32 %207, i32* %208
%209 = load i32, i32* %6
%210 = load i32, i32* @SIOCSIFVLAN
%211 = call i64 @ioctl(i32 %209, i32 %210, %struct.vlan_ioctl_args* %7)
%212 = icmp slt i64 %211, 0
br i1 %212, label %213, label %219
213: ; preds = %206
%214 = load i32, i32* @stderr
%215 = load i8*, i8** %9
%216 = load i32, i32* @errno
%217 = call i8* @strerror(i32 %216)
%218 = call i32 (i32, i8*, ...) @fprintf(i32 %214, i8* getelementptr inbounds ([61 x i8], [61 x i8]* @.str.18, i64 0, i64 0), i8* %215, i8* %217)
br label %219
219: ; preds = %213, %206
br label %263
220: ; preds = %202
%221 = load i8*, i8** %8
%222 = call i64 @strcasecmp(i8* %221, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.19, i64 0, i64 0))
%223 = icmp eq i64 %222, 0
br i1 %223, label %224, label %238
224: ; preds = %220
%225 = load i32, i32* @SET_VLAN_FLAG_CMD
%226 = getelementptr inbounds %struct.vlan_ioctl_args, %struct.vlan_ioctl_args* %7, i32 0, i32 1
store i32 %225, i32* %226
%227 = load i32, i32* %6
%228 = load i32, i32* @SIOCSIFVLAN
%229 = call i64 @ioctl(i32 %227, i32 %228, %struct.vlan_ioctl_args* %7)
%230 = icmp slt i64 %229, 0
br i1 %230, label %231, label %237
231: ; preds = %224
%232 = load i32, i32* @stderr
%233 = load i8*, i8** %9
%234 = load i32, i32* @errno
%235 = call i8* @strerror(i32 %234)
%236 = call i32 (i32, i8*, ...) @fprintf(i32 %232, i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.20, i64 0, i64 0), i8* %233, i8* %235)
br label %237
237: ; preds = %231, %224
br label %262
238: ; preds = %220
%239 = load i8*, i8** %8
%240 = call i64 @strcasecmp(i8* %239, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0))
%241 = icmp eq i64 %240, 0
br i1 %241, label %242, label %255
242: ; preds = %238
%243 = load i32, i32* @SET_VLAN_NAME_TYPE_CMD
%244 = getelementptr inbounds %struct.vlan_ioctl_args, %struct.vlan_ioctl_args* %7, i32 0, i32 1
store i32 %243, i32* %244
%245 = load i32, i32* %6
%246 = load i32, i32* @SIOCSIFVLAN
%247 = call i64 @ioctl(i32 %245, i32 %246, %struct.vlan_ioctl_args* %7)
%248 = icmp slt i64 %247, 0
br i1 %248, label %249, label %254
249: ; preds = %242
%250 = load i32, i32* @stderr
%251 = load i32, i32* @errno
%252 = call i8* @strerror(i32 %251)
%253 = call i32 (i32, i8*, ...) @fprintf(i32 %250, i8* getelementptr inbounds ([62 x i8], [62 x i8]* @.str.21, i64 0, i64 0), i8* %252)
br label %254
254: ; preds = %249, %242
br label %261
255: ; preds = %238
%256 = load i32, i32* @stderr
%257 = load i8*, i8** %8
%258 = call i32 (i32, i8*, ...) @fprintf(i32 %256, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.22, i64 0, i64 0), i8* %257)
%259 = call i32 (...) @show_usage()
%260 = call i32 @exit(i32 5)
unreachable
261: ; preds = %254
br label %262
262: ; preds = %261, %237
br label %263
263: ; preds = %262, %219
br label %264
264: ; preds = %263, %201
br label %265
265: ; preds = %264, %183
br label %266
266: ; preds = %265, %165
ret i32 0
}

LLVM IR (-O2):
%struct.vlan_ioctl_args = type { i16, i32, %struct.TYPE_2__, i32 }
%struct.TYPE_2__ = type { i32, i32, i32 }
@VLAN_NAME_TYPE_PLUS_VID = global i32 0
@.str = [22 x i8] c"/proc/net/vlan/config\00"
@stdout = global i32 0
@.str.1 = [47 x i8] c"Expecting argc to be 3-5, inclusive. Was: %d\0A\00"
@.str.2 = [14 x i8] c"set_name_type\00"
@.str.3 = [14 x i8] c"VLAN_PLUS_VID\00"
@.str.4 = [21 x i8] c"VLAN_PLUS_VID_NO_PAD\00"
@VLAN_NAME_TYPE_PLUS_VID_NO_PAD = global i32 0
@.str.5 = [13 x i8] c"DEV_PLUS_VID\00"
@VLAN_NAME_TYPE_RAW_PLUS_VID = global i32 0
@.str.6 = [20 x i8] c"DEV_PLUS_VID_NO_PAD\00"
@VLAN_NAME_TYPE_RAW_PLUS_VID_NO_PAD = global i32 0
@stderr = global i32 0
@.str.7 = [20 x i8] c"Invalid name type.\0A\00"
@.str.8 = [48 x i8] c"ERROR: if_name must be 15 characters or less.\0A\00"
@O_RDONLY = global i32 0
@.str.9 = [127 x i8] c"WARNING: Could not open /proc/net/vlan/config. Maybe you need to load the 8021q module, or maybe you are not using PROCFS??\0A\00"
@AF_INET = global i32 0
@SOCK_STREAM = global i32 0
@.str.10 = [44 x i8] c"FATAL: Couldn't open a socket..go figure!\0A\00"
@.str.11 = [4 x i8] c"add\00"
@ADD_VLAN_CMD = global i32 0
@SIOCSIFVLAN = global i32 0
@.str.12 = [55 x i8] c"ERROR: trying to add VLAN #%u to IF -:%s:- error: %s\0A\00"
@errno = global i32 0
@.str.13 = [4 x i8] c"rem\00"
@DEL_VLAN_CMD = global i32 0
@.str.14 = [47 x i8] c"ERROR: trying to remove VLAN -:%s:- error: %s\0A\00"
@.str.15 = [15 x i8] c"set_egress_map\00"
@SET_VLAN_EGRESS_PRIORITY_CMD = global i32 0
@.str.16 = [60 x i8] c"ERROR: trying to set egress map on device -:%s:- error: %s\0A\00"
@.str.17 = [16 x i8] c"set_ingress_map\00"
@SET_VLAN_INGRESS_PRIORITY_CMD = global i32 0
@.str.18 = [61 x i8] c"ERROR: trying to set ingress map on device -:%s:- error: %s\0A\00"
@.str.19 = [9 x i8] c"set_flag\00"
@SET_VLAN_FLAG_CMD = global i32 0
@.str.20 = [54 x i8] c"ERROR: trying to set flag on device -:%s:- error: %s\0A\00"
@SET_VLAN_NAME_TYPE_CMD = global i32 0
@.str.21 = [62 x i8] c"ERROR: trying to set name type for VLAN subsystem, error: %s\0A\00"
@.str.22 = [24 x i8] c"Unknown command -:%s:-\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca %struct.vlan_ioctl_args
%4 = bitcast %struct.vlan_ioctl_args* %3 to i8*
%5 = call i32 @memset(%struct.vlan_ioctl_args* %3, i32 0, i32 24)
%6 = add i32 %0, -6
%7 = icmp ult i32 %6, -3
br i1 %7, label %8, label %13
8: ; preds = %2
%9 = load i32, i32* @stdout
%10 = call i32 (i32, i8*, ...) @fprintf(i32 %9, i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.1, i64 0, i64 0), i32 %0)
%11 = call i32 (...) @show_usage()
%12 = call i32 @exit(i32 1)
unreachable
13: ; preds = %2
%14 = getelementptr inbounds i8*, i8** %1, i64 1
%15 = load i8*, i8** %14
%16 = call i64 @strcasecmp(i8* %15, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0))
%17 = icmp eq i64 %16, 0
%18 = getelementptr inbounds i8*, i8** %1, i64 2
%19 = load i8*, i8** %18
br i1 %17, label %20, label %41
20: ; preds = %13
%21 = call i64 @strcasecmp(i8* %19, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0))
%22 = icmp eq i64 %21, 0
br i1 %22, label %37, label %23
23: ; preds = %20
%24 = call i64 @strcasecmp(i8* %19, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.4, i64 0, i64 0))
%25 = icmp eq i64 %24, 0
br i1 %25, label %37, label %26
26: ; preds = %23
%27 = call i64 @strcasecmp(i8* %19, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.5, i64 0, i64 0))
%28 = icmp eq i64 %27, 0
br i1 %28, label %37, label %29
29: ; preds = %26
%30 = call i64 @strcasecmp(i8* %19, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.6, i64 0, i64 0))
%31 = icmp eq i64 %30, 0
br i1 %31, label %37, label %32
32: ; preds = %29
%33 = load i32, i32* @stderr
%34 = call i32 (i32, i8*, ...) @fprintf(i32 %33, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.7, i64 0, i64 0))
%35 = call i32 (...) @show_usage()
%36 = call i32 @exit(i32 1)
unreachable
37: ; preds = %29, %26, %23, %20
%38 = phi i32* [ @VLAN_NAME_TYPE_PLUS_VID, %20 ], [ @VLAN_NAME_TYPE_PLUS_VID_NO_PAD, %23 ], [ @VLAN_NAME_TYPE_RAW_PLUS_VID, %26 ], [ @VLAN_NAME_TYPE_RAW_PLUS_VID_NO_PAD, %29 ]
%39 = load i32, i32* %38
%40 = getelementptr inbounds %struct.vlan_ioctl_args, %struct.vlan_ioctl_args* %3, i64 0, i32 2, i32 0
store i32 %39, i32* %40
br label %52
41: ; preds = %13
%42 = call i32 @strlen(i8* %19)
%43 = icmp sgt i32 %42, 15
br i1 %43, label %44, label %48
44: ; preds = %41
%45 = load i32, i32* @stderr
%46 = call i32 (i32, i8*, ...) @fprintf(i32 %45, i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.8, i64 0, i64 0))
%47 = call i32 @exit(i32 1)
unreachable
48: ; preds = %41
%49 = getelementptr inbounds %struct.vlan_ioctl_args, %struct.vlan_ioctl_args* %3, i64 0, i32 3
%50 = load i32, i32* %49
%51 = call i32 @strcpy(i32 %50, i8* %19)
br label %52
52: ; preds = %48, %37
%53 = phi i8* [ null, %37 ], [ %19, %48 ]
switch i32 %0, label %74 [
i32 4, label %54
i32 5, label %61
]
54: ; preds = %52
%55 = getelementptr inbounds i8*, i8** %1, i64 3
%56 = load i8*, i8** %55
%57 = call i8* @atoi(i8* %56)
%58 = ptrtoint i8* %57 to i64
%59 = trunc i64 %58 to i32
%60 = getelementptr inbounds %struct.vlan_ioctl_args, %struct.vlan_ioctl_args* %3, i64 0, i32 2, i32 1
store i32 %59, i32* %60
br label %74
61: ; preds = %52
%62 = getelementptr inbounds i8*, i8** %1, i64 3
%63 = load i8*, i8** %62
%64 = call i8* @atoi(i8* %63)
%65 = ptrtoint i8* %64 to i64
%66 = trunc i64 %65 to i32
%67 = getelementptr inbounds i8*, i8** %1, i64 4
%68 = load i8*, i8** %67
%69 = call i8* @atoi(i8* %68)
%70 = ptrtoint i8* %69 to i64
%71 = trunc i64 %70 to i16
%72 = getelementptr inbounds %struct.vlan_ioctl_args, %struct.vlan_ioctl_args* %3, i64 0, i32 2, i32 2
store i32 %66, i32* %72
%73 = getelementptr inbounds %struct.vlan_ioctl_args, %struct.vlan_ioctl_args* %3, i64 0, i32 0
store i16 %71, i16* %73
br label %74
74: ; preds = %52, %54, %61
%75 = phi i32 [ %59, %54 ], [ 0, %61 ], [ 0, %52 ]
%76 = load i32, i32* @O_RDONLY
%77 = call i32 @open(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i32 %76)
%78 = icmp slt i32 %77, 0
br i1 %78, label %79, label %82
79: ; preds = %74
%80 = load i32, i32* @stderr
%81 = call i32 (i32, i8*, ...) @fprintf(i32 %80, i8* getelementptr inbounds ([127 x i8], [127 x i8]* @.str.9, i64 0, i64 0))
br label %84
82: ; preds = %74
%83 = call i32 @close(i32 %77)
br label %84
84: ; preds = %82, %79
%85 = load i32, i32* @AF_INET
%86 = load i32, i32* @SOCK_STREAM
%87 = call i32 @socket(i32 %85, i32 %86, i32 0)
%88 = icmp slt i32 %87, 0
br i1 %88, label %89, label %93
89: ; preds = %84
%90 = load i32, i32* @stderr
%91 = call i32 (i32, i8*, ...) @fprintf(i32 %90, i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.10, i64 0, i64 0))
%92 = call i32 @exit(i32 2)
unreachable
93: ; preds = %84
%94 = call i64 @strcasecmp(i8* %15, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.11, i64 0, i64 0))
%95 = icmp eq i64 %94, 0
br i1 %95, label %96, label %107
96: ; preds = %93
%97 = load i32, i32* @ADD_VLAN_CMD
%98 = getelementptr inbounds %struct.vlan_ioctl_args, %struct.vlan_ioctl_args* %3, i64 0, i32 1
store i32 %97, i32* %98
%99 = load i32, i32* @SIOCSIFVLAN
%100 = call i64 @ioctl(i32 %87, i32 %99, %struct.vlan_ioctl_args* %3)
%101 = icmp slt i64 %100, 0
br i1 %101, label %102, label %182
102: ; preds = %96
%103 = load i32, i32* @stderr
%104 = load i32, i32* @errno
%105 = call i8* @strerror(i32 %104)
%106 = call i32 (i32, i8*, ...) @fprintf(i32 %103, i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str.12, i64 0, i64 0), i32 %75, i8* %53, i8* %105)
br label %182
107: ; preds = %93
%108 = call i64 @strcasecmp(i8* %15, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.13, i64 0, i64 0))
%109 = icmp eq i64 %108, 0
br i1 %109, label %110, label %121
110: ; preds = %107
%111 = load i32, i32* @DEL_VLAN_CMD
%112 = getelementptr inbounds %struct.vlan_ioctl_args, %struct.vlan_ioctl_args* %3, i64 0, i32 1
store i32 %111, i32* %112
%113 = load i32, i32* @SIOCSIFVLAN
%114 = call i64 @ioctl(i32 %87, i32 %113, %struct.vlan_ioctl_args* %3)
%115 = icmp slt i64 %114, 0
br i1 %115, label %116, label %182
116: ; preds = %110
%117 = load i32, i32* @stderr
%118 = load i32, i32* @errno
%119 = call i8* @strerror(i32 %118)
%120 = call i32 (i32, i8*, ...) @fprintf(i32 %117, i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.14, i64 0, i64 0), i8* %53, i8* %119)
br label %182
121: ; preds = %107
%122 = call i64 @strcasecmp(i8* %15, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.15, i64 0, i64 0))
%123 = icmp eq i64 %122, 0
br i1 %123, label %124, label %135
124: ; preds = %121
%125 = load i32, i32* @SET_VLAN_EGRESS_PRIORITY_CMD
%126 = getelementptr inbounds %struct.vlan_ioctl_args, %struct.vlan_ioctl_args* %3, i64 0, i32 1
store i32 %125, i32* %126
%127 = load i32, i32* @SIOCSIFVLAN
%128 = call i64 @ioctl(i32 %87, i32 %127, %struct.vlan_ioctl_args* %3)
%129 = icmp slt i64 %128, 0
br i1 %129, label %130, label %182
130: ; preds = %124
%131 = load i32, i32* @stderr
%132 = load i32, i32* @errno
%133 = call i8* @strerror(i32 %132)
%134 = call i32 (i32, i8*, ...) @fprintf(i32 %131, i8* getelementptr inbounds ([60 x i8], [60 x i8]* @.str.16, i64 0, i64 0), i8* %53, i8* %133)
br label %182
135: ; preds = %121
%136 = call i64 @strcasecmp(i8* %15, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.17, i64 0, i64 0))
%137 = icmp eq i64 %136, 0
br i1 %137, label %138, label %149
138: ; preds = %135
%139 = load i32, i32* @SET_VLAN_INGRESS_PRIORITY_CMD
%140 = getelementptr inbounds %struct.vlan_ioctl_args, %struct.vlan_ioctl_args* %3, i64 0, i32 1
store i32 %139, i32* %140
%141 = load i32, i32* @SIOCSIFVLAN
%142 = call i64 @ioctl(i32 %87, i32 %141, %struct.vlan_ioctl_args* %3)
%143 = icmp slt i64 %142, 0
br i1 %143, label %144, label %182
144: ; preds = %138
%145 = load i32, i32* @stderr
%146 = load i32, i32* @errno
%147 = call i8* @strerror(i32 %146)
%148 = call i32 (i32, i8*, ...) @fprintf(i32 %145, i8* getelementptr inbounds ([61 x i8], [61 x i8]* @.str.18, i64 0, i64 0), i8* %53, i8* %147)
br label %182
149: ; preds = %135
%150 = call i64 @strcasecmp(i8* %15, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.19, i64 0, i64 0))
%151 = icmp eq i64 %150, 0
br i1 %151, label %152, label %163
152: ; preds = %149
%153 = load i32, i32* @SET_VLAN_FLAG_CMD
%154 = getelementptr inbounds %struct.vlan_ioctl_args, %struct.vlan_ioctl_args* %3, i64 0, i32 1
store i32 %153, i32* %154
%155 = load i32, i32* @SIOCSIFVLAN
%156 = call i64 @ioctl(i32 %87, i32 %155, %struct.vlan_ioctl_args* %3)
%157 = icmp slt i64 %156, 0
br i1 %157, label %158, label %182
158: ; preds = %152
%159 = load i32, i32* @stderr
%160 = load i32, i32* @errno
%161 = call i8* @strerror(i32 %160)
%162 = call i32 (i32, i8*, ...) @fprintf(i32 %159, i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.20, i64 0, i64 0), i8* %53, i8* %161)
br label %182
163: ; preds = %149
%164 = call i64 @strcasecmp(i8* %15, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0))
%165 = icmp eq i64 %164, 0
br i1 %165, label %166, label %177
166: ; preds = %163
%167 = load i32, i32* @SET_VLAN_NAME_TYPE_CMD
%168 = getelementptr inbounds %struct.vlan_ioctl_args, %struct.vlan_ioctl_args* %3, i64 0, i32 1
store i32 %167, i32* %168
%169 = load i32, i32* @SIOCSIFVLAN
%170 = call i64 @ioctl(i32 %87, i32 %169, %struct.vlan_ioctl_args* %3)
%171 = icmp slt i64 %170, 0
br i1 %171, label %172, label %182
172: ; preds = %166
%173 = load i32, i32* @stderr
%174 = load i32, i32* @errno
%175 = call i8* @strerror(i32 %174)
%176 = call i32 (i32, i8*, ...) @fprintf(i32 %173, i8* getelementptr inbounds ([62 x i8], [62 x i8]* @.str.21, i64 0, i64 0), i8* %175)
br label %182
177: ; preds = %163
%178 = load i32, i32* @stderr
%179 = call i32 (i32, i8*, ...) @fprintf(i32 %178, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.22, i64 0, i64 0), i8* %15)
%180 = call i32 (...) @show_usage()
%181 = call i32 @exit(i32 5)
unreachable
182: ; preds = %116, %110, %144, %138, %172, %166, %152, %158, %124, %130, %96, %102
ret i32 0
}