#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 input_event {
  int /*<<< orphan*/ value;
  void *code;
  void *type;
};
typedef int /*<<< orphan*/ event;
typedef void *__u16;
typedef int /*<<< orphan*/ __s32;

/* Variables and functions */
int /*<<< orphan*/ memset(struct input_event *, int /*<<< orphan*/, int);
int /*<<< orphan*/ warn(char *);
int write(int, struct input_event *, int);
int send_event(int ufile, __u16 type, __u16 code, __s32 value) {
  struct input_event event;
  memset(&event, 0, sizeof(event));
  event.type = type;
  event.code = code;
  event.value = value;
  if (write(ufile, &event, sizeof(event)) != sizeof(event)) {
    warn("Error during event sending");
    return -1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<send_event>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
lea    -0x38(%rbp),%rdi
xor    %esi,%esi
mov    $0x18,%edx
call   1050 <memset@plt>
mov    -0x10(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x1c(%rbp),%eax
mov    %eax,-0x38(%rbp)
mov    -0x8(%rbp),%edi
lea    -0x38(%rbp),%rsi
mov    $0x18,%edx
call   1040 <write@plt>
cltq
cmp    $0x18,%rax
je     11a1 <send_event+0x71>
lea    0xe70(%rip),%rdi
call   1030 <warn@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    11a8 <send_event+0x78>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<send_event>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %ecx,%r14d
mov    %rdx,%rbp
mov    %rsi,%rbx
mov    %edi,%r12d
mov    %rsp,%r13
xor    %r15d,%r15d
mov    %r13,%rdi
xor    %esi,%esi
mov    $0x18,%edx
call   1050 <memset@plt>
mov    %rbx,0x10(%rsp)
mov    %rbp,0x8(%rsp)
mov    %r14d,(%rsp)
mov    %r12d,%edi
mov    %r13,%rsi
mov    $0x18,%edx
call   1040 <write@plt>
cmp    $0x18,%eax
je     1194 <send_event+0x64>
lea    0xe77(%rip),%rdi
call   1030 <warn@plt>
mov    $0xffffffff,%r15d
mov    %r15d,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.input_event = type { i32, i8*, i8* }
@.str = [27 x i8] c"Error during event sending\00"
define i32 @send_event(i32 %0, i8* %1, i8* %2, i32 %3) {
%5 = alloca i32
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i32
%10 = alloca %struct.input_event
store i32 %0, i32* %6
store i8* %1, i8** %7
store i8* %2, i8** %8
store i32 %3, i32* %9
%11 = call i32 @memset(%struct.input_event* %10, i32 0, i32 24)
%12 = load i8*, i8** %7
%13 = getelementptr inbounds %struct.input_event, %struct.input_event* %10, i32 0, i32 2
store i8* %12, i8** %13
%14 = load i8*, i8** %8
%15 = getelementptr inbounds %struct.input_event, %struct.input_event* %10, i32 0, i32 1
store i8* %14, i8** %15
%16 = load i32, i32* %9
%17 = getelementptr inbounds %struct.input_event, %struct.input_event* %10, i32 0, i32 0
store i32 %16, i32* %17
%18 = load i32, i32* %6
%19 = call i32 @write(i32 %18, %struct.input_event* %10, i32 24)
%20 = sext i32 %19 to i64
%21 = icmp ne i64 %20, 24
br i1 %21, label %22, label %24
22: ; preds = %4
%23 = call i32 @warn(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0))
store i32 -1, i32* %5
br label %25
24: ; preds = %4
store i32 0, i32* %5
br label %25
25: ; preds = %24, %22
%26 = load i32, i32* %5
ret i32 %26
}

LLVM IR (-O2):
%struct.input_event = type { i32, i8*, i8* }
@.str = [27 x i8] c"Error during event sending\00"
define i32 @send_event(i32 %0, i8* %1, i8* %2, i32 %3) {
%5 = alloca %struct.input_event
%6 = bitcast %struct.input_event* %5 to i8*
%7 = call i32 @memset(%struct.input_event* %5, i32 0, i32 24)
%8 = getelementptr inbounds %struct.input_event, %struct.input_event* %5, i64 0, i32 2
store i8* %1, i8** %8
%9 = getelementptr inbounds %struct.input_event, %struct.input_event* %5, i64 0, i32 1
store i8* %2, i8** %9
%10 = getelementptr inbounds %struct.input_event, %struct.input_event* %5, i64 0, i32 0
store i32 %3, i32* %10
%11 = call i32 @write(i32 %0, %struct.input_event* %5, i32 24)
%12 = icmp eq i32 %11, 24
br i1 %12, label %15, label %13
13: ; preds = %4
%14 = call i32 @warn(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0))
br label %15
15: ; preds = %4, %13
%16 = phi i32 [ -1, %13 ], [ 0, %4 ]
ret i32 %16
}