; LLVM IR from Amoiensis/Optimization-Algorithm :: [Direct_Method]直接法/[Univariate_Search_Method]坐标轮换法 (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._Elementary_Transformation = type { i32, i32, double, ptr, ptr }

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

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

; Function Attrs: nounwind uwtable
declare dso_local ptr @M_I(i32 noundef) #1

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

; Function Attrs: nounwind uwtable
define dso_local ptr @Etrans_2_Matrix(ptr noundef %0, i32 noundef %1, i32 noundef %2) #1 {
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  store ptr %0, ptr %4, align 8, !tbaa !5
  store i32 %1, ptr %5, align 4, !tbaa !9
  store i32 %2, ptr %6, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #2
  %9 = load ptr, ptr %4, align 8, !tbaa !5
  store ptr %9, ptr %7, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #2
  %10 = load i32, ptr %5, align 4, !tbaa !9
  %11 = call ptr @M_I(i32 noundef %10)
  store ptr %11, ptr %8, align 8, !tbaa !5
  %12 = load ptr, ptr %4, align 8, !tbaa !5
  %13 = icmp ne ptr %12, null
  br i1 %13, label %14, label %49

14:                                               ; preds = %3
  br label %15

15:                                               ; preds = %20, %14
  %16 = load ptr, ptr %7, align 8, !tbaa !5
  %17 = getelementptr inbounds %struct._Elementary_Transformation, ptr %16, i32 0, i32 4
  %18 = load ptr, ptr %17, align 8, !tbaa !11
  %19 = icmp ne ptr %18, null
  br i1 %19, label %20, label %24

20:                                               ; preds = %15
  %21 = load ptr, ptr %7, align 8, !tbaa !5
  %22 = getelementptr inbounds %struct._Elementary_Transformation, ptr %21, i32 0, i32 4
  %23 = load ptr, ptr %22, align 8, !tbaa !11
  store ptr %23, ptr %7, align 8, !tbaa !5
  br label %15, !llvm.loop !14

24:                                               ; preds = %15
  br label %25

25:                                               ; preds = %45, %24
  %26 = load ptr, ptr %7, align 8, !tbaa !5
  %27 = getelementptr inbounds %struct._Elementary_Transformation, ptr %26, i32 0, i32 2
  %28 = load double, ptr %27, align 8, !tbaa !16
  %29 = fmul double -1.000000e+00, %28
  %30 = load ptr, ptr %7, align 8, !tbaa !5
  %31 = getelementptr inbounds %struct._Elementary_Transformation, ptr %30, i32 0, i32 2
  store double %29, ptr %31, align 8, !tbaa !16
  %32 = load ptr, ptr %8, align 8, !tbaa !5
  %33 = load ptr, ptr %7, align 8, !tbaa !5
  %34 = load i32, ptr %6, align 4, !tbaa !9
  %35 = call i32 @M_E_trans(ptr noundef %32, ptr noundef %33, i32 noundef %34)
  %36 = load ptr, ptr %7, align 8, !tbaa !5
  %37 = getelementptr inbounds %struct._Elementary_Transformation, ptr %36, i32 0, i32 2
  %38 = load double, ptr %37, align 8, !tbaa !16
  %39 = fmul double -1.000000e+00, %38
  %40 = load ptr, ptr %7, align 8, !tbaa !5
  %41 = getelementptr inbounds %struct._Elementary_Transformation, ptr %40, i32 0, i32 2
  store double %39, ptr %41, align 8, !tbaa !16
  %42 = load ptr, ptr %7, align 8, !tbaa !5
  %43 = getelementptr inbounds %struct._Elementary_Transformation, ptr %42, i32 0, i32 3
  %44 = load ptr, ptr %43, align 8, !tbaa !17
  store ptr %44, ptr %7, align 8, !tbaa !5
  br label %45

45:                                               ; preds = %25
  %46 = load ptr, ptr %7, align 8, !tbaa !5
  %47 = icmp ne ptr %46, null
  br i1 %47, label %25, label %48, !llvm.loop !18

48:                                               ; preds = %45
  br label %49

49:                                               ; preds = %48, %3
  %50 = load ptr, ptr %8, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #2
  ret ptr %50
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #2 = { 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/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !6, i64 24}
!12 = !{!"_Elementary_Transformation", !10, i64 0, !10, i64 4, !13, i64 8, !6, i64 16, !6, i64 24}
!13 = !{!"double", !7, i64 0}
!14 = distinct !{!14, !15}
!15 = !{!"llvm.loop.mustprogress"}
!16 = !{!12, !13, i64 8}
!17 = !{!12, !6, i64 16}
!18 = distinct !{!18, !15}


; 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 @M_I(i32 noundef) local_unnamed_addr #0

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

; Function Attrs: nounwind uwtable
define dso_local ptr @Etrans_2_Matrix(ptr noundef %0, i32 noundef %1, i32 noundef %2) local_unnamed_addr #0 {
  %4 = tail call ptr @M_I(i32 noundef %1)
  %.not = icmp eq ptr %0, null
  br i1 %.not, label %.loopexit, label %.preheader18

.preheader18:                                     ; preds = %3, %.preheader18
  %.0 = phi ptr [ %6, %.preheader18 ], [ %0, %3 ]
  %5 = getelementptr inbounds i8, ptr %.0, i64 24
  %6 = load ptr, ptr %5, align 8, !tbaa !5
  %.not16 = icmp eq ptr %6, null
  br i1 %.not16, label %.preheader, label %.preheader18, !llvm.loop !12

.preheader:                                       ; preds = %.preheader18, %.preheader
  %.1 = phi ptr [ %14, %.preheader ], [ %.0, %.preheader18 ]
  %7 = getelementptr inbounds i8, ptr %.1, i64 8
  %8 = load double, ptr %7, align 8, !tbaa !14
  %9 = fneg double %8
  store double %9, ptr %7, align 8, !tbaa !14
  %10 = tail call i32 @M_E_trans(ptr noundef %4, ptr noundef nonnull %.1, i32 noundef %2)
  %11 = load double, ptr %7, align 8, !tbaa !14
  %12 = fneg double %11
  store double %12, ptr %7, align 8, !tbaa !14
  %13 = getelementptr inbounds i8, ptr %.1, i64 16
  %14 = load ptr, ptr %13, align 8, !tbaa !15
  %.not17 = icmp eq ptr %14, null
  br i1 %.not17, label %.loopexit, label %.preheader, !llvm.loop !16

.loopexit:                                        ; preds = %.preheader, %3
  ret ptr %4
}

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

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


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LoopSimplifyPass,LoopUnrollPass,SROAPass,SimplifyCFGPass,TailCallElimPass