#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*/ Print_array(int *, int);
int /*<<< orphan*/ Read_array(int *, int);
int /*<<< orphan*/ circular_shift(int, int *, int);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ scanf(char *, int *);
int main(void) {
  int size, shift_amount;
  do {
    printf("How many elements in your array? > 0 && < 20 \n");
    scanf("%d", &size);
  } while (size > 20 || size < 1);
  int array_of_elements[size];
  printf("Enter the elements of your array. \n");
  Read_array(array_of_elements, size);
  printf("How many places would you like to shift array? \n");
  scanf("%d", &shift_amount);
  printf("Before: \n");
  Print_array(array_of_elements, size);
  circular_shift(size, array_of_elements, shift_amount);
  printf("After: \n");
  Print_array(array_of_elements, size);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe9a(%rip),%rdi
call   1040 <printf@plt>
lea    0xebd(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1060 <scanf@plt>
mov    $0x1,%al
cmpl   $0x14,-0x8(%rbp)
mov    %al,-0x21(%rbp)
jg     1194 <main+0x44>
cmpl   $0x1,-0x8(%rbp)
setl   %al
mov    %al,-0x21(%rbp)
mov    -0x21(%rbp),%al
test   $0x1,%al
jne    115f <main+0xf>
mov    -0x8(%rbp),%eax
mov    %rsp,%rcx
mov    %rcx,-0x18(%rbp)
lea    0xf(,%rax,4),%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x30(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x20(%rbp)
lea    0xe65(%rip),%rdi
call   1040 <printf@plt>
mov    -0x30(%rbp),%rdi
mov    -0x8(%rbp),%esi
call   1030 <Read_array@plt>
lea    0xe71(%rip),%rdi
call   1040 <printf@plt>
lea    0xe3e(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1060 <scanf@plt>
lea    0xe86(%rip),%rdi
call   1040 <printf@plt>
mov    -0x30(%rbp),%rdi
mov    -0x8(%rbp),%esi
call   1070 <Print_array@plt>
mov    -0x30(%rbp),%rsi
mov    -0x8(%rbp),%edi
mov    -0xc(%rbp),%edx
call   1050 <circular_shift@plt>
lea    0xe69(%rip),%rdi
call   1040 <printf@plt>
mov    -0x30(%rbp),%rdi
mov    -0x8(%rbp),%esi
call   1070 <Print_array@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %rbx
push   %rax
lea    0xea2(%rip),%r14
lea    0xe98(%rip),%r15
lea    -0x1c(%rbp),%rbx
nopl   0x0(%rax)
mov    %r14,%rdi
call   1030 <puts@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1060 <scanf@plt>
mov    -0x1c(%rbp),%eax
lea    -0x15(%rax),%ecx
cmp    $0xffffffec,%ecx
jb     1170 <main+0x20>
mov    %rsp,%r14
mov    %rsp,%rbx
lea    0xf(,%rax,4),%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%rbx
mov    %rbx,%rsp
lea    0xe84(%rip),%rdi
call   1030 <puts@plt>
mov    -0x1c(%rbp),%esi
mov    %rbx,%rdi
call   1040 <Read_array@plt>
lea    0xe90(%rip),%rdi
call   1030 <puts@plt>
lea    0xe30(%rip),%rdi
lea    -0x20(%rbp),%rsi
call   1060 <scanf@plt>
lea    0xea4(%rip),%rdi
call   1030 <puts@plt>
mov    -0x1c(%rbp),%esi
mov    %rbx,%rdi
call   1070 <Print_array@plt>
mov    -0x1c(%rbp),%edi
mov    -0x20(%rbp),%edx
mov    %rbx,%rsi
call   1050 <circular_shift@plt>
lea    0xe88(%rip),%rdi
call   1030 <puts@plt>
mov    -0x1c(%rbp),%esi
mov    %rbx,%rdi
call   1070 <Print_array@plt>
mov    %r14,%rsp
xor    %eax,%eax
lea    -0x18(%rbp),%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [47 x i8] c"How many elements in your array? > 0 && < 20 \0A\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [36 x i8] c"Enter the elements of your array. \0A\00"
@.str.3 = [49 x i8] c"How many places would you like to shift array? \0A\00"
@.str.4 = [10 x i8] c"Before: \0A\00"
@.str.5 = [9 x i8] c"After: \0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i64
store i32 0, i32* %1
br label %6
6: ; preds = %15, %0
%7 = call i32 @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str, i64 0, i64 0))
%8 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
br label %9
9: ; preds = %6
%10 = load i32, i32* %2
%11 = icmp sgt i32 %10, 20
br i1 %11, label %15, label %12
12: ; preds = %9
%13 = load i32, i32* %2
%14 = icmp slt i32 %13, 1
br label %15
15: ; preds = %12, %9
%16 = phi i1 [ true, %9 ], [ %14, %12 ]
br i1 %16, label %6, label %17
17: ; preds = %15
%18 = load i32, i32* %2
%19 = zext i32 %18 to i64
%20 = call i8* @llvm.stacksave()
store i8* %20, i8** %4
%21 = alloca i32, i64 %19
store i64 %19, i64* %5
%22 = call i32 @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.2, i64 0, i64 0))
%23 = load i32, i32* %2
%24 = call i32 @Read_array(i32* %21, i32 %23)
%25 = call i32 @printf(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.3, i64 0, i64 0))
%26 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%27 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0))
%28 = load i32, i32* %2
%29 = call i32 @Print_array(i32* %21, i32 %28)
%30 = load i32, i32* %2
%31 = load i32, i32* %3
%32 = call i32 @circular_shift(i32 %30, i32* %21, i32 %31)
%33 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0))
%34 = load i32, i32* %2
%35 = call i32 @Print_array(i32* %21, i32 %34)
store i32 0, i32* %1
%36 = load i8*, i8** %4
%37 = load i32, i32* %1
ret i32 %37
}

LLVM IR (-O2):
@.str.1 = [3 x i8] c"%d\00"
@str = [46 x i8] c"How many elements in your array? > 0 && < 20 \00"
@str.6 = [35 x i8] c"Enter the elements of your array. \00"
@str.7 = [48 x i8] c"How many places would you like to shift array? \00"
@str.8 = [9 x i8] c"Before: \00"
@str.9 = [8 x i8] c"After: \00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = bitcast i32* %1 to i8*
%4 = bitcast i32* %2 to i8*
br label %5
5: ; preds = %5, %0
%6 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([46 x i8], [46 x i8]* @str, i64 0, i64 0))
%7 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%8 = load i32, i32* %1
%9 = add i32 %8, -21
%10 = icmp ult i32 %9, -20
br i1 %10, label %5, label %11
11: ; preds = %5
%12 = zext i32 %8 to i64
%13 = call i8* @llvm.stacksave()
%14 = alloca i32, i64 %12
%15 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @str.6, i64 0, i64 0))
%16 = load i32, i32* %1
%17 = call i32 @Read_array(i32* %14, i32 %16)
%18 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([48 x i8], [48 x i8]* @str.7, i64 0, i64 0))
%19 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%20 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @str.8, i64 0, i64 0))
%21 = load i32, i32* %1
%22 = call i32 @Print_array(i32* %14, i32 %21)
%23 = load i32, i32* %1
%24 = load i32, i32* %2
%25 = call i32 @circular_shift(i32 %23, i32* %14, i32 %24)
%26 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @str.9, i64 0, i64 0))
%27 = load i32, i32* %1
%28 = call i32 @Print_array(i32* %14, i32 %27)
ret i32 0
}