; LLVM IR from o0o0o0o0o0o0o/image-processing-from-scratch :: ImageMatting/Eigen/blas (double)

; 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"

@_ZZ5dspr_E4func = external hidden constant [2 x ptr], align 16
@.str.10 = external hidden unnamed_addr constant [7 x i8], align 1

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

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

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

; Function Attrs: mustprogress uwtable
declare dso_local noundef ptr @_Z18get_compact_vectorIdEPT_S1_ii(ptr noundef, i32 noundef, i32 noundef) #2

; Function Attrs: nobuiltin nounwind
declare void @_ZdaPv(ptr noundef) #3

; Function Attrs: mustprogress uwtable
define dso_local i32 @dspr_(ptr noundef %0, ptr noundef %1, ptr noundef %2, ptr noundef %3, ptr noundef %4, ptr noundef %5) #2 {
  %7 = alloca i32, align 4
  %8 = alloca ptr, align 8
  %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 double, align 8
  %17 = alloca i32, align 4
  %18 = alloca i32, align 4
  %19 = alloca ptr, align 8
  %20 = alloca i32, align 4
  store ptr %0, ptr %8, align 8, !tbaa !5
  store ptr %1, ptr %9, align 8, !tbaa !5
  store ptr %2, ptr %10, align 8, !tbaa !5
  store ptr %3, ptr %11, align 8, !tbaa !5
  store ptr %4, ptr %12, align 8, !tbaa !5
  store ptr %5, ptr %13, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #4
  %21 = load ptr, ptr %11, align 8, !tbaa !5
  store ptr %21, ptr %14, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #4
  %22 = load ptr, ptr %13, align 8, !tbaa !5
  store ptr %22, ptr %15, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #4
  %23 = load ptr, ptr %10, align 8, !tbaa !5
  %24 = load double, ptr %23, align 8, !tbaa !9
  store double %24, ptr %16, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %17) #4
  store i32 0, ptr %17, align 4, !tbaa !11
  %25 = load ptr, ptr %8, align 8, !tbaa !5
  %26 = load i8, ptr %25, align 1, !tbaa !13
  %27 = sext i8 %26 to i32
  %28 = icmp eq i32 %27, 85
  br i1 %28, label %34, label %29

29:                                               ; preds = %6
  %30 = load ptr, ptr %8, align 8, !tbaa !5
  %31 = load i8, ptr %30, align 1, !tbaa !13
  %32 = sext i8 %31 to i32
  %33 = icmp eq i32 %32, 117
  br i1 %33, label %34, label %35

34:                                               ; preds = %29, %6
  br label %49

35:                                               ; preds = %29
  %36 = load ptr, ptr %8, align 8, !tbaa !5
  %37 = load i8, ptr %36, align 1, !tbaa !13
  %38 = sext i8 %37 to i32
  %39 = icmp eq i32 %38, 76
  br i1 %39, label %45, label %40

40:                                               ; preds = %35
  %41 = load ptr, ptr %8, align 8, !tbaa !5
  %42 = load i8, ptr %41, align 1, !tbaa !13
  %43 = sext i8 %42 to i32
  %44 = icmp eq i32 %43, 108
  br label %45

45:                                               ; preds = %40, %35
  %46 = phi i1 [ true, %35 ], [ %44, %40 ]
  %47 = zext i1 %46 to i64
  %48 = select i1 %46, i32 1, i32 255
  br label %49

49:                                               ; preds = %45, %34
  %50 = phi i32 [ 0, %34 ], [ %48, %45 ]
  %51 = icmp eq i32 %50, 255
  br i1 %51, label %52, label %53

52:                                               ; preds = %49
  store i32 1, ptr %17, align 4, !tbaa !11
  br label %65

53:                                               ; preds = %49
  %54 = load ptr, ptr %9, align 8, !tbaa !5
  %55 = load i32, ptr %54, align 4, !tbaa !11
  %56 = icmp slt i32 %55, 0
  br i1 %56, label %57, label %58

57:                                               ; preds = %53
  store i32 2, ptr %17, align 4, !tbaa !11
  br label %64

58:                                               ; preds = %53
  %59 = load ptr, ptr %12, align 8, !tbaa !5
  %60 = load i32, ptr %59, align 4, !tbaa !11
  %61 = icmp eq i32 %60, 0
  br i1 %61, label %62, label %63

62:                                               ; preds = %58
  store i32 5, ptr %17, align 4, !tbaa !11
  br label %63

63:                                               ; preds = %62, %58
  br label %64

64:                                               ; preds = %63, %57
  br label %65

65:                                               ; preds = %64, %52
  %66 = load i32, ptr %17, align 4, !tbaa !11
  %67 = icmp ne i32 %66, 0
  br i1 %67, label %68, label %70

68:                                               ; preds = %65
  %69 = call i32 @xerbla_(ptr noundef @.str.10, ptr noundef %17, i32 noundef 6)
  store i32 %69, ptr %7, align 4
  store i32 1, ptr %18, align 4
  br label %136

70:                                               ; preds = %65
  %71 = load double, ptr %16, align 8, !tbaa !9
  %72 = fcmp oeq double %71, 0.000000e+00
  br i1 %72, label %73, label %74

73:                                               ; preds = %70
  store i32 1, ptr %7, align 4
  store i32 1, ptr %18, align 4
  br label %136

74:                                               ; preds = %70
  call void @llvm.lifetime.start.p0(i64 8, ptr %19) #4
  %75 = load ptr, ptr %14, align 8, !tbaa !5
  %76 = load ptr, ptr %9, align 8, !tbaa !5
  %77 = load i32, ptr %76, align 4, !tbaa !11
  %78 = load ptr, ptr %12, align 8, !tbaa !5
  %79 = load i32, ptr %78, align 4, !tbaa !11
  %80 = call noundef ptr @_Z18get_compact_vectorIdEPT_S1_ii(ptr noundef %75, i32 noundef %77, i32 noundef %79)
  store ptr %80, ptr %19, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %20) #4
  %81 = load ptr, ptr %8, align 8, !tbaa !5
  %82 = load i8, ptr %81, align 1, !tbaa !13
  %83 = sext i8 %82 to i32
  %84 = icmp eq i32 %83, 85
  br i1 %84, label %90, label %85

85:                                               ; preds = %74
  %86 = load ptr, ptr %8, align 8, !tbaa !5
  %87 = load i8, ptr %86, align 1, !tbaa !13
  %88 = sext i8 %87 to i32
  %89 = icmp eq i32 %88, 117
  br i1 %89, label %90, label %91

90:                                               ; preds = %85, %74
  br label %105

91:                                               ; preds = %85
  %92 = load ptr, ptr %8, align 8, !tbaa !5
  %93 = load i8, ptr %92, align 1, !tbaa !13
  %94 = sext i8 %93 to i32
  %95 = icmp eq i32 %94, 76
  br i1 %95, label %101, label %96

96:                                               ; preds = %91
  %97 = load ptr, ptr %8, align 8, !tbaa !5
  %98 = load i8, ptr %97, align 1, !tbaa !13
  %99 = sext i8 %98 to i32
  %100 = icmp eq i32 %99, 108
  br label %101

101:                                              ; preds = %96, %91
  %102 = phi i1 [ true, %91 ], [ %100, %96 ]
  %103 = zext i1 %102 to i64
  %104 = select i1 %102, i32 1, i32 255
  br label %105

105:                                              ; preds = %101, %90
  %106 = phi i32 [ 0, %90 ], [ %104, %101 ]
  store i32 %106, ptr %20, align 4, !tbaa !11
  %107 = load i32, ptr %20, align 4, !tbaa !11
  %108 = icmp sge i32 %107, 2
  br i1 %108, label %115, label %109

109:                                              ; preds = %105
  %110 = load i32, ptr %20, align 4, !tbaa !11
  %111 = sext i32 %110 to i64
  %112 = getelementptr inbounds [2 x ptr], ptr @_ZZ5dspr_E4func, i64 0, i64 %111
  %113 = load ptr, ptr %112, align 8, !tbaa !5
  %114 = icmp eq ptr %113, null
  br i1 %114, label %115, label %116

115:                                              ; preds = %109, %105
  store i32 0, ptr %7, align 4
  store i32 1, ptr %18, align 4
  br label %135

116:                                              ; preds = %109
  %117 = load i32, ptr %20, align 4, !tbaa !11
  %118 = sext i32 %117 to i64
  %119 = getelementptr inbounds [2 x ptr], ptr @_ZZ5dspr_E4func, i64 0, i64 %118
  %120 = load ptr, ptr %119, align 8, !tbaa !5
  %121 = load ptr, ptr %9, align 8, !tbaa !5
  %122 = load i32, ptr %121, align 4, !tbaa !11
  %123 = load ptr, ptr %15, align 8, !tbaa !5
  %124 = load ptr, ptr %19, align 8, !tbaa !5
  %125 = load double, ptr %16, align 8, !tbaa !9
  call void %120(i32 noundef %122, ptr noundef %123, ptr noundef %124, double noundef %125)
  %126 = load ptr, ptr %19, align 8, !tbaa !5
  %127 = load ptr, ptr %14, align 8, !tbaa !5
  %128 = icmp ne ptr %126, %127
  br i1 %128, label %129, label %134

129:                                              ; preds = %116
  %130 = load ptr, ptr %19, align 8, !tbaa !5
  %131 = icmp eq ptr %130, null
  br i1 %131, label %133, label %132

132:                                              ; preds = %129
  call void @_ZdaPv(ptr noundef %130) #5
  br label %133

133:                                              ; preds = %132, %129
  br label %134

134:                                              ; preds = %133, %116
  store i32 1, ptr %7, align 4
  store i32 1, ptr %18, align 4
  br label %135

135:                                              ; preds = %134, %115
  call void @llvm.lifetime.end.p0(i64 4, ptr %20) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %19) #4
  br label %136

136:                                              ; preds = %135, %73, %68
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #4
  %137 = load i32, ptr %7, align 4
  ret i32 %137
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { "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 #2 = { mustprogress 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 #3 = { nobuiltin 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 #4 = { nounwind }
attributes #5 = { builtin 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++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"double", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{!7, !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"

@_ZZ5dspr_E4func = external hidden local_unnamed_addr constant [2 x ptr], align 16
@.str.10 = external hidden unnamed_addr constant [7 x i8], align 1

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

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

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

; Function Attrs: mustprogress uwtable
declare dso_local noundef ptr @_Z18get_compact_vectorIdEPT_S1_ii(ptr noundef, i32 noundef, i32 noundef) local_unnamed_addr #2

; Function Attrs: nobuiltin nounwind
declare void @_ZdaPv(ptr noundef) local_unnamed_addr #3

; Function Attrs: mustprogress uwtable
define dso_local i32 @dspr_(ptr nocapture noundef readonly %0, ptr nocapture noundef readonly %1, ptr nocapture noundef readonly %2, ptr noundef %3, ptr nocapture noundef readonly %4, ptr noundef %5) local_unnamed_addr #2 {
  %7 = alloca i32, align 4
  %8 = load double, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %7) #4
  %9 = load i8, ptr %0, align 1, !tbaa !9
  switch i8 %9, label %10 [
    i8 85, label %.critedge
    i8 117, label %.critedge
    i8 76, label %.critedge
    i8 108, label %.critedge
  ]

10:                                               ; preds = %6
  store i32 1, ptr %7, align 4, !tbaa !10
  br label %.thread

.critedge:                                        ; preds = %6, %6, %6, %6
  %11 = load i32, ptr %1, align 4, !tbaa !10
  %12 = icmp slt i32 %11, 0
  br i1 %12, label %13, label %14

13:                                               ; preds = %.critedge
  store i32 2, ptr %7, align 4, !tbaa !10
  br label %.thread

14:                                               ; preds = %.critedge
  %15 = load i32, ptr %4, align 4, !tbaa !10
  %16 = icmp eq i32 %15, 0
  br i1 %16, label %17, label %19

17:                                               ; preds = %14
  store i32 5, ptr %7, align 4, !tbaa !10
  br label %.thread

.thread:                                          ; preds = %10, %17, %13
  %18 = call i32 @xerbla_(ptr noundef nonnull @.str.10, ptr noundef nonnull %7, i32 noundef 6)
  br label %32

19:                                               ; preds = %14
  %20 = fcmp oeq double %8, 0.000000e+00
  br i1 %20, label %32, label %21

21:                                               ; preds = %19
  %22 = tail call noundef ptr @_Z18get_compact_vectorIdEPT_S1_ii(ptr noundef %3, i32 noundef %11, i32 noundef %15)
  %23 = load i8, ptr %0, align 1, !tbaa !9
  switch i8 %23, label %32 [
    i8 85, label %select.unfold
    i8 117, label %select.unfold
    i8 76, label %24
    i8 108, label %select.unfold.fold.split
  ]

24:                                               ; preds = %21
  br label %select.unfold

select.unfold.fold.split:                         ; preds = %21
  br label %select.unfold

select.unfold:                                    ; preds = %21, %21, %select.unfold.fold.split, %24
  %.ph = phi i64 [ 1, %24 ], [ 0, %21 ], [ 0, %21 ], [ 1, %select.unfold.fold.split ]
  %25 = getelementptr inbounds [2 x ptr], ptr @_ZZ5dspr_E4func, i64 0, i64 %.ph
  %26 = load ptr, ptr %25, align 8, !tbaa !12
  %27 = icmp eq ptr %26, null
  br i1 %27, label %32, label %28

28:                                               ; preds = %select.unfold
  %29 = load i32, ptr %1, align 4, !tbaa !10
  tail call void %26(i32 noundef %29, ptr noundef %5, ptr noundef %22, double noundef %8)
  %.not33 = icmp eq ptr %22, %3
  %30 = icmp eq ptr %22, null
  %or.cond = or i1 %.not33, %30
  br i1 %or.cond, label %32, label %31

31:                                               ; preds = %28
  tail call void @_ZdaPv(ptr noundef nonnull %22) #5
  br label %32

32:                                               ; preds = %21, %select.unfold, %31, %28, %19, %.thread
  %.1 = phi i32 [ %18, %.thread ], [ 1, %19 ], [ 0, %select.unfold ], [ 1, %31 ], [ 1, %28 ], [ 0, %21 ]
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %7) #4
  ret i32 %.1
}

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { "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 #2 = { mustprogress 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 #3 = { nobuiltin 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 #4 = { nounwind }
attributes #5 = { builtin 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 = !{!"double", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!7, !7, i64 0}
!10 = !{!11, !11, i64 0}
!11 = !{!"int", !7, i64 0}
!12 = !{!13, !13, i64 0}
!13 = !{!"any pointer", !7, i64 0}


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