#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*/ free(double *);
int /*<<< orphan*/ hermite_weight(long, double *, double *);
scalar_t__ mymalloc(long);
int /*<<< orphan*/ root_hermite(long, double *);
double sqrt(double);
void inithermitcat(long categs, double alpha, double *rate, double *probcat) {
  long i;
  double *hroot;
  double std;
  std = 1.4142135623730950488 / sqrt(alpha);
  hroot = (double *)mymalloc((long)(categs + 1) * sizeof(double));
  root_hermite(categs, hroot);
  hermite_weight(categs, hroot, probcat);
  for (i = 0; i < categs; i++) {
    rate[i] = 1.0 + std * hroot[i];
    probcat[i] = probcat[i];
  }
  free(hroot);
}


x86 assembly (clang, -O0):
<inithermitcat>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
movsd  %xmm0,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
movsd  -0x10(%rbp),%xmm0
call   1070 <sqrt@plt>
movaps %xmm0,%xmm1
movsd  0xe82(%rip),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
mov    -0x8(%rbp),%rdi
add    $0x1,%rdi
shl    $0x3,%rdi
call   1050 <mymalloc@plt>
mov    %rax,-0x30(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x30(%rbp),%rsi
call   1040 <root_hermite@plt>
mov    -0x8(%rbp),%rdi
mov    -0x30(%rbp),%rsi
mov    -0x20(%rbp),%rdx
call   1060 <hermite_weight@plt>
movq   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%rax
cmp    -0x8(%rbp),%rax
jge    122a <inithermitcat+0xda>
movsd  -0x38(%rbp),%xmm0
mov    -0x30(%rbp),%rax
mov    -0x28(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xe1a(%rip),%xmm1
addsd  %xmm1,%xmm0
mov    -0x18(%rbp),%rax
mov    -0x28(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x20(%rbp),%rax
mov    -0x28(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x20(%rbp),%rax
mov    -0x28(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x28(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
jmp    11c2 <inithermitcat+0x72>
mov    -0x30(%rbp),%rdi
call   1030 <free@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<inithermitcat>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rdx,%r12
mov    %rsi,%r15
mov    %rdi,%r14
xorpd  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jb     1171 <inithermitcat+0x21>
sqrtsd %xmm0,%xmm0
jmp    1176 <inithermitcat+0x26>
call   1070 <sqrt@plt>
movsd  %xmm0,(%rsp)
lea    0x8(,%r14,8),%rdi
call   1050 <mymalloc@plt>
mov    %rax,%rbx
mov    %r14,%rdi
mov    %rax,%rsi
call   1040 <root_hermite@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
mov    %r12,%rdx
call   1060 <hermite_weight@plt>
test   %r14,%r14
jle    136a <inithermitcat+0x21a>
movsd  0xe4b(%rip),%xmm0
divsd  (%rsp),%xmm0
cmp    $0x4,%r14
jb     11da <inithermitcat+0x8a>
lea    (%rbx,%r14,8),%rax
cmp    %r15,%rax
jbe    1290 <inithermitcat+0x140>
lea    (%r15,%r14,8),%rax
cmp    %rax,%rbx
jae    1290 <inithermitcat+0x140>
xor    %eax,%eax
mov    %rax,%rcx
not    %rcx
add    %r14,%rcx
mov    %r14,%rdx
and    $0x3,%rdx
je     121d <inithermitcat+0xcd>
movsd  0xe12(%rip),%xmm1
cs nopw 0x0(%rax,%rax,1)
movsd  (%rbx,%rax,8),%xmm2
mulsd  %xmm0,%xmm2
addsd  %xmm1,%xmm2
movsd  %xmm2,(%r15,%rax,8)
add    $0x1,%rax
add    $0xffffffffffffffff,%rdx
jne    1200 <inithermitcat+0xb0>
cmp    $0x3,%rcx
jb     136a <inithermitcat+0x21a>
movsd  0xdd9(%rip),%xmm1
nop
movsd  (%rbx,%rax,8),%xmm2
mulsd  %xmm0,%xmm2
addsd  %xmm1,%xmm2
movsd  %xmm2,(%r15,%rax,8)
movsd  0x8(%rbx,%rax,8),%xmm2
mulsd  %xmm0,%xmm2
addsd  %xmm1,%xmm2
movsd  %xmm2,0x8(%r15,%rax,8)
movsd  0x10(%rbx,%rax,8),%xmm2
mulsd  %xmm0,%xmm2
addsd  %xmm1,%xmm2
movsd  %xmm2,0x10(%r15,%rax,8)
movsd  0x18(%rbx,%rax,8),%xmm2
mulsd  %xmm0,%xmm2
addsd  %xmm1,%xmm2
movsd  %xmm2,0x18(%r15,%rax,8)
add    $0x4,%rax
cmp    %rax,%r14
jne    1230 <inithermitcat+0xe0>
jmp    136a <inithermitcat+0x21a>
mov    %r14,%rax
and    $0xfffffffffffffffc,%rax
movapd %xmm0,%xmm1
unpcklpd %xmm0,%xmm1
lea    -0x4(%rax),%rcx
mov    %rcx,%rdx
shr    $0x2,%rdx
add    $0x1,%rdx
test   %rcx,%rcx
je     137d <inithermitcat+0x22d>
mov    %rdx,%rsi
and    $0xfffffffffffffffe,%rsi
xor    %ecx,%ecx
movapd 0xd48(%rip),%xmm2
nopl   0x0(%rax,%rax,1)
movupd (%rbx,%rcx,8),%xmm3
movupd 0x10(%rbx,%rcx,8),%xmm4
mulpd  %xmm1,%xmm3
addpd  %xmm2,%xmm3
mulpd  %xmm1,%xmm4
addpd  %xmm2,%xmm4
movupd %xmm3,(%r15,%rcx,8)
movupd %xmm4,0x10(%r15,%rcx,8)
movupd 0x20(%rbx,%rcx,8),%xmm3
movupd 0x30(%rbx,%rcx,8),%xmm4
mulpd  %xmm1,%xmm3
addpd  %xmm2,%xmm3
mulpd  %xmm1,%xmm4
addpd  %xmm2,%xmm4
movupd %xmm3,0x20(%r15,%rcx,8)
movupd %xmm4,0x30(%r15,%rcx,8)
add    $0x8,%rcx
add    $0xfffffffffffffffe,%rsi
jne    12d0 <inithermitcat+0x180>
test   $0x1,%dl
je     1361 <inithermitcat+0x211>
movupd (%rbx,%rcx,8),%xmm2
movupd 0x10(%rbx,%rcx,8),%xmm3
mulpd  %xmm1,%xmm2
movapd 0xcc8(%rip),%xmm4
addpd  %xmm4,%xmm2
mulpd  %xmm1,%xmm3
addpd  %xmm4,%xmm3
movupd %xmm2,(%r15,%rcx,8)
movupd %xmm3,0x10(%r15,%rcx,8)
cmp    %r14,%rax
jne    11dc <inithermitcat+0x8c>
mov    %rbx,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
jmp    1030 <free@plt>
xor    %ecx,%ecx
test   $0x1,%dl
jne    1331 <inithermitcat+0x1e1>
jmp    1361 <inithermitcat+0x211>

LLVM IR (-O0):
define void @inithermitcat(i64 %0, double %1, double* %2, double* %3) {
%5 = alloca i64
%6 = alloca double
%7 = alloca double*
%8 = alloca double*
%9 = alloca i64
%10 = alloca double*
%11 = alloca double
store i64 %0, i64* %5
store double %1, double* %6
store double* %2, double** %7
store double* %3, double** %8
%12 = load double, double* %6
%13 = call double @sqrt(double %12)
%14 = fdiv double 0x3FF6A09E667F3BCD, %13
store double %14, double* %11
%15 = load i64, i64* %5
%16 = add nsw i64 %15, 1
%17 = mul i64 %16, 8
%18 = call i64 @mymalloc(i64 %17)
%19 = inttoptr i64 %18 to double*
store double* %19, double** %10
%20 = load i64, i64* %5
%21 = load double*, double** %10
%22 = call i32 @root_hermite(i64 %20, double* %21)
%23 = load i64, i64* %5
%24 = load double*, double** %10
%25 = load double*, double** %8
%26 = call i32 @hermite_weight(i64 %23, double* %24, double* %25)
store i64 0, i64* %9
br label %27
27: ; preds = %48, %4
%28 = load i64, i64* %9
%29 = load i64, i64* %5
%30 = icmp slt i64 %28, %29
br i1 %30, label %31, label %51
31: ; preds = %27
%32 = load double, double* %11
%33 = load double*, double** %10
%34 = load i64, i64* %9
%35 = getelementptr inbounds double, double* %33, i64 %34
%36 = load double, double* %35
%37 = call double @llvm.fmuladd.f64(double %32, double %36, double 1.000000e+00)
%38 = load double*, double** %7
%39 = load i64, i64* %9
%40 = getelementptr inbounds double, double* %38, i64 %39
store double %37, double* %40
%41 = load double*, double** %8
%42 = load i64, i64* %9
%43 = getelementptr inbounds double, double* %41, i64 %42
%44 = load double, double* %43
%45 = load double*, double** %8
%46 = load i64, i64* %9
%47 = getelementptr inbounds double, double* %45, i64 %46
store double %44, double* %47
br label %48
48: ; preds = %31
%49 = load i64, i64* %9
%50 = add nsw i64 %49, 1
store i64 %50, i64* %9
br label %27
51: ; preds = %27
%52 = load double*, double** %10
%53 = call i32 @free(double* %52)
ret void
}

LLVM IR (-O2):
define void @inithermitcat(i64 %0, double %1, double* nocapture writeonly %2, double* %3) {
%5 = tail call double @sqrt(double %1)
%6 = fdiv double 0x3FF6A09E667F3BCD, %5
%7 = shl i64 %0, 3
%8 = add i64 %7, 8
%9 = tail call i64 @mymalloc(i64 %8)
%10 = inttoptr i64 %9 to double*
%11 = inttoptr i64 %9 to i8*
%12 = tail call i32 @root_hermite(i64 %0, double* %10)
%13 = tail call i32 @hermite_weight(i64 %0, double* %10, double* %3)
%14 = icmp sgt i64 %0, 0
br i1 %14, label %15, label %128
15: ; preds = %4
%16 = icmp ult i64 %0, 4
br i1 %16, label %86, label %17
17: ; preds = %15
%18 = getelementptr double, double* %2, i64 %0
%19 = bitcast double* %18 to i8*
%20 = getelementptr double, double* %10, i64 %0
%21 = icmp ugt double* %20, %2
%22 = icmp ult i8* %11, %19
%23 = and i1 %21, %22
br i1 %23, label %86, label %24
24: ; preds = %17
%25 = and i64 %0, -4
%26 = insertelement <2 x double> poison, double %6, i64 0
%27 = shufflevector <2 x double> %26, <2 x double> poison, <2 x i32> zeroinitializer
%28 = insertelement <2 x double> poison, double %6, i64 0
%29 = shufflevector <2 x double> %28, <2 x double> poison, <2 x i32> zeroinitializer
%30 = add i64 %25, -4
%31 = lshr exact i64 %30, 2
%32 = add nuw nsw i64 %31, 1
%33 = and i64 %32, 1
%34 = icmp eq i64 %30, 0
br i1 %34, label %68, label %35
35: ; preds = %24
%36 = and i64 %32, 9223372036854775806
br label %37
37: ; preds = %37, %35
%38 = phi i64 [ 0, %35 ], [ %65, %37 ]
%39 = phi i64 [ 0, %35 ], [ %66, %37 ]
%40 = getelementptr inbounds double, double* %10, i64 %38
%41 = bitcast double* %40 to <2 x double>*
%42 = load <2 x double>, <2 x double>* %41
%43 = getelementptr inbounds double, double* %40, i64 2
%44 = bitcast double* %43 to <2 x double>*
%45 = load <2 x double>, <2 x double>* %44
%46 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %27, <2 x double> %42, <2 x double> <double 1.000000e+00, double 1.000000e+00>)
%47 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %29, <2 x double> %45, <2 x double> <double 1.000000e+00, double 1.000000e+00>)
%48 = getelementptr inbounds double, double* %2, i64 %38
%49 = bitcast double* %48 to <2 x double>*
store <2 x double> %46, <2 x double>* %49
%50 = getelementptr inbounds double, double* %48, i64 2
%51 = bitcast double* %50 to <2 x double>*
store <2 x double> %47, <2 x double>* %51
%52 = or i64 %38, 4
%53 = getelementptr inbounds double, double* %10, i64 %52
%54 = bitcast double* %53 to <2 x double>*
%55 = load <2 x double>, <2 x double>* %54
%56 = getelementptr inbounds double, double* %53, i64 2
%57 = bitcast double* %56 to <2 x double>*
%58 = load <2 x double>, <2 x double>* %57
%59 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %27, <2 x double> %55, <2 x double> <double 1.000000e+00, double 1.000000e+00>)
%60 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %29, <2 x double> %58, <2 x double> <double 1.000000e+00, double 1.000000e+00>)
%61 = getelementptr inbounds double, double* %2, i64 %52
%62 = bitcast double* %61 to <2 x double>*
store <2 x double> %59, <2 x double>* %62
%63 = getelementptr inbounds double, double* %61, i64 2
%64 = bitcast double* %63 to <2 x double>*
store <2 x double> %60, <2 x double>* %64
%65 = add nuw i64 %38, 8
%66 = add i64 %39, 2
%67 = icmp eq i64 %66, %36
br i1 %67, label %68, label %37
68: ; preds = %37, %24
%69 = phi i64 [ 0, %24 ], [ %65, %37 ]
%70 = icmp eq i64 %33, 0
br i1 %70, label %84, label %71
71: ; preds = %68
%72 = getelementptr inbounds double, double* %10, i64 %69
%73 = bitcast double* %72 to <2 x double>*
%74 = load <2 x double>, <2 x double>* %73
%75 = getelementptr inbounds double, double* %72, i64 2
%76 = bitcast double* %75 to <2 x double>*
%77 = load <2 x double>, <2 x double>* %76
%78 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %27, <2 x double> %74, <2 x double> <double 1.000000e+00, double 1.000000e+00>)
%79 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %29, <2 x double> %77, <2 x double> <double 1.000000e+00, double 1.000000e+00>)
%80 = getelementptr inbounds double, double* %2, i64 %69
%81 = bitcast double* %80 to <2 x double>*
store <2 x double> %78, <2 x double>* %81
%82 = getelementptr inbounds double, double* %80, i64 2
%83 = bitcast double* %82 to <2 x double>*
store <2 x double> %79, <2 x double>* %83
br label %84
84: ; preds = %68, %71
%85 = icmp eq i64 %25, %0
br i1 %85, label %128, label %86
86: ; preds = %17, %15, %84
%87 = phi i64 [ 0, %17 ], [ 0, %15 ], [ %25, %84 ]
%88 = xor i64 %87, -1
%89 = add i64 %88, %0
%90 = and i64 %0, 3
%91 = icmp eq i64 %90, 0
br i1 %91, label %102, label %92
92: ; preds = %86, %92
%93 = phi i64 [ %99, %92 ], [ %87, %86 ]
%94 = phi i64 [ %100, %92 ], [ 0, %86 ]
%95 = getelementptr inbounds double, double* %10, i64 %93
%96 = load double, double* %95
%97 = tail call double @llvm.fmuladd.f64(double %6, double %96, double 1.000000e+00)
%98 = getelementptr inbounds double, double* %2, i64 %93
store double %97, double* %98
%99 = add nuw nsw i64 %93, 1
%100 = add i64 %94, 1
%101 = icmp eq i64 %100, %90
br i1 %101, label %102, label %92
102: ; preds = %92, %86
%103 = phi i64 [ %87, %86 ], [ %99, %92 ]
%104 = icmp ult i64 %89, 3
br i1 %104, label %128, label %105
105: ; preds = %102, %105
%106 = phi i64 [ %126, %105 ], [ %103, %102 ]
%107 = getelementptr inbounds double, double* %10, i64 %106
%108 = load double, double* %107
%109 = tail call double @llvm.fmuladd.f64(double %6, double %108, double 1.000000e+00)
%110 = getelementptr inbounds double, double* %2, i64 %106
store double %109, double* %110
%111 = add nuw nsw i64 %106, 1
%112 = getelementptr inbounds double, double* %10, i64 %111
%113 = load double, double* %112
%114 = tail call double @llvm.fmuladd.f64(double %6, double %113, double 1.000000e+00)
%115 = getelementptr inbounds double, double* %2, i64 %111
store double %114, double* %115
%116 = add nuw nsw i64 %106, 2
%117 = getelementptr inbounds double, double* %10, i64 %116
%118 = load double, double* %117
%119 = tail call double @llvm.fmuladd.f64(double %6, double %118, double 1.000000e+00)
%120 = getelementptr inbounds double, double* %2, i64 %116
store double %119, double* %120
%121 = add nuw nsw i64 %106, 3
%122 = getelementptr inbounds double, double* %10, i64 %121
%123 = load double, double* %122
%124 = tail call double @llvm.fmuladd.f64(double %6, double %123, double 1.000000e+00)
%125 = getelementptr inbounds double, double* %2, i64 %121
store double %124, double* %125
%126 = add nuw nsw i64 %106, 4
%127 = icmp eq i64 %126, %0
br i1 %127, label %128, label %105
128: ; preds = %102, %105, %84, %4
%129 = tail call i32 @free(double* %10)
ret void
}