#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 */
double sqrt(double);
void finalizeQual(double *qm, int total, int n) {
  int i;
  for (i = 0; i < n; i++) {
    qm[i] = sqrt(qm[i] / total);
  }
}


x86 assembly (clang, -O0):
<finalizeQual>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    116b <finalizeQual+0x5b>
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
cvtsi2sdl -0xc(%rbp),%xmm1
divsd  %xmm1,%xmm0
call   1030 <sqrt@plt>
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1129 <finalizeQual+0x19>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<finalizeQual>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
test   %edx,%edx
jle    11e6 <finalizeQual+0xd6>
mov    %rdi,%r14
cvtsi2sd %esi,%xmm1
mov    %edx,%r15d
cmp    $0x1,%edx
jne    115c <finalizeQual+0x4c>
xor    %ebx,%ebx
test   $0x1,%r15b
je     11e6 <finalizeQual+0xd6>
movsd  (%r14,%rbx,8),%xmm0
divsd  %xmm1,%xmm0
xorpd  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jb     11db <finalizeQual+0xcb>
sqrtsd %xmm0,%xmm0
jmp    11e0 <finalizeQual+0xd0>
mov    %r15d,%r12d
and    $0xfffffffe,%r12d
xor    %ebx,%ebx
xorpd  %xmm2,%xmm2
movsd  %xmm1,(%rsp)
jmp    118e <finalizeQual+0x7e>
call   1030 <sqrt@plt>
xorpd  %xmm2,%xmm2
movsd  (%rsp),%xmm1
movsd  %xmm0,0x8(%r14,%rbx,8)
add    $0x2,%rbx
cmp    %rbx,%r12
je     1131 <finalizeQual+0x21>
movsd  (%r14,%rbx,8),%xmm0
divsd  %xmm1,%xmm0
ucomisd %xmm2,%xmm0
jb     11b0 <finalizeQual+0xa0>
sqrtsd %xmm0,%xmm0
jmp    11be <finalizeQual+0xae>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
call   1030 <sqrt@plt>
xorpd  %xmm2,%xmm2
movsd  (%rsp),%xmm1
movsd  %xmm0,(%r14,%rbx,8)
movsd  0x8(%r14,%rbx,8),%xmm0
divsd  %xmm1,%xmm0
ucomisd %xmm2,%xmm0
jb     1170 <finalizeQual+0x60>
sqrtsd %xmm0,%xmm0
jmp    117e <finalizeQual+0x6e>
call   1030 <sqrt@plt>
movsd  %xmm0,(%r14,%rbx,8)
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @finalizeQual(double* %0, i32 %1, i32 %2) {
%4 = alloca double*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store double* %0, double** %4
store i32 %1, i32* %5
store i32 %2, i32* %6
store i32 0, i32* %7
br label %8
8: ; preds = %26, %3
%9 = load i32, i32* %7
%10 = load i32, i32* %6
%11 = icmp slt i32 %9, %10
br i1 %11, label %12, label %29
12: ; preds = %8
%13 = load double*, double** %4
%14 = load i32, i32* %7
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds double, double* %13, i64 %15
%17 = load double, double* %16
%18 = load i32, i32* %5
%19 = sitofp i32 %18 to double
%20 = fdiv double %17, %19
%21 = call double @sqrt(double %20)
%22 = load double*, double** %4
%23 = load i32, i32* %7
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds double, double* %22, i64 %24
store double %21, double* %25
br label %26
26: ; preds = %12
%27 = load i32, i32* %7
%28 = add nsw i32 %27, 1
store i32 %28, i32* %7
br label %8
29: ; preds = %8
ret void
}

LLVM IR (-O2):
define void @finalizeQual(double* nocapture %0, i32 %1, i32 %2) {
%4 = icmp sgt i32 %2, 0
br i1 %4, label %5, label %35
5: ; preds = %3
%6 = sitofp i32 %1 to double
%7 = zext i32 %2 to i64
%8 = and i64 %7, 1
%9 = icmp eq i32 %2, 1
br i1 %9, label %27, label %10
10: ; preds = %5
%11 = and i64 %7, 4294967294
br label %12
12: ; preds = %12, %10
%13 = phi i64 [ 0, %10 ], [ %24, %12 ]
%14 = phi i64 [ 0, %10 ], [ %25, %12 ]
%15 = getelementptr inbounds double, double* %0, i64 %13
%16 = load double, double* %15
%17 = fdiv double %16, %6
%18 = tail call double @sqrt(double %17)
store double %18, double* %15
%19 = or i64 %13, 1
%20 = getelementptr inbounds double, double* %0, i64 %19
%21 = load double, double* %20
%22 = fdiv double %21, %6
%23 = tail call double @sqrt(double %22)
store double %23, double* %20
%24 = add nuw nsw i64 %13, 2
%25 = add i64 %14, 2
%26 = icmp eq i64 %25, %11
br i1 %26, label %27, label %12
27: ; preds = %12, %5
%28 = phi i64 [ 0, %5 ], [ %24, %12 ]
%29 = icmp eq i64 %8, 0
br i1 %29, label %35, label %30
30: ; preds = %27
%31 = getelementptr inbounds double, double* %0, i64 %28
%32 = load double, double* %31
%33 = fdiv double %32, %6
%34 = tail call double @sqrt(double %33)
store double %34, double* %31
br label %35
35: ; preds = %30, %27, %3
ret void
}