#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 /*<<< orphan*/ scanf(char *, int *);
main() {
  int A[10] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}, i, k, v_end, j;
  printf("k=");
  scanf("%d", &k);
  for (j = 1; j <= k; j++) {
    v_end = A[10 - 1];
    for (i = 10 - 1; i > 0; i--) {
      A[i] = A[i - 1];
    }
    A[0] = v_end;
  }
  for (i = 1; i <= 10; i++)
    printf("A[%d]=%d\n", i - 1, A[i - 1]);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x30(%rbp),%rdi
lea    0xeb6(%rip),%rsi
mov    $0x28,%edx
call   1040 <memcpy@plt>
lea    0xecd(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xec2(%rip),%rdi
lea    -0x38(%rbp),%rsi
call   1050 <scanf@plt>
movl   $0x1,-0x40(%rbp)
mov    -0x40(%rbp),%eax
cmp    -0x38(%rbp),%eax
jg     11d2 <main+0xa2>
mov    -0xc(%rbp),%eax
mov    %eax,-0x3c(%rbp)
movl   $0x9,-0x34(%rbp)
cmpl   $0x0,-0x34(%rbp)
jle    11be <main+0x8e>
mov    -0x34(%rbp),%eax
sub    $0x1,%eax
cltq
mov    -0x30(%rbp,%rax,4),%ecx
movslq -0x34(%rbp),%rax
mov    %ecx,-0x30(%rbp,%rax,4)
mov    -0x34(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x34(%rbp)
jmp    1192 <main+0x62>
mov    -0x3c(%rbp),%eax
mov    %eax,-0x30(%rbp)
mov    -0x40(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x40(%rbp)
jmp    1179 <main+0x49>
movl   $0x1,-0x34(%rbp)
cmpl   $0xa,-0x34(%rbp)
jg     1211 <main+0xe1>
mov    -0x34(%rbp),%esi
sub    $0x1,%esi
mov    -0x34(%rbp),%eax
sub    $0x1,%eax
cltq
mov    -0x30(%rbp,%rax,4),%edx
lea    0xe32(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    11d9 <main+0xa9>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
mov    0xeeb(%rip),%rax
mov    %rax,0x20(%rsp)
movaps 0xecf(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movaps 0xeb3(%rip),%xmm0
movaps %xmm0,(%rsp)
lea    0xed0(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xec5(%rip),%rdi
lea    0x34(%rsp),%rsi
call   1040 <scanf@plt>
mov    0x34(%rsp),%edi
test   %edi,%edi
jle    12a5 <main+0x185>
movaps (%rsp),%xmm0
movaps 0x10(%rsp),%xmm1
movups %xmm0,0x4(%rsp)
mov    0x20(%rsp),%eax
movups %xmm1,0x14(%rsp)
mov    %eax,0x24(%rsp)
movl   $0xa,(%rsp)
mov    $0xa,%edx
cmp    $0x1,%edi
je     1283 <main+0x163>
lea    0x4(%rsp),%rax
lea    -0x1(%rdi),%esi
add    $0xfffffffe,%edi
mov    %esi,%ecx
and    $0x3,%ecx
cmp    $0x3,%edi
jb     124d <main+0x12d>
and    $0xfffffffc,%esi
nopl   0x0(%rax,%rax,1)
mov    0x24(%rsp),%edx
movaps (%rsp),%xmm0
movaps 0x10(%rsp),%xmm1
mov    0x20(%rsp),%edi
mov    %edi,0x20(%rax)
movups %xmm1,0x10(%rax)
movups %xmm0,(%rax)
mov    %edx,(%rsp)
mov    0x24(%rsp),%edx
movaps (%rsp),%xmm0
movaps 0x10(%rsp),%xmm1
mov    0x20(%rsp),%edi
mov    %edi,0x20(%rax)
movups %xmm1,0x10(%rax)
movups %xmm0,(%rax)
mov    %edx,(%rsp)
mov    0x24(%rsp),%edx
movaps (%rsp),%xmm0
movaps 0x10(%rsp),%xmm1
mov    0x20(%rsp),%edi
mov    %edi,0x20(%rax)
movups %xmm1,0x10(%rax)
movups %xmm0,(%rax)
mov    %edx,(%rsp)
mov    0x24(%rsp),%edx
movaps (%rsp),%xmm0
movaps 0x10(%rsp),%xmm1
mov    0x20(%rsp),%edi
mov    %edi,0x20(%rax)
movups %xmm1,0x10(%rax)
movups %xmm0,(%rax)
mov    %edx,(%rsp)
add    $0xfffffffc,%esi
jne    11d0 <main+0xb0>
test   %ecx,%ecx
je     1283 <main+0x163>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    0x24(%rsp),%edx
movaps (%rsp),%xmm0
movaps 0x10(%rsp),%xmm1
mov    0x20(%rsp),%esi
mov    %esi,0x20(%rax)
movups %xmm1,0x10(%rax)
movups %xmm0,(%rax)
mov    %edx,(%rsp)
add    $0xffffffff,%ecx
jne    1260 <main+0x140>
mov    0x4(%rsp),%r14d
mov    0x8(%rsp),%ebp
mov    0xc(%rsp),%r13d
mov    0x10(%rsp),%r12d
mov    0x14(%rsp),%r15d
mov    0x18(%rsp),%eax
mov    %eax,0x30(%rsp)
jmp    12cf <main+0x1af>
mov    $0x1,%edx
mov    $0x2,%r14d
mov    $0x3,%ebp
mov    $0x4,%r13d
mov    $0x5,%r12d
mov    $0x6,%r15d
movl   $0x7,0x30(%rsp)
lea    0xd58(%rip),%rbx
mov    %rbx,%rdi
xor    %esi,%esi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %rbx,%rdi
mov    $0x1,%esi
mov    %r14d,%edx
xor    %eax,%eax
call   1030 <printf@plt>
mov    %rbx,%rdi
mov    $0x2,%esi
mov    %ebp,%edx
xor    %eax,%eax
call   1030 <printf@plt>
mov    %rbx,%rdi
mov    $0x3,%esi
mov    %r13d,%edx
xor    %eax,%eax
call   1030 <printf@plt>
mov    %rbx,%rdi
mov    $0x4,%esi
mov    %r12d,%edx
xor    %eax,%eax
call   1030 <printf@plt>
mov    %rbx,%rdi
mov    $0x5,%esi
mov    %r15d,%edx
xor    %eax,%eax
call   1030 <printf@plt>
mov    %rbx,%rdi
mov    $0x6,%esi
mov    0x30(%rsp),%edx
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x1c(%rsp),%edx
mov    %rbx,%rdi
mov    $0x7,%esi
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x20(%rsp),%edx
mov    %rbx,%rdi
mov    $0x8,%esi
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x24(%rsp),%edx
mov    %rbx,%rdi
mov    $0x9,%esi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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