; LLVM IR from niuyishuai/PDCABB :: LAPACK_BLAS/LAPACK (dlag2s)

; 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 [2 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local i32 @dlag2s_(ptr noundef %0, ptr noundef %1, ptr noundef %2, ptr noundef %3, ptr noundef %4, ptr noundef %5, ptr noundef %6) #0 {
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca ptr, align 8
  %12 = alloca ptr, align 8
  %13 = alloca ptr, align 8
  %14 = alloca ptr, align 8
  %15 = alloca i64, align 8
  %16 = alloca i64, align 8
  %17 = alloca i64, align 8
  %18 = alloca i64, align 8
  %19 = alloca i64, align 8
  %20 = alloca i64, align 8
  %21 = alloca i64, align 8
  %22 = alloca i64, align 8
  %23 = alloca double, align 8
  store ptr %0, ptr %8, align 8, !tbaa !5
  store ptr %1, ptr %9, align 8, !tbaa !5
  store ptr %2, ptr %10, align 8, !tbaa !5
  store ptr %3, ptr %11, align 8, !tbaa !5
  store ptr %4, ptr %12, align 8, !tbaa !5
  store ptr %5, ptr %13, align 8, !tbaa !5
  store ptr %6, ptr %14, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %17) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %18) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %19) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %20) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %21) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %22) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %23) #3
  %24 = load ptr, ptr %11, align 8, !tbaa !5
  %25 = load i64, ptr %24, align 8, !tbaa !9
  store i64 %25, ptr %17, align 8, !tbaa !9
  %26 = load i64, ptr %17, align 8, !tbaa !9
  %27 = add nsw i64 1, %26
  store i64 %27, ptr %18, align 8, !tbaa !9
  %28 = load i64, ptr %18, align 8, !tbaa !9
  %29 = load ptr, ptr %10, align 8, !tbaa !5
  %30 = sub i64 0, %28
  %31 = getelementptr inbounds double, ptr %29, i64 %30
  store ptr %31, ptr %10, align 8, !tbaa !5
  %32 = load ptr, ptr %13, align 8, !tbaa !5
  %33 = load i64, ptr %32, align 8, !tbaa !9
  store i64 %33, ptr %15, align 8, !tbaa !9
  %34 = load i64, ptr %15, align 8, !tbaa !9
  %35 = add nsw i64 1, %34
  store i64 %35, ptr %16, align 8, !tbaa !9
  %36 = load i64, ptr %16, align 8, !tbaa !9
  %37 = load ptr, ptr %12, align 8, !tbaa !5
  %38 = sub i64 0, %36
  %39 = getelementptr inbounds float, ptr %37, i64 %38
  store ptr %39, ptr %12, align 8, !tbaa !5
  %40 = call double @slamch_(ptr noundef @.str)
  store double %40, ptr %23, align 8, !tbaa !11
  %41 = load ptr, ptr %9, align 8, !tbaa !5
  %42 = load i64, ptr %41, align 8, !tbaa !9
  store i64 %42, ptr %19, align 8, !tbaa !9
  store i64 1, ptr %22, align 8, !tbaa !9
  br label %43

43:                                               ; preds = %100, %7
  %44 = load i64, ptr %22, align 8, !tbaa !9
  %45 = load i64, ptr %19, align 8, !tbaa !9
  %46 = icmp sle i64 %44, %45
  br i1 %46, label %47, label %103

47:                                               ; preds = %43
  %48 = load ptr, ptr %8, align 8, !tbaa !5
  %49 = load i64, ptr %48, align 8, !tbaa !9
  store i64 %49, ptr %20, align 8, !tbaa !9
  store i64 1, ptr %21, align 8, !tbaa !9
  br label %50

50:                                               ; preds = %96, %47
  %51 = load i64, ptr %21, align 8, !tbaa !9
  %52 = load i64, ptr %20, align 8, !tbaa !9
  %53 = icmp sle i64 %51, %52
  br i1 %53, label %54, label %99

54:                                               ; preds = %50
  %55 = load ptr, ptr %10, align 8, !tbaa !5
  %56 = load i64, ptr %21, align 8, !tbaa !9
  %57 = load i64, ptr %22, align 8, !tbaa !9
  %58 = load i64, ptr %17, align 8, !tbaa !9
  %59 = mul nsw i64 %57, %58
  %60 = add nsw i64 %56, %59
  %61 = getelementptr inbounds double, ptr %55, i64 %60
  %62 = load double, ptr %61, align 8, !tbaa !11
  %63 = load double, ptr %23, align 8, !tbaa !11
  %64 = fneg double %63
  %65 = fcmp olt double %62, %64
  br i1 %65, label %77, label %66

66:                                               ; preds = %54
  %67 = load ptr, ptr %10, align 8, !tbaa !5
  %68 = load i64, ptr %21, align 8, !tbaa !9
  %69 = load i64, ptr %22, align 8, !tbaa !9
  %70 = load i64, ptr %17, align 8, !tbaa !9
  %71 = mul nsw i64 %69, %70
  %72 = add nsw i64 %68, %71
  %73 = getelementptr inbounds double, ptr %67, i64 %72
  %74 = load double, ptr %73, align 8, !tbaa !11
  %75 = load double, ptr %23, align 8, !tbaa !11
  %76 = fcmp ogt double %74, %75
  br i1 %76, label %77, label %79

77:                                               ; preds = %66, %54
  %78 = load ptr, ptr %14, align 8, !tbaa !5
  store i64 1, ptr %78, align 8, !tbaa !9
  br label %105

79:                                               ; preds = %66
  %80 = load ptr, ptr %10, align 8, !tbaa !5
  %81 = load i64, ptr %21, align 8, !tbaa !9
  %82 = load i64, ptr %22, align 8, !tbaa !9
  %83 = load i64, ptr %17, align 8, !tbaa !9
  %84 = mul nsw i64 %82, %83
  %85 = add nsw i64 %81, %84
  %86 = getelementptr inbounds double, ptr %80, i64 %85
  %87 = load double, ptr %86, align 8, !tbaa !11
  %88 = fptrunc double %87 to float
  %89 = load ptr, ptr %12, align 8, !tbaa !5
  %90 = load i64, ptr %21, align 8, !tbaa !9
  %91 = load i64, ptr %22, align 8, !tbaa !9
  %92 = load i64, ptr %15, align 8, !tbaa !9
  %93 = mul nsw i64 %91, %92
  %94 = add nsw i64 %90, %93
  %95 = getelementptr inbounds float, ptr %89, i64 %94
  store float %88, ptr %95, align 4, !tbaa !13
  br label %96

96:                                               ; preds = %79
  %97 = load i64, ptr %21, align 8, !tbaa !9
  %98 = add nsw i64 %97, 1
  store i64 %98, ptr %21, align 8, !tbaa !9
  br label %50, !llvm.loop !15

99:                                               ; preds = %50
  br label %100

100:                                              ; preds = %99
  %101 = load i64, ptr %22, align 8, !tbaa !9
  %102 = add nsw i64 %101, 1
  store i64 %102, ptr %22, align 8, !tbaa !9
  br label %43, !llvm.loop !17

103:                                              ; preds = %43
  %104 = load ptr, ptr %14, align 8, !tbaa !5
  store i64 0, ptr %104, align 8, !tbaa !9
  br label %105

105:                                              ; preds = %103, %77
  call void @llvm.lifetime.end.p0(i64 8, ptr %23) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %22) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %21) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %20) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %19) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %18) #3
  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
  ret i32 0
}

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

declare double @slamch_(ptr noundef) #2

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

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

!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 = !{!"long", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"double", !7, i64 0}
!13 = !{!14, !14, i64 0}
!14 = !{!"float", !7, i64 0}
!15 = distinct !{!15, !16}
!16 = !{!"llvm.loop.mustprogress"}
!17 = distinct !{!17, !16}


; 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 [2 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local noundef i32 @dlag2s_(ptr nocapture noundef readonly %0, ptr nocapture noundef readonly %1, ptr nocapture noundef readonly %2, ptr nocapture noundef readonly %3, ptr nocapture noundef writeonly %4, ptr nocapture noundef readonly %5, ptr nocapture noundef writeonly %6) local_unnamed_addr #0 {
  %8 = load i64, ptr %3, align 8, !tbaa !5
  %9 = xor i64 %8, -1
  %10 = getelementptr inbounds double, ptr %2, i64 %9
  %11 = load i64, ptr %5, align 8, !tbaa !5
  %12 = xor i64 %11, -1
  %13 = getelementptr inbounds float, ptr %4, i64 %12
  %14 = tail call double @slamch_(ptr noundef nonnull @.str) #2
  %15 = load i64, ptr %1, align 8, !tbaa !5
  %.not43 = icmp slt i64 %15, 1
  br i1 %.not43, label %.loopexit, label %.lr.ph46

.lr.ph46:                                         ; preds = %7
  %16 = load i64, ptr %0, align 8, !tbaa !5
  %.not3739 = icmp slt i64 %16, 1
  %17 = fneg double %14
  br i1 %.not3739, label %.loopexit, label %.lr.ph

.lr.ph:                                           ; preds = %.lr.ph46, %._crit_edge
  %.044 = phi i64 [ %27, %._crit_edge ], [ 1, %.lr.ph46 ]
  %18 = mul nsw i64 %.044, %8
  %invariant.gep = getelementptr double, ptr %10, i64 %18
  %19 = mul nsw i64 %.044, %11
  %invariant.gep41 = getelementptr float, ptr %13, i64 %19
  br label %20

20:                                               ; preds = %.lr.ph, %24
  %.03540 = phi i64 [ 1, %.lr.ph ], [ %26, %24 ]
  %gep = getelementptr double, ptr %invariant.gep, i64 %.03540
  %21 = load double, ptr %gep, align 8, !tbaa !9
  %22 = fcmp olt double %21, %17
  %23 = fcmp ogt double %21, %14
  %or.cond = or i1 %22, %23
  br i1 %or.cond, label %.loopexit, label %24

24:                                               ; preds = %20
  %25 = fptrunc double %21 to float
  %gep42 = getelementptr float, ptr %invariant.gep41, i64 %.03540
  store float %25, ptr %gep42, align 4, !tbaa !11
  %26 = add nuw i64 %.03540, 1
  %exitcond.not = icmp eq i64 %.03540, %16
  br i1 %exitcond.not, label %._crit_edge, label %20, !llvm.loop !13

._crit_edge:                                      ; preds = %24
  %27 = add nuw i64 %.044, 1
  %exitcond49.not = icmp eq i64 %.044, %15
  br i1 %exitcond49.not, label %.loopexit, label %.lr.ph, !llvm.loop !15

.loopexit:                                        ; preds = %._crit_edge, %20, %.lr.ph46, %7
  %storemerge = phi i64 [ 0, %7 ], [ 0, %.lr.ph46 ], [ 1, %20 ], [ 0, %._crit_edge ]
  store i64 %storemerge, ptr %6, align 8, !tbaa !5
  ret i32 0
}

declare double @slamch_(ptr noundef) local_unnamed_addr #1

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 = { "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 = !{!"long", !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, !12, i64 0}
!12 = !{!"float", !7, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}
!15 = distinct !{!15, !14}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopRotatePass,LoopSimplifyCFGPass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass