#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__ pid_t;

/* Variables and functions */
int execl(char *, char *, char *, char *, char *, char *, char const *, char *);
int /*<<< orphan*/ perror(char *);
scalar_t__ vfork();
void control_mouse(int enable) {
  const char *flag = enable ? "1" : "0";
  pid_t pID = vfork();
  if (0 == pID) {
    int ret = execl("/usr/bin/xinput", "/usr/bin/xinput", "set-int-prop", "12",
                    "Device Enabled", "8", flag, (char *)0);
    if (-1 == ret) {
      perror("error executing xinput!");
    }
  } else if (pID < 0) {
    perror("error forking to xinput!!!");
  }
}


x86 assembly (clang, -O0):
<control_mouse>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%edx
lea    0xebd(%rip),%rax
lea    0xeb4(%rip),%rcx
cmp    $0x0,%edx
cmovne %rcx,%rax
mov    %rax,-0x10(%rbp)
mov    $0x0,%al
call   1040 <vfork@plt>
mov    %rax,-0x18(%rbp)
xor    %eax,%eax
cmp    -0x18(%rbp),%rax
jne    11ce <control_mouse+0x9e>
mov    -0x10(%rbp),%rax
lea    0xe8b(%rip),%rsi
lea    0xe94(%rip),%rdx
lea    0xe9a(%rip),%rcx
lea    0xe96(%rip),%r8
lea    0xe9e(%rip),%r9
xor    %edi,%edi
mov    %rsi,%rdi
mov    %rax,(%rsp)
movq   $0x0,0x8(%rsp)
call   1050 <execl@plt>
mov    %eax,-0x1c(%rbp)
mov    $0xffffffff,%eax
cmp    -0x1c(%rbp),%eax
jne    11c9 <control_mouse+0x99>
lea    0xe71(%rip),%rdi
call   1030 <perror@plt>
jmp    11ea <control_mouse+0xba>
cmpq   $0x0,-0x18(%rbp)
jge    11e5 <control_mouse+0xb5>
lea    0xe6d(%rip),%rdi
call   1030 <perror@plt>
jmp    11ea <control_mouse+0xba>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<control_mouse>:
push   %rbx
mov    %edi,%ebx
xor    %eax,%eax
call   1040 <vfork@plt>
test   %rax,%rax
je     114e <control_mouse+0x1e>
jns    1199 <control_mouse+0x69>
lea    0xf05(%rip),%rdi
pop    %rbx
jmp    1030 <perror@plt>
test   %ebx,%ebx
lea    0xeab(%rip),%rax
lea    0xea2(%rip),%rbx
cmove  %rax,%rbx
lea    0xe9b(%rip),%rdi
lea    0xea4(%rip),%rdx
lea    0xeaa(%rip),%rcx
lea    0xea6(%rip),%r8
lea    0xeae(%rip),%r9
mov    %rdi,%rsi
push   $0x0
push   %rbx
call   1050 <execl@plt>
add    $0x10,%rsp
cmp    $0xffffffff,%eax
je     119b <control_mouse+0x6b>
pop    %rbx
ret
lea    0xe93(%rip),%rdi
pop    %rbx
jmp    1030 <perror@plt>

LLVM IR (-O0):
@.str = [2 x i8] c"1\00"
@.str.1 = [2 x i8] c"0\00"
@.str.2 = [16 x i8] c"/usr/bin/xinput\00"
@.str.3 = [13 x i8] c"set-int-prop\00"
@.str.4 = [3 x i8] c"12\00"
@.str.5 = [15 x i8] c"Device Enabled\00"
@.str.6 = [2 x i8] c"8\00"
@.str.7 = [24 x i8] c"error executing xinput!\00"
@.str.8 = [27 x i8] c"error forking to xinput!!!\00"
define void @control_mouse(i32 %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i64
%5 = alloca i32
store i32 %0, i32* %2
%6 = load i32, i32* %2
%7 = icmp ne i32 %6, 0
%8 = zext i1 %7 to i64
%9 = select i1 %7, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0)
store i8* %9, i8** %3
%10 = call i64 (...) @vfork()
store i64 %10, i64* %4
%11 = load i64, i64* %4
%12 = icmp eq i64 0, %11
br i1 %12, label %13, label %21
13: ; preds = %1
%14 = load i8*, i8** %3
%15 = call i32 @execl(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0), i8* %14, i8* null)
store i32 %15, i32* %5
%16 = load i32, i32* %5
%17 = icmp eq i32 -1, %16
br i1 %17, label %18, label %20
18: ; preds = %13
%19 = call i32 @perror(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.7, i64 0, i64 0))
br label %20
20: ; preds = %18, %13
br label %27
21: ; preds = %1
%22 = load i64, i64* %4
%23 = icmp slt i64 %22, 0
br i1 %23, label %24, label %26
24: ; preds = %21
%25 = call i32 @perror(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.8, i64 0, i64 0))
br label %26
26: ; preds = %24, %21
br label %27
27: ; preds = %26, %20
ret void
}

LLVM IR (-O2):
@.str = [2 x i8] c"1\00"
@.str.1 = [2 x i8] c"0\00"
@.str.2 = [16 x i8] c"/usr/bin/xinput\00"
@.str.3 = [13 x i8] c"set-int-prop\00"
@.str.4 = [3 x i8] c"12\00"
@.str.5 = [15 x i8] c"Device Enabled\00"
@.str.6 = [2 x i8] c"8\00"
@.str.7 = [24 x i8] c"error executing xinput!\00"
@.str.8 = [27 x i8] c"error forking to xinput!!!\00"
define void @control_mouse(i32 %0) {
%2 = tail call i64 (...) @vfork()
%3 = icmp eq i64 %2, 0
br i1 %3, label %4, label %9
4: ; preds = %1
%5 = icmp eq i32 %0, 0
%6 = select i1 %5, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0)
%7 = tail call i32 @execl(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0), i8* %6, i8* null)
%8 = icmp eq i32 %7, -1
br i1 %8, label %11, label %14
9: ; preds = %1
%10 = icmp slt i64 %2, 0
br i1 %10, label %11, label %14
11: ; preds = %9, %4
%12 = phi i8* [ getelementptr inbounds ([24 x i8], [24 x i8]* @.str.7, i64 0, i64 0), %4 ], [ getelementptr inbounds ([27 x i8], [27 x i8]* @.str.8, i64 0, i64 0), %9 ]
%13 = tail call i32 @perror(i8* %12)
br label %14
14: ; preds = %11, %4, %9
ret void
}