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

/* Variables and functions */
int /*<<< orphan*/ EV_FF;
int write(int, void const *, int);
int ffmemless_play(int effect_id, int device_file, int play) {
  struct input_event event;
  event.type = EV_FF;
  event.code = effect_id;
  event.value = play;
  if (write(device_file, (const void *)&event, sizeof(event)) == -1)
    return -1;
  else
    return 0;
}


x86 assembly (clang, -O0):
<ffmemless_play>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    0x2eb8(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x18(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0x10(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0xc(%rbp),%edi
lea    -0x20(%rbp),%rsi
mov    $0xc,%edx
call   1030 <write@plt>
cmp    $0xffffffff,%eax
jne    115f <ffmemless_play+0x4f>
movl   $0xffffffff,-0x4(%rbp)
jmp    1166 <ffmemless_play+0x56>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ffmemless_play>:
sub    $0x18,%rsp
mov    %esi,%eax
mov    0x2ec3(%rip),%rcx
mov    (%rcx),%ecx
mov    %ecx,0x10(%rsp)
mov    %edi,0x8(%rsp)
mov    %edx,0xc(%rsp)
lea    0x8(%rsp),%rsi
mov    %eax,%edi
mov    $0xc,%edx
call   1030 <write@plt>
xor    %ecx,%ecx
cmp    $0xffffffff,%eax
sete   %cl
neg    %ecx
mov    %ecx,%eax
add    $0x18,%rsp
ret

LLVM IR (-O0):
%struct.input_event = type { i32, i32, i32 }
@EV_FF = global i32 0
define i32 @ffmemless_play(i32 %0, i32 %1, i32 %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca %struct.input_event
store i32 %0, i32* %5
store i32 %1, i32* %6
store i32 %2, i32* %7
%9 = load i32, i32* @EV_FF
%10 = getelementptr inbounds %struct.input_event, %struct.input_event* %8, i32 0, i32 2
store i32 %9, i32* %10
%11 = load i32, i32* %5
%12 = getelementptr inbounds %struct.input_event, %struct.input_event* %8, i32 0, i32 0
store i32 %11, i32* %12
%13 = load i32, i32* %7
%14 = getelementptr inbounds %struct.input_event, %struct.input_event* %8, i32 0, i32 1
store i32 %13, i32* %14
%15 = load i32, i32* %6
%16 = bitcast %struct.input_event* %8 to i8*
%17 = call i32 @write(i32 %15, i8* %16, i32 12)
%18 = icmp eq i32 %17, -1
br i1 %18, label %19, label %20
19: ; preds = %3
store i32 -1, i32* %4
br label %21
20: ; preds = %3
store i32 0, i32* %4
br label %21
21: ; preds = %20, %19
%22 = load i32, i32* %4
ret i32 %22
}

LLVM IR (-O2):
%struct.input_event = type { i32, i32, i32 }
@EV_FF = global i32 0
define i32 @ffmemless_play(i32 %0, i32 %1, i32 %2) {
%4 = alloca %struct.input_event
%5 = bitcast %struct.input_event* %4 to i8*
%6 = load i32, i32* @EV_FF
%7 = getelementptr inbounds %struct.input_event, %struct.input_event* %4, i64 0, i32 2
store i32 %6, i32* %7
%8 = getelementptr inbounds %struct.input_event, %struct.input_event* %4, i64 0, i32 0
store i32 %0, i32* %8
%9 = getelementptr inbounds %struct.input_event, %struct.input_event* %4, i64 0, i32 1
store i32 %2, i32* %9
%10 = call i32 @write(i32 %1, i8* %5, i32 12)
%11 = icmp eq i32 %10, -1
%12 = sext i1 %11 to i32
ret i32 %12
}