#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*/ chis_rndc(int, double, double *);
double *dvector(int /*<<< orphan*/, int);
int /*<<< orphan*/ free_dvector(double *, int /*<<< orphan*/);
int /*<<< orphan*/ snormal_rndc(int, double *);
double sqrt(double);
void tdis_rndc(int n, double dof, double *array) {
  int i;
  double *ndis, *cdis;
  ndis = dvector(0, n - 1);
  cdis = dvector(0, n - 1);
  snormal_rndc(n, ndis);
  chis_rndc(n, dof, cdis);
  for (i = 0; i < n; i++)
    *(array + i) = ndis[i] * sqrt(dof) / sqrt(cdis[i]);
  free_dvector(ndis, 0);
  free_dvector(cdis, 0);
}


x86 assembly (clang, -O0):
<tdis_rndc>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0x4(%rbp)
movsd  %xmm0,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x4(%rbp),%esi
sub    $0x1,%esi
xor    %edi,%edi
call   1040 <dvector@plt>
mov    %rax,-0x28(%rbp)
mov    -0x4(%rbp),%esi
sub    $0x1,%esi
xor    %edi,%edi
call   1040 <dvector@plt>
mov    %rax,-0x30(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x28(%rbp),%rsi
call   1070 <snormal_rndc@plt>
mov    -0x4(%rbp),%edi
movsd  -0x10(%rbp),%xmm0
mov    -0x30(%rbp),%rsi
call   1030 <chis_rndc@plt>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    121c <tdis_rndc+0xcc>
mov    -0x28(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x10(%rbp),%xmm0
call   1060 <sqrt@plt>
movaps %xmm0,%xmm1
movsd  -0x40(%rbp),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
mov    -0x30(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
call   1060 <sqrt@plt>
movaps %xmm0,%xmm1
movsd  -0x38(%rbp),%xmm0
divsd  %xmm1,%xmm0
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    11aa <tdis_rndc+0x5a>
mov    -0x28(%rbp),%rdi
xor    %esi,%esi
call   1050 <free_dvector@plt>
mov    -0x30(%rbp),%rdi
xor    %esi,%esi
call   1050 <free_dvector@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<tdis_rndc>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %rsi,%r14
movsd  %xmm0,0x8(%rsp)
mov    %edi,%r12d
lea    -0x1(%r12),%ebx
xor    %edi,%edi
mov    %ebx,%esi
call   1040 <dvector@plt>
mov    %rax,%r15
xor    %edi,%edi
mov    %ebx,%esi
call   1040 <dvector@plt>
mov    %rax,%r13
mov    %r12d,%edi
mov    %r15,%rsi
call   1070 <snormal_rndc@plt>
mov    %r12d,%edi
movsd  0x8(%rsp),%xmm0
mov    %r13,%rsi
call   1030 <chis_rndc@plt>
test   %r12d,%r12d
jle    1366 <tdis_rndc+0x216>
mov    %r12d,%ebp
cmp    $0x1,%r12d
jne    11e7 <tdis_rndc+0x97>
mov    %rbp,%r12
xor    %ebx,%ebx
test   $0x1,%r12b
je     1366 <tdis_rndc+0x216>
movsd  (%r15,%rbx,8),%xmm1
xorpd  %xmm2,%xmm2
movsd  0x8(%rsp),%xmm0
ucomisd %xmm2,%xmm0
jb     131f <tdis_rndc+0x1cf>
sqrtsd %xmm0,%xmm0
jmp    1334 <tdis_rndc+0x1e4>
mov    %rbp,%r12
and    $0xfffffffe,%ebp
xor    %ebx,%ebx
movsd  0x8(%rsp),%xmm1
xorps  %xmm0,%xmm0
sqrtsd %xmm1,%xmm0
movsd  %xmm0,0x20(%rsp)
xorpd  %xmm2,%xmm2
jmp    124d <tdis_rndc+0xfd>
nopl   0x0(%rax,%rax,1)
movsd  %xmm4,0x18(%rsp)
call   1060 <sqrt@plt>
movsd  0x18(%rsp),%xmm4
movsd  0x10(%rsp),%xmm3
xorpd  %xmm2,%xmm2
movsd  0x8(%rsp),%xmm1
mulsd  %xmm4,%xmm3
divsd  %xmm0,%xmm3
movsd  %xmm3,0x8(%r14,%rbx,8)
add    $0x2,%rbx
cmp    %rbx,%rbp
je     11ba <tdis_rndc+0x6a>
movsd  (%r15,%rbx,8),%xmm3
ucomisd %xmm2,%xmm1
movsd  0x20(%rsp),%xmm4
movsd  %xmm3,0x10(%rsp)
jae    1282 <tdis_rndc+0x132>
movapd %xmm1,%xmm0
call   1060 <sqrt@plt>
movsd  0x10(%rsp),%xmm3
xorpd  %xmm2,%xmm2
movsd  0x8(%rsp),%xmm1
movapd %xmm0,%xmm4
movsd  0x0(%r13,%rbx,8),%xmm0
ucomisd %xmm2,%xmm0
jb     12a0 <tdis_rndc+0x150>
sqrtsd %xmm0,%xmm0
jmp    12c1 <tdis_rndc+0x171>
cs nopw 0x0(%rax,%rax,1)
nop
movsd  %xmm4,0x18(%rsp)
call   1060 <sqrt@plt>
movsd  0x18(%rsp),%xmm4
movsd  0x10(%rsp),%xmm3
xorpd  %xmm2,%xmm2
movsd  0x8(%rsp),%xmm1
mulsd  %xmm4,%xmm3
divsd  %xmm0,%xmm3
movsd  %xmm3,(%r14,%rbx,8)
movsd  0x8(%r15,%rbx,8),%xmm3
ucomisd %xmm2,%xmm1
movsd  0x20(%rsp),%xmm4
movsd  %xmm3,0x10(%rsp)
jae    1305 <tdis_rndc+0x1b5>
movapd %xmm1,%xmm0
call   1060 <sqrt@plt>
movsd  0x10(%rsp),%xmm3
xorpd  %xmm2,%xmm2
movsd  0x8(%rsp),%xmm1
movapd %xmm0,%xmm4
movsd  0x8(%r13,%rbx,8),%xmm0
ucomisd %xmm2,%xmm0
jb     1210 <tdis_rndc+0xc0>
sqrtsd %xmm0,%xmm0
jmp    1231 <tdis_rndc+0xe1>
movsd  %xmm1,0x8(%rsp)
call   1060 <sqrt@plt>
xorpd  %xmm2,%xmm2
movsd  0x8(%rsp),%xmm1
mulsd  %xmm0,%xmm1
movsd  0x0(%r13,%rbx,8),%xmm0
ucomisd %xmm2,%xmm0
jb     134b <tdis_rndc+0x1fb>
sqrtsd %xmm0,%xmm0
jmp    135c <tdis_rndc+0x20c>
movsd  %xmm1,0x8(%rsp)
call   1060 <sqrt@plt>
movsd  0x8(%rsp),%xmm1
divsd  %xmm0,%xmm1
movsd  %xmm1,(%r14,%rbx,8)
mov    %r15,%rdi
xor    %esi,%esi
call   1050 <free_dvector@plt>
mov    %r13,%rdi
xor    %esi,%esi
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1050 <free_dvector@plt>

LLVM IR (-O0):
define void @tdis_rndc(i32 %0, double %1, double* %2) {
%4 = alloca i32
%5 = alloca double
%6 = alloca double*
%7 = alloca i32
%8 = alloca double*
%9 = alloca double*
store i32 %0, i32* %4
store double %1, double* %5
store double* %2, double** %6
%10 = load i32, i32* %4
%11 = sub nsw i32 %10, 1
%12 = call double* @dvector(i32 0, i32 %11)
store double* %12, double** %8
%13 = load i32, i32* %4
%14 = sub nsw i32 %13, 1
%15 = call double* @dvector(i32 0, i32 %14)
store double* %15, double** %9
%16 = load i32, i32* %4
%17 = load double*, double** %8
%18 = call i32 @snormal_rndc(i32 %16, double* %17)
%19 = load i32, i32* %4
%20 = load double, double* %5
%21 = load double*, double** %9
%22 = call i32 @chis_rndc(i32 %19, double %20, double* %21)
store i32 0, i32* %7
br label %23
23: ; preds = %47, %3
%24 = load i32, i32* %7
%25 = load i32, i32* %4
%26 = icmp slt i32 %24, %25
br i1 %26, label %27, label %50
27: ; preds = %23
%28 = load double*, double** %8
%29 = load i32, i32* %7
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds double, double* %28, i64 %30
%32 = load double, double* %31
%33 = load double, double* %5
%34 = call double @sqrt(double %33)
%35 = fmul double %32, %34
%36 = load double*, double** %9
%37 = load i32, i32* %7
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds double, double* %36, i64 %38
%40 = load double, double* %39
%41 = call double @sqrt(double %40)
%42 = fdiv double %35, %41
%43 = load double*, double** %6
%44 = load i32, i32* %7
%45 = sext i32 %44 to i64
%46 = getelementptr inbounds double, double* %43, i64 %45
store double %42, double* %46
br label %47
47: ; preds = %27
%48 = load i32, i32* %7
%49 = add nsw i32 %48, 1
store i32 %49, i32* %7
br label %23
50: ; preds = %23
%51 = load double*, double** %8
%52 = call i32 @free_dvector(double* %51, i32 0)
%53 = load double*, double** %9
%54 = call i32 @free_dvector(double* %53, i32 0)
ret void
}

LLVM IR (-O2):
define void @tdis_rndc(i32 %0, double %1, double* nocapture writeonly %2) {
%4 = add nsw i32 %0, -1
%5 = tail call double* @dvector(i32 0, i32 %4)
%6 = tail call double* @dvector(i32 0, i32 %4)
%7 = tail call i32 @snormal_rndc(i32 %0, double* %5)
%8 = tail call i32 @chis_rndc(i32 %0, double %1, double* %6)
%9 = icmp sgt i32 %0, 0
br i1 %9, label %10, label %54
10: ; preds = %3
%11 = zext i32 %0 to i64
%12 = and i64 %11, 1
%13 = icmp eq i32 %0, 1
br i1 %13, label %41, label %14
14: ; preds = %10
%15 = and i64 %11, 4294967294
br label %16
16: ; preds = %16, %14
%17 = phi i64 [ 0, %14 ], [ %38, %16 ]
%18 = phi i64 [ 0, %14 ], [ %39, %16 ]
%19 = getelementptr inbounds double, double* %5, i64 %17
%20 = load double, double* %19
%21 = tail call double @sqrt(double %1)
%22 = fmul double %20, %21
%23 = getelementptr inbounds double, double* %6, i64 %17
%24 = load double, double* %23
%25 = tail call double @sqrt(double %24)
%26 = fdiv double %22, %25
%27 = getelementptr inbounds double, double* %2, i64 %17
store double %26, double* %27
%28 = or i64 %17, 1
%29 = getelementptr inbounds double, double* %5, i64 %28
%30 = load double, double* %29
%31 = tail call double @sqrt(double %1)
%32 = fmul double %30, %31
%33 = getelementptr inbounds double, double* %6, i64 %28
%34 = load double, double* %33
%35 = tail call double @sqrt(double %34)
%36 = fdiv double %32, %35
%37 = getelementptr inbounds double, double* %2, i64 %28
store double %36, double* %37
%38 = add nuw nsw i64 %17, 2
%39 = add i64 %18, 2
%40 = icmp eq i64 %39, %15
br i1 %40, label %41, label %16
41: ; preds = %16, %10
%42 = phi i64 [ 0, %10 ], [ %38, %16 ]
%43 = icmp eq i64 %12, 0
br i1 %43, label %54, label %44
44: ; preds = %41
%45 = getelementptr inbounds double, double* %5, i64 %42
%46 = load double, double* %45
%47 = tail call double @sqrt(double %1)
%48 = fmul double %46, %47
%49 = getelementptr inbounds double, double* %6, i64 %42
%50 = load double, double* %49
%51 = tail call double @sqrt(double %50)
%52 = fdiv double %48, %51
%53 = getelementptr inbounds double, double* %2, i64 %42
store double %52, double* %53
br label %54
54: ; preds = %44, %41, %3
%55 = tail call i32 @free_dvector(double* %5, i32 0)
%56 = tail call i32 @free_dvector(double* %6, i32 0)
ret void
}