#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*/ printf(char *, char);
int read(char *);
int /*<<< orphan*/ scanf(char *, ...);
int main() {
  char a[100];
  int m, n;
  int i, j;
  scanf("%s", a);
  scanf("%d", &n);
  m = read(a);
  for (i = m - n; i < m; i++) {
    printf("%c", a[i]);
  }
  for (j = 0; j < m - n; j++) {
    printf("%c", a[j]);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x70(%rbp),%rsi
lea    0xeb3(%rip),%rdi
mov    $0x0,%al
call   1050 <scanf@plt>
lea    0xea8(%rip),%rdi
lea    -0x78(%rbp),%rsi
mov    $0x0,%al
call   1050 <scanf@plt>
lea    -0x70(%rbp),%rdi
call   1040 <read@plt>
mov    %eax,-0x74(%rbp)
mov    -0x74(%rbp),%eax
sub    -0x78(%rbp),%eax
mov    %eax,-0x7c(%rbp)
mov    -0x7c(%rbp),%eax
cmp    -0x74(%rbp),%eax
jge    11aa <main+0x7a>
movslq -0x7c(%rbp),%rax
lea    0xe74(%rip),%rdi
movsbl -0x70(%rbp,%rax,1),%esi
call   1030 <printf@plt>
mov    -0x7c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x7c(%rbp)
jmp    117b <main+0x4b>
movl   $0x0,-0x80(%rbp)
mov    -0x80(%rbp),%eax
mov    -0x74(%rbp),%ecx
sub    -0x78(%rbp),%ecx
cmp    %ecx,%eax
jge    11e5 <main+0xb5>
movslq -0x80(%rbp),%rax
lea    0xe39(%rip),%rdi
movsbl -0x70(%rbp,%rax,1),%esi
call   1030 <printf@plt>
mov    -0x80(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x80(%rbp)
jmp    11b1 <main+0x81>
xor    %eax,%eax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x78,%rsp
lea    0xebf(%rip),%rdi
lea    0x10(%rsp),%rbx
mov    %rbx,%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
lea    0xeac(%rip),%rdi
lea    0xc(%rsp),%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
mov    %rbx,%rdi
call   1040 <read@plt>
mov    %eax,%r14d
mov    0xc(%rsp),%eax
movslq %r14d,%rbp
test   %eax,%eax
jle    11aa <main+0x7a>
mov    %r14d,%ecx
sub    %eax,%ecx
movslq %ecx,%rbx
lea    0xe7e(%rip),%r15
nopl   0x0(%rax,%rax,1)
movsbl 0x10(%rsp,%rbx,1),%esi
mov    %r15,%rdi
call   1030 <printf@plt>
add    $0x1,%rbx
cmp    %rbp,%rbx
jl     1190 <main+0x60>
mov    0xc(%rsp),%eax
cmp    %eax,%r14d
jle    11e1 <main+0xb1>
xor    %ebx,%ebx
lea    0xe4e(%rip),%r14
nopl   0x0(%rax,%rax,1)
movsbl 0x10(%rsp,%rbx,1),%esi
mov    %r14,%rdi
call   1030 <printf@plt>
add    $0x1,%rbx
movslq 0xc(%rsp),%rax
mov    %rbp,%rcx
sub    %rax,%rcx
cmp    %rcx,%rbx
jl     11c0 <main+0x90>
xor    %eax,%eax
add    $0x78,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

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