#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_can {
  int can_ifindex;
  int /*<<< orphan*/ can_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;
};
struct can_filter {
  int can_id;
  int can_mask;
};
typedef int /*<<< orphan*/ rfilter;
typedef int /*<<< orphan*/ frame;
typedef int /*<<< orphan*/ addr;

/* Variables and functions */
int /*<<< orphan*/ AF_CAN;
int CAN_EFF_FLAG;
int /*<<< orphan*/ CAN_RAW;
int /*<<< orphan*/ CAN_RAW_FILTER;
int CAN_RTR_FLAG;
int CAN_SFF_MASK;
int /*<<< orphan*/ PF_CAN;
int /*<<< orphan*/ SIOCGIFINDEX;
int /*<<< orphan*/ SOCK_RAW;
int /*<<< orphan*/ SOL_CAN_RAW;
scalar_t__ bind(int, struct sockaddr *, int);
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ getchar();
int /*<<< orphan*/ ioctl(int, int /*<<< orphan*/, struct ifreq *);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, ...);
int read(int, struct can_frame *, int);
int /*<<< orphan*/ setsockopt(int, int /*<<< orphan*/, int /*<<< orphan*/,
                              struct can_filter *, int);
int socket(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ strcpy(int /*<<< orphan*/, char *);
scalar_t__ write(int, struct can_frame *, int);
int main(int argc, char **argv) {
  int s;
  struct sockaddr_can addr;
  struct can_filter rfilter;
  struct can_frame frame;
  int testcase;
  int nbytes;
  struct ifreq ifr;
  int ifindex;
  if ((s = socket(PF_CAN, SOCK_RAW, CAN_RAW)) < 0) {
    perror("socket");
    return 1;
  }
  strcpy(ifr.ifr_name, "vcan0");
  ioctl(s, SIOCGIFINDEX, &ifr);
  ifindex = ifr.ifr_ifindex;
  addr.can_family = AF_CAN;
  addr.can_ifindex = ifindex;
  rfilter.can_id = 0xFA;
  rfilter.can_mask = CAN_SFF_MASK | CAN_EFF_FLAG | CAN_RTR_FLAG;
  setsockopt(s, SOL_CAN_RAW, CAN_RAW_FILTER, &rfilter, sizeof(rfilter));
  if (bind(s, (struct sockaddr *)&addr, sizeof(addr)) < 0) {
    perror("bind");
    return 1;
  }
  for (testcase = 0; testcase < 19; testcase++) {
    printf("Sending testcase %2d ... ", testcase);
    frame.can_id = 0x0F;
    frame.can_dlc = 1;
    frame.data[0] = testcase;
    if (write(s, &frame, sizeof(frame)) < 0) {
      perror("write");
      exit(1);
    }
    if ((nbytes = read(s, &frame, sizeof(struct can_frame))) < 0) {
      perror("read");
      exit(1);
    }
    if (nbytes < sizeof(struct can_frame)) {
      fprintf(stderr, "read: incomplete CAN frame\n");
      exit(1);
    }
    if ((frame.can_id != 0xFA) || (frame.can_dlc != 1) ||
        (frame.data[0] != testcase)) {
      fprintf(stderr, "\nWrong answer from server!\n");
      exit(1);
    }
    printf("acked. ");
    if (testcase > 17)
      break;
    if (argc == 2) {
      printf("[press enter] ");
      getchar();
    }
    printf("Sending patterns ... ");
    frame.can_dlc = 0;
    frame.can_id = 0x123;
    if (write(s, &frame, sizeof(frame)) < 0) {
      perror("write");
      exit(1);
    }
    frame.can_id = (0x123 | CAN_RTR_FLAG);
    if (write(s, &frame, sizeof(frame)) < 0) {
      perror("write");
      exit(1);
    }
    frame.can_id = (0x123 | CAN_EFF_FLAG);
    if (write(s, &frame, sizeof(frame)) < 0) {
      perror("write");
      exit(1);
    }
    frame.can_id = (0x123 | CAN_EFF_FLAG | CAN_RTR_FLAG);
    if (write(s, &frame, sizeof(frame)) < 0) {
      perror("write");
      exit(1);
    }
    printf("ok\n");
  }
  printf("Filtertest done.\n");
  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)
mov    0x2dbb(%rip),%rax
mov    (%rax),%edi
mov    0x2dea(%rip),%rax
mov    (%rax),%esi
mov    0x2da1(%rip),%rax
mov    (%rax),%edx
call   10f0 <socket@plt>
mov    %eax,-0x14(%rbp)
cmp    $0x0,%eax
jge    122a <main+0x5a>
lea    0xde7(%rip),%rdi
call   10d0 <perror@plt>
movl   $0x1,-0x4(%rbp)
jmp    1582 <main+0x3b2>
mov    -0x44(%rbp),%edi
lea    0xdd3(%rip),%rsi
call   1030 <strcpy@plt>
mov    -0x14(%rbp),%edi
mov    0x2d45(%rip),%rax
mov    (%rax),%esi
lea    -0x48(%rbp),%rdx
call   1070 <ioctl@plt>
mov    -0x48(%rbp),%eax
mov    %eax,-0x4c(%rbp)
mov    0x2d95(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x4c(%rbp),%eax
mov    %eax,-0x20(%rbp)
movl   $0xfa,-0x28(%rbp)
mov    0x2d1c(%rip),%rax
mov    (%rax),%eax
mov    0x2d3b(%rip),%rcx
or     (%rcx),%eax
mov    0x2d2a(%rip),%rcx
or     (%rcx),%eax
mov    %eax,-0x24(%rbp)
mov    -0x14(%rbp),%edi
mov    0x2d43(%rip),%rax
mov    (%rax),%esi
mov    0x2d22(%rip),%rax
mov    (%rax),%edx
lea    -0x28(%rbp),%rcx
mov    $0x8,%r8d
call   1040 <setsockopt@plt>
mov    -0x14(%rbp),%edi
lea    -0x20(%rbp),%rsi
mov    $0x8,%edx
call   10c0 <bind@plt>
cmp    $0x0,%rax
jge    12e2 <main+0x112>
lea    0xd3c(%rip),%rdi
call   10d0 <perror@plt>
movl   $0x1,-0x4(%rbp)
jmp    1582 <main+0x3b2>
movl   $0x0,-0x3c(%rbp)
cmpl   $0x13,-0x3c(%rbp)
jge    1565 <main+0x395>
mov    -0x3c(%rbp),%esi
lea    0xd15(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0xf,-0x38(%rbp)
movl   $0x1,-0x34(%rbp)
mov    -0x3c(%rbp),%ecx
mov    -0x30(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x14(%rbp),%edi
lea    -0x38(%rbp),%rsi
mov    $0x10,%edx
call   1050 <write@plt>
cmp    $0x0,%rax
jge    134c <main+0x17c>
lea    0xcef(%rip),%rdi
call   10d0 <perror@plt>
mov    $0x1,%edi
call   10e0 <exit@plt>
mov    -0x14(%rbp),%edi
lea    -0x38(%rbp),%rsi
mov    $0x10,%edx
call   1090 <read@plt>
mov    %eax,-0x40(%rbp)
cmp    $0x0,%eax
jge    137f <main+0x1af>
lea    0xcc2(%rip),%rdi
call   10d0 <perror@plt>
mov    $0x1,%edi
call   10e0 <exit@plt>
movslq -0x40(%rbp),%rax
cmp    $0x10,%rax
jae    13ac <main+0x1dc>
mov    0x2c34(%rip),%rax
mov    (%rax),%edi
lea    0xc9a(%rip),%rsi
call   10b0 <fprintf@plt>
mov    $0x1,%edi
call   10e0 <exit@plt>
cmpl   $0xfa,-0x38(%rbp)
jne    13d2 <main+0x202>
cmpl   $0x1,-0x34(%rbp)
jne    13d2 <main+0x202>
mov    -0x30(%rbp),%rax
mov    (%rax),%eax
cmp    -0x3c(%rbp),%eax
je     13f1 <main+0x221>
mov    0x2bef(%rip),%rax
mov    (%rax),%edi
lea    0xc71(%rip),%rsi
call   10b0 <fprintf@plt>
mov    $0x1,%edi
call   10e0 <exit@plt>
lea    0xc77(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
cmpl   $0x11,-0x3c(%rbp)
jle    140e <main+0x23e>
jmp    1565 <main+0x395>
cmpl   $0x2,-0x8(%rbp)
jne    142d <main+0x25d>
lea    0xc58(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    $0x0,%al
call   10a0 <getchar@plt>
lea    0xc52(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0x0,-0x34(%rbp)
movl   $0x123,-0x38(%rbp)
mov    -0x14(%rbp),%edi
lea    -0x38(%rbp),%rsi
mov    $0x10,%edx
call   1050 <write@plt>
cmp    $0x0,%rax
jge    147a <main+0x2aa>
lea    0xbc1(%rip),%rdi
call   10d0 <perror@plt>
mov    $0x1,%edi
call   10e0 <exit@plt>
mov    0x2b2f(%rip),%rax
mov    (%rax),%eax
or     $0x123,%eax
mov    %eax,-0x38(%rbp)
mov    -0x14(%rbp),%edi
lea    -0x38(%rbp),%rsi
mov    $0x10,%edx
call   1050 <write@plt>
cmp    $0x0,%rax
jge    14bc <main+0x2ec>
lea    0xb7f(%rip),%rdi
call   10d0 <perror@plt>
mov    $0x1,%edi
call   10e0 <exit@plt>
mov    0x2af5(%rip),%rax
mov    (%rax),%eax
or     $0x123,%eax
mov    %eax,-0x38(%rbp)
mov    -0x14(%rbp),%edi
lea    -0x38(%rbp),%rsi
mov    $0x10,%edx
call   1050 <write@plt>
cmp    $0x0,%rax
jge    14fe <main+0x32e>
lea    0xb3d(%rip),%rdi
call   10d0 <perror@plt>
mov    $0x1,%edi
call   10e0 <exit@plt>
mov    0x2ab3(%rip),%rax
mov    (%rax),%eax
or     $0x123,%eax
mov    0x2a9d(%rip),%rcx
or     (%rcx),%eax
mov    %eax,-0x38(%rbp)
mov    -0x14(%rbp),%edi
lea    -0x38(%rbp),%rsi
mov    $0x10,%edx
call   1050 <write@plt>
cmp    $0x0,%rax
jge    1549 <main+0x379>
lea    0xaf2(%rip),%rdi
call   10d0 <perror@plt>
mov    $0x1,%edi
call   10e0 <exit@plt>
lea    0xb4c(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
jmp    12e9 <main+0x119>
lea    0xb34(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x14(%rbp),%edi
call   1080 <close@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x20,%rsp
mov    0x2e34(%rip),%rax
mov    (%rax),%edi
mov    0x2e5b(%rip),%rax
mov    (%rax),%esi
mov    0x2e1a(%rip),%rax
mov    (%rax),%edx
call   1090 <socket@plt>
test   %eax,%eax
jns    11a5 <main+0x35>
lea    0xe60(%rip),%rdi
jmp    1245 <main+0xd5>
mov    %eax,%ebx
lea    0xe59(%rip),%rsi
call   1030 <strcpy@plt>
mov    0x2dd6(%rip),%rax
mov    (%rax),%esi
lea    0x18(%rsp),%rdx
mov    %ebx,%edi
call   1060 <ioctl@plt>
mov    0x18(%rsp),%eax
mov    0x2e1d(%rip),%rcx
mov    (%rcx),%ecx
mov    %ecx,0x14(%rsp)
mov    %eax,0x10(%rsp)
movl   $0xfa,0x8(%rsp)
mov    0x2dac(%rip),%rax
mov    0x2dcd(%rip),%rcx
mov    (%rcx),%ecx
or     (%rax),%ecx
mov    0x2dba(%rip),%rax
or     (%rax),%ecx
mov    %ecx,0xc(%rsp)
mov    0x2dcd(%rip),%rax
mov    (%rax),%esi
mov    0x2db4(%rip),%rax
mov    (%rax),%edx
lea    0x8(%rsp),%rcx
mov    %ebx,%edi
mov    $0x8,%r8d
call   1040 <setsockopt@plt>
lea    0x10(%rsp),%rsi
mov    %ebx,%edi
mov    $0x8,%edx
call   1070 <bind@plt>
test   %rax,%rax
jns    1255 <main+0xe5>
lea    0xdc8(%rip),%rdi
call   1080 <perror@plt>
mov    $0x1,%eax
add    $0x20,%rsp
pop    %rbx
ret
lea    0xdb6(%rip),%rdi
xor    %esi,%esi
xor    %eax,%eax
call   1050 <printf@plt>

LLVM IR (-O0):
%struct.sockaddr_can = type { i32, i32 }
%struct.can_filter = type { i32, i32 }
%struct.can_frame = type { i32, i32, i32* }
%struct.ifreq = type { i32, i32 }
%struct.sockaddr = type { i32 }
@PF_CAN = global i32 0
@SOCK_RAW = global i32 0
@CAN_RAW = global i32 0
@.str = [7 x i8] c"socket\00"
@.str.1 = [6 x i8] c"vcan0\00"
@SIOCGIFINDEX = global i32 0
@AF_CAN = global i32 0
@CAN_SFF_MASK = global i32 0
@CAN_EFF_FLAG = global i32 0
@CAN_RTR_FLAG = global i32 0
@SOL_CAN_RAW = global i32 0
@CAN_RAW_FILTER = global i32 0
@.str.2 = [5 x i8] c"bind\00"
@.str.3 = [26 x i8] c"Sending testcase %2d ... \00"
@.str.4 = [6 x i8] c"write\00"
@.str.5 = [5 x i8] c"read\00"
@stderr = global i32 0
@.str.6 = [28 x i8] c"read: incomplete CAN frame\0A\00"
@.str.7 = [28 x i8] c"\0AWrong answer from server!\0A\00"
@.str.8 = [8 x i8] c"acked. \00"
@.str.9 = [15 x i8] c"[press enter] \00"
@.str.10 = [22 x i8] c"Sending patterns ... \00"
@.str.11 = [4 x i8] c"ok\0A\00"
@.str.12 = [18 x i8] c"Filtertest done.\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca %struct.sockaddr_can
%8 = alloca %struct.can_filter
%9 = alloca %struct.can_frame
%10 = alloca i32
%11 = alloca i32
%12 = alloca %struct.ifreq
%13 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%14 = load i32, i32* @PF_CAN
%15 = load i32, i32* @SOCK_RAW
%16 = load i32, i32* @CAN_RAW
%17 = call i32 @socket(i32 %14, i32 %15, i32 %16)
store i32 %17, i32* %6
%18 = icmp slt i32 %17, 0
br i1 %18, label %19, label %21
19: ; preds = %2
%20 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %3
br label %166
21: ; preds = %2
%22 = getelementptr inbounds %struct.ifreq, %struct.ifreq* %12, i32 0, i32 1
%23 = load i32, i32* %22
%24 = call i32 @strcpy(i32 %23, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%25 = load i32, i32* %6
%26 = load i32, i32* @SIOCGIFINDEX
%27 = call i32 @ioctl(i32 %25, i32 %26, %struct.ifreq* %12)
%28 = getelementptr inbounds %struct.ifreq, %struct.ifreq* %12, i32 0, i32 0
%29 = load i32, i32* %28
store i32 %29, i32* %13
%30 = load i32, i32* @AF_CAN
%31 = getelementptr inbounds %struct.sockaddr_can, %struct.sockaddr_can* %7, i32 0, i32 1
store i32 %30, i32* %31
%32 = load i32, i32* %13
%33 = getelementptr inbounds %struct.sockaddr_can, %struct.sockaddr_can* %7, i32 0, i32 0
store i32 %32, i32* %33
%34 = getelementptr inbounds %struct.can_filter, %struct.can_filter* %8, i32 0, i32 0
store i32 250, i32* %34
%35 = load i32, i32* @CAN_SFF_MASK
%36 = load i32, i32* @CAN_EFF_FLAG
%37 = or i32 %35, %36
%38 = load i32, i32* @CAN_RTR_FLAG
%39 = or i32 %37, %38
%40 = getelementptr inbounds %struct.can_filter, %struct.can_filter* %8, i32 0, i32 1
store i32 %39, i32* %40
%41 = load i32, i32* %6
%42 = load i32, i32* @SOL_CAN_RAW
%43 = load i32, i32* @CAN_RAW_FILTER
%44 = call i32 @setsockopt(i32 %41, i32 %42, i32 %43, %struct.can_filter* %8, i32 8)
%45 = load i32, i32* %6
%46 = bitcast %struct.sockaddr_can* %7 to %struct.sockaddr*
%47 = call i64 @bind(i32 %45, %struct.sockaddr* %46, i32 8)
%48 = icmp slt i64 %47, 0
br i1 %48, label %49, label %51
49: ; preds = %21
%50 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
store i32 1, i32* %3
br label %166
51: ; preds = %21
store i32 0, i32* %10
br label %52
52: ; preds = %159, %51
%53 = load i32, i32* %10
%54 = icmp slt i32 %53, 19
br i1 %54, label %55, label %162
55: ; preds = %52
%56 = load i32, i32* %10
%57 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.3, i64 0, i64 0), i32 %56)
%58 = getelementptr inbounds %struct.can_frame, %struct.can_frame* %9, i32 0, i32 0
store i32 15, i32* %58
%59 = getelementptr inbounds %struct.can_frame, %struct.can_frame* %9, i32 0, i32 1
store i32 1, i32* %59
%60 = load i32, i32* %10
%61 = getelementptr inbounds %struct.can_frame, %struct.can_frame* %9, i32 0, i32 2
%62 = load i32*, i32** %61
%63 = getelementptr inbounds i32, i32* %62, i64 0
store i32 %60, i32* %63
%64 = load i32, i32* %6
%65 = call i64 @write(i32 %64, %struct.can_frame* %9, i32 16)
%66 = icmp slt i64 %65, 0
br i1 %66, label %67, label %70
67: ; preds = %55
%68 = call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0))
%69 = call i32 @exit(i32 1)
unreachable
70: ; preds = %55
%71 = load i32, i32* %6
%72 = call i32 @read(i32 %71, %struct.can_frame* %9, i32 16)
store i32 %72, i32* %11
%73 = icmp slt i32 %72, 0
br i1 %73, label %74, label %77
74: ; preds = %70
%75 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0))
%76 = call i32 @exit(i32 1)
unreachable
77: ; preds = %70
%78 = load i32, i32* %11
%79 = sext i32 %78 to i64
%80 = icmp ult i64 %79, 16
br i1 %80, label %81, label %85
81: ; preds = %77
%82 = load i32, i32* @stderr
%83 = call i32 @fprintf(i32 %82, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.6, i64 0, i64 0))
%84 = call i32 @exit(i32 1)
unreachable
85: ; preds = %77
%86 = getelementptr inbounds %struct.can_frame, %struct.can_frame* %9, i32 0, i32 0
%87 = load i32, i32* %86
%88 = icmp ne i32 %87, 250
br i1 %88, label %100, label %89
89: ; preds = %85
%90 = getelementptr inbounds %struct.can_frame, %struct.can_frame* %9, i32 0, i32 1
%91 = load i32, i32* %90
%92 = icmp ne i32 %91, 1
br i1 %92, label %100, label %93
93: ; preds = %89
%94 = getelementptr inbounds %struct.can_frame, %struct.can_frame* %9, i32 0, i32 2
%95 = load i32*, i32** %94
%96 = getelementptr inbounds i32, i32* %95, i64 0
%97 = load i32, i32* %96
%98 = load i32, i32* %10
%99 = icmp ne i32 %97, %98
br i1 %99, label %100, label %104
100: ; preds = %93, %89, %85
%101 = load i32, i32* @stderr
%102 = call i32 @fprintf(i32 %101, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.7, i64 0, i64 0))
%103 = call i32 @exit(i32 1)
unreachable
104: ; preds = %93
%105 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.8, i64 0, i64 0))
%106 = load i32, i32* %10
%107 = icmp sgt i32 %106, 17
br i1 %107, label %108, label %109
108: ; preds = %104
br label %162
109: ; preds = %104
%110 = load i32, i32* %4
%111 = icmp eq i32 %110, 2
br i1 %111, label %112, label %115
112: ; preds = %109
%113 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.9, i64 0, i64 0))
%114 = call i32 (...) @getchar()
br label %115
115: ; preds = %112, %109
%116 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.10, i64 0, i64 0))
%117 = getelementptr inbounds %struct.can_frame, %struct.can_frame* %9, i32 0, i32 1
store i32 0, i32* %117
%118 = getelementptr inbounds %struct.can_frame, %struct.can_frame* %9, i32 0, i32 0
store i32 291, i32* %118
%119 = load i32, i32* %6
%120 = call i64 @write(i32 %119, %struct.can_frame* %9, i32 16)
%121 = icmp slt i64 %120, 0
br i1 %121, label %122, label %125
122: ; preds = %115
%123 = call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0))
%124 = call i32 @exit(i32 1)
unreachable
125: ; preds = %115
%126 = load i32, i32* @CAN_RTR_FLAG
%127 = or i32 291, %126
%128 = getelementptr inbounds %struct.can_frame, %struct.can_frame* %9, i32 0, i32 0
store i32 %127, i32* %128
%129 = load i32, i32* %6
%130 = call i64 @write(i32 %129, %struct.can_frame* %9, i32 16)
%131 = icmp slt i64 %130, 0
br i1 %131, label %132, label %135
132: ; preds = %125
%133 = call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0))
%134 = call i32 @exit(i32 1)
unreachable
135: ; preds = %125
%136 = load i32, i32* @CAN_EFF_FLAG
%137 = or i32 291, %136
%138 = getelementptr inbounds %struct.can_frame, %struct.can_frame* %9, i32 0, i32 0
store i32 %137, i32* %138
%139 = load i32, i32* %6
%140 = call i64 @write(i32 %139, %struct.can_frame* %9, i32 16)
%141 = icmp slt i64 %140, 0
br i1 %141, label %142, label %145
142: ; preds = %135
%143 = call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0))
%144 = call i32 @exit(i32 1)
unreachable
145: ; preds = %135
%146 = load i32, i32* @CAN_EFF_FLAG
%147 = or i32 291, %146
%148 = load i32, i32* @CAN_RTR_FLAG
%149 = or i32 %147, %148
%150 = getelementptr inbounds %struct.can_frame, %struct.can_frame* %9, i32 0, i32 0
store i32 %149, i32* %150
%151 = load i32, i32* %6
%152 = call i64 @write(i32 %151, %struct.can_frame* %9, i32 16)
%153 = icmp slt i64 %152, 0
br i1 %153, label %154, label %157
154: ; preds = %145
%155 = call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0))
%156 = call i32 @exit(i32 1)
unreachable
157: ; preds = %145
%158 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.11, i64 0, i64 0))
br label %159
159: ; preds = %157
%160 = load i32, i32* %10
%161 = add nsw i32 %160, 1
store i32 %161, i32* %10
br label %52
162: ; preds = %108, %52
%163 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.12, i64 0, i64 0))
%164 = load i32, i32* %6
%165 = call i32 @close(i32 %164)
store i32 0, i32* %3
br label %166
166: ; preds = %162, %49, %19
%167 = load i32, i32* %3
ret i32 %167
}

LLVM IR (-O2):
%struct.sockaddr_can = type { i32, i32 }
%struct.can_filter = type { i32, i32 }
%struct.ifreq = type { i32, i32 }
%struct.sockaddr = type { i32 }
@PF_CAN = global i32 0
@SOCK_RAW = global i32 0
@CAN_RAW = global i32 0
@.str = [7 x i8] c"socket\00"
@.str.1 = [6 x i8] c"vcan0\00"
@SIOCGIFINDEX = global i32 0
@AF_CAN = global i32 0
@CAN_SFF_MASK = global i32 0
@CAN_EFF_FLAG = global i32 0
@CAN_RTR_FLAG = global i32 0
@SOL_CAN_RAW = global i32 0
@CAN_RAW_FILTER = global i32 0
@.str.2 = [5 x i8] c"bind\00"
@.str.3 = [26 x i8] c"Sending testcase %2d ... \00"
@stderr = global i32 0
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca %struct.sockaddr_can
%4 = alloca %struct.can_filter
%5 = alloca %struct.ifreq
%6 = bitcast %struct.sockaddr_can* %3 to i8*
%7 = bitcast %struct.can_filter* %4 to i8*
%8 = bitcast %struct.ifreq* %5 to i8*
%9 = load i32, i32* @PF_CAN
%10 = load i32, i32* @SOCK_RAW
%11 = load i32, i32* @CAN_RAW
%12 = tail call i32 @socket(i32 %9, i32 %10, i32 %11)
%13 = icmp slt i32 %12, 0
br i1 %13, label %14, label %16
14: ; preds = %2
%15 = tail call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
br label %42
16: ; preds = %2
%17 = tail call i32 @strcpy(i32 undef, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%18 = load i32, i32* @SIOCGIFINDEX
%19 = call i32 @ioctl(i32 %12, i32 %18, %struct.ifreq* %5)
%20 = getelementptr inbounds %struct.ifreq, %struct.ifreq* %5, i64 0, i32 0
%21 = load i32, i32* %20
%22 = load i32, i32* @AF_CAN
%23 = getelementptr inbounds %struct.sockaddr_can, %struct.sockaddr_can* %3, i64 0, i32 1
store i32 %22, i32* %23
%24 = getelementptr inbounds %struct.sockaddr_can, %struct.sockaddr_can* %3, i64 0, i32 0
store i32 %21, i32* %24
%25 = getelementptr inbounds %struct.can_filter, %struct.can_filter* %4, i64 0, i32 0
store i32 250, i32* %25
%26 = load i32, i32* @CAN_SFF_MASK
%27 = load i32, i32* @CAN_EFF_FLAG
%28 = or i32 %27, %26
%29 = load i32, i32* @CAN_RTR_FLAG
%30 = or i32 %28, %29
%31 = getelementptr inbounds %struct.can_filter, %struct.can_filter* %4, i64 0, i32 1
store i32 %30, i32* %31
%32 = load i32, i32* @SOL_CAN_RAW
%33 = load i32, i32* @CAN_RAW_FILTER
%34 = call i32 @setsockopt(i32 %12, i32 %32, i32 %33, %struct.can_filter* %4, i32 8)
%35 = bitcast %struct.sockaddr_can* %3 to %struct.sockaddr*
%36 = call i64 @bind(i32 %12, %struct.sockaddr* %35, i32 8)
%37 = icmp slt i64 %36, 0
br i1 %37, label %40, label %38
38: ; preds = %16
%39 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.3, i64 0, i64 0), i32 0)
unreachable
40: ; preds = %16
%41 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
br label %42
42: ; preds = %40, %14
ret i32 1
}