#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */
struct sockaddr_ll {
  int sll_ifindex;
  int /*<<< orphan*/ sll_protocol;
  int /*<<< orphan*/ sll_family;
};
struct sockaddr {
  int dummy;
};
struct ifreq {
  int ifr_ifindex;
  int /*<<< orphan*/ ifr_name;
};
struct can_frame {
  int can_id;
  int can_dlc;
  int *data;
};
typedef int /*<<< orphan*/ sll;

/* Variables and functions */
int /*<<< orphan*/ AF_PACKET;
int CAN_EFF_FLAG;
int CAN_EFF_MASK;
int CAN_RTR_FLAG;
int CAN_SFF_MASK;
int /*<<< orphan*/ ETH_P_CAN;
int /*<<< orphan*/ PF_PACKET;
int /*<<< orphan*/ SIOCGIFINDEX;
int /*<<< orphan*/ SOCK_RAW;
scalar_t__ bind(int, struct sockaddr *, int);
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ fflush(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int getopt(int, char **, char *);
int /*<<< orphan*/ htons(int /*<<< orphan*/);
int /*<<< orphan*/ ioctl(int, int /*<<< orphan*/, struct ifreq *);
char *optarg;
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, ...);
int read(int, struct can_frame *, int);
int socket(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdout;
scalar_t__ strcmp(char *, char *);
int /*<<< orphan*/ strcpy(int /*<<< orphan*/, char *);
int write(int, struct can_frame *, int);
int main(int argc, char **argv) {
  int s;
  struct can_frame frame;
  int nbytes, i;
  static struct ifreq ifr;
  static struct sockaddr_ll sll;
  char *ifname = "vcan2";
  int ifindex;
  int opt;
  int send_one_frame = 0;
  while ((opt = getopt(argc, argv, "i:s")) != -1) {
    switch (opt) {
    case 'i':
      ifname = optarg;
      break;
    case 's':
      send_one_frame = 1;
      break;
    default:
      fprintf(stderr, "Unknown option %c\n", opt);
      break;
    }
  }
  s = socket(PF_PACKET, SOCK_RAW, htons(ETH_P_CAN));
  if (s < 0) {
    perror("socket");
    return 1;
  }
  if (strcmp(ifname, "any") == 0)
    ifindex = 0;
  else {
    strcpy(ifr.ifr_name, ifname);
    ioctl(s, SIOCGIFINDEX, &ifr);
    ifindex = ifr.ifr_ifindex;
  }
  sll.sll_family = AF_PACKET;
  sll.sll_ifindex = ifindex;
  sll.sll_protocol = htons(ETH_P_CAN);
  if (bind(s, (struct sockaddr *)&sll, sizeof(sll)) < 0) {
    perror("bind");
    return 1;
  }
  if (send_one_frame) {
    frame.can_id = 0x123;
    frame.can_dlc = 2;
    frame.data[0] = 0x11;
    frame.data[1] = 0x22;
    nbytes = write(s, &frame, sizeof(struct can_frame));
    if (nbytes < 0) {
      perror("write");
      return 1;
    }
    if (nbytes != sizeof(struct can_frame)) {
      perror("write_len");
      return 1;
    }
  }
  while (1) {
    if ((nbytes = read(s, &frame, sizeof(struct can_frame))) < 0) {
      perror("read");
      return 1;
    } else if (nbytes < sizeof(struct can_frame)) {
      fprintf(stderr, "read: incomplete CAN frame\n");
      return 1;
    } else {
      if (frame.can_id & CAN_EFF_FLAG)
        printf("%8X  ", frame.can_id & CAN_EFF_MASK);
      else
        printf("%3X  ", frame.can_id & CAN_SFF_MASK);
      printf("[%d] ", frame.can_dlc);
      for (i = 0; i < frame.can_dlc; i++) {
        printf("%02X ", frame.data[i]);
      }
      if (frame.can_id & CAN_RTR_FLAG)
        printf("remote request");
      printf("\n");
      fflush(stdout);
    }
  }
  close(s);
  return 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)
lea    0xe13(%rip),%rax
mov    %rax,-0x38(%rbp)
movl   $0x0,-0x44(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xe00(%rip),%rdx
call   10e0 <getopt@plt>
mov    %eax,-0x40(%rbp)
cmp    $0xffffffff,%eax
je     127a <main+0xaa>
mov    -0x40(%rbp),%eax
mov    %eax,-0x48(%rbp)
sub    $0x69,%eax
je     123c <main+0x6c>
jmp    122b <main+0x5b>
mov    -0x48(%rbp),%eax
sub    $0x73,%eax
je     124f <main+0x7f>
jmp    125b <main+0x8b>
mov    0x2db5(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x38(%rbp)
jmp    1275 <main+0xa5>
movl   $0x1,-0x44(%rbp)
jmp    1275 <main+0xa5>
mov    0x2d4e(%rip),%rax
mov    (%rax),%edi
mov    -0x40(%rbp),%edx
lea    0xd9c(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
jmp    11f8 <main+0x28>
mov    0x2d67(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x50(%rbp)
mov    0x2d43(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4c(%rbp)
mov    0x2d2f(%rip),%rax
mov    (%rax),%edi
call   1050 <htons@plt>
mov    -0x50(%rbp),%edi
mov    -0x4c(%rbp),%esi
mov    %eax,%edx
call   10f0 <socket@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jge    12d2 <main+0x102>
lea    0xd5c(%rip),%rdi
call   10d0 <perror@plt>
movl   $0x1,-0x4(%rbp)
jmp    1565 <main+0x395>
mov    -0x38(%rbp),%rdi
lea    0xd47(%rip),%rsi
call   1090 <strcmp@plt>
cmp    $0x0,%rax
jne    12f8 <main+0x128>
movl   $0x0,-0x3c(%rbp)
jmp    1328 <main+0x158>
mov    0x2d96(%rip),%edi
mov    -0x38(%rbp),%rsi
call   1030 <strcpy@plt>
mov    -0x14(%rbp),%edi
mov    0x2c6f(%rip),%rax
mov    (%rax),%esi
lea    0x2d76(%rip),%rdx
call   1070 <ioctl@plt>
mov    0x2d6b(%rip),%eax
mov    %eax,-0x3c(%rbp)
mov    0x2c89(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x2d69(%rip)
mov    -0x3c(%rbp),%eax
mov    %eax,0x2d58(%rip)
mov    0x2c81(%rip),%rax
mov    (%rax),%edi
call   1050 <htons@plt>
mov    %eax,0x2d48(%rip)
mov    -0x14(%rbp),%edi
lea    0x2d3a(%rip),%rsi
mov    $0xc,%edx
call   10c0 <bind@plt>
cmp    $0x0,%rax
jge    138a <main+0x1ba>
lea    0xcaf(%rip),%rdi
call   10d0 <perror@plt>
movl   $0x1,-0x4(%rbp)
jmp    1565 <main+0x395>
cmpl   $0x0,-0x44(%rbp)
je     1418 <main+0x248>
movl   $0x123,-0x28(%rbp)
movl   $0x2,-0x24(%rbp)
mov    -0x20(%rbp),%rax
movl   $0x11,(%rax)
mov    -0x20(%rbp),%rax
movl   $0x22,0x4(%rax)
mov    -0x14(%rbp),%edi
lea    -0x28(%rbp),%rsi
mov    $0x10,%edx
call   1040 <write@plt>
mov    %eax,-0x2c(%rbp)
cmpl   $0x0,-0x2c(%rbp)
jge    13ed <main+0x21d>
lea    0xc51(%rip),%rdi
call   10d0 <perror@plt>
movl   $0x1,-0x4(%rbp)
jmp    1565 <main+0x395>
movslq -0x2c(%rbp),%rax
cmp    $0x10,%rax
je     1413 <main+0x243>
lea    0xc31(%rip),%rdi
call   10d0 <perror@plt>
movl   $0x1,-0x4(%rbp)
jmp    1565 <main+0x395>
jmp    1418 <main+0x248>
jmp    141d <main+0x24d>
mov    -0x14(%rbp),%edi
lea    -0x28(%rbp),%rsi
mov    $0x10,%edx
call   1080 <read@plt>
mov    %eax,-0x2c(%rbp)
cmp    $0x0,%eax
jge    1452 <main+0x282>
lea    0xbfc(%rip),%rdi
call   10d0 <perror@plt>
movl   $0x1,-0x4(%rbp)
jmp    1565 <main+0x395>
movslq -0x2c(%rbp),%rax
cmp    $0x10,%rax
jae    1483 <main+0x2b3>
mov    0x2b49(%rip),%rax
mov    (%rax),%edi
lea    0xbd2(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1565 <main+0x395>
mov    -0x28(%rbp),%eax
mov    0x2b1b(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
je     14b7 <main+0x2e7>
mov    -0x28(%rbp),%esi
mov    0x2b36(%rip),%rax
and    (%rax),%esi
lea    0xbb3(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    14d1 <main+0x301>
mov    -0x28(%rbp),%esi
mov    0x2ac7(%rip),%rax
and    (%rax),%esi
lea    0xb9a(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x24(%rbp),%esi
lea    0xb8f(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0x0,-0x30(%rbp)
mov    -0x30(%rbp),%eax
cmp    -0x24(%rbp),%eax
jge    151c <main+0x34c>
mov    -0x20(%rbp),%rax
movslq -0x30(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
lea    0xb69(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x30(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30(%rbp)
jmp    14e9 <main+0x319>
mov    -0x28(%rbp),%eax
mov    0x2a7a(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
je     153f <main+0x36f>
lea    0xb3e(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    0xad5(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    0x2a44(%rip),%rax
mov    (%rax),%edi
call   10b0 <fflush@plt>
jmp    1560 <main+0x390>
jmp    141d <main+0x24d>
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rsi,%rbp
mov    %edi,%ebx
lea    0xe16(%rip),%r14
lea    0xe15(%rip),%r15
mov    0x2e00(%rip),%r13
lea    0xe0b(%rip),%r12
nop
mov    %ebx,%edi
mov    %rbp,%rsi
mov    %r15,%rdx
call   10e0 <getopt@plt>
cmp    $0xffffffff,%eax
je     1239 <main+0x69>
cmp    $0x73,%eax
je     1200 <main+0x30>
cmp    $0x69,%eax
je     1233 <main+0x63>
mov    0x2d8d(%rip),%rcx
mov    (%rcx),%edi
mov    %r12,%rsi
mov    %eax,%edx
xor    %eax,%eax
call   10a0 <fprintf@plt>
jmp    1200 <main+0x30>
mov    0x0(%r13),%r14
jmp    1200 <main+0x30>
mov    0x2da8(%rip),%rax
mov    (%rax),%ebx
mov    0x2d87(%rip),%rax
mov    (%rax),%ebp
mov    0x2d76(%rip),%r15
mov    (%r15),%edi
call   1050 <htons@plt>
mov    %ebx,%edi
mov    %ebp,%esi
mov    %eax,%edx
call   10f0 <socket@plt>
test   %eax,%eax
js     141c <main+0x24c>
mov    %eax,%r13d
lea    0xdad(%rip),%rsi
mov    %r14,%rdi
call   1090 <strcmp@plt>
test   %rax,%rax
je     12b5 <main+0xe5>
lea    0x2e05(%rip),%rbx
mov    0x2e03(%rip),%edi
mov    %r14,%rsi
call   1040 <strcpy@plt>
mov    0x2ce0(%rip),%rax
mov    (%rax),%esi
mov    %r13d,%edi
mov    %rbx,%rdx
call   1070 <ioctl@plt>
mov    0x2ddd(%rip),%eax
jmp    12b7 <main+0xe7>
xor    %eax,%eax
mov    0x2cfa(%rip),%rcx
mov    (%rcx),%ecx
mov    %ecx,0x2dda(%rip)
lea    0x2dcb(%rip),%rbx
mov    %eax,0x2dc5(%rip)
mov    (%r15),%edi
call   1050 <htons@plt>
mov    %eax,0x2dbb(%rip)
mov    %r13d,%edi
mov    %rbx,%rsi
mov    $0xc,%edx
call   10c0 <bind@plt>
test   %rax,%rax
js     1425 <main+0x255>
lea    0x8(%rsp),%rsi
mov    %r13d,%edi
mov    $0x10,%edx
call   1080 <read@plt>
test   %eax,%eax
js     1413 <main+0x243>
lea    0xd45(%rip),%rbx
jmp    1352 <main+0x182>
nopl   (%rax)
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    0x2c67(%rip),%rax
mov    (%rax),%edi
call   10b0 <fflush@plt>
mov    %r13d,%edi
lea    0x8(%rsp),%rsi
mov    $0x10,%edx
call   1080 <read@plt>
test   %eax,%eax
js     1413 <main+0x243>
cmp    $0xf,%eax
jbe    13fa <main+0x22a>
mov    0x8(%rsp),%r12d
mov    0x2c41(%rip),%rax
mov    (%rax),%eax
and    %r12d,%eax
lea    0xcdb(%rip),%rdi
lea    0xcda(%rip),%rax
cmove  %rax,%rdi
mov    0x2c53(%rip),%rax
cmove  0x2bfb(%rip),%rax
mov    (%rax),%esi
and    %r12d,%esi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0xc(%rsp),%ebp
lea    0xcb6(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1060 <printf@plt>
test   %ebp,%ebp
jle    13d7 <main+0x207>
mov    0x10(%rsp),%r14
xor    %r15d,%r15d
nopl   0x0(%rax)
mov    (%r14,%r15,4),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
add    $0x1,%r15
cmp    %r15,%rbp
jne    13c0 <main+0x1f0>
mov    0x2bc2(%rip),%rax
test   %r12d,(%rax)
je     1320 <main+0x150>
lea    0xc78(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
jmp    1320 <main+0x150>
mov    0x2baf(%rip),%rax
mov    (%rax),%edi
lea    0xc28(%rip),%rsi
xor    %eax,%eax
call   10a0 <fprintf@plt>
jmp    1431 <main+0x261>
lea    0xc13(%rip),%rdi
jmp    142c <main+0x25c>
lea    0xbfa(%rip),%rdi
jmp    142c <main+0x25c>
lea    0xbfc(%rip),%rdi
call   10d0 <perror@plt>
mov    $0x1,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.ifreq = type { i32, i32 }
%struct.sockaddr_ll = type { i32, i32, i32 }
%struct.can_frame = type { i32, i32, i32* }
%struct.sockaddr = type { i32 }
@main.ifr = internal global %struct.ifreq zeroinitializer
@main.sll = internal global %struct.sockaddr_ll zeroinitializer
@.str = [6 x i8] c"vcan2\00"
@.str.1 = [4 x i8] c"i:s\00"
@optarg = global i8* null
@stderr = global i32 0
@.str.2 = [19 x i8] c"Unknown option %c\0A\00"
@PF_PACKET = global i32 0
@SOCK_RAW = global i32 0
@ETH_P_CAN = global i32 0
@.str.3 = [7 x i8] c"socket\00"
@.str.4 = [4 x i8] c"any\00"
@SIOCGIFINDEX = global i32 0
@AF_PACKET = global i32 0
@.str.5 = [5 x i8] c"bind\00"
@.str.6 = [6 x i8] c"write\00"
@.str.7 = [10 x i8] c"write_len\00"
@.str.8 = [5 x i8] c"read\00"
@.str.9 = [28 x i8] c"read: incomplete CAN frame\0A\00"
@CAN_EFF_FLAG = global i32 0
@.str.10 = [6 x i8] c"%8X \00"
@CAN_EFF_MASK = global i32 0
@.str.11 = [6 x i8] c"%3X \00"
@CAN_SFF_MASK = global i32 0
@.str.12 = [6 x i8] c"[%d] \00"
@.str.13 = [6 x i8] c"%02X \00"
@CAN_RTR_FLAG = global i32 0
@.str.14 = [15 x i8] c"remote request\00"
@.str.15 = [2 x i8] c"\0A\00"
@stdout = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca %struct.can_frame
%8 = alloca i32
%9 = alloca i32
%10 = alloca i8*
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8** %10
store i32 0, i32* %13
br label %14
14: ; preds = %28, %2
%15 = load i32, i32* %4
%16 = load i8**, i8*** %5
%17 = call i32 @getopt(i32 %15, i8** %16, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
store i32 %17, i32* %12
%18 = icmp ne i32 %17, -1
br i1 %18, label %19, label %29
19: ; preds = %14
%20 = load i32, i32* %12
switch i32 %20, label %24 [
i32 105, label %21
i32 115, label %23
]
21: ; preds = %19
%22 = load i8*, i8** @optarg
store i8* %22, i8** %10
br label %28
23: ; preds = %19
store i32 1, i32* %13
br label %28
24: ; preds = %19
%25 = load i32, i32* @stderr
%26 = load i32, i32* %12
%27 = call i32 (i32, i8*, ...) @fprintf(i32 %25, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0), i32 %26)
br label %28
28: ; preds = %24, %23, %21
br label %14
29: ; preds = %14
%30 = load i32, i32* @PF_PACKET
%31 = load i32, i32* @SOCK_RAW
%32 = load i32, i32* @ETH_P_CAN
%33 = call i32 @htons(i32 %32)
%34 = call i32 @socket(i32 %30, i32 %31, i32 %33)
store i32 %34, i32* %6
%35 = load i32, i32* %6
%36 = icmp slt i32 %35, 0
br i1 %36, label %37, label %39
37: ; preds = %29
%38 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
store i32 1, i32* %3
br label %153
39: ; preds = %29
%40 = load i8*, i8** %10
%41 = call i64 @strcmp(i8* %40, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0))
%42 = icmp eq i64 %41, 0
br i1 %42, label %43, label %44
43: ; preds = %39
store i32 0, i32* %11
br label %52
44: ; preds = %39
%45 = load i32, i32* getelementptr inbounds (%struct.ifreq, %struct.ifreq* @main.ifr, i32 0, i32 1)
%46 = load i8*, i8** %10
%47 = call i32 @strcpy(i32 %45, i8* %46)
%48 = load i32, i32* %6
%49 = load i32, i32* @SIOCGIFINDEX
%50 = call i32 @ioctl(i32 %48, i32 %49, %struct.ifreq* @main.ifr)
%51 = load i32, i32* getelementptr inbounds (%struct.ifreq, %struct.ifreq* @main.ifr, i32 0, i32 0)
store i32 %51, i32* %11
br label %52
52: ; preds = %44, %43
%53 = load i32, i32* @AF_PACKET
store i32 %53, i32* getelementptr inbounds (%struct.sockaddr_ll, %struct.sockaddr_ll* @main.sll, i32 0, i32 2)
%54 = load i32, i32* %11
store i32 %54, i32* getelementptr inbounds (%struct.sockaddr_ll, %struct.sockaddr_ll* @main.sll, i32 0, i32 0)
%55 = load i32, i32* @ETH_P_CAN
%56 = call i32 @htons(i32 %55)
store i32 %56, i32* getelementptr inbounds (%struct.sockaddr_ll, %struct.sockaddr_ll* @main.sll, i32 0, i32 1)
%57 = load i32, i32* %6
%58 = call i64 @bind(i32 %57, %struct.sockaddr* bitcast (%struct.sockaddr_ll* @main.sll to %struct.sockaddr*), i32 12)
%59 = icmp slt i64 %58, 0
br i1 %59, label %60, label %62
60: ; preds = %52
%61 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0))
store i32 1, i32* %3
br label %153
62: ; preds = %52
%63 = load i32, i32* %13
%64 = icmp ne i32 %63, 0
br i1 %64, label %65, label %87
65: ; preds = %62
%66 = getelementptr inbounds %struct.can_frame, %struct.can_frame* %7, i32 0, i32 0
store i32 291, i32* %66
%67 = getelementptr inbounds %struct.can_frame, %struct.can_frame* %7, i32 0, i32 1
store i32 2, i32* %67
%68 = getelementptr inbounds %struct.can_frame, %struct.can_frame* %7, i32 0, i32 2
%69 = load i32*, i32** %68
%70 = getelementptr inbounds i32, i32* %69, i64 0
store i32 17, i32* %70
%71 = getelementptr inbounds %struct.can_frame, %struct.can_frame* %7, i32 0, i32 2
%72 = load i32*, i32** %71
%73 = getelementptr inbounds i32, i32* %72, i64 1
store i32 34, i32* %73
%74 = load i32, i32* %6
%75 = call i32 @write(i32 %74, %struct.can_frame* %7, i32 16)
store i32 %75, i32* %8
%76 = load i32, i32* %8
%77 = icmp slt i32 %76, 0
br i1 %77, label %78, label %80
78: ; preds = %65
%79 = call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0))
store i32 1, i32* %3
br label %153
80: ; preds = %65
%81 = load i32, i32* %8
%82 = sext i32 %81 to i64
%83 = icmp ne i64 %82, 16
br i1 %83, label %84, label %86
84: ; preds = %80
%85 = call i32 @perror(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.7, i64 0, i64 0))
store i32 1, i32* %3
br label %153
86: ; preds = %80
br label %87
87: ; preds = %86, %62
br label %88
88: ; preds = %87, %152
%89 = load i32, i32* %6
%90 = call i32 @read(i32 %89, %struct.can_frame* %7, i32 16)
store i32 %90, i32* %8
%91 = icmp slt i32 %90, 0
br i1 %91, label %92, label %94
92: ; preds = %88
%93 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.8, i64 0, i64 0))
store i32 1, i32* %3
br label %153
94: ; preds = %88
%95 = load i32, i32* %8
%96 = sext i32 %95 to i64
%97 = icmp ult i64 %96, 16
br i1 %97, label %98, label %101
98: ; preds = %94
%99 = load i32, i32* @stderr
%100 = call i32 (i32, i8*, ...) @fprintf(i32 %99, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.9, i64 0, i64 0))
store i32 1, i32* %3
br label %153
101: ; preds = %94
%102 = getelementptr inbounds %struct.can_frame, %struct.can_frame* %7, i32 0, i32 0
%103 = load i32, i32* %102
%104 = load i32, i32* @CAN_EFF_FLAG
%105 = and i32 %103, %104
%106 = icmp ne i32 %105, 0
br i1 %106, label %107, label %113
107: ; preds = %101
%108 = getelementptr inbounds %struct.can_frame, %struct.can_frame* %7, i32 0, i32 0
%109 = load i32, i32* %108
%110 = load i32, i32* @CAN_EFF_MASK
%111 = and i32 %109, %110
%112 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.10, i64 0, i64 0), i32 %111)
br label %119
113: ; preds = %101
%114 = getelementptr inbounds %struct.can_frame, %struct.can_frame* %7, i32 0, i32 0
%115 = load i32, i32* %114
%116 = load i32, i32* @CAN_SFF_MASK
%117 = and i32 %115, %116
%118 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.11, i64 0, i64 0), i32 %117)
br label %119
119: ; preds = %113, %107
%120 = getelementptr inbounds %struct.can_frame, %struct.can_frame* %7, i32 0, i32 1
%121 = load i32, i32* %120
%122 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.12, i64 0, i64 0), i32 %121)
store i32 0, i32* %9
br label %123
123: ; preds = %136, %119
%124 = load i32, i32* %9
%125 = getelementptr inbounds %struct.can_frame, %struct.can_frame* %7, i32 0, i32 1
%126 = load i32, i32* %125
%127 = icmp slt i32 %124, %126
br i1 %127, label %128, label %139
128: ; preds = %123
%129 = getelementptr inbounds %struct.can_frame, %struct.can_frame* %7, i32 0, i32 2
%130 = load i32*, i32** %129
%131 = load i32, i32* %9
%132 = sext i32 %131 to i64
%133 = getelementptr inbounds i32, i32* %130, i64 %132
%134 = load i32, i32* %133
%135 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.13, i64 0, i64 0), i32 %134)
br label %136
136: ; preds = %128
%137 = load i32, i32* %9
%138 = add nsw i32 %137, 1
store i32 %138, i32* %9
br label %123
139: ; preds = %123
%140 = getelementptr inbounds %struct.can_frame, %struct.can_frame* %7, i32 0, i32 0
%141 = load i32, i32* %140
%142 = load i32, i32* @CAN_RTR_FLAG
%143 = and i32 %141, %142
%144 = icmp ne i32 %143, 0
br i1 %144, label %145, label %147
145: ; preds = %139
%146 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.14, i64 0, i64 0))
br label %147
147: ; preds = %145, %139
%148 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.15, i64 0, i64 0))
%149 = load i32, i32* @stdout
%150 = call i32 @fflush(i32 %149)
br label %151
151: ; preds = %147
br label %152
152: ; preds = %151
br label %88
153: ; preds = %98, %92, %84, %78, %60, %37
%154 = load i32, i32* %3
ret i32 %154
}

LLVM IR (-O2):
%struct.ifreq = type { i32, i32 }
%struct.sockaddr_ll = type { i32, i32, i32 }
%struct.can_frame = type { i32, i32, i32* }
%struct.sockaddr = type { i32 }
@main.ifr = internal global %struct.ifreq zeroinitializer
@main.sll = internal global %struct.sockaddr_ll zeroinitializer
@.str = [6 x i8] c"vcan2\00"
@.str.1 = [4 x i8] c"i:s\00"
@optarg = global i8* null
@stderr = global i32 0
@.str.2 = [19 x i8] c"Unknown option %c\0A\00"
@PF_PACKET = global i32 0
@SOCK_RAW = global i32 0
@ETH_P_CAN = global i32 0
@.str.3 = [7 x i8] c"socket\00"
@.str.4 = [4 x i8] c"any\00"
@SIOCGIFINDEX = global i32 0
@AF_PACKET = global i32 0
@.str.5 = [5 x i8] c"bind\00"
@.str.8 = [5 x i8] c"read\00"
@.str.9 = [28 x i8] c"read: incomplete CAN frame\0A\00"
@CAN_EFF_FLAG = global i32 0
@.str.10 = [6 x i8] c"%8X \00"
@CAN_EFF_MASK = global i32 0
@.str.11 = [6 x i8] c"%3X \00"
@CAN_SFF_MASK = global i32 0
@.str.12 = [6 x i8] c"[%d] \00"
@.str.13 = [6 x i8] c"%02X \00"
@CAN_RTR_FLAG = global i32 0
@.str.14 = [15 x i8] c"remote request\00"
@stdout = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca %struct.can_frame
%4 = bitcast %struct.can_frame* %3 to i8*
br label %5
5: ; preds = %12, %2
%6 = phi i8* [ %13, %12 ], [ getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), %2 ]
%7 = phi i32 [ %9, %12 ], [ 0, %2 ]
br label %8
8: ; preds = %10, %5
%9 = phi i32 [ %7, %5 ], [ 1, %10 ]
br label %10
10: ; preds = %8, %14
%11 = tail call i32 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
switch i32 %11, label %14 [
i32 -1, label %17
i32 105, label %12
i32 115, label %8
]
12: ; preds = %10
%13 = load i8*, i8** @optarg
br label %5
14: ; preds = %10
%15 = load i32, i32* @stderr
%16 = tail call i32 (i32, i8*, ...) @fprintf(i32 %15, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0), i32 %11)
br label %10
17: ; preds = %10
%18 = load i32, i32* @PF_PACKET
%19 = load i32, i32* @SOCK_RAW
%20 = load i32, i32* @ETH_P_CAN
%21 = tail call i32 @htons(i32 %20)
%22 = tail call i32 @socket(i32 %18, i32 %19, i32 %21)
%23 = icmp slt i32 %22, 0
br i1 %23, label %24, label %26
24: ; preds = %17
%25 = tail call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
br label %96
26: ; preds = %17
%27 = tail call i64 @strcmp(i8* %6, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0))
%28 = icmp eq i64 %27, 0
br i1 %28, label %35, label %29
29: ; preds = %26
%30 = load i32, i32* getelementptr inbounds (%struct.ifreq, %struct.ifreq* @main.ifr, i64 0, i32 1)
%31 = tail call i32 @strcpy(i32 %30, i8* %6)
%32 = load i32, i32* @SIOCGIFINDEX
%33 = tail call i32 @ioctl(i32 %22, i32 %32, %struct.ifreq* @main.ifr)
%34 = load i32, i32* getelementptr inbounds (%struct.ifreq, %struct.ifreq* @main.ifr, i64 0, i32 0)
br label %35
35: ; preds = %26, %29
%36 = phi i32 [ %34, %29 ], [ 0, %26 ]
%37 = load i32, i32* @AF_PACKET
store i32 %37, i32* getelementptr inbounds (%struct.sockaddr_ll, %struct.sockaddr_ll* @main.sll, i64 0, i32 2)
store i32 %36, i32* getelementptr inbounds (%struct.sockaddr_ll, %struct.sockaddr_ll* @main.sll, i64 0, i32 0)
%38 = load i32, i32* @ETH_P_CAN
%39 = tail call i32 @htons(i32 %38)
store i32 %39, i32* getelementptr inbounds (%struct.sockaddr_ll, %struct.sockaddr_ll* @main.sll, i64 0, i32 1)
%40 = tail call i64 @bind(i32 %22, %struct.sockaddr* bitcast (%struct.sockaddr_ll* @main.sll to %struct.sockaddr*), i32 12)
%41 = icmp slt i64 %40, 0
br i1 %41, label %42, label %44
42: ; preds = %35
%43 = tail call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0))
br label %96
44: ; preds = %35
%45 = icmp eq i32 %9, 0
%46 = call i32 @read(i32 %22, %struct.can_frame* %3, i32 16)
%47 = icmp slt i32 %46, 0
br i1 %47, label %52, label %48
48: ; preds = %44
%49 = getelementptr inbounds %struct.can_frame, %struct.can_frame* %3, i64 0, i32 0
%50 = getelementptr inbounds %struct.can_frame, %struct.can_frame* %3, i64 0, i32 1
%51 = getelementptr inbounds %struct.can_frame, %struct.can_frame* %3, i64 0, i32 2
br label %54
52: ; preds = %90, %44
%53 = tail call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.8, i64 0, i64 0))
br label %96
54: ; preds = %48, %90
%55 = phi i32 [ %46, %48 ], [ %94, %90 ]
%56 = icmp ult i32 %55, 16
br i1 %56, label %57, label %60
57: ; preds = %54
%58 = load i32, i32* @stderr
%59 = tail call i32 (i32, i8*, ...) @fprintf(i32 %58, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.9, i64 0, i64 0))
br label %96
60: ; preds = %54
%61 = load i32, i32* %49
%62 = load i32, i32* @CAN_EFF_FLAG
%63 = and i32 %62, %61
%64 = icmp eq i32 %63, 0
%65 = select i1 %64, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.11, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.10, i64 0, i64 0)
%66 = load i32, i32* @CAN_SFF_MASK
%67 = load i32, i32* @CAN_EFF_MASK
%68 = select i1 %64, i32 %66, i32 %67
%69 = and i32 %68, %61
%70 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) %65, i32 %69)
%71 = load i32, i32* %50
%72 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.12, i64 0, i64 0), i32 %71)
%73 = icmp sgt i32 %71, 0
br i1 %73, label %74, label %84
74: ; preds = %60
%75 = load i32*, i32** %51
%76 = zext i32 %71 to i64
br label %77
77: ; preds = %74, %77
%78 = phi i64 [ 0, %74 ], [ %82, %77 ]
%79 = getelementptr inbounds i32, i32* %75, i64 %78
%80 = load i32, i32* %79
%81 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.13, i64 0, i64 0), i32 %80)
%82 = add nuw nsw i64 %78, 1
%83 = icmp eq i64 %82, %76
br i1 %83, label %84, label %77
84: ; preds = %77, %60
%85 = load i32, i32* @CAN_RTR_FLAG
%86 = and i32 %85, %61
%87 = icmp eq i32 %86, 0
br i1 %87, label %90, label %88
88: ; preds = %84
%89 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.14, i64 0, i64 0))
br label %90
90: ; preds = %88, %84
%91 = tail call i32 @putchar(i32 10)
%92 = load i32, i32* @stdout
%93 = tail call i32 @fflush(i32 %92)
%94 = call i32 @read(i32 %22, %struct.can_frame* %3, i32 16)
%95 = icmp slt i32 %94, 0
br i1 %95, label %52, label %54
96: ; preds = %57, %52, %42, %24
ret i32 1
}