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

/* Variables and functions */
int CS(int);
int T(int);
int /*<<< orphan*/ bzero(struct can_frame *, int);
int /*<<< orphan*/ init_timeout();
int /*<<< orphan*/ socketcan_write(struct can_frame);
void sdo_upload_segment_request(uint8_t node_id, int toggle) {
  struct can_frame frame;
  bzero(&frame, sizeof(frame));
  frame.can_id = 0x600 + node_id;
  frame.can_dlc = 8;
  frame.data[0] = CS(3) | T(toggle);
  socketcan_write(frame);
  init_timeout();
}


x86 assembly (clang, -O0):
<sdo_upload_segment_request>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
lea    -0x28(%rbp),%rdi
mov    $0x18,%esi
call   1070 <bzero@plt>
mov    -0x8(%rbp),%rax
add    $0x600,%rax
mov    %rax,-0x18(%rbp)
movl   $0x8,-0x28(%rbp)
mov    $0x3,%edi
call   1050 <CS@plt>
mov    %eax,-0x2c(%rbp)
mov    -0xc(%rbp),%edi
call   1030 <T@plt>
mov    -0x2c(%rbp),%ecx
or     %eax,%ecx
mov    -0x20(%rbp),%rax
mov    %ecx,(%rax)
lea    -0x28(%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   1040 <socketcan_write@plt>
mov    $0x0,%al
call   1060 <init_timeout@plt>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sdo_upload_segment_request>:
push   %rbp
push   %rbx
sub    $0x38,%rsp
mov    %esi,%ebp
mov    %rdi,%rbx
lea    0x20(%rsp),%rdi
mov    $0x18,%esi
call   1070 <bzero@plt>
add    $0x600,%rbx
mov    %rbx,0x30(%rsp)
movl   $0x8,0x20(%rsp)
mov    $0x3,%edi
call   1050 <CS@plt>
mov    %eax,%ebx
mov    %ebp,%edi
call   1030 <T@plt>
or     %ebx,%eax
mov    0x28(%rsp),%rcx
mov    %eax,(%rcx)
mov    0x30(%rsp),%rax
mov    %rax,0x10(%rsp)
movups 0x20(%rsp),%xmm0
movups %xmm0,(%rsp)
call   1040 <socketcan_write@plt>
xor    %eax,%eax
add    $0x38,%rsp
pop    %rbx
pop    %rbp
jmp    1060 <init_timeout@plt>

LLVM IR (-O0):
%struct.can_frame = type { i32, i32*, i64 }
define void @sdo_upload_segment_request(i64 %0, i32 %1) {
%3 = alloca i64
%4 = alloca i32
%5 = alloca %struct.can_frame
store i64 %0, i64* %3
store i32 %1, i32* %4
%6 = call i32 @bzero(%struct.can_frame* %5, i32 24)
%7 = load i64, i64* %3
%8 = add nsw i64 1536, %7
%9 = getelementptr inbounds %struct.can_frame, %struct.can_frame* %5, i32 0, i32 2
store i64 %8, i64* %9
%10 = getelementptr inbounds %struct.can_frame, %struct.can_frame* %5, i32 0, i32 0
store i32 8, i32* %10
%11 = call i32 @CS(i32 3)
%12 = load i32, i32* %4
%13 = call i32 @T(i32 %12)
%14 = or i32 %11, %13
%15 = getelementptr inbounds %struct.can_frame, %struct.can_frame* %5, i32 0, i32 1
%16 = load i32*, i32** %15
%17 = getelementptr inbounds i32, i32* %16, i64 0
store i32 %14, i32* %17
%18 = call i32 @socketcan_write(%struct.can_frame* byval(%struct.can_frame) align 8 %5)
%19 = call i32 (...) @init_timeout()
ret void
}

LLVM IR (-O2):
%struct.can_frame = type { i32, i32*, i64 }
define void @sdo_upload_segment_request(i64 %0, i32 %1) {
%3 = alloca %struct.can_frame
%4 = bitcast %struct.can_frame* %3 to i8*
%5 = call i32 @bzero(%struct.can_frame* %3, i32 24)
%6 = add nsw i64 %0, 1536
%7 = getelementptr inbounds %struct.can_frame, %struct.can_frame* %3, i64 0, i32 2
store i64 %6, i64* %7
%8 = getelementptr inbounds %struct.can_frame, %struct.can_frame* %3, i64 0, i32 0
store i32 8, i32* %8
%9 = tail call i32 @CS(i32 3)
%10 = tail call i32 @T(i32 %1)
%11 = or i32 %10, %9
%12 = getelementptr inbounds %struct.can_frame, %struct.can_frame* %3, i64 0, i32 1
%13 = load i32*, i32** %12
store i32 %11, i32* %13
%14 = tail call i32 @socketcan_write(%struct.can_frame* byval(%struct.can_frame) align 8 %3)
%15 = tail call i32 (...) @init_timeout()
ret void
}