#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);
int /*<<< orphan*/ scanf(char *, double *);
void fnReadArray(double A[], int n) {
  int i;
  printf("\nEnter %d elements into the array\n", n);
  for (i = 0; i < n; i++)
    scanf("%lf", &A[i]);
}


x86 assembly (clang, -O0):
<fnReadArray>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0xc(%rbp),%esi
lea    0xec7(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    117a <fnReadArray+0x5a>
mov    -0x8(%rbp),%rsi
movslq -0x10(%rbp),%rax
shl    $0x3,%rax
add    %rax,%rsi
lea    0xebc(%rip),%rdi
call   1040 <scanf@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1145 <fnReadArray+0x25>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fnReadArray>:
push   %rbp
push   %r14
push   %rbx
mov    %esi,%ebp
mov    %rdi,%rbx
lea    0xed0(%rip),%rdi
call   1030 <printf@plt>
test   %ebp,%ebp
jle    1165 <fnReadArray+0x45>
mov    %ebp,%ebp
lea    0xee1(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %r14,%rdi
mov    %rbx,%rsi
call   1040 <scanf@plt>
add    $0x8,%rbx
add    $0xffffffffffffffff,%rbp
jne    1150 <fnReadArray+0x30>
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [35 x i8] c"\0AEnter %d elements into the array\0A\00"
@.str.1 = [4 x i8] c"%lf\00"
define void @fnReadArray(double* %0, i32 %1) {
%3 = alloca double*
%4 = alloca i32
%5 = alloca i32
store double* %0, double** %3
store i32 %1, i32* %4
%6 = load i32, i32* %4
%7 = call i32 @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0), i32 %6)
store i32 0, i32* %5
br label %8
8: ; preds = %18, %2
%9 = load i32, i32* %5
%10 = load i32, i32* %4
%11 = icmp slt i32 %9, %10
br i1 %11, label %12, label %21
12: ; preds = %8
%13 = load double*, double** %3
%14 = load i32, i32* %5
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds double, double* %13, i64 %15
%17 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), double* %16)
br label %18
18: ; preds = %12
%19 = load i32, i32* %5
%20 = add nsw i32 %19, 1
store i32 %20, i32* %5
br label %8
21: ; preds = %8
ret void
}

LLVM IR (-O2):
@.str = [35 x i8] c"\0AEnter %d elements into the array\0A\00"
@.str.1 = [4 x i8] c"%lf\00"
define void @fnReadArray(double* %0, i32 %1) {
%3 = tail call i32 @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0), i32 %1)
%4 = icmp sgt i32 %1, 0
br i1 %4, label %5, label %13
5: ; preds = %2
%6 = zext i32 %1 to i64
br label %7
7: ; preds = %5, %7
%8 = phi i64 [ 0, %5 ], [ %11, %7 ]
%9 = getelementptr inbounds double, double* %0, i64 %8
%10 = tail call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), double* %9)
%11 = add nuw nsw i64 %8, 1
%12 = icmp eq i64 %11, %6
br i1 %12, label %13, label %7
13: ; preds = %7, %2
ret void
}