#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*/ printf(char *);
int /*<<< orphan*/ scanf(char *, char *);
int strlen(char *);
int main(void) {
  int city[6][2] = {{1, 2}, {-1, 3}, {1, -1}, {4, 5}, {5, 2}, {2, 1}}, i, now;
  char route[100];
  while (1) {
    scanf(" %s\n", route);
    if (route[0] == '#')
      break;
    now = 0;
    for (i = 0; i < strlen(route) && now != -1; i++) {
      now = city[now][route[i] - '0'];
    }
    if (now == 5) {
      printf("Yes\n");
    } else {
      printf("No\n");
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xc0,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x40(%rbp),%rdi
lea    0xea3(%rip),%rsi
mov    $0x30,%edx
call   1050 <memcpy@plt>
lea    -0xb0(%rbp),%rsi
lea    0xebb(%rip),%rdi
call   1060 <scanf@plt>
movsbl -0xb0(%rbp),%eax
cmp    $0x23,%eax
jne    118f <main+0x4f>
jmp    124b <main+0x10b>
movl   $0x0,-0x48(%rbp)
movl   $0x0,-0x44(%rbp)
mov    -0x44(%rbp),%eax
mov    %eax,-0xb8(%rbp)
lea    -0xb0(%rbp),%rdi
call   1030 <strlen@plt>
mov    -0xb8(%rbp),%ecx
mov    %eax,%edx
xor    %eax,%eax
cmp    %edx,%ecx
mov    %al,-0xb1(%rbp)
jge    11d7 <main+0x97>
cmpl   $0xffffffff,-0x48(%rbp)
setne  %al
mov    %al,-0xb1(%rbp)
mov    -0xb1(%rbp),%al
test   $0x1,%al
jne    11ea <main+0xaa>
jmp    121f <main+0xdf>
movslq -0x48(%rbp),%rcx
lea    -0x40(%rbp),%rax
shl    $0x3,%rcx
add    %rcx,%rax
movslq -0x44(%rbp),%rcx
movsbl -0xb0(%rbp,%rcx,1),%ecx
ff
sub    $0x30,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,4),%eax
mov    %eax,-0x48(%rbp)
mov    -0x44(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x44(%rbp)
jmp    119d <main+0x5d>
cmpl   $0x5,-0x48(%rbp)
jne    123a <main+0xfa>
lea    0xe05(%rip),%rdi
call   1040 <printf@plt>
jmp    1246 <main+0x106>
lea    0xdf9(%rip),%rdi
call   1040 <printf@plt>
jmp    1167 <main+0x27>
xor    %eax,%eax
add    $0xc0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x68,%rsp
lea    0xeeb(%rip),%rdi
mov    %rsp,%rsi
call   1050 <scanf@plt>
cmpb   $0x23,(%rsp)
jne    1164 <main+0x34>
xor    %eax,%eax
add    $0x68,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %rsp,%rbx
lea    0xe92(%rip),%r15
lea    0xebb(%rip),%r14
lea    0xeb9(%rip),%r13
jmp    1199 <main+0x69>
xchg   %ax,%ax
mov    %r13,%rdi
call   1030 <puts@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1050 <scanf@plt>
cmpb   $0x23,(%rsp)
je     1153 <main+0x23>
mov    %rbx,%rdi
call   1040 <strlen@plt>
test   %eax,%eax
jle    1180 <main+0x50>
xor    %ebp,%ebp
mov    $0x1,%r12d
nopl   (%rax)
movslq %ebp,%rax
movsbq -0x1(%rsp,%r12,1),%rcx
lea    (%r15,%rax,8),%rax
mov    -0xc0(%rax,%rcx,4),%ebp
mov    %rbx,%rdi
call   1040 <strlen@plt>
cltq
cmp    %rax,%r12
jge    11dc <main+0xac>
add    $0x1,%r12
cmp    $0xffffffff,%ebp
jne    11b0 <main+0x80>
lea    0xe55(%rip),%rdi
cmp    $0x5,%ebp
jne    1180 <main+0x50>
jmp    1183 <main+0x53>

LLVM IR (-O0):
@__const.main.city = [6 x [2 x i32]] [[2 x i32] [i32 1, i32 2], [2 x i32] [i32 -1, i32 3], [2 x i32] [i32 1, i32 -1], [2 x i32] [i32 4, i32 5], [2 x i32] [i32 5, i32 2], [2 x i32] [i32 2, i32 1]]
@.str = [5 x i8] c" %s\0A\00"
@.str.1 = [5 x i8] c"Yes\0A\00"
@.str.2 = [4 x i8] c"No\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [6 x [2 x i32]]
%3 = alloca i32
%4 = alloca i32
%5 = alloca [100 x i8]
store i32 0, i32* %1
%6 = bitcast [6 x [2 x i32]]* %2 to i8*
br label %7
7: ; preds = %0, %49
%8 = getelementptr inbounds [100 x i8], [100 x i8]* %5, i64 0, i64 0
%9 = call i32 @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* %8)
%10 = getelementptr inbounds [100 x i8], [100 x i8]* %5, i64 0, i64 0
%11 = load i8, i8* %10
%12 = sext i8 %11 to i32
%13 = icmp eq i32 %12, 35
br i1 %13, label %14, label %15
14: ; preds = %7
br label %50
15: ; preds = %7
store i32 0, i32* %4
store i32 0, i32* %3
br label %16
16: ; preds = %39, %15
%17 = load i32, i32* %3
%18 = getelementptr inbounds [100 x i8], [100 x i8]* %5, i64 0, i64 0
%19 = call i32 @strlen(i8* %18)
%20 = icmp slt i32 %17, %19
br i1 %20, label %21, label %24
21: ; preds = %16
%22 = load i32, i32* %4
%23 = icmp ne i32 %22, -1
br label %24
24: ; preds = %21, %16
%25 = phi i1 [ false, %16 ], [ %23, %21 ]
br i1 %25, label %26, label %42
26: ; preds = %24
%27 = load i32, i32* %4
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds [6 x [2 x i32]], [6 x [2 x i32]]* %2, i64 0, i64 %28
%30 = load i32, i32* %3
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds [100 x i8], [100 x i8]* %5, i64 0, i64 %31
%33 = load i8, i8* %32
%34 = sext i8 %33 to i32
%35 = sub nsw i32 %34, 48
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds [2 x i32], [2 x i32]* %29, i64 0, i64 %36
%38 = load i32, i32* %37
store i32 %38, i32* %4
br label %39
39: ; preds = %26
%40 = load i32, i32* %3
%41 = add nsw i32 %40, 1
store i32 %41, i32* %3
br label %16
42: ; preds = %24
%43 = load i32, i32* %4
%44 = icmp eq i32 %43, 5
br i1 %44, label %45, label %47
45: ; preds = %42
%46 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
br label %49
47: ; preds = %42
%48 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
br label %49
49: ; preds = %47, %45
br label %7
50: ; preds = %14
ret i32 0
}

LLVM IR (-O2):
@__const.main.city = [6 x [2 x i32]] [[2 x i32] [i32 1, i32 2], [2 x i32] [i32 -1, i32 3], [2 x i32] [i32 1, i32 -1], [2 x i32] [i32 4, i32 5], [2 x i32] [i32 5, i32 2], [2 x i32] [i32 2, i32 1]]
@.str = [5 x i8] c" %s\0A\00"
@str = [3 x i8] c"No\00"
@str.3 = [4 x i8] c"Yes\00"
define i32 @main() {
%1 = alloca [100 x i8]
%2 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 0
%3 = call i32 @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* %2)
%4 = load i8, i8* %2
%5 = icmp eq i8 %4, 35
br i1 %5, label %34, label %6
6: ; preds = %0, %28
%7 = call i32 @strlen(i8* %2)
%8 = icmp sgt i32 %7, 0
br i1 %8, label %9, label %27
9: ; preds = %6, %9
%10 = phi i64 [ %19, %9 ], [ 0, %6 ]
%11 = phi i32 [ %18, %9 ], [ 0, %6 ]
%12 = sext i32 %11 to i64
%13 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 %10
%14 = load i8, i8* %13
%15 = sext i8 %14 to i64
%16 = add nsw i64 %15, -48
%17 = getelementptr inbounds [6 x [2 x i32]], [6 x [2 x i32]]* @__const.main.city, i64 0, i64 %12, i64 %16
%18 = load i32, i32* %17
%19 = add nuw nsw i64 %10, 1
%20 = call i32 @strlen(i8* %2)
%21 = sext i32 %20 to i64
%22 = icmp slt i64 %19, %21
%23 = icmp ne i32 %18, -1
%24 = select i1 %22, i1 %23, i1 false
br i1 %24, label %9, label %25
25: ; preds = %9
%26 = icmp eq i32 %18, 5
br i1 %26, label %28, label %27
27: ; preds = %6, %25
br label %28
28: ; preds = %25, %27
%29 = phi i8* [ getelementptr inbounds ([3 x i8], [3 x i8]* @str, i64 0, i64 0), %27 ], [ getelementptr inbounds ([4 x i8], [4 x i8]* @str.3, i64 0, i64 0), %25 ]
%30 = call i32 @puts(i8* dereferenceable(1) %29)
%31 = call i32 @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* %2)
%32 = load i8, i8* %2
%33 = icmp eq i8 %32, 35
br i1 %33, label %34, label %6
34: ; preds = %28, %0
ret i32 0
}