#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(void) {
  int a[30];
  int i, num, pos, in;
  printf("Enter number of elements: \n> ");
  scanf("%d", &in);
  for (i = 0; i < in; i++) {
    scanf("%d", &a[i]);
  }
  printf("Enter the number to be insterted: \n> ");
  scanf("%d", &num);
  printf("Enter the location to be insterted: \n> ");
  scanf("%d", &pos);
  for (i = in; i >= pos; i--) {
    a[i] = a[i - 1];
  }
  in++;
  a[pos - 1] = num;
  for (i = 0; i < in; i++) {
    printf("%d", a[i]);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xec7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xed7(%rip),%rdi
lea    -0x90(%rbp),%rsi
call   1040 <scanf@plt>
movl   $0x0,-0x84(%rbp)
mov    -0x84(%rbp),%eax
cmp    -0x90(%rbp),%eax
jge    11a1 <main+0x81>
movslq -0x84(%rbp),%rax
lea    -0x80(%rbp),%rsi
shl    $0x2,%rax
add    %rax,%rsi
lea    0xe96(%rip),%rdi
call   1040 <scanf@plt>
mov    -0x84(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x84(%rbp)
jmp    115d <main+0x3d>
lea    0xe79(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe68(%rip),%rdi
lea    -0x88(%rbp),%rsi
call   1040 <scanf@plt>
lea    0xe7e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe47(%rip),%rdi
lea    -0x8c(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0x90(%rbp),%eax
mov    %eax,-0x84(%rbp)
mov    -0x84(%rbp),%eax
cmp    -0x8c(%rbp),%eax
jl     122f <main+0x10f>
mov    -0x84(%rbp),%eax
sub    $0x1,%eax
cltq
mov    -0x80(%rbp,%rax,4),%ecx
movslq -0x84(%rbp),%rax
mov    %ecx,-0x80(%rbp,%rax,4)
mov    -0x84(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x84(%rbp)
jmp    11ef <main+0xcf>
mov    -0x90(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x90(%rbp)
mov    -0x88(%rbp),%ecx
mov    -0x8c(%rbp),%eax
sub    $0x1,%eax
cltq
mov    %ecx,-0x80(%rbp,%rax,4)
movl   $0x0,-0x84(%rbp)
mov    -0x84(%rbp),%eax
cmp    -0x90(%rbp),%eax
jge    129c <main+0x17c>
movslq -0x84(%rbp),%rax
mov    -0x80(%rbp,%rax,4),%esi
lea    0xd9d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x84(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x84(%rbp)
jmp    125d <main+0x13d>
xor    %eax,%eax
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x90,%rsp
lea    0xecd(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xedd(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1040 <scanf@plt>
cmpl   $0x0,0x4(%rsp)
jle    117d <main+0x5d>
lea    0x10(%rsp),%r15
xor    %ebx,%ebx
lea    0xebe(%rip),%r14
mov    %r14,%rdi
mov    %r15,%rsi
call   1040 <scanf@plt>
add    $0x1,%rbx
movslq 0x4(%rsp),%rax
add    $0x4,%r15
cmp    %rax,%rbx
jl     1160 <main+0x40>
lea    0xe9d(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xe8c(%rip),%rbx
lea    0xc(%rsp),%rsi
mov    %rbx,%rdi
call   1040 <scanf@plt>
lea    0xea1(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0x8(%rsp),%rsi
mov    %rbx,%rdi
call   1040 <scanf@plt>
movslq 0x4(%rsp),%rdi
movslq 0x8(%rsp),%rcx
cmp    %ecx,%edi
jl     1222 <main+0x102>
mov    %edi,%esi
sub    %ecx,%esi
add    $0x1,%esi
mov    %rdi,%r8
sub    %rcx,%r8
mov    %rdi,%rdx
and    $0x3,%rsi
je     1205 <main+0xe5>
mov    %rdi,%rax
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
lea    -0x1(%rax),%rdx
mov    0xc(%rsp,%rax,4),%ebx
mov    %ebx,0x10(%rsp,%rax,4)
mov    %rdx,%rax
add    $0xffffffffffffffff,%rsi
jne    11f0 <main+0xd0>
cmp    $0x3,%r8
jb     1222 <main+0x102>
add    $0x1,%rdx
nop
movups -0x4(%rsp,%rdx,4),%xmm0
movups %xmm0,(%rsp,%rdx,4)
add    $0xfffffffffffffffc,%rdx
cmp    %rcx,%rdx
jg     1210 <main+0xf0>
lea    0x1(%rdi),%eax
mov    %eax,0x4(%rsp)
mov    0xc(%rsp),%eax
mov    %eax,0xc(%rsp,%rcx,4)
test   %edi,%edi
js     125c <main+0x13c>
lea    0xde2(%rip),%r14
xor    %ebx,%ebx
xchg   %ax,%ax
mov    0x10(%rsp,%rbx,4),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
add    $0x1,%rbx
movslq 0x4(%rsp),%rax
cmp    %rax,%rbx
jl     1240 <main+0x120>
xor    %eax,%eax
add    $0x90,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

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

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