#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 */
scalar_t__ EOF;
int /*<<< orphan*/ gets(char *);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ putchar(char);
scalar_t__ scanf(char *, int *, ...);
int main(int argc, const char *argv[]) {
  int n, i, a, b;
  char buffer[1001];
  gets(buffer);
  scanf("%d", &n);
  while (scanf("%d%d", &a, &b) != EOF) {
    for (i = 0; i < b; i++) {
      putchar(buffer[a + i]);
    }
    printf("\n");
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x410,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x410(%rbp),%rdi
call   1050 <gets@plt>
lea    0xe96(%rip),%rdi
lea    -0x14(%rbp),%rsi
mov    $0x0,%al
call   1060 <scanf@plt>
lea    0xe82(%rip),%rdi
lea    -0x1c(%rbp),%rsi
lea    -0x20(%rbp),%rdx
mov    $0x0,%al
call   1060 <scanf@plt>
mov    0x2e54(%rip),%rcx
cmp    (%rcx),%rax
je     11e4 <main+0xa4>
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x20(%rbp),%eax
jge    11d3 <main+0x93>
mov    -0x1c(%rbp),%eax
add    -0x18(%rbp),%eax
cltq
movsbl -0x410(%rbp,%rax,1),%edi
ff
call   1030 <putchar@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    11a4 <main+0x64>
lea    0xe2b(%rip),%rdi
call   1040 <printf@plt>
jmp    1177 <main+0x37>
xor    %eax,%eax
add    $0x410,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x400,%rsp
lea    0x10(%rsp),%rdi
call   1040 <gets@plt>
lea    0xeb1(%rip),%rdi
lea    0xc(%rsp),%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
lea    0xe9c(%rip),%rdi
lea    0x8(%rsp),%rsi
lea    0x4(%rsp),%rdx
xor    %eax,%eax
call   1050 <scanf@plt>
mov    0x2e6c(%rip),%r12
cmp    (%r12),%rax
jne    1195 <main+0x65>
xor    %eax,%eax
add    $0x400,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret
lea    0xe64(%rip),%r14
lea    0x8(%rsp),%r15
lea    0x4(%rsp),%r13
jmp    11d0 <main+0xa0>
nopl   0x0(%rax,%rax,1)
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    %r14,%rdi
mov    %r15,%rsi
mov    %r13,%rdx
xor    %eax,%eax
call   1050 <scanf@plt>
cmp    (%r12),%rax
je     1182 <main+0x52>
cmpl   $0x0,0x4(%rsp)
jle    11b0 <main+0x80>
xor    %ebx,%ebx
nopl   0x0(%rax)
movslq 0x8(%rsp),%rax
add    %rsp,%rax
add    $0x10,%rax
movsbl (%rbx,%rax,1),%edi
call   1030 <putchar@plt>
add    $0x1,%rbx
cmp    0x4(%rsp),%ebx
jl     11e0 <main+0xb0>
jmp    11b0 <main+0x80>

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

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
@.str.1 = [5 x i8] c"%d%d\00"
@EOF = global i64 0
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca [1001 x i8]
%7 = bitcast i32* %3 to i8*
%8 = bitcast i32* %4 to i8*
%9 = bitcast i32* %5 to i8*
%10 = getelementptr inbounds [1001 x i8], [1001 x i8]* %6, i64 0, i64 0
%11 = call i32 @gets(i8* %10)
%12 = call i64 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %3)
%13 = call i64 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32* %4, i32* %5)
%14 = load i64, i64* @EOF
%15 = icmp eq i64 %13, %14
br i1 %15, label %35, label %16
16: ; preds = %2, %30
%17 = load i32, i32* %5
%18 = icmp sgt i32 %17, 0
br i1 %18, label %19, label %30
19: ; preds = %16, %19
%20 = phi i32 [ %27, %19 ], [ 0, %16 ]
%21 = load i32, i32* %4
%22 = add nsw i32 %21, %20
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds [1001 x i8], [1001 x i8]* %6, i64 0, i64 %23
%25 = load i8, i8* %24
%26 = call i32 @putchar(i8 signext %25)
%27 = add nuw nsw i32 %20, 1
%28 = load i32, i32* %5
%29 = icmp slt i32 %27, %28
br i1 %29, label %19, label %30
30: ; preds = %19, %16
%31 = call i32 bitcast (i32 (i8)* @putchar to i32 (i32)*)(i32 10)
%32 = call i64 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32* %4, i32* %5)
%33 = load i64, i64* @EOF
%34 = icmp eq i64 %32, %33
br i1 %34, label %35, label %16
35: ; preds = %30, %2
ret i32 0
}