#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 psmouse {
  int dummy;
};

/* Variables and functions */
scalar_t__ psmouse_command(struct psmouse *, unsigned char *, int);
scalar_t__ psmouse_sliced_command(struct psmouse *, unsigned char);
int synaptics_mode_cmd(struct psmouse *psmouse, unsigned char mode) {
  unsigned char param[1];
  if (psmouse_sliced_command(psmouse, mode))
    return -1;
  param[0] = 0x14;
  if (psmouse_command(psmouse, param, 0x10f3))
    return -1;
  return 0;
}


x86 assembly (clang, -O0):
<synaptics_mode_cmd>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %sil,%al
mov    %rdi,-0x10(%rbp)
mov    %al,-0x11(%rbp)
mov    -0x10(%rbp),%rdi
movzbl -0x11(%rbp),%esi
call   1040 <psmouse_sliced_command@plt>
cmp    $0x0,%rax
je     1155 <synaptics_mode_cmd+0x35>
movl   $0xffffffff,-0x4(%rbp)
jmp    1188 <synaptics_mode_cmd+0x68>
movb   $0x14,-0x12(%rbp)
mov    -0x10(%rbp),%rdi
lea    -0x12(%rbp),%rsi
mov    $0x10f3,%edx
call   1030 <psmouse_command@plt>
cmp    $0x0,%rax
je     1181 <synaptics_mode_cmd+0x61>
movl   $0xffffffff,-0x4(%rbp)
jmp    1188 <synaptics_mode_cmd+0x68>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<synaptics_mode_cmd>:
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%rbx
call   1040 <psmouse_sliced_command@plt>
mov    %rax,%rcx
mov    $0xffffffff,%eax
test   %rcx,%rcx
jne    1156 <synaptics_mode_cmd+0x36>
movb   $0x14,0xf(%rsp)
lea    0xf(%rsp),%rsi
mov    %rbx,%rdi
mov    $0x10f3,%edx
call   1030 <psmouse_command@plt>
neg    %rax
sbb    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
%struct.psmouse = type { i32 }
define i32 @synaptics_mode_cmd(%struct.psmouse* %0, i8 zeroext %1) {
%3 = alloca i32
%4 = alloca %struct.psmouse*
%5 = alloca i8
%6 = alloca [1 x i8]
store %struct.psmouse* %0, %struct.psmouse** %4
store i8 %1, i8* %5
%7 = load %struct.psmouse*, %struct.psmouse** %4
%8 = load i8, i8* %5
%9 = call i64 @psmouse_sliced_command(%struct.psmouse* %7, i8 zeroext %8)
%10 = icmp ne i64 %9, 0
br i1 %10, label %11, label %12
11: ; preds = %2
store i32 -1, i32* %3
br label %20
12: ; preds = %2
%13 = getelementptr inbounds [1 x i8], [1 x i8]* %6, i64 0, i64 0
store i8 20, i8* %13
%14 = load %struct.psmouse*, %struct.psmouse** %4
%15 = getelementptr inbounds [1 x i8], [1 x i8]* %6, i64 0, i64 0
%16 = call i64 @psmouse_command(%struct.psmouse* %14, i8* %15, i32 4339)
%17 = icmp ne i64 %16, 0
br i1 %17, label %18, label %19
18: ; preds = %12
store i32 -1, i32* %3
br label %20
19: ; preds = %12
store i32 0, i32* %3
br label %20
20: ; preds = %19, %18, %11
%21 = load i32, i32* %3
ret i32 %21
}

LLVM IR (-O2):
%struct.psmouse = type { i32 }
define i32 @synaptics_mode_cmd(%struct.psmouse* %0, i8 zeroext %1) {
%3 = alloca [1 x i8]
%4 = getelementptr inbounds [1 x i8], [1 x i8]* %3, i64 0, i64 0
%5 = tail call i64 @psmouse_sliced_command(%struct.psmouse* %0, i8 zeroext %1)
%6 = icmp eq i64 %5, 0
br i1 %6, label %7, label %11
7: ; preds = %2
store i8 20, i8* %4
%8 = call i64 @psmouse_command(%struct.psmouse* %0, i8* %4, i32 4339)
%9 = icmp ne i64 %8, 0
%10 = sext i1 %9 to i32
br label %11
11: ; preds = %7, %2
%12 = phi i32 [ -1, %2 ], [ %10, %7 ]
ret i32 %12
}