; LLVM IR from dartsim/dart :: dart/external/odelcpsolver/matrix.ll (ZN4dart8external3ode20_dIsPositiveDefiniteEPKdiPv)

; Unoptimized IR (clang -disable-llvm-passes):
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

@.str = external hidden unnamed_addr constant [24 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [84 x i8], align 1
@__FUNCTION__._ZN4dart8external3ode20_dIsPositiveDefiniteEPKdiPv = external hidden unnamed_addr constant [21 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [76 x i8], align 1

declare void @_ZN4dart8external3ode6dDebugEiPKcz(i32 noundef, ptr noundef, ...) #0

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #1

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_ZN4dart8external3ode16_dFactorCholeskyEPdiPv(ptr noundef, i32 noundef, ptr noundef) #2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare hidden noundef i64 @_ZN4dart8external3odeL34_dEstimateFactorCholeskyTmpbufSizeEi(i32 noundef) #3

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #4

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_ZN4dart8external3ode20_dIsPositiveDefiniteEPKdiPv(ptr noundef %0, i32 noundef %1, ptr noundef %2) #2 {
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  %6 = alloca ptr, align 8
  %7 = alloca i64, align 8
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca ptr, align 8
  %11 = alloca ptr, align 8
  store ptr %0, ptr %4, align 8, !tbaa !5
  store i32 %1, ptr %5, align 4, !tbaa !9
  store ptr %2, ptr %6, align 8, !tbaa !5
  %12 = load i32, ptr %5, align 4, !tbaa !9
  %13 = icmp sgt i32 %12, 0
  br i1 %13, label %14, label %17

14:                                               ; preds = %3
  %15 = load ptr, ptr %4, align 8, !tbaa !5
  %16 = icmp ne ptr %15, null
  br i1 %16, label %18, label %17

17:                                               ; preds = %14, %3
  call void (i32, ptr, ...) @_ZN4dart8external3ode6dDebugEiPKcz(i32 noundef 2, ptr noundef @.str, ptr noundef @__FUNCTION__._ZN4dart8external3ode20_dIsPositiveDefiniteEPKdiPv)
  br label %18

18:                                               ; preds = %17, %14
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #5
  %19 = load i32, ptr %5, align 4, !tbaa !9
  %20 = call noundef i64 @_ZN4dart8external3odeL34_dEstimateFactorCholeskyTmpbufSizeEi(i32 noundef %19)
  store i64 %20, ptr %7, align 8, !tbaa !11
  %21 = load i64, ptr %7, align 8, !tbaa !11
  %22 = urem i64 %21, 8
  %23 = icmp eq i64 %22, 0
  br i1 %23, label %25, label %24

24:                                               ; preds = %18
  call void (i32, ptr, ...) @_ZN4dart8external3ode6dDebugEiPKcz(i32 noundef 1, ptr noundef @.str.5, ptr noundef @__FUNCTION__._ZN4dart8external3ode20_dIsPositiveDefiniteEPKdiPv, ptr noundef @.str.2, i32 noundef 259)
  br label %25

25:                                               ; preds = %24, %18
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #5
  %26 = load i32, ptr %5, align 4, !tbaa !9
  %27 = icmp sgt i32 %26, 1
  br i1 %27, label %28, label %33

28:                                               ; preds = %25
  %29 = load i32, ptr %5, align 4, !tbaa !9
  %30 = sub nsw i32 %29, 1
  %31 = or i32 %30, 3
  %32 = add nsw i32 %31, 1
  br label %35

33:                                               ; preds = %25
  %34 = load i32, ptr %5, align 4, !tbaa !9
  br label %35

35:                                               ; preds = %33, %28
  %36 = phi i32 [ %32, %28 ], [ %34, %33 ]
  store i32 %36, ptr %8, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #5
  %37 = load i32, ptr %8, align 4, !tbaa !9
  %38 = load i32, ptr %5, align 4, !tbaa !9
  %39 = mul nsw i32 %37, %38
  store i32 %39, ptr %9, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #5
  %40 = load ptr, ptr %6, align 8, !tbaa !5
  %41 = icmp ne ptr %40, null
  br i1 %41, label %42, label %44

42:                                               ; preds = %35
  %43 = load ptr, ptr %6, align 8, !tbaa !5
  br label %56

44:                                               ; preds = %35
  %45 = load i64, ptr %7, align 8, !tbaa !11
  %46 = load i32, ptr %9, align 4, !tbaa !9
  %47 = sext i32 %46 to i64
  %48 = mul i64 %47, 8
  %49 = add i64 %45, %48
  %50 = add i64 %49, 15
  %51 = alloca i8, i64 %50, align 16
  %52 = ptrtoint ptr %51 to i64
  %53 = add i64 %52, 15
  %54 = and i64 %53, -16
  %55 = inttoptr i64 %54 to ptr
  br label %56

56:                                               ; preds = %44, %42
  %57 = phi ptr [ %43, %42 ], [ %55, %44 ]
  store ptr %57, ptr %10, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #5
  %58 = load ptr, ptr %10, align 8, !tbaa !5
  %59 = load i64, ptr %7, align 8, !tbaa !11
  %60 = getelementptr inbounds i8, ptr %58, i64 %59
  store ptr %60, ptr %11, align 8, !tbaa !5
  %61 = load ptr, ptr %11, align 8, !tbaa !5
  %62 = load ptr, ptr %4, align 8, !tbaa !5
  %63 = load i32, ptr %9, align 4, !tbaa !9
  %64 = sext i32 %63 to i64
  %65 = mul i64 %64, 8
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %61, ptr align 8 %62, i64 %65, i1 false)
  %66 = load ptr, ptr %11, align 8, !tbaa !5
  %67 = load i32, ptr %5, align 4, !tbaa !9
  %68 = load ptr, ptr %10, align 8, !tbaa !5
  %69 = call noundef i32 @_ZN4dart8external3ode16_dFactorCholeskyEPdiPv(ptr noundef %66, i32 noundef %67, ptr noundef %68)
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #5
  ret i32 %69
}

attributes #0 = { "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { mustprogress uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { inlinehint mustprogress nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #4 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #5 = { nounwind }

!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"long", !7, i64 0}


; Optimized IR (opt -passes='default<O3>'):
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

@.str = external hidden unnamed_addr constant [24 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [84 x i8], align 1
@__FUNCTION__._ZN4dart8external3ode20_dIsPositiveDefiniteEPKdiPv = external hidden unnamed_addr constant [21 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [76 x i8], align 1

declare void @_ZN4dart8external3ode6dDebugEiPKcz(i32 noundef, ptr noundef, ...) local_unnamed_addr #0

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_ZN4dart8external3ode16_dFactorCholeskyEPdiPv(ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #1

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare hidden noundef i64 @_ZN4dart8external3odeL34_dEstimateFactorCholeskyTmpbufSizeEi(i32 noundef) local_unnamed_addr #2

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #3

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_ZN4dart8external3ode20_dIsPositiveDefiniteEPKdiPv(ptr noundef readonly %0, i32 noundef %1, ptr noundef %2) local_unnamed_addr #1 {
  %4 = icmp sgt i32 %1, 0
  %5 = icmp ne ptr %0, null
  %or.cond = and i1 %5, %4
  br i1 %or.cond, label %7, label %6

6:                                                ; preds = %3
  tail call void (i32, ptr, ...) @_ZN4dart8external3ode6dDebugEiPKcz(i32 noundef 2, ptr noundef nonnull @.str, ptr noundef nonnull @__FUNCTION__._ZN4dart8external3ode20_dIsPositiveDefiniteEPKdiPv)
  br label %7

7:                                                ; preds = %3, %6
  %8 = tail call noundef i64 @_ZN4dart8external3odeL34_dEstimateFactorCholeskyTmpbufSizeEi(i32 noundef %1)
  %9 = and i64 %8, 7
  %10 = icmp eq i64 %9, 0
  br i1 %10, label %12, label %11

11:                                               ; preds = %7
  tail call void (i32, ptr, ...) @_ZN4dart8external3ode6dDebugEiPKcz(i32 noundef 1, ptr noundef nonnull @.str.5, ptr noundef nonnull @__FUNCTION__._ZN4dart8external3ode20_dIsPositiveDefiniteEPKdiPv, ptr noundef nonnull @.str.2, i32 noundef 259)
  br label %12

12:                                               ; preds = %11, %7
  %13 = icmp sgt i32 %1, 1
  %14 = add nsw i32 %1, -1
  %15 = or i32 %14, 3
  %16 = add nuw nsw i32 %15, 1
  %17 = select i1 %13, i32 %16, i32 %1
  %18 = mul nsw i32 %17, %1
  %.not = icmp eq ptr %2, null
  %19 = sext i32 %18 to i64
  %20 = shl nsw i64 %19, 3
  br i1 %.not, label %21, label %._crit_edge

21:                                               ; preds = %12
  %22 = add nsw i64 %20, 15
  %23 = add i64 %22, %8
  %24 = alloca i8, i64 %23, align 16
  br label %._crit_edge

._crit_edge:                                      ; preds = %12, %21
  %25 = phi ptr [ %24, %21 ], [ %2, %12 ]
  %26 = getelementptr inbounds i8, ptr %25, i64 %8
  call void @llvm.memcpy.p0.p0.i64(ptr nonnull align 8 %26, ptr align 8 %0, i64 %20, i1 false)
  %27 = call noundef i32 @_ZN4dart8external3ode16_dFactorCholeskyEPdiPv(ptr noundef nonnull %26, i32 noundef %1, ptr noundef nonnull %25)
  ret i32 %27
}

attributes #0 = { "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { mustprogress uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #2 = { inlinehint mustprogress nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }

!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}


; Effective O3 passes: BDCEPass,GVNPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass