; LLVM IR from Amoiensis/Optimization-Algorithm :: [Lagrangian_Relaxation]拉格朗日松弛法 (main)

; 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"

%struct._Matrix = type { i32, i32, ptr }

; Function Attrs: nounwind uwtable
declare dso_local ptr @Matrix_gen(i32 noundef, 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: nounwind allocsize(0)
declare noalias ptr @malloc(i64 noundef) #2

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

; Function Attrs: nounwind uwtable
declare dso_local ptr @M_add_sub(double noundef, ptr noundef, double noundef, ptr noundef) #0

; Function Attrs: nounwind uwtable
declare dso_local i32 @M_print(ptr noundef) #0

; Function Attrs: nounwind uwtable
declare dso_local i32 @M_free(ptr noundef) #0

; Function Attrs: nounwind uwtable
declare dso_local ptr @M_numul(ptr noundef, double noundef) #0

; Function Attrs: nounwind uwtable
declare dso_local ptr @M_matFull(ptr noundef, i32 noundef, i32 noundef, ptr noundef) #0

; Function Attrs: nounwind uwtable
declare dso_local double @Function(ptr noundef) #0

; Function Attrs: nounwind uwtable
declare dso_local ptr @Func_derivative(ptr noundef, double noundef) #0

; Function Attrs: nounwind uwtable
define dso_local ptr @Func_Hessian(ptr noundef %0, double noundef %1, double noundef %2) #0 {
  %4 = alloca ptr, align 8
  %5 = alloca double, align 8
  %6 = alloca double, align 8
  %7 = alloca ptr, align 8
  %8 = alloca i32, align 4
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca ptr, align 8
  %12 = alloca double, align 8
  %13 = alloca i32, align 4
  %14 = alloca i32, align 4
  %15 = alloca ptr, align 8
  %16 = alloca ptr, align 8
  %17 = alloca ptr, align 8
  store ptr %0, ptr %4, align 8, !tbaa !5
  store double %1, ptr %5, align 8, !tbaa !9
  store double %2, ptr %6, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #3
  store ptr @Function, ptr %7, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #3
  %18 = load ptr, ptr %4, align 8, !tbaa !5
  %19 = getelementptr inbounds %struct._Matrix, ptr %18, i32 0, i32 1
  %20 = load i32, ptr %19, align 4, !tbaa !11
  %21 = load ptr, ptr %4, align 8, !tbaa !5
  %22 = getelementptr inbounds %struct._Matrix, ptr %21, i32 0, i32 1
  %23 = load i32, ptr %22, align 4, !tbaa !11
  %24 = mul nsw i32 %20, %23
  store i32 %24, ptr %8, align 4, !tbaa !14
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #3
  %25 = load i32, ptr %8, align 4, !tbaa !14
  %26 = sext i32 %25 to i64
  %27 = mul i64 %26, 8
  %28 = call noalias ptr @malloc(i64 noundef %27) #4
  store ptr %28, ptr %9, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #3
  %29 = load ptr, ptr %4, align 8, !tbaa !5
  %30 = getelementptr inbounds %struct._Matrix, ptr %29, i32 0, i32 1
  %31 = load i32, ptr %30, align 4, !tbaa !11
  %32 = load ptr, ptr %4, align 8, !tbaa !5
  %33 = getelementptr inbounds %struct._Matrix, ptr %32, i32 0, i32 1
  %34 = load i32, ptr %33, align 4, !tbaa !11
  %35 = load ptr, ptr %9, align 8, !tbaa !5
  %36 = call ptr @Matrix_gen(i32 noundef %31, i32 noundef %34, ptr noundef %35)
  store ptr %36, ptr %10, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #3
  %37 = load ptr, ptr %4, align 8, !tbaa !5
  %38 = getelementptr inbounds %struct._Matrix, ptr %37, i32 0, i32 0
  %39 = load i32, ptr %38, align 8, !tbaa !15
  %40 = load ptr, ptr %4, align 8, !tbaa !5
  %41 = getelementptr inbounds %struct._Matrix, ptr %40, i32 0, i32 1
  %42 = load i32, ptr %41, align 4, !tbaa !11
  %43 = load ptr, ptr %4, align 8, !tbaa !5
  %44 = getelementptr inbounds %struct._Matrix, ptr %43, i32 0, i32 2
  %45 = load ptr, ptr %44, align 8, !tbaa !16
  %46 = call ptr @Matrix_gen(i32 noundef %39, i32 noundef %42, ptr noundef %45)
  store ptr %46, ptr %11, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #3
  %47 = load ptr, ptr %7, align 8, !tbaa !5
  %48 = load ptr, ptr %11, align 8, !tbaa !5
  %49 = call double %47(ptr noundef %48)
  store double %49, ptr %12, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #3
  %50 = load ptr, ptr %4, align 8, !tbaa !5
  %51 = load double, ptr %5, align 8, !tbaa !9
  %52 = call ptr @Func_derivative(ptr noundef %50, double noundef %51)
  store ptr %52, ptr %15, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %17) #3
  %53 = load ptr, ptr %15, align 8, !tbaa !5
  %54 = call i32 @M_print(ptr noundef %53)
  store i32 0, ptr %14, align 4, !tbaa !14
  br label %55

55:                                               ; preds = %112, %3
  %56 = load i32, ptr %14, align 4, !tbaa !14
  %57 = load ptr, ptr %4, align 8, !tbaa !5
  %58 = getelementptr inbounds %struct._Matrix, ptr %57, i32 0, i32 1
  %59 = load i32, ptr %58, align 4, !tbaa !11
  %60 = icmp slt i32 %56, %59
  br i1 %60, label %61, label %115

61:                                               ; preds = %55
  %62 = load i32, ptr %14, align 4, !tbaa !14
  %63 = icmp eq i32 %62, 0
  br i1 %63, label %64, label %74

64:                                               ; preds = %61
  %65 = load double, ptr %6, align 8, !tbaa !9
  %66 = load ptr, ptr %11, align 8, !tbaa !5
  %67 = getelementptr inbounds %struct._Matrix, ptr %66, i32 0, i32 2
  %68 = load ptr, ptr %67, align 8, !tbaa !16
  %69 = load i32, ptr %14, align 4, !tbaa !14
  %70 = sext i32 %69 to i64
  %71 = getelementptr inbounds double, ptr %68, i64 %70
  %72 = load double, ptr %71, align 8, !tbaa !9
  %73 = fadd double %72, %65
  store double %73, ptr %71, align 8, !tbaa !9
  br label %94

74:                                               ; preds = %61
  %75 = load double, ptr %6, align 8, !tbaa !9
  %76 = load ptr, ptr %11, align 8, !tbaa !5
  %77 = getelementptr inbounds %struct._Matrix, ptr %76, i32 0, i32 2
  %78 = load ptr, ptr %77, align 8, !tbaa !16
  %79 = load i32, ptr %14, align 4, !tbaa !14
  %80 = sub nsw i32 %79, 1
  %81 = sext i32 %80 to i64
  %82 = getelementptr inbounds double, ptr %78, i64 %81
  %83 = load double, ptr %82, align 8, !tbaa !9
  %84 = fsub double %83, %75
  store double %84, ptr %82, align 8, !tbaa !9
  %85 = load double, ptr %6, align 8, !tbaa !9
  %86 = load ptr, ptr %11, align 8, !tbaa !5
  %87 = getelementptr inbounds %struct._Matrix, ptr %86, i32 0, i32 2
  %88 = load ptr, ptr %87, align 8, !tbaa !16
  %89 = load i32, ptr %14, align 4, !tbaa !14
  %90 = sext i32 %89 to i64
  %91 = getelementptr inbounds double, ptr %88, i64 %90
  %92 = load double, ptr %91, align 8, !tbaa !9
  %93 = fadd double %92, %85
  store double %93, ptr %91, align 8, !tbaa !9
  br label %94

94:                                               ; preds = %74, %64
  %95 = load ptr, ptr %11, align 8, !tbaa !5
  %96 = load double, ptr %5, align 8, !tbaa !9
  %97 = call ptr @Func_derivative(ptr noundef %95, double noundef %96)
  store ptr %97, ptr %16, align 8, !tbaa !5
  %98 = load ptr, ptr %15, align 8, !tbaa !5
  %99 = load ptr, ptr %16, align 8, !tbaa !5
  %100 = call ptr @M_add_sub(double noundef 1.000000e+00, ptr noundef %98, double noundef 1.000000e+00, ptr noundef %99)
  %101 = load double, ptr %6, align 8, !tbaa !9
  %102 = fdiv double 1.000000e+00, %101
  %103 = call ptr @M_numul(ptr noundef %100, double noundef %102)
  store ptr %103, ptr %17, align 8, !tbaa !5
  %104 = load ptr, ptr %10, align 8, !tbaa !5
  %105 = load i32, ptr %14, align 4, !tbaa !14
  %106 = load ptr, ptr %17, align 8, !tbaa !5
  %107 = call ptr @M_matFull(ptr noundef %104, i32 noundef %105, i32 noundef 0, ptr noundef %106)
  store ptr %107, ptr %10, align 8, !tbaa !5
  %108 = load ptr, ptr %16, align 8, !tbaa !5
  %109 = call i32 @M_free(ptr noundef %108)
  %110 = load ptr, ptr %17, align 8, !tbaa !5
  %111 = call i32 @M_free(ptr noundef %110)
  br label %112

112:                                              ; preds = %94
  %113 = load i32, ptr %14, align 4, !tbaa !14
  %114 = add nsw i32 %113, 1
  store i32 %114, ptr %14, align 4, !tbaa !14
  br label %55, !llvm.loop !17

115:                                              ; preds = %55
  %116 = load ptr, ptr %11, align 8, !tbaa !5
  %117 = call i32 @M_free(ptr noundef %116)
  %118 = load ptr, ptr %10, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 8, ptr %17) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #3
  ret ptr %118
}

attributes #0 = { 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 #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { nounwind allocsize(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 = { nounwind }
attributes #4 = { nounwind allocsize(0) }

!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/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"double", !7, i64 0}
!11 = !{!12, !13, i64 4}
!12 = !{!"_Matrix", !13, i64 0, !13, i64 4, !6, i64 8}
!13 = !{!"int", !7, i64 0}
!14 = !{!13, !13, i64 0}
!15 = !{!12, !13, i64 0}
!16 = !{!12, !6, i64 8}
!17 = distinct !{!17, !18}
!18 = !{!"llvm.loop.mustprogress"}


; 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"

; Function Attrs: nounwind uwtable
declare dso_local ptr @Matrix_gen(i32 noundef, i32 noundef, ptr noundef) local_unnamed_addr #0

; Function Attrs: mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @malloc(i64 noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare dso_local ptr @M_add_sub(double noundef, ptr noundef, double noundef, ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare dso_local i32 @M_print(ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare dso_local i32 @M_free(ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare dso_local ptr @M_numul(ptr noundef, double noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare dso_local ptr @M_matFull(ptr noundef, i32 noundef, i32 noundef, ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare dso_local double @Function(ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare dso_local ptr @Func_derivative(ptr noundef, double noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local ptr @Func_Hessian(ptr noundef %0, double noundef %1, double noundef %2) local_unnamed_addr #0 {
  %4 = getelementptr inbounds i8, ptr %0, i64 4
  %5 = load i32, ptr %4, align 4, !tbaa !5
  %6 = mul nsw i32 %5, %5
  %7 = zext nneg i32 %6 to i64
  %8 = shl nuw nsw i64 %7, 3
  %9 = tail call noalias ptr @malloc(i64 noundef %8) #2
  %10 = tail call ptr @Matrix_gen(i32 noundef %5, i32 noundef %5, ptr noundef %9)
  %11 = load i32, ptr %0, align 8, !tbaa !11
  %12 = load i32, ptr %4, align 4, !tbaa !5
  %13 = getelementptr inbounds i8, ptr %0, i64 8
  %14 = load ptr, ptr %13, align 8, !tbaa !12
  %15 = tail call ptr @Matrix_gen(i32 noundef %11, i32 noundef %12, ptr noundef %14)
  %16 = tail call double @Function(ptr noundef %15)
  %17 = tail call ptr @Func_derivative(ptr noundef nonnull %0, double noundef %1)
  %18 = tail call i32 @M_print(ptr noundef %17)
  %19 = load i32, ptr %4, align 4, !tbaa !5
  %20 = icmp sgt i32 %19, 0
  br i1 %20, label %21, label %._crit_edge

21:                                               ; preds = %3
  %22 = getelementptr inbounds i8, ptr %15, i64 8
  %23 = fdiv double 1.000000e+00, %2
  %24 = load ptr, ptr %22, align 8, !tbaa !12
  %25 = load double, ptr %24, align 8, !tbaa !13
  %26 = fadd double %25, %2
  store double %26, ptr %24, align 8, !tbaa !13
  %27 = tail call ptr @Func_derivative(ptr noundef nonnull %15, double noundef %1)
  %28 = tail call ptr @M_add_sub(double noundef 1.000000e+00, ptr noundef %17, double noundef 1.000000e+00, ptr noundef %27)
  %29 = tail call ptr @M_numul(ptr noundef %28, double noundef %23)
  %30 = tail call ptr @M_matFull(ptr noundef %10, i32 noundef 0, i32 noundef 0, ptr noundef %29)
  %31 = tail call i32 @M_free(ptr noundef %27)
  %32 = tail call i32 @M_free(ptr noundef %29)
  %33 = load i32, ptr %4, align 4, !tbaa !5
  %34 = icmp sgt i32 %33, 1
  br i1 %34, label %.peel.next, label %._crit_edge

.peel.next:                                       ; preds = %21, %.peel.next
  %indvars.iv = phi i64 [ %indvars.iv.next, %.peel.next ], [ 1, %21 ]
  %.040 = phi ptr [ %46, %.peel.next ], [ %30, %21 ]
  %35 = load ptr, ptr %22, align 8, !tbaa !12
  %36 = getelementptr double, ptr %35, i64 %indvars.iv
  %37 = getelementptr i8, ptr %36, i64 -8
  %38 = load double, ptr %37, align 8, !tbaa !13
  %39 = fsub double %38, %2
  store double %39, ptr %37, align 8, !tbaa !13
  %40 = load double, ptr %36, align 8, !tbaa !13
  %41 = fadd double %40, %2
  store double %41, ptr %36, align 8, !tbaa !13
  %42 = tail call ptr @Func_derivative(ptr noundef nonnull %15, double noundef %1)
  %43 = tail call ptr @M_add_sub(double noundef 1.000000e+00, ptr noundef %17, double noundef 1.000000e+00, ptr noundef %42)
  %44 = tail call ptr @M_numul(ptr noundef %43, double noundef %23)
  %45 = trunc nuw nsw i64 %indvars.iv to i32
  %46 = tail call ptr @M_matFull(ptr noundef %.040, i32 noundef %45, i32 noundef 0, ptr noundef %44)
  %47 = tail call i32 @M_free(ptr noundef %42)
  %48 = tail call i32 @M_free(ptr noundef %44)
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %49 = load i32, ptr %4, align 4, !tbaa !5
  %50 = sext i32 %49 to i64
  %51 = icmp slt i64 %indvars.iv.next, %50
  br i1 %51, label %.peel.next, label %._crit_edge, !llvm.loop !15

._crit_edge:                                      ; preds = %.peel.next, %21, %3
  %.0.lcssa = phi ptr [ %10, %3 ], [ %30, %21 ], [ %46, %.peel.next ]
  %52 = tail call i32 @M_free(ptr noundef %15)
  ret ptr %.0.lcssa
}

attributes #0 = { 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 #1 = { mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite) "alloc-family"="malloc" "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 = { nounwind allocsize(0) }

!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, !7, i64 4}
!6 = !{!"_Matrix", !7, i64 0, !7, i64 4, !10, i64 8}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"any pointer", !8, i64 0}
!11 = !{!6, !7, i64 0}
!12 = !{!6, !10, i64 8}
!13 = !{!14, !14, i64 0}
!14 = !{!"double", !8, i64 0}
!15 = distinct !{!15, !16, !17}
!16 = !{!"llvm.loop.mustprogress"}
!17 = !{!"llvm.loop.peeled.count", i32 1}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopFullUnrollPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,ReassociatePass,SCCPPass,SROAPass,SimplifyCFGPass,TailCallElimPass