#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 */
typedef int /*<<< orphan*/ timestamping_on;
typedef int /*<<< orphan*/ timestamp_on;
struct sockaddr_can {
  scalar_t__ can_ifindex;
  int /*<<< orphan*/ can_family;
};
struct sockaddr {
  int dummy;
};
struct ifreq {
  scalar_t__ ifr_ifindex;
  int /*<<< orphan*/ ifr_name;
};
typedef int /*<<< orphan*/ recv_own_msgs;
typedef int /*<<< orphan*/ err_mask;
typedef int /*<<< orphan*/ dropmonitor_on;
typedef int const can_err_mask_t;
typedef int /*<<< orphan*/ addr;
typedef int /*<<< orphan*/ TxBuffSize;
typedef int /*<<< orphan*/ RxBuffSize;

/* Variables and functions */
int /*<<< orphan*/ AF_CAN;
int CAN_ERR_ACK;
int CAN_ERR_BUSERROR;
int CAN_ERR_BUSOFF;
int CAN_ERR_CRTL;
int CAN_ERR_LOSTARB;
int CAN_ERR_PROT;
int CAN_ERR_RESTARTED;
int CAN_ERR_TRX;
int CAN_ERR_TX_TIMEOUT;
int /*<<< orphan*/ CAN_RAW;
int /*<<< orphan*/ CAN_RAW_ERR_FILTER;
int /*<<< orphan*/ CAN_RAW_RECV_OWN_MSGS;
int /*<<< orphan*/ PF_CAN;
int /*<<< orphan*/ SIOCGIFINDEX;
int /*<<< orphan*/ SOCK_RAW;
int /*<<< orphan*/ SOL_CAN_RAW;
int /*<<< orphan*/ SOL_SOCKET;
int /*<<< orphan*/ SO_RCVBUF;
int /*<<< orphan*/ SO_RXQ_OVFL;
int /*<<< orphan*/ SO_SNDBUF;
int /*<<< orphan*/ SO_TIMESTAMP;
int /*<<< orphan*/ SO_TIMESTAMPING;
scalar_t__ bind(int, struct sockaddr const *, int);
int errno;
int /*<<< orphan*/ ioctl(int, int /*<<< orphan*/, struct ifreq *);
int /*<<< orphan*/ memset(struct sockaddr_can *, int /*<<< orphan*/, int);
int /*<<< orphan*/ perror(char *);
scalar_t__ setsockopt(int, int /*<<< orphan*/, int /*<<< orphan*/, int const *,
                      int);
int socket(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ strcpy(int /*<<< orphan*/, char const *);
int SocketOpen(const char *InterfaceName, int TxBuffSize, int RxBuffSize) {
  int number;
  number = socket(PF_CAN, SOCK_RAW, CAN_RAW);
  if (number < 0) {
    int errsv = errno;
    return -100 * errsv;
  }
  struct ifreq ifr;
  strcpy(ifr.ifr_name, InterfaceName);
  ioctl(number, SIOCGIFINDEX, &ifr);
  if (ifr.ifr_ifindex < 0) {
    int errsv = errno;
    return -10000 * errsv;
  }
  int recv_own_msgs = 1;
  setsockopt(number, SOL_CAN_RAW, CAN_RAW_RECV_OWN_MSGS, &recv_own_msgs,
             sizeof(recv_own_msgs));
  const int timestamping_on = 1;
  if (setsockopt(number, SOL_SOCKET, SO_TIMESTAMPING, &timestamping_on,
                 sizeof(timestamping_on)) < 0) {
    perror("setsockopt SO_TIMESTAMPING");
    return -9;
  }
  const int timestamp_on = 1;
  if (setsockopt(number, SOL_SOCKET, SO_TIMESTAMP, &timestamp_on,
                 sizeof(timestamp_on)) < 0) {
    perror("setsockopt SO_TIMESTAMP");
    return -10;
  }
  can_err_mask_t err_mask =
      (CAN_ERR_TX_TIMEOUT | CAN_ERR_LOSTARB | CAN_ERR_CRTL | CAN_ERR_PROT |
       CAN_ERR_TRX | CAN_ERR_ACK | CAN_ERR_BUSOFF | CAN_ERR_BUSERROR |
       CAN_ERR_RESTARTED);
  if (setsockopt(number, SOL_CAN_RAW, CAN_RAW_ERR_FILTER, &err_mask,
                 sizeof(err_mask)) < 0) {
    perror("setsockopt CAN_RAW_ERR_FILTER");
    return -11;
  }
  TxBuffSize = 352 * TxBuffSize;
  RxBuffSize = 352 * RxBuffSize;
  if (setsockopt(number, SOL_SOCKET, SO_SNDBUF, &TxBuffSize,
                 sizeof(TxBuffSize)) < 0) {
    perror("setsockopt SO_SNDBUF");
    return -12;
  }
  if (setsockopt(number, SOL_SOCKET, SO_RCVBUF, &RxBuffSize,
                 sizeof(RxBuffSize)) < 0) {
    perror("setsockopt SO_RCVBUF");
    return -13;
  }
  const int dropmonitor_on = 1;
  if (setsockopt(number, SOL_SOCKET, SO_RXQ_OVFL, &dropmonitor_on,
                 sizeof(dropmonitor_on)) < 0) {
    perror("setsockopt SO_RXQ_OVFL");
    return -14;
  }
  struct sockaddr_can addr;
  memset(&addr, 0, sizeof(addr));
  addr.can_family = AF_CAN;
  addr.can_ifindex = ifr.ifr_ifindex;
  if (bind(number, (const struct sockaddr *)&addr, sizeof(addr)) != 0) {
    int errsv = errno;
    return -1000000 * errsv;
  }
  return number;
}


x86 assembly (clang, -O0):
<SocketOpen>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %edx,-0x18(%rbp)
mov    0x2dc7(%rip),%rax
mov    (%rax),%edi
mov    0x2e36(%rip),%rax
mov    (%rax),%esi
mov    0x2dad(%rip),%rax
mov    (%rax),%edx
call   1090 <socket@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jge    11ca <SocketOpen+0x5a>
mov    0x2dba(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x20(%rbp)
imul   $0xffffff9c,-0x20(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    14bd <SocketOpen+0x34d>
mov    -0x28(%rbp),%edi
mov    -0x10(%rbp),%rsi
call   1030 <strcpy@plt>
mov    -0x1c(%rbp),%edi
mov    0x2d40(%rip),%rax
mov    (%rax),%esi
lea    -0x30(%rbp),%rdx
call   1060 <ioctl@plt>
cmpq   $0x0,-0x30(%rbp)
jge    1211 <SocketOpen+0xa1>
mov    0x2d73(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x34(%rbp)
imul   $0xffffd8f0,-0x34(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    14bd <SocketOpen+0x34d>
movl   $0x1,-0x38(%rbp)
mov    -0x1c(%rbp),%edi
mov    0x2d86(%rip),%rax
mov    (%rax),%esi
mov    0x2d8d(%rip),%rax
mov    (%rax),%edx
lea    -0x38(%rbp),%rcx
mov    $0x4,%r8d
call   1040 <setsockopt@plt>
movl   $0x1,-0x3c(%rbp)
mov    -0x1c(%rbp),%edi
mov    0x2d93(%rip),%rax
mov    (%rax),%esi
mov    0x2d0a(%rip),%rax
mov    (%rax),%edx
lea    -0x3c(%rbp),%rcx
mov    $0x4,%r8d
call   1040 <setsockopt@plt>
cmp    $0x0,%rax
jge    1289 <SocketOpen+0x119>
lea    0xd88(%rip),%rdi
call   1080 <perror@plt>
movl   $0xfffffff7,-0x4(%rbp)
jmp    14bd <SocketOpen+0x34d>
movl   $0x1,-0x40(%rbp)
mov    -0x1c(%rbp),%edi
mov    0x2d46(%rip),%rax
mov    (%rax),%esi
mov    0x2d35(%rip),%rax
mov    (%rax),%edx
lea    -0x40(%rbp),%rcx
mov    $0x4,%r8d
call   1040 <setsockopt@plt>
cmp    $0x0,%rax
jge    12d6 <SocketOpen+0x166>
lea    0xd56(%rip),%rdi
call   1080 <perror@plt>
movl   $0xfffffff6,-0x4(%rbp)
jmp    14bd <SocketOpen+0x34d>
mov    0x2c63(%rip),%rax
mov    (%rax),%eax
mov    0x2c72(%rip),%rcx
or     (%rcx),%eax
mov    0x2c39(%rip),%rcx
or     (%rcx),%eax
mov    0x2c40(%rip),%rcx
or     (%rcx),%eax
mov    0x2c9f(%rip),%rcx
or     (%rcx),%eax
mov    0x2c6e(%rip),%rcx
or     (%rcx),%eax
mov    0x2c6d(%rip),%rcx
or     (%rcx),%eax
mov    0x2c4c(%rip),%rcx
or     (%rcx),%eax
mov    0x2cab(%rip),%rcx
or     (%rcx),%eax
mov    %eax,-0x44(%rbp)
mov    -0x1c(%rbp),%edi
mov    0x2c74(%rip),%rax
mov    (%rax),%esi
mov    0x2c53(%rip),%rax
mov    (%rax),%edx
lea    -0x44(%rbp),%rcx
mov    $0x4,%r8d
call   1040 <setsockopt@plt>
cmp    $0x0,%rax
jge    1370 <SocketOpen+0x200>
lea    0xcd4(%rip),%rdi
call   1080 <perror@plt>
movl   $0xfffffff5,-0x4(%rbp)
jmp    14bd <SocketOpen+0x34d>
imul   $0x160,-0x14(%rbp),%eax
mov    %eax,-0x14(%rbp)
imul   $0x160,-0x18(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x1c(%rbp),%edi
mov    0x2c52(%rip),%rax
mov    (%rax),%esi
mov    0x2c29(%rip),%rax
mov    (%rax),%edx
lea    -0x14(%rbp),%rcx
mov    $0x4,%r8d
call   1040 <setsockopt@plt>
cmp    $0x0,%rax
jge    13ca <SocketOpen+0x25a>
lea    0xc98(%rip),%rdi
call   1080 <perror@plt>
movl   $0xfffffff4,-0x4(%rbp)
jmp    14bd <SocketOpen+0x34d>
mov    -0x1c(%rbp),%edi
mov    0x2c0c(%rip),%rax
mov    (%rax),%esi
mov    0x2bab(%rip),%rax
mov    (%rax),%edx
lea    -0x18(%rbp),%rcx
mov    $0x4,%r8d
call   1040 <setsockopt@plt>
cmp    $0x0,%rax
jge    1410 <SocketOpen+0x2a0>
lea    0xc67(%rip),%rdi
call   1080 <perror@plt>
movl   $0xfffffff3,-0x4(%rbp)
jmp    14bd <SocketOpen+0x34d>
movl   $0x1,-0x48(%rbp)
mov    -0x1c(%rbp),%edi
mov    0x2bbf(%rip),%rax
mov    (%rax),%esi
mov    0x2b86(%rip),%rax
mov    (%rax),%edx
lea    -0x48(%rbp),%rcx
mov    $0x4,%r8d
call   1040 <setsockopt@plt>
cmp    $0x0,%rax
jge    145d <SocketOpen+0x2ed>
lea    0xc2f(%rip),%rdi
call   1080 <perror@plt>
movl   $0xfffffff2,-0x4(%rbp)
jmp    14bd <SocketOpen+0x34d>
lea    -0x58(%rbp),%rdi
xor    %esi,%esi
mov    $0x10,%edx
call   1050 <memset@plt>
mov    0x2b7c(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x50(%rbp)
mov    -0x30(%rbp),%rax
mov    %rax,-0x58(%rbp)
mov    -0x1c(%rbp),%edi
lea    -0x58(%rbp),%rsi
mov    $0x10,%edx
call   1070 <bind@plt>
cmp    $0x0,%rax
je     14b7 <SocketOpen+0x347>
mov    0x2acd(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x5c(%rbp)
imul   $0xfff0bdc0,-0x5c(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    14bd <SocketOpen+0x34d>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<SocketOpen>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x40,%rsp
mov    %edx,%r14d
mov    %esi,%r15d
mov    %rdi,%rbp
mov    %esi,0x4(%rsp)
mov    0x2dc0(%rip),%rax
mov    (%rax),%edi
mov    0x2e2f(%rip),%rax
mov    (%rax),%esi
mov    0x2da6(%rip),%rax
mov    (%rax),%edx
call   1090 <socket@plt>
test   %eax,%eax
js     13ce <SocketOpen+0x25e>
mov    %eax,%ebx
mov    %rbp,%rsi
call   1030 <strcpy@plt>
mov    0x2d5e(%rip),%rax
mov    (%rax),%esi
lea    0x30(%rsp),%rdx
mov    %ebx,%edi
call   1060 <ioctl@plt>
cmpq   $0x0,0x30(%rsp)
js     13da <SocketOpen+0x26a>
movl   $0x1,0x18(%rsp)
mov    0x2dbd(%rip),%r12
mov    (%r12),%esi
mov    0x2dc2(%rip),%rax
mov    (%rax),%edx
lea    0x18(%rsp),%rcx
mov    %ebx,%edi
mov    $0x4,%r8d
call   1040 <setsockopt@plt>
movl   $0x1,0x14(%rsp)
mov    0x2dc7(%rip),%rbp
mov    0x0(%rbp),%esi
mov    0x2d3d(%rip),%rax
mov    (%rax),%edx
lea    0x14(%rsp),%rcx
mov    %ebx,%edi
mov    $0x4,%r8d
call   1040 <setsockopt@plt>
test   %rax,%rax
js     13f6 <SocketOpen+0x286>
movl   $0x1,0x10(%rsp)
mov    0x0(%rbp),%esi
mov    0x2d86(%rip),%rax
mov    (%rax),%edx
lea    0x10(%rsp),%rcx
mov    %ebx,%edi
mov    $0x4,%r8d
call   1040 <setsockopt@plt>
test   %rax,%rax
js     1409 <SocketOpen+0x299>
mov    0x2cca(%rip),%rax
mov    0x2cdb(%rip),%rcx
mov    (%rcx),%ecx
or     (%rax),%ecx
mov    0x2ca0(%rip),%rax
or     (%rax),%ecx
mov    0x2ca7(%rip),%rax
or     (%rax),%ecx
mov    0x2d06(%rip),%rax
or     (%rax),%ecx
mov    0x2cd5(%rip),%rax
or     (%rax),%ecx
mov    0x2cd4(%rip),%rax
or     (%rax),%ecx
mov    0x2cb3(%rip),%rax
or     (%rax),%ecx
mov    0x2d12(%rip),%rax
or     (%rax),%ecx
mov    %ecx,0xc(%rsp)
mov    (%r12),%esi
mov    0x2cc1(%rip),%rax
mov    (%rax),%edx
lea    0xc(%rsp),%rcx
mov    %ebx,%edi
mov    $0x4,%r8d
call   1040 <setsockopt@plt>
test   %rax,%rax
js     141c <SocketOpen+0x2ac>
imul   $0x160,%r15d,%eax
mov    %eax,0x4(%rsp)
imul   $0x160,%r14d,%eax
mov    %eax,0x1c(%rsp)
mov    0x0(%rbp),%esi
mov    0x2cb4(%rip),%rax
mov    (%rax),%edx
lea    0x4(%rsp),%rcx
mov    %ebx,%edi
mov    $0x4,%r8d
call   1040 <setsockopt@plt>
test   %rax,%rax
js     142f <SocketOpen+0x2bf>
mov    0x0(%rbp),%esi
mov    0x2c55(%rip),%rax
mov    (%rax),%edx
lea    0x1c(%rsp),%rcx
mov    %ebx,%edi
mov    $0x4,%r8d
call   1040 <setsockopt@plt>
test   %rax,%rax
js     1442 <SocketOpen+0x2d2>
movl   $0x1,0x8(%rsp)
mov    0x0(%rbp),%esi
mov    0x2c4e(%rip),%rax
mov    (%rax),%edx
lea    0x8(%rsp),%rcx
mov    %ebx,%edi
mov    $0x4,%r8d
call   1040 <setsockopt@plt>
test   %rax,%rax
js     1455 <SocketOpen+0x2e5>
lea    0x20(%rsp),%rbp
mov    %rbp,%rdi
xor    %esi,%esi
mov    $0x10,%edx
call   1050 <memset@plt>
mov    0x2c56(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x28(%rsp)
mov    0x30(%rsp),%rax
mov    %rax,0x20(%rsp)
mov    %ebx,%edi
mov    %rbp,%rsi
mov    $0x10,%edx
call   1070 <bind@plt>
mov    0x2bb0(%rip),%rcx
imul   $0xfff0bdc0,(%rcx),%ecx
test   %rax,%rax
cmove  %ebx,%ecx
jmp    13e7 <SocketOpen+0x277>
mov    0x2b9b(%rip),%rax
imul   $0xffffff9c,(%rax),%ecx
jmp    13e7 <SocketOpen+0x277>
mov    0x2b8f(%rip),%rax
imul   $0xffffd8f0,(%rax),%ecx
mov    %ecx,%eax
add    $0x40,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xc03(%rip),%rdi
call   1080 <perror@plt>
mov    $0xfffffff7,%ecx
jmp    13e7 <SocketOpen+0x277>
lea    0xc0b(%rip),%rdi
call   1080 <perror@plt>
mov    $0xfffffff6,%ecx
jmp    13e7 <SocketOpen+0x277>
lea    0xc10(%rip),%rdi
call   1080 <perror@plt>
mov    $0xfffffff5,%ecx
jmp    13e7 <SocketOpen+0x277>
lea    0xc1b(%rip),%rdi
call   1080 <perror@plt>
mov    $0xfffffff4,%ecx
jmp    13e7 <SocketOpen+0x277>
lea    0xc1d(%rip),%rdi
call   1080 <perror@plt>
mov    $0xfffffff3,%ecx
jmp    13e7 <SocketOpen+0x277>
lea    0xc1f(%rip),%rdi
call   1080 <perror@plt>
mov    $0xfffffff2,%ecx
jmp    13e7 <SocketOpen+0x277>

LLVM IR (-O0):
%struct.ifreq = type { i64, i32 }
%struct.sockaddr_can = type { i64, i32 }
%struct.sockaddr = type { i32 }
@PF_CAN = global i32 0
@SOCK_RAW = global i32 0
@CAN_RAW = global i32 0
@errno = global i32 0
@SIOCGIFINDEX = global i32 0
@SOL_CAN_RAW = global i32 0
@CAN_RAW_RECV_OWN_MSGS = global i32 0
@SOL_SOCKET = global i32 0
@SO_TIMESTAMPING = global i32 0
@.str = [27 x i8] c"setsockopt SO_TIMESTAMPING\00"
@SO_TIMESTAMP = global i32 0
@.str.1 = [24 x i8] c"setsockopt SO_TIMESTAMP\00"
@CAN_ERR_TX_TIMEOUT = global i32 0
@CAN_ERR_LOSTARB = global i32 0
@CAN_ERR_CRTL = global i32 0
@CAN_ERR_PROT = global i32 0
@CAN_ERR_TRX = global i32 0
@CAN_ERR_ACK = global i32 0
@CAN_ERR_BUSOFF = global i32 0
@CAN_ERR_BUSERROR = global i32 0
@CAN_ERR_RESTARTED = global i32 0
@CAN_RAW_ERR_FILTER = global i32 0
@.str.2 = [30 x i8] c"setsockopt CAN_RAW_ERR_FILTER\00"
@SO_SNDBUF = global i32 0
@.str.3 = [21 x i8] c"setsockopt SO_SNDBUF\00"
@SO_RCVBUF = global i32 0
@.str.4 = [21 x i8] c"setsockopt SO_RCVBUF\00"
@SO_RXQ_OVFL = global i32 0
@.str.5 = [23 x i8] c"setsockopt SO_RXQ_OVFL\00"
@AF_CAN = global i32 0
define i32 @SocketOpen(i8* %0, i32 %1, i32 %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca %struct.ifreq
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
%16 = alloca i32
%17 = alloca %struct.sockaddr_can
%18 = alloca i32
store i8* %0, i8** %5
store i32 %1, i32* %6
store i32 %2, i32* %7
%19 = load i32, i32* @PF_CAN
%20 = load i32, i32* @SOCK_RAW
%21 = load i32, i32* @CAN_RAW
%22 = call i32 @socket(i32 %19, i32 %20, i32 %21)
store i32 %22, i32* %8
%23 = load i32, i32* %8
%24 = icmp slt i32 %23, 0
br i1 %24, label %25, label %29
25: ; preds = %3
%26 = load i32, i32* @errno
store i32 %26, i32* %9
%27 = load i32, i32* %9
%28 = mul nsw i32 -100, %27
store i32 %28, i32* %4
br label %134
29: ; preds = %3
%30 = getelementptr inbounds %struct.ifreq, %struct.ifreq* %10, i32 0, i32 1
%31 = load i32, i32* %30
%32 = load i8*, i8** %5
%33 = call i32 @strcpy(i32 %31, i8* %32)
%34 = load i32, i32* %8
%35 = load i32, i32* @SIOCGIFINDEX
%36 = call i32 @ioctl(i32 %34, i32 %35, %struct.ifreq* %10)
%37 = getelementptr inbounds %struct.ifreq, %struct.ifreq* %10, i32 0, i32 0
%38 = load i64, i64* %37
%39 = icmp slt i64 %38, 0
br i1 %39, label %40, label %44
40: ; preds = %29
%41 = load i32, i32* @errno
store i32 %41, i32* %11
%42 = load i32, i32* %11
%43 = mul nsw i32 -10000, %42
store i32 %43, i32* %4
br label %134
44: ; preds = %29
store i32 1, i32* %12
%45 = load i32, i32* %8
%46 = load i32, i32* @SOL_CAN_RAW
%47 = load i32, i32* @CAN_RAW_RECV_OWN_MSGS
%48 = call i64 @setsockopt(i32 %45, i32 %46, i32 %47, i32* %12, i32 4)
store i32 1, i32* %13
%49 = load i32, i32* %8
%50 = load i32, i32* @SOL_SOCKET
%51 = load i32, i32* @SO_TIMESTAMPING
%52 = call i64 @setsockopt(i32 %49, i32 %50, i32 %51, i32* %13, i32 4)
%53 = icmp slt i64 %52, 0
br i1 %53, label %54, label %56
54: ; preds = %44
%55 = call i32 @perror(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0))
store i32 -9, i32* %4
br label %134
56: ; preds = %44
store i32 1, i32* %14
%57 = load i32, i32* %8
%58 = load i32, i32* @SOL_SOCKET
%59 = load i32, i32* @SO_TIMESTAMP
%60 = call i64 @setsockopt(i32 %57, i32 %58, i32 %59, i32* %14, i32 4)
%61 = icmp slt i64 %60, 0
br i1 %61, label %62, label %64
62: ; preds = %56
%63 = call i32 @perror(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0))
store i32 -10, i32* %4
br label %134
64: ; preds = %56
%65 = load i32, i32* @CAN_ERR_TX_TIMEOUT
%66 = load i32, i32* @CAN_ERR_LOSTARB
%67 = or i32 %65, %66
%68 = load i32, i32* @CAN_ERR_CRTL
%69 = or i32 %67, %68
%70 = load i32, i32* @CAN_ERR_PROT
%71 = or i32 %69, %70
%72 = load i32, i32* @CAN_ERR_TRX
%73 = or i32 %71, %72
%74 = load i32, i32* @CAN_ERR_ACK
%75 = or i32 %73, %74
%76 = load i32, i32* @CAN_ERR_BUSOFF
%77 = or i32 %75, %76
%78 = load i32, i32* @CAN_ERR_BUSERROR
%79 = or i32 %77, %78
%80 = load i32, i32* @CAN_ERR_RESTARTED
%81 = or i32 %79, %80
store i32 %81, i32* %15
%82 = load i32, i32* %8
%83 = load i32, i32* @SOL_CAN_RAW
%84 = load i32, i32* @CAN_RAW_ERR_FILTER
%85 = call i64 @setsockopt(i32 %82, i32 %83, i32 %84, i32* %15, i32 4)
%86 = icmp slt i64 %85, 0
br i1 %86, label %87, label %89
87: ; preds = %64
%88 = call i32 @perror(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.2, i64 0, i64 0))
store i32 -11, i32* %4
br label %134
89: ; preds = %64
%90 = load i32, i32* %6
%91 = mul nsw i32 352, %90
store i32 %91, i32* %6
%92 = load i32, i32* %7
%93 = mul nsw i32 352, %92
store i32 %93, i32* %7
%94 = load i32, i32* %8
%95 = load i32, i32* @SOL_SOCKET
%96 = load i32, i32* @SO_SNDBUF
%97 = call i64 @setsockopt(i32 %94, i32 %95, i32 %96, i32* %6, i32 4)
%98 = icmp slt i64 %97, 0
br i1 %98, label %99, label %101
99: ; preds = %89
%100 = call i32 @perror(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0))
store i32 -12, i32* %4
br label %134
101: ; preds = %89
%102 = load i32, i32* %8
%103 = load i32, i32* @SOL_SOCKET
%104 = load i32, i32* @SO_RCVBUF
%105 = call i64 @setsockopt(i32 %102, i32 %103, i32 %104, i32* %7, i32 4)
%106 = icmp slt i64 %105, 0
br i1 %106, label %107, label %109
107: ; preds = %101
%108 = call i32 @perror(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.4, i64 0, i64 0))
store i32 -13, i32* %4
br label %134
109: ; preds = %101
store i32 1, i32* %16
%110 = load i32, i32* %8
%111 = load i32, i32* @SOL_SOCKET
%112 = load i32, i32* @SO_RXQ_OVFL
%113 = call i64 @setsockopt(i32 %110, i32 %111, i32 %112, i32* %16, i32 4)
%114 = icmp slt i64 %113, 0
br i1 %114, label %115, label %117
115: ; preds = %109
%116 = call i32 @perror(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.5, i64 0, i64 0))
store i32 -14, i32* %4
br label %134
117: ; preds = %109
%118 = call i32 @memset(%struct.sockaddr_can* %17, i32 0, i32 16)
%119 = load i32, i32* @AF_CAN
%120 = getelementptr inbounds %struct.sockaddr_can, %struct.sockaddr_can* %17, i32 0, i32 1
store i32 %119, i32* %120
%121 = getelementptr inbounds %struct.ifreq, %struct.ifreq* %10, i32 0, i32 0
%122 = load i64, i64* %121
%123 = getelementptr inbounds %struct.sockaddr_can, %struct.sockaddr_can* %17, i32 0, i32 0
store i64 %122, i64* %123
%124 = load i32, i32* %8
%125 = bitcast %struct.sockaddr_can* %17 to %struct.sockaddr*
%126 = call i64 @bind(i32 %124, %struct.sockaddr* %125, i32 16)
%127 = icmp ne i64 %126, 0
br i1 %127, label %128, label %132
128: ; preds = %117
%129 = load i32, i32* @errno
store i32 %129, i32* %18
%130 = load i32, i32* %18
%131 = mul nsw i32 -1000000, %130
store i32 %131, i32* %4
br label %134
132: ; preds = %117
%133 = load i32, i32* %8
store i32 %133, i32* %4
br label %134
134: ; preds = %132, %128, %115, %107, %99, %87, %62, %54, %40, %25
%135 = load i32, i32* %4
ret i32 %135
}

LLVM IR (-O2):
%struct.ifreq = type { i64, i32 }
%struct.sockaddr_can = type { i64, i32 }
%struct.sockaddr = type { i32 }
@PF_CAN = global i32 0
@SOCK_RAW = global i32 0
@CAN_RAW = global i32 0
@errno = global i32 0
@SIOCGIFINDEX = global i32 0
@SOL_CAN_RAW = global i32 0
@CAN_RAW_RECV_OWN_MSGS = global i32 0
@SOL_SOCKET = global i32 0
@SO_TIMESTAMPING = global i32 0
@.str = [27 x i8] c"setsockopt SO_TIMESTAMPING\00"
@SO_TIMESTAMP = global i32 0
@.str.1 = [24 x i8] c"setsockopt SO_TIMESTAMP\00"
@CAN_ERR_TX_TIMEOUT = global i32 0
@CAN_ERR_LOSTARB = global i32 0
@CAN_ERR_CRTL = global i32 0
@CAN_ERR_PROT = global i32 0
@CAN_ERR_TRX = global i32 0
@CAN_ERR_ACK = global i32 0
@CAN_ERR_BUSOFF = global i32 0
@CAN_ERR_BUSERROR = global i32 0
@CAN_ERR_RESTARTED = global i32 0
@CAN_RAW_ERR_FILTER = global i32 0
@.str.2 = [30 x i8] c"setsockopt CAN_RAW_ERR_FILTER\00"
@SO_SNDBUF = global i32 0
@.str.3 = [21 x i8] c"setsockopt SO_SNDBUF\00"
@SO_RCVBUF = global i32 0
@.str.4 = [21 x i8] c"setsockopt SO_RCVBUF\00"
@SO_RXQ_OVFL = global i32 0
@.str.5 = [23 x i8] c"setsockopt SO_RXQ_OVFL\00"
@AF_CAN = global i32 0
define i32 @SocketOpen(i8* %0, i32 %1, i32 %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca %struct.ifreq
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca %struct.sockaddr_can
store i32 %1, i32* %4
%13 = load i32, i32* @PF_CAN
%14 = load i32, i32* @SOCK_RAW
%15 = load i32, i32* @CAN_RAW
%16 = tail call i32 @socket(i32 %13, i32 %14, i32 %15)
%17 = icmp slt i32 %16, 0
br i1 %17, label %18, label %21
18: ; preds = %3
%19 = load i32, i32* @errno
%20 = mul nsw i32 %19, -100
br label %124
21: ; preds = %3
%22 = bitcast %struct.ifreq* %6 to i8*
%23 = tail call i32 @strcpy(i32 undef, i8* %0)
%24 = load i32, i32* @SIOCGIFINDEX
%25 = call i32 @ioctl(i32 %16, i32 %24, %struct.ifreq* %6)
%26 = getelementptr inbounds %struct.ifreq, %struct.ifreq* %6, i64 0, i32 0
%27 = load i64, i64* %26
%28 = icmp slt i64 %27, 0
br i1 %28, label %29, label %32
29: ; preds = %21
%30 = load i32, i32* @errno
%31 = mul nsw i32 %30, -10000
br label %122
32: ; preds = %21
%33 = bitcast i32* %7 to i8*
store i32 1, i32* %7
%34 = load i32, i32* @SOL_CAN_RAW
%35 = load i32, i32* @CAN_RAW_RECV_OWN_MSGS
%36 = call i64 @setsockopt(i32 %16, i32 %34, i32 %35, i32* %7, i32 4)
%37 = bitcast i32* %8 to i8*
store i32 1, i32* %8
%38 = load i32, i32* @SOL_SOCKET
%39 = load i32, i32* @SO_TIMESTAMPING
%40 = call i64 @setsockopt(i32 %16, i32 %38, i32 %39, i32* %8, i32 4)
%41 = icmp slt i64 %40, 0
br i1 %41, label %42, label %44
42: ; preds = %32
%43 = call i32 @perror(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0))
br label %120
44: ; preds = %32
%45 = bitcast i32* %9 to i8*
store i32 1, i32* %9
%46 = load i32, i32* @SOL_SOCKET
%47 = load i32, i32* @SO_TIMESTAMP
%48 = call i64 @setsockopt(i32 %16, i32 %46, i32 %47, i32* %9, i32 4)
%49 = icmp slt i64 %48, 0
br i1 %49, label %50, label %52
50: ; preds = %44
%51 = call i32 @perror(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0))
br label %118
52: ; preds = %44
%53 = bitcast i32* %10 to i8*
%54 = load i32, i32* @CAN_ERR_TX_TIMEOUT
%55 = load i32, i32* @CAN_ERR_LOSTARB
%56 = or i32 %55, %54
%57 = load i32, i32* @CAN_ERR_CRTL
%58 = or i32 %56, %57
%59 = load i32, i32* @CAN_ERR_PROT
%60 = or i32 %58, %59
%61 = load i32, i32* @CAN_ERR_TRX
%62 = or i32 %60, %61
%63 = load i32, i32* @CAN_ERR_ACK
%64 = or i32 %62, %63
%65 = load i32, i32* @CAN_ERR_BUSOFF
%66 = or i32 %64, %65
%67 = load i32, i32* @CAN_ERR_BUSERROR
%68 = or i32 %66, %67
%69 = load i32, i32* @CAN_ERR_RESTARTED
%70 = or i32 %68, %69
store i32 %70, i32* %10
%71 = load i32, i32* @SOL_CAN_RAW
%72 = load i32, i32* @CAN_RAW_ERR_FILTER
%73 = call i64 @setsockopt(i32 %16, i32 %71, i32 %72, i32* %10, i32 4)
%74 = icmp slt i64 %73, 0
br i1 %74, label %75, label %77
75: ; preds = %52
%76 = call i32 @perror(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.2, i64 0, i64 0))
br label %116
77: ; preds = %52
%78 = mul nsw i32 %1, 352
store i32 %78, i32* %4
%79 = mul nsw i32 %2, 352
store i32 %79, i32* %5
%80 = load i32, i32* @SOL_SOCKET
%81 = load i32, i32* @SO_SNDBUF
%82 = call i64 @setsockopt(i32 %16, i32 %80, i32 %81, i32* %4, i32 4)
%83 = icmp slt i64 %82, 0
br i1 %83, label %84, label %86
84: ; preds = %77
%85 = call i32 @perror(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0))
br label %116
86: ; preds = %77
%87 = load i32, i32* @SOL_SOCKET
%88 = load i32, i32* @SO_RCVBUF
%89 = call i64 @setsockopt(i32 %16, i32 %87, i32 %88, i32* %5, i32 4)
%90 = icmp slt i64 %89, 0
br i1 %90, label %91, label %93
91: ; preds = %86
%92 = call i32 @perror(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.4, i64 0, i64 0))
br label %116
93: ; preds = %86
%94 = bitcast i32* %11 to i8*
store i32 1, i32* %11
%95 = load i32, i32* @SOL_SOCKET
%96 = load i32, i32* @SO_RXQ_OVFL
%97 = call i64 @setsockopt(i32 %16, i32 %95, i32 %96, i32* %11, i32 4)
%98 = icmp slt i64 %97, 0
br i1 %98, label %99, label %101
99: ; preds = %93
%100 = call i32 @perror(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.5, i64 0, i64 0))
br label %114
101: ; preds = %93
%102 = bitcast %struct.sockaddr_can* %12 to i8*
%103 = call i32 @memset(%struct.sockaddr_can* %12, i32 0, i32 16)
%104 = load i32, i32* @AF_CAN
%105 = getelementptr inbounds %struct.sockaddr_can, %struct.sockaddr_can* %12, i64 0, i32 1
store i32 %104, i32* %105
%106 = load i64, i64* %26
%107 = getelementptr inbounds %struct.sockaddr_can, %struct.sockaddr_can* %12, i64 0, i32 0
store i64 %106, i64* %107
%108 = bitcast %struct.sockaddr_can* %12 to %struct.sockaddr*
%109 = call i64 @bind(i32 %16, %struct.sockaddr* %108, i32 16)
%110 = icmp eq i64 %109, 0
%111 = load i32, i32* @errno
%112 = mul nsw i32 %111, -1000000
%113 = select i1 %110, i32 %16, i32 %112
br label %114
114: ; preds = %101, %99
%115 = phi i32 [ -14, %99 ], [ %113, %101 ]
br label %116
116: ; preds = %114, %91, %84, %75
%117 = phi i32 [ -11, %75 ], [ -12, %84 ], [ -13, %91 ], [ %115, %114 ]
br label %118
118: ; preds = %116, %50
%119 = phi i32 [ -10, %50 ], [ %117, %116 ]
br label %120
120: ; preds = %118, %42
%121 = phi i32 [ -9, %42 ], [ %119, %118 ]
br label %122
122: ; preds = %120, %29
%123 = phi i32 [ %31, %29 ], [ %121, %120 ]
br label %124
124: ; preds = %122, %18
%125 = phi i32 [ %20, %18 ], [ %123, %122 ]
ret i32 %125
}