#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*/ fflush(int /*<<< orphan*/);
int /*<<< orphan*/ init_robot();
int /*<<< orphan*/ move_robot(int);
int /*<<< orphan*/ print_world();
int /*<<< orphan*/ printf(char *, char, char, char, char, char);
int /*<<< orphan*/ rotate_90_left();
int /*<<< orphan*/ rotate_90_right();
int /*<<< orphan*/ scanf(char *, char *);
int /*<<< orphan*/ stdin;
int main(void) {
  char c;
  init_robot();
  fflush(stdin);
  printf("Usage: %c to exit, %c to move forward, %c to move backward, %c to "
         "rotate to left, %c to rotate to right!\n\n",
         'q', '+', '-', '*', '/');
  print_world();
  scanf("%c", &c);
  while (c != 'q') {
    switch (c) {
    case '+':
      move_robot(1);
      print_world();
      break;
    case '-':
      move_robot(-1);
      print_world();
      break;
    case '*':
      rotate_90_left();
      print_world();
      break;
    case '/':
      rotate_90_right();
      print_world();
      break;
    }
    scanf("%c", &c);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1050 <init_robot@plt>
mov    0x2e4b(%rip),%rax
mov    (%rax),%edi
call   1060 <fflush@plt>
lea    0xe6d(%rip),%rdi
mov    $0x71,%esi
mov    $0x2b,%edx
mov    $0x2d,%ecx
mov    $0x2a,%r8d
mov    $0x2f,%r9d
call   1040 <printf@plt>
mov    $0x0,%al
call   1030 <print_world@plt>
lea    0xeaa(%rip),%rdi
lea    -0x5(%rbp),%rsi
call   1070 <scanf@plt>
movsbl -0x5(%rbp),%eax
cmp    $0x71,%eax
je     127b <main+0xfb>
movsbl -0x5(%rbp),%eax
add    $0xffffffd6,%eax
mov    %eax,%ecx
mov    %rcx,-0x10(%rbp)
sub    $0x5,%eax
ja     1266 <main+0xe6>
mov    -0x10(%rbp),%rax
lea    0xdf0(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    $0x1,%edi
call   1090 <move_robot@plt>
mov    $0x0,%al
call   1030 <print_world@plt>
jmp    1266 <main+0xe6>
mov    $0xffffffff,%edi
call   1090 <move_robot@plt>
mov    $0x0,%al
call   1030 <print_world@plt>
jmp    1266 <main+0xe6>
mov    $0x0,%al
call   10a0 <rotate_90_left@plt>
mov    $0x0,%al
call   1030 <print_world@plt>
jmp    1266 <main+0xe6>
mov    $0x0,%al
call   1080 <rotate_90_right@plt>
mov    $0x0,%al
call   1030 <print_world@plt>
lea    0xe16(%rip),%rdi
lea    -0x5(%rbp),%rsi
call   1070 <scanf@plt>
jmp    11e2 <main+0x62>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
xor    %eax,%eax
call   1050 <init_robot@plt>
mov    0x2e51(%rip),%rax
mov    (%rax),%edi
call   1060 <fflush@plt>
lea    0xe73(%rip),%rdi
mov    $0x71,%esi
mov    $0x2b,%edx
mov    $0x2d,%ecx
mov    $0x2a,%r8d
mov    $0x2f,%r9d
call   1040 <printf@plt>
xor    %eax,%eax
call   1030 <print_world@plt>
lea    0xeb0(%rip),%rdi
lea    0xf(%rsp),%rsi
call   1070 <scanf@plt>
mov    0xf(%rsp),%al
cmp    $0x71,%al
jne    11f1 <main+0x71>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret
lea    0xe8b(%rip),%r14
lea    0xf(%rsp),%r15
lea    0xdfc(%rip),%rbx
jmp    1232 <main+0xb2>
cs nopw 0x0(%rax,%rax,1)
xor    %eax,%eax
call   1080 <rotate_90_right@plt>
xor    %eax,%eax
call   1030 <print_world@plt>
mov    %r14,%rdi
mov    %r15,%rsi
call   1070 <scanf@plt>
movzbl 0xf(%rsp),%eax
cmp    $0x71,%al
je     11e5 <main+0x65>
movsbl %al,%eax
add    $0xffffffd6,%eax
cmp    $0x5,%eax
ja     121e <main+0x9e>
movslq (%rbx,%rax,4),%rax
add    %rbx,%rax
jmp    *%rax
xor    %eax,%eax
call   10a0 <rotate_90_left@plt>
jmp    1217 <main+0x97>
nop
mov    $0x1,%edi
call   1090 <move_robot@plt>
jmp    1217 <main+0x97>
nopl   0x0(%rax)
mov    $0xffffffff,%edi
call   1090 <move_robot@plt>
jmp    1217 <main+0x97>

LLVM IR (-O0):
@stdin = global i32 0
@.str = [107 x i8] c"Usage: %c to exit, %c to move forward, %c to move backward, %c to rotate to left, %c to rotate to right!\0A\0A\00"
@.str.1 = [3 x i8] c"%c\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8
store i32 0, i32* %1
%3 = call i32 (...) @init_robot()
%4 = load i32, i32* @stdin
%5 = call i32 @fflush(i32 %4)
%6 = call i32 @printf(i8* getelementptr inbounds ([107 x i8], [107 x i8]* @.str, i64 0, i64 0), i8 signext 113, i8 signext 43, i8 signext 45, i8 signext 42, i8 signext 47)
%7 = call i32 (...) @print_world()
%8 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %2)
br label %9
9: ; preds = %28, %0
%10 = load i8, i8* %2
%11 = sext i8 %10 to i32
%12 = icmp ne i32 %11, 113
br i1 %12, label %13, label %30
13: ; preds = %9
%14 = load i8, i8* %2
%15 = sext i8 %14 to i32
switch i32 %15, label %28 [
i32 43, label %16
i32 45, label %19
i32 42, label %22
i32 47, label %25
]
16: ; preds = %13
%17 = call i32 @move_robot(i32 1)
%18 = call i32 (...) @print_world()
br label %28
19: ; preds = %13
%20 = call i32 @move_robot(i32 -1)
%21 = call i32 (...) @print_world()
br label %28
22: ; preds = %13
%23 = call i32 (...) @rotate_90_left()
%24 = call i32 (...) @print_world()
br label %28
25: ; preds = %13
%26 = call i32 (...) @rotate_90_right()
%27 = call i32 (...) @print_world()
br label %28
28: ; preds = %13, %25, %22, %19, %16
%29 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %2)
br label %9
30: ; preds = %9
ret i32 0
}

LLVM IR (-O2):
@stdin = global i32 0
@.str = [107 x i8] c"Usage: %c to exit, %c to move forward, %c to move backward, %c to rotate to left, %c to rotate to right!\0A\0A\00"
@.str.1 = [3 x i8] c"%c\00"
define i32 @main() {
%1 = alloca i8
%2 = tail call i32 (...) @init_robot()
%3 = load i32, i32* @stdin
%4 = tail call i32 @fflush(i32 %3)
%5 = tail call i32 @printf(i8* getelementptr inbounds ([107 x i8], [107 x i8]* @.str, i64 0, i64 0), i8 signext 113, i8 signext 43, i8 signext 45, i8 signext 42, i8 signext 47)
%6 = tail call i32 (...) @print_world()
%7 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %1)
%8 = load i8, i8* %1
%9 = icmp eq i8 %8, 113
br i1 %9, label %27, label %10
10: ; preds = %0, %23
%11 = phi i8 [ %25, %23 ], [ %8, %0 ]
%12 = sext i8 %11 to i32
switch i32 %12, label %23 [
i32 43, label %13
i32 45, label %15
i32 42, label %17
i32 47, label %19
]
13: ; preds = %10
%14 = call i32 @move_robot(i32 1)
br label %21
15: ; preds = %10
%16 = call i32 @move_robot(i32 -1)
br label %21
17: ; preds = %10
%18 = call i32 (...) @rotate_90_left()
br label %21
19: ; preds = %10
%20 = call i32 (...) @rotate_90_right()
br label %21
21: ; preds = %13, %15, %17, %19
%22 = call i32 (...) @print_world()
br label %23
23: ; preds = %21, %10
%24 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %1)
%25 = load i8, i8* %1
%26 = icmp eq i8 %25, 113
br i1 %26, label %27, label %10
27: ; preds = %23, %0
ret i32 0
}