#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 bcm_msg_head {
  int can_id;
  scalar_t__ nframes;
  int /*<<< orphan*/ opcode;
};
typedef int /*<<< orphan*/ msg_head;

/* Variables and functions */
int /*<<< orphan*/ RX_DELETE;
int /*<<< orphan*/ perror(char *);
scalar_t__ write(int, struct bcm_msg_head *, int);
void rx_delete(int fd, int id) {
  struct bcm_msg_head msg_head;
  msg_head.opcode = RX_DELETE;
  msg_head.can_id = id;
  msg_head.nframes = 0;
  if (write(fd, &msg_head, sizeof(msg_head)) < 0)
    perror("write");
}


x86 assembly (clang, -O0):
<rx_delete>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    0x2eab(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0x20(%rbp)
movq   $0x0,-0x18(%rbp)
mov    -0x4(%rbp),%edi
lea    -0x20(%rbp),%rsi
mov    $0x18,%edx
call   1030 <write@plt>
cmp    $0x0,%rax
jge    116f <rx_delete+0x4f>
lea    0xe96(%rip),%rdi
call   1040 <perror@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<rx_delete>:
sub    $0x18,%rsp
mov    0x2eb5(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x10(%rsp)
mov    %esi,(%rsp)
movq   $0x0,0x8(%rsp)
mov    %rsp,%rsi
mov    $0x18,%edx
call   1030 <write@plt>
test   %rax,%rax
js     1154 <rx_delete+0x34>
add    $0x18,%rsp
ret
lea    0xea5(%rip),%rdi
add    $0x18,%rsp
jmp    1040 <perror@plt>

LLVM IR (-O0):
%struct.bcm_msg_head = type { i32, i64, i32 }
@RX_DELETE = global i32 0
@.str = [6 x i8] c"write\00"
define void @rx_delete(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca %struct.bcm_msg_head
store i32 %0, i32* %3
store i32 %1, i32* %4
%6 = load i32, i32* @RX_DELETE
%7 = getelementptr inbounds %struct.bcm_msg_head, %struct.bcm_msg_head* %5, i32 0, i32 2
store i32 %6, i32* %7
%8 = load i32, i32* %4
%9 = getelementptr inbounds %struct.bcm_msg_head, %struct.bcm_msg_head* %5, i32 0, i32 0
store i32 %8, i32* %9
%10 = getelementptr inbounds %struct.bcm_msg_head, %struct.bcm_msg_head* %5, i32 0, i32 1
store i64 0, i64* %10
%11 = load i32, i32* %3
%12 = call i64 @write(i32 %11, %struct.bcm_msg_head* %5, i32 24)
%13 = icmp slt i64 %12, 0
br i1 %13, label %14, label %16
14: ; preds = %2
%15 = call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
br label %16
16: ; preds = %14, %2
ret void
}

LLVM IR (-O2):
%struct.bcm_msg_head = type { i32, i64, i32 }
@RX_DELETE = global i32 0
@.str = [6 x i8] c"write\00"
define void @rx_delete(i32 %0, i32 %1) {
%3 = alloca %struct.bcm_msg_head
%4 = bitcast %struct.bcm_msg_head* %3 to i8*
%5 = load i32, i32* @RX_DELETE
%6 = getelementptr inbounds %struct.bcm_msg_head, %struct.bcm_msg_head* %3, i64 0, i32 2
store i32 %5, i32* %6
%7 = getelementptr inbounds %struct.bcm_msg_head, %struct.bcm_msg_head* %3, i64 0, i32 0
store i32 %1, i32* %7
%8 = getelementptr inbounds %struct.bcm_msg_head, %struct.bcm_msg_head* %3, i64 0, i32 1
store i64 0, i64* %8
%9 = call i64 @write(i32 %0, %struct.bcm_msg_head* %3, i32 24)
%10 = icmp slt i64 %9, 0
br i1 %10, label %11, label %13
11: ; preds = %2
%12 = tail call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
br label %13
13: ; preds = %11, %2
ret void
}