#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 *);
int main() {
  int i, n, arr[50], insert, position;
  printf("Enter the size of array\n");
  scanf("%d", &n);
  printf("Enter the elements of array\n");
  for (i = 0; i < n; i++) {
    scanf("%d", &arr[i]);
  }
  printf("Enter the location where you wish to insert an element\n");
  scanf("%d", &position);
  printf("Enter the element which you want to insert\n");
  scanf("%d", &insert);
  for (i = n - 1; i >= position - 1; i--)
    arr[i + 1] = arr[i];
  arr[position - 1] = insert;
  printf("You entered array\n");
  for (i = 0; i < n + 1; i++) {
    printf("%d", arr[i]);
    if (i < n)
      printf(",");
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xf0,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xec7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xed2(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1040 <scanf@plt>
lea    0xec5(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    119d <main+0x7d>
movslq -0x8(%rbp),%rax
lea    -0xe0(%rbp),%rsi
shl    $0x2,%rax
add    %rax,%rsi
lea    0xe8f(%rip),%rdi
call   1040 <scanf@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1165 <main+0x45>
lea    0xe95(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe67(%rip),%rdi
lea    -0xe8(%rbp),%rsi
call   1040 <scanf@plt>
lea    0xeac(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe46(%rip),%rdi
lea    -0xe4(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0xc(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    -0xe8(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jl     1224 <main+0x104>
movslq -0x8(%rbp),%rax
mov    -0xe0(%rbp,%rax,4),%ecx
mov    -0x8(%rbp),%eax
add    $0x1,%eax
cltq
mov    %ecx,-0xe0(%rbp,%rax,4)
mov    -0x8(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x8(%rbp)
jmp    11e8 <main+0xc8>
mov    -0xe4(%rbp),%ecx
mov    -0xe8(%rbp),%eax
sub    $0x1,%eax
cltq
mov    %ecx,-0xe0(%rbp,%rax,4)
lea    0xe5a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    -0xc(%rbp),%ecx
add    $0x1,%ecx
cmp    %ecx,%eax
jge    12a8 <main+0x188>
movslq -0x8(%rbp),%rax
mov    -0xe0(%rbp,%rax,4),%esi
lea    0xda5(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    1295 <main+0x175>
lea    0xe22(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    129a <main+0x17a>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1251 <main+0x131>
xor    %eax,%eax
add    $0xf0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0xe0,%rsp
lea    0xeb0(%rip),%rdi
call   1040 <puts@plt>
lea    0xea1(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1060 <scanf@plt>
lea    0xeab(%rip),%rdi
call   1040 <puts@plt>
cmpl   $0x0,0x4(%rsp)
jle    11ad <main+0x6d>
lea    0x10(%rsp),%r15
xor    %ebx,%ebx
lea    0xe76(%rip),%r14
nopw   0x0(%rax,%rax,1)
mov    %r14,%rdi
mov    %r15,%rsi
call   1060 <scanf@plt>
add    $0x1,%rbx
movslq 0x4(%rsp),%rax
add    $0x4,%r15
cmp    %rax,%rbx
jl     1190 <main+0x50>
lea    0xe83(%rip),%rdi
call   1040 <puts@plt>
lea    0xe40(%rip),%rbx
lea    0x8(%rsp),%rsi
mov    %rbx,%rdi
call   1060 <scanf@plt>
lea    0xe9a(%rip),%rdi
call   1040 <puts@plt>
lea    0xc(%rsp),%rsi
mov    %rbx,%rdi
call   1060 <scanf@plt>
movslq 0x4(%rsp),%rcx
movslq 0x8(%rsp),%rax
cmp    %eax,%ecx
jl     1252 <main+0x112>
mov    %ecx,%edi
sub    %eax,%edi
add    $0x1,%edi
mov    %rcx,%rsi
sub    %rax,%rsi
and    $0x3,%rdi
je     122d <main+0xed>
nopw   0x0(%rax,%rax,1)
lea    -0x1(%rcx),%rdx
mov    0xc(%rsp,%rcx,4),%ebx
mov    %ebx,0x10(%rsp,%rcx,4)
mov    %rdx,%rcx
add    $0xffffffffffffffff,%rdi
jne    1210 <main+0xd0>
cmp    $0x3,%rsi
jae    1236 <main+0xf6>
jmp    1252 <main+0x112>
mov    %rcx,%rdx
cmp    $0x3,%rsi
jb     1252 <main+0x112>
add    $0x1,%rdx
nopw   0x0(%rax,%rax,1)
movups -0x4(%rsp,%rdx,4),%xmm0
movups %xmm0,(%rsp,%rdx,4)
add    $0xfffffffffffffffc,%rdx
cmp    %rax,%rdx
jg     1240 <main+0x100>
mov    0xc(%rsp),%ecx
mov    %ecx,0xc(%rsp,%rax,4)
lea    0xe38(%rip),%rdi
call   1040 <puts@plt>
cmpl   $0x0,0x4(%rsp)
js     12b5 <main+0x175>
lea    0xd8c(%rip),%r14
xor    %ebx,%ebx
jmp    128c <main+0x14c>
nopl   0x0(%rax,%rax,1)
lea    0x1(%rbx),%rcx
cmp    %rax,%rbx
mov    %rcx,%rbx
jge    12b5 <main+0x175>
mov    0x10(%rsp,%rbx,4),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
movslq 0x4(%rsp),%rax
cmp    %rax,%rbx
jge    1280 <main+0x140>
mov    $0x2c,%edi
call   1030 <putchar@plt>
movslq 0x4(%rsp),%rax
jmp    1280 <main+0x140>
xor    %eax,%eax
add    $0xe0,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
@.str.1 = [3 x i8] c"%d\00"
@str = [24 x i8] c"Enter the size of array\00"
@str.7 = [28 x i8] c"Enter the elements of array\00"
@str.8 = [55 x i8] c"Enter the location where you wish to insert an element\00"
@str.9 = [43 x i8] c"Enter the element which you want to insert\00"
@str.10 = [18 x i8] c"You entered array\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [50 x i32]
%3 = alloca i32
%4 = alloca i32
%5 = bitcast i32* %1 to i8*
%6 = bitcast [50 x i32]* %2 to i8*
%7 = bitcast i32* %3 to i8*
%8 = bitcast i32* %4 to i8*
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @str, i64 0, i64 0))
%10 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%11 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @str.7, i64 0, i64 0))
%12 = load i32, i32* %1
%13 = icmp sgt i32 %12, 0
br i1 %13, label %14, label %22
14: ; preds = %0, %14
%15 = phi i64 [ %18, %14 ], [ 0, %0 ]
%16 = getelementptr inbounds [50 x i32], [50 x i32]* %2, i64 0, i64 %15
%17 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %16)
%18 = add nuw nsw i64 %15, 1
%19 = load i32, i32* %1
%20 = sext i32 %19 to i64
%21 = icmp slt i64 %18, %20
br i1 %21, label %14, label %22
22: ; preds = %14, %0
%23 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([55 x i8], [55 x i8]* @str.8, i64 0, i64 0))
%24 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %4)
%25 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([43 x i8], [43 x i8]* @str.9, 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 = load i32, i32* %1
%28 = load i32, i32* %4
%29 = icmp slt i32 %27, %28
br i1 %29, label %69, label %30
30: ; preds = %22
%31 = sext i32 %27 to i64
%32 = sext i32 %28 to i64
%33 = add nsw i64 %31, 1
%34 = sub nsw i64 %33, %32
%35 = sub nsw i64 %31, %32
%36 = and i64 %34, 3
%37 = icmp eq i64 %36, 0
br i1 %37, label %47, label %38
38: ; preds = %30, %38
%39 = phi i64 [ %41, %38 ], [ %31, %30 ]
%40 = phi i64 [ %45, %38 ], [ 0, %30 ]
%41 = add nsw i64 %39, -1
%42 = getelementptr inbounds [50 x i32], [50 x i32]* %2, i64 0, i64 %41
%43 = load i32, i32* %42
%44 = getelementptr inbounds [50 x i32], [50 x i32]* %2, i64 0, i64 %39
store i32 %43, i32* %44
%45 = add i64 %40, 1
%46 = icmp eq i64 %45, %36
br i1 %46, label %47, label %38
47: ; preds = %38, %30
%48 = phi i64 [ %31, %30 ], [ %41, %38 ]
%49 = icmp ult i64 %35, 3
br i1 %49, label %69, label %50
50: ; preds = %47, %50
%51 = phi i64 [ %64, %50 ], [ %48, %47 ]
%52 = add nsw i64 %51, -1
%53 = getelementptr inbounds [50 x i32], [50 x i32]* %2, i64 0, i64 %52
%54 = load i32, i32* %53
%55 = getelementptr inbounds [50 x i32], [50 x i32]* %2, i64 0, i64 %51
store i32 %54, i32* %55
%56 = add nsw i64 %51, -2
%57 = getelementptr inbounds [50 x i32], [50 x i32]* %2, i64 0, i64 %56
%58 = load i32, i32* %57
%59 = getelementptr inbounds [50 x i32], [50 x i32]* %2, i64 0, i64 %52
store i32 %58, i32* %59
%60 = add nsw i64 %51, -3
%61 = getelementptr inbounds [50 x i32], [50 x i32]* %2, i64 0, i64 %60
%62 = load i32, i32* %61
%63 = getelementptr inbounds [50 x i32], [50 x i32]* %2, i64 0, i64 %56
store i32 %62, i32* %63
%64 = add nsw i64 %51, -4
%65 = getelementptr inbounds [50 x i32], [50 x i32]* %2, i64 0, i64 %64
%66 = load i32, i32* %65
%67 = getelementptr inbounds [50 x i32], [50 x i32]* %2, i64 0, i64 %60
store i32 %66, i32* %67
%68 = icmp sgt i64 %60, %32
br i1 %68, label %50, label %69
69: ; preds = %47, %50, %22
%70 = add nsw i32 %28, -1
%71 = load i32, i32* %3
%72 = sext i32 %70 to i64
%73 = getelementptr inbounds [50 x i32], [50 x i32]* %2, i64 0, i64 %72
store i32 %71, i32* %73
%74 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @str.10, i64 0, i64 0))
%75 = load i32, i32* %1
%76 = icmp slt i32 %75, 0
br i1 %76, label %93, label %77
77: ; preds = %69, %89
%78 = phi i64 [ %91, %89 ], [ 0, %69 ]
%79 = getelementptr inbounds [50 x i32], [50 x i32]* %2, i64 0, i64 %78
%80 = load i32, i32* %79
%81 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %80)
%82 = load i32, i32* %1
%83 = sext i32 %82 to i64
%84 = icmp slt i64 %78, %83
br i1 %84, label %85, label %89
85: ; preds = %77
%86 = call i32 @putchar(i32 44)
%87 = load i32, i32* %1
%88 = sext i32 %87 to i64
br label %89
89: ; preds = %77, %85
%90 = phi i64 [ %83, %77 ], [ %88, %85 ]
%91 = add nuw nsw i64 %78, 1
%92 = icmp slt i64 %78, %90
br i1 %92, label %77, label %93
93: ; preds = %89, %69
ret i32 0
}