#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*/ explore(int, int);
int /*<<< orphan*/ init(int);
int /*<<< orphan*/ printf(char *, int);
int run(int, int);
int /*<<< orphan*/ scanf(char *, int *, int *, ...);
int main() {
  int N, Q;
  scanf("%d%d", &N, &Q);
  init(N);
  while (Q--) {
    int a, b, c;
    scanf("%d%d%d", &a, &b, &c);
    if (a == 2)
      printf("%d\n", run(b, c));
    else
      explore(b, c);
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe9c(%rip),%rdi
lea    -0x8(%rbp),%rsi
lea    -0xc(%rbp),%rdx
mov    $0x0,%al
call   1070 <scanf@plt>
mov    -0x8(%rbp),%edi
call   1050 <init@plt>
mov    -0xc(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0xc(%rbp)
cmp    $0x0,%eax
je     11e3 <main+0x93>
lea    0xe68(%rip),%rdi
lea    -0x10(%rbp),%rsi
lea    -0x14(%rbp),%rdx
lea    -0x18(%rbp),%rcx
mov    $0x0,%al
call   1070 <scanf@plt>
cmpl   $0x2,-0x10(%rbp)
jne    11d3 <main+0x83>
mov    -0x14(%rbp),%edi
mov    -0x18(%rbp),%esi
call   1030 <run@plt>
mov    %eax,%esi
lea    0xe3e(%rip),%rdi
call   1040 <printf@plt>
jmp    11de <main+0x8e>
mov    -0x14(%rbp),%edi
mov    -0x18(%rbp),%esi
call   1060 <explore@plt>
jmp    117d <main+0x2d>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x20,%rsp
lea    0xe9e(%rip),%rdi
lea    0x1c(%rsp),%rsi
lea    0xc(%rsp),%rdx
xor    %eax,%eax
call   1070 <scanf@plt>
mov    0x1c(%rsp),%edi
call   1050 <init@plt>
subl   $0x1,0xc(%rsp)
jb     11f4 <main+0xa4>
lea    0xe74(%rip),%r14
lea    0x18(%rsp),%r15
lea    0x14(%rsp),%r12
lea    0x10(%rsp),%rbx
lea    0xe65(%rip),%r13
jmp    11bc <main+0x6c>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
call   1060 <explore@plt>
subl   $0x1,0xc(%rsp)
jb     11f4 <main+0xa4>
mov    %r14,%rdi
mov    %r15,%rsi
mov    %r12,%rdx
mov    %rbx,%rcx
xor    %eax,%eax
call   1070 <scanf@plt>
cmpl   $0x2,0x18(%rsp)
mov    0x14(%rsp),%edi
mov    0x10(%rsp),%esi
jne    11b0 <main+0x60>
call   1030 <run@plt>
mov    %r13,%rdi
mov    %eax,%esi
call   1040 <printf@plt>
subl   $0x1,0xc(%rsp)
jae    11bc <main+0x6c>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [5 x i8] c"%d%d\00"
@.str.1 = [7 x i8] c"%d%d%d\00"
@.str.2 = [4 x i8] c"%d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32 0, i32* %1
%7 = call i32 (i8*, i32*, i32*, ...) @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32* %2, i32* %3)
%8 = load i32, i32* %2
%9 = call i32 @init(i32 %8)
br label %10
10: ; preds = %27, %0
%11 = load i32, i32* %3
%12 = add nsw i32 %11, -1
store i32 %12, i32* %3
%13 = icmp ne i32 %11, 0
br i1 %13, label %14, label %28
14: ; preds = %10
%15 = call i32 (i8*, i32*, i32*, ...) @scanf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32* %4, i32* %5, i32* %6)
%16 = load i32, i32* %4
%17 = icmp eq i32 %16, 2
br i1 %17, label %18, label %23
18: ; preds = %14
%19 = load i32, i32* %5
%20 = load i32, i32* %6
%21 = call i32 @run(i32 %19, i32 %20)
%22 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %21)
br label %27
23: ; preds = %14
%24 = load i32, i32* %5
%25 = load i32, i32* %6
%26 = call i32 @explore(i32 %24, i32 %25)
br label %27
27: ; preds = %23, %18
br label %10
28: ; preds = %10
%29 = load i32, i32* %1
ret i32 %29
}

LLVM IR (-O2):
@.str = [5 x i8] c"%d%d\00"
@.str.1 = [7 x i8] c"%d%d%d\00"
@.str.2 = [4 x i8] c"%d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = bitcast i32* %1 to i8*
%7 = bitcast i32* %2 to i8*
%8 = call i32 (i8*, i32*, i32*, ...) @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32* %1, i32* %2)
%9 = load i32, i32* %1
%10 = call i32 @init(i32 %9)
%11 = load i32, i32* %2
%12 = add nsw i32 %11, -1
store i32 %12, i32* %2
%13 = icmp eq i32 %11, 0
br i1 %13, label %33, label %14
14: ; preds = %0
%15 = bitcast i32* %3 to i8*
%16 = bitcast i32* %4 to i8*
%17 = bitcast i32* %5 to i8*
br label %18
18: ; preds = %14, %29
%19 = call i32 (i8*, i32*, i32*, ...) @scanf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32* %3, i32* %4, i32* %5)
%20 = load i32, i32* %3
%21 = icmp eq i32 %20, 2
%22 = load i32, i32* %4
%23 = load i32, i32* %5
br i1 %21, label %24, label %27
24: ; preds = %18
%25 = call i32 @run(i32 %22, i32 %23)
%26 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %25)
br label %29
27: ; preds = %18
%28 = call i32 @explore(i32 %22, i32 %23)
br label %29
29: ; preds = %27, %24
%30 = load i32, i32* %2
%31 = add nsw i32 %30, -1
store i32 %31, i32* %2
%32 = icmp eq i32 %30, 0
br i1 %32, label %33, label %18
33: ; preds = %29, %0
ret i32 0
}