#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 *);
scalar_t__ malloc(int);
int /*<<< orphan*/ mmult(double *, double *, double *, int, int, int);
void inithess_l(double *H, int N, int k, double *tsk, double *tyk, double *dx) {
  int i, j, ct;
  double temp;
  double *num, *den;
  num = (double *)malloc(sizeof(double) * 1);
  den = (double *)malloc(sizeof(double) * 1);
  mmult(tsk, tyk, num, 1, N, 1);
  mmult(tyk, tyk, den, 1, N, 1);
  if (k > 0) {
    temp = num[0] / den[0];
  } else {
    temp = 1.0;
  }
  for (i = 0; i < N; ++i) {
    ct = i * N;
    for (j = 0; j < N; ++j) {
      if (i == j) {
        H[ct + j] = temp * dx[i] * dx[i];
      } else {
        H[ct + j] = 0.0;
      }
    }
  }
  free(num);
  free(den);
}


x86 assembly (clang, -O0):
<inithess_l>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %rcx,-0x18(%rbp)
mov    %r8,-0x20(%rbp)
mov    %r9,-0x28(%rbp)
mov    $0x8,%edi
call   1050 <malloc@plt>
mov    %rax,-0x48(%rbp)
mov    $0x8,%edi
call   1050 <malloc@plt>
mov    %rax,-0x50(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    -0x48(%rbp),%rdx
mov    -0xc(%rbp),%r8d
mov    $0x1,%r9d
mov    %r9d,%ecx
call   1040 <mmult@plt>
mov    -0x20(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    -0x50(%rbp),%rdx
mov    -0xc(%rbp),%r8d
mov    $0x1,%r9d
mov    %r9d,%ecx
call   1040 <mmult@plt>
cmpl   $0x0,-0x10(%rbp)
jle    11ca <inithess_l+0x9a>
mov    -0x48(%rbp),%rax
movsd  (%rax),%xmm0
mov    -0x50(%rbp),%rax
divsd  (%rax),%xmm0
movsd  %xmm0,-0x40(%rbp)
jmp    11d7 <inithess_l+0xa7>
movsd  0xe2e(%rip),%xmm0
movsd  %xmm0,-0x40(%rbp)
movl   $0x0,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    1284 <inithess_l+0x154>
mov    -0x2c(%rbp),%eax
imul   -0xc(%rbp),%eax
mov    %eax,-0x34(%rbp)
movl   $0x0,-0x30(%rbp)
mov    -0x30(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    1271 <inithess_l+0x141>
mov    -0x2c(%rbp),%eax
cmp    -0x30(%rbp),%eax
jne    1249 <inithess_l+0x119>
movsd  -0x40(%rbp),%xmm0
mov    -0x28(%rbp),%rax
movslq -0x2c(%rbp),%rcx
mulsd  (%rax,%rcx,8),%xmm0
mov    -0x28(%rbp),%rax
movslq -0x2c(%rbp),%rcx
mulsd  (%rax,%rcx,8),%xmm0
mov    -0x8(%rbp),%rax
mov    -0x34(%rbp),%ecx
add    -0x30(%rbp),%ecx
movslq %ecx,%rcx
movsd  %xmm0,(%rax,%rcx,8)
jmp    125e <inithess_l+0x12e>
mov    -0x8(%rbp),%rax
mov    -0x34(%rbp),%ecx
add    -0x30(%rbp),%ecx
movslq %ecx,%rcx
xorps  %xmm0,%xmm0
movsd  %xmm0,(%rax,%rcx,8)
jmp    1263 <inithess_l+0x133>
mov    -0x30(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30(%rbp)
jmp    11fb <inithess_l+0xcb>
jmp    1276 <inithess_l+0x146>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    11de <inithess_l+0xae>
mov    -0x48(%rbp),%rdi
call   1030 <free@plt>
mov    -0x50(%rbp),%rdi
call   1030 <free@plt>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<inithess_l>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %r9,%r13
mov    %r8,%r15
mov    %rcx,0x10(%rsp)
mov    %edx,0xc(%rsp)
mov    %esi,%r14d
mov    %rdi,%rbp
mov    $0x8,%edi
call   1050 <malloc@plt>
mov    %rax,%r12
mov    $0x8,%edi
call   1050 <malloc@plt>
mov    %rax,%rbx
mov    0x10(%rsp),%rdi
mov    %r15,%rsi
mov    %r12,%rdx
mov    $0x1,%ecx
mov    %r14d,%r8d
mov    $0x1,%r9d
call   1040 <mmult@plt>
mov    %r15,%rdi
mov    %r15,%rsi
mov    %rbx,%r15
mov    %rbx,%rdx
mov    $0x1,%ecx
mov    %r14d,%r8d
mov    $0x1,%r9d
call   1040 <mmult@plt>
cmpl   $0x0,0xc(%rsp)
jle    11c6 <inithess_l+0x96>
movsd  (%r12),%xmm0
divsd  (%r15),%xmm0
test   %r14d,%r14d
jg     11d7 <inithess_l+0xa7>
jmp    12e8 <inithess_l+0x1b8>
movsd  0xe32(%rip),%xmm0
test   %r14d,%r14d
jle    12e8 <inithess_l+0x1b8>
mov    %r14d,%r9d
mov    %r9d,%ecx
and    $0xfffffffe,%ecx
lea    0x8(%rbp),%rdx
lea    0x0(,%r9,8),%r8
xor    %edi,%edi
jmp    1219 <inithess_l+0xe9>
movsd  0x0(%r13,%rdi,8),%xmm1
movapd %xmm0,%xmm2
mulsd  %xmm1,%xmm2
mulsd  %xmm1,%xmm2
movsd  %xmm2,0x0(%rbp,%rsi,8)
add    $0x1,%rdi
add    %r8,%rdx
cmp    %r9,%rdi
je     12e8 <inithess_l+0x1b8>
mov    %rdi,%r10
imul   %r9,%r10
lea    (%rdi,%r10,1),%rsi
cmp    $0x1,%r14d
jne    1240 <inithess_l+0x110>
xor    %ebx,%ebx
test   $0x1,%r9b
je     1209 <inithess_l+0xd9>
jmp    12ce <inithess_l+0x19e>
nopw   0x0(%rax,%rax,1)
xor    %eax,%eax
jmp    1272 <inithess_l+0x142>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movsd  0x0(%r13,%rdi,8),%xmm1
movapd %xmm0,%xmm2
mulsd  %xmm1,%xmm2
mulsd  %xmm1,%xmm2
movsd  %xmm2,0x0(%rbp,%rsi,8)
add    $0x1,%rax
cmp    %rcx,%rax
je     12c0 <inithess_l+0x190>
mov    %rax,%rbx
cmp    %rax,%rdi
jne    12a0 <inithess_l+0x170>
movsd  0x0(%r13,%rdi,8),%xmm1
movapd %xmm0,%xmm2
mulsd  %xmm1,%xmm2
mulsd  %xmm1,%xmm2
movsd  %xmm2,0x0(%rbp,%rsi,8)
jmp    12a9 <inithess_l+0x179>
cs nopw 0x0(%rax,%rax,1)
nop
movq   $0x0,-0x8(%rdx,%rbx,8)
lea    0x1(%rbx),%rax
cmp    %rax,%rdi
je     1250 <inithess_l+0x120>
movq   $0x0,(%rdx,%rbx,8)
jmp    1269 <inithess_l+0x139>
nopl   0x0(%rax)
add    $0x2,%rbx
test   $0x1,%r9b
je     1209 <inithess_l+0xd9>
cmp    %rbx,%rdi
je     11f0 <inithess_l+0xc0>
add    %r10,%rbx
movq   $0x0,0x0(%rbp,%rbx,8)
jmp    1209 <inithess_l+0xd9>
mov    %r12,%rdi
call   1030 <free@plt>
mov    %r15,%rdi
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <free@plt>

LLVM IR (-O0):
define void @inithess_l(double* %0, i32 %1, i32 %2, double* %3, double* %4, double* %5) {
%7 = alloca double*
%8 = alloca i32
%9 = alloca i32
%10 = alloca double*
%11 = alloca double*
%12 = alloca double*
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
%16 = alloca double
%17 = alloca double*
%18 = alloca double*
store double* %0, double** %7
store i32 %1, i32* %8
store i32 %2, i32* %9
store double* %3, double** %10
store double* %4, double** %11
store double* %5, double** %12
%19 = call i64 @malloc(i32 8)
%20 = inttoptr i64 %19 to double*
store double* %20, double** %17
%21 = call i64 @malloc(i32 8)
%22 = inttoptr i64 %21 to double*
store double* %22, double** %18
%23 = load double*, double** %10
%24 = load double*, double** %11
%25 = load double*, double** %17
%26 = load i32, i32* %8
%27 = call i32 @mmult(double* %23, double* %24, double* %25, i32 1, i32 %26, i32 1)
%28 = load double*, double** %11
%29 = load double*, double** %11
%30 = load double*, double** %18
%31 = load i32, i32* %8
%32 = call i32 @mmult(double* %28, double* %29, double* %30, i32 1, i32 %31, i32 1)
%33 = load i32, i32* %9
%34 = icmp sgt i32 %33, 0
br i1 %34, label %35, label %43
35: ; preds = %6
%36 = load double*, double** %17
%37 = getelementptr inbounds double, double* %36, i64 0
%38 = load double, double* %37
%39 = load double*, double** %18
%40 = getelementptr inbounds double, double* %39, i64 0
%41 = load double, double* %40
%42 = fdiv double %38, %41
store double %42, double* %16
br label %44
43: ; preds = %6
store double 1.000000e+00, double* %16
br label %44
44: ; preds = %43, %35
store i32 0, i32* %13
br label %45
45: ; preds = %93, %44
%46 = load i32, i32* %13
%47 = load i32, i32* %8
%48 = icmp slt i32 %46, %47
br i1 %48, label %49, label %96
49: ; preds = %45
%50 = load i32, i32* %13
%51 = load i32, i32* %8
%52 = mul nsw i32 %50, %51
store i32 %52, i32* %15
store i32 0, i32* %14
br label %53
53: ; preds = %89, %49
%54 = load i32, i32* %14
%55 = load i32, i32* %8
%56 = icmp slt i32 %54, %55
br i1 %56, label %57, label %92
57: ; preds = %53
%58 = load i32, i32* %13
%59 = load i32, i32* %14
%60 = icmp eq i32 %58, %59
br i1 %60, label %61, label %81
61: ; preds = %57
%62 = load double, double* %16
%63 = load double*, double** %12
%64 = load i32, i32* %13
%65 = sext i32 %64 to i64
%66 = getelementptr inbounds double, double* %63, i64 %65
%67 = load double, double* %66
%68 = fmul double %62, %67
%69 = load double*, double** %12
%70 = load i32, i32* %13
%71 = sext i32 %70 to i64
%72 = getelementptr inbounds double, double* %69, i64 %71
%73 = load double, double* %72
%74 = fmul double %68, %73
%75 = load double*, double** %7
%76 = load i32, i32* %15
%77 = load i32, i32* %14
%78 = add nsw i32 %76, %77
%79 = sext i32 %78 to i64
%80 = getelementptr inbounds double, double* %75, i64 %79
store double %74, double* %80
br label %88
81: ; preds = %57
%82 = load double*, double** %7
%83 = load i32, i32* %15
%84 = load i32, i32* %14
%85 = add nsw i32 %83, %84
%86 = sext i32 %85 to i64
%87 = getelementptr inbounds double, double* %82, i64 %86
store double 0.000000e+00, double* %87
br label %88
88: ; preds = %81, %61
br label %89
89: ; preds = %88
%90 = load i32, i32* %14
%91 = add nsw i32 %90, 1
store i32 %91, i32* %14
br label %53
92: ; preds = %53
br label %93
93: ; preds = %92
%94 = load i32, i32* %13
%95 = add nsw i32 %94, 1
store i32 %95, i32* %13
br label %45
96: ; preds = %45
%97 = load double*, double** %17
%98 = call i32 @free(double* %97)
%99 = load double*, double** %18
%100 = call i32 @free(double* %99)
ret void
}

LLVM IR (-O2):
define void @inithess_l(double* nocapture writeonly %0, i32 %1, i32 %2, double* %3, double* %4, double* nocapture %5) {
%7 = tail call i64 @malloc(i32 8)
%8 = inttoptr i64 %7 to double*
%9 = tail call i64 @malloc(i32 8)
%10 = inttoptr i64 %9 to double*
%11 = tail call i32 @mmult(double* %3, double* %4, double* %8, i32 1, i32 %1, i32 1)
%12 = tail call i32 @mmult(double* %4, double* %4, double* %10, i32 1, i32 %1, i32 1)
%13 = icmp sgt i32 %2, 0
br i1 %13, label %14, label %18
14: ; preds = %6
%15 = load double, double* %8
%16 = load double, double* %10
%17 = fdiv double %15, %16
br label %18
18: ; preds = %6, %14
%19 = phi double [ %17, %14 ], [ 1.000000e+00, %6 ]
%20 = icmp sgt i32 %1, 0
br i1 %20, label %21, label %73
21: ; preds = %18
%22 = zext i32 %1 to i64
%23 = zext i32 %1 to i64
%24 = and i64 %23, 1
%25 = icmp eq i32 %1, 1
%26 = and i64 %23, 4294967294
%27 = icmp eq i64 %24, 0
br label %28
28: ; preds = %70, %21
%29 = phi i64 [ 0, %21 ], [ %71, %70 ]
%30 = mul nsw i64 %29, %22
%31 = getelementptr inbounds double, double* %5, i64 %29
%32 = add nuw nsw i64 %29, %30
%33 = getelementptr inbounds double, double* %0, i64 %32
br i1 %25, label %59, label %34
34: ; preds = %28, %55
%35 = phi i64 [ %56, %55 ], [ 0, %28 ]
%36 = phi i64 [ %57, %55 ], [ 0, %28 ]
%37 = icmp eq i64 %29, %35
br i1 %37, label %38, label %42
38: ; preds = %34
%39 = load double, double* %31
%40 = fmul double %19, %39
%41 = fmul double %39, %40
store double %41, double* %33
br label %45
42: ; preds = %34
%43 = add nuw nsw i64 %35, %30
%44 = getelementptr inbounds double, double* %0, i64 %43
store double 0.000000e+00, double* %44
br label %45
45: ; preds = %38, %42
%46 = or i64 %35, 1
%47 = icmp eq i64 %29, %46
br i1 %47, label %51, label %48
48: ; preds = %45
%49 = add nuw nsw i64 %46, %30
%50 = getelementptr inbounds double, double* %0, i64 %49
store double 0.000000e+00, double* %50
br label %55
51: ; preds = %45
%52 = load double, double* %31
%53 = fmul double %19, %52
%54 = fmul double %52, %53
store double %54, double* %33
br label %55
55: ; preds = %51, %48
%56 = add nuw nsw i64 %35, 2
%57 = add i64 %36, 2
%58 = icmp eq i64 %57, %26
br i1 %58, label %59, label %34
59: ; preds = %55, %28
%60 = phi i64 [ 0, %28 ], [ %56, %55 ]
br i1 %27, label %70, label %61
61: ; preds = %59
%62 = icmp eq i64 %29, %60
br i1 %62, label %66, label %63
63: ; preds = %61
%64 = add nuw nsw i64 %60, %30
%65 = getelementptr inbounds double, double* %0, i64 %64
store double 0.000000e+00, double* %65
br label %70
66: ; preds = %61
%67 = load double, double* %31
%68 = fmul double %19, %67
%69 = fmul double %67, %68
store double %69, double* %33
br label %70
70: ; preds = %63, %66, %59
%71 = add nuw nsw i64 %29, 1
%72 = icmp eq i64 %71, %23
br i1 %72, label %73, label %28
73: ; preds = %70, %18
%74 = tail call i32 @free(double* %8)
%75 = tail call i32 @free(double* %10)
ret void
}