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

@_ZZ6dspr2_E4func = external hidden constant [2 x ptr], align 16
@.str.11 = 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 @dspr2_(ptr noundef %0, ptr noundef %1, ptr noundef %2, ptr noundef %3, ptr noundef %4, ptr noundef %5, ptr noundef %6, ptr noundef %7) #2 {
  %9 = alloca i32, align 4
  %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 ptr, align 8
  %17 = alloca ptr, align 8
  %18 = alloca ptr, align 8
  %19 = alloca ptr, align 8
  %20 = alloca ptr, align 8
  %21 = alloca double, align 8
  %22 = alloca i32, align 4
  %23 = alloca i32, align 4
  %24 = alloca ptr, align 8
  %25 = alloca ptr, align 8
  %26 = alloca i32, align 4
  store ptr %0, ptr %10, align 8, !tbaa !5
  store ptr %1, ptr %11, align 8, !tbaa !5
  store ptr %2, ptr %12, align 8, !tbaa !5
  store ptr %3, ptr %13, align 8, !tbaa !5
  store ptr %4, ptr %14, align 8, !tbaa !5
  store ptr %5, ptr %15, align 8, !tbaa !5
  store ptr %6, ptr %16, align 8, !tbaa !5
  store ptr %7, ptr %17, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %18) #4
  %27 = load ptr, ptr %13, align 8, !tbaa !5
  store ptr %27, ptr %18, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %19) #4
  %28 = load ptr, ptr %15, align 8, !tbaa !5
  store ptr %28, ptr %19, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %20) #4
  %29 = load ptr, ptr %17, align 8, !tbaa !5
  store ptr %29, ptr %20, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %21) #4
  %30 = load ptr, ptr %12, align 8, !tbaa !5
  %31 = load double, ptr %30, align 8, !tbaa !9
  store double %31, ptr %21, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %22) #4
  store i32 0, ptr %22, align 4, !tbaa !11
  %32 = load ptr, ptr %10, align 8, !tbaa !5
  %33 = load i8, ptr %32, align 1, !tbaa !13
  %34 = sext i8 %33 to i32
  %35 = icmp eq i32 %34, 85
  br i1 %35, label %41, label %36

36:                                               ; preds = %8
  %37 = load ptr, ptr %10, align 8, !tbaa !5
  %38 = load i8, ptr %37, align 1, !tbaa !13
  %39 = sext i8 %38 to i32
  %40 = icmp eq i32 %39, 117
  br i1 %40, label %41, label %42

41:                                               ; preds = %36, %8
  br label %56

42:                                               ; preds = %36
  %43 = load ptr, ptr %10, align 8, !tbaa !5
  %44 = load i8, ptr %43, align 1, !tbaa !13
  %45 = sext i8 %44 to i32
  %46 = icmp eq i32 %45, 76
  br i1 %46, label %52, label %47

47:                                               ; preds = %42
  %48 = load ptr, ptr %10, align 8, !tbaa !5
  %49 = load i8, ptr %48, align 1, !tbaa !13
  %50 = sext i8 %49 to i32
  %51 = icmp eq i32 %50, 108
  br label %52

52:                                               ; preds = %47, %42
  %53 = phi i1 [ true, %42 ], [ %51, %47 ]
  %54 = zext i1 %53 to i64
  %55 = select i1 %53, i32 1, i32 255
  br label %56

56:                                               ; preds = %52, %41
  %57 = phi i32 [ 0, %41 ], [ %55, %52 ]
  %58 = icmp eq i32 %57, 255
  br i1 %58, label %59, label %60

59:                                               ; preds = %56
  store i32 1, ptr %22, align 4, !tbaa !11
  br label %78

60:                                               ; preds = %56
  %61 = load ptr, ptr %11, align 8, !tbaa !5
  %62 = load i32, ptr %61, align 4, !tbaa !11
  %63 = icmp slt i32 %62, 0
  br i1 %63, label %64, label %65

64:                                               ; preds = %60
  store i32 2, ptr %22, align 4, !tbaa !11
  br label %77

65:                                               ; preds = %60
  %66 = load ptr, ptr %14, align 8, !tbaa !5
  %67 = load i32, ptr %66, align 4, !tbaa !11
  %68 = icmp eq i32 %67, 0
  br i1 %68, label %69, label %70

69:                                               ; preds = %65
  store i32 5, ptr %22, align 4, !tbaa !11
  br label %76

70:                                               ; preds = %65
  %71 = load ptr, ptr %16, align 8, !tbaa !5
  %72 = load i32, ptr %71, align 4, !tbaa !11
  %73 = icmp eq i32 %72, 0
  br i1 %73, label %74, label %75

74:                                               ; preds = %70
  store i32 7, ptr %22, align 4, !tbaa !11
  br label %75

75:                                               ; preds = %74, %70
  br label %76

76:                                               ; preds = %75, %69
  br label %77

77:                                               ; preds = %76, %64
  br label %78

78:                                               ; preds = %77, %59
  %79 = load i32, ptr %22, align 4, !tbaa !11
  %80 = icmp ne i32 %79, 0
  br i1 %80, label %81, label %83

81:                                               ; preds = %78
  %82 = call i32 @xerbla_(ptr noundef @.str.11, ptr noundef %22, i32 noundef 6)
  store i32 %82, ptr %9, align 4
  store i32 1, ptr %23, align 4
  br label %165

83:                                               ; preds = %78
  %84 = load double, ptr %21, align 8, !tbaa !9
  %85 = fcmp oeq double %84, 0.000000e+00
  br i1 %85, label %86, label %87

86:                                               ; preds = %83
  store i32 1, ptr %9, align 4
  store i32 1, ptr %23, align 4
  br label %165

87:                                               ; preds = %83
  call void @llvm.lifetime.start.p0(i64 8, ptr %24) #4
  %88 = load ptr, ptr %18, align 8, !tbaa !5
  %89 = load ptr, ptr %11, align 8, !tbaa !5
  %90 = load i32, ptr %89, align 4, !tbaa !11
  %91 = load ptr, ptr %14, align 8, !tbaa !5
  %92 = load i32, ptr %91, align 4, !tbaa !11
  %93 = call noundef ptr @_Z18get_compact_vectorIdEPT_S1_ii(ptr noundef %88, i32 noundef %90, i32 noundef %92)
  store ptr %93, ptr %24, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %25) #4
  %94 = load ptr, ptr %19, align 8, !tbaa !5
  %95 = load ptr, ptr %11, align 8, !tbaa !5
  %96 = load i32, ptr %95, align 4, !tbaa !11
  %97 = load ptr, ptr %16, align 8, !tbaa !5
  %98 = load i32, ptr %97, align 4, !tbaa !11
  %99 = call noundef ptr @_Z18get_compact_vectorIdEPT_S1_ii(ptr noundef %94, i32 noundef %96, i32 noundef %98)
  store ptr %99, ptr %25, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %26) #4
  %100 = load ptr, ptr %10, align 8, !tbaa !5
  %101 = load i8, ptr %100, align 1, !tbaa !13
  %102 = sext i8 %101 to i32
  %103 = icmp eq i32 %102, 85
  br i1 %103, label %109, label %104

104:                                              ; preds = %87
  %105 = load ptr, ptr %10, align 8, !tbaa !5
  %106 = load i8, ptr %105, align 1, !tbaa !13
  %107 = sext i8 %106 to i32
  %108 = icmp eq i32 %107, 117
  br i1 %108, label %109, label %110

109:                                              ; preds = %104, %87
  br label %124

110:                                              ; preds = %104
  %111 = load ptr, ptr %10, align 8, !tbaa !5
  %112 = load i8, ptr %111, align 1, !tbaa !13
  %113 = sext i8 %112 to i32
  %114 = icmp eq i32 %113, 76
  br i1 %114, label %120, label %115

115:                                              ; preds = %110
  %116 = load ptr, ptr %10, align 8, !tbaa !5
  %117 = load i8, ptr %116, align 1, !tbaa !13
  %118 = sext i8 %117 to i32
  %119 = icmp eq i32 %118, 108
  br label %120

120:                                              ; preds = %115, %110
  %121 = phi i1 [ true, %110 ], [ %119, %115 ]
  %122 = zext i1 %121 to i64
  %123 = select i1 %121, i32 1, i32 255
  br label %124

124:                                              ; preds = %120, %109
  %125 = phi i32 [ 0, %109 ], [ %123, %120 ]
  store i32 %125, ptr %26, align 4, !tbaa !11
  %126 = load i32, ptr %26, align 4, !tbaa !11
  %127 = icmp sge i32 %126, 2
  br i1 %127, label %134, label %128

128:                                              ; preds = %124
  %129 = load i32, ptr %26, align 4, !tbaa !11
  %130 = sext i32 %129 to i64
  %131 = getelementptr inbounds [2 x ptr], ptr @_ZZ6dspr2_E4func, i64 0, i64 %130
  %132 = load ptr, ptr %131, align 8, !tbaa !5
  %133 = icmp eq ptr %132, null
  br i1 %133, label %134, label %135

134:                                              ; preds = %128, %124
  store i32 0, ptr %9, align 4
  store i32 1, ptr %23, align 4
  br label %164

135:                                              ; preds = %128
  %136 = load i32, ptr %26, align 4, !tbaa !11
  %137 = sext i32 %136 to i64
  %138 = getelementptr inbounds [2 x ptr], ptr @_ZZ6dspr2_E4func, i64 0, i64 %137
  %139 = load ptr, ptr %138, align 8, !tbaa !5
  %140 = load ptr, ptr %11, align 8, !tbaa !5
  %141 = load i32, ptr %140, align 4, !tbaa !11
  %142 = load ptr, ptr %20, align 8, !tbaa !5
  %143 = load ptr, ptr %24, align 8, !tbaa !5
  %144 = load ptr, ptr %25, align 8, !tbaa !5
  %145 = load double, ptr %21, align 8, !tbaa !9
  call void %139(i32 noundef %141, ptr noundef %142, ptr noundef %143, ptr noundef %144, double noundef %145)
  %146 = load ptr, ptr %24, align 8, !tbaa !5
  %147 = load ptr, ptr %18, align 8, !tbaa !5
  %148 = icmp ne ptr %146, %147
  br i1 %148, label %149, label %154

149:                                              ; preds = %135
  %150 = load ptr, ptr %24, align 8, !tbaa !5
  %151 = icmp eq ptr %150, null
  br i1 %151, label %153, label %152

152:                                              ; preds = %149
  call void @_ZdaPv(ptr noundef %150) #5
  br label %153

153:                                              ; preds = %152, %149
  br label %154

154:                                              ; preds = %153, %135
  %155 = load ptr, ptr %25, align 8, !tbaa !5
  %156 = load ptr, ptr %19, align 8, !tbaa !5
  %157 = icmp ne ptr %155, %156
  br i1 %157, label %158, label %163

158:                                              ; preds = %154
  %159 = load ptr, ptr %25, align 8, !tbaa !5
  %160 = icmp eq ptr %159, null
  br i1 %160, label %162, label %161

161:                                              ; preds = %158
  call void @_ZdaPv(ptr noundef %159) #5
  br label %162

162:                                              ; preds = %161, %158
  br label %163

163:                                              ; preds = %162, %154
  store i32 1, ptr %9, align 4
  store i32 1, ptr %23, align 4
  br label %164

164:                                              ; preds = %163, %134
  call void @llvm.lifetime.end.p0(i64 4, ptr %26) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %25) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %24) #4
  br label %165

165:                                              ; preds = %164, %86, %81
  call void @llvm.lifetime.end.p0(i64 4, ptr %22) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %21) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %20) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %19) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %18) #4
  %166 = load i32, ptr %9, align 4
  ret i32 %166
}

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"

@_ZZ6dspr2_E4func = external hidden local_unnamed_addr constant [2 x ptr], align 16
@.str.11 = 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 @dspr2_(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, ptr nocapture noundef readonly %6, ptr noundef %7) local_unnamed_addr #2 {
  %9 = alloca i32, align 4
  %10 = load double, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %9) #4
  %11 = load i8, ptr %0, align 1, !tbaa !9
  switch i8 %11, label %12 [
    i8 85, label %.critedge
    i8 117, label %.critedge
    i8 76, label %.critedge
    i8 108, label %.critedge
  ]

12:                                               ; preds = %8
  store i32 1, ptr %9, align 4, !tbaa !10
  br label %.thread

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

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

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

19:                                               ; preds = %16
  store i32 5, ptr %9, align 4, !tbaa !10
  br label %.thread

20:                                               ; preds = %16
  %21 = load i32, ptr %6, align 4, !tbaa !10
  %22 = icmp eq i32 %21, 0
  br i1 %22, label %23, label %25

23:                                               ; preds = %20
  store i32 7, ptr %9, align 4, !tbaa !10
  br label %.thread

.thread:                                          ; preds = %12, %19, %23, %15
  %24 = call i32 @xerbla_(ptr noundef nonnull @.str.11, ptr noundef nonnull %9, i32 noundef 6)
  br label %44

25:                                               ; preds = %20
  %26 = fcmp oeq double %10, 0.000000e+00
  br i1 %26, label %44, label %27

27:                                               ; preds = %25
  %28 = tail call noundef ptr @_Z18get_compact_vectorIdEPT_S1_ii(ptr noundef %3, i32 noundef %13, i32 noundef %17)
  %29 = load i32, ptr %1, align 4, !tbaa !10
  %30 = load i32, ptr %6, align 4, !tbaa !10
  %31 = tail call noundef ptr @_Z18get_compact_vectorIdEPT_S1_ii(ptr noundef %5, i32 noundef %29, i32 noundef %30)
  %32 = load i8, ptr %0, align 1, !tbaa !9
  switch i8 %32, label %44 [
    i8 85, label %select.unfold
    i8 117, label %select.unfold
    i8 76, label %33
    i8 108, label %select.unfold.fold.split
  ]

33:                                               ; preds = %27
  br label %select.unfold

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

select.unfold:                                    ; preds = %27, %27, %select.unfold.fold.split, %33
  %.ph = phi i64 [ 1, %33 ], [ 0, %27 ], [ 0, %27 ], [ 1, %select.unfold.fold.split ]
  %34 = getelementptr inbounds [2 x ptr], ptr @_ZZ6dspr2_E4func, i64 0, i64 %.ph
  %35 = load ptr, ptr %34, align 8, !tbaa !12
  %36 = icmp eq ptr %35, null
  br i1 %36, label %44, label %37

37:                                               ; preds = %select.unfold
  %38 = load i32, ptr %1, align 4, !tbaa !10
  tail call void %35(i32 noundef %38, ptr noundef %7, ptr noundef %28, ptr noundef %31, double noundef %10)
  %.not43 = icmp eq ptr %28, %3
  %39 = icmp eq ptr %28, null
  %or.cond = or i1 %.not43, %39
  br i1 %or.cond, label %41, label %40

40:                                               ; preds = %37
  tail call void @_ZdaPv(ptr noundef nonnull %28) #5
  br label %41

41:                                               ; preds = %40, %37
  %.not44 = icmp eq ptr %31, %5
  %42 = icmp eq ptr %31, null
  %or.cond45 = or i1 %.not44, %42
  br i1 %or.cond45, label %44, label %43

43:                                               ; preds = %41
  tail call void @_ZdaPv(ptr noundef nonnull %31) #5
  br label %44

44:                                               ; preds = %27, %select.unfold, %43, %41, %25, %.thread
  %.1 = phi i32 [ %24, %.thread ], [ 1, %25 ], [ 0, %select.unfold ], [ 1, %43 ], [ 1, %41 ], [ 0, %27 ]
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %9) #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