int main() {
  int source[100] = {1, 2, 3, 4, 5, 6};
  int dest[] = {10, 20, 30};
  int N = 6;
  int M = sizeof(dest) / sizeof(dest)[0];
  int k;
  scanf("%d", &k);
  for (int i = (N - 1); i >= k; i--) {
    source[i + M] = source[i];
  }
  for (int i = 0; i <= M; i++) {
    source[i + k] = dest[i];
  }
  for (int i = 0; i < M + N; i++) {
    printf("%d\n", source[i]);
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1d0,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x1a0(%rbp),%rdi
xor    %esi,%esi
mov    $0x190,%edx
call   1040 <memset@plt>
movl   $0x1,-0x1a0(%rbp)
movl   $0x2,-0x19c(%rbp)
movl   $0x3,-0x198(%rbp)
movl   $0x4,-0x194(%rbp)
movl   $0x5,-0x190(%rbp)
movl   $0x6,-0x18c(%rbp)
mov    0xe68(%rip),%rax
mov    %rax,-0x1ac(%rbp)
mov    0xe63(%rip),%eax
mov    %eax,-0x1a4(%rbp)
movl   $0x6,-0x1b0(%rbp)
movl   $0x3,-0x1b4(%rbp)
lea    0xe46(%rip),%rdi
lea    -0x1b8(%rbp),%rsi
mov    $0x0,%al
call   1050 <scanf@plt>
mov    -0x1b0(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x1bc(%rbp)
mov    -0x1bc(%rbp),%eax
cmp    -0x1b8(%rbp),%eax
jl     122c <main+0xfc>
movslq -0x1bc(%rbp),%rax
mov    -0x1a0(%rbp,%rax,4),%ecx
mov    -0x1bc(%rbp),%eax
add    -0x1b4(%rbp),%eax
cltq
mov    %ecx,-0x1a0(%rbp,%rax,4)
mov    -0x1bc(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x1bc(%rbp)
jmp    11e3 <main+0xb3>
movl   $0x0,-0x1c0(%rbp)
mov    -0x1c0(%rbp),%eax
cmp    -0x1b4(%rbp),%eax
jg     127f <main+0x14f>
movslq -0x1c0(%rbp),%rax
mov    -0x1ac(%rbp,%rax,4),%ecx
mov    -0x1c0(%rbp),%eax
add    -0x1b8(%rbp),%eax
cltq
mov    %ecx,-0x1a0(%rbp,%rax,4)
mov    -0x1c0(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c0(%rbp)
jmp    1236 <main+0x106>
movl   $0x0,-0x1c4(%rbp)
mov    -0x1c4(%rbp),%eax
mov    -0x1b4(%rbp),%ecx
add    -0x1b0(%rbp),%ecx
cmp    %ecx,%eax
jge    12d3 <main+0x1a3>
movslq -0x1c4(%rbp),%rax
mov    -0x1a0(%rbp,%rax,4),%esi
lea    0xd57(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x1c4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c4(%rbp)
jmp    1289 <main+0x159>
mov    -0x4(%rbp),%eax
add    $0x1d0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x1a0,%rsp
lea    0x20(%rsp),%rdi
mov    $0x180,%edx
xor    %esi,%esi
call   1040 <memset@plt>
movaps 0xeb0(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movabs $0x600000005,%rax
mov    %rax,0x20(%rsp)
lea    0xeb1(%rip),%rdi
lea    0xc(%rsp),%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
movslq 0xc(%rsp),%rax
mov    %eax,%ecx
cmp    $0x6,%rax
jl     1189 <main+0x59>
mov    %rcx,%rax
jmp    11b4 <main+0x84>
movl   $0x6,0x30(%rsp)
cmp    $0x5,%ecx
je     11b4 <main+0x84>
mov    $0x4,%ecx
nopl   0x0(%rax,%rax,1)
mov    0x10(%rsp,%rcx,4),%edx
mov    %edx,0x1c(%rsp,%rcx,4)
lea    -0x1(%rcx),%rdx
cmp    %rax,%rcx
mov    %rdx,%rcx
jg     11a0 <main+0x70>
movups 0xe55(%rip),%xmm0
movups %xmm0,0x10(%rsp,%rax,4)
mov    0x10(%rsp),%esi
lea    0xe54(%rip),%rbx
mov    %rbx,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x14(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x18(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x1c(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x20(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x24(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x28(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x2c(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x30(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x1a0,%rsp
pop    %rbx
ret

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

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