#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ fcloseall();
int fgetc(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, unsigned char *);
int /*<<< orphan*/ fscanf(int /*<<< orphan*/ *, char *, unsigned char *,
                          unsigned char *);
int /*<<< orphan*/ memmove(unsigned char *, unsigned char *, unsigned char);
int /*<<< orphan*/ strcpy(unsigned char *, unsigned char *);
char strlen(unsigned char *);
int main() {
  FILE *fi = fopen("INP.TXT", "r"), *fo = fopen("OUT.TXT", "w");
  unsigned char n, i, j, s[256], sx[256], x, y;
  fscanf(fi, "%s %hhd\n", s, &n);
  for (i = 0; i < n; i++)
    if (fgetc(fi) ^ 49) {
      fscanf(fi, " %hhd %hhd\n", &x, &y);
      x--;
      memmove(s + x, s + x + y, strlen(s) - x - y + 1);
      fprintf(fo, "%s\n", s);
    } else {
      fscanf(fi, " %s %hhd\n", sx, &y);
      strcpy(sx + strlen(sx), s + y);
      strcpy(s + y, sx);
      fprintf(fo, "%s\n", s);
    }
  fcloseall();
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x240,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe67(%rip),%rdi
lea    0xe68(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0x10(%rbp)
lea    0xe5a(%rip),%rdi
lea    0xe5b(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
lea    -0x120(%rbp),%rdx
lea    0xe53(%rip),%rsi
lea    -0x19(%rbp),%rcx
call   1050 <fscanf@plt>
movb   $0x0,-0x1a(%rbp)
movzbl -0x1a(%rbp),%eax
movzbl -0x19(%rbp),%ecx
cmp    %ecx,%eax
jge    1370 <main+0x1f0>
mov    -0x10(%rbp),%rdi
call   1060 <fgetc@plt>
xor    $0x31,%eax
cmp    $0x0,%eax
je     12c9 <main+0x149>
mov    -0x10(%rbp),%rdi
lea    0xe05(%rip),%rsi
lea    -0x221(%rbp),%rdx
lea    -0x222(%rbp),%rcx
call   1050 <fscanf@plt>
mov    -0x221(%rbp),%al
add    $0xff,%al
mov    %al,-0x221(%rbp)
lea    -0x120(%rbp),%rax
movzbl -0x221(%rbp),%ecx
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x238(%rbp)
lea    -0x120(%rbp),%rax
movzbl -0x221(%rbp),%ecx
movslq %ecx,%rcx
add    %rcx,%rax
movzbl -0x222(%rbp),%ecx
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x230(%rbp)
lea    -0x120(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x238(%rbp),%rdi
mov    -0x230(%rbp),%rsi
movsbl %al,%eax
movzbl -0x221(%rbp),%ecx
sub    %ecx,%eax
movzbl -0x222(%rbp),%ecx
sub    %ecx,%eax
add    $0x1,%eax
movzbl %al,%edx
call   1080 <memmove@plt>
mov    -0x18(%rbp),%rdi
lea    -0x120(%rbp),%rdx
lea    0xd61(%rip),%rsi
call   1070 <fprintf@plt>
jmp    135e <main+0x1de>
mov    -0x10(%rbp),%rdi
lea    -0x220(%rbp),%rdx
lea    0xd49(%rip),%rsi
lea    -0x222(%rbp),%rcx
call   1050 <fscanf@plt>
lea    -0x220(%rbp),%rax
mov    %rax,-0x240(%rbp)
lea    -0x220(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x240(%rbp),%rdi
movsbl %al,%eax
cltq
add    %rax,%rdi
lea    -0x120(%rbp),%rsi
movzbl -0x222(%rbp),%eax
cltq
add    %rax,%rsi
call   1030 <strcpy@plt>
lea    -0x120(%rbp),%rdi
movzbl -0x222(%rbp),%eax
cltq
add    %rax,%rdi
lea    -0x220(%rbp),%rsi
call   1030 <strcpy@plt>
mov    -0x18(%rbp),%rdi
lea    -0x120(%rbp),%rdx
lea    0xcc7(%rip),%rsi
call   1070 <fprintf@plt>
jmp    1363 <main+0x1e3>
mov    -0x1a(%rbp),%al
add    $0x1,%al
mov    %al,-0x1a(%rbp)
jmp    11df <main+0x5f>
mov    $0x0,%al
call   10a0 <fcloseall@plt>
xor    %eax,%eax
add    $0x240,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x218,%rsp
lea    0xe68(%rip),%rdi
lea    0xe69(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,%r15
lea    0xe5c(%rip),%rdi
lea    0xe5d(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,%r14
lea    0xe61(%rip),%rsi
lea    0x10(%rsp),%rdx
lea    0x7(%rsp),%rcx
mov    %r15,%rdi
call   1050 <fscanf@plt>
cmpb   $0x0,0x7(%rsp)
je     1303 <main+0x183>
xor    %r12d,%r12d
lea    0x5(%rsp),%rbx
lea    0xe30(%rip),%r13
mov    %r15,0x8(%rsp)
jmp    127d <main+0xfd>
nopw   0x0(%rax,%rax,1)
mov    %r15,%rdi
lea    0xe1a(%rip),%rsi
lea    0x110(%rsp),%rbp
mov    %rbp,%rdx
mov    %rbx,%rcx
call   1050 <fscanf@plt>
mov    %rbp,%rdi
call   1040 <strlen@plt>
movsbq %al,%rax
lea    (%rsp,%rax,1),%rdi
add    $0x110,%rdi
movzbl 0x5(%rsp),%eax
lea    (%rsp,%rax,1),%rsi
add    $0x10,%rsi
call   1030 <strcpy@plt>
movzbl 0x5(%rsp),%eax
lea    (%rsp,%rax,1),%rdi
add    $0x10,%rdi
mov    %rbp,%rsi
lea    0x10(%rsp),%rbp
call   1030 <strcpy@plt>
mov    %r14,%rdi
mov    %r13,%rsi
mov    %rbp,%rdx
call   1070 <fprintf@plt>
add    $0x1,%r12b
cmp    0x7(%rsp),%r12b
jae    1303 <main+0x183>
mov    %r15,%rdi
call   1060 <fgetc@plt>
cmp    $0x31,%eax
je     1200 <main+0x80>
mov    %r15,%rdi
lea    0xd7c(%rip),%rsi
lea    0x6(%rsp),%rdx
mov    %rbx,%rcx
call   1050 <fscanf@plt>
movzbl 0x6(%rsp),%eax
add    $0xff,%al
mov    %al,0x6(%rsp)
movzbl %al,%eax
mov    %r14,%r15
mov    %r13,%r14
lea    (%rsp,%rax,1),%r13
add    $0x10,%r13
movzbl 0x5(%rsp),%ebp
add    %r13,%rbp
lea    0x10(%rsp),%rdi
call   1040 <strlen@plt>
movzbl 0x6(%rsp),%ecx
add    0x5(%rsp),%cl
sub    %cl,%al
add    $0x1,%al
movzbl %al,%edx
mov    %r13,%rdi
mov    %r14,%r13
mov    %r15,%r14
mov    0x8(%rsp),%r15
mov    %rbp,%rsi
lea    0x10(%rsp),%rbp
call   1080 <memmove@plt>
jmp    1260 <main+0xe0>
xor    %eax,%eax
call   10a0 <fcloseall@plt>
xor    %eax,%eax
add    $0x218,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [8 x i8] c"INP.TXT\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [8 x i8] c"OUT.TXT\00"
@.str.3 = [2 x i8] c"w\00"
@.str.4 = [9 x i8] c"%s %hhd\0A\00"
@.str.5 = [12 x i8] c" %hhd %hhd\0A\00"
@.str.6 = [4 x i8] c"%s\0A\00"
@.str.7 = [10 x i8] c" %s %hhd\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32*
%3 = alloca i32*
%4 = alloca i8
%5 = alloca i8
%6 = alloca i8
%7 = alloca [256 x i8]
%8 = alloca [256 x i8]
%9 = alloca i8
%10 = alloca i8
store i32 0, i32* %1
%11 = call i32* @fopen(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %11, i32** %2
%12 = call i32* @fopen(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
store i32* %12, i32** %3
%13 = load i32*, i32** %2
%14 = getelementptr inbounds [256 x i8], [256 x i8]* %7, i64 0, i64 0
%15 = call i32 @fscanf(i32* %13, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0), i8* %14, i8* %4)
store i8 0, i8* %5
br label %16
16: ; preds = %88, %0
%17 = load i8, i8* %5
%18 = zext i8 %17 to i32
%19 = load i8, i8* %4
%20 = zext i8 %19 to i32
%21 = icmp slt i32 %18, %20
br i1 %21, label %22, label %91
22: ; preds = %16
%23 = load i32*, i32** %2
%24 = call i32 @fgetc(i32* %23)
%25 = xor i32 %24, 49
%26 = icmp ne i32 %25, 0
br i1 %26, label %27, label %61
27: ; preds = %22
%28 = load i32*, i32** %2
%29 = call i32 @fscanf(i32* %28, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.5, i64 0, i64 0), i8* %9, i8* %10)
%30 = load i8, i8* %9
%31 = add i8 %30, -1
store i8 %31, i8* %9
%32 = getelementptr inbounds [256 x i8], [256 x i8]* %7, i64 0, i64 0
%33 = load i8, i8* %9
%34 = zext i8 %33 to i32
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds i8, i8* %32, i64 %35
%37 = getelementptr inbounds [256 x i8], [256 x i8]* %7, i64 0, i64 0
%38 = load i8, i8* %9
%39 = zext i8 %38 to i32
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds i8, i8* %37, i64 %40
%42 = load i8, i8* %10
%43 = zext i8 %42 to i32
%44 = sext i32 %43 to i64
%45 = getelementptr inbounds i8, i8* %41, i64 %44
%46 = getelementptr inbounds [256 x i8], [256 x i8]* %7, i64 0, i64 0
%47 = call signext i8 @strlen(i8* %46)
%48 = sext i8 %47 to i32
%49 = load i8, i8* %9
%50 = zext i8 %49 to i32
%51 = sub nsw i32 %48, %50
%52 = load i8, i8* %10
%53 = zext i8 %52 to i32
%54 = sub nsw i32 %51, %53
%55 = add nsw i32 %54, 1
%56 = trunc i32 %55 to i8
%57 = call i32 @memmove(i8* %36, i8* %45, i8 zeroext %56)
%58 = load i32*, i32** %3
%59 = getelementptr inbounds [256 x i8], [256 x i8]* %7, i64 0, i64 0
%60 = call i32 @fprintf(i32* %58, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), i8* %59)
br label %87
61: ; preds = %22
%62 = load i32*, i32** %2
%63 = getelementptr inbounds [256 x i8], [256 x i8]* %8, i64 0, i64 0
%64 = call i32 @fscanf(i32* %62, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.7, i64 0, i64 0), i8* %63, i8* %10)
%65 = getelementptr inbounds [256 x i8], [256 x i8]* %8, i64 0, i64 0
%66 = getelementptr inbounds [256 x i8], [256 x i8]* %8, i64 0, i64 0
%67 = call signext i8 @strlen(i8* %66)
%68 = sext i8 %67 to i32
%69 = sext i32 %68 to i64
%70 = getelementptr inbounds i8, i8* %65, i64 %69
%71 = getelementptr inbounds [256 x i8], [256 x i8]* %7, i64 0, i64 0
%72 = load i8, i8* %10
%73 = zext i8 %72 to i32
%74 = sext i32 %73 to i64
%75 = getelementptr inbounds i8, i8* %71, i64 %74
%76 = call i32 @strcpy(i8* %70, i8* %75)
%77 = getelementptr inbounds [256 x i8], [256 x i8]* %7, i64 0, i64 0
%78 = load i8, i8* %10
%79 = zext i8 %78 to i32
%80 = sext i32 %79 to i64
%81 = getelementptr inbounds i8, i8* %77, i64 %80
%82 = getelementptr inbounds [256 x i8], [256 x i8]* %8, i64 0, i64 0
%83 = call i32 @strcpy(i8* %81, i8* %82)
%84 = load i32*, i32** %3
%85 = getelementptr inbounds [256 x i8], [256 x i8]* %7, i64 0, i64 0
%86 = call i32 @fprintf(i32* %84, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), i8* %85)
br label %87
87: ; preds = %61, %27
br label %88
88: ; preds = %87
%89 = load i8, i8* %5
%90 = add i8 %89, 1
store i8 %90, i8* %5
br label %16
91: ; preds = %16
%92 = call i32 (...) @fcloseall()
ret i32 0
}

LLVM IR (-O2):
@.str = [8 x i8] c"INP.TXT\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [8 x i8] c"OUT.TXT\00"
@.str.3 = [2 x i8] c"w\00"
@.str.4 = [9 x i8] c"%s %hhd\0A\00"
@.str.5 = [12 x i8] c" %hhd %hhd\0A\00"
@.str.6 = [4 x i8] c"%s\0A\00"
@.str.7 = [10 x i8] c" %s %hhd\0A\00"
define i32 @main() {
%1 = alloca i8
%2 = alloca [256 x i8]
%3 = alloca [256 x i8]
%4 = alloca i8
%5 = alloca i8
%6 = tail call i32* @fopen(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%7 = tail call i32* @fopen(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%8 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 0
%9 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%10 = call i32 @fscanf(i32* %6, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0), i8* %8, i8* %1)
%11 = load i8, i8* %1
%12 = icmp eq i8 %11, 0
br i1 %12, label %51, label %13
13: ; preds = %0, %46
%14 = phi i8 [ %48, %46 ], [ 0, %0 ]
%15 = call i32 @fgetc(i32* %6)
%16 = icmp eq i32 %15, 49
br i1 %16, label %33, label %17
17: ; preds = %13
%18 = call i32 @fscanf(i32* %6, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.5, i64 0, i64 0), i8* %4, i8* %5)
%19 = load i8, i8* %4
%20 = add i8 %19, -1
store i8 %20, i8* %4
%21 = zext i8 %20 to i64
%22 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 %21
%23 = load i8, i8* %5
%24 = zext i8 %23 to i64
%25 = getelementptr inbounds i8, i8* %22, i64 %24
%26 = call signext i8 @strlen(i8* %8)
%27 = load i8, i8* %4
%28 = load i8, i8* %5
%29 = add i8 %26, 1
%30 = add i8 %27, %28
%31 = sub i8 %29, %30
%32 = call i32 @memmove(i8* %22, i8* %25, i8 zeroext %31)
br label %46
33: ; preds = %13
%34 = call i32 @fscanf(i32* %6, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.7, i64 0, i64 0), i8* %9, i8* %5)
%35 = call signext i8 @strlen(i8* %9)
%36 = sext i8 %35 to i64
%37 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 %36
%38 = load i8, i8* %5
%39 = zext i8 %38 to i64
%40 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 %39
%41 = call i32 @strcpy(i8* %37, i8* %40)
%42 = load i8, i8* %5
%43 = zext i8 %42 to i64
%44 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 %43
%45 = call i32 @strcpy(i8* %44, i8* %9)
br label %46
46: ; preds = %17, %33
%47 = call i32 @fprintf(i32* %7, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), i8* %8)
%48 = add nuw i8 %14, 1
%49 = load i8, i8* %1
%50 = icmp ult i8 %48, %49
br i1 %50, label %13, label %51
51: ; preds = %46, %0
%52 = call i32 (...) @fcloseall()
ret i32 0
}