#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 *, int);
int /*<<< orphan*/ scanf(char *, int *, int *);
int main() {
  int K, M, i, j, count = 1, n;
  int arr[5], arr2[5];
  n = 5;
  scanf("%d%d", &K, &M);
  for (i = 0; i < n; i++) {
    arr[i] = count++;
  }
  for (j = 0; j < 5; j++) {
    if (M > n) {
      M = M % n;
    }
    arr2[j] = arr[K + M - 1];
    n--;
    printf("%d\n", arr2[j]);
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0x18(%rbp)
movl   $0x5,-0x1c(%rbp)
lea    0xebc(%rip),%rdi
lea    -0x8(%rbp),%rsi
lea    -0xc(%rbp),%rdx
call   1040 <scanf@plt>
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    1185 <main+0x65>
mov    -0x18(%rbp),%ecx
mov    %ecx,%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
movslq -0x10(%rbp),%rax
mov    %ecx,-0x30(%rbp,%rax,4)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1158 <main+0x38>
movl   $0x0,-0x14(%rbp)
cmpl   $0x5,-0x14(%rbp)
jge    11ee <main+0xce>
mov    -0xc(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jle    11ac <main+0x8c>
mov    -0xc(%rbp),%eax
cltd
idivl  -0x1c(%rbp)
mov    %edx,-0xc(%rbp)
mov    -0x8(%rbp),%eax
add    -0xc(%rbp),%eax
sub    $0x1,%eax
cltq
mov    -0x30(%rbp,%rax,4),%ecx
movslq -0x14(%rbp),%rax
mov    %ecx,-0x50(%rbp,%rax,4)
mov    -0x1c(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x1c(%rbp)
movslq -0x14(%rbp),%rax
mov    -0x50(%rbp,%rax,4),%esi
lea    0xe2a(%rip),%rdi
call   1030 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    118c <main+0x6c>
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x28,%rsp
lea    0xee5(%rip),%rdi
lea    0xc(%rsp),%rsi
lea    0x8(%rsp),%rdx
call   1040 <scanf@plt>
movaps 0xebf(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movl   $0x5,0x20(%rsp)
mov    0x8(%rsp),%eax
cmp    $0x6,%eax
jl     116f <main+0x4f>
mov    %eax,%ecx
mov    $0xcccccccd,%edx
imul   %rcx,%rdx
shr    $0x22,%rdx
lea    (%rdx,%rdx,4),%ecx
sub    %ecx,%eax
mov    %eax,0x8(%rsp)
mov    0xc(%rsp),%ecx
add    %ecx,%eax
add    $0xffffffff,%eax
cltq
mov    0x10(%rsp,%rax,4),%esi
lea    0xe90(%rip),%rdi
call   1030 <printf@plt>
mov    0x8(%rsp),%eax
cmp    $0x5,%eax
jl     119a <main+0x7a>
and    $0x3,%eax
mov    %eax,0x8(%rsp)
mov    0xc(%rsp),%ecx
add    %ecx,%eax
add    $0xffffffff,%eax
cltq
mov    0x10(%rsp,%rax,4),%esi
lea    0xe65(%rip),%rdi
call   1030 <printf@plt>
mov    0x8(%rsp),%eax
cmp    $0x4,%eax
jl     11d6 <main+0xb6>
mov    %eax,%ecx
mov    $0xaaaaaaab,%edx
imul   %rcx,%rdx
shr    $0x21,%rdx
lea    (%rdx,%rdx,2),%ecx
sub    %ecx,%eax
mov    %eax,0x8(%rsp)
mov    0xc(%rsp),%ecx
add    %ecx,%eax
add    $0xffffffff,%eax
cltq
mov    0x10(%rsp,%rax,4),%esi
lea    0xe29(%rip),%rdi
call   1030 <printf@plt>
mov    0x8(%rsp),%eax
cmp    $0x3,%eax
jl     1201 <main+0xe1>
and    $0x1,%eax
mov    %eax,0x8(%rsp)
mov    0xc(%rsp),%ecx
add    %ecx,%eax
add    $0xffffffff,%eax
cltq
mov    0x10(%rsp,%rax,4),%esi
lea    0xdfe(%rip),%rdi
call   1030 <printf@plt>
mov    0x8(%rsp),%eax
cmp    $0x2,%eax
jl     122f <main+0x10f>
movl   $0x0,0x8(%rsp)
xor    %eax,%eax
mov    0xc(%rsp),%ecx
add    %ecx,%eax
add    $0xffffffff,%eax
cltq
mov    0x10(%rsp,%rax,4),%esi
lea    0xdd0(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x28,%rsp
ret

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

LLVM IR (-O2):
@.str = [5 x i8] c"%d%d\00"
@.str.1 = [4 x i8] c"%d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca [5 x i32]
%4 = bitcast i32* %1 to i8*
%5 = bitcast i32* %2 to i8*
%6 = bitcast [5 x i32]* %3 to i8*
%7 = call i32 @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32* %1, i32* %2)
%8 = bitcast [5 x i32]* %3 to <4 x i32>*
store <4 x i32> <i32 1, i32 2, i32 3, i32 4>, <4 x i32>* %8
%9 = getelementptr inbounds [5 x i32], [5 x i32]* %3, i64 0, i64 4
store i32 5, i32* %9
%10 = load i32, i32* %2
%11 = icmp sgt i32 %10, 5
br i1 %11, label %12, label %14
12: ; preds = %0
%13 = urem i32 %10, 5
store i32 %13, i32* %2
br label %14
14: ; preds = %12, %0
%15 = phi i32 [ %13, %12 ], [ %10, %0 ]
%16 = load i32, i32* %1
%17 = add i32 %16, -1
%18 = add i32 %17, %15
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds [5 x i32], [5 x i32]* %3, i64 0, i64 %19
%21 = load i32, i32* %20
%22 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %21)
%23 = load i32, i32* %2
%24 = icmp sgt i32 %23, 4
br i1 %24, label %25, label %27
25: ; preds = %14
%26 = and i32 %23, 3
store i32 %26, i32* %2
br label %27
27: ; preds = %25, %14
%28 = phi i32 [ %26, %25 ], [ %23, %14 ]
%29 = load i32, i32* %1
%30 = add i32 %29, -1
%31 = add i32 %30, %28
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds [5 x i32], [5 x i32]* %3, i64 0, i64 %32
%34 = load i32, i32* %33
%35 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %34)
%36 = load i32, i32* %2
%37 = icmp sgt i32 %36, 3
br i1 %37, label %38, label %40
38: ; preds = %27
%39 = urem i32 %36, 3
store i32 %39, i32* %2
br label %40
40: ; preds = %38, %27
%41 = phi i32 [ %39, %38 ], [ %36, %27 ]
%42 = load i32, i32* %1
%43 = add i32 %42, -1
%44 = add i32 %43, %41
%45 = sext i32 %44 to i64
%46 = getelementptr inbounds [5 x i32], [5 x i32]* %3, i64 0, i64 %45
%47 = load i32, i32* %46
%48 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %47)
%49 = load i32, i32* %2
%50 = icmp sgt i32 %49, 2
br i1 %50, label %51, label %53
51: ; preds = %40
%52 = and i32 %49, 1
store i32 %52, i32* %2
br label %53
53: ; preds = %51, %40
%54 = phi i32 [ %52, %51 ], [ %49, %40 ]
%55 = load i32, i32* %1
%56 = add i32 %55, -1
%57 = add i32 %56, %54
%58 = sext i32 %57 to i64
%59 = getelementptr inbounds [5 x i32], [5 x i32]* %3, i64 0, i64 %58
%60 = load i32, i32* %59
%61 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %60)
%62 = load i32, i32* %2
%63 = icmp sgt i32 %62, 1
br i1 %63, label %64, label %65
64: ; preds = %53
store i32 0, i32* %2
br label %65
65: ; preds = %64, %53
%66 = phi i32 [ 0, %64 ], [ %62, %53 ]
%67 = load i32, i32* %1
%68 = add i32 %67, -1
%69 = add i32 %68, %66
%70 = sext i32 %69 to i64
%71 = getelementptr inbounds [5 x i32], [5 x i32]* %3, i64 0, i64 %70
%72 = load i32, i32* %71
%73 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %72)
ret i32 0
}