#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 int /*<<< orphan*/ output_buffer;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int atoi(char *);
int /*<<< orphan*/ *fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ pclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *popen(char *, char *);
int strlen(char *);
int get_clickpad_setting() {
  int setting = -1;
  char output_buffer[100];
  FILE *synclient_data = popen("synclient | grep ClickPad", "r");
  if (synclient_data != NULL) {
    if (fgets(output_buffer, sizeof(output_buffer), synclient_data) != NULL) {
      char value[10];
      value[0] = output_buffer[(strlen(output_buffer) - 2)];
      setting = atoi(value);
    }
  }
  pclose(synclient_data);
  return setting;
}


x86 assembly (clang, -O0):
<get_clickpad_setting>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
movl   $0xffffffff,-0x4(%rbp)
lea    0xe97(%rip),%rdi
lea    0xeaa(%rip),%rsi
call   1060 <popen@plt>
mov    %rax,-0x78(%rbp)
cmpq   $0x0,-0x78(%rbp)
je     11cc <get_clickpad_setting+0x7c>
lea    -0x70(%rbp),%rdi
mov    -0x78(%rbp),%rdx
mov    $0x64,%esi
call   1050 <fgets@plt>
cmp    $0x0,%rax
je     11c7 <get_clickpad_setting+0x77>
lea    -0x70(%rbp),%rdi
call   1030 <strlen@plt>
sub    $0x2,%eax
cltq
mov    -0x70(%rbp,%rax,1),%al
mov    %al,-0x82(%rbp)
lea    -0x82(%rbp),%rdi
call   1070 <atoi@plt>
mov    %eax,-0x4(%rbp)
jmp    11cc <get_clickpad_setting+0x7c>
mov    -0x78(%rbp),%rdi
call   1040 <pclose@plt>
mov    -0x4(%rbp),%eax
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_clickpad_setting>:
push   %rbp
push   %r14
push   %rbx
sub    $0x80,%rsp
lea    0xe9e(%rip),%rdi
lea    0xeb1(%rip),%rsi
call   1060 <popen@plt>
mov    %rax,%rbx
mov    $0xffffffff,%ebp
test   %rax,%rax
je     11b4 <get_clickpad_setting+0x64>
lea    0x10(%rsp),%r14
mov    %r14,%rdi
mov    $0x64,%esi
mov    %rbx,%rdx
call   1050 <fgets@plt>
test   %rax,%rax
je     11b4 <get_clickpad_setting+0x64>
mov    %r14,%rdi
call   1030 <strlen@plt>
cltq
mov    -0x2(%rax,%r14,1),%al
mov    %al,0x6(%rsp)
lea    0x6(%rsp),%rdi
call   1070 <atoi@plt>
mov    %eax,%ebp
mov    %rbx,%rdi
call   1040 <pclose@plt>
mov    %ebp,%eax
add    $0x80,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [26 x i8] c"synclient | grep ClickPad\00"
@.str.1 = [2 x i8] c"r\00"
define i32 @get_clickpad_setting() {
%1 = alloca i32
%2 = alloca [100 x i8]
%3 = alloca i32*
%4 = alloca [10 x i8]
store i32 -1, i32* %1
%5 = call i32* @popen(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %5, i32** %3
%6 = load i32*, i32** %3
%7 = icmp ne i32* %6, null
br i1 %7, label %8, label %24
8: ; preds = %0
%9 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%10 = load i32*, i32** %3
%11 = call i32* @fgets(i8* %9, i32 100, i32* %10)
%12 = icmp ne i32* %11, null
br i1 %12, label %13, label %23
13: ; preds = %8
%14 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%15 = call i32 @strlen(i8* %14)
%16 = sub nsw i32 %15, 2
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 %17
%19 = load i8, i8* %18
%20 = getelementptr inbounds [10 x i8], [10 x i8]* %4, i64 0, i64 0
store i8 %19, i8* %20
%21 = getelementptr inbounds [10 x i8], [10 x i8]* %4, i64 0, i64 0
%22 = call i32 @atoi(i8* %21)
store i32 %22, i32* %1
br label %23
23: ; preds = %13, %8
br label %24
24: ; preds = %23, %0
%25 = load i32*, i32** %3
%26 = call i32 @pclose(i32* %25)
%27 = load i32, i32* %1
ret i32 %27
}

LLVM IR (-O2):
@.str = [26 x i8] c"synclient | grep ClickPad\00"
@.str.1 = [2 x i8] c"r\00"
define i32 @get_clickpad_setting() {
%1 = alloca [100 x i8]
%2 = alloca [10 x i8]
%3 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 0
%4 = tail call i32* @popen(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%5 = icmp eq i32* %4, null
br i1 %5, label %17, label %6
6: ; preds = %0
%7 = call i32* @fgets(i8* %3, i32 100, i32* %4)
%8 = icmp eq i32* %7, null
br i1 %8, label %17, label %9
9: ; preds = %6
%10 = getelementptr inbounds [10 x i8], [10 x i8]* %2, i64 0, i64 0
%11 = call i32 @strlen(i8* %3)
%12 = add nsw i32 %11, -2
%13 = sext i32 %12 to i64
%14 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 %13
%15 = load i8, i8* %14
store i8 %15, i8* %10
%16 = call i32 @atoi(i8* %10)
br label %17
17: ; preds = %6, %9, %0
%18 = phi i32 [ %16, %9 ], [ -1, %6 ], [ -1, %0 ]
%19 = call i32 @pclose(i32* %4)
ret i32 %18
}