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

; 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 @cppsv_(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 %12, align 8, !tbaa !5
  %21 = getelementptr inbounds %struct.complex, ptr %20, i32 -1
  store ptr %21, ptr %12, align 8, !tbaa !5
  %22 = load ptr, ptr %14, align 8, !tbaa !5
  %23 = load i64, ptr %22, align 8, !tbaa !9
  store i64 %23, ptr %16, align 8, !tbaa !9
  %24 = load i64, ptr %16, align 8, !tbaa !9
  %25 = add nsw i64 1, %24
  store i64 %25, ptr %17, align 8, !tbaa !9
  %26 = load i64, ptr %17, align 8, !tbaa !9
  %27 = load ptr, ptr %13, align 8, !tbaa !5
  %28 = sub i64 0, %26
  %29 = getelementptr inbounds %struct.complex, ptr %27, i64 %28
  store ptr %29, ptr %13, align 8, !tbaa !5
  %30 = load ptr, ptr %15, align 8, !tbaa !5
  store i64 0, ptr %30, align 8, !tbaa !9
  %31 = load ptr, ptr %9, align 8, !tbaa !5
  %32 = call i64 @lsame_(ptr noundef %31, ptr noundef @.str)
  %33 = icmp ne i64 %32, 0
  br i1 %33, label %40, label %34

34:                                               ; preds = %7
  %35 = load ptr, ptr %9, align 8, !tbaa !5
  %36 = call i64 @lsame_(ptr noundef %35, ptr noundef @.str.1)
  %37 = icmp ne i64 %36, 0
  br i1 %37, label %40, label %38

38:                                               ; preds = %34
  %39 = load ptr, ptr %15, align 8, !tbaa !5
  store i64 -1, ptr %39, align 8, !tbaa !9
  br label %70

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

44:                                               ; preds = %40
  %45 = load ptr, ptr %15, align 8, !tbaa !5
  store i64 -2, ptr %45, align 8, !tbaa !9
  br label %69

46:                                               ; preds = %40
  %47 = load ptr, ptr %11, align 8, !tbaa !5
  %48 = load i64, ptr %47, align 8, !tbaa !9
  %49 = icmp slt i64 %48, 0
  br i1 %49, label %50, label %52

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

52:                                               ; preds = %46
  %53 = load ptr, ptr %14, align 8, !tbaa !5
  %54 = load i64, ptr %53, align 8, !tbaa !9
  %55 = load ptr, ptr %10, align 8, !tbaa !5
  %56 = load i64, ptr %55, align 8, !tbaa !9
  %57 = icmp sge i64 1, %56
  br i1 %57, label %58, label %59

58:                                               ; preds = %52
  br label %62

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

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

65:                                               ; preds = %62
  %66 = load ptr, ptr %15, align 8, !tbaa !5
  store i64 -6, ptr %66, align 8, !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, %38
  %71 = load ptr, ptr %15, align 8, !tbaa !5
  %72 = load i64, ptr %71, align 8, !tbaa !9
  %73 = icmp ne i64 %72, 0
  br i1 %73, label %74, label %79

74:                                               ; preds = %70
  %75 = load ptr, ptr %15, align 8, !tbaa !5
  %76 = load i64, ptr %75, align 8, !tbaa !9
  %77 = sub nsw i64 0, %76
  store i64 %77, ptr %18, align 8, !tbaa !9
  %78 = call i32 @xerbla_(ptr noundef @.str.2, ptr noundef %18)
  store i32 0, ptr %8, align 4
  store i32 1, ptr %19, align 4
  br label %102

79:                                               ; preds = %70
  %80 = load ptr, ptr %9, align 8, !tbaa !5
  %81 = load ptr, ptr %10, align 8, !tbaa !5
  %82 = load ptr, ptr %12, align 8, !tbaa !5
  %83 = getelementptr inbounds %struct.complex, ptr %82, i64 1
  %84 = load ptr, ptr %15, align 8, !tbaa !5
  %85 = call i32 @cpptrf_(ptr noundef %80, ptr noundef %81, ptr noundef %83, ptr noundef %84)
  %86 = load ptr, ptr %15, align 8, !tbaa !5
  %87 = load i64, ptr %86, align 8, !tbaa !9
  %88 = icmp eq i64 %87, 0
  br i1 %88, label %89, label %101

89:                                               ; preds = %79
  %90 = load ptr, ptr %9, align 8, !tbaa !5
  %91 = load ptr, ptr %10, align 8, !tbaa !5
  %92 = load ptr, ptr %11, align 8, !tbaa !5
  %93 = load ptr, ptr %12, align 8, !tbaa !5
  %94 = getelementptr inbounds %struct.complex, ptr %93, i64 1
  %95 = load ptr, ptr %13, align 8, !tbaa !5
  %96 = load i64, ptr %17, align 8, !tbaa !9
  %97 = getelementptr inbounds %struct.complex, ptr %95, i64 %96
  %98 = load ptr, ptr %14, align 8, !tbaa !5
  %99 = load ptr, ptr %15, align 8, !tbaa !5
  %100 = call i32 @cpptrs_(ptr noundef %90, ptr noundef %91, ptr noundef %92, ptr noundef %94, ptr noundef %97, ptr noundef %98, ptr noundef %99)
  br label %101

101:                                              ; preds = %89, %79
  store i32 0, ptr %8, align 4
  store i32 1, ptr %19, align 4
  br label %102

102:                                              ; preds = %101, %74
  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
  %103 = load i32, ptr %8, align 4
  ret i32 %103
}

; 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 @cpptrf_(ptr noundef, ptr noundef, ptr noundef, ptr noundef) #2

declare i32 @cpptrs_(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 @cppsv_(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 = tail call i64 @lsame_(ptr noundef %0, ptr noundef nonnull @.str) #4
  %.not = icmp eq i64 %9, 0
  br i1 %.not, label %10, label %12

10:                                               ; preds = %7
  %11 = tail call i64 @lsame_(ptr noundef %0, ptr noundef nonnull @.str.1) #4
  %.not33 = icmp eq i64 %11, 0
  br i1 %.not33, label %.thread.sink.split, label %12

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

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

18:                                               ; preds = %15
  %19 = load i64, ptr %5, align 8, !tbaa !5
  %spec.select = tail call i64 @llvm.umax.i64(i64 %13, i64 1)
  %20 = icmp slt i64 %19, %spec.select
  br i1 %20, label %.thread.sink.split, label %21

21:                                               ; preds = %18
  %.pr = load i64, ptr %6, align 8, !tbaa !5
  %.not34 = icmp eq i64 %.pr, 0
  br i1 %.not34, label %25, label %.thread

.thread.sink.split:                               ; preds = %18, %15, %12, %10
  %.sink = phi i64 [ -1, %10 ], [ -2, %12 ], [ -3, %15 ], [ -6, %18 ]
  store i64 %.sink, ptr %6, align 8, !tbaa !5
  br label %.thread

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

25:                                               ; preds = %21
  %26 = tail call i32 @cpptrf_(ptr noundef %0, ptr noundef nonnull %1, ptr noundef %3, ptr noundef nonnull %6) #4
  %27 = load i64, ptr %6, align 8, !tbaa !5
  %28 = icmp eq i64 %27, 0
  br i1 %28, label %29, label %31

29:                                               ; preds = %25
  %30 = tail call i32 @cpptrs_(ptr noundef %0, ptr noundef nonnull %1, ptr noundef nonnull %2, ptr noundef %3, ptr noundef %4, ptr noundef nonnull %5, ptr noundef nonnull %6) #4
  br label %31

31:                                               ; preds = %25, %29, %.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 i64 @lsame_(ptr noundef, ptr noundef) local_unnamed_addr #2

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

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

declare i32 @cpptrs_(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