#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 */
char getchar();
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ putchar(char);
int /*<<< orphan*/ scanf(char *, int *, int *);
int main() {
  char text[20], ch;
  int i, n, m;
  printf("Enter the text: \n");
  while ((ch = getchar()) != '\n' && i < 20)
    text[i++] = ch;
  printf("Enter the Value of M and N: ");
  scanf("%d %d", &m, &n);
  for (i = n; i < n + m; i++)
    putchar(text[i]);
  printf("\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeaa(%rip),%rdi
call   1040 <printf@plt>
mov    $0x0,%al
call   1050 <getchar@plt>
mov    %al,-0x21(%rbp)
movsbl %al,%ecx
xor    %eax,%eax
cmp    $0xa,%ecx
mov    %al,-0x31(%rbp)
je     1180 <main+0x40>
cmpl   $0x14,-0x28(%rbp)
setl   %al
mov    %al,-0x31(%rbp)
mov    -0x31(%rbp),%al
test   $0x1,%al
jne    1190 <main+0x50>
jmp    11a9 <main+0x69>
mov    -0x21(%rbp),%cl
mov    -0x28(%rbp),%eax
mov    %eax,%edx
add    $0x1,%edx
mov    %edx,-0x28(%rbp)
cltq
mov    %cl,-0x20(%rbp,%rax,1)
jmp    115b <main+0x1b>
lea    0xe62(%rip),%rdi
call   1040 <printf@plt>
lea    0xe73(%rip),%rdi
lea    -0x30(%rbp),%rsi
lea    -0x2c(%rbp),%rdx
call   1060 <scanf@plt>
mov    -0x2c(%rbp),%eax
mov    %eax,-0x28(%rbp)
mov    -0x28(%rbp),%eax
mov    -0x2c(%rbp),%ecx
add    -0x30(%rbp),%ecx
cmp    %ecx,%eax
jge    11fc <main+0xbc>
movslq -0x28(%rbp),%rax
movsbl -0x20(%rbp,%rax,1),%edi
call   1030 <putchar@plt>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    11cf <main+0x8f>
lea    0xe0d(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x30,%rsp
lea    0xec7(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
call   1060 <getchar@plt>
lea    0xe91(%rip),%rdi
call   1050 <printf@plt>
lea    0xea2(%rip),%rdi
lea    0x8(%rsp),%rsi
lea    0xc(%rsp),%rdx
call   1070 <scanf@plt>
cmpl   $0x0,0x8(%rsp)
jle    11c0 <main+0x70>
movslq 0xc(%rsp),%rbx
cs nopw 0x0(%rax,%rax,1)
movsbl 0x10(%rsp,%rbx,1),%edi
call   1030 <putchar@plt>
add    $0x1,%rbx
movslq 0xc(%rsp),%rax
movslq 0x8(%rsp),%rcx
add    %rax,%rcx
cmp    %rcx,%rbx
jl     11a0 <main+0x50>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbx
ret

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

LLVM IR (-O2):
@.str.1 = [29 x i8] c"Enter the Value of M and N: \00"
@.str.2 = [6 x i8] c"%d %d\00"
@str = [17 x i8] c"Enter the text: \00"
define i32 @main() {
%1 = alloca [20 x i8]
%2 = alloca i32
%3 = alloca i32
%4 = getelementptr inbounds [20 x i8], [20 x i8]* %1, i64 0, i64 0
%5 = bitcast i32* %2 to i8*
%6 = bitcast i32* %3 to i8*
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @str, i64 0, i64 0))
%8 = tail call signext i8 (...) @getchar()
%9 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0))
%10 = call i32 @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32* %3, i32* %2)
%11 = load i32, i32* %3
%12 = icmp sgt i32 %11, 0
br i1 %12, label %13, label %27
13: ; preds = %0
%14 = load i32, i32* %2
%15 = sext i32 %14 to i64
br label %16
16: ; preds = %13, %16
%17 = phi i64 [ %15, %13 ], [ %21, %16 ]
%18 = getelementptr inbounds [20 x i8], [20 x i8]* %1, i64 0, i64 %17
%19 = load i8, i8* %18
%20 = call i32 @putchar(i8 signext %19)
%21 = add nsw i64 %17, 1
%22 = load i32, i32* %2
%23 = load i32, i32* %3
%24 = add nsw i32 %23, %22
%25 = sext i32 %24 to i64
%26 = icmp slt i64 %21, %25
br i1 %26, label %16, label %27
27: ; preds = %16, %0
%28 = call i32 bitcast (i32 (i8)* @putchar to i32 (i32)*)(i32 10)
ret i32 0
}