#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 */
int /*<<< orphan*/ psmouse_command(struct psmouse *, unsigned char *, int);
int synaptics_detect(struct psmouse *psmouse) {
  unsigned char param[4];
  param[0] = 0;
  psmouse_command(psmouse, param, 0x10e8);
  psmouse_command(psmouse, param, 0x10e8);
  psmouse_command(psmouse, param, 0x10e8);
  psmouse_command(psmouse, param, 0x10e8);
  psmouse_command(psmouse, param, 0x03e9);
  return param[1] == 0x47;
}


x86 assembly (clang, -O0):
<synaptics_detect>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
movb   $0x0,-0xc(%rbp)
mov    -0x8(%rbp),%rdi
lea    -0xc(%rbp),%rsi
mov    $0x10e8,%edx
call   1030 <psmouse_command@plt>
mov    -0x8(%rbp),%rdi
lea    -0xc(%rbp),%rsi
mov    $0x10e8,%edx
call   1030 <psmouse_command@plt>
mov    -0x8(%rbp),%rdi
lea    -0xc(%rbp),%rsi
mov    $0x10e8,%edx
call   1030 <psmouse_command@plt>
mov    -0x8(%rbp),%rdi
lea    -0xc(%rbp),%rsi
mov    $0x10e8,%edx
call   1030 <psmouse_command@plt>
mov    -0x8(%rbp),%rdi
lea    -0xc(%rbp),%rsi
mov    $0x3e9,%edx
call   1030 <psmouse_command@plt>
movzbl -0xb(%rbp),%eax
cmp    $0x47,%eax
sete   %al
and    $0x1,%al
movzbl %al,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<synaptics_detect>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rbx
movb   $0x0,0x4(%rsp)
lea    0x4(%rsp),%r14
mov    %r14,%rsi
mov    $0x10e8,%edx
call   1030 <psmouse_command@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0x10e8,%edx
call   1030 <psmouse_command@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0x10e8,%edx
call   1030 <psmouse_command@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0x10e8,%edx
call   1030 <psmouse_command@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0x3e9,%edx
call   1030 <psmouse_command@plt>
xor    %eax,%eax
cmpb   $0x47,0x5(%rsp)
sete   %al
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.psmouse = type { i32 }
define i32 @synaptics_detect(%struct.psmouse* %0) {
%2 = alloca %struct.psmouse*
%3 = alloca [4 x i8]
store %struct.psmouse* %0, %struct.psmouse** %2
%4 = getelementptr inbounds [4 x i8], [4 x i8]* %3, i64 0, i64 0
store i8 0, i8* %4
%5 = load %struct.psmouse*, %struct.psmouse** %2
%6 = getelementptr inbounds [4 x i8], [4 x i8]* %3, i64 0, i64 0
%7 = call i32 @psmouse_command(%struct.psmouse* %5, i8* %6, i32 4328)
%8 = load %struct.psmouse*, %struct.psmouse** %2
%9 = getelementptr inbounds [4 x i8], [4 x i8]* %3, i64 0, i64 0
%10 = call i32 @psmouse_command(%struct.psmouse* %8, i8* %9, i32 4328)
%11 = load %struct.psmouse*, %struct.psmouse** %2
%12 = getelementptr inbounds [4 x i8], [4 x i8]* %3, i64 0, i64 0
%13 = call i32 @psmouse_command(%struct.psmouse* %11, i8* %12, i32 4328)
%14 = load %struct.psmouse*, %struct.psmouse** %2
%15 = getelementptr inbounds [4 x i8], [4 x i8]* %3, i64 0, i64 0
%16 = call i32 @psmouse_command(%struct.psmouse* %14, i8* %15, i32 4328)
%17 = load %struct.psmouse*, %struct.psmouse** %2
%18 = getelementptr inbounds [4 x i8], [4 x i8]* %3, i64 0, i64 0
%19 = call i32 @psmouse_command(%struct.psmouse* %17, i8* %18, i32 1001)
%20 = getelementptr inbounds [4 x i8], [4 x i8]* %3, i64 0, i64 1
%21 = load i8, i8* %20
%22 = zext i8 %21 to i32
%23 = icmp eq i32 %22, 71
%24 = zext i1 %23 to i32
ret i32 %24
}

LLVM IR (-O2):
%struct.psmouse = type { i32 }
define i32 @synaptics_detect(%struct.psmouse* %0) {
%2 = alloca [4 x i8]
%3 = getelementptr inbounds [4 x i8], [4 x i8]* %2, i64 0, i64 0
store i8 0, i8* %3
%4 = call i32 @psmouse_command(%struct.psmouse* %0, i8* %3, i32 4328)
%5 = call i32 @psmouse_command(%struct.psmouse* %0, i8* %3, i32 4328)
%6 = call i32 @psmouse_command(%struct.psmouse* %0, i8* %3, i32 4328)
%7 = call i32 @psmouse_command(%struct.psmouse* %0, i8* %3, i32 4328)
%8 = call i32 @psmouse_command(%struct.psmouse* %0, i8* %3, i32 1001)
%9 = getelementptr inbounds [4 x i8], [4 x i8]* %2, i64 0, i64 1
%10 = load i8, i8* %9
%11 = icmp eq i8 %10, 71
%12 = zext i1 %11 to i32
ret i32 %12
}