; LLVM IR from OpenMathLib/OpenBLAS :: lapack-netlib/LAPACKE/src (lapacke_clantr_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 float @LAPACKE_clantr_work(i32 noundef %0, i8 noundef signext %1, i8 noundef signext %2, i8 noundef signext %3, i32 noundef %4, i32 noundef %5, ptr noundef %6, i32 noundef %7, ptr noundef %8) #0 {
  %10 = alloca float, align 4
  %11 = alloca i32, align 4
  %12 = alloca i8, align 1
  %13 = alloca i8, align 1
  %14 = alloca i8, align 1
  %15 = alloca i32, align 4
  %16 = alloca i32, align 4
  %17 = alloca ptr, align 8
  %18 = alloca i32, align 4
  %19 = alloca ptr, align 8
  %20 = alloca i32, align 4
  %21 = alloca float, align 4
  %22 = alloca ptr, align 8
  %23 = alloca i8, align 1
  %24 = alloca i8, align 1
  %25 = alloca i32, align 4
  store i32 %0, ptr %11, align 4, !tbaa !5
  store i8 %1, ptr %12, align 1, !tbaa !9
  store i8 %2, ptr %13, align 1, !tbaa !9
  store i8 %3, ptr %14, align 1, !tbaa !9
  store i32 %4, ptr %15, align 4, !tbaa !5
  store i32 %5, ptr %16, align 4, !tbaa !5
  store ptr %6, ptr %17, align 8, !tbaa !10
  store i32 %7, ptr %18, align 4, !tbaa !5
  store ptr %8, ptr %19, align 8, !tbaa !10
  call void @llvm.lifetime.start.p0(i64 4, ptr %20) #6
  store i32 0, ptr %20, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %21) #6
  store float 0.000000e+00, ptr %21, align 4, !tbaa !12
  %26 = load i32, ptr %11, align 4, !tbaa !5
  %27 = icmp eq i32 %26, 102
  br i1 %27, label %28, label %32

28:                                               ; preds = %9
  %29 = load ptr, ptr %17, align 8, !tbaa !10
  %30 = load ptr, ptr %19, align 8, !tbaa !10
  %31 = call float @clantr_(ptr noundef %12, ptr noundef %13, ptr noundef %14, ptr noundef %15, ptr noundef %16, ptr noundef %29, ptr noundef %18, ptr noundef %30, i64 noundef 1, i64 noundef 1, i64 noundef 1)
  store float %31, ptr %21, align 4, !tbaa !12
  br label %106

32:                                               ; preds = %9
  %33 = load i32, ptr %11, align 4, !tbaa !5
  %34 = icmp eq i32 %33, 101
  br i1 %34, label %35, label %103

35:                                               ; preds = %32
  call void @llvm.lifetime.start.p0(i64 8, ptr %22) #6
  store ptr null, ptr %22, align 8, !tbaa !10
  call void @llvm.lifetime.start.p0(i64 1, ptr %23) #6
  call void @llvm.lifetime.start.p0(i64 1, ptr %24) #6
  %36 = load i32, ptr %18, align 4, !tbaa !5
  %37 = load i32, ptr %16, align 4, !tbaa !5
  %38 = icmp slt i32 %36, %37
  br i1 %38, label %39, label %43

39:                                               ; preds = %35
  store i32 -8, ptr %20, align 4, !tbaa !5
  %40 = load i32, ptr %20, align 4, !tbaa !5
  call void @LAPACKE_xerbla(ptr noundef @.str, i32 noundef %40)
  %41 = load i32, ptr %20, align 4, !tbaa !5
  %42 = sitofp i32 %41 to float
  store float %42, ptr %10, align 4
  store i32 1, ptr %25, align 4
  br label %100

43:                                               ; preds = %35
  %44 = load i8, ptr %12, align 1, !tbaa !9
  %45 = call i32 @LAPACKE_lsame(i8 noundef signext %44, i8 noundef signext 49) #7
  %46 = icmp ne i32 %45, 0
  br i1 %46, label %51, label %47

47:                                               ; preds = %43
  %48 = load i8, ptr %12, align 1, !tbaa !9
  %49 = call i32 @LAPACKE_lsame(i8 noundef signext %48, i8 noundef signext 111) #7
  %50 = icmp ne i32 %49, 0
  br i1 %50, label %51, label %52

51:                                               ; preds = %47, %43
  store i8 105, ptr %23, align 1, !tbaa !9
  br label %60

52:                                               ; preds = %47
  %53 = load i8, ptr %12, align 1, !tbaa !9
  %54 = call i32 @LAPACKE_lsame(i8 noundef signext %53, i8 noundef signext 105) #7
  %55 = icmp ne i32 %54, 0
  br i1 %55, label %56, label %57

56:                                               ; preds = %52
  store i8 49, ptr %23, align 1, !tbaa !9
  br label %59

57:                                               ; preds = %52
  %58 = load i8, ptr %12, align 1, !tbaa !9
  store i8 %58, ptr %23, align 1, !tbaa !9
  br label %59

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

60:                                               ; preds = %59, %51
  %61 = load i8, ptr %13, align 1, !tbaa !9
  %62 = call i32 @LAPACKE_lsame(i8 noundef signext %61, i8 noundef signext 117) #7
  %63 = icmp ne i32 %62, 0
  br i1 %63, label %64, label %65

64:                                               ; preds = %60
  store i8 108, ptr %24, align 1, !tbaa !9
  br label %66

65:                                               ; preds = %60
  store i8 117, ptr %24, align 1, !tbaa !9
  br label %66

66:                                               ; preds = %65, %64
  %67 = load i8, ptr %23, align 1, !tbaa !9
  %68 = call i32 @LAPACKE_lsame(i8 noundef signext %67, i8 noundef signext 105) #7
  %69 = icmp ne i32 %68, 0
  br i1 %69, label %70, label %85

70:                                               ; preds = %66
  %71 = load i32, ptr %16, align 4, !tbaa !5
  %72 = icmp sgt i32 1, %71
  br i1 %72, label %73, label %74

73:                                               ; preds = %70
  br label %76

74:                                               ; preds = %70
  %75 = load i32, ptr %16, align 4, !tbaa !5
  br label %76

76:                                               ; preds = %74, %73
  %77 = phi i32 [ 1, %73 ], [ %75, %74 ]
  %78 = sext i32 %77 to i64
  %79 = mul i64 4, %78
  %80 = call noalias ptr @malloc(i64 noundef %79) #8
  store ptr %80, ptr %22, align 8, !tbaa !10
  %81 = load ptr, ptr %22, align 8, !tbaa !10
  %82 = icmp eq ptr %81, null
  br i1 %82, label %83, label %84

83:                                               ; preds = %76
  store i32 -1010, ptr %20, align 4, !tbaa !5
  br label %94

84:                                               ; preds = %76
  br label %85

85:                                               ; preds = %84, %66
  %86 = load ptr, ptr %17, align 8, !tbaa !10
  %87 = load ptr, ptr %22, align 8, !tbaa !10
  %88 = call float @clantr_(ptr noundef %23, ptr noundef %24, ptr noundef %14, ptr noundef %16, ptr noundef %15, ptr noundef %86, ptr noundef %18, ptr noundef %87, i64 noundef 1, i64 noundef 1, i64 noundef 1)
  store float %88, ptr %21, align 4, !tbaa !12
  %89 = load ptr, ptr %22, align 8, !tbaa !10
  %90 = icmp ne ptr %89, null
  br i1 %90, label %91, label %93

91:                                               ; preds = %85
  %92 = load ptr, ptr %22, align 8, !tbaa !10
  call void @free(ptr noundef %92) #6
  br label %93

93:                                               ; preds = %91, %85
  br label %94

94:                                               ; preds = %93, %83
  %95 = load i32, ptr %20, align 4, !tbaa !5
  %96 = icmp eq i32 %95, -1010
  br i1 %96, label %97, label %99

97:                                               ; preds = %94
  %98 = load i32, ptr %20, align 4, !tbaa !5
  call void @LAPACKE_xerbla(ptr noundef @.str, i32 noundef %98)
  br label %99

99:                                               ; preds = %97, %94
  store i32 0, ptr %25, align 4
  br label %100

100:                                              ; preds = %99, %39
  call void @llvm.lifetime.end.p0(i64 1, ptr %24) #6
  call void @llvm.lifetime.end.p0(i64 1, ptr %23) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %22) #6
  %101 = load i32, ptr %25, align 4
  switch i32 %101, label %108 [
    i32 0, label %102
  ]

102:                                              ; preds = %100
  br label %105

103:                                              ; preds = %32
  store i32 -1, ptr %20, align 4, !tbaa !5
  %104 = load i32, ptr %20, align 4, !tbaa !5
  call void @LAPACKE_xerbla(ptr noundef @.str, i32 noundef %104)
  br label %105

105:                                              ; preds = %103, %102
  br label %106

106:                                              ; preds = %105, %28
  %107 = load float, ptr %21, align 4, !tbaa !12
  store float %107, ptr %10, align 4
  store i32 1, ptr %25, align 4
  br label %108

108:                                              ; preds = %106, %100
  call void @llvm.lifetime.end.p0(i64 4, ptr %21) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %20) #6
  %109 = load float, ptr %10, align 4
  ret float %109
}

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

declare float @clantr_(ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef, i64 noundef, i64 noundef, i64 noundef) #2

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

; Function Attrs: nounwind willreturn memory(none)
declare i32 @LAPACKE_lsame(i8 noundef signext, i8 noundef signext) #3

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

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

; 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 willreturn memory(none) "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 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 #5 = { 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 #6 = { nounwind }
attributes #7 = { nounwind willreturn memory(none) }
attributes #8 = { 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}
!12 = !{!13, !13, i64 0}
!13 = !{!"float", !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 float @LAPACKE_clantr_work(i32 noundef %0, i8 noundef signext %1, i8 noundef signext %2, i8 noundef signext %3, i32 noundef %4, i32 noundef %5, ptr noundef %6, i32 noundef %7, ptr noundef %8) local_unnamed_addr #0 {
  %10 = alloca i8, align 1
  %11 = alloca i8, align 1
  %12 = alloca i8, align 1
  %13 = alloca i32, align 4
  %14 = alloca i32, align 4
  %15 = alloca i32, align 4
  %16 = alloca i8, align 1
  %17 = alloca i8, align 1
  store i8 %1, ptr %10, align 1, !tbaa !5
  store i8 %2, ptr %11, align 1, !tbaa !5
  store i8 %3, ptr %12, align 1, !tbaa !5
  store i32 %4, ptr %13, align 4, !tbaa !8
  store i32 %5, ptr %14, align 4, !tbaa !8
  store i32 %7, ptr %15, align 4, !tbaa !8
  switch i32 %0, label %45 [
    i32 102, label %18
    i32 101, label %20
  ]

18:                                               ; preds = %9
  %19 = call float @clantr_(ptr noundef nonnull %10, ptr noundef nonnull %11, ptr noundef nonnull %12, ptr noundef nonnull %13, ptr noundef nonnull %14, ptr noundef %6, ptr noundef nonnull %15, ptr noundef %8, i64 noundef 1, i64 noundef 1, i64 noundef 1) #7
  br label %46

20:                                               ; preds = %9
  call void @llvm.lifetime.start.p0(i64 1, ptr nonnull %16) #7
  call void @llvm.lifetime.start.p0(i64 1, ptr nonnull %17) #7
  %.not28 = icmp slt i32 %7, %5
  br i1 %.not28, label %44, label %21

21:                                               ; preds = %20
  %22 = tail call i32 @LAPACKE_lsame(i8 noundef signext %1, i8 noundef signext 49) #8
  %.not = icmp eq i32 %22, 0
  br i1 %.not, label %23, label %25

23:                                               ; preds = %21
  %24 = tail call i32 @LAPACKE_lsame(i8 noundef signext %1, i8 noundef signext 111) #8
  %.not23 = icmp eq i32 %24, 0
  br i1 %.not23, label %26, label %25

25:                                               ; preds = %23, %21
  store i8 105, ptr %16, align 1, !tbaa !5
  br label %30

26:                                               ; preds = %23
  %27 = tail call i32 @LAPACKE_lsame(i8 noundef signext %1, i8 noundef signext 105) #8
  %.not24 = icmp eq i32 %27, 0
  br i1 %.not24, label %29, label %28

28:                                               ; preds = %26
  store i8 49, ptr %16, align 1, !tbaa !5
  br label %30

29:                                               ; preds = %26
  store i8 %1, ptr %16, align 1, !tbaa !5
  br label %30

30:                                               ; preds = %28, %29, %25
  %31 = phi i8 [ 49, %28 ], [ %1, %29 ], [ 105, %25 ]
  %32 = tail call i32 @LAPACKE_lsame(i8 noundef signext %2, i8 noundef signext 117) #8
  %.not25 = icmp eq i32 %32, 0
  %. = select i1 %.not25, i8 117, i8 108
  store i8 %., ptr %17, align 1, !tbaa !5
  %33 = tail call i32 @LAPACKE_lsame(i8 noundef signext %31, i8 noundef signext 105) #8
  %.not26 = icmp eq i32 %33, 0
  br i1 %.not26, label %.thread, label %35

.thread:                                          ; preds = %30
  %34 = call float @clantr_(ptr noundef nonnull %16, ptr noundef nonnull %17, ptr noundef nonnull %12, ptr noundef nonnull %14, ptr noundef nonnull %13, ptr noundef %6, ptr noundef nonnull %15, ptr noundef null, i64 noundef 1, i64 noundef 1, i64 noundef 1) #7
  br label %.thread31

35:                                               ; preds = %30
  %36 = tail call i32 @llvm.smax.i32(i32 %5, i32 1)
  %37 = zext nneg i32 %36 to i64
  %38 = shl nuw nsw i64 %37, 2
  %39 = tail call noalias ptr @malloc(i64 noundef %38) #9
  %40 = icmp eq ptr %39, null
  br i1 %40, label %43, label %41

41:                                               ; preds = %35
  %42 = call float @clantr_(ptr noundef nonnull %16, ptr noundef nonnull %17, ptr noundef nonnull %12, ptr noundef nonnull %14, ptr noundef nonnull %13, ptr noundef %6, ptr noundef nonnull %15, ptr noundef nonnull %39, i64 noundef 1, i64 noundef 1, i64 noundef 1) #7
  call void @free(ptr noundef nonnull %39) #7
  br label %.thread31

43:                                               ; preds = %35
  tail call void @LAPACKE_xerbla(ptr noundef nonnull @.str, i32 noundef -1010) #7
  br label %.thread31

44:                                               ; preds = %20
  tail call void @LAPACKE_xerbla(ptr noundef nonnull @.str, i32 noundef -8) #7
  call void @llvm.lifetime.end.p0(i64 1, ptr nonnull %17) #7
  call void @llvm.lifetime.end.p0(i64 1, ptr nonnull %16) #7
  br label %46

45:                                               ; preds = %9
  tail call void @LAPACKE_xerbla(ptr noundef nonnull @.str, i32 noundef -1) #7
  br label %46

.thread31:                                        ; preds = %.thread, %41, %43
  %.1.ph = phi float [ 0.000000e+00, %43 ], [ %34, %.thread ], [ %42, %41 ]
  call void @llvm.lifetime.end.p0(i64 1, ptr nonnull %17) #7
  call void @llvm.lifetime.end.p0(i64 1, ptr nonnull %16) #7
  br label %46

46:                                               ; preds = %44, %18, %45, %.thread31
  %.120 = phi float [ -8.000000e+00, %44 ], [ %19, %18 ], [ 0.000000e+00, %45 ], [ %.1.ph, %.thread31 ]
  ret float %.120
}

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

declare float @clantr_(ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef, i64 noundef, i64 noundef, i64 noundef) local_unnamed_addr #2

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

; Function Attrs: mustprogress nofree nosync nounwind willreturn memory(none)
declare i32 @LAPACKE_lsame(i8 noundef signext, i8 noundef signext) local_unnamed_addr #3

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

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

; 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) #6

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 nosync nounwind willreturn memory(none) "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 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 #5 = { 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 #6 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #7 = { nounwind }
attributes #8 = { nounwind willreturn memory(none) }
attributes #9 = { 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,SROAPass,SimplifyCFGPass,TailCallElimPass