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

; 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_ctrtri(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 %147

79:                                               ; preds = %70
  %80 = load ptr, ptr %9, align 8, !tbaa !5
  %81 = load i32, ptr %80, align 4, !tbaa !9
  %82 = icmp eq i32 %81, 0
  br i1 %82, label %83, label %84

83:                                               ; preds = %79
  store i32 1, ptr %18, align 4
  br label %147

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

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

98:                                               ; preds = %134, %97
  %99 = load i32, ptr %21, align 4, !tbaa !9
  %100 = load ptr, ptr %9, align 8, !tbaa !5
  %101 = load i32, ptr %100, align 4, !tbaa !9
  %102 = icmp slt i32 %99, %101
  br i1 %102, label %103, label %137

103:                                              ; preds = %98
  %104 = load ptr, ptr %10, align 8, !tbaa !5
  %105 = load i32, ptr %21, align 4, !tbaa !9
  %106 = load ptr, ptr %11, align 8, !tbaa !5
  %107 = load i32, ptr %106, align 4, !tbaa !9
  %108 = load i32, ptr %21, align 4, !tbaa !9
  %109 = mul nsw i32 %107, %108
  %110 = add nsw i32 %105, %109
  %111 = mul nsw i32 2, %110
  %112 = sext i32 %111 to i64
  %113 = getelementptr inbounds float, ptr %104, i64 %112
  %114 = load float, ptr %113, align 4, !tbaa !12
  %115 = fcmp oeq float %114, 0.000000e+00
  br i1 %115, label %116, label %133

116:                                              ; preds = %103
  %117 = load ptr, ptr %10, align 8, !tbaa !5
  %118 = load i32, ptr %21, align 4, !tbaa !9
  %119 = load ptr, ptr %11, align 8, !tbaa !5
  %120 = load i32, ptr %119, align 4, !tbaa !9
  %121 = load i32, ptr %21, align 4, !tbaa !9
  %122 = mul nsw i32 %120, %121
  %123 = add nsw i32 %118, %122
  %124 = mul nsw i32 2, %123
  %125 = add nsw i32 %124, 1
  %126 = sext i32 %125 to i64
  %127 = getelementptr inbounds float, ptr %117, i64 %126
  %128 = load float, ptr %127, align 4, !tbaa !12
  %129 = fcmp oeq float %128, 0.000000e+00
  br i1 %129, label %130, label %133

130:                                              ; preds = %116
  %131 = load i32, ptr %21, align 4, !tbaa !9
  %132 = load ptr, ptr %12, align 8, !tbaa !5
  store i32 %131, ptr %132, align 4, !tbaa !9
  store i32 1, ptr %18, align 4
  br label %138

133:                                              ; preds = %116, %103
  br label %134

134:                                              ; preds = %133
  %135 = load i32, ptr %21, align 4, !tbaa !9
  %136 = add nsw i32 %135, 1
  store i32 %136, ptr %21, align 4, !tbaa !9
  br label %98, !llvm.loop !14

137:                                              ; preds = %98
  store i32 0, ptr %18, align 4
  br label %138

138:                                              ; preds = %137, %130
  call void @llvm.lifetime.end.p0(i64 4, ptr %21) #3
  %139 = load i32, ptr %18, align 4
  switch i32 %139, label %146 [
    i32 0, label %140
  ]

140:                                              ; preds = %138
  br label %141

141:                                              ; preds = %140, %84
  %142 = load ptr, ptr %9, align 8, !tbaa !5
  %143 = load ptr, ptr %10, align 8, !tbaa !5
  %144 = load ptr, ptr %11, align 8, !tbaa !5
  %145 = load ptr, ptr %12, align 8, !tbaa !5
  call void @RELAPACK_ctrtri_rec(ptr noundef %19, ptr noundef %20, ptr noundef %142, ptr noundef %143, ptr noundef %144, ptr noundef %145)
  store i32 0, ptr %18, align 4
  br label %146

146:                                              ; preds = %141, %138
  call void @llvm.lifetime.end.p0(i64 1, ptr %20) #3
  call void @llvm.lifetime.end.p0(i64 1, ptr %19) #3
  br label %147

147:                                              ; preds = %146, %83, %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
  %148 = load i32, ptr %18, align 4
  switch i32 %148, label %150 [
    i32 0, label %149
    i32 1, label %149
  ]

149:                                              ; preds = %147, %147
  ret void

150:                                              ; preds = %147
  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_ctrtri_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 = !{!"float", !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_ctrtri(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 %47

26:                                               ; preds = %22
  %27 = icmp eq i32 %20, 0
  br i1 %27, label %47, label %28

28:                                               ; preds = %26
  call void @llvm.lifetime.start.p0(i64 1, ptr nonnull %8) #4
  %29 = select i1 %14, i8 76, i8 85
  store i8 %29, ptr %8, align 1, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 1, ptr nonnull %9) #4
  %30 = select i1 %17, i8 78, i8 85
  store i8 %30, ptr %9, align 1, !tbaa !9
  br i1 %17, label %.lr.ph, label %.critedge

.lr.ph:                                           ; preds = %28
  %31 = shl nuw i32 %23, 1
  %factor.op.mul = add i32 %31, 2
  %wide.trip.count = zext nneg i32 %20 to i64
  br label %32

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

38:                                               ; preds = %32
  %39 = or disjoint i32 %.reass, 1
  %40 = sext i32 %39 to i64
  %41 = getelementptr inbounds float, ptr %3, i64 %40
  %42 = load float, ptr %41, align 4, !tbaa !10
  %43 = fcmp oeq float %42, 0.000000e+00
  br i1 %43, label %44, label %45

44:                                               ; preds = %38
  store i32 %33, ptr %5, align 4, !tbaa !5
  br label %46

45:                                               ; preds = %32, %38
  %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 %32, !llvm.loop !12

.critedge:                                        ; preds = %45, %28
  call void @RELAPACK_ctrtri_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 %46

46:                                               ; preds = %44, %.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 %47

47:                                               ; preds = %26, %46, %.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_ctrtri_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 = !{!"float", !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