; LLVM IR from OpenMathLib/OpenBLAS :: relapack/src (dtrtri)

; 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
@.str.1 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [7 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local void @RELAPACK_dtrtri(ptr noundef %0, ptr noundef %1, ptr noundef %2, ptr noundef %3, ptr noundef %4, ptr noundef %5) #0 {
  %7 = alloca ptr, align 8
  %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 i32, align 4
  %14 = alloca i32, align 4
  %15 = alloca i32, align 4
  %16 = alloca i32, align 4
  %17 = alloca i32, align 4
  %18 = alloca i32, align 4
  %19 = alloca i8, align 1
  %20 = alloca i8, align 1
  %21 = alloca i32, align 4
  store ptr %0, ptr %7, align 8, !tbaa !5
  store ptr %1, ptr %8, align 8, !tbaa !5
  store ptr %2, ptr %9, align 8, !tbaa !5
  store ptr %3, ptr %10, align 8, !tbaa !5
  store ptr %4, ptr %11, align 8, !tbaa !5
  store ptr %5, ptr %12, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #3
  %22 = load ptr, ptr %7, align 8, !tbaa !5
  %23 = call i32 @lsame_(ptr noundef %22, ptr noundef @.str)
  store i32 %23, ptr %13, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #3
  %24 = load ptr, ptr %7, align 8, !tbaa !5
  %25 = call i32 @lsame_(ptr noundef %24, ptr noundef @.str.1)
  store i32 %25, ptr %14, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #3
  %26 = load ptr, ptr %8, align 8, !tbaa !5
  %27 = call i32 @lsame_(ptr noundef %26, ptr noundef @.str.2)
  store i32 %27, ptr %15, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #3
  %28 = load ptr, ptr %8, align 8, !tbaa !5
  %29 = call i32 @lsame_(ptr noundef %28, ptr noundef @.str.1)
  store i32 %29, ptr %16, align 4, !tbaa !9
  %30 = load ptr, ptr %12, align 8, !tbaa !5
  store i32 0, ptr %30, align 4, !tbaa !9
  %31 = load i32, ptr %13, align 4, !tbaa !9
  %32 = icmp ne i32 %31, 0
  br i1 %32, label %38, label %33

33:                                               ; preds = %6
  %34 = load i32, ptr %14, align 4, !tbaa !9
  %35 = icmp ne i32 %34, 0
  br i1 %35, label %38, label %36

36:                                               ; preds = %33
  %37 = load ptr, ptr %12, align 8, !tbaa !5
  store i32 -1, ptr %37, align 4, !tbaa !9
  br label %70

38:                                               ; preds = %33, %6
  %39 = load i32, ptr %15, align 4, !tbaa !9
  %40 = icmp ne i32 %39, 0
  br i1 %40, label %46, label %41

41:                                               ; preds = %38
  %42 = load i32, ptr %16, align 4, !tbaa !9
  %43 = icmp ne i32 %42, 0
  br i1 %43, label %46, label %44

44:                                               ; preds = %41
  %45 = load ptr, ptr %12, align 8, !tbaa !5
  store i32 -2, ptr %45, align 4, !tbaa !9
  br label %69

46:                                               ; preds = %41, %38
  %47 = load ptr, ptr %9, align 8, !tbaa !5
  %48 = load i32, ptr %47, align 4, !tbaa !9
  %49 = icmp slt i32 %48, 0
  br i1 %49, label %50, label %52

50:                                               ; preds = %46
  %51 = load ptr, ptr %12, align 8, !tbaa !5
  store i32 -3, ptr %51, align 4, !tbaa !9
  br label %68

52:                                               ; preds = %46
  %53 = load ptr, ptr %11, align 8, !tbaa !5
  %54 = load i32, ptr %53, align 4, !tbaa !9
  %55 = load ptr, ptr %9, align 8, !tbaa !5
  %56 = load i32, ptr %55, align 4, !tbaa !9
  %57 = icmp sgt i32 1, %56
  br i1 %57, label %58, label %59

58:                                               ; preds = %52
  br label %62

59:                                               ; preds = %52
  %60 = load ptr, ptr %9, align 8, !tbaa !5
  %61 = load i32, ptr %60, align 4, !tbaa !9
  br label %62

62:                                               ; preds = %59, %58
  %63 = phi i32 [ 1, %58 ], [ %61, %59 ]
  %64 = icmp slt i32 %54, %63
  br i1 %64, label %65, label %67

65:                                               ; preds = %62
  %66 = load ptr, ptr %12, align 8, !tbaa !5
  store i32 -5, ptr %66, align 4, !tbaa !9
  br label %67

67:                                               ; preds = %65, %62
  br label %68

68:                                               ; preds = %67, %50
  br label %69

69:                                               ; preds = %68, %44
  br label %70

70:                                               ; preds = %69, %36
  %71 = load ptr, ptr %12, align 8, !tbaa !5
  %72 = load i32, ptr %71, align 4, !tbaa !9
  %73 = icmp ne i32 %72, 0
  br i1 %73, label %74, label %79

74:                                               ; preds = %70
  call void @llvm.lifetime.start.p0(i64 4, ptr %17) #3
  %75 = load ptr, ptr %12, align 8, !tbaa !5
  %76 = load i32, ptr %75, align 4, !tbaa !9
  %77 = sub nsw i32 0, %76
  store i32 %77, ptr %17, align 4, !tbaa !9
  %78 = call i32 @xerbla_(ptr noundef @.str.3, ptr noundef %17, i32 noundef 6)
  store i32 1, ptr %18, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #3
  br label %127

79:                                               ; preds = %70
  call void @llvm.lifetime.start.p0(i64 1, ptr %19) #3
  %80 = load i32, ptr %13, align 4, !tbaa !9
  %81 = icmp ne i32 %80, 0
  %82 = zext i1 %81 to i64
  %83 = select i1 %81, i32 76, i32 85
  %84 = trunc i32 %83 to i8
  store i8 %84, ptr %19, align 1, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 1, ptr %20) #3
  %85 = load i32, ptr %15, align 4, !tbaa !9
  %86 = icmp ne i32 %85, 0
  %87 = zext i1 %86 to i64
  %88 = select i1 %86, i32 78, i32 85
  %89 = trunc i32 %88 to i8
  store i8 %89, ptr %20, align 1, !tbaa !11
  %90 = load i32, ptr %15, align 4, !tbaa !9
  %91 = icmp ne i32 %90, 0
  br i1 %91, label %92, label %121

92:                                               ; preds = %79
  call void @llvm.lifetime.start.p0(i64 4, ptr %21) #3
  store i32 0, ptr %21, align 4, !tbaa !9
  br label %93

93:                                               ; preds = %114, %92
  %94 = load i32, ptr %21, align 4, !tbaa !9
  %95 = load ptr, ptr %9, align 8, !tbaa !5
  %96 = load i32, ptr %95, align 4, !tbaa !9
  %97 = icmp slt i32 %94, %96
  br i1 %97, label %98, label %117

98:                                               ; preds = %93
  %99 = load ptr, ptr %10, align 8, !tbaa !5
  %100 = load i32, ptr %21, align 4, !tbaa !9
  %101 = load ptr, ptr %11, align 8, !tbaa !5
  %102 = load i32, ptr %101, align 4, !tbaa !9
  %103 = load i32, ptr %21, align 4, !tbaa !9
  %104 = mul nsw i32 %102, %103
  %105 = add nsw i32 %100, %104
  %106 = sext i32 %105 to i64
  %107 = getelementptr inbounds double, ptr %99, i64 %106
  %108 = load double, ptr %107, align 8, !tbaa !12
  %109 = fcmp oeq double %108, 0.000000e+00
  br i1 %109, label %110, label %113

110:                                              ; preds = %98
  %111 = load i32, ptr %21, align 4, !tbaa !9
  %112 = load ptr, ptr %12, align 8, !tbaa !5
  store i32 %111, ptr %112, align 4, !tbaa !9
  store i32 1, ptr %18, align 4
  br label %118

113:                                              ; preds = %98
  br label %114

114:                                              ; preds = %113
  %115 = load i32, ptr %21, align 4, !tbaa !9
  %116 = add nsw i32 %115, 1
  store i32 %116, ptr %21, align 4, !tbaa !9
  br label %93, !llvm.loop !14

117:                                              ; preds = %93
  store i32 0, ptr %18, align 4
  br label %118

118:                                              ; preds = %117, %110
  call void @llvm.lifetime.end.p0(i64 4, ptr %21) #3
  %119 = load i32, ptr %18, align 4
  switch i32 %119, label %126 [
    i32 0, label %120
  ]

120:                                              ; preds = %118
  br label %121

121:                                              ; preds = %120, %79
  %122 = load ptr, ptr %9, align 8, !tbaa !5
  %123 = load ptr, ptr %10, align 8, !tbaa !5
  %124 = load ptr, ptr %11, align 8, !tbaa !5
  %125 = load ptr, ptr %12, align 8, !tbaa !5
  call void @RELAPACK_dtrtri_rec(ptr noundef %19, ptr noundef %20, ptr noundef %122, ptr noundef %123, ptr noundef %124, ptr noundef %125)
  store i32 0, ptr %18, align 4
  br label %126

126:                                              ; preds = %121, %118
  call void @llvm.lifetime.end.p0(i64 1, ptr %20) #3
  call void @llvm.lifetime.end.p0(i64 1, ptr %19) #3
  br label %127

127:                                              ; preds = %126, %74
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #3
  call void @llvm.lifetime.end.p0(i64 4, 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
  %128 = load i32, ptr %18, align 4
  switch i32 %128, label %130 [
    i32 0, label %129
    i32 1, label %129
  ]

129:                                              ; preds = %127, %127
  ret void

130:                                              ; preds = %127
  unreachable
}

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

declare i32 @lsame_(ptr noundef, ptr noundef) #2

declare i32 @xerbla_(ptr noundef, ptr noundef, i32 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 hidden void @RELAPACK_dtrtri_rec(ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef) #0

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 = !{!"int", !7, i64 0}
!11 = !{!7, !7, i64 0}
!12 = !{!13, !13, i64 0}
!13 = !{!"double", !7, i64 0}
!14 = distinct !{!14, !15}
!15 = !{!"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"

@.str = external hidden unnamed_addr constant [2 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [7 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local void @RELAPACK_dtrtri(ptr noundef %0, ptr noundef %1, ptr noundef %2, ptr noundef %3, ptr noundef %4, ptr noundef %5) local_unnamed_addr #0 {
  %7 = alloca i32, align 4
  %8 = alloca i8, align 1
  %9 = alloca i8, align 1
  %10 = tail call i32 @lsame_(ptr noundef %0, ptr noundef nonnull @.str) #4
  %11 = tail call i32 @lsame_(ptr noundef %0, ptr noundef nonnull @.str.1) #4
  %12 = tail call i32 @lsame_(ptr noundef %1, ptr noundef nonnull @.str.2) #4
  %13 = tail call i32 @lsame_(ptr noundef %1, ptr noundef nonnull @.str.1) #4
  store i32 0, ptr %5, align 4, !tbaa !5
  %14 = icmp ne i32 %10, 0
  %15 = icmp ne i32 %11, 0
  %or.cond = select i1 %14, i1 true, i1 %15
  br i1 %or.cond, label %16, label %.thread

16:                                               ; preds = %6
  %17 = icmp ne i32 %12, 0
  %18 = icmp ne i32 %13, 0
  %or.cond3 = select i1 %17, i1 true, i1 %18
  br i1 %or.cond3, label %19, label %.thread

19:                                               ; preds = %16
  %20 = load i32, ptr %2, align 4, !tbaa !5
  %21 = icmp slt i32 %20, 0
  br i1 %21, label %.thread, label %22

22:                                               ; preds = %19
  %23 = load i32, ptr %4, align 4, !tbaa !5
  %spec.select = tail call i32 @llvm.umax.i32(i32 %20, i32 1)
  %24 = icmp slt i32 %23, %spec.select
  br i1 %24, label %.thread, label %26

.thread:                                          ; preds = %22, %19, %16, %6
  %.sink = phi i32 [ -1, %6 ], [ -2, %16 ], [ -3, %19 ], [ -5, %22 ]
  %.neg = phi i32 [ 1, %6 ], [ 2, %16 ], [ 3, %19 ], [ 5, %22 ]
  store i32 %.sink, ptr %5, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %7) #4
  store i32 %.neg, ptr %7, align 4, !tbaa !5
  %25 = call i32 @xerbla_(ptr noundef nonnull @.str.3, ptr noundef nonnull %7, i32 noundef 6) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %7) #4
  br label %40

26:                                               ; preds = %22
  call void @llvm.lifetime.start.p0(i64 1, ptr nonnull %8) #4
  %27 = select i1 %14, i8 76, i8 85
  store i8 %27, ptr %8, align 1, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 1, ptr nonnull %9) #4
  %.not40 = icmp eq i32 %12, 0
  %28 = select i1 %.not40, i8 85, i8 78
  store i8 %28, ptr %9, align 1, !tbaa !9
  %.not4144.not = icmp eq i32 %20, 0
  %or.cond49 = or i1 %.not40, %.not4144.not
  br i1 %or.cond49, label %.critedge, label %.lr.ph

.lr.ph:                                           ; preds = %26
  %29 = add nuw i32 %23, 1
  %wide.trip.count = zext nneg i32 %20 to i64
  br label %30

30:                                               ; preds = %.lr.ph, %38
  %indvars.iv = phi i64 [ 0, %.lr.ph ], [ %indvars.iv.next, %38 ]
  %31 = trunc nuw nsw i64 %indvars.iv to i32
  %32 = mul i32 %29, %31
  %33 = sext i32 %32 to i64
  %34 = getelementptr inbounds double, ptr %3, i64 %33
  %35 = load double, ptr %34, align 8, !tbaa !10
  %36 = fcmp oeq double %35, 0.000000e+00
  br i1 %36, label %37, label %38

37:                                               ; preds = %30
  store i32 %31, ptr %5, align 4, !tbaa !5
  br label %39

38:                                               ; preds = %30
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, %wide.trip.count
  br i1 %exitcond.not, label %.critedge, label %30, !llvm.loop !12

.critedge:                                        ; preds = %38, %26
  call void @RELAPACK_dtrtri_rec(ptr noundef nonnull %8, ptr noundef nonnull %9, ptr noundef nonnull %2, ptr noundef %3, ptr noundef nonnull %4, ptr noundef nonnull %5)
  br label %39

39:                                               ; preds = %37, %.critedge
  call void @llvm.lifetime.end.p0(i64 1, ptr nonnull %9) #4
  call void @llvm.lifetime.end.p0(i64 1, ptr nonnull %8) #4
  br label %40

40:                                               ; preds = %39, %.thread
  ret void
}

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

declare i32 @lsame_(ptr noundef, ptr noundef) local_unnamed_addr #2

declare i32 @xerbla_(ptr noundef, ptr noundef, i32 noundef) local_unnamed_addr #2

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

; Function Attrs: nounwind uwtable
declare hidden void @RELAPACK_dtrtri_rec(ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #0

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.umax.i32(i32, i32) #3

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 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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #4 = { 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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!7, !7, i64 0}
!10 = !{!11, !11, i64 0}
!11 = !{!"double", !7, i64 0}
!12 = distinct !{!12, !13}
!13 = !{!"llvm.loop.mustprogress"}


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