#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 */
scalar_t__ insArr(float *, float, int, int *);
int /*<<< orphan*/ printf(char *, ...);
char scanf(char *, ...);
int main(void) {
  int n, pos;
  float arr[100], in;
  printf("Enter number of elements: ");
  scanf("%d", &n);
  for (size_t i = 0; i < n; i++) {
    if (scanf("%f", &arr[i]) != '\0')
      ;
    else {
      printf("Scan failed\n");
      goto end;
    }
  }
  printf("Enter position to insert: ");
  scanf("%d", &pos);
  printf("Enter number to insert: ");
  scanf("%f", &in);
  if (insArr(arr, in, pos, &n)) {
    printf("The number is:\n");
    for (size_t i = 0; i < n; i++) {
      printf("%.2f\n", arr[i]);
    }
  } else
    printf("Insert failed");
end:
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1c0,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeb7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xec4(%rip),%rdi
lea    -0x8(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
movq   $0x0,-0x1b0(%rbp)
mov    -0x1b0(%rbp),%rax
movslq -0x8(%rbp),%rcx
cmp    %rcx,%rax
jae    11e4 <main+0xb4>
mov    -0x1b0(%rbp),%rax
lea    -0x1a0(%rbp),%rsi
shl    $0x2,%rax
add    %rax,%rsi
lea    0xe81(%rip),%rdi
mov    $0x0,%al
call   1040 <scanf@plt>
movsbl %al,%eax
cmp    $0x0,%eax
je     11b5 <main+0x85>
jmp    11c8 <main+0x98>
lea    0xe65(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    12ca <main+0x19a>
jmp    11cd <main+0x9d>
mov    -0x1b0(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x1b0(%rbp)
jmp    116d <main+0x3d>
lea    0xe43(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe22(%rip),%rdi
lea    -0xc(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
lea    0xe3e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe05(%rip),%rdi
lea    -0x1a4(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
lea    -0x1a0(%rbp),%rdi
movss  -0x1a4(%rbp),%xmm0
ff
mov    -0xc(%rbp),%esi
lea    -0x8(%rbp),%rdx
call   1050 <insArr@plt>
cmp    $0x0,%rax
je     12b7 <main+0x187>
lea    0xe0f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movq   $0x0,-0x1b8(%rbp)
mov    -0x1b8(%rbp),%rax
movslq -0x8(%rbp),%rcx
cmp    %rcx,%rax
jae    12b2 <main+0x182>
mov    -0x1b8(%rbp),%rax
movss  -0x1a0(%rbp,%rax,4),%xmm0
ff ff
cvtss2sd %xmm0,%xmm0
lea    0xdde(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
mov    -0x1b8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x1b8(%rbp)
jmp    1265 <main+0x135>
jmp    12c5 <main+0x195>
lea    0xdba(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    12ca <main+0x19a>
xor    %eax,%eax
add    $0x1c0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x1a0,%rsp
lea    0xead(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xeba(%rip),%rdi
lea    0x4(%rsp),%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
cmpl   $0x0,0x4(%rsp)
je     11b7 <main+0x77>
lea    0x10(%rsp),%r15
lea    0xe9e(%rip),%r14
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %r14,%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
test   %al,%al
je     1264 <main+0x124>
add    $0x1,%rbx
movslq 0x4(%rsp),%rax
add    $0x4,%r15
cmp    %rax,%rbx
jb     1190 <main+0x50>
lea    0xe63(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe4f(%rip),%rdi
lea    0xc(%rsp),%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
lea    0xe5d(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe31(%rip),%rdi
lea    0x8(%rsp),%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
movss  0x8(%rsp),%xmm0
mov    0xc(%rsp),%esi
lea    0x10(%rsp),%rdi
lea    0x4(%rsp),%rdx
call   1060 <insArr@plt>
test   %rax,%rax
je     1272 <main+0x132>
lea    0xe4b(%rip),%rdi
call   1030 <puts@plt>
cmpl   $0x0,0x4(%rsp)
je     1280 <main+0x140>
xor    %ebx,%ebx
lea    0xe22(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movss  0x10(%rsp,%rbx,4),%xmm0
cvtss2sd %xmm0,%xmm0
mov    %r14,%rdi
mov    $0x1,%al
call   1040 <printf@plt>
add    $0x1,%rbx
movslq 0x4(%rsp),%rax
cmp    %rax,%rbx
jb     1240 <main+0x100>
jmp    1280 <main+0x140>
lea    0xe0d(%rip),%rdi
call   1030 <puts@plt>
jmp    1280 <main+0x140>
lea    0xde2(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x1a0,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [27 x i8] c"Enter number of elements: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [3 x i8] c"%f\00"
@.str.3 = [13 x i8] c"Scan failed\0A\00"
@.str.4 = [27 x i8] c"Enter position to insert: \00"
@.str.5 = [25 x i8] c"Enter number to insert: \00"
@.str.6 = [16 x i8] c"The number is:\0A\00"
@.str.7 = [6 x i8] c"%.2f\0A\00"
@.str.8 = [14 x i8] c"Insert failed\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca [100 x float]
%5 = alloca float
%6 = alloca i64
%7 = alloca i64
store i32 0, i32* %1
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0))
%9 = call signext i8 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
store i64 0, i64* %6
br label %10
10: ; preds = %25, %0
%11 = load i64, i64* %6
%12 = load i32, i32* %2
%13 = sext i32 %12 to i64
%14 = icmp ult i64 %11, %13
br i1 %14, label %15, label %28
15: ; preds = %10
%16 = load i64, i64* %6
%17 = getelementptr inbounds [100 x float], [100 x float]* %4, i64 0, i64 %16
%18 = call signext i8 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), float* %17)
%19 = sext i8 %18 to i32
%20 = icmp ne i32 %19, 0
br i1 %20, label %21, label %22
21: ; preds = %15
br label %24
22: ; preds = %15
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0))
br label %58
24: ; preds = %21
br label %25
25: ; preds = %24
%26 = load i64, i64* %6
%27 = add i64 %26, 1
store i64 %27, i64* %6
br label %10
28: ; preds = %10
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.4, i64 0, i64 0))
%30 = call signext i8 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.5, i64 0, i64 0))
%32 = call signext i8 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), float* %5)
%33 = getelementptr inbounds [100 x float], [100 x float]* %4, i64 0, i64 0
%34 = load float, float* %5
%35 = load i32, i32* %3
%36 = call i64 @insArr(float* %33, float %34, i32 %35, i32* %2)
%37 = icmp ne i64 %36, 0
br i1 %37, label %38, label %55
38: ; preds = %28
%39 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.6, i64 0, i64 0))
store i64 0, i64* %7
br label %40
40: ; preds = %51, %38
%41 = load i64, i64* %7
%42 = load i32, i32* %2
%43 = sext i32 %42 to i64
%44 = icmp ult i64 %41, %43
br i1 %44, label %45, label %54
45: ; preds = %40
%46 = load i64, i64* %7
%47 = getelementptr inbounds [100 x float], [100 x float]* %4, i64 0, i64 %46
%48 = load float, float* %47
%49 = fpext float %48 to double
%50 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.7, i64 0, i64 0), double %49)
br label %51
51: ; preds = %45
%52 = load i64, i64* %7
%53 = add i64 %52, 1
store i64 %53, i64* %7
br label %40
54: ; preds = %40
br label %57
55: ; preds = %28
%56 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.8, i64 0, i64 0))
br label %57
57: ; preds = %55, %54
br label %58
58: ; preds = %57, %22
ret i32 0
}

LLVM IR (-O2):
@.str = [27 x i8] c"Enter number of elements: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [3 x i8] c"%f\00"
@.str.4 = [27 x i8] c"Enter position to insert: \00"
@.str.5 = [25 x i8] c"Enter number to insert: \00"
@.str.7 = [6 x i8] c"%.2f\0A\00"
@.str.8 = [14 x i8] c"Insert failed\00"
@str = [15 x i8] c"The number is:\00"
@str.9 = [12 x i8] c"Scan failed\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca [100 x float]
%4 = alloca float
%5 = bitcast i32* %1 to i8*
%6 = bitcast i32* %2 to i8*
%7 = bitcast [100 x float]* %3 to i8*
%8 = bitcast float* %4 to i8*
%9 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0))
%10 = call signext i8 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%11 = load i32, i32* %1
%12 = icmp eq i32 %11, 0
br i1 %12, label %25, label %17
13: ; preds = %17
%14 = load i32, i32* %1
%15 = sext i32 %14 to i64
%16 = icmp ult i64 %22, %15
br i1 %16, label %17, label %25
17: ; preds = %0, %13
%18 = phi i64 [ %22, %13 ], [ 0, %0 ]
%19 = getelementptr inbounds [100 x float], [100 x float]* %3, i64 0, i64 %18
%20 = call signext i8 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), float* %19)
%21 = icmp eq i8 %20, 0
%22 = add nuw i64 %18, 1
br i1 %21, label %23, label %13
23: ; preds = %17
%24 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @str.9, i64 0, i64 0))
br label %51
25: ; preds = %13, %0
%26 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.4, i64 0, i64 0))
%27 = call signext i8 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%28 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.5, i64 0, i64 0))
%29 = call signext i8 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), float* %4)
%30 = getelementptr inbounds [100 x float], [100 x float]* %3, i64 0, i64 0
%31 = load float, float* %4
%32 = load i32, i32* %2
%33 = call i64 @insArr(float* %30, float %31, i32 %32, i32* %1)
%34 = icmp eq i64 %33, 0
br i1 %34, label %49, label %35
35: ; preds = %25
%36 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @str, i64 0, i64 0))
%37 = load i32, i32* %1
%38 = icmp eq i32 %37, 0
br i1 %38, label %51, label %39
39: ; preds = %35, %39
%40 = phi i64 [ %45, %39 ], [ 0, %35 ]
%41 = getelementptr inbounds [100 x float], [100 x float]* %3, i64 0, i64 %40
%42 = load float, float* %41
%43 = fpext float %42 to double
%44 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.7, i64 0, i64 0), double %43)
%45 = add nuw i64 %40, 1
%46 = load i32, i32* %1
%47 = sext i32 %46 to i64
%48 = icmp ult i64 %45, %47
br i1 %48, label %39, label %51
49: ; preds = %25
%50 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.8, i64 0, i64 0))
br label %51
51: ; preds = %39, %35, %23, %49
ret i32 0
}