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

; 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.complex = type { float, float }

@.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 [7 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local i32 @cpbsv_(ptr noundef %0, ptr noundef %1, ptr noundef %2, ptr noundef %3, ptr noundef %4, ptr noundef %5, ptr noundef %6, ptr noundef %7, ptr noundef %8) #0 {
  %10 = alloca i32, align 4
  %11 = alloca ptr, align 8
  %12 = alloca ptr, align 8
  %13 = alloca ptr, align 8
  %14 = alloca ptr, align 8
  %15 = alloca ptr, align 8
  %16 = alloca ptr, align 8
  %17 = alloca ptr, align 8
  %18 = alloca ptr, align 8
  %19 = alloca ptr, align 8
  %20 = alloca i64, align 8
  %21 = alloca i64, align 8
  %22 = alloca i64, align 8
  %23 = alloca i64, align 8
  %24 = alloca i64, align 8
  %25 = alloca i32, align 4
  store ptr %0, ptr %11, align 8, !tbaa !5
  store ptr %1, ptr %12, align 8, !tbaa !5
  store ptr %2, ptr %13, align 8, !tbaa !5
  store ptr %3, ptr %14, align 8, !tbaa !5
  store ptr %4, ptr %15, align 8, !tbaa !5
  store ptr %5, ptr %16, align 8, !tbaa !5
  store ptr %6, ptr %17, align 8, !tbaa !5
  store ptr %7, ptr %18, align 8, !tbaa !5
  store ptr %8, ptr %19, align 8, !tbaa !5
  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
  call void @llvm.lifetime.start.p0(i64 8, ptr %24) #3
  %26 = load ptr, ptr %16, align 8, !tbaa !5
  %27 = load i64, ptr %26, align 8, !tbaa !9
  store i64 %27, ptr %20, align 8, !tbaa !9
  %28 = load i64, ptr %20, align 8, !tbaa !9
  %29 = add nsw i64 1, %28
  store i64 %29, ptr %21, align 8, !tbaa !9
  %30 = load i64, ptr %21, align 8, !tbaa !9
  %31 = load ptr, ptr %15, align 8, !tbaa !5
  %32 = sub i64 0, %30
  %33 = getelementptr inbounds %struct.complex, ptr %31, i64 %32
  store ptr %33, ptr %15, align 8, !tbaa !5
  %34 = load ptr, ptr %18, align 8, !tbaa !5
  %35 = load i64, ptr %34, align 8, !tbaa !9
  store i64 %35, ptr %22, align 8, !tbaa !9
  %36 = load i64, ptr %22, align 8, !tbaa !9
  %37 = add nsw i64 1, %36
  store i64 %37, ptr %23, align 8, !tbaa !9
  %38 = load i64, ptr %23, align 8, !tbaa !9
  %39 = load ptr, ptr %17, align 8, !tbaa !5
  %40 = sub i64 0, %38
  %41 = getelementptr inbounds %struct.complex, ptr %39, i64 %40
  store ptr %41, ptr %17, align 8, !tbaa !5
  %42 = load ptr, ptr %19, align 8, !tbaa !5
  store i64 0, ptr %42, align 8, !tbaa !9
  %43 = load ptr, ptr %11, align 8, !tbaa !5
  %44 = call i64 @lsame_(ptr noundef %43, ptr noundef @.str)
  %45 = icmp ne i64 %44, 0
  br i1 %45, label %52, label %46

46:                                               ; preds = %9
  %47 = load ptr, ptr %11, align 8, !tbaa !5
  %48 = call i64 @lsame_(ptr noundef %47, ptr noundef @.str.1)
  %49 = icmp ne i64 %48, 0
  br i1 %49, label %52, label %50

50:                                               ; preds = %46
  %51 = load ptr, ptr %19, align 8, !tbaa !5
  store i64 -1, ptr %51, align 8, !tbaa !9
  br label %99

52:                                               ; preds = %46, %9
  %53 = load ptr, ptr %12, align 8, !tbaa !5
  %54 = load i64, ptr %53, align 8, !tbaa !9
  %55 = icmp slt i64 %54, 0
  br i1 %55, label %56, label %58

56:                                               ; preds = %52
  %57 = load ptr, ptr %19, align 8, !tbaa !5
  store i64 -2, ptr %57, align 8, !tbaa !9
  br label %98

58:                                               ; preds = %52
  %59 = load ptr, ptr %13, align 8, !tbaa !5
  %60 = load i64, ptr %59, align 8, !tbaa !9
  %61 = icmp slt i64 %60, 0
  br i1 %61, label %62, label %64

62:                                               ; preds = %58
  %63 = load ptr, ptr %19, align 8, !tbaa !5
  store i64 -3, ptr %63, align 8, !tbaa !9
  br label %97

64:                                               ; preds = %58
  %65 = load ptr, ptr %14, align 8, !tbaa !5
  %66 = load i64, ptr %65, align 8, !tbaa !9
  %67 = icmp slt i64 %66, 0
  br i1 %67, label %68, label %70

68:                                               ; preds = %64
  %69 = load ptr, ptr %19, align 8, !tbaa !5
  store i64 -4, ptr %69, align 8, !tbaa !9
  br label %96

70:                                               ; preds = %64
  %71 = load ptr, ptr %16, align 8, !tbaa !5
  %72 = load i64, ptr %71, align 8, !tbaa !9
  %73 = load ptr, ptr %13, align 8, !tbaa !5
  %74 = load i64, ptr %73, align 8, !tbaa !9
  %75 = add nsw i64 %74, 1
  %76 = icmp slt i64 %72, %75
  br i1 %76, label %77, label %79

77:                                               ; preds = %70
  %78 = load ptr, ptr %19, align 8, !tbaa !5
  store i64 -6, ptr %78, align 8, !tbaa !9
  br label %95

79:                                               ; preds = %70
  %80 = load ptr, ptr %18, align 8, !tbaa !5
  %81 = load i64, ptr %80, align 8, !tbaa !9
  %82 = load ptr, ptr %12, align 8, !tbaa !5
  %83 = load i64, ptr %82, align 8, !tbaa !9
  %84 = icmp sge i64 1, %83
  br i1 %84, label %85, label %86

85:                                               ; preds = %79
  br label %89

86:                                               ; preds = %79
  %87 = load ptr, ptr %12, align 8, !tbaa !5
  %88 = load i64, ptr %87, align 8, !tbaa !9
  br label %89

89:                                               ; preds = %86, %85
  %90 = phi i64 [ 1, %85 ], [ %88, %86 ]
  %91 = icmp slt i64 %81, %90
  br i1 %91, label %92, label %94

92:                                               ; preds = %89
  %93 = load ptr, ptr %19, align 8, !tbaa !5
  store i64 -8, ptr %93, align 8, !tbaa !9
  br label %94

94:                                               ; preds = %92, %89
  br label %95

95:                                               ; preds = %94, %77
  br label %96

96:                                               ; preds = %95, %68
  br label %97

97:                                               ; preds = %96, %62
  br label %98

98:                                               ; preds = %97, %56
  br label %99

99:                                               ; preds = %98, %50
  %100 = load ptr, ptr %19, align 8, !tbaa !5
  %101 = load i64, ptr %100, align 8, !tbaa !9
  %102 = icmp ne i64 %101, 0
  br i1 %102, label %103, label %108

103:                                              ; preds = %99
  %104 = load ptr, ptr %19, align 8, !tbaa !5
  %105 = load i64, ptr %104, align 8, !tbaa !9
  %106 = sub nsw i64 0, %105
  store i64 %106, ptr %24, align 8, !tbaa !9
  %107 = call i32 @xerbla_(ptr noundef @.str.2, ptr noundef %24)
  store i32 0, ptr %10, align 4
  store i32 1, ptr %25, align 4
  br label %137

108:                                              ; preds = %99
  %109 = load ptr, ptr %11, align 8, !tbaa !5
  %110 = load ptr, ptr %12, align 8, !tbaa !5
  %111 = load ptr, ptr %13, align 8, !tbaa !5
  %112 = load ptr, ptr %15, align 8, !tbaa !5
  %113 = load i64, ptr %21, align 8, !tbaa !9
  %114 = getelementptr inbounds %struct.complex, ptr %112, i64 %113
  %115 = load ptr, ptr %16, align 8, !tbaa !5
  %116 = load ptr, ptr %19, align 8, !tbaa !5
  %117 = call i32 @cpbtrf_(ptr noundef %109, ptr noundef %110, ptr noundef %111, ptr noundef %114, ptr noundef %115, ptr noundef %116)
  %118 = load ptr, ptr %19, align 8, !tbaa !5
  %119 = load i64, ptr %118, align 8, !tbaa !9
  %120 = icmp eq i64 %119, 0
  br i1 %120, label %121, label %136

121:                                              ; preds = %108
  %122 = load ptr, ptr %11, align 8, !tbaa !5
  %123 = load ptr, ptr %12, align 8, !tbaa !5
  %124 = load ptr, ptr %13, align 8, !tbaa !5
  %125 = load ptr, ptr %14, align 8, !tbaa !5
  %126 = load ptr, ptr %15, align 8, !tbaa !5
  %127 = load i64, ptr %21, align 8, !tbaa !9
  %128 = getelementptr inbounds %struct.complex, ptr %126, i64 %127
  %129 = load ptr, ptr %16, align 8, !tbaa !5
  %130 = load ptr, ptr %17, align 8, !tbaa !5
  %131 = load i64, ptr %23, align 8, !tbaa !9
  %132 = getelementptr inbounds %struct.complex, ptr %130, i64 %131
  %133 = load ptr, ptr %18, align 8, !tbaa !5
  %134 = load ptr, ptr %19, align 8, !tbaa !5
  %135 = call i32 @cpbtrs_(ptr noundef %122, ptr noundef %123, ptr noundef %124, ptr noundef %125, ptr noundef %128, ptr noundef %129, ptr noundef %132, ptr noundef %133, ptr noundef %134)
  br label %136

136:                                              ; preds = %121, %108
  store i32 0, ptr %10, align 4
  store i32 1, ptr %25, align 4
  br label %137

137:                                              ; preds = %136, %103
  call void @llvm.lifetime.end.p0(i64 8, ptr %24) #3
  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
  %138 = load i32, ptr %10, align 4
  ret i32 %138
}

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

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

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

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

declare i32 @cpbtrs_(ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef, 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}


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

; Function Attrs: nounwind uwtable
define dso_local noundef i32 @cpbsv_(ptr noundef %0, ptr noundef %1, ptr noundef %2, ptr noundef %3, ptr noundef %4, ptr noundef %5, ptr noundef %6, ptr noundef %7, ptr noundef %8) local_unnamed_addr #0 {
  %10 = alloca i64, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %10) #4
  store i64 0, ptr %8, align 8, !tbaa !5
  %11 = tail call i64 @lsame_(ptr noundef %0, ptr noundef nonnull @.str) #4
  %.not = icmp eq i64 %11, 0
  br i1 %.not, label %12, label %14

12:                                               ; preds = %9
  %13 = tail call i64 @lsame_(ptr noundef %0, ptr noundef nonnull @.str.1) #4
  %.not48 = icmp eq i64 %13, 0
  br i1 %.not48, label %.thread.sink.split, label %14

14:                                               ; preds = %12, %9
  %15 = load i64, ptr %1, align 8, !tbaa !5
  %16 = icmp slt i64 %15, 0
  br i1 %16, label %.thread.sink.split, label %17

17:                                               ; preds = %14
  %18 = load i64, ptr %2, align 8, !tbaa !5
  %19 = icmp slt i64 %18, 0
  br i1 %19, label %.thread.sink.split, label %20

20:                                               ; preds = %17
  %21 = load i64, ptr %3, align 8, !tbaa !5
  %22 = icmp slt i64 %21, 0
  br i1 %22, label %.thread.sink.split, label %23

23:                                               ; preds = %20
  %24 = load i64, ptr %5, align 8, !tbaa !5
  %.not49 = icmp sgt i64 %24, %18
  br i1 %.not49, label %25, label %.thread.sink.split

25:                                               ; preds = %23
  %26 = load i64, ptr %7, align 8, !tbaa !5
  %spec.select = tail call i64 @llvm.umax.i64(i64 %15, i64 1)
  %27 = icmp slt i64 %26, %spec.select
  br i1 %27, label %.thread.sink.split, label %28

28:                                               ; preds = %25
  %.pr = load i64, ptr %8, align 8, !tbaa !5
  %.not50 = icmp eq i64 %.pr, 0
  br i1 %.not50, label %32, label %.thread

.thread.sink.split:                               ; preds = %25, %23, %20, %17, %14, %12
  %.sink = phi i64 [ -1, %12 ], [ -2, %14 ], [ -3, %17 ], [ -4, %20 ], [ -6, %23 ], [ -8, %25 ]
  store i64 %.sink, ptr %8, align 8, !tbaa !5
  br label %.thread

.thread:                                          ; preds = %.thread.sink.split, %28
  %29 = phi i64 [ %.pr, %28 ], [ %.sink, %.thread.sink.split ]
  %30 = sub nsw i64 0, %29
  store i64 %30, ptr %10, align 8, !tbaa !5
  %31 = call i32 @xerbla_(ptr noundef nonnull @.str.2, ptr noundef nonnull %10) #4
  br label %38

32:                                               ; preds = %28
  %33 = tail call i32 @cpbtrf_(ptr noundef %0, ptr noundef nonnull %1, ptr noundef nonnull %2, ptr noundef %4, ptr noundef nonnull %5, ptr noundef nonnull %8) #4
  %34 = load i64, ptr %8, align 8, !tbaa !5
  %35 = icmp eq i64 %34, 0
  br i1 %35, label %36, label %38

36:                                               ; preds = %32
  %37 = tail call i32 @cpbtrs_(ptr noundef %0, ptr noundef nonnull %1, ptr noundef nonnull %2, ptr noundef nonnull %3, ptr noundef %4, ptr noundef nonnull %5, ptr noundef %6, ptr noundef nonnull %7, ptr noundef nonnull %8) #4
  br label %38

38:                                               ; preds = %32, %36, %.thread
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %10) #4
  ret i32 0
}

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

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

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

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

declare i32 @cpbtrs_(ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr 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: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i64 @llvm.umax.i64(i64, i64) #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 = !{!"long", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass