#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 abs(int);
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ scanf(char *, int *, ...);
int main() {
  int n, q;
  scanf("%d %d", &n, &q);
  int companies[n];
  for (int i = 0; i < n; i++)
    scanf("%d", companies + i);
  while (q--) {
    int type, a, b;
    scanf("%d %d %d", &type, &a, &b);
    if (type == 1) {
      companies[a - 1] = b;
    } else {
      printf("%d\n", abs(companies[a - 1] - companies[b - 1]));
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xebd(%rip),%rdi
xor    %eax,%eax
lea    -0x8(%rbp),%rsi
lea    -0xc(%rbp),%rdx
call   1050 <scanf@plt>
mov    -0x8(%rbp),%eax
mov    %rsp,%rcx
mov    %rcx,-0x18(%rbp)
lea    0xf(,%rax,4),%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x38(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11ba <main+0x8a>
mov    -0x38(%rbp),%rsi
movslq -0x24(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rsi
lea    0xe61(%rip),%rdi
mov    $0x0,%al
call   1050 <scanf@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1183 <main+0x53>
jmp    11bf <main+0x8f>
mov    -0xc(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0xc(%rbp)
cmp    $0x0,%eax
je     1243 <main+0x113>
lea    0xe26(%rip),%rdi
lea    -0x28(%rbp),%rsi
lea    -0x2c(%rbp),%rdx
lea    -0x30(%rbp),%rcx
mov    $0x0,%al
call   1050 <scanf@plt>
cmpl   $0x1,-0x28(%rbp)
jne    120f <main+0xdf>
mov    -0x38(%rbp),%rax
mov    -0x30(%rbp),%edx
mov    -0x2c(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
mov    %edx,(%rax,%rcx,4)
jmp    123e <main+0x10e>
mov    -0x38(%rbp),%rax
mov    -0x2c(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,4),%edi
mov    -0x30(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
sub    (%rax,%rcx,4),%edi
call   1030 <abs@plt>
mov    %eax,%esi
lea    0xdd0(%rip),%rdi
call   1040 <printf@plt>
jmp    11bf <main+0x8f>
movl   $0x0,-0x4(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
lea    0xecb(%rip),%rdi
lea    -0x2c(%rbp),%rsi
lea    -0x38(%rbp),%rdx
xor    %eax,%eax
call   1040 <scanf@plt>
mov    %rsp,-0x48(%rbp)
mov    -0x2c(%rbp),%eax
mov    %rsp,%r13
lea    0xf(,%rax,4),%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r13
mov    %r13,%rsp
cmpl   $0x0,-0x2c(%rbp)
jle    119e <main+0x7e>
lea    0xe96(%rip),%r14
mov    %r13,%r15
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nop
mov    %r14,%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1040 <scanf@plt>
add    $0x1,%rbx
movslq -0x2c(%rbp),%rax
add    $0x4,%r15
cmp    %rax,%rbx
jl     1180 <main+0x60>
subl   $0x1,-0x38(%rbp)
jb     1216 <main+0xf6>
lea    0xe55(%rip),%r14
lea    -0x3c(%rbp),%r15
lea    -0x34(%rbp),%r12
lea    -0x30(%rbp),%rbx
jmp    11eb <main+0xcb>
nopl   0x0(%rax)
movslq -0x34(%rbp),%rax
mov    -0x4(%r13,%rax,4),%eax
movslq -0x30(%rbp),%rcx
sub    -0x4(%r13,%rcx,4),%eax
mov    %eax,%esi
neg    %esi
cmovs  %eax,%esi
lea    0xe29(%rip),%rdi
call   1030 <printf@plt>
subl   $0x1,-0x38(%rbp)
jb     1216 <main+0xf6>
mov    %r14,%rdi
mov    %r15,%rsi
mov    %r12,%rdx
mov    %rbx,%rcx
xor    %eax,%eax
call   1040 <scanf@plt>
cmpl   $0x1,-0x3c(%rbp)
jne    11c0 <main+0xa0>
mov    -0x30(%rbp),%eax
movslq -0x34(%rbp),%rcx
mov    %eax,-0x4(%r13,%rcx,4)
subl   $0x1,-0x38(%rbp)
jae    11eb <main+0xcb>
mov    -0x48(%rbp),%rsp
xor    %eax,%eax
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [6 x i8] c"%d %d\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [9 x i8] c"%d %d %d\00"
@.str.3 = [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*, ...) @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32* %1, i32* %2)
%9 = load i32, i32* %1
%10 = zext i32 %9 to i64
%11 = call i8* @llvm.stacksave()
%12 = alloca i32, i64 %10
%13 = load i32, i32* %1
%14 = icmp sgt i32 %13, 0
br i1 %14, label %23, label %15
15: ; preds = %23, %0
%16 = load i32, i32* %2
%17 = add nsw i32 %16, -1
store i32 %17, i32* %2
%18 = icmp eq i32 %16, 0
br i1 %18, label %59, label %19
19: ; preds = %15
%20 = bitcast i32* %3 to i8*
%21 = bitcast i32* %4 to i8*
%22 = bitcast i32* %5 to i8*
br label %31
23: ; preds = %0, %23
%24 = phi i64 [ %27, %23 ], [ 0, %0 ]
%25 = getelementptr inbounds i32, i32* %12, i64 %24
%26 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %25)
%27 = add nuw nsw i64 %24, 1
%28 = load i32, i32* %1
%29 = sext i32 %28 to i64
%30 = icmp slt i64 %27, %29
br i1 %30, label %23, label %15
31: ; preds = %19, %55
%32 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i32* %3, i32* %4, i32* %5)
%33 = load i32, i32* %3
%34 = icmp eq i32 %33, 1
br i1 %34, label %35, label %41
35: ; preds = %31
%36 = load i32, i32* %5
%37 = load i32, i32* %4
%38 = add nsw i32 %37, -1
%39 = sext i32 %38 to i64
%40 = getelementptr inbounds i32, i32* %12, i64 %39
store i32 %36, i32* %40
br label %55
41: ; preds = %31
%42 = load i32, i32* %4
%43 = add nsw i32 %42, -1
%44 = sext i32 %43 to i64
%45 = getelementptr inbounds i32, i32* %12, i64 %44
%46 = load i32, i32* %45
%47 = load i32, i32* %5
%48 = add nsw i32 %47, -1
%49 = sext i32 %48 to i64
%50 = getelementptr inbounds i32, i32* %12, i64 %49
%51 = load i32, i32* %50
%52 = sub nsw i32 %46, %51
%53 = call i32 @llvm.abs.i32(i32 %52, i1 true)
%54 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %53)
br label %55
55: ; preds = %41, %35
%56 = load i32, i32* %2
%57 = add nsw i32 %56, -1
store i32 %57, i32* %2
%58 = icmp eq i32 %56, 0
br i1 %58, label %59, label %31
59: ; preds = %55, %15
ret i32 0
}