#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
scalar_t__ EOF;
int /*<<< orphan*/ fflush(int /*<<< orphan*/);
scalar_t__ fscanf(int /*<<< orphan*/ *, char *, double *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ stdout;
void readArray(FILE *fp, double x[], int n) {
  int i = 0;
  double temp;
  int m;
  m = 0;
  printf("Reading array....\n");
  while (fscanf(fp, "%lf\n", &temp) != EOF) {
    x[i] = temp;
    i++;
    if (((int)(100 * (i / (n + 0.)))) == m) {
      printf("\r\r\r\r%d%%", m);
      fflush(stdout);
      m++;
    }
  }
  printf("\r\r\r\rDone!\n");
}


x86 assembly (clang, -O0):
<readArray>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
movl   $0x0,-0x24(%rbp)
lea    0xeb0(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%rdi
lea    0xeb1(%rip),%rsi
lea    -0x20(%rbp),%rdx
call   1040 <fscanf@plt>
mov    0x2e6e(%rip),%rcx
cmp    (%rcx),%rax
je     11f9 <readArray+0xc9>
movsd  -0x20(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
cvtsi2sdl -0x18(%rbp),%xmm1
cvtsi2sdl -0x14(%rbp),%xmm0
xorps  %xmm2,%xmm2
addsd  %xmm2,%xmm0
divsd  %xmm0,%xmm1
movsd  0xe45(%rip),%xmm0
mulsd  %xmm1,%xmm0
cvttsd2si %xmm0,%eax
cmp    -0x24(%rbp),%eax
jne    11f4 <readArray+0xc4>
mov    -0x24(%rbp),%esi
lea    0xe4a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    0x2df4(%rip),%rax
mov    (%rax),%edi
call   1050 <fflush@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    115f <readArray+0x2f>
lea    0xe29(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<readArray>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %edx,%ebp
mov    %rsi,%r14
mov    %rdi,%rbx
lea    0xeb9(%rip),%rdi
call   1030 <puts@plt>
lea    0xe9f(%rip),%rsi
lea    0x8(%rsp),%rdx
mov    %rbx,%rdi
call   1050 <fscanf@plt>
mov    0x2e6b(%rip),%rcx
cmp    (%rcx),%rax
jne    119d <readArray+0x5d>
lea    0xe9f(%rip),%rdi
call   1030 <puts@plt>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
cvtsi2sd %ebp,%xmm0
movsd  %xmm0,0x10(%rsp)
lea    0xe5a(%rip),%r12
lea    0x8(%rsp),%r13
xor    %r15d,%r15d
xor    %ebp,%ebp
jmp    11de <readArray+0x9e>
nopw   0x0(%rax,%rax,1)
mov    %rbx,%rdi
mov    %r12,%rsi
mov    %r13,%rdx
call   1050 <fscanf@plt>
add    $0x1,%r15
mov    0x2e0f(%rip),%rcx
cmp    (%rcx),%rax
je     1182 <readArray+0x42>
movsd  0x8(%rsp),%xmm0
movsd  %xmm0,(%r14,%r15,8)
lea    0x1(%r15),%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
divsd  0x10(%rsp),%xmm0
mulsd  0xdfd(%rip),%xmm0
cvttsd2si %xmm0,%eax
cmp    %eax,%ebp
jne    11c0 <readArray+0x80>
lea    0xdfb(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x2db6(%rip),%rax
mov    (%rax),%edi
call   1060 <fflush@plt>
add    $0x1,%ebp
jmp    11c0 <readArray+0x80>

LLVM IR (-O0):
@.str = [19 x i8] c"Reading array....\0A\00"
@.str.1 = [5 x i8] c"%lf\0A\00"
@EOF = global i64 0
@.str.2 = [9 x i8] c"\0D\0D\0D\0D%d%%\00"
@stdout = global i32 0
@.str.3 = [11 x i8] c"\0D\0D\0D\0DDone!\0A\00"
define void @readArray(i32* %0, double* %1, i32 %2) {
%4 = alloca i32*
%5 = alloca double*
%6 = alloca i32
%7 = alloca i32
%8 = alloca double
%9 = alloca i32
store i32* %0, i32** %4
store double* %1, double** %5
store i32 %2, i32* %6
store i32 0, i32* %7
store i32 0, i32* %9
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
br label %11
11: ; preds = %41, %3
%12 = load i32*, i32** %4
%13 = call i64 @fscanf(i32* %12, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), double* %8)
%14 = load i64, i64* @EOF
%15 = icmp ne i64 %13, %14
br i1 %15, label %16, label %42
16: ; preds = %11
%17 = load double, double* %8
%18 = load double*, double** %5
%19 = load i32, i32* %7
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds double, double* %18, i64 %20
store double %17, double* %21
%22 = load i32, i32* %7
%23 = add nsw i32 %22, 1
store i32 %23, i32* %7
%24 = load i32, i32* %7
%25 = sitofp i32 %24 to double
%26 = load i32, i32* %6
%27 = sitofp i32 %26 to double
%28 = fadd double %27, 0.000000e+00
%29 = fdiv double %25, %28
%30 = fmul double 1.000000e+02, %29
%31 = fptosi double %30 to i32
%32 = load i32, i32* %9
%33 = icmp eq i32 %31, %32
br i1 %33, label %34, label %41
34: ; preds = %16
%35 = load i32, i32* %9
%36 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i32 %35)
%37 = load i32, i32* @stdout
%38 = call i32 @fflush(i32 %37)
%39 = load i32, i32* %9
%40 = add nsw i32 %39, 1
store i32 %40, i32* %9
br label %41
41: ; preds = %34, %16
br label %11
42: ; preds = %11
%43 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str.1 = [5 x i8] c"%lf\0A\00"
@EOF = global i64 0
@.str.2 = [9 x i8] c"\0D\0D\0D\0D%d%%\00"
@stdout = global i32 0
@str = [18 x i8] c"Reading array....\00"
@str.4 = [10 x i8] c"\0D\0D\0D\0DDone!\00"
define void @readArray(i32* nocapture %0, double* nocapture writeonly %1, i32 %2) {
%4 = alloca double
%5 = bitcast double* %4 to i8*
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @str, i64 0, i64 0))
%7 = call i64 @fscanf(i32* %0, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), double* %4)
%8 = load i64, i64* @EOF
%9 = icmp eq i64 %7, %8
br i1 %9, label %34, label %10
10: ; preds = %3
%11 = sitofp i32 %2 to double
br label %12
12: ; preds = %10, %29
%13 = phi i64 [ 0, %10 ], [ %17, %29 ]
%14 = phi i32 [ 0, %10 ], [ %30, %29 ]
%15 = load double, double* %4
%16 = getelementptr inbounds double, double* %1, i64 %13
store double %15, double* %16
%17 = add nuw i64 %13, 1
%18 = trunc i64 %17 to i32
%19 = sitofp i32 %18 to double
%20 = fdiv double %19, %11
%21 = fmul double %20, 1.000000e+02
%22 = fptosi double %21 to i32
%23 = icmp eq i32 %14, %22
br i1 %23, label %24, label %29
24: ; preds = %12
%25 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i32 %14)
%26 = load i32, i32* @stdout
%27 = call i32 @fflush(i32 %26)
%28 = add nsw i32 %14, 1
br label %29
29: ; preds = %24, %12
%30 = phi i32 [ %28, %24 ], [ %14, %12 ]
%31 = call i64 @fscanf(i32* %0, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), double* %4)
%32 = load i64, i64* @EOF
%33 = icmp eq i64 %31, %32
br i1 %33, label %34, label %12
34: ; preds = %29, %3
%35 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @str.4, i64 0, i64 0))
ret void
}