#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 *, ...);
void main() {
  int array[5] = {2, 3, 4, 5};
  int N = 4;
  int i = 0;
  int value = 1;
  printf("Printing array before insertion −\n");
  for (i = 0; i < N; i++) {
    printf("array[%d] = %d \n", i, array[i]);
  }
  for (i = N; i >= 0; i--) {
    array[i + 1] = array[i];
  }
  array[0] = value;
  N++;
  printf("Printing array after insertion −\n");
  for (i = 0; i < N; i++) {
    printf("array[%d] = %d\n", i, array[i]);
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    0xee1(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0xede(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    0xedc(%rip),%eax
mov    %eax,-0x10(%rbp)
movl   $0x4,-0x24(%rbp)
movl   $0x0,-0x28(%rbp)
movl   $0x1,-0x2c(%rbp)
lea    0xec1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%eax
cmp    -0x24(%rbp),%eax
jge    1194 <main+0x84>
mov    -0x28(%rbp),%esi
movslq -0x28(%rbp),%rax
mov    -0x20(%rbp,%rax,4),%edx
lea    0xeba(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    1161 <main+0x51>
mov    -0x24(%rbp),%eax
mov    %eax,-0x28(%rbp)
cmpl   $0x0,-0x28(%rbp)
jl     11c6 <main+0xb6>
movslq -0x28(%rbp),%rax
mov    -0x20(%rbp,%rax,4),%ecx
mov    -0x28(%rbp),%eax
add    $0x1,%eax
cltq
mov    %ecx,-0x20(%rbp,%rax,4)
mov    -0x28(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x28(%rbp)
jmp    119a <main+0x8a>
mov    -0x2c(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
lea    0xe6e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%eax
cmp    -0x24(%rbp),%eax
jge    121d <main+0x10d>
mov    -0x28(%rbp),%esi
movslq -0x28(%rbp),%rax
mov    -0x20(%rbp,%rax,4),%edx
lea    0xe66(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    11ea <main+0xda>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x20,%rsp
mov    0xee5(%rip),%eax
mov    %eax,0x10(%rsp)
movaps 0xeca(%rip),%xmm0
movaps %xmm0,(%rsp)
lea    0xef4(%rip),%rdi
call   1030 <puts@plt>
lea    0xec7(%rip),%rbx
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x2,%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    $0x4,%edx
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    $0x3,%esi
mov    $0x5,%edx
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x10(%rsp),%eax
movaps (%rsp),%xmm0
movups %xmm0,0x4(%rsp)
mov    %eax,0x14(%rsp)
lea    0xea7(%rip),%rdi
call   1030 <puts@plt>
lea    0xe67(%rip),%rbx
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x1,%edx
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x4(%rsp),%edx
mov    %rbx,%rdi
mov    $0x1,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x8(%rsp),%edx
mov    %rbx,%rdi
mov    $0x2,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0xc(%rsp),%edx
mov    %rbx,%rdi
mov    $0x3,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x10(%rsp),%edx
mov    %rbx,%rdi
mov    $0x4,%esi
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbx
jmp    1040 <printf@plt>

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

LLVM IR (-O2):
@__const.main.array = [5 x i32] [i32 2, i32 3, i32 4, i32 5, i32 0]
@.str.1 = [17 x i8] c"array[%d] = %d \0A\00"
@.str.3 = [16 x i8] c"array[%d] = %d\0A\00"
@str = [36 x i8] c"Printing array before insertion \E2\88\92\00"
@str.4 = [35 x i8] c"Printing array after insertion \E2\88\92\00"
define void @main() {
%1 = alloca [5 x i32]
%2 = bitcast [5 x i32]* %1 to i8*
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @str, i64 0, i64 0))
%4 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0), i32 0, i32 2)
%5 = getelementptr inbounds [5 x i32], [5 x i32]* %1, i64 0, i64 1
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0), i32 1, i32 3)
%7 = getelementptr inbounds [5 x i32], [5 x i32]* %1, i64 0, i64 2
%8 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0), i32 2, i32 4)
%9 = getelementptr inbounds [5 x i32], [5 x i32]* %1, i64 0, i64 3
%10 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0), i32 3, i32 5)
%11 = bitcast i32* %5 to i8*
%12 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @str.4, i64 0, i64 0))
%13 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0), i32 0, i32 1)
%14 = load i32, i32* %5
%15 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0), i32 1, i32 %14)
%16 = load i32, i32* %7
%17 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0), i32 2, i32 %16)
%18 = load i32, i32* %9
%19 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0), i32 3, i32 %18)
%20 = getelementptr inbounds [5 x i32], [5 x i32]* %1, i64 0, i64 4
%21 = load i32, i32* %20
%22 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0), i32 4, i32 %21)
ret void
}