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

/* Variables and functions */
int /*<<< orphan*/ EXIT_FAILURE;
int /*<<< orphan*/ EXIT_SUCCESS;
struct alps_serio_dev *alps_serio_alloc();
int /*<<< orphan*/ alps_serio_free(struct alps_serio_dev *);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
scalar_t__ geteuid();
int /*<<< orphan*/ printf(char *, ...);
scalar_t__ ps2_command(struct alps_serio_dev *, unsigned char *, int);
int /*<<< orphan*/ ps2_drain(struct alps_serio_dev *);
int /*<<< orphan*/ serio_mouse_deinit(struct alps_serio_dev *);
scalar_t__ serio_mouse_init(struct alps_serio_dev *);
int /*<<< orphan*/ stderr;
int main(void) {
  struct alps_serio_dev *dev;
  unsigned char param[4];
  if (geteuid() != 0) {
    fprintf(stderr, "Error: Must be run as root\n");
    exit(EXIT_FAILURE);
  }
  dev = alps_serio_alloc();
  if (!dev) {
    printf("Error: Could not allocate device\n");
    exit(EXIT_FAILURE);
  }
  if (serio_mouse_init(dev)) {
    printf("Error: Could not locate serio mouse\n");
    serio_mouse_deinit(dev);
    exit(EXIT_FAILURE);
  }
  ps2_command(dev, param, 0x02ff);
  ps2_drain(dev);
  param[0] = 0;
  if (ps2_command(dev, param, 0x10e8) || ps2_command(dev, NULL, 0x00e6) ||
      ps2_command(dev, NULL, 0x00e6) || ps2_command(dev, NULL, 0x00e6) ||
      ps2_command(dev, param, 0x03e9)) {
    printf("E6 report failed, not an ALPS touchpad\n");
    goto cleanup;
  }
  if (param[0] != 0 || param[1] != 0 || (param[2] != 10 && param[2] != 100)) {
    printf("Invalid E6 report: %02hhx %02hhx %02hhx\n", param[0], param[1],
           param[2]);
    printf("Not an ALPS touchpad\n");
    goto cleanup;
  }
  param[0] = 0;
  if (ps2_command(dev, param, 0x10e8) || ps2_command(dev, NULL, 0x00e7) ||
      ps2_command(dev, NULL, 0x00e7) || ps2_command(dev, NULL, 0x00e7) ||
      ps2_command(dev, param, 0x03e9)) {
    printf("E7 report failed, not an ALPS touchpad\n");
    goto cleanup;
  }
  if (param[0] == 0x73 && param[1] == 0x03 && param[2] == 0x50) {
    printf("V6 ALPS touchpad found\n");
  } else if (param[0] == 0x73 && param[1] == 0x03 && param[2] == 0x0a) {
    printf("V5 ALPS touchpad found\n");
  } else if (param[0] == 0x73 && param[1] == 0x02 && param[2] == 0x64) {
    printf("V3 ALPS touchpad found\n");
  } else {
    printf("E7 report: %02hhx %02hhx %02hhx\n", param[0], param[1], param[2]);
    printf("Not an ALPS touchpad\n");
  }
cleanup:
  serio_mouse_deinit(dev);
  alps_serio_free(dev);
  exit(EXIT_SUCCESS);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1080 <geteuid@plt>
cmp    $0x0,%rax
je     11e3 <main+0x43>
mov    0x2e19(%rip),%rax
mov    (%rax),%edi
lea    0xe30(%rip),%rsi
call   10a0 <fprintf@plt>
mov    0x2dfc(%rip),%rax
mov    (%rax),%edi
call   10c0 <exit@plt>
mov    $0x0,%al
call   1090 <alps_serio_alloc@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1215 <main+0x75>
lea    0xe1c(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    0x2dca(%rip),%rax
mov    (%rax),%edi
call   10c0 <exit@plt>
mov    -0x10(%rbp),%rdi
call   1070 <serio_mouse_init@plt>
cmp    $0x0,%rax
je     124d <main+0xad>
lea    0xe0f(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x10(%rbp),%rdi
call   1030 <serio_mouse_deinit@plt>
mov    0x2d92(%rip),%rax
mov    (%rax),%edi
call   10c0 <exit@plt>
mov    -0x10(%rbp),%rdi
lea    -0x14(%rbp),%rsi
mov    $0x2ff,%edx
call   1040 <ps2_command@plt>
mov    -0x10(%rbp),%rdi
call   10b0 <ps2_drain@plt>
movb   $0x0,-0x14(%rbp)
mov    -0x10(%rbp),%rdi
lea    -0x14(%rbp),%rsi
mov    $0x10e8,%edx
call   1040 <ps2_command@plt>
cmp    $0x0,%rax
jne    12f8 <main+0x158>
mov    -0x10(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
mov    $0xe6,%edx
call   1040 <ps2_command@plt>
cmp    $0x0,%rax
jne    12f8 <main+0x158>
mov    -0x10(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
mov    $0xe6,%edx
call   1040 <ps2_command@plt>
cmp    $0x0,%rax
jne    12f8 <main+0x158>
mov    -0x10(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
mov    $0xe6,%edx
call   1040 <ps2_command@plt>
cmp    $0x0,%rax
jne    12f8 <main+0x158>
mov    -0x10(%rbp),%rdi
lea    -0x14(%rbp),%rsi
mov    $0x3e9,%edx
call   1040 <ps2_command@plt>
cmp    $0x0,%rax
je     130b <main+0x16b>
lea    0xd64(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    14f4 <main+0x354>
movzbl -0x14(%rbp),%eax
cmp    $0x0,%eax
jne    133f <main+0x19f>
movzbl -0x13(%rbp),%eax
cmp    $0x0,%eax
jne    133f <main+0x19f>
movzbl -0x12(%rbp),%eax
cmp    $0xa,%eax
je     136c <main+0x1cc>
movzbl -0x12(%rbp),%eax
cmp    $0x64,%eax
je     136c <main+0x1cc>
movzbl -0x14(%rbp),%esi
movzbl -0x13(%rbp),%edx
movzbl -0x12(%rbp),%ecx
lea    0xd39(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    0xd54(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    14f4 <main+0x354>
movb   $0x0,-0x14(%rbp)
mov    -0x10(%rbp),%rdi
lea    -0x14(%rbp),%rsi
mov    $0x10e8,%edx
call   1040 <ps2_command@plt>
cmp    $0x0,%rax
jne    13fc <main+0x25c>
mov    -0x10(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
mov    $0xe7,%edx
call   1040 <ps2_command@plt>
cmp    $0x0,%rax
jne    13fc <main+0x25c>
mov    -0x10(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
mov    $0xe7,%edx
call   1040 <ps2_command@plt>
cmp    $0x0,%rax
jne    13fc <main+0x25c>
mov    -0x10(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
mov    $0xe7,%edx
call   1040 <ps2_command@plt>
cmp    $0x0,%rax
jne    13fc <main+0x25c>
mov    -0x10(%rbp),%rdi
lea    -0x14(%rbp),%rsi
mov    $0x3e9,%edx
call   1040 <ps2_command@plt>
cmp    $0x0,%rax
je     140f <main+0x26f>
lea    0xcc7(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    14f4 <main+0x354>
movzbl -0x14(%rbp),%eax
cmp    $0x73,%eax
jne    1449 <main+0x2a9>
movzbl -0x13(%rbp),%eax
cmp    $0x3,%eax
jne    1449 <main+0x2a9>
movzbl -0x12(%rbp),%eax
cmp    $0x50,%eax
jne    1449 <main+0x2a9>
lea    0xcb5(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    14ef <main+0x34f>
movzbl -0x14(%rbp),%eax
cmp    $0x73,%eax
jne    1483 <main+0x2e3>
movzbl -0x13(%rbp),%eax
cmp    $0x3,%eax
jne    1483 <main+0x2e3>
movzbl -0x12(%rbp),%eax
cmp    $0xa,%eax
jne    1483 <main+0x2e3>
lea    0xc93(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    14ea <main+0x34a>
movzbl -0x14(%rbp),%eax
cmp    $0x73,%eax
jne    14bd <main+0x31d>
movzbl -0x13(%rbp),%eax
cmp    $0x2,%eax
jne    14bd <main+0x31d>
movzbl -0x12(%rbp),%eax
cmp    $0x64,%eax
jne    14bd <main+0x31d>
lea    0xc71(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    14e5 <main+0x345>
movzbl -0x14(%rbp),%esi
movzbl -0x13(%rbp),%edx
movzbl -0x12(%rbp),%ecx
lea    0xc6a(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    0xbd6(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    14ea <main+0x34a>
jmp    14ef <main+0x34f>
jmp    14f4 <main+0x354>
mov    -0x10(%rbp),%rdi
call   1030 <serio_mouse_deinit@plt>
mov    -0x10(%rbp),%rdi
call   1050 <alps_serio_free@plt>
mov    0x2ac3(%rip),%rax
mov    (%rax),%edi
call   10c0 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
xor    %eax,%eax
call   1090 <geteuid@plt>
test   %rax,%rax
jne    11da <main+0x2a>
xor    %eax,%eax
call   10a0 <alps_serio_alloc@plt>
test   %rax,%rax
jne    11fd <main+0x4d>
lea    0xe93(%rip),%rdi
call   1040 <puts@plt>
jmp    11ef <main+0x3f>
mov    0x2dff(%rip),%rax
mov    (%rax),%edi
lea    0xe16(%rip),%rsi
call   10b0 <fprintf@plt>
mov    0x2de2(%rip),%rax
mov    (%rax),%edi
call   10d0 <exit@plt>
mov    %rax,%rbx
mov    %rax,%rdi
call   1080 <serio_mouse_init@plt>
test   %rax,%rax
jne    1397 <main+0x1e7>
lea    0x4(%rsp),%r14
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0x2ff,%edx
call   1050 <ps2_command@plt>
mov    %rbx,%rdi
call   10c0 <ps2_drain@plt>
movb   $0x0,0x4(%rsp)
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0x10e8,%edx
call   1050 <ps2_command@plt>
lea    0xebe(%rip),%r14
test   %rax,%rax
jne    13fa <main+0x24a>
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0xe6,%edx
call   1050 <ps2_command@plt>
test   %rax,%rax
jne    13fa <main+0x24a>
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0xe6,%edx
call   1050 <ps2_command@plt>
test   %rax,%rax
jne    13fa <main+0x24a>
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0xe6,%edx
call   1050 <ps2_command@plt>
test   %rax,%rax
jne    13fa <main+0x24a>
lea    0x4(%rsp),%rsi
mov    %rbx,%rdi
mov    $0x3e9,%edx
call   1050 <ps2_command@plt>
test   %rax,%rax
jne    13fa <main+0x24a>
mov    0x4(%rsp),%r8b
mov    0x5(%rsp),%dl
mov    %r8d,%eax
or     %dl,%al
lea    0xd51(%rip),%rdi
mov    0x6(%rsp),%al
jne    13e2 <main+0x232>
cmp    $0x64,%al
je     12e1 <main+0x131>
cmp    $0xa,%al
jne    13e2 <main+0x232>
movb   $0x0,0x4(%rsp)
lea    0x4(%rsp),%rsi
mov    %rbx,%rdi
mov    $0x10e8,%edx
call   1050 <ps2_command@plt>
lea    0xdcd(%rip),%r14
test   %rax,%rax
jne    13fa <main+0x24a>
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0xe7,%edx
call   1050 <ps2_command@plt>
test   %rax,%rax
jne    13fa <main+0x24a>
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0xe7,%edx
call   1050 <ps2_command@plt>
test   %rax,%rax
jne    13fa <main+0x24a>
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0xe7,%edx
call   1050 <ps2_command@plt>
test   %rax,%rax
jne    13fa <main+0x24a>
lea    0x4(%rsp),%rsi
mov    %rbx,%rdi
mov    $0x3e9,%edx
call   1050 <ps2_command@plt>
test   %rax,%rax
jne    13fa <main+0x24a>
mov    0x4(%rsp),%r8b
mov    0x5(%rsp),%dl
mov    %r8d,%eax
xor    $0x73,%al
mov    %edx,%ecx
xor    $0x3,%cl
or     %al,%cl
sete   %sil
mov    0x6(%rsp),%al
jne    13b0 <main+0x200>
cmp    $0x50,%al
jne    13b0 <main+0x200>
lea    0xd20(%rip),%r14
jmp    13fa <main+0x24a>
lea    0xd91(%rip),%rdi
call   1040 <puts@plt>
mov    %rbx,%rdi
call   1030 <serio_mouse_deinit@plt>
jmp    11ef <main+0x3f>
cmp    $0xa,%al
sete   %cl
test   %cl,%sil
je     13c3 <main+0x213>
lea    0xcdd(%rip),%r14
jmp    13fa <main+0x24a>
lea    0xc7b(%rip),%rdi
cmp    $0x73,%r8b
jne    13e2 <main+0x232>
cmp    $0x2,%dl
jne    13e2 <main+0x232>
cmp    $0x64,%al
jne    13e2 <main+0x232>
lea    0xca7(%rip),%r14
jmp    13fa <main+0x24a>
movzbl %r8b,%esi
movzbl %dl,%edx
movzbl %al,%ecx
xor    %eax,%eax
call   1070 <printf@plt>
lea    0xcf9(%rip),%r14
mov    %r14,%rdi
call   1040 <puts@plt>
mov    %rbx,%rdi
call   1030 <serio_mouse_deinit@plt>
mov    %rbx,%rdi
call   1060 <alps_serio_free@plt>
mov    0x2bb7(%rip),%rax
mov    (%rax),%edi
call   10d0 <exit@plt>

LLVM IR (-O0):
%struct.alps_serio_dev = type { i32 }
@stderr = global i32 0
@.str = [28 x i8] c"Error: Must be run as root\0A\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [34 x i8] c"Error: Could not allocate device\0A\00"
@.str.2 = [37 x i8] c"Error: Could not locate serio mouse\0A\00"
@.str.3 = [40 x i8] c"E6 report failed, not an ALPS touchpad\0A\00"
@.str.4 = [41 x i8] c"Invalid E6 report: %02hhx %02hhx %02hhx\0A\00"
@.str.5 = [22 x i8] c"Not an ALPS touchpad\0A\00"
@.str.6 = [40 x i8] c"E7 report failed, not an ALPS touchpad\0A\00"
@.str.7 = [24 x i8] c"V6 ALPS touchpad found\0A\00"
@.str.8 = [24 x i8] c"V5 ALPS touchpad found\0A\00"
@.str.9 = [24 x i8] c"V3 ALPS touchpad found\0A\00"
@.str.10 = [33 x i8] c"E7 report: %02hhx %02hhx %02hhx\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca %struct.alps_serio_dev*
%3 = alloca [4 x i8]
store i32 0, i32* %1
%4 = call i64 (...) @geteuid()
%5 = icmp ne i64 %4, 0
br i1 %5, label %6, label %11
6: ; preds = %0
%7 = load i32, i32* @stderr
%8 = call i32 @fprintf(i32 %7, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0))
%9 = load i32, i32* @EXIT_FAILURE
%10 = call i32 @exit(i32 %9)
unreachable
11: ; preds = %0
%12 = call %struct.alps_serio_dev* (...) @alps_serio_alloc()
store %struct.alps_serio_dev* %12, %struct.alps_serio_dev** %2
%13 = load %struct.alps_serio_dev*, %struct.alps_serio_dev** %2
%14 = icmp ne %struct.alps_serio_dev* %13, null
br i1 %14, label %19, label %15
15: ; preds = %11
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.1, i64 0, i64 0))
%17 = load i32, i32* @EXIT_FAILURE
%18 = call i32 @exit(i32 %17)
unreachable
19: ; preds = %11
%20 = load %struct.alps_serio_dev*, %struct.alps_serio_dev** %2
%21 = call i64 @serio_mouse_init(%struct.alps_serio_dev* %20)
%22 = icmp ne i64 %21, 0
br i1 %22, label %23, label %29
23: ; preds = %19
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.2, i64 0, i64 0))
%25 = load %struct.alps_serio_dev*, %struct.alps_serio_dev** %2
%26 = call i32 @serio_mouse_deinit(%struct.alps_serio_dev* %25)
%27 = load i32, i32* @EXIT_FAILURE
%28 = call i32 @exit(i32 %27)
unreachable
29: ; preds = %19
%30 = load %struct.alps_serio_dev*, %struct.alps_serio_dev** %2
%31 = getelementptr inbounds [4 x i8], [4 x i8]* %3, i64 0, i64 0
%32 = call i64 @ps2_command(%struct.alps_serio_dev* %30, i8* %31, i32 767)
%33 = load %struct.alps_serio_dev*, %struct.alps_serio_dev** %2
%34 = call i32 @ps2_drain(%struct.alps_serio_dev* %33)
%35 = getelementptr inbounds [4 x i8], [4 x i8]* %3, i64 0, i64 0
store i8 0, i8* %35
%36 = load %struct.alps_serio_dev*, %struct.alps_serio_dev** %2
%37 = getelementptr inbounds [4 x i8], [4 x i8]* %3, i64 0, i64 0
%38 = call i64 @ps2_command(%struct.alps_serio_dev* %36, i8* %37, i32 4328)
%39 = icmp ne i64 %38, 0
br i1 %39, label %57, label %40
40: ; preds = %29
%41 = load %struct.alps_serio_dev*, %struct.alps_serio_dev** %2
%42 = call i64 @ps2_command(%struct.alps_serio_dev* %41, i8* null, i32 230)
%43 = icmp ne i64 %42, 0
br i1 %43, label %57, label %44
44: ; preds = %40
%45 = load %struct.alps_serio_dev*, %struct.alps_serio_dev** %2
%46 = call i64 @ps2_command(%struct.alps_serio_dev* %45, i8* null, i32 230)
%47 = icmp ne i64 %46, 0
br i1 %47, label %57, label %48
48: ; preds = %44
%49 = load %struct.alps_serio_dev*, %struct.alps_serio_dev** %2
%50 = call i64 @ps2_command(%struct.alps_serio_dev* %49, i8* null, i32 230)
%51 = icmp ne i64 %50, 0
br i1 %51, label %57, label %52
52: ; preds = %48
%53 = load %struct.alps_serio_dev*, %struct.alps_serio_dev** %2
%54 = getelementptr inbounds [4 x i8], [4 x i8]* %3, i64 0, i64 0
%55 = call i64 @ps2_command(%struct.alps_serio_dev* %53, i8* %54, i32 1001)
%56 = icmp ne i64 %55, 0
br i1 %56, label %57, label %59
57: ; preds = %52, %48, %44, %40, %29
%58 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.3, i64 0, i64 0))
br label %182
59: ; preds = %52
%60 = getelementptr inbounds [4 x i8], [4 x i8]* %3, i64 0, i64 0
%61 = load i8, i8* %60
%62 = zext i8 %61 to i32
%63 = icmp ne i32 %62, 0
br i1 %63, label %79, label %64
64: ; preds = %59
%65 = getelementptr inbounds [4 x i8], [4 x i8]* %3, i64 0, i64 1
%66 = load i8, i8* %65
%67 = zext i8 %66 to i32
%68 = icmp ne i32 %67, 0
br i1 %68, label %79, label %69
69: ; preds = %64
%70 = getelementptr inbounds [4 x i8], [4 x i8]* %3, i64 0, i64 2
%71 = load i8, i8* %70
%72 = zext i8 %71 to i32
%73 = icmp ne i32 %72, 10
br i1 %73, label %74, label %91
74: ; preds = %69
%75 = getelementptr inbounds [4 x i8], [4 x i8]* %3, i64 0, i64 2
%76 = load i8, i8* %75
%77 = zext i8 %76 to i32
%78 = icmp ne i32 %77, 100
br i1 %78, label %79, label %91
79: ; preds = %74, %64, %59
%80 = getelementptr inbounds [4 x i8], [4 x i8]* %3, i64 0, i64 0
%81 = load i8, i8* %80
%82 = zext i8 %81 to i32
%83 = getelementptr inbounds [4 x i8], [4 x i8]* %3, i64 0, i64 1
%84 = load i8, i8* %83
%85 = zext i8 %84 to i32
%86 = getelementptr inbounds [4 x i8], [4 x i8]* %3, i64 0, i64 2
%87 = load i8, i8* %86
%88 = zext i8 %87 to i32
%89 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.4, i64 0, i64 0), i32 %82, i32 %85, i32 %88)
%90 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.5, i64 0, i64 0))
br label %182
91: ; preds = %74, %69
%92 = getelementptr inbounds [4 x i8], [4 x i8]* %3, i64 0, i64 0
store i8 0, i8* %92
%93 = load %struct.alps_serio_dev*, %struct.alps_serio_dev** %2
%94 = getelementptr inbounds [4 x i8], [4 x i8]* %3, i64 0, i64 0
%95 = call i64 @ps2_command(%struct.alps_serio_dev* %93, i8* %94, i32 4328)
%96 = icmp ne i64 %95, 0
br i1 %96, label %114, label %97
97: ; preds = %91
%98 = load %struct.alps_serio_dev*, %struct.alps_serio_dev** %2
%99 = call i64 @ps2_command(%struct.alps_serio_dev* %98, i8* null, i32 231)
%100 = icmp ne i64 %99, 0
br i1 %100, label %114, label %101
101: ; preds = %97
%102 = load %struct.alps_serio_dev*, %struct.alps_serio_dev** %2
%103 = call i64 @ps2_command(%struct.alps_serio_dev* %102, i8* null, i32 231)
%104 = icmp ne i64 %103, 0
br i1 %104, label %114, label %105
105: ; preds = %101
%106 = load %struct.alps_serio_dev*, %struct.alps_serio_dev** %2
%107 = call i64 @ps2_command(%struct.alps_serio_dev* %106, i8* null, i32 231)
%108 = icmp ne i64 %107, 0
br i1 %108, label %114, label %109
109: ; preds = %105
%110 = load %struct.alps_serio_dev*, %struct.alps_serio_dev** %2
%111 = getelementptr inbounds [4 x i8], [4 x i8]* %3, i64 0, i64 0
%112 = call i64 @ps2_command(%struct.alps_serio_dev* %110, i8* %111, i32 1001)
%113 = icmp ne i64 %112, 0
br i1 %113, label %114, label %116
114: ; preds = %109, %105, %101, %97, %91
%115 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.6, i64 0, i64 0))
br label %182
116: ; preds = %109
%117 = getelementptr inbounds [4 x i8], [4 x i8]* %3, i64 0, i64 0
%118 = load i8, i8* %117
%119 = zext i8 %118 to i32
%120 = icmp eq i32 %119, 115
br i1 %120, label %121, label %133
121: ; preds = %116
%122 = getelementptr inbounds [4 x i8], [4 x i8]* %3, i64 0, i64 1
%123 = load i8, i8* %122
%124 = zext i8 %123 to i32
%125 = icmp eq i32 %124, 3
br i1 %125, label %126, label %133
126: ; preds = %121
%127 = getelementptr inbounds [4 x i8], [4 x i8]* %3, i64 0, i64 2
%128 = load i8, i8* %127
%129 = zext i8 %128 to i32
%130 = icmp eq i32 %129, 80
br i1 %130, label %131, label %133
131: ; preds = %126
%132 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.7, i64 0, i64 0))
br label %181
133: ; preds = %126, %121, %116
%134 = getelementptr inbounds [4 x i8], [4 x i8]* %3, i64 0, i64 0
%135 = load i8, i8* %134
%136 = zext i8 %135 to i32
%137 = icmp eq i32 %136, 115
br i1 %137, label %138, label %150
138: ; preds = %133
%139 = getelementptr inbounds [4 x i8], [4 x i8]* %3, i64 0, i64 1
%140 = load i8, i8* %139
%141 = zext i8 %140 to i32
%142 = icmp eq i32 %141, 3
br i1 %142, label %143, label %150
143: ; preds = %138
%144 = getelementptr inbounds [4 x i8], [4 x i8]* %3, i64 0, i64 2
%145 = load i8, i8* %144
%146 = zext i8 %145 to i32
%147 = icmp eq i32 %146, 10
br i1 %147, label %148, label %150
148: ; preds = %143
%149 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.8, i64 0, i64 0))
br label %180
150: ; preds = %143, %138, %133
%151 = getelementptr inbounds [4 x i8], [4 x i8]* %3, i64 0, i64 0
%152 = load i8, i8* %151
%153 = zext i8 %152 to i32
%154 = icmp eq i32 %153, 115
br i1 %154, label %155, label %167
155: ; preds = %150
%156 = getelementptr inbounds [4 x i8], [4 x i8]* %3, i64 0, i64 1
%157 = load i8, i8* %156
%158 = zext i8 %157 to i32
%159 = icmp eq i32 %158, 2
br i1 %159, label %160, label %167
160: ; preds = %155
%161 = getelementptr inbounds [4 x i8], [4 x i8]* %3, i64 0, i64 2
%162 = load i8, i8* %161
%163 = zext i8 %162 to i32
%164 = icmp eq i32 %163, 100
br i1 %164, label %165, label %167
165: ; preds = %160
%166 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.9, i64 0, i64 0))
br label %179
167: ; preds = %160, %155, %150
%168 = getelementptr inbounds [4 x i8], [4 x i8]* %3, i64 0, i64 0
%169 = load i8, i8* %168
%170 = zext i8 %169 to i32
%171 = getelementptr inbounds [4 x i8], [4 x i8]* %3, i64 0, i64 1
%172 = load i8, i8* %171
%173 = zext i8 %172 to i32
%174 = getelementptr inbounds [4 x i8], [4 x i8]* %3, i64 0, i64 2
%175 = load i8, i8* %174
%176 = zext i8 %175 to i32
%177 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.10, i64 0, i64 0), i32 %170, i32 %173, i32 %176)
%178 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.5, i64 0, i64 0))
br label %179
179: ; preds = %167, %165
br label %180
180: ; preds = %179, %148
br label %181
181: ; preds = %180, %131
br label %182
182: ; preds = %181, %114, %79, %57
%183 = load %struct.alps_serio_dev*, %struct.alps_serio_dev** %2
%184 = call i32 @serio_mouse_deinit(%struct.alps_serio_dev* %183)
%185 = load %struct.alps_serio_dev*, %struct.alps_serio_dev** %2
%186 = call i32 @alps_serio_free(%struct.alps_serio_dev* %185)
%187 = load i32, i32* @EXIT_SUCCESS
%188 = call i32 @exit(i32 %187)
unreachable
}

LLVM IR (-O2):
%struct.alps_serio_dev = type { i32 }
@stderr = global i32 0
@.str = [28 x i8] c"Error: Must be run as root\0A\00"
@EXIT_FAILURE = global i32 0
@.str.4 = [41 x i8] c"Invalid E6 report: %02hhx %02hhx %02hhx\0A\00"
@.str.10 = [33 x i8] c"E7 report: %02hhx %02hhx %02hhx\0A\00"
@EXIT_SUCCESS = global i32 0
@str = [33 x i8] c"Error: Could not allocate device\00"
@str.12 = [23 x i8] c"V3 ALPS touchpad found\00"
@str.13 = [23 x i8] c"V5 ALPS touchpad found\00"
@str.14 = [23 x i8] c"V6 ALPS touchpad found\00"
@str.15 = [39 x i8] c"E7 report failed, not an ALPS touchpad\00"
@str.16 = [21 x i8] c"Not an ALPS touchpad\00"
@str.17 = [39 x i8] c"E6 report failed, not an ALPS touchpad\00"
@str.18 = [36 x i8] c"Error: Could not locate serio mouse\00"
define i32 @main() {
%1 = alloca [4 x i8]
%2 = getelementptr inbounds [4 x i8], [4 x i8]* %1, i64 0, i64 0
%3 = tail call i64 (...) @geteuid()
%4 = icmp eq i64 %3, 0
br i1 %4, label %10, label %5
5: ; preds = %0
%6 = load i32, i32* @stderr
%7 = tail call i32 @fprintf(i32 %6, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0))
%8 = load i32, i32* @EXIT_FAILURE
%9 = tail call i32 @exit(i32 %8)
unreachable
10: ; preds = %0
%11 = tail call %struct.alps_serio_dev* (...) @alps_serio_alloc()
%12 = icmp eq %struct.alps_serio_dev* %11, null
br i1 %12, label %13, label %17
13: ; preds = %10
%14 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @str, i64 0, i64 0))
%15 = load i32, i32* @EXIT_FAILURE
%16 = tail call i32 @exit(i32 %15)
unreachable
17: ; preds = %10
%18 = tail call i64 @serio_mouse_init(%struct.alps_serio_dev* %11)
%19 = icmp eq i64 %18, 0
br i1 %19, label %25, label %20
20: ; preds = %17
%21 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @str.18, i64 0, i64 0))
%22 = tail call i32 @serio_mouse_deinit(%struct.alps_serio_dev* %11)
%23 = load i32, i32* @EXIT_FAILURE
%24 = tail call i32 @exit(i32 %23)
unreachable
25: ; preds = %17
%26 = call i64 @ps2_command(%struct.alps_serio_dev* %11, i8* %2, i32 767)
%27 = call i32 @ps2_drain(%struct.alps_serio_dev* %11)
store i8 0, i8* %2
%28 = call i64 @ps2_command(%struct.alps_serio_dev* %11, i8* %2, i32 4328)
%29 = icmp eq i64 %28, 0
br i1 %29, label %30, label %94
30: ; preds = %25
%31 = call i64 @ps2_command(%struct.alps_serio_dev* %11, i8* null, i32 230)
%32 = icmp eq i64 %31, 0
br i1 %32, label %33, label %94
33: ; preds = %30
%34 = call i64 @ps2_command(%struct.alps_serio_dev* %11, i8* null, i32 230)
%35 = icmp eq i64 %34, 0
br i1 %35, label %36, label %94
36: ; preds = %33
%37 = call i64 @ps2_command(%struct.alps_serio_dev* %11, i8* null, i32 230)
%38 = icmp eq i64 %37, 0
br i1 %38, label %39, label %94
39: ; preds = %36
%40 = call i64 @ps2_command(%struct.alps_serio_dev* %11, i8* %2, i32 1001)
%41 = icmp eq i64 %40, 0
br i1 %41, label %42, label %94
42: ; preds = %39
%43 = load i8, i8* %2
%44 = icmp ne i8 %43, 0
%45 = getelementptr inbounds [4 x i8], [4 x i8]* %1, i64 0, i64 1
%46 = load i8, i8* %45
%47 = icmp ne i8 %46, 0
%48 = select i1 %44, i1 true, i1 %47
%49 = getelementptr inbounds [4 x i8], [4 x i8]* %1, i64 0, i64 2
%50 = load i8, i8* %49
br i1 %48, label %84, label %51
51: ; preds = %42
switch i8 %50, label %84 [
i8 100, label %52
i8 10, label %52
]
52: ; preds = %51, %51
store i8 0, i8* %2
%53 = call i64 @ps2_command(%struct.alps_serio_dev* %11, i8* %2, i32 4328)
%54 = icmp eq i64 %53, 0
br i1 %54, label %55, label %94
55: ; preds = %52
%56 = call i64 @ps2_command(%struct.alps_serio_dev* %11, i8* null, i32 231)
%57 = icmp eq i64 %56, 0
br i1 %57, label %58, label %94
58: ; preds = %55
%59 = call i64 @ps2_command(%struct.alps_serio_dev* %11, i8* null, i32 231)
%60 = icmp eq i64 %59, 0
br i1 %60, label %61, label %94
61: ; preds = %58
%62 = call i64 @ps2_command(%struct.alps_serio_dev* %11, i8* null, i32 231)
%63 = icmp eq i64 %62, 0
br i1 %63, label %64, label %94
64: ; preds = %61
%65 = call i64 @ps2_command(%struct.alps_serio_dev* %11, i8* %2, i32 1001)
%66 = icmp eq i64 %65, 0
br i1 %66, label %67, label %94
67: ; preds = %64
%68 = load i8, i8* %2
%69 = icmp eq i8 %68, 115
%70 = load i8, i8* %45
%71 = icmp eq i8 %70, 3
%72 = select i1 %69, i1 %71, i1 false
%73 = load i8, i8* %49
%74 = icmp eq i8 %73, 80
%75 = select i1 %72, i1 %74, i1 false
br i1 %75, label %94, label %76
76: ; preds = %67
%77 = icmp eq i8 %73, 10
%78 = select i1 %72, i1 %77, i1 false
br i1 %78, label %94, label %79
79: ; preds = %76
%80 = icmp eq i8 %70, 2
%81 = select i1 %69, i1 %80, i1 false
%82 = icmp eq i8 %73, 100
%83 = select i1 %81, i1 %82, i1 false
br i1 %83, label %94, label %84
84: ; preds = %51, %42, %79
%85 = phi i8 [ %73, %79 ], [ %50, %42 ], [ %50, %51 ]
%86 = phi i8 [ %70, %79 ], [ %46, %42 ], [ %46, %51 ]
%87 = phi i8 [ %68, %79 ], [ %43, %42 ], [ %43, %51 ]
%88 = phi i8* [ getelementptr inbounds ([33 x i8], [33 x i8]* @.str.10, i64 0, i64 0), %79 ], [ getelementptr inbounds ([41 x i8], [41 x i8]* @.str.4, i64 0, i64 0), %42 ], [ getelementptr inbounds ([41 x i8], [41 x i8]* @.str.4, i64 0, i64 0), %51 ]
%89 = phi i8* [ getelementptr inbounds ([21 x i8], [21 x i8]* @str.16, i64 0, i64 0), %79 ], [ getelementptr inbounds ([21 x i8], [21 x i8]* @str.16, i64 0, i64 0), %42 ], [ getelementptr inbounds ([21 x i8], [21 x i8]* @str.16, i64 0, i64 0), %51 ]
%90 = zext i8 %87 to i32
%91 = zext i8 %86 to i32
%92 = zext i8 %85 to i32
%93 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) %88, i32 %90, i32 %91, i32 %92)
br label %94
94: ; preds = %84, %79, %76, %67, %52, %55, %58, %61, %64, %25, %30, %33, %36, %39
%95 = phi i8* [ getelementptr inbounds ([39 x i8], [39 x i8]* @str.17, i64 0, i64 0), %39 ], [ getelementptr inbounds ([39 x i8], [39 x i8]* @str.17, i64 0, i64 0), %36 ], [ getelementptr inbounds ([39 x i8], [39 x i8]* @str.17, i64 0, i64 0), %33 ], [ getelementptr inbounds ([39 x i8], [39 x i8]* @str.17, i64 0, i64 0), %30 ], [ getelementptr inbounds ([39 x i8], [39 x i8]* @str.17, i64 0, i64 0), %25 ], [ getelementptr inbounds ([39 x i8], [39 x i8]* @str.15, i64 0, i64 0), %64 ], [ getelementptr inbounds ([39 x i8], [39 x i8]* @str.15, i64 0, i64 0), %61 ], [ getelementptr inbounds ([39 x i8], [39 x i8]* @str.15, i64 0, i64 0), %58 ], [ getelementptr inbounds ([39 x i8], [39 x i8]* @str.15, i64 0, i64 0), %55 ], [ getelementptr inbounds ([39 x i8], [39 x i8]* @str.15, i64 0, i64 0), %52 ], [ getelementptr inbounds ([23 x i8], [23 x i8]* @str.14, i64 0, i64 0), %67 ], [ getelementptr inbounds ([23 x i8], [23 x i8]* @str.13, i64 0, i64 0), %76 ], [ getelementptr inbounds ([23 x i8], [23 x i8]* @str.12, i64 0, i64 0), %79 ], [ %89, %84 ]
%96 = call i32 @puts(i8* dereferenceable(1) %95)
%97 = call i32 @serio_mouse_deinit(%struct.alps_serio_dev* %11)
%98 = call i32 @alps_serio_free(%struct.alps_serio_dev* %11)
%99 = load i32, i32* @EXIT_SUCCESS
%100 = call i32 @exit(i32 %99)
unreachable
}