#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*/ check_message();
int /*<<< orphan*/ is_direction(int, int *);
int /*<<< orphan*/ message(char *, int /*<<< orphan*/);
int /*<<< orphan*/ one_move_rogue(int, int /*<<< orphan*/);
int rgetchar();
int /*<<< orphan*/ sound_bell();
void move_onto() {
  int ch, d;
  int first_miss = 1;
  while (!is_direction(ch = rgetchar(), &d)) {
    sound_bell();
    if (first_miss) {
      message("direction? ", 0);
      first_miss = 0;
    }
  }
  check_message();
  if (ch != '\033') {
    (void)one_move_rogue(ch, 0);
  }
}


x86 assembly (clang, -O0):
<move_onto>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x1,-0xc(%rbp)
mov    $0x0,%al
call   1040 <rgetchar@plt>
mov    %eax,%edi
mov    %edi,-0x4(%rbp)
lea    -0x8(%rbp),%rsi
call   1050 <is_direction@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    1199 <move_onto+0x39>
jmp    11c4 <move_onto+0x64>
mov    $0x0,%al
call   1060 <sound_bell@plt>
cmpl   $0x0,-0xc(%rbp)
je     11bf <move_onto+0x5f>
lea    0xe4f(%rip),%rdi
xor    %esi,%esi
call   1030 <message@plt>
movl   $0x0,-0xc(%rbp)
jmp    116f <move_onto+0xf>
mov    $0x0,%al
call   1080 <check_message@plt>
cmpl   $0x1b,-0x4(%rbp)
je     11df <move_onto+0x7f>
mov    -0x4(%rbp),%edi
xor    %esi,%esi
call   1070 <one_move_rogue@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<move_onto>:
push   %r14
push   %rbx
push   %rax
xor    %eax,%eax
call   1040 <rgetchar@plt>
mov    %eax,%ebx
lea    0x4(%rsp),%rsi
mov    %eax,%edi
call   1050 <is_direction@plt>
test   %eax,%eax
jne    11ce <move_onto+0x6e>
xor    %eax,%eax
call   1060 <sound_bell@plt>
lea    0xe75(%rip),%rdi
xor    %esi,%esi
call   1030 <message@plt>
xor    %eax,%eax
call   1040 <rgetchar@plt>
mov    %eax,%ebx
lea    0x4(%rsp),%rsi
mov    %eax,%edi
call   1050 <is_direction@plt>
test   %eax,%eax
jne    11ce <move_onto+0x6e>
lea    0x4(%rsp),%r14
xor    %eax,%eax
call   1060 <sound_bell@plt>
xor    %eax,%eax
call   1040 <rgetchar@plt>
mov    %eax,%ebx
mov    %eax,%edi
mov    %r14,%rsi
call   1050 <is_direction@plt>
test   %eax,%eax
je     11b0 <move_onto+0x50>
xor    %eax,%eax
call   1080 <check_message@plt>
cmp    $0x1b,%ebx
je     11e3 <move_onto+0x83>
mov    %ebx,%edi
xor    %esi,%esi
call   1070 <one_move_rogue@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [12 x i8] c"direction? \00"
define void @move_onto() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
store i32 1, i32* %3
br label %4
4: ; preds = %15, %0
%5 = call i32 (...) @rgetchar()
store i32 %5, i32* %1
%6 = call i32 @is_direction(i32 %5, i32* %2)
%7 = icmp ne i32 %6, 0
%8 = xor i1 %7, true
br i1 %8, label %9, label %16
9: ; preds = %4
%10 = call i32 (...) @sound_bell()
%11 = load i32, i32* %3
%12 = icmp ne i32 %11, 0
br i1 %12, label %13, label %15
13: ; preds = %9
%14 = call i32 @message(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 0)
store i32 0, i32* %3
br label %15
15: ; preds = %13, %9
br label %4
16: ; preds = %4
%17 = call i32 (...) @check_message()
%18 = load i32, i32* %1
%19 = icmp ne i32 %18, 27
br i1 %19, label %20, label %23
20: ; preds = %16
%21 = load i32, i32* %1
%22 = call i32 @one_move_rogue(i32 %21, i32 0)
br label %23
23: ; preds = %20, %16
ret void
}

LLVM IR (-O2):
@.str = [12 x i8] c"direction? \00"
define void @move_onto() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = call i32 (...) @rgetchar()
%4 = call i32 @is_direction(i32 %3, i32* %1)
%5 = icmp eq i32 %4, 0
br i1 %5, label %6, label %17
6: ; preds = %0
%7 = call i32 (...) @sound_bell()
%8 = call i32 @message(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 0)
%9 = call i32 (...) @rgetchar()
%10 = call i32 @is_direction(i32 %9, i32* %1)
%11 = icmp eq i32 %10, 0
br i1 %11, label %12, label %17
12: ; preds = %6, %12
%13 = call i32 (...) @sound_bell()
%14 = call i32 (...) @rgetchar()
%15 = call i32 @is_direction(i32 %14, i32* %1)
%16 = icmp eq i32 %15, 0
br i1 %16, label %12, label %17
17: ; preds = %12, %6, %0
%18 = phi i32 [ %3, %0 ], [ %9, %6 ], [ %14, %12 ]
%19 = call i32 (...) @check_message()
%20 = icmp eq i32 %18, 27
br i1 %20, label %23, label %21
21: ; preds = %17
%22 = call i32 @one_move_rogue(i32 %18, i32 0)
br label %23
23: ; preds = %21, %17
ret void
}