#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 */

/* Variables and functions */
int get_clickpad_xinput_id();
int /*<<< orphan*/ snprintf(char *, int, char *, int, int);
scalar_t__ strcmp(char const *, char *);
int /*<<< orphan*/ system(char *);
int set_touchpad_xinput_state(const char *state) {
  int sucess = -1;
  int cmd = 1;
  char xinput_cmd[45];
  int id = get_clickpad_xinput_id();
  if (id != -1) {
    if (strcmp(state, "ON") == 0) {
      cmd = 1;
    } else {
      cmd = 0;
    }
    snprintf(xinput_cmd, 45, "xinput set-prop %d 'Device Enabled' %d", id, cmd);
    system(xinput_cmd);
    sucess = 0;
  }
  return sucess;
}


x86 assembly (clang, -O0):
<set_touchpad_xinput_state>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0xffffffff,-0xc(%rbp)
movl   $0x1,-0x10(%rbp)
mov    $0x0,%al
call   1050 <get_clickpad_xinput_id@plt>
mov    %eax,-0x44(%rbp)
cmpl   $0xffffffff,-0x44(%rbp)
je     11c7 <set_touchpad_xinput_state+0x87>
mov    -0x8(%rbp),%rdi
lea    0xe87(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
jne    1194 <set_touchpad_xinput_state+0x54>
movl   $0x1,-0x10(%rbp)
jmp    119b <set_touchpad_xinput_state+0x5b>
movl   $0x0,-0x10(%rbp)
lea    -0x40(%rbp),%rdi
mov    -0x44(%rbp),%ecx
mov    -0x10(%rbp),%r8d
mov    $0x2d,%esi
lea    0xe51(%rip),%rdx
call   1040 <snprintf@plt>
lea    -0x40(%rbp),%rdi
call   1030 <system@plt>
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<set_touchpad_xinput_state>:
push   %rbp
push   %r14
push   %rbx
sub    $0x30,%rsp
mov    %rdi,%rbx
xor    %r14d,%r14d
xor    %eax,%eax
call   1050 <get_clickpad_xinput_id@plt>
cmp    $0xffffffff,%eax
je     1198 <set_touchpad_xinput_state+0x58>
mov    %eax,%ebp
lea    0xe9d(%rip),%rsi
mov    %rbx,%rdi
call   1060 <strcmp@plt>
xor    %r8d,%r8d
test   %rax,%rax
sete   %r8b
lea    0xe87(%rip),%rdx
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    $0x2d,%esi
mov    %ebp,%ecx
call   1040 <snprintf@plt>
mov    %rbx,%rdi
call   1030 <system@plt>
jmp    119e <set_touchpad_xinput_state+0x5e>
mov    $0xffffffff,%r14d
mov    %r14d,%eax
add    $0x30,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"ON\00"
@.str.1 = [39 x i8] c"xinput set-prop %d 'Device Enabled' %d\00"
define i32 @set_touchpad_xinput_state(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i32
%5 = alloca [45 x i8]
%6 = alloca i32
store i8* %0, i8** %2
store i32 -1, i32* %3
store i32 1, i32* %4
%7 = call i32 (...) @get_clickpad_xinput_id()
store i32 %7, i32* %6
%8 = load i32, i32* %6
%9 = icmp ne i32 %8, -1
br i1 %9, label %10, label %23
10: ; preds = %1
%11 = load i8*, i8** %2
%12 = call i64 @strcmp(i8* %11, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%13 = icmp eq i64 %12, 0
br i1 %13, label %14, label %15
14: ; preds = %10
store i32 1, i32* %4
br label %16
15: ; preds = %10
store i32 0, i32* %4
br label %16
16: ; preds = %15, %14
%17 = getelementptr inbounds [45 x i8], [45 x i8]* %5, i64 0, i64 0
%18 = load i32, i32* %6
%19 = load i32, i32* %4
%20 = call i32 @snprintf(i8* %17, i32 45, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.1, i64 0, i64 0), i32 %18, i32 %19)
%21 = getelementptr inbounds [45 x i8], [45 x i8]* %5, i64 0, i64 0
%22 = call i32 @system(i8* %21)
store i32 0, i32* %3
br label %23
23: ; preds = %16, %1
%24 = load i32, i32* %3
ret i32 %24
}

LLVM IR (-O2):
@.str = [3 x i8] c"ON\00"
@.str.1 = [39 x i8] c"xinput set-prop %d 'Device Enabled' %d\00"
define i32 @set_touchpad_xinput_state(i8* %0) {
%2 = alloca [45 x i8]
%3 = getelementptr inbounds [45 x i8], [45 x i8]* %2, i64 0, i64 0
%4 = tail call i32 (...) @get_clickpad_xinput_id()
%5 = icmp eq i32 %4, -1
br i1 %5, label %12, label %6
6: ; preds = %1
%7 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%8 = icmp eq i64 %7, 0
%9 = zext i1 %8 to i32
%10 = call i32 @snprintf(i8* %3, i32 45, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.1, i64 0, i64 0), i32 %4, i32 %9)
%11 = call i32 @system(i8* %3)
br label %12
12: ; preds = %6, %1
%13 = phi i32 [ 0, %6 ], [ -1, %1 ]
ret i32 %13
}