#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*/ gets(char *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ puts(char *);
int /*<<< orphan*/ scanf(char *, int *, int *);
int strlen(char *);
int /*<<< orphan*/ strncpy(char *, char *, int);
int main() {
  char s[100], dest[100];
  int pozicija, dolzhina;
  gets(s);
  scanf("%d %d", &pozicija, &dolzhina);
  if (pozicija <= strlen(s)) {
    strncpy(dest, s + pozicija - 1, dolzhina);
    dest[dolzhina] = '\0';
    printf("Rezultat: ");
    puts(dest);
  } else
    printf("Nevaliden vnes, prochitaniot string ima samo %d znaci.\n",
           strlen(s));
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xf0,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x70(%rbp),%rdi
call   1070 <gets@plt>
lea    0xe7e(%rip),%rdi
lea    -0xe4(%rbp),%rsi
lea    -0xe8(%rbp),%rdx
call   1080 <scanf@plt>
mov    -0xe4(%rbp),%eax
mov    %eax,-0xec(%rbp)
lea    -0x70(%rbp),%rdi
call   1050 <strlen@plt>
mov    %eax,%ecx
mov    -0xec(%rbp),%eax
cmp    %ecx,%eax
jg     120c <main+0xac>
lea    -0xe0(%rbp),%rdi
lea    -0x70(%rbp),%rsi
movslq -0xe4(%rbp),%rax
add    %rax,%rsi
add    $0xffffffffffffffff,%rsi
mov    -0xe8(%rbp),%edx
call   1030 <strncpy@plt>
movslq -0xe8(%rbp),%rax
movb   $0x0,-0xe0(%rbp,%rax,1)
lea    0xe12(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    -0xe0(%rbp),%rdi
call   1040 <puts@plt>
jmp    1225 <main+0xc5>
lea    -0x70(%rbp),%rdi
call   1050 <strlen@plt>
mov    %eax,%esi
lea    0xdf3(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
xor    %eax,%eax
add    $0xf0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
sub    $0xe8,%rsp
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
call   1070 <gets@plt>
lea    0xe83(%rip),%rdi
lea    0xc(%rsp),%rsi
lea    0x8(%rsp),%rdx
call   1080 <scanf@plt>
mov    0xc(%rsp),%ebp
mov    %rbx,%rdi
call   1050 <strlen@plt>
cmp    %eax,%ebp
jle    11b8 <main+0x58>
lea    0x10(%rsp),%rdi
call   1050 <strlen@plt>
lea    0xe64(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1060 <printf@plt>
jmp    11fc <main+0x9c>
movslq 0xc(%rsp),%rax
lea    (%rsp,%rax,1),%rsi
add    $0xf,%rsi
mov    0x8(%rsp),%edx
lea    0x80(%rsp),%rbx
mov    %rbx,%rdi
call   1030 <strncpy@plt>
movslq 0x8(%rsp),%rax
movb   $0x0,0x80(%rsp,%rax,1)
lea    0xe19(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %rbx,%rdi
call   1040 <puts@plt>
xor    %eax,%eax
add    $0xe8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [6 x i8] c"%d %d\00"
@.str.1 = [11 x i8] c"Rezultat: \00"
@.str.2 = [56 x i8] c"Nevaliden vnes, prochitaniot string ima samo %d znaci.\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [100 x i8]
%3 = alloca [100 x i8]
%4 = alloca i32
%5 = alloca i32
store i32 0, i32* %1
%6 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%7 = call i32 @gets(i8* %6)
%8 = call i32 @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32* %4, i32* %5)
%9 = load i32, i32* %4
%10 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%11 = call i32 @strlen(i8* %10)
%12 = icmp sle i32 %9, %11
br i1 %12, label %13, label %28
13: ; preds = %0
%14 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%15 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%16 = load i32, i32* %4
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds i8, i8* %15, i64 %17
%19 = getelementptr inbounds i8, i8* %18, i64 -1
%20 = load i32, i32* %5
%21 = call i32 @strncpy(i8* %14, i8* %19, i32 %20)
%22 = load i32, i32* %5
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 %23
store i8 0, i8* %24
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0))
%26 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%27 = call i32 @puts(i8* %26)
br label %32
28: ; preds = %0
%29 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%30 = call i32 @strlen(i8* %29)
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str.2, i64 0, i64 0), i32 %30)
br label %32
32: ; preds = %28, %13
ret i32 0
}

LLVM IR (-O2):
@.str = [6 x i8] c"%d %d\00"
@.str.1 = [11 x i8] c"Rezultat: \00"
@.str.2 = [56 x i8] c"Nevaliden vnes, prochitaniot string ima samo %d znaci.\0A\00"
define i32 @main() {
%1 = alloca [100 x i8]
%2 = alloca [100 x i8]
%3 = alloca i32
%4 = alloca i32
%5 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 0
%6 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%7 = bitcast i32* %3 to i8*
%8 = bitcast i32* %4 to i8*
%9 = call i32 @gets(i8* %5)
%10 = call i32 @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32* %3, i32* %4)
%11 = load i32, i32* %3
%12 = call i32 @strlen(i8* %5)
%13 = icmp sgt i32 %11, %12
br i1 %13, label %26, label %14
14: ; preds = %0
%15 = load i32, i32* %3
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 %16
%18 = getelementptr inbounds i8, i8* %17, i64 -1
%19 = load i32, i32* %4
%20 = call i32 @strncpy(i8* %6, i8* %18, i32 %19)
%21 = load i32, i32* %4
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 %22
store i8 0, i8* %23
%24 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0))
%25 = call i32 @puts(i8* %6)
br label %29
26: ; preds = %0
%27 = call i32 @strlen(i8* %5)
%28 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([56 x i8], [56 x i8]* @.str.2, i64 0, i64 0), i32 %27)
br label %29
29: ; preds = %26, %14
ret i32 0
}