int main() {
  char s[101];
  int n, i, l;
  scanf("%s %d", s, &n), l = (int)strlen(s);
  for (i = 0; i < l && i < n; putchar(s[l - ++i]))
    ;
}


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
lea    -0x74(%rbp),%rdx
mov    $0x0,%al
call   1050 <scanf@plt>
lea    -0x70(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x7c(%rbp)
movl   $0x0,-0x78(%rbp)
mov    -0x78(%rbp),%ecx
xor    %eax,%eax
cmp    -0x7c(%rbp),%ecx
mov    %al,-0x7d(%rbp)
jge    1188 <main+0x58>
mov    -0x78(%rbp),%eax
cmp    -0x74(%rbp),%eax
setl   %al
mov    %al,-0x7d(%rbp)
mov    -0x7d(%rbp),%al
test   $0x1,%al
jne    1198 <main+0x68>
jmp    11be <main+0x8e>
jmp    119d <main+0x6d>
mov    -0x7c(%rbp),%eax
mov    -0x78(%rbp),%ecx
add    $0x1,%ecx
mov    %ecx,-0x78(%rbp)
sub    %ecx,%eax
cltq
movsbl -0x70(%rbp,%rax,1),%edi
mov    $0x0,%al
call   1030 <putchar@plt>
jmp    116b <main+0x3b>
mov    -0x4(%rbp),%eax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x80,%rsp
lea    0xebd(%rip),%rdi
lea    0x10(%rsp),%r14
lea    0xc(%rsp),%rdx
mov    %r14,%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
mov    %r14,%rdi
call   1040 <strlen@plt>
test   %eax,%eax
jle    11a4 <main+0x74>
cmpl   $0x0,0xc(%rsp)
jle    11a4 <main+0x74>
movslq %eax,%r15
lea    (%r15,%r14,1),%rbx
add    $0xffffffffffffffff,%rbx
mov    $0x1,%r14d
nopl   0x0(%rax,%rax,1)
movsbl (%rbx),%edi
xor    %eax,%eax
call   1030 <putchar@plt>
cmp    %r14,%r15
jle    11a4 <main+0x74>
lea    0x1(%r14),%rax
add    $0xffffffffffffffff,%rbx
movslq 0xc(%rsp),%rcx
cmp    %rcx,%r14
mov    %rax,%r14
jl     1180 <main+0x50>
xor    %eax,%eax
add    $0x80,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

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

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