; LLVM IR from ljm941004/HYPERCV_PUBLIC :: modules/process/src/c_src (filter)

; 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.SIMPLE_MAT = type { i32, i32, i32, i32, i32, ptr }

@.str = external hidden unnamed_addr constant [8 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [27 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [18 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [32 x i8], align 1

declare i32 @printf(ptr noundef, ...) #0

; Function Attrs: noreturn nounwind
declare void @exit(i32 noundef) #1

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

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

; Function Attrs: nounwind uwtable
declare dso_local ptr @gaussian_kernel(i32 noundef, double noundef, i32 noundef) #3

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.fmuladd.f64(double, double, double) #4

; Function Attrs: nounwind uwtable
define dso_local void @hypercv_gaussian_blur(ptr noundef %0, ptr noundef %1, i32 noundef %2, i32 noundef %3, double noundef %4, double noundef %5, i32 noundef %6) #3 {
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca double, align 8
  %13 = alloca double, align 8
  %14 = alloca i32, align 4
  %15 = alloca i32, align 4
  %16 = alloca i32, align 4
  %17 = alloca ptr, align 8
  %18 = alloca ptr, align 8
  store ptr %0, ptr %8, align 8, !tbaa !5
  store ptr %1, ptr %9, align 8, !tbaa !5
  store i32 %2, ptr %10, align 4, !tbaa !9
  store i32 %3, ptr %11, align 4, !tbaa !9
  store double %4, ptr %12, align 8, !tbaa !11
  store double %5, ptr %13, align 8, !tbaa !11
  store i32 %6, ptr %14, align 4, !tbaa !9
  %19 = load ptr, ptr %8, align 8, !tbaa !5
  %20 = icmp ne ptr %19, null
  br i1 %20, label %21, label %22

21:                                               ; preds = %7
  br label %26

22:                                               ; preds = %7
  %23 = call i32 (ptr, ...) @printf(ptr noundef @.str)
  %24 = call i32 (ptr, ...) @printf(ptr noundef @.str.9)
  %25 = call i32 (ptr, ...) @printf(ptr noundef @.str.2)
  call void @exit(i32 noundef 1) #6
  unreachable

26:                                               ; preds = %21
  %27 = load i32, ptr %10, align 4, !tbaa !9
  %28 = icmp sgt i32 %27, 0
  br i1 %28, label %29, label %41

29:                                               ; preds = %26
  %30 = load i32, ptr %10, align 4, !tbaa !9
  %31 = srem i32 %30, 2
  %32 = icmp eq i32 %31, 1
  br i1 %32, label %33, label %41

33:                                               ; preds = %29
  %34 = load i32, ptr %11, align 4, !tbaa !9
  %35 = icmp sgt i32 %34, 0
  br i1 %35, label %36, label %41

36:                                               ; preds = %33
  %37 = load i32, ptr %11, align 4, !tbaa !9
  %38 = srem i32 %37, 2
  %39 = icmp eq i32 %38, 1
  br i1 %39, label %40, label %41

40:                                               ; preds = %36
  br label %45

41:                                               ; preds = %36, %33, %29, %26
  %42 = call i32 (ptr, ...) @printf(ptr noundef @.str)
  %43 = call i32 (ptr, ...) @printf(ptr noundef @.str.10)
  %44 = call i32 (ptr, ...) @printf(ptr noundef @.str.2)
  call void @exit(i32 noundef 1) #6
  unreachable

45:                                               ; preds = %40
  %46 = load i32, ptr %14, align 4, !tbaa !9
  %47 = icmp eq i32 %46, 2
  br i1 %47, label %60, label %48

48:                                               ; preds = %45
  %49 = load i32, ptr %14, align 4, !tbaa !9
  %50 = icmp eq i32 %49, 4
  br i1 %50, label %60, label %51

51:                                               ; preds = %48
  %52 = load i32, ptr %14, align 4, !tbaa !9
  %53 = icmp eq i32 %52, 1
  br i1 %53, label %60, label %54

54:                                               ; preds = %51
  %55 = load i32, ptr %14, align 4, !tbaa !9
  %56 = icmp eq i32 %55, 3
  br i1 %56, label %60, label %57

57:                                               ; preds = %54
  %58 = load i32, ptr %14, align 4, !tbaa !9
  %59 = icmp eq i32 %58, 0
  br i1 %59, label %60, label %61

60:                                               ; preds = %57, %54, %51, %48, %45
  br label %65

61:                                               ; preds = %57
  %62 = call i32 (ptr, ...) @printf(ptr noundef @.str)
  %63 = call i32 (ptr, ...) @printf(ptr noundef @.str.11)
  %64 = call i32 (ptr, ...) @printf(ptr noundef @.str.2)
  call void @exit(i32 noundef 1) #6
  unreachable

65:                                               ; preds = %60
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #7
  %66 = load ptr, ptr %8, align 8, !tbaa !5
  %67 = getelementptr inbounds %struct.SIMPLE_MAT, ptr %66, i32 0, i32 2
  %68 = load i32, ptr %67, align 8, !tbaa !13
  store i32 %68, ptr %15, align 4, !tbaa !9
  %69 = load i32, ptr %14, align 4, !tbaa !9
  %70 = icmp ne i32 %69, 0
  br i1 %70, label %71, label %94

71:                                               ; preds = %65
  %72 = load i32, ptr %14, align 4, !tbaa !9
  %73 = and i32 %72, 16
  %74 = icmp ne i32 %73, 0
  br i1 %74, label %75, label %94

75:                                               ; preds = %71
  %76 = load ptr, ptr %8, align 8, !tbaa !5
  %77 = getelementptr inbounds %struct.SIMPLE_MAT, ptr %76, i32 0, i32 0
  %78 = load i32, ptr %77, align 8, !tbaa !15
  %79 = icmp eq i32 %78, 1
  br i1 %79, label %80, label %84

80:                                               ; preds = %75
  %81 = load i32, ptr %11, align 4, !tbaa !9
  %82 = icmp eq i32 %81, 1
  %83 = zext i1 %82 to i32
  br label %84

84:                                               ; preds = %80, %75
  %85 = load ptr, ptr %8, align 8, !tbaa !5
  %86 = getelementptr inbounds %struct.SIMPLE_MAT, ptr %85, i32 0, i32 1
  %87 = load i32, ptr %86, align 4, !tbaa !16
  %88 = icmp eq i32 %87, 1
  br i1 %88, label %89, label %93

89:                                               ; preds = %84
  %90 = load i32, ptr %10, align 4, !tbaa !9
  %91 = icmp eq i32 %90, 1
  %92 = zext i1 %91 to i32
  br label %93

93:                                               ; preds = %89, %84
  br label %94

94:                                               ; preds = %93, %71, %65
  %95 = load double, ptr %13, align 8, !tbaa !11
  %96 = fcmp ole double %95, 0.000000e+00
  br i1 %96, label %97, label %99

97:                                               ; preds = %94
  %98 = load double, ptr %12, align 8, !tbaa !11
  store double %98, ptr %13, align 8, !tbaa !11
  br label %99

99:                                               ; preds = %97, %94
  %100 = load i32, ptr %10, align 4, !tbaa !9
  %101 = icmp sle i32 %100, 0
  br i1 %101, label %102, label %110

102:                                              ; preds = %99
  %103 = load double, ptr %12, align 8, !tbaa !11
  %104 = fcmp ogt double %103, 0.000000e+00
  br i1 %104, label %105, label %110

105:                                              ; preds = %102
  %106 = load double, ptr %12, align 8, !tbaa !11
  %107 = call double @llvm.fmuladd.f64(double %106, double 6.000000e+00, double 1.000000e+00)
  %108 = call i32 @HYPERCV_ROUND(double noundef %107)
  %109 = or i32 %108, 1
  store i32 %109, ptr %10, align 4, !tbaa !9
  br label %110

110:                                              ; preds = %105, %102, %99
  %111 = load i32, ptr %10, align 4, !tbaa !9
  %112 = icmp sle i32 %111, 0
  br i1 %112, label %113, label %121

113:                                              ; preds = %110
  %114 = load double, ptr %13, align 8, !tbaa !11
  %115 = fcmp ogt double %114, 0.000000e+00
  br i1 %115, label %116, label %121

116:                                              ; preds = %113
  %117 = load double, ptr %13, align 8, !tbaa !11
  %118 = call double @llvm.fmuladd.f64(double %117, double 6.000000e+00, double 1.000000e+00)
  %119 = call i32 @HYPERCV_ROUND(double noundef %118)
  %120 = or i32 %119, 1
  store i32 %120, ptr %11, align 4, !tbaa !9
  br label %121

121:                                              ; preds = %116, %113, %110
  %122 = load double, ptr %12, align 8, !tbaa !11
  %123 = fcmp ogt double %122, 0.000000e+00
  br i1 %123, label %124, label %126

124:                                              ; preds = %121
  %125 = load double, ptr %12, align 8, !tbaa !11
  br label %127

126:                                              ; preds = %121
  br label %127

127:                                              ; preds = %126, %124
  %128 = phi double [ %125, %124 ], [ 0.000000e+00, %126 ]
  store double %128, ptr %12, align 8, !tbaa !11
  %129 = load double, ptr %13, align 8, !tbaa !11
  %130 = fcmp ogt double %129, 0.000000e+00
  br i1 %130, label %131, label %133

131:                                              ; preds = %127
  %132 = load double, ptr %13, align 8, !tbaa !11
  br label %134

133:                                              ; preds = %127
  br label %134

134:                                              ; preds = %133, %131
  %135 = phi double [ %132, %131 ], [ 0.000000e+00, %133 ]
  store double %135, ptr %13, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #7
  store i32 4, ptr %16, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %17) #7
  %136 = load i32, ptr %10, align 4, !tbaa !9
  %137 = load double, ptr %12, align 8, !tbaa !11
  %138 = load i32, ptr %16, align 4, !tbaa !9
  %139 = call ptr @gaussian_kernel(i32 noundef %136, double noundef %137, i32 noundef %138)
  store ptr %139, ptr %17, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %18) #7
  %140 = load i32, ptr %11, align 4, !tbaa !9
  %141 = load double, ptr %13, align 8, !tbaa !11
  %142 = load i32, ptr %16, align 4, !tbaa !9
  %143 = call ptr @gaussian_kernel(i32 noundef %140, double noundef %141, i32 noundef %142)
  store ptr %143, ptr %18, align 8, !tbaa !5
  %144 = load ptr, ptr %8, align 8, !tbaa !5
  %145 = load ptr, ptr %9, align 8, !tbaa !5
  %146 = load ptr, ptr %17, align 8, !tbaa !5
  %147 = load ptr, ptr %18, align 8, !tbaa !5
  %148 = load i32, ptr %14, align 4, !tbaa !9
  call void @hypercv_gaussian_blur_with_kernel(ptr noundef %144, ptr noundef %145, ptr noundef %146, ptr noundef %147, i32 noundef %148)
  call void @llvm.lifetime.end.p0(i64 8, ptr %18) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %17) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #7
  ret void
}

; Function Attrs: inlinehint nounwind uwtable
declare hidden i32 @HYPERCV_ROUND(double noundef) #5

; Function Attrs: nounwind uwtable
declare dso_local void @hypercv_gaussian_blur_with_kernel(ptr noundef, ptr noundef, ptr noundef, ptr noundef, i32 noundef) #3

attributes #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 = { noreturn 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 #2 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { 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 #4 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #5 = { inlinehint nounwind uwtable "min-legal-vector-width"="128" "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 = { noreturn nounwind }
attributes #7 = { 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 = !{!"int", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"double", !7, i64 0}
!13 = !{!14, !10, i64 8}
!14 = !{!"", !10, i64 0, !10, i64 4, !10, i64 8, !10, i64 12, !10, i64 16, !6, i64 24}
!15 = !{!14, !10, i64 0}
!16 = !{!14, !10, i64 4}


; 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 [8 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [27 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [18 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [32 x i8], align 1

; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #0

; Function Attrs: noreturn nounwind
declare void @exit(i32 noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare dso_local ptr @gaussian_kernel(i32 noundef, double noundef, i32 noundef) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
define dso_local void @hypercv_gaussian_blur(ptr noundef %0, ptr noundef %1, i32 noundef %2, i32 noundef %3, double noundef %4, double noundef %5, i32 noundef %6) local_unnamed_addr #2 {
  %.not = icmp eq ptr %0, null
  br i1 %.not, label %8, label %12

8:                                                ; preds = %7
  %9 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str)
  %10 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.9)
  %11 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2)
  tail call void @exit(i32 noundef 1) #3
  unreachable

12:                                               ; preds = %7
  %13 = icmp sgt i32 %2, 0
  br i1 %13, label %14, label %19

14:                                               ; preds = %12
  %15 = icmp slt i32 %3, 1
  %16 = and i32 %2, 1
  %17 = and i32 %16, %3
  %18 = icmp eq i32 %17, 0
  %or.cond62 = or i1 %15, %18
  br i1 %or.cond62, label %19, label %23

19:                                               ; preds = %14, %12
  %20 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str)
  %21 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.10)
  %22 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2)
  tail call void @exit(i32 noundef 1) #3
  unreachable

23:                                               ; preds = %14
  %or.cond9 = icmp ult i32 %6, 5
  br i1 %or.cond9, label %28, label %24

24:                                               ; preds = %23
  %25 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str)
  %26 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.11)
  %27 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2)
  tail call void @exit(i32 noundef 1) #3
  unreachable

28:                                               ; preds = %23
  %29 = fcmp ugt double %5, 0.000000e+00
  %.053 = select i1 %29, double %5, double %4
  %30 = fcmp ogt double %.053, 0.000000e+00
  %31 = fcmp ogt double %4, 0.000000e+00
  %32 = select i1 %31, double %4, double 0.000000e+00
  %33 = select i1 %30, double %.053, double 0.000000e+00
  %34 = tail call ptr @gaussian_kernel(i32 noundef %2, double noundef %32, i32 noundef 4)
  %35 = tail call ptr @gaussian_kernel(i32 noundef %3, double noundef %33, i32 noundef 4)
  tail call void @hypercv_gaussian_blur_with_kernel(ptr noundef nonnull %0, ptr noundef %1, ptr noundef %34, ptr noundef %35, i32 noundef %6)
  ret void
}

; Function Attrs: nounwind uwtable
declare dso_local void @hypercv_gaussian_blur_with_kernel(ptr noundef, ptr noundef, ptr noundef, ptr noundef, i32 noundef) local_unnamed_addr #2

attributes #0 = { nofree 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 #1 = { noreturn 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 #2 = { 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 #3 = { noreturn 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)"}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass