#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 *, ...);
main() {
  int LA[] = {1, 3, 5, 7, 8};
  int item = 10, k = 3, n = 5;
  int i = 0, j = n;
  printf("The original array elements are :\n");
  for (i = 0; i < n; i++) {
    printf("LA[%d] = %d \n", i, LA[i]);
  }
  n = n + 1;
  while (j >= k) {
    printf("Value of j is %d , k is %d and n is %d \n", j, k, n);
    LA[j + 1] = LA[j];
    printf("Value of LA[%d] = %d and LA[%d] = %d \n", j + 1, LA[j + 1], j,
           LA[j]);
    j = j - 1;
  }
  LA[k] = item;
  printf("The array elements after insertion :\n");
  for (i = 0; i < n; i++) {
    printf("LA[%d] = %d \n", i, LA[i]);
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    0xeda(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0xed7(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    0xed5(%rip),%eax
mov    %eax,-0x10(%rbp)
movl   $0xa,-0x24(%rbp)
movl   $0x3,-0x28(%rbp)
movl   $0x5,-0x2c(%rbp)
movl   $0x0,-0x30(%rbp)
mov    -0x2c(%rbp),%eax
mov    %eax,-0x34(%rbp)
lea    0xead(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x30(%rbp)
mov    -0x30(%rbp),%eax
cmp    -0x2c(%rbp),%eax
jge    11a8 <main+0x98>
mov    -0x30(%rbp),%esi
movslq -0x30(%rbp),%rax
mov    -0x20(%rbp,%rax,4),%edx
lea    0xee6(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x30(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30(%rbp)
jmp    1175 <main+0x65>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
mov    -0x34(%rbp),%eax
cmp    -0x28(%rbp),%eax
jl     1222 <main+0x112>
mov    -0x34(%rbp),%esi
mov    -0x28(%rbp),%edx
mov    -0x2c(%rbp),%ecx
lea    0xe6a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movslq -0x34(%rbp),%rax
mov    -0x20(%rbp,%rax,4),%ecx
mov    -0x34(%rbp),%eax
add    $0x1,%eax
cltq
mov    %ecx,-0x20(%rbp,%rax,4)
mov    -0x34(%rbp),%esi
add    $0x1,%esi
mov    -0x34(%rbp),%eax
add    $0x1,%eax
cltq
mov    -0x20(%rbp,%rax,4),%edx
mov    -0x34(%rbp),%ecx
movslq -0x34(%rbp),%rax
mov    -0x20(%rbp,%rax,4),%r8d
lea    0xe53(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x34(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    11b1 <main+0xa1>
mov    -0x24(%rbp),%ecx
movslq -0x28(%rbp),%rax
mov    %ecx,-0x20(%rbp,%rax,4)
lea    0xe53(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x30(%rbp)
mov    -0x30(%rbp),%eax
cmp    -0x2c(%rbp),%eax
jge    1275 <main+0x165>
mov    -0x30(%rbp),%esi
movslq -0x30(%rbp),%rax
mov    -0x20(%rbp,%rax,4),%edx
lea    0xe19(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x30(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30(%rbp)
jmp    1242 <main+0x132>
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
lea    0xf24(%rip),%rdi
call   1030 <puts@plt>
lea    0xf0a(%rip),%rbx
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x1,%edx
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    $0x1,%esi
mov    $0x3,%edx
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    $0x2,%esi
mov    $0x5,%edx
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    $0x3,%esi
mov    $0x7,%edx
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    $0x4,%esi
mov    $0x8,%edx
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe60(%rip),%r14
mov    %r14,%rdi
mov    $0x5,%esi
mov    $0x3,%edx
mov    $0x6,%ecx
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe69(%rip),%r15
mov    %r15,%rdi
mov    $0x6,%esi
mov    $0x5,%ecx
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r14,%rdi
mov    $0x4,%esi
mov    $0x3,%edx
mov    $0x6,%ecx
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r15,%rdi
mov    $0x5,%esi
mov    $0x8,%edx
mov    $0x4,%ecx
mov    $0x8,%r8d
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r14,%rdi
mov    $0x3,%esi
mov    $0x3,%edx
mov    $0x6,%ecx
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r15,%rdi
mov    $0x4,%esi
mov    $0x7,%edx
mov    $0x3,%ecx
mov    $0x7,%r8d
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe27(%rip),%rdi
call   1030 <puts@plt>
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x1,%edx
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    $0x1,%esi
mov    $0x3,%edx
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    $0x2,%esi
mov    $0x5,%edx
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    $0x3,%esi
mov    $0xa,%edx
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    $0x4,%esi
mov    $0x7,%edx
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    $0x5,%esi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
@.str.1 = [14 x i8] c"LA[%d] = %d \0A\00"
@.str.2 = [41 x i8] c"Value of j is %d , k is %d and n is %d \0A\00"
@.str.3 = [39 x i8] c"Value of LA[%d] = %d and LA[%d] = %d \0A\00"
@str = [34 x i8] c"The original array elements are :\00"
@str.5 = [37 x i8] c"The array elements after insertion :\00"
define i32 @main() {
%1 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @str, i64 0, i64 0))
%2 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i32 0, i32 1)
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i32 1, i32 3)
%4 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i32 2, i32 5)
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i32 3, i32 7)
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i32 4, i32 8)
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @.str.2, i64 0, i64 0), i32 5, i32 3, i32 6)
%8 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @.str.3, i64 0, i64 0), i32 6, i32 poison, i32 5, i32 poison)
%9 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @.str.2, i64 0, i64 0), i32 4, i32 3, i32 6)
%10 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @.str.3, i64 0, i64 0), i32 5, i32 8, i32 4, i32 8)
%11 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @.str.2, i64 0, i64 0), i32 3, i32 3, i32 6)
%12 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @.str.3, i64 0, i64 0), i32 4, i32 7, i32 3, i32 7)
%13 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @str.5, i64 0, i64 0))
%14 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i32 0, i32 1)
%15 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i32 1, i32 3)
%16 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i32 2, i32 5)
%17 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i32 3, i32 10)
%18 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i32 4, i32 7)
%19 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i32 5, i32 poison)
ret i32 0
}