; LLVM IR from OpenMathLib/OpenBLAS :: lapack-netlib/LAPACKE/src (lapacke_clacpy_work)

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

; Function Attrs: nounwind uwtable
define dso_local i32 @LAPACKE_clacpy_work(i32 noundef %0, i8 noundef signext %1, i32 noundef %2, i32 noundef %3, ptr noundef %4, i32 noundef %5, ptr noundef %6, i32 noundef %7) #0 {
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca i8, align 1
  %12 = alloca i32, align 4
  %13 = alloca i32, align 4
  %14 = alloca ptr, align 8
  %15 = alloca i32, align 4
  %16 = alloca ptr, align 8
  %17 = alloca i32, align 4
  %18 = alloca i32, align 4
  %19 = alloca i32, align 4
  %20 = alloca i32, align 4
  %21 = alloca ptr, align 8
  %22 = alloca ptr, align 8
  %23 = alloca i32, align 4
  store i32 %0, ptr %10, align 4, !tbaa !5
  store i8 %1, ptr %11, align 1, !tbaa !9
  store i32 %2, ptr %12, align 4, !tbaa !5
  store i32 %3, ptr %13, align 4, !tbaa !5
  store ptr %4, ptr %14, align 8, !tbaa !10
  store i32 %5, ptr %15, align 4, !tbaa !5
  store ptr %6, ptr %16, align 8, !tbaa !10
  store i32 %7, ptr %17, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %18) #5
  store i32 0, ptr %18, align 4, !tbaa !5
  %24 = load i32, ptr %10, align 4, !tbaa !5
  %25 = icmp eq i32 %24, 102
  br i1 %25, label %26, label %29

26:                                               ; preds = %8
  %27 = load ptr, ptr %14, align 8, !tbaa !10
  %28 = load ptr, ptr %16, align 8, !tbaa !10
  call void @clacpy_(ptr noundef %11, ptr noundef %12, ptr noundef %13, ptr noundef %27, ptr noundef %15, ptr noundef %28, ptr noundef %17, i64 noundef 1)
  br label %125

29:                                               ; preds = %8
  %30 = load i32, ptr %10, align 4, !tbaa !5
  %31 = icmp eq i32 %30, 101
  br i1 %31, label %32, label %122

32:                                               ; preds = %29
  call void @llvm.lifetime.start.p0(i64 4, ptr %19) #5
  %33 = load i32, ptr %12, align 4, !tbaa !5
  %34 = icmp sgt i32 1, %33
  br i1 %34, label %35, label %36

35:                                               ; preds = %32
  br label %38

36:                                               ; preds = %32
  %37 = load i32, ptr %12, align 4, !tbaa !5
  br label %38

38:                                               ; preds = %36, %35
  %39 = phi i32 [ 1, %35 ], [ %37, %36 ]
  store i32 %39, ptr %19, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %20) #5
  %40 = load i32, ptr %12, align 4, !tbaa !5
  %41 = icmp sgt i32 1, %40
  br i1 %41, label %42, label %43

42:                                               ; preds = %38
  br label %45

43:                                               ; preds = %38
  %44 = load i32, ptr %12, align 4, !tbaa !5
  br label %45

45:                                               ; preds = %43, %42
  %46 = phi i32 [ 1, %42 ], [ %44, %43 ]
  store i32 %46, ptr %20, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %21) #5
  store ptr null, ptr %21, align 8, !tbaa !10
  call void @llvm.lifetime.start.p0(i64 8, ptr %22) #5
  store ptr null, ptr %22, align 8, !tbaa !10
  %47 = load i32, ptr %15, align 4, !tbaa !5
  %48 = load i32, ptr %13, align 4, !tbaa !5
  %49 = icmp slt i32 %47, %48
  br i1 %49, label %50, label %53

50:                                               ; preds = %45
  store i32 -6, ptr %18, align 4, !tbaa !5
  %51 = load i32, ptr %18, align 4, !tbaa !5
  call void @LAPACKE_xerbla(ptr noundef @.str, i32 noundef %51)
  %52 = load i32, ptr %18, align 4, !tbaa !5
  store i32 %52, ptr %9, align 4
  store i32 1, ptr %23, align 4
  br label %119

53:                                               ; preds = %45
  %54 = load i32, ptr %17, align 4, !tbaa !5
  %55 = load i32, ptr %13, align 4, !tbaa !5
  %56 = icmp slt i32 %54, %55
  br i1 %56, label %57, label %60

57:                                               ; preds = %53
  store i32 -8, ptr %18, align 4, !tbaa !5
  %58 = load i32, ptr %18, align 4, !tbaa !5
  call void @LAPACKE_xerbla(ptr noundef @.str, i32 noundef %58)
  %59 = load i32, ptr %18, align 4, !tbaa !5
  store i32 %59, ptr %9, align 4
  store i32 1, ptr %23, align 4
  br label %119

60:                                               ; preds = %53
  %61 = load i32, ptr %19, align 4, !tbaa !5
  %62 = sext i32 %61 to i64
  %63 = mul i64 8, %62
  %64 = load i32, ptr %13, align 4, !tbaa !5
  %65 = icmp sgt i32 1, %64
  br i1 %65, label %66, label %67

66:                                               ; preds = %60
  br label %69

67:                                               ; preds = %60
  %68 = load i32, ptr %13, align 4, !tbaa !5
  br label %69

69:                                               ; preds = %67, %66
  %70 = phi i32 [ 1, %66 ], [ %68, %67 ]
  %71 = sext i32 %70 to i64
  %72 = mul i64 %63, %71
  %73 = call noalias ptr @malloc(i64 noundef %72) #6
  store ptr %73, ptr %21, align 8, !tbaa !10
  %74 = load ptr, ptr %21, align 8, !tbaa !10
  %75 = icmp eq ptr %74, null
  br i1 %75, label %76, label %77

76:                                               ; preds = %69
  store i32 -1011, ptr %18, align 4, !tbaa !5
  br label %113

77:                                               ; preds = %69
  %78 = load i32, ptr %20, align 4, !tbaa !5
  %79 = sext i32 %78 to i64
  %80 = mul i64 8, %79
  %81 = load i32, ptr %13, align 4, !tbaa !5
  %82 = icmp sgt i32 1, %81
  br i1 %82, label %83, label %84

83:                                               ; preds = %77
  br label %86

84:                                               ; preds = %77
  %85 = load i32, ptr %13, align 4, !tbaa !5
  br label %86

86:                                               ; preds = %84, %83
  %87 = phi i32 [ 1, %83 ], [ %85, %84 ]
  %88 = sext i32 %87 to i64
  %89 = mul i64 %80, %88
  %90 = call noalias ptr @malloc(i64 noundef %89) #6
  store ptr %90, ptr %22, align 8, !tbaa !10
  %91 = load ptr, ptr %22, align 8, !tbaa !10
  %92 = icmp eq ptr %91, null
  br i1 %92, label %93, label %94

93:                                               ; preds = %86
  store i32 -1011, ptr %18, align 4, !tbaa !5
  br label %111

94:                                               ; preds = %86
  %95 = load i32, ptr %10, align 4, !tbaa !5
  %96 = load i32, ptr %12, align 4, !tbaa !5
  %97 = load i32, ptr %13, align 4, !tbaa !5
  %98 = load ptr, ptr %14, align 8, !tbaa !10
  %99 = load i32, ptr %15, align 4, !tbaa !5
  %100 = load ptr, ptr %21, align 8, !tbaa !10
  %101 = load i32, ptr %19, align 4, !tbaa !5
  call void @LAPACKE_cge_trans(i32 noundef %95, i32 noundef %96, i32 noundef %97, ptr noundef %98, i32 noundef %99, ptr noundef %100, i32 noundef %101)
  %102 = load ptr, ptr %21, align 8, !tbaa !10
  %103 = load ptr, ptr %22, align 8, !tbaa !10
  call void @clacpy_(ptr noundef %11, ptr noundef %12, ptr noundef %13, ptr noundef %102, ptr noundef %19, ptr noundef %103, ptr noundef %20, i64 noundef 1)
  store i32 0, ptr %18, align 4, !tbaa !5
  %104 = load i32, ptr %12, align 4, !tbaa !5
  %105 = load i32, ptr %13, align 4, !tbaa !5
  %106 = load ptr, ptr %22, align 8, !tbaa !10
  %107 = load i32, ptr %20, align 4, !tbaa !5
  %108 = load ptr, ptr %16, align 8, !tbaa !10
  %109 = load i32, ptr %17, align 4, !tbaa !5
  call void @LAPACKE_cge_trans(i32 noundef 102, i32 noundef %104, i32 noundef %105, ptr noundef %106, i32 noundef %107, ptr noundef %108, i32 noundef %109)
  %110 = load ptr, ptr %22, align 8, !tbaa !10
  call void @free(ptr noundef %110) #5
  br label %111

111:                                              ; preds = %94, %93
  %112 = load ptr, ptr %21, align 8, !tbaa !10
  call void @free(ptr noundef %112) #5
  br label %113

113:                                              ; preds = %111, %76
  %114 = load i32, ptr %18, align 4, !tbaa !5
  %115 = icmp eq i32 %114, -1011
  br i1 %115, label %116, label %118

116:                                              ; preds = %113
  %117 = load i32, ptr %18, align 4, !tbaa !5
  call void @LAPACKE_xerbla(ptr noundef @.str, i32 noundef %117)
  br label %118

118:                                              ; preds = %116, %113
  store i32 0, ptr %23, align 4
  br label %119

119:                                              ; preds = %118, %57, %50
  call void @llvm.lifetime.end.p0(i64 8, ptr %22) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %21) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %20) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %19) #5
  %120 = load i32, ptr %23, align 4
  switch i32 %120, label %127 [
    i32 0, label %121
  ]

121:                                              ; preds = %119
  br label %124

122:                                              ; preds = %29
  store i32 -1, ptr %18, align 4, !tbaa !5
  %123 = load i32, ptr %18, align 4, !tbaa !5
  call void @LAPACKE_xerbla(ptr noundef @.str, i32 noundef %123)
  br label %124

124:                                              ; preds = %122, %121
  br label %125

125:                                              ; preds = %124, %26
  %126 = load i32, ptr %18, align 4, !tbaa !5
  store i32 %126, ptr %9, align 4
  store i32 1, ptr %23, align 4
  br label %127

127:                                              ; preds = %125, %119
  call void @llvm.lifetime.end.p0(i64 4, ptr %18) #5
  %128 = load i32, ptr %9, align 4
  ret i32 %128
}

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

declare void @clacpy_(ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef, i64 noundef) #2

declare void @LAPACKE_xerbla(ptr noundef, i32 noundef) #2

; Function Attrs: nounwind allocsize(0)
declare noalias ptr @malloc(i64 noundef) #3

declare void @LAPACKE_cge_trans(i32 noundef, i32 noundef, i32 noundef, ptr noundef, i32 noundef, ptr noundef, i32 noundef) #2

; Function Attrs: nounwind
declare void @free(ptr noundef) #4

; 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 allocsize(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 #4 = { nounwind "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 #5 = { nounwind }
attributes #6 = { nounwind allocsize(0) }

!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 = !{!"any pointer", !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 [20 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local noundef i32 @LAPACKE_clacpy_work(i32 noundef %0, i8 noundef signext %1, i32 noundef %2, i32 noundef %3, ptr noundef %4, i32 noundef %5, ptr noundef %6, i32 noundef %7) local_unnamed_addr #0 {
  %9 = alloca i8, align 1
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  %13 = alloca i32, align 4
  %14 = alloca i32, align 4
  %15 = alloca i32, align 4
  store i8 %1, ptr %9, align 1, !tbaa !5
  store i32 %2, ptr %10, align 4, !tbaa !8
  store i32 %3, ptr %11, align 4, !tbaa !8
  store i32 %5, ptr %12, align 4, !tbaa !8
  store i32 %7, ptr %13, align 4, !tbaa !8
  switch i32 %0, label %39 [
    i32 102, label %16
    i32 101, label %17
  ]

16:                                               ; preds = %8
  call void @clacpy_(ptr noundef nonnull %9, ptr noundef nonnull %10, ptr noundef nonnull %11, ptr noundef %4, ptr noundef nonnull %12, ptr noundef %6, ptr noundef nonnull %13, i64 noundef 1) #6
  br label %40

17:                                               ; preds = %8
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %14) #6
  %18 = tail call i32 @llvm.smax.i32(i32 %2, i32 1)
  store i32 %18, ptr %14, align 4, !tbaa !8
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %15) #6
  store i32 %18, ptr %15, align 4, !tbaa !8
  %19 = icmp slt i32 %5, %3
  br i1 %19, label %37, label %20

20:                                               ; preds = %17
  %21 = icmp slt i32 %7, %3
  br i1 %21, label %37, label %22

22:                                               ; preds = %20
  %23 = zext nneg i32 %18 to i64
  %24 = shl nuw nsw i64 %23, 3
  %25 = tail call i32 @llvm.smax.i32(i32 %3, i32 1)
  %26 = zext nneg i32 %25 to i64
  %27 = mul i64 %24, %26
  %28 = tail call noalias ptr @malloc(i64 noundef %27) #7
  %29 = icmp eq ptr %28, null
  br i1 %29, label %.thread, label %30

30:                                               ; preds = %22
  %31 = tail call noalias ptr @malloc(i64 noundef %27) #7
  %32 = icmp eq ptr %31, null
  br i1 %32, label %.thread33, label %33

.thread33:                                        ; preds = %30
  tail call void @free(ptr noundef nonnull %28) #6
  br label %.thread

33:                                               ; preds = %30
  tail call void @LAPACKE_cge_trans(i32 noundef 101, i32 noundef %2, i32 noundef %3, ptr noundef %4, i32 noundef %5, ptr noundef nonnull %28, i32 noundef %18) #6
  call void @clacpy_(ptr noundef nonnull %9, ptr noundef nonnull %10, ptr noundef nonnull %11, ptr noundef nonnull %28, ptr noundef nonnull %14, ptr noundef nonnull %31, ptr noundef nonnull %15, i64 noundef 1) #6
  %34 = load i32, ptr %10, align 4, !tbaa !8
  %35 = load i32, ptr %11, align 4, !tbaa !8
  %36 = load i32, ptr %15, align 4, !tbaa !8
  call void @LAPACKE_cge_trans(i32 noundef 102, i32 noundef %34, i32 noundef %35, ptr noundef nonnull %31, i32 noundef %36, ptr noundef %6, i32 noundef %7) #6
  call void @free(ptr noundef nonnull %31) #6
  call void @free(ptr noundef nonnull %28) #6
  br label %38

.thread:                                          ; preds = %22, %.thread33
  tail call void @LAPACKE_xerbla(ptr noundef nonnull @.str, i32 noundef -1011) #6
  br label %38

37:                                               ; preds = %20, %17
  %.sink = phi i32 [ -6, %17 ], [ -8, %20 ]
  tail call void @LAPACKE_xerbla(ptr noundef nonnull @.str, i32 noundef %.sink) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %15) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %14) #6
  br label %40

38:                                               ; preds = %.thread, %33
  %.2.ph = phi i32 [ 0, %33 ], [ -1011, %.thread ]
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %15) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %14) #6
  br label %40

39:                                               ; preds = %8
  tail call void @LAPACKE_xerbla(ptr noundef nonnull @.str, i32 noundef -1) #6
  br label %40

40:                                               ; preds = %38, %37, %16, %39
  %.126 = phi i32 [ 0, %16 ], [ -1, %39 ], [ %.2.ph, %38 ], [ %.sink, %37 ]
  ret i32 %.126
}

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

declare void @clacpy_(ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef, i64 noundef) local_unnamed_addr #2

declare void @LAPACKE_xerbla(ptr noundef, i32 noundef) local_unnamed_addr #2

; Function Attrs: mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @malloc(i64 noundef) local_unnamed_addr #3

declare void @LAPACKE_cge_trans(i32 noundef, i32 noundef, i32 noundef, ptr noundef, i32 noundef, ptr noundef, i32 noundef) local_unnamed_addr #2

; Function Attrs: mustprogress nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite)
declare void @free(ptr allocptr nocapture noundef) local_unnamed_addr #4

; 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 i32 @llvm.smax.i32(i32, i32) #5

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 = { mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite) "alloc-family"="malloc" "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 #4 = { mustprogress nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite) "alloc-family"="malloc" "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 #5 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #6 = { nounwind }
attributes #7 = { nounwind allocsize(0) }

!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 = !{!"omnipotent char", !7, i64 0}
!7 = !{!"Simple C/C++ TBAA"}
!8 = !{!9, !9, i64 0}
!9 = !{!"int", !6, i64 0}


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