#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 getarrowkey();
int /*<<< orphan*/ usleep(int);
int /*<<< orphan*/ write(int, char *, int);
int main(void) {
  int key;
  while (1) {
    key = getarrowkey();
    if (key == 1)
      write(1, "W\n", 2);
    else if (key == 2)
      write(1, "fleche haut\n", 12);
    else if (key == 3)
      write(1, "fleche bas\n", 11);
    else if (key == 4)
      write(1, "S\n", 2);
    usleep(100000);
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1040 <getarrowkey@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x1,-0x8(%rbp)
jne    116e <main+0x3e>
mov    $0x1,%edi
lea    0xea1(%rip),%rsi
mov    $0x2,%edx
call   1030 <write@plt>
jmp    11e7 <main+0xb7>
cmpl   $0x2,-0x8(%rbp)
jne    1193 <main+0x63>
mov    $0x1,%edi
lea    0xe7f(%rip),%rsi
mov    $0xc,%edx
call   1030 <write@plt>
jmp    11e2 <main+0xb2>
cmpl   $0x3,-0x8(%rbp)
jne    11b8 <main+0x88>
mov    $0x1,%edi
lea    0xe67(%rip),%rsi
mov    $0xb,%edx
call   1030 <write@plt>
jmp    11dd <main+0xad>
cmpl   $0x4,-0x8(%rbp)
jne    11d8 <main+0xa8>
mov    $0x1,%edi
lea    0xe4e(%rip),%rsi
mov    $0x2,%edx
call   1030 <write@plt>
jmp    11dd <main+0xad>
jmp    11e2 <main+0xb2>
jmp    11e7 <main+0xb7>
mov    $0x186a0,%edi
call   1050 <usleep@plt>
jmp    113f <main+0xf>

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
lea    0xec0(%rip),%rbx
lea    0xec9(%rip),%r14
lea    0xec5(%rip),%r15
lea    0xecb(%rip),%r12
lea    0xed0(%rip),%r13
jmp    117c <main+0x4c>
xchg   %ax,%ax
mov    $0x1,%edi
mov    %r13,%rsi
mov    $0x2,%edx
call   1030 <write@plt>
mov    $0x186a0,%edi
call   1050 <usleep@plt>
xor    %eax,%eax
call   1040 <getarrowkey@plt>
add    $0xffffffff,%eax
cmp    $0x3,%eax
ja     1172 <main+0x42>
movslq (%rbx,%rax,4),%rax
add    %rbx,%rax
jmp    *%rax
mov    $0x1,%edi
mov    %r14,%rsi
jmp    1168 <main+0x38>
xchg   %ax,%ax
mov    $0x1,%edi
mov    %r15,%rsi
mov    $0xc,%edx
jmp    116d <main+0x3d>
nop
mov    $0x1,%edi
mov    %r12,%rsi
mov    $0xb,%edx
jmp    116d <main+0x3d>

LLVM IR (-O0):
@.str = [3 x i8] c"W\0A\00"
@.str.1 = [13 x i8] c"fleche haut\0A\00"
@.str.2 = [12 x i8] c"fleche bas\0A\00"
@.str.3 = [3 x i8] c"S\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
store i32 0, i32* %1
br label %3
3: ; preds = %0, %27
%4 = call i32 (...) @getarrowkey()
store i32 %4, i32* %2
%5 = load i32, i32* %2
%6 = icmp eq i32 %5, 1
br i1 %6, label %7, label %9
7: ; preds = %3
%8 = call i32 @write(i32 1, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 2)
br label %27
9: ; preds = %3
%10 = load i32, i32* %2
%11 = icmp eq i32 %10, 2
br i1 %11, label %12, label %14
12: ; preds = %9
%13 = call i32 @write(i32 1, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i32 12)
br label %26
14: ; preds = %9
%15 = load i32, i32* %2
%16 = icmp eq i32 %15, 3
br i1 %16, label %17, label %19
17: ; preds = %14
%18 = call i32 @write(i32 1, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i32 11)
br label %25
19: ; preds = %14
%20 = load i32, i32* %2
%21 = icmp eq i32 %20, 4
br i1 %21, label %22, label %24
22: ; preds = %19
%23 = call i32 @write(i32 1, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32 2)
br label %24
24: ; preds = %22, %19
br label %25
25: ; preds = %24, %17
br label %26
26: ; preds = %25, %12
br label %27
27: ; preds = %26, %7
%28 = call i32 @usleep(i32 100000)
br label %3
}

LLVM IR (-O2):
@.str = [3 x i8] c"W\0A\00"
@.str.1 = [13 x i8] c"fleche haut\0A\00"
@.str.2 = [12 x i8] c"fleche bas\0A\00"
@.str.3 = [3 x i8] c"S\0A\00"
define i32 @main() {
br label %1
1: ; preds = %11, %0
%2 = tail call i32 (...) @getarrowkey()
switch i32 %2, label %11 [
i32 1, label %3
i32 2, label %5
i32 3, label %7
i32 4, label %9
]
3: ; preds = %1
%4 = tail call i32 @write(i32 1, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 2)
br label %11
5: ; preds = %1
%6 = tail call i32 @write(i32 1, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i32 12)
br label %11
7: ; preds = %1
%8 = tail call i32 @write(i32 1, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i32 11)
br label %11
9: ; preds = %1
%10 = tail call i32 @write(i32 1, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32 2)
br label %11
11: ; preds = %1, %5, %9, %7, %3
%12 = tail call i32 @usleep(i32 100000)
br label %1
}