#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*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, char *);
int /*<<< orphan*/ stdout;
scalar_t__ strcmp(char *, char *);
int main() {
  char response[10];
  int width, height;
  do {
    printf("left\n");
    fflush(stdout);
    scanf("%s", response);
  } while (strcmp(response, "fail") != 0);
  width = 0;
  do {
    ++width;
    printf("right\n");
    fflush(stdout);
    scanf("%s", response);
  } while (strcmp(response, "fail") != 0);
  do {
    printf("up\n");
    fflush(stdout);
    scanf("%s", response);
  } while (strcmp(response, "fail") != 0);
  height = 0;
  do {
    ++height;
    printf("down\n");
    fflush(stdout);
    scanf("%s", response);
  } while (strcmp(response, "fail") != 0);
  printf("%d\n", width * height);
  fflush(stdout);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeaa(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    0x2e7c(%rip),%rax
mov    (%rax),%edi
call   1050 <fflush@plt>
lea    -0xe(%rbp),%rsi
lea    0xe90(%rip),%rdi
call   1060 <scanf@plt>
lea    -0xe(%rbp),%rdi
lea    0xe83(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    114f <main+0xf>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
lea    0xe62(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    0x2e26(%rip),%rax
mov    (%rax),%edi
call   1050 <fflush@plt>
lea    -0xe(%rbp),%rsi
lea    0xe3a(%rip),%rdi
call   1060 <scanf@plt>
lea    -0xe(%rbp),%rdi
lea    0xe2d(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    119c <main+0x5c>
jmp    11f0 <main+0xb0>
lea    0xe1e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    0x2ddb(%rip),%rax
mov    (%rax),%edi
call   1050 <fflush@plt>
lea    -0xe(%rbp),%rsi
lea    0xdef(%rip),%rdi
call   1060 <scanf@plt>
lea    -0xe(%rbp),%rdi
lea    0xde2(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    11f0 <main+0xb0>
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
lea    0xdcc(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    0x2d85(%rip),%rax
mov    (%rax),%edi
call   1050 <fflush@plt>
lea    -0xe(%rbp),%rsi
lea    0xd99(%rip),%rdi
call   1060 <scanf@plt>
lea    -0xe(%rbp),%rdi
lea    0xd8c(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    123d <main+0xfd>
mov    -0x14(%rbp),%esi
imul   -0x18(%rbp),%esi
lea    0xd85(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    0x2d38(%rip),%rax
mov    (%rax),%edi
call   1050 <fflush@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
lea    0xea7(%rip),%r14
mov    0x2e74(%rip),%rbp
lea    0xe8d(%rip),%r15
lea    0xe(%rsp),%rbx
lea    0xe84(%rip),%r12
nop
mov    %r14,%rdi
call   1030 <puts@plt>
mov    0x0(%rbp),%edi
call   1060 <fflush@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1070 <scanf@plt>
mov    %rbx,%rdi
mov    %r12,%rsi
call   1050 <strcmp@plt>
test   %rax,%rax
jne    1180 <main+0x30>
xor    %r13d,%r13d
lea    0xe5c(%rip),%r14
lea    0xe44(%rip),%r15
lea    0xe(%rsp),%rbx
lea    0xe3b(%rip),%r12
nopl   0x0(%rax,%rax,1)
add    $0x1,%r13d
mov    %r14,%rdi
call   1030 <puts@plt>
mov    0x0(%rbp),%edi
call   1060 <fflush@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1070 <scanf@plt>
mov    %rbx,%rdi
mov    %r12,%rsi
call   1050 <strcmp@plt>
test   %rax,%rax
jne    11d0 <main+0x80>
lea    0xe11(%rip),%r14
lea    0xdf3(%rip),%r15
lea    0xe(%rsp),%rbx
lea    0xdea(%rip),%r12
nopl   0x0(%rax)
mov    %r14,%rdi
call   1030 <puts@plt>
mov    0x0(%rbp),%edi
call   1060 <fflush@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1070 <scanf@plt>
mov    %rbx,%rdi
mov    %r12,%rsi
call   1050 <strcmp@plt>
test   %rax,%rax
jne    1220 <main+0xd0>
xor    %ebx,%ebx
lea    0xdac(%rip),%r15
lea    0xe(%rsp),%r12
lea    0xda3(%rip),%r14
lea    0xdb3(%rip),%rdi
call   1030 <puts@plt>
mov    0x0(%rbp),%edi
call   1060 <fflush@plt>
mov    %r15,%rdi
mov    %r12,%rsi
call   1070 <scanf@plt>
mov    %r12,%rdi
mov    %r14,%rsi
call   1050 <strcmp@plt>
add    %r13d,%ebx
test   %rax,%rax
jne    1260 <main+0x110>
lea    0xd6f(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x0(%rbp),%edi
call   1060 <fflush@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [6 x i8] c"left\0A\00"
@stdout = global i32 0
@.str.1 = [3 x i8] c"%s\00"
@.str.2 = [5 x i8] c"fail\00"
@.str.3 = [7 x i8] c"right\0A\00"
@.str.4 = [4 x i8] c"up\0A\00"
@.str.5 = [6 x i8] c"down\0A\00"
@.str.6 = [4 x i8] c"%d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [10 x i8]
%3 = alloca i32
%4 = alloca i32
store i32 0, i32* %1
br label %5
5: ; preds = %11, %0
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%7 = load i32, i32* @stdout
%8 = call i32 @fflush(i32 %7)
%9 = getelementptr inbounds [10 x i8], [10 x i8]* %2, i64 0, i64 0
%10 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %9)
br label %11
11: ; preds = %5
%12 = getelementptr inbounds [10 x i8], [10 x i8]* %2, i64 0, i64 0
%13 = call i64 @strcmp(i8* %12, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%14 = icmp ne i64 %13, 0
br i1 %14, label %5, label %15
15: ; preds = %11
store i32 0, i32* %3
br label %16
16: ; preds = %24, %15
%17 = load i32, i32* %3
%18 = add nsw i32 %17, 1
store i32 %18, i32* %3
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
%20 = load i32, i32* @stdout
%21 = call i32 @fflush(i32 %20)
%22 = getelementptr inbounds [10 x i8], [10 x i8]* %2, i64 0, i64 0
%23 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %22)
br label %24
24: ; preds = %16
%25 = getelementptr inbounds [10 x i8], [10 x i8]* %2, i64 0, i64 0
%26 = call i64 @strcmp(i8* %25, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%27 = icmp ne i64 %26, 0
br i1 %27, label %16, label %28
28: ; preds = %24
br label %29
29: ; preds = %35, %28
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0))
%31 = load i32, i32* @stdout
%32 = call i32 @fflush(i32 %31)
%33 = getelementptr inbounds [10 x i8], [10 x i8]* %2, i64 0, i64 0
%34 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %33)
br label %35
35: ; preds = %29
%36 = getelementptr inbounds [10 x i8], [10 x i8]* %2, i64 0, i64 0
%37 = call i64 @strcmp(i8* %36, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%38 = icmp ne i64 %37, 0
br i1 %38, label %29, label %39
39: ; preds = %35
store i32 0, i32* %4
br label %40
40: ; preds = %48, %39
%41 = load i32, i32* %4
%42 = add nsw i32 %41, 1
store i32 %42, i32* %4
%43 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0))
%44 = load i32, i32* @stdout
%45 = call i32 @fflush(i32 %44)
%46 = getelementptr inbounds [10 x i8], [10 x i8]* %2, i64 0, i64 0
%47 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %46)
br label %48
48: ; preds = %40
%49 = getelementptr inbounds [10 x i8], [10 x i8]* %2, i64 0, i64 0
%50 = call i64 @strcmp(i8* %49, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%51 = icmp ne i64 %50, 0
br i1 %51, label %40, label %52
52: ; preds = %48
%53 = load i32, i32* %3
%54 = load i32, i32* %4
%55 = mul nsw i32 %53, %54
%56 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), i32 %55)
%57 = load i32, i32* @stdout
%58 = call i32 @fflush(i32 %57)
ret i32 0
}

LLVM IR (-O2):
@stdout = global i32 0
@.str.1 = [3 x i8] c"%s\00"
@.str.2 = [5 x i8] c"fail\00"
@.str.6 = [4 x i8] c"%d\0A\00"
@str = [5 x i8] c"left\00"
@str.7 = [6 x i8] c"right\00"
@str.8 = [3 x i8] c"up\00"
@str.9 = [5 x i8] c"down\00"
define i32 @main() {
%1 = alloca [10 x i8]
%2 = getelementptr inbounds [10 x i8], [10 x i8]* %1, i64 0, i64 0
br label %3
3: ; preds = %3, %0
%4 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @str, i64 0, i64 0))
%5 = load i32, i32* @stdout
%6 = call i32 @fflush(i32 %5)
%7 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %2)
%8 = call i64 @strcmp(i8* %2, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%9 = icmp eq i64 %8, 0
br i1 %9, label %10, label %3
10: ; preds = %3, %10
%11 = phi i32 [ %12, %10 ], [ 0, %3 ]
%12 = add nuw nsw i32 %11, 1
%13 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @str.7, i64 0, i64 0))
%14 = load i32, i32* @stdout
%15 = call i32 @fflush(i32 %14)
%16 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %2)
%17 = call i64 @strcmp(i8* %2, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%18 = icmp eq i64 %17, 0
br i1 %18, label %19, label %10
19: ; preds = %10, %19
%20 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @str.8, i64 0, i64 0))
%21 = load i32, i32* @stdout
%22 = call i32 @fflush(i32 %21)
%23 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %2)
%24 = call i64 @strcmp(i8* %2, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%25 = icmp eq i64 %24, 0
br i1 %25, label %26, label %19
26: ; preds = %19, %26
%27 = phi i32 [ %28, %26 ], [ 0, %19 ]
%28 = add nuw nsw i32 %27, 1
%29 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @str.9, i64 0, i64 0))
%30 = load i32, i32* @stdout
%31 = call i32 @fflush(i32 %30)
%32 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %2)
%33 = call i64 @strcmp(i8* %2, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%34 = icmp eq i64 %33, 0
br i1 %34, label %35, label %26
35: ; preds = %26
%36 = mul nsw i32 %28, %12
%37 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), i32 %36)
%38 = load i32, i32* @stdout
%39 = call i32 @fflush(i32 %38)
ret i32 0
}