#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 /*<<< orphan*/ STDIN_FILENO;
int /*<<< orphan*/ printf(char *);
scalar_t__ testscancodes(int /*<<< orphan*/);
int main(void) {
  printf("try out some keys to find out whether SCANCODES works\n");
  printf("press CTRL+C to end this test\n");
  printf("please note that this test only works from a console tty\n");
  if (testscancodes(STDIN_FILENO) < 0)
    return -1;
  else
    return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeca(%rip),%rdi
call   1030 <printf@plt>
lea    0xef5(%rip),%rdi
call   1030 <printf@plt>
lea    0xf08(%rip),%rdi
call   1030 <printf@plt>
mov    0x2e86(%rip),%rax
mov    (%rax),%edi
call   1040 <testscancodes@plt>
cmp    $0x0,%rax
jge    1177 <main+0x57>
movl   $0xffffffff,-0x4(%rbp)
jmp    117e <main+0x5e>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
lea    0xed8(%rip),%rdi
call   1030 <puts@plt>
lea    0xf02(%rip),%rdi
call   1030 <puts@plt>
lea    0xf14(%rip),%rdi
call   1030 <puts@plt>
mov    0x2e94(%rip),%rax
mov    (%rax),%edi
call   1040 <testscancodes@plt>
sar    $0x3f,%rax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [55 x i8] c"try out some keys to find out whether SCANCODES works\0A\00"
@.str.1 = [31 x i8] c"press CTRL+C to end this test\0A\00"
@.str.2 = [58 x i8] c"please note that this test only works from a console tty\0A\00"
@STDIN_FILENO = global i32 0
define i32 @main() {
%1 = alloca i32
store i32 0, i32* %1
%2 = call i32 @printf(i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str, i64 0, i64 0))
%3 = call i32 @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0))
%4 = call i32 @printf(i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str.2, i64 0, i64 0))
%5 = load i32, i32* @STDIN_FILENO
%6 = call i64 @testscancodes(i32 %5)
%7 = icmp slt i64 %6, 0
br i1 %7, label %8, label %9
8: ; preds = %0
store i32 -1, i32* %1
br label %10
9: ; preds = %0
store i32 0, i32* %1
br label %10
10: ; preds = %9, %8
%11 = load i32, i32* %1
ret i32 %11
}

LLVM IR (-O2):
@STDIN_FILENO = global i32 0
@str = [54 x i8] c"try out some keys to find out whether SCANCODES works\00"
@str.3 = [30 x i8] c"press CTRL+C to end this test\00"
@str.4 = [57 x i8] c"please note that this test only works from a console tty\00"
define i32 @main() {
%1 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([54 x i8], [54 x i8]* @str, i64 0, i64 0))
%2 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @str.3, i64 0, i64 0))
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([57 x i8], [57 x i8]* @str.4, i64 0, i64 0))
%4 = load i32, i32* @STDIN_FILENO
%5 = tail call i64 @testscancodes(i32 %4)
%6 = ashr i64 %5, 63
%7 = trunc i64 %6 to i32
ret i32 %7
}