; LLVM IR from ermig1979/Simd :: src/Simd (SimdBaseRecursiveBilateralFilter)

; 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.Simd::RbfParam" = type <{ i64, i64, i64, float, float, i32, [4 x i8], i64, float, [256 x float], [4 x i8] }>

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZNK4Simd8RbfParam5ValidEv(ptr noundef nonnull align 8 dereferenceable(1076)) #0 align 2

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

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

declare i32 @__gxx_personality_v0(...)

; Function Attrs: mustprogress uwtable
define dso_local noundef ptr @_ZN4Simd4Base28RecursiveBilateralFilterInitEmmmPKfS2_33SimdRecursiveBilateralFilterFlags(i64 noundef %0, i64 noundef %1, i64 noundef %2, ptr noundef %3, ptr noundef %4, i32 noundef %5) #2 personality ptr @__gxx_personality_v0 {
  %7 = alloca ptr, align 8
  %8 = alloca i64, align 8
  %9 = alloca i64, align 8
  %10 = alloca i64, align 8
  %11 = alloca ptr, align 8
  %12 = alloca ptr, align 8
  %13 = alloca i32, align 4
  %14 = alloca %"struct.Simd::RbfParam", align 8
  %15 = alloca i32, align 4
  %16 = alloca ptr, align 8
  %17 = alloca i32, align 4
  store i64 %0, ptr %8, align 8, !tbaa !5
  store i64 %1, ptr %9, align 8, !tbaa !5
  store i64 %2, ptr %10, align 8, !tbaa !5
  store ptr %3, ptr %11, align 8, !tbaa !9
  store ptr %4, ptr %12, align 8, !tbaa !9
  store i32 %5, ptr %13, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 1080, ptr %14) #6
  %18 = load i64, ptr %8, align 8, !tbaa !5
  %19 = load i64, ptr %9, align 8, !tbaa !5
  %20 = load i64, ptr %10, align 8, !tbaa !5
  %21 = load ptr, ptr %11, align 8, !tbaa !9
  %22 = load ptr, ptr %12, align 8, !tbaa !9
  %23 = load i32, ptr %13, align 4, !tbaa !11
  call void @_ZN4Simd8RbfParamC1EmmmPKfS2_33SimdRecursiveBilateralFilterFlagsm(ptr noundef nonnull align 8 dereferenceable(1076) %14, i64 noundef %18, i64 noundef %19, i64 noundef %20, ptr noundef %21, ptr noundef %22, i32 noundef %23, i64 noundef 8)
  %24 = call noundef zeroext i1 @_ZNK4Simd8RbfParam5ValidEv(ptr noundef nonnull align 8 dereferenceable(1076) %14)
  br i1 %24, label %26, label %25

25:                                               ; preds = %6
  store ptr null, ptr %7, align 8
  store i32 1, ptr %15, align 4
  br label %43

26:                                               ; preds = %6
  %27 = load i32, ptr %13, align 4, !tbaa !11
  %28 = call noundef zeroext i1 @_ZN4Simd7PreciseE33SimdRecursiveBilateralFilterFlags(i32 noundef %27)
  br i1 %28, label %29, label %36

29:                                               ; preds = %26
  %30 = call noalias noundef nonnull ptr @_Znwm(i64 noundef 1120) #7
  invoke void @_ZN4Simd4Base31RecursiveBilateralFilterPrecizeC1ERKNS_8RbfParamE(ptr noundef nonnull align 8 dereferenceable(1120) %30, ptr noundef nonnull align 8 dereferenceable(1076) %14)
          to label %31 unwind label %32

31:                                               ; preds = %29
  store ptr %30, ptr %7, align 8
  store i32 1, ptr %15, align 4
  br label %43

32:                                               ; preds = %29
  %33 = landingpad { ptr, i32 }
          cleanup
  %34 = extractvalue { ptr, i32 } %33, 0
  store ptr %34, ptr %16, align 8
  %35 = extractvalue { ptr, i32 } %33, 1
  store i32 %35, ptr %17, align 4
  call void @_ZdlPvm(ptr noundef %30, i64 noundef 1120) #8
  br label %45

36:                                               ; preds = %26
  %37 = call noalias noundef nonnull ptr @_Znwm(i64 noundef 1136) #7
  invoke void @_ZN4Simd4Base28RecursiveBilateralFilterFastC1ERKNS_8RbfParamE(ptr noundef nonnull align 8 dereferenceable(1136) %37, ptr noundef nonnull align 8 dereferenceable(1076) %14)
          to label %38 unwind label %39

38:                                               ; preds = %36
  store ptr %37, ptr %7, align 8
  store i32 1, ptr %15, align 4
  br label %43

39:                                               ; preds = %36
  %40 = landingpad { ptr, i32 }
          cleanup
  %41 = extractvalue { ptr, i32 } %40, 0
  store ptr %41, ptr %16, align 8
  %42 = extractvalue { ptr, i32 } %40, 1
  store i32 %42, ptr %17, align 4
  call void @_ZdlPvm(ptr noundef %37, i64 noundef 1136) #8
  br label %45

43:                                               ; preds = %38, %31, %25
  call void @llvm.lifetime.end.p0(i64 1080, ptr %14) #6
  %44 = load ptr, ptr %7, align 8
  ret ptr %44

45:                                               ; preds = %39, %32
  call void @llvm.lifetime.end.p0(i64 1080, ptr %14) #6
  br label %46

46:                                               ; preds = %45
  %47 = load ptr, ptr %16, align 8
  %48 = load i32, ptr %17, align 4
  %49 = insertvalue { ptr, i32 } poison, ptr %47, 0
  %50 = insertvalue { ptr, i32 } %49, i32 %48, 1
  resume { ptr, i32 } %50
}

; Function Attrs: alwaysinline mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZN4Simd7PreciseE33SimdRecursiveBilateralFilterFlags(i32 noundef) #3

; Function Attrs: nobuiltin allocsize(0)
declare noundef nonnull ptr @_Znwm(i64 noundef) #4

; Function Attrs: nobuiltin nounwind
declare void @_ZdlPvm(ptr noundef, i64 noundef) #5

declare void @_ZN4Simd8RbfParamC1EmmmPKfS2_33SimdRecursiveBilateralFilterFlagsm(ptr, i64, i64, i64, ptr, ptr, i32, i64)

declare void @_ZN4Simd4Base31RecursiveBilateralFilterPrecizeC1ERKNS_8RbfParamE(ptr, ptr)

declare void @_ZN4Simd4Base28RecursiveBilateralFilterFastC1ERKNS_8RbfParamE(ptr, ptr)

attributes #0 = { mustprogress 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 = { 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 = { alwaysinline mustprogress 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 = { nobuiltin 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 = { 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 #6 = { nounwind }
attributes #7 = { builtin allocsize(0) }
attributes #8 = { 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 = !{!"long", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"_ZTS33SimdRecursiveBilateralFilterFlags", !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"

%"struct.Simd::RbfParam" = type <{ i64, i64, i64, float, float, i32, [4 x i8], i64, float, [256 x float], [4 x i8] }>

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZNK4Simd8RbfParam5ValidEv(ptr noundef nonnull align 8 dereferenceable(1076)) local_unnamed_addr #0 align 2

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

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

declare i32 @__gxx_personality_v0(...)

; Function Attrs: mustprogress uwtable
define dso_local noundef ptr @_ZN4Simd4Base28RecursiveBilateralFilterInitEmmmPKfS2_33SimdRecursiveBilateralFilterFlags(i64 noundef %0, i64 noundef %1, i64 noundef %2, ptr noundef %3, ptr noundef %4, i32 noundef %5) local_unnamed_addr #2 personality ptr @__gxx_personality_v0 {
  %7 = alloca %"struct.Simd::RbfParam", align 8
  call void @llvm.lifetime.start.p0(i64 1080, ptr nonnull %7) #6
  call void @_ZN4Simd8RbfParamC1EmmmPKfS2_33SimdRecursiveBilateralFilterFlagsm(ptr noundef nonnull align 8 dereferenceable(1076) %7, i64 noundef %0, i64 noundef %1, i64 noundef %2, ptr noundef %3, ptr noundef %4, i32 noundef %5, i64 noundef 8)
  %8 = call noundef zeroext i1 @_ZNK4Simd8RbfParam5ValidEv(ptr noundef nonnull align 8 dereferenceable(1076) %7)
  br i1 %8, label %9, label %19

9:                                                ; preds = %6
  %10 = call noundef zeroext i1 @_ZN4Simd7PreciseE33SimdRecursiveBilateralFilterFlags(i32 noundef %5)
  br i1 %10, label %11, label %15

11:                                               ; preds = %9
  %12 = call noalias noundef nonnull dereferenceable(1120) ptr @_Znwm(i64 noundef 1120) #7
  invoke void @_ZN4Simd4Base31RecursiveBilateralFilterPrecizeC1ERKNS_8RbfParamE(ptr noundef nonnull align 8 dereferenceable(1120) %12, ptr noundef nonnull align 8 dereferenceable(1076) %7)
          to label %19 unwind label %13

13:                                               ; preds = %11
  %14 = landingpad { ptr, i32 }
          cleanup
  call void @_ZdlPvm(ptr noundef nonnull %12, i64 noundef 1120) #8
  br label %20

15:                                               ; preds = %9
  %16 = call noalias noundef nonnull dereferenceable(1136) ptr @_Znwm(i64 noundef 1136) #7
  invoke void @_ZN4Simd4Base28RecursiveBilateralFilterFastC1ERKNS_8RbfParamE(ptr noundef nonnull align 8 dereferenceable(1136) %16, ptr noundef nonnull align 8 dereferenceable(1076) %7)
          to label %19 unwind label %17

17:                                               ; preds = %15
  %18 = landingpad { ptr, i32 }
          cleanup
  call void @_ZdlPvm(ptr noundef nonnull %16, i64 noundef 1136) #8
  br label %20

19:                                               ; preds = %15, %11, %6
  %.010 = phi ptr [ null, %6 ], [ %12, %11 ], [ %16, %15 ]
  call void @llvm.lifetime.end.p0(i64 1080, ptr nonnull %7) #6
  ret ptr %.010

20:                                               ; preds = %17, %13
  %.pn = phi { ptr, i32 } [ %14, %13 ], [ %18, %17 ]
  call void @llvm.lifetime.end.p0(i64 1080, ptr nonnull %7) #6
  resume { ptr, i32 } %.pn
}

; Function Attrs: alwaysinline mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZN4Simd7PreciseE33SimdRecursiveBilateralFilterFlags(i32 noundef) local_unnamed_addr #3

; Function Attrs: nobuiltin allocsize(0)
declare noundef nonnull ptr @_Znwm(i64 noundef) local_unnamed_addr #4

; Function Attrs: nobuiltin nounwind
declare void @_ZdlPvm(ptr noundef, i64 noundef) local_unnamed_addr #5

declare void @_ZN4Simd8RbfParamC1EmmmPKfS2_33SimdRecursiveBilateralFilterFlagsm(ptr, i64, i64, i64, ptr, ptr, i32, i64) local_unnamed_addr

declare void @_ZN4Simd4Base31RecursiveBilateralFilterPrecizeC1ERKNS_8RbfParamE(ptr, ptr) local_unnamed_addr

declare void @_ZN4Simd4Base28RecursiveBilateralFilterFastC1ERKNS_8RbfParamE(ptr, ptr) local_unnamed_addr

attributes #0 = { mustprogress 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 = { 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 = { alwaysinline mustprogress 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 = { nobuiltin 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 = { 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 #6 = { nounwind }
attributes #7 = { builtin allocsize(0) }
attributes #8 = { 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)"}


; Effective O3 passes: CorrelatedValuePropagationPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,SROAPass,SimplifyCFGPass