#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 void *uint8_t;
typedef int uint32_t;
typedef int uint16_t;
struct can_frame {
  int can_dlc;
  int *data;
  void *can_id;
};
typedef int /*<<< orphan*/ frame;

/* Variables and functions */
int CS(int);
int /*<<< orphan*/ bzero(struct can_frame *, int);
int /*<<< orphan*/ init_timeout();
int /*<<< orphan*/ socketcan_write(struct can_frame);
void sdo_abort_transfer(uint8_t node_id, uint16_t index, uint8_t subindex,
                        uint32_t abort_code) {
  struct can_frame frame;
  bzero(&frame, sizeof(frame));
  frame.can_id = 0x600 + node_id;
  frame.can_dlc = 8;
  frame.data[0] = CS(4);
  frame.data[1] = index >> 8 & 0xFF;
  frame.data[2] = index >> 0 & 0xFF;
  frame.data[3] = subindex;
  frame.data[4] = abort_code >> 0 & 0xFF;
  frame.data[5] = abort_code >> 8 & 0xFF;
  frame.data[6] = abort_code >> 16 & 0xFF;
  frame.data[7] = abort_code >> 24 & 0xFF;
  socketcan_write(frame);
  init_timeout();
}


x86 assembly (clang, -O0):
<sdo_abort_transfer>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
lea    -0x38(%rbp),%rdi
mov    $0x18,%esi
call   1060 <bzero@plt>
mov    -0x8(%rbp),%rax
add    $0x600,%rax
mov    %rax,-0x28(%rbp)
movl   $0x8,-0x38(%rbp)
mov    $0x4,%edi
call   1040 <CS@plt>
mov    %eax,%ecx
mov    -0x30(%rbp),%rax
mov    %ecx,(%rax)
mov    -0xc(%rbp),%ecx
sar    $0x8,%ecx
and    $0xff,%ecx
mov    -0x30(%rbp),%rax
mov    %ecx,0x4(%rax)
mov    -0xc(%rbp),%ecx
sar    $0x0,%ecx
and    $0xff,%ecx
mov    -0x30(%rbp),%rax
mov    %ecx,0x8(%rax)
mov    -0x18(%rbp),%rax
mov    %eax,%ecx
mov    -0x30(%rbp),%rax
mov    %ecx,0xc(%rax)
mov    -0x1c(%rbp),%ecx
sar    $0x0,%ecx
and    $0xff,%ecx
mov    -0x30(%rbp),%rax
mov    %ecx,0x10(%rax)
mov    -0x1c(%rbp),%ecx
sar    $0x8,%ecx
and    $0xff,%ecx
mov    -0x30(%rbp),%rax
mov    %ecx,0x14(%rax)
mov    -0x1c(%rbp),%ecx
sar    $0x10,%ecx
and    $0xff,%ecx
mov    -0x30(%rbp),%rax
mov    %ecx,0x18(%rax)
mov    -0x1c(%rbp),%ecx
sar    $0x18,%ecx
and    $0xff,%ecx
mov    -0x30(%rbp),%rax
mov    %ecx,0x1c(%rax)
lea    -0x38(%rbp),%rax
mov    (%rax),%rcx
mov    %rcx,(%rsp)
mov    0x8(%rax),%rcx
mov    %rcx,0x8(%rsp)
mov    0x10(%rax),%rax
mov    %rax,0x10(%rsp)
call   1030 <socketcan_write@plt>
mov    $0x0,%al
call   1050 <init_timeout@plt>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sdo_abort_transfer>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x38,%rsp
mov    %ecx,%r15d
mov    %rdx,%r14
mov    %esi,%ebp
mov    %rdi,%rbx
lea    0x20(%rsp),%rdi
mov    $0x18,%esi
call   1060 <bzero@plt>
add    $0x600,%rbx
mov    %rbx,0x30(%rsp)
movl   $0x8,0x20(%rsp)
mov    $0x4,%edi
call   1040 <CS@plt>
mov    0x28(%rsp),%rcx
mov    %eax,(%rcx)
mov    %ebp,%edx
movzbl %dh,%eax
mov    %eax,0x4(%rcx)
movzbl %dl,%eax
mov    %eax,0x8(%rcx)
mov    %r14d,0xc(%rcx)
mov    %r15d,%edx
movzbl %dl,%eax
mov    %eax,0x10(%rcx)
movzbl %dh,%eax
mov    %eax,0x14(%rcx)
mov    %r15d,%eax
shr    $0x10,%eax
movzbl %al,%eax
mov    %eax,0x18(%rcx)
shr    $0x18,%edx
mov    %edx,0x1c(%rcx)
mov    0x30(%rsp),%rax
mov    %rax,0x10(%rsp)
movups 0x20(%rsp),%xmm0
movups %xmm0,(%rsp)
call   1030 <socketcan_write@plt>
xor    %eax,%eax
add    $0x38,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1050 <init_timeout@plt>

LLVM IR (-O0):
%struct.can_frame = type { i32, i32*, i8* }
define void @sdo_abort_transfer(i8* %0, i32 %1, i8* %2, i32 %3) {
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i32
%9 = alloca %struct.can_frame
store i8* %0, i8** %5
store i32 %1, i32* %6
store i8* %2, i8** %7
store i32 %3, i32* %8
%10 = call i32 @bzero(%struct.can_frame* %9, i32 24)
%11 = load i8*, i8** %5
%12 = getelementptr i8, i8* %11, i64 1536
%13 = getelementptr inbounds %struct.can_frame, %struct.can_frame* %9, i32 0, i32 2
store i8* %12, i8** %13
%14 = getelementptr inbounds %struct.can_frame, %struct.can_frame* %9, i32 0, i32 0
store i32 8, i32* %14
%15 = call i32 @CS(i32 4)
%16 = getelementptr inbounds %struct.can_frame, %struct.can_frame* %9, i32 0, i32 1
%17 = load i32*, i32** %16
%18 = getelementptr inbounds i32, i32* %17, i64 0
store i32 %15, i32* %18
%19 = load i32, i32* %6
%20 = ashr i32 %19, 8
%21 = and i32 %20, 255
%22 = getelementptr inbounds %struct.can_frame, %struct.can_frame* %9, i32 0, i32 1
%23 = load i32*, i32** %22
%24 = getelementptr inbounds i32, i32* %23, i64 1
store i32 %21, i32* %24
%25 = load i32, i32* %6
%26 = ashr i32 %25, 0
%27 = and i32 %26, 255
%28 = getelementptr inbounds %struct.can_frame, %struct.can_frame* %9, i32 0, i32 1
%29 = load i32*, i32** %28
%30 = getelementptr inbounds i32, i32* %29, i64 2
store i32 %27, i32* %30
%31 = load i8*, i8** %7
%32 = ptrtoint i8* %31 to i32
%33 = getelementptr inbounds %struct.can_frame, %struct.can_frame* %9, i32 0, i32 1
%34 = load i32*, i32** %33
%35 = getelementptr inbounds i32, i32* %34, i64 3
store i32 %32, i32* %35
%36 = load i32, i32* %8
%37 = ashr i32 %36, 0
%38 = and i32 %37, 255
%39 = getelementptr inbounds %struct.can_frame, %struct.can_frame* %9, i32 0, i32 1
%40 = load i32*, i32** %39
%41 = getelementptr inbounds i32, i32* %40, i64 4
store i32 %38, i32* %41
%42 = load i32, i32* %8
%43 = ashr i32 %42, 8
%44 = and i32 %43, 255
%45 = getelementptr inbounds %struct.can_frame, %struct.can_frame* %9, i32 0, i32 1
%46 = load i32*, i32** %45
%47 = getelementptr inbounds i32, i32* %46, i64 5
store i32 %44, i32* %47
%48 = load i32, i32* %8
%49 = ashr i32 %48, 16
%50 = and i32 %49, 255
%51 = getelementptr inbounds %struct.can_frame, %struct.can_frame* %9, i32 0, i32 1
%52 = load i32*, i32** %51
%53 = getelementptr inbounds i32, i32* %52, i64 6
store i32 %50, i32* %53
%54 = load i32, i32* %8
%55 = ashr i32 %54, 24
%56 = and i32 %55, 255
%57 = getelementptr inbounds %struct.can_frame, %struct.can_frame* %9, i32 0, i32 1
%58 = load i32*, i32** %57
%59 = getelementptr inbounds i32, i32* %58, i64 7
store i32 %56, i32* %59
%60 = call i32 @socketcan_write(%struct.can_frame* byval(%struct.can_frame) align 8 %9)
%61 = call i32 (...) @init_timeout()
ret void
}

LLVM IR (-O2):
%struct.can_frame = type { i32, i32*, i8* }
define void @sdo_abort_transfer(i8* %0, i32 %1, i8* %2, i32 %3) {
%5 = alloca %struct.can_frame
%6 = bitcast %struct.can_frame* %5 to i8*
%7 = call i32 @bzero(%struct.can_frame* %5, i32 24)
%8 = getelementptr i8, i8* %0, i64 1536
%9 = getelementptr inbounds %struct.can_frame, %struct.can_frame* %5, i64 0, i32 2
store i8* %8, i8** %9
%10 = getelementptr inbounds %struct.can_frame, %struct.can_frame* %5, i64 0, i32 0
store i32 8, i32* %10
%11 = tail call i32 @CS(i32 4)
%12 = getelementptr inbounds %struct.can_frame, %struct.can_frame* %5, i64 0, i32 1
%13 = load i32*, i32** %12
store i32 %11, i32* %13
%14 = lshr i32 %1, 8
%15 = and i32 %14, 255
%16 = getelementptr inbounds i32, i32* %13, i64 1
store i32 %15, i32* %16
%17 = and i32 %1, 255
%18 = getelementptr inbounds i32, i32* %13, i64 2
store i32 %17, i32* %18
%19 = ptrtoint i8* %2 to i64
%20 = trunc i64 %19 to i32
%21 = getelementptr inbounds i32, i32* %13, i64 3
store i32 %20, i32* %21
%22 = and i32 %3, 255
%23 = getelementptr inbounds i32, i32* %13, i64 4
store i32 %22, i32* %23
%24 = lshr i32 %3, 8
%25 = and i32 %24, 255
%26 = getelementptr inbounds i32, i32* %13, i64 5
store i32 %25, i32* %26
%27 = lshr i32 %3, 16
%28 = and i32 %27, 255
%29 = getelementptr inbounds i32, i32* %13, i64 6
store i32 %28, i32* %29
%30 = lshr i32 %3, 24
%31 = getelementptr inbounds i32, i32* %13, i64 7
store i32 %30, i32* %31
%32 = tail call i32 @socketcan_write(%struct.can_frame* byval(%struct.can_frame) align 8 %5)
%33 = tail call i32 (...) @init_timeout()
ret void
}