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

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

; Function Attrs: nounwind uwtable
define dso_local i32 @cptsv_(ptr noundef %0, ptr noundef %1, ptr noundef %2, ptr noundef %3, ptr noundef %4, ptr noundef %5, ptr noundef %6) #0 {
  %8 = alloca i32, align 4
  %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 ptr, align 8
  %16 = alloca i64, align 8
  %17 = alloca i64, align 8
  %18 = alloca i64, align 8
  %19 = alloca i32, align 4
  store ptr %0, ptr %9, align 8, !tbaa !5
  store ptr %1, ptr %10, align 8, !tbaa !5
  store ptr %2, ptr %11, align 8, !tbaa !5
  store ptr %3, ptr %12, align 8, !tbaa !5
  store ptr %4, ptr %13, align 8, !tbaa !5
  store ptr %5, ptr %14, align 8, !tbaa !5
  store ptr %6, ptr %15, align 8, !tbaa !5
  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
  %20 = load ptr, ptr %11, align 8, !tbaa !5
  %21 = getelementptr inbounds float, ptr %20, i32 -1
  store ptr %21, ptr %11, align 8, !tbaa !5
  %22 = load ptr, ptr %12, align 8, !tbaa !5
  %23 = getelementptr inbounds %struct.complex, ptr %22, i32 -1
  store ptr %23, ptr %12, align 8, !tbaa !5
  %24 = load ptr, ptr %14, align 8, !tbaa !5
  %25 = load i64, ptr %24, align 8, !tbaa !9
  store i64 %25, ptr %16, align 8, !tbaa !9
  %26 = load i64, ptr %16, align 8, !tbaa !9
  %27 = add nsw i64 1, %26
  store i64 %27, ptr %17, align 8, !tbaa !9
  %28 = load i64, ptr %17, align 8, !tbaa !9
  %29 = load ptr, ptr %13, align 8, !tbaa !5
  %30 = sub i64 0, %28
  %31 = getelementptr inbounds %struct.complex, ptr %29, i64 %30
  store ptr %31, ptr %13, align 8, !tbaa !5
  %32 = load ptr, ptr %15, align 8, !tbaa !5
  store i64 0, ptr %32, align 8, !tbaa !9
  %33 = load ptr, ptr %9, align 8, !tbaa !5
  %34 = load i64, ptr %33, align 8, !tbaa !9
  %35 = icmp slt i64 %34, 0
  br i1 %35, label %36, label %38

36:                                               ; preds = %7
  %37 = load ptr, ptr %15, align 8, !tbaa !5
  store i64 -1, ptr %37, align 8, !tbaa !9
  br label %61

38:                                               ; preds = %7
  %39 = load ptr, ptr %10, align 8, !tbaa !5
  %40 = load i64, ptr %39, align 8, !tbaa !9
  %41 = icmp slt i64 %40, 0
  br i1 %41, label %42, label %44

42:                                               ; preds = %38
  %43 = load ptr, ptr %15, align 8, !tbaa !5
  store i64 -2, ptr %43, align 8, !tbaa !9
  br label %60

44:                                               ; preds = %38
  %45 = load ptr, ptr %14, align 8, !tbaa !5
  %46 = load i64, ptr %45, align 8, !tbaa !9
  %47 = load ptr, ptr %9, align 8, !tbaa !5
  %48 = load i64, ptr %47, align 8, !tbaa !9
  %49 = icmp sge i64 1, %48
  br i1 %49, label %50, label %51

50:                                               ; preds = %44
  br label %54

51:                                               ; preds = %44
  %52 = load ptr, ptr %9, align 8, !tbaa !5
  %53 = load i64, ptr %52, align 8, !tbaa !9
  br label %54

54:                                               ; preds = %51, %50
  %55 = phi i64 [ 1, %50 ], [ %53, %51 ]
  %56 = icmp slt i64 %46, %55
  br i1 %56, label %57, label %59

57:                                               ; preds = %54
  %58 = load ptr, ptr %15, align 8, !tbaa !5
  store i64 -6, ptr %58, align 8, !tbaa !9
  br label %59

59:                                               ; preds = %57, %54
  br label %60

60:                                               ; preds = %59, %42
  br label %61

61:                                               ; preds = %60, %36
  %62 = load ptr, ptr %15, align 8, !tbaa !5
  %63 = load i64, ptr %62, align 8, !tbaa !9
  %64 = icmp ne i64 %63, 0
  br i1 %64, label %65, label %70

65:                                               ; preds = %61
  %66 = load ptr, ptr %15, align 8, !tbaa !5
  %67 = load i64, ptr %66, align 8, !tbaa !9
  %68 = sub nsw i64 0, %67
  store i64 %68, ptr %18, align 8, !tbaa !9
  %69 = call i32 @xerbla_(ptr noundef @.str, ptr noundef %18)
  store i32 0, ptr %8, align 4
  store i32 1, ptr %19, align 4
  br label %95

70:                                               ; preds = %61
  %71 = load ptr, ptr %9, align 8, !tbaa !5
  %72 = load ptr, ptr %11, align 8, !tbaa !5
  %73 = getelementptr inbounds float, ptr %72, i64 1
  %74 = load ptr, ptr %12, align 8, !tbaa !5
  %75 = getelementptr inbounds %struct.complex, ptr %74, i64 1
  %76 = load ptr, ptr %15, align 8, !tbaa !5
  %77 = call i32 @cpttrf_(ptr noundef %71, ptr noundef %73, ptr noundef %75, ptr noundef %76)
  %78 = load ptr, ptr %15, align 8, !tbaa !5
  %79 = load i64, ptr %78, align 8, !tbaa !9
  %80 = icmp eq i64 %79, 0
  br i1 %80, label %81, label %94

81:                                               ; preds = %70
  %82 = load ptr, ptr %9, align 8, !tbaa !5
  %83 = load ptr, ptr %10, align 8, !tbaa !5
  %84 = load ptr, ptr %11, align 8, !tbaa !5
  %85 = getelementptr inbounds float, ptr %84, i64 1
  %86 = load ptr, ptr %12, align 8, !tbaa !5
  %87 = getelementptr inbounds %struct.complex, ptr %86, i64 1
  %88 = load ptr, ptr %13, align 8, !tbaa !5
  %89 = load i64, ptr %17, align 8, !tbaa !9
  %90 = getelementptr inbounds %struct.complex, ptr %88, i64 %89
  %91 = load ptr, ptr %14, align 8, !tbaa !5
  %92 = load ptr, ptr %15, align 8, !tbaa !5
  %93 = call i32 @cpttrs_(ptr noundef @.str.1, ptr noundef %82, ptr noundef %83, ptr noundef %85, ptr noundef %87, ptr noundef %90, ptr noundef %91, ptr noundef %92)
  br label %94

94:                                               ; preds = %81, %70
  store i32 0, ptr %8, align 4
  store i32 1, ptr %19, align 4
  br label %95

95:                                               ; preds = %94, %65
  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
  %96 = load i32, ptr %8, align 4
  ret i32 %96
}

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

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

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

declare i32 @cpttrs_(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 [7 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [6 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local noundef i32 @cptsv_(ptr noundef %0, ptr noundef %1, ptr noundef %2, ptr noundef %3, ptr noundef %4, ptr noundef %5, ptr noundef %6) local_unnamed_addr #0 {
  %8 = alloca i64, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %8) #4
  store i64 0, ptr %6, align 8, !tbaa !5
  %9 = load i64, ptr %0, align 8, !tbaa !5
  %10 = icmp slt i64 %9, 0
  br i1 %10, label %.thread, label %11

11:                                               ; preds = %7
  %12 = load i64, ptr %1, align 8, !tbaa !5
  %13 = icmp slt i64 %12, 0
  br i1 %13, label %.thread, label %14

14:                                               ; preds = %11
  %15 = load i64, ptr %5, align 8, !tbaa !5
  %spec.select = tail call i64 @llvm.umax.i64(i64 %9, i64 1)
  %16 = icmp slt i64 %15, %spec.select
  br i1 %16, label %.thread, label %18

.thread:                                          ; preds = %14, %11, %7
  %.sink = phi i64 [ -1, %7 ], [ -2, %11 ], [ -6, %14 ]
  %.neg = phi i64 [ 1, %7 ], [ 2, %11 ], [ 6, %14 ]
  store i64 %.sink, ptr %6, align 8, !tbaa !5
  store i64 %.neg, ptr %8, align 8, !tbaa !5
  %17 = call i32 @xerbla_(ptr noundef nonnull @.str, ptr noundef nonnull %8) #4
  br label %24

18:                                               ; preds = %14
  %19 = tail call i32 @cpttrf_(ptr noundef nonnull %0, ptr noundef %2, ptr noundef %3, ptr noundef nonnull %6) #4
  %20 = load i64, ptr %6, align 8, !tbaa !5
  %21 = icmp eq i64 %20, 0
  br i1 %21, label %22, label %24

22:                                               ; preds = %18
  %23 = tail call i32 @cpttrs_(ptr noundef nonnull @.str.1, ptr noundef nonnull %0, ptr noundef nonnull %1, ptr noundef %2, ptr noundef %3, ptr noundef %4, ptr noundef nonnull %5, ptr noundef nonnull %6) #4
  br label %24

24:                                               ; preds = %18, %22, %.thread
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %8) #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 i32 @xerbla_(ptr noundef, ptr noundef) local_unnamed_addr #2

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

declare i32 @cpttrs_(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,GVNPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,PostOrderFunctionAttrsPass,SCCPPass,SROAPass,SimplifyCFGPass,TailCallElimPass