#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 */
typedef int /*<<< orphan*/ buf;

/* Variables and functions */
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *);
int sscanf(char *, char *, int *, int *);
int /*<<< orphan*/ stdin;
int /*<<< orphan*/ strcpy(char *, char *);
scalar_t__ strstr(char *, char *);
int readmove(int *from, int *to, char *command) {
  char buf[64];
  printf("\nEnter your move ? ");
  fgets(buf, sizeof(buf), stdin);
  if (sscanf(buf, "%d-%d", from, to) == 2)
    return 1;
  else if (sscanf(buf, "%dx%d", from, to) == 2)
    return 2;
  else if (strstr(buf, "save"))
    return -1;
  else if (strstr(buf, "new"))
    return -2;
  else if (strstr(buf, "part"))
    return -3;
  else if (strstr(buf, "quit") || strstr(buf, "exit"))
    return -4;
  strcpy(command, buf);
  return 3;
}


x86 assembly (clang, -O0):
<readmove>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
lea    0xe95(%rip),%rdi
call   1040 <printf@plt>
lea    -0x60(%rbp),%rdi
mov    0x2e6d(%rip),%rax
mov    (%rax),%edx
mov    $0x40,%esi
call   1050 <fgets@plt>
lea    -0x60(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    -0x18(%rbp),%rcx
lea    0xe7a(%rip),%rsi
call   1060 <sscanf@plt>
cmp    $0x2,%eax
jne    11b4 <readmove+0x64>
movl   $0x1,-0x4(%rbp)
jmp    12c0 <readmove+0x170>
lea    -0x60(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    -0x18(%rbp),%rcx
lea    0xe53(%rip),%rsi
call   1060 <sscanf@plt>
cmp    $0x2,%eax
jne    11e1 <readmove+0x91>
movl   $0x2,-0x4(%rbp)
jmp    12c0 <readmove+0x170>
lea    -0x60(%rbp),%rdi
lea    0xe34(%rip),%rsi
call   1070 <strstr@plt>
cmp    $0x0,%rax
je     1207 <readmove+0xb7>
movl   $0xffffffff,-0x4(%rbp)
jmp    12c0 <readmove+0x170>
lea    -0x60(%rbp),%rdi
lea    0xe13(%rip),%rsi
call   1070 <strstr@plt>
cmp    $0x0,%rax
je     122d <readmove+0xdd>
movl   $0xfffffffe,-0x4(%rbp)
jmp    12c0 <readmove+0x170>
lea    -0x60(%rbp),%rdi
lea    0xdf1(%rip),%rsi
call   1070 <strstr@plt>
cmp    $0x0,%rax
je     1253 <readmove+0x103>
movl   $0xfffffffd,-0x4(%rbp)
jmp    12c0 <readmove+0x170>
lea    -0x60(%rbp),%rdi
lea    0xdd0(%rip),%rsi
call   1070 <strstr@plt>
cmp    $0x0,%rax
jne    1287 <readmove+0x137>
lea    -0x60(%rbp),%rdi
lea    0xdbb(%rip),%rsi
call   1070 <strstr@plt>
cmp    $0x0,%rax
je     1293 <readmove+0x143>
movl   $0xfffffffc,-0x4(%rbp)
jmp    12c0 <readmove+0x170>
jmp    1298 <readmove+0x148>
jmp    129d <readmove+0x14d>
jmp    12a2 <readmove+0x152>
jmp    12a7 <readmove+0x157>
jmp    12ac <readmove+0x15c>
mov    -0x20(%rbp),%rdi
lea    -0x60(%rbp),%rsi
call   1030 <strcpy@plt>
movl   $0x3,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<readmove>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x48,%rsp
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%rbx
lea    0xe96(%rip),%rdi
call   1040 <printf@plt>
mov    0x2e72(%rip),%rax
mov    (%rax),%edx
mov    %rsp,%rbp
mov    %rbp,%rdi
mov    $0x40,%esi
call   1050 <fgets@plt>
lea    0xe85(%rip),%rsi
mov    %rbp,%rdi
mov    %rbx,%rdx
mov    %r15,%rcx
call   1060 <sscanf@plt>
mov    $0x1,%ebp
cmp    $0x2,%eax
je     1256 <readmove+0x106>
lea    0xe68(%rip),%rsi
mov    %rsp,%rdi
mov    %rbx,%rdx
mov    %r15,%rcx
call   1060 <sscanf@plt>
mov    $0x2,%ebp
cmp    $0x2,%eax
je     1256 <readmove+0x106>
lea    0xe4b(%rip),%rsi
mov    %rsp,%rdi
call   1070 <strstr@plt>
mov    $0xffffffff,%ebp
test   %rax,%rax
jne    1256 <readmove+0x106>
lea    0xe37(%rip),%rsi
mov    %rsp,%rdi
call   1070 <strstr@plt>
mov    $0xfffffffe,%ebp
test   %rax,%rax
jne    1256 <readmove+0x106>
lea    0xe22(%rip),%rsi
mov    %rsp,%rdi
call   1070 <strstr@plt>
mov    $0xfffffffd,%ebp
test   %rax,%rax
jne    1256 <readmove+0x106>
lea    0xe0e(%rip),%rsi
mov    %rsp,%rdi
call   1070 <strstr@plt>
mov    $0xfffffffc,%ebp
test   %rax,%rax
jne    1256 <readmove+0x106>
lea    0xdfa(%rip),%rsi
mov    %rsp,%rdi
call   1070 <strstr@plt>
test   %rax,%rax
jne    1256 <readmove+0x106>
mov    %rsp,%rsi
mov    %r14,%rdi
call   1030 <strcpy@plt>
mov    $0x3,%ebp
mov    %ebp,%eax
add    $0x48,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [20 x i8] c"\0AEnter your move ? \00"
@stdin = global i32 0
@.str.1 = [6 x i8] c"%d-%d\00"
@.str.2 = [6 x i8] c"%dx%d\00"
@.str.3 = [5 x i8] c"save\00"
@.str.4 = [4 x i8] c"new\00"
@.str.5 = [5 x i8] c"part\00"
@.str.6 = [5 x i8] c"quit\00"
@.str.7 = [5 x i8] c"exit\00"
define i32 @readmove(i32* %0, i32* %1, i8* %2) {
%4 = alloca i32
%5 = alloca i32*
%6 = alloca i32*
%7 = alloca i8*
%8 = alloca [64 x i8]
store i32* %0, i32** %5
store i32* %1, i32** %6
store i8* %2, i8** %7
%9 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
%10 = getelementptr inbounds [64 x i8], [64 x i8]* %8, i64 0, i64 0
%11 = load i32, i32* @stdin
%12 = call i32 @fgets(i8* %10, i32 64, i32 %11)
%13 = getelementptr inbounds [64 x i8], [64 x i8]* %8, i64 0, i64 0
%14 = load i32*, i32** %5
%15 = load i32*, i32** %6
%16 = call i32 @sscanf(i8* %13, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32* %14, i32* %15)
%17 = icmp eq i32 %16, 2
br i1 %17, label %18, label %19
18: ; preds = %3
store i32 1, i32* %4
br label %59
19: ; preds = %3
%20 = getelementptr inbounds [64 x i8], [64 x i8]* %8, i64 0, i64 0
%21 = load i32*, i32** %5
%22 = load i32*, i32** %6
%23 = call i32 @sscanf(i8* %20, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32* %21, i32* %22)
%24 = icmp eq i32 %23, 2
br i1 %24, label %25, label %26
25: ; preds = %19
store i32 2, i32* %4
br label %59
26: ; preds = %19
%27 = getelementptr inbounds [64 x i8], [64 x i8]* %8, i64 0, i64 0
%28 = call i64 @strstr(i8* %27, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
%29 = icmp ne i64 %28, 0
br i1 %29, label %30, label %31
30: ; preds = %26
store i32 -1, i32* %4
br label %59
31: ; preds = %26
%32 = getelementptr inbounds [64 x i8], [64 x i8]* %8, i64 0, i64 0
%33 = call i64 @strstr(i8* %32, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0))
%34 = icmp ne i64 %33, 0
br i1 %34, label %35, label %36
35: ; preds = %31
store i32 -2, i32* %4
br label %59
36: ; preds = %31
%37 = getelementptr inbounds [64 x i8], [64 x i8]* %8, i64 0, i64 0
%38 = call i64 @strstr(i8* %37, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0))
%39 = icmp ne i64 %38, 0
br i1 %39, label %40, label %41
40: ; preds = %36
store i32 -3, i32* %4
br label %59
41: ; preds = %36
%42 = getelementptr inbounds [64 x i8], [64 x i8]* %8, i64 0, i64 0
%43 = call i64 @strstr(i8* %42, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0))
%44 = icmp ne i64 %43, 0
br i1 %44, label %49, label %45
45: ; preds = %41
%46 = getelementptr inbounds [64 x i8], [64 x i8]* %8, i64 0, i64 0
%47 = call i64 @strstr(i8* %46, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0))
%48 = icmp ne i64 %47, 0
br i1 %48, label %49, label %50
49: ; preds = %45, %41
store i32 -4, i32* %4
br label %59
50: ; preds = %45
br label %51
51: ; preds = %50
br label %52
52: ; preds = %51
br label %53
53: ; preds = %52
br label %54
54: ; preds = %53
br label %55
55: ; preds = %54
%56 = load i8*, i8** %7
%57 = getelementptr inbounds [64 x i8], [64 x i8]* %8, i64 0, i64 0
%58 = call i32 @strcpy(i8* %56, i8* %57)
store i32 3, i32* %4
br label %59
59: ; preds = %55, %49, %40, %35, %30, %25, %18
%60 = load i32, i32* %4
ret i32 %60
}

LLVM IR (-O2):
@.str = [20 x i8] c"\0AEnter your move ? \00"
@stdin = global i32 0
@.str.1 = [6 x i8] c"%d-%d\00"
@.str.2 = [6 x i8] c"%dx%d\00"
@.str.3 = [5 x i8] c"save\00"
@.str.4 = [4 x i8] c"new\00"
@.str.5 = [5 x i8] c"part\00"
@.str.6 = [5 x i8] c"quit\00"
@.str.7 = [5 x i8] c"exit\00"
define i32 @readmove(i32* %0, i32* %1, i8* %2) {
%4 = alloca [64 x i8]
%5 = getelementptr inbounds [64 x i8], [64 x i8]* %4, i64 0, i64 0
%6 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
%7 = load i32, i32* @stdin
%8 = call i32 @fgets(i8* %5, i32 64, i32 %7)
%9 = call i32 @sscanf(i8* %5, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32* %0, i32* %1)
%10 = icmp eq i32 %9, 2
br i1 %10, label %31, label %11
11: ; preds = %3
%12 = call i32 @sscanf(i8* %5, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32* %0, i32* %1)
%13 = icmp eq i32 %12, 2
br i1 %13, label %31, label %14
14: ; preds = %11
%15 = call i64 @strstr(i8* %5, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
%16 = icmp eq i64 %15, 0
br i1 %16, label %17, label %31
17: ; preds = %14
%18 = call i64 @strstr(i8* %5, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0))
%19 = icmp eq i64 %18, 0
br i1 %19, label %20, label %31
20: ; preds = %17
%21 = call i64 @strstr(i8* %5, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0))
%22 = icmp eq i64 %21, 0
br i1 %22, label %23, label %31
23: ; preds = %20
%24 = call i64 @strstr(i8* %5, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0))
%25 = icmp eq i64 %24, 0
br i1 %25, label %26, label %31
26: ; preds = %23
%27 = call i64 @strstr(i8* %5, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0))
%28 = icmp eq i64 %27, 0
br i1 %28, label %29, label %31
29: ; preds = %26
%30 = call i32 @strcpy(i8* %2, i8* %5)
br label %31
31: ; preds = %23, %26, %20, %17, %14, %11, %3, %29
%32 = phi i32 [ 3, %29 ], [ 1, %3 ], [ 2, %11 ], [ -1, %14 ], [ -2, %17 ], [ -3, %20 ], [ -4, %26 ], [ -4, %23 ]
ret i32 %32
}