#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 *, int *);
int main() {
  int caminho;
  scanf("%d", &caminho);
  if (caminho == 1) {
    scanf("%d", &caminho);
    if (caminho == 4) {
      scanf("%d", &caminho);
      if (caminho == 6) {
        printf("Caminho válido\nDestino alcançado\n");
      } else {
        printf("Caminho inválido\n");
      }
    } else {
      printf("Caminho inválido\n");
    }
  } else if (caminho == 2) {
    printf("Caminho válido, mas o destino não foi alcançado\n");
  } else if (caminho == 3) {
    scanf("%d", &caminho);
    if (caminho == 5) {
      scanf("%d", &caminho);
      if (caminho == 7) {
        scanf("%d", &caminho);
        if (caminho == 8) {
          printf("Caminho válido\nDestino alcançado\n");
        } else {
          printf("Caminho inválido\n");
        }
      } else {
        printf("Caminho inválido\n");
      }
    } else {
      printf("Caminho inválido\n");
    }
  } else {
    printf("Caminho inválido\n");
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeca(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
cmpl   $0x1,-0x8(%rbp)
jne    11b0 <main+0x90>
lea    0xeb0(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
cmpl   $0x4,-0x8(%rbp)
jne    119f <main+0x7f>
lea    0xe96(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
cmpl   $0x6,-0x8(%rbp)
jne    118e <main+0x6e>
lea    0xe7f(%rip),%rdi
call   1030 <printf@plt>
jmp    119a <main+0x7a>
lea    0xe92(%rip),%rdi
call   1030 <printf@plt>
jmp    11ab <main+0x8b>
lea    0xe81(%rip),%rdi
call   1030 <printf@plt>
jmp    127d <main+0x15d>
cmpl   $0x2,-0x8(%rbp)
jne    11cb <main+0xab>
lea    0xe79(%rip),%rdi
call   1030 <printf@plt>
jmp    1278 <main+0x158>
cmpl   $0x3,-0x8(%rbp)
jne    1267 <main+0x147>
lea    0xe24(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
cmpl   $0x5,-0x8(%rbp)
jne    1256 <main+0x136>
lea    0xe0a(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
cmpl   $0x7,-0x8(%rbp)
jne    1245 <main+0x125>
lea    0xdf0(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
cmpl   $0x8,-0x8(%rbp)
jne    1234 <main+0x114>
lea    0xdd9(%rip),%rdi
call   1030 <printf@plt>
jmp    1240 <main+0x120>
lea    0xdec(%rip),%rdi
call   1030 <printf@plt>
jmp    1251 <main+0x131>
lea    0xddb(%rip),%rdi
call   1030 <printf@plt>
jmp    1262 <main+0x142>
lea    0xdca(%rip),%rdi
call   1030 <printf@plt>
jmp    1273 <main+0x153>
lea    0xdb9(%rip),%rdi
call   1030 <printf@plt>
jmp    1278 <main+0x158>
jmp    127d <main+0x15d>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
lea    0xed4(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1040 <scanf@plt>
mov    0xc(%rsp),%eax
cmp    $0x3,%eax
je     118b <main+0x6b>
cmp    $0x2,%eax
je     1182 <main+0x62>
cmp    $0x1,%eax
jne    1179 <main+0x59>
lea    0xeb0(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1040 <scanf@plt>
cmpl   $0x4,0xc(%rsp)
jne    1179 <main+0x59>
lea    0xe98(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1040 <scanf@plt>
cmpl   $0x6,0xc(%rsp)
jmp    11d8 <main+0xb8>
lea    0xeb6(%rip),%rbx
jmp    11ea <main+0xca>
lea    0xe7a(%rip),%rbx
jmp    11ea <main+0xca>
lea    0xe6e(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1040 <scanf@plt>
lea    0xe93(%rip),%rbx
cmpl   $0x5,0xc(%rsp)
jne    11ea <main+0xca>
lea    0xe4f(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1040 <scanf@plt>
cmpl   $0x7,0xc(%rsp)
jne    11ea <main+0xca>
lea    0xe37(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1040 <scanf@plt>
cmpl   $0x8,0xc(%rsp)
lea    0xe69(%rip),%rax
lea    0xe50(%rip),%rbx
cmove  %rax,%rbx
mov    %rbx,%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
@.str.1 = [36 x i8] c"Caminho v\C3\A1lido\0ADestino alcan\C3\A7ado\0A\00"
@.str.2 = [19 x i8] c"Caminho inv\C3\A1lido\0A\00"
@.str.3 = [52 x i8] c"Caminho v\C3\A1lido, mas o destino n\C3\A3o foi alcan\C3\A7ado\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
store i32 0, i32* %1
%3 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
%4 = load i32, i32* %2
%5 = icmp eq i32 %4, 1
br i1 %5, label %6, label %22
6: ; preds = %0
%7 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
%8 = load i32, i32* %2
%9 = icmp eq i32 %8, 4
br i1 %9, label %10, label %19
10: ; preds = %6
%11 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
%12 = load i32, i32* %2
%13 = icmp eq i32 %12, 6
br i1 %13, label %14, label %16
14: ; preds = %10
%15 = call i32 @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.1, i64 0, i64 0))
br label %18
16: ; preds = %10
%17 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0))
br label %18
18: ; preds = %16, %14
br label %21
19: ; preds = %6
%20 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0))
br label %21
21: ; preds = %19, %18
br label %57
22: ; preds = %0
%23 = load i32, i32* %2
%24 = icmp eq i32 %23, 2
br i1 %24, label %25, label %27
25: ; preds = %22
%26 = call i32 @printf(i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.3, i64 0, i64 0))
br label %56
27: ; preds = %22
%28 = load i32, i32* %2
%29 = icmp eq i32 %28, 3
br i1 %29, label %30, label %53
30: ; preds = %27
%31 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
%32 = load i32, i32* %2
%33 = icmp eq i32 %32, 5
br i1 %33, label %34, label %50
34: ; preds = %30
%35 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
%36 = load i32, i32* %2
%37 = icmp eq i32 %36, 7
br i1 %37, label %38, label %47
38: ; preds = %34
%39 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
%40 = load i32, i32* %2
%41 = icmp eq i32 %40, 8
br i1 %41, label %42, label %44
42: ; preds = %38
%43 = call i32 @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.1, i64 0, i64 0))
br label %46
44: ; preds = %38
%45 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0))
br label %46
46: ; preds = %44, %42
br label %49
47: ; preds = %34
%48 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0))
br label %49
49: ; preds = %47, %46
br label %52
50: ; preds = %30
%51 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0))
br label %52
52: ; preds = %50, %49
br label %55
53: ; preds = %27
%54 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0))
br label %55
55: ; preds = %53, %52
br label %56
56: ; preds = %55, %25
br label %57
57: ; preds = %56, %21
ret i32 0
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
@str.8 = [51 x i8] c"Caminho v\C3\A1lido, mas o destino n\C3\A3o foi alcan\C3\A7ado\00"
@str.10 = [18 x i8] c"Caminho inv\C3\A1lido\00"
@str.11 = [35 x i8] c"Caminho v\C3\A1lido\0ADestino alcan\C3\A7ado\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %1)
%4 = load i32, i32* %1
switch i32 %4, label %27 [
i32 1, label %5
i32 2, label %28
i32 3, label %14
]
5: ; preds = %0
%6 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %1)
%7 = load i32, i32* %1
%8 = icmp eq i32 %7, 4
br i1 %8, label %9, label %28
9: ; preds = %5
%10 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %1)
%11 = load i32, i32* %1
%12 = icmp eq i32 %11, 6
%13 = select i1 %12, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @str.11, i64 0, i64 0), i8* getelementptr inbounds ([18 x i8], [18 x i8]* @str.10, i64 0, i64 0)
br label %28
14: ; preds = %0
%15 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %1)
%16 = load i32, i32* %1
%17 = icmp eq i32 %16, 5
br i1 %17, label %18, label %28
18: ; preds = %14
%19 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %1)
%20 = load i32, i32* %1
%21 = icmp eq i32 %20, 7
br i1 %21, label %22, label %28
22: ; preds = %18
%23 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %1)
%24 = load i32, i32* %1
%25 = icmp eq i32 %24, 8
%26 = select i1 %25, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @str.11, i64 0, i64 0), i8* getelementptr inbounds ([18 x i8], [18 x i8]* @str.10, i64 0, i64 0)
br label %28
27: ; preds = %0
br label %28
28: ; preds = %14, %18, %22, %0, %5, %9, %27
%29 = phi i8* [ getelementptr inbounds ([18 x i8], [18 x i8]* @str.10, i64 0, i64 0), %27 ], [ %13, %9 ], [ getelementptr inbounds ([18 x i8], [18 x i8]* @str.10, i64 0, i64 0), %5 ], [ getelementptr inbounds ([51 x i8], [51 x i8]* @str.8, i64 0, i64 0), %0 ], [ %26, %22 ], [ getelementptr inbounds ([18 x i8], [18 x i8]* @str.10, i64 0, i64 0), %18 ], [ getelementptr inbounds ([18 x i8], [18 x i8]* @str.10, i64 0, i64 0), %14 ]
%30 = call i32 @puts(i8* dereferenceable(1) %29)
ret i32 0
}