#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*/ insert_num_into_array(int *, int, int, int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *);
int main() {
  int array[5] = {};
  int i;
  int insert_pos, insert_number;
  printf("input array[5]:\n");
  for (i = 0; i < 5; i++)
    scanf("%d", &array[i]);
  printf("insert position:\n");
  scanf("%d", &insert_pos);
  printf("insert  number:\n");
  scanf("%d", &insert_number);
  insert_num_into_array(array, 5, insert_pos, insert_number);
  for (i = 0; i < 5; i++)
    printf("%3d", array[i]);
  printf("\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x20(%rbp),%rdi
xor    %esi,%esi
mov    $0x14,%edx
call   1040 <memset@plt>
lea    0xe9a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x24(%rbp)
cmpl   $0x5,-0x24(%rbp)
jge    11a7 <main+0x67>
movslq -0x24(%rbp),%rax
lea    -0x20(%rbp),%rsi
shl    $0x2,%rax
add    %rax,%rsi
lea    0xe7d(%rip),%rdi
call   1060 <scanf@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1174 <main+0x34>
lea    0xe66(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe55(%rip),%rdi
lea    -0x28(%rbp),%rsi
call   1060 <scanf@plt>
lea    0xe5a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe37(%rip),%rdi
lea    -0x2c(%rbp),%rsi
call   1060 <scanf@plt>
lea    -0x20(%rbp),%rdi
mov    -0x28(%rbp),%edx
mov    -0x2c(%rbp),%ecx
mov    $0x5,%esi
call   1050 <insert_num_into_array@plt>
movl   $0x0,-0x24(%rbp)
cmpl   $0x5,-0x24(%rbp)
jge    122c <main+0xec>
movslq -0x24(%rbp),%rax
mov    -0x20(%rbp,%rax,4),%esi
lea    0xe20(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    11fe <main+0xbe>
lea    0xddc(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x20,%rsp
xorps  %xmm0,%xmm0
movaps %xmm0,(%rsp)
movl   $0x0,0x10(%rsp)
lea    0x10(%rsp),%r15
lea    0xe93(%rip),%rdi
call   1040 <puts@plt>
lea    0xe80(%rip),%rbx
mov    %rsp,%r14
mov    %rbx,%rdi
mov    %r14,%rsi
call   1070 <scanf@plt>
lea    0x4(%rsp),%rsi
mov    %rbx,%rdi
call   1070 <scanf@plt>
lea    0x8(%rsp),%rsi
mov    %rbx,%rdi
call   1070 <scanf@plt>
lea    0xc(%rsp),%rsi
mov    %rbx,%rdi
call   1070 <scanf@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
call   1070 <scanf@plt>
lea    0xe50(%rip),%rdi
call   1040 <puts@plt>
lea    0x1c(%rsp),%rsi
mov    %rbx,%rdi
call   1070 <scanf@plt>
lea    0xe48(%rip),%rdi
call   1040 <puts@plt>
lea    0x18(%rsp),%rsi
mov    %rbx,%rdi
call   1070 <scanf@plt>
mov    0x1c(%rsp),%edx
mov    0x18(%rsp),%ecx
mov    %r14,%rdi
mov    $0x5,%esi
call   1060 <insert_num_into_array@plt>
mov    (%rsp),%esi
lea    0xdf2(%rip),%rbx
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x4(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x8(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0xc(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x10(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [17 x i8] c"input array[5]:\0A\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [18 x i8] c"insert position:\0A\00"
@.str.3 = [17 x i8] c"insert number:\0A\00"
@.str.4 = [4 x i8] c"%3d\00"
@.str.5 = [2 x i8] c"\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [5 x i32]
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 0, i32* %1
%6 = bitcast [5 x i32]* %2 to i8*
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %3
br label %8
8: ; preds = %16, %0
%9 = load i32, i32* %3
%10 = icmp slt i32 %9, 5
br i1 %10, label %11, label %19
11: ; preds = %8
%12 = load i32, i32* %3
%13 = sext i32 %12 to i64
%14 = getelementptr inbounds [5 x i32], [5 x i32]* %2, i64 0, i64 %13
%15 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %14)
br label %16
16: ; preds = %11
%17 = load i32, i32* %3
%18 = add nsw i32 %17, 1
store i32 %18, i32* %3
br label %8
19: ; preds = %8
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0))
%21 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %4)
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0))
%23 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %5)
%24 = getelementptr inbounds [5 x i32], [5 x i32]* %2, i64 0, i64 0
%25 = load i32, i32* %4
%26 = load i32, i32* %5
%27 = call i32 @insert_num_into_array(i32* %24, i32 5, i32 %25, i32 %26)
store i32 0, i32* %3
br label %28
28: ; preds = %37, %19
%29 = load i32, i32* %3
%30 = icmp slt i32 %29, 5
br i1 %30, label %31, label %40
31: ; preds = %28
%32 = load i32, i32* %3
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds [5 x i32], [5 x i32]* %2, i64 0, i64 %33
%35 = load i32, i32* %34
%36 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32 %35)
br label %37
37: ; preds = %31
%38 = load i32, i32* %3
%39 = add nsw i32 %38, 1
store i32 %39, i32* %3
br label %28
40: ; preds = %28
%41 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [3 x i8] c"%d\00"
@.str.4 = [4 x i8] c"%3d\00"
@str = [16 x i8] c"input array[5]:\00"
@str.6 = [17 x i8] c"insert position:\00"
@str.7 = [16 x i8] c"insert number:\00"
define i32 @main() {
%1 = alloca [5 x i32]
%2 = alloca i32
%3 = alloca i32
%4 = bitcast [5 x i32]* %1 to i8*
%5 = bitcast i32* %2 to i8*
%6 = bitcast i32* %3 to i8*
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @str, i64 0, i64 0))
%8 = getelementptr inbounds [5 x i32], [5 x i32]* %1, i64 0, i64 0
%9 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %8)
%10 = getelementptr inbounds [5 x i32], [5 x i32]* %1, i64 0, i64 1
%11 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %10)
%12 = getelementptr inbounds [5 x i32], [5 x i32]* %1, i64 0, i64 2
%13 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %12)
%14 = getelementptr inbounds [5 x i32], [5 x i32]* %1, i64 0, i64 3
%15 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %14)
%16 = getelementptr inbounds [5 x i32], [5 x i32]* %1, i64 0, i64 4
%17 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %16)
%18 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @str.6, 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 ([16 x i8], [16 x i8]* @str.7, i64 0, i64 0))
%21 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%22 = load i32, i32* %2
%23 = load i32, i32* %3
%24 = call i32 @insert_num_into_array(i32* %8, i32 5, i32 %22, i32 %23)
%25 = load i32, i32* %8
%26 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32 %25)
%27 = load i32, i32* %10
%28 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32 %27)
%29 = load i32, i32* %12
%30 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32 %29)
%31 = load i32, i32* %14
%32 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32 %31)
%33 = load i32, i32* %16
%34 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32 %33)
%35 = call i32 @putchar(i32 10)
ret i32 0
}