; LLVM IR from NVIDIA/DALI :: dali/kernels/imgproc/resample (resampling_setup)

; 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.dali::kernels::ResamplingFilter" = type { ptr, i32, float, float }
%"struct.dali::kernels::FilterDesc" = type { i8, i8, float }

@.str.1 = external hidden unnamed_addr constant [95 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [18 x i8], align 1
@__PRETTY_FUNCTION__._ZN4dali7kernels10resampling19GetResamplingFilterEPKNS0_17ResamplingFiltersERKNS0_10FilterDescE = external hidden unnamed_addr constant [111 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [17 x i8], align 1

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) #0

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #1

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_ZN4dali7kernels10resampling19GetResamplingFilterEPKNS0_17ResamplingFiltersERKNS0_10FilterDescE(ptr dead_on_unwind noalias writable sret(%"struct.dali::kernels::ResamplingFilter") align 8 %0, ptr noundef %1, ptr noundef nonnull align 4 dereferenceable(8) %2) #2 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  store ptr %1, ptr %4, align 8, !tbaa !5
  store ptr %2, ptr %5, align 8, !tbaa !5
  %6 = load ptr, ptr %5, align 8, !tbaa !5
  %7 = getelementptr inbounds %"struct.dali::kernels::FilterDesc", ptr %6, i32 0, i32 0
  %8 = load i8, ptr %7, align 4, !tbaa !9
  switch i8 %8, label %52 [
    i8 1, label %9
    i8 2, label %20
    i8 3, label %33
    i8 4, label %42
    i8 5, label %47
  ]

9:                                                ; preds = %3
  %10 = load ptr, ptr %5, align 8, !tbaa !5
  %11 = getelementptr inbounds %"struct.dali::kernels::FilterDesc", ptr %10, i32 0, i32 1
  %12 = load i8, ptr %11, align 1, !tbaa !14, !range !15, !noundef !16
  %13 = trunc i8 %12 to i1
  %14 = xor i1 %13, true
  br i1 %14, label %15, label %16

15:                                               ; preds = %9
  br label %18

16:                                               ; preds = %9
  call void @__assert_fail(ptr noundef @.str.4, ptr noundef @.str.1, i32 noundef 30, ptr noundef @__PRETTY_FUNCTION__._ZN4dali7kernels10resampling19GetResamplingFilterEPKNS0_17ResamplingFiltersERKNS0_10FilterDescE) #4
  unreachable

17:                                               ; No predecessors!
  br label %18

18:                                               ; preds = %17, %15
  %19 = load ptr, ptr %4, align 8, !tbaa !5
  call void @_ZNK4dali7kernels17ResamplingFilters10TriangularEf(ptr dead_on_unwind writable sret(%"struct.dali::kernels::ResamplingFilter") align 8 %0, ptr noundef nonnull align 8 dereferenceable(64) %19, float noundef 1.000000e+00) #5
  br label %57

20:                                               ; preds = %3
  %21 = load ptr, ptr %5, align 8, !tbaa !5
  %22 = getelementptr inbounds %"struct.dali::kernels::FilterDesc", ptr %21, i32 0, i32 1
  %23 = load i8, ptr %22, align 1, !tbaa !14, !range !15, !noundef !16
  %24 = trunc i8 %23 to i1
  br i1 %24, label %25, label %26

25:                                               ; preds = %20
  br label %28

26:                                               ; preds = %20
  call void @__assert_fail(ptr noundef @.str.5, ptr noundef @.str.1, i32 noundef 33, ptr noundef @__PRETTY_FUNCTION__._ZN4dali7kernels10resampling19GetResamplingFilterEPKNS0_17ResamplingFiltersERKNS0_10FilterDescE) #4
  unreachable

27:                                               ; No predecessors!
  br label %28

28:                                               ; preds = %27, %25
  %29 = load ptr, ptr %4, align 8, !tbaa !5
  %30 = load ptr, ptr %5, align 8, !tbaa !5
  %31 = getelementptr inbounds %"struct.dali::kernels::FilterDesc", ptr %30, i32 0, i32 2
  %32 = load float, ptr %31, align 4, !tbaa !17
  call void @_ZNK4dali7kernels17ResamplingFilters10TriangularEf(ptr dead_on_unwind writable sret(%"struct.dali::kernels::ResamplingFilter") align 8 %0, ptr noundef nonnull align 8 dereferenceable(64) %29, float noundef %32) #5
  br label %57

33:                                               ; preds = %3
  %34 = load ptr, ptr %4, align 8, !tbaa !5
  %35 = load ptr, ptr %5, align 8, !tbaa !5
  %36 = getelementptr inbounds %"struct.dali::kernels::FilterDesc", ptr %35, i32 0, i32 2
  %37 = load float, ptr %36, align 4, !tbaa !17
  %38 = fmul float %37, 5.000000e-01
  %39 = fpext float %38 to double
  %40 = fdiv double %39, 0x3FF6A09E667F3BCD
  %41 = fptrunc double %40 to float
  call void @_ZNK4dali7kernels17ResamplingFilters8GaussianEf(ptr dead_on_unwind writable sret(%"struct.dali::kernels::ResamplingFilter") align 8 %0, ptr noundef nonnull align 8 dereferenceable(64) %34, float noundef %41) #5
  br label %57

42:                                               ; preds = %3
  %43 = load ptr, ptr %4, align 8, !tbaa !5
  %44 = load ptr, ptr %5, align 8, !tbaa !5
  %45 = getelementptr inbounds %"struct.dali::kernels::FilterDesc", ptr %44, i32 0, i32 2
  %46 = load float, ptr %45, align 4, !tbaa !17
  call void @_ZNK4dali7kernels17ResamplingFilters5CubicEf(ptr dead_on_unwind writable sret(%"struct.dali::kernels::ResamplingFilter") align 8 %0, ptr noundef nonnull align 8 dereferenceable(64) %43, float noundef %46) #5
  br label %57

47:                                               ; preds = %3
  %48 = load ptr, ptr %4, align 8, !tbaa !5
  %49 = load ptr, ptr %5, align 8, !tbaa !5
  %50 = getelementptr inbounds %"struct.dali::kernels::FilterDesc", ptr %49, i32 0, i32 2
  %51 = load float, ptr %50, align 4, !tbaa !17
  call void @_ZNK4dali7kernels17ResamplingFilters8Lanczos3Ef(ptr dead_on_unwind writable sret(%"struct.dali::kernels::ResamplingFilter") align 8 %0, ptr noundef nonnull align 8 dereferenceable(64) %48, float noundef %51) #5
  br label %57

52:                                               ; preds = %3
  call void @llvm.memset.p0.i64(ptr align 8 %0, i8 0, i64 24, i1 false)
  %53 = getelementptr inbounds %"struct.dali::kernels::ResamplingFilter", ptr %0, i32 0, i32 0
  %54 = getelementptr inbounds %"struct.dali::kernels::ResamplingFilter", ptr %0, i32 0, i32 1
  %55 = getelementptr inbounds %"struct.dali::kernels::ResamplingFilter", ptr %0, i32 0, i32 2
  %56 = getelementptr inbounds %"struct.dali::kernels::ResamplingFilter", ptr %0, i32 0, i32 3
  store float 1.000000e+00, ptr %56, align 8, !tbaa !18
  br label %57

57:                                               ; preds = %52, %47, %42, %33, %28, %18
  ret void
}

; Function Attrs: nounwind
declare void @_ZNK4dali7kernels17ResamplingFilters10TriangularEf(ptr dead_on_unwind writable sret(%"struct.dali::kernels::ResamplingFilter") align 8, ptr noundef nonnull align 8 dereferenceable(64), float noundef) #3

; Function Attrs: nounwind
declare void @_ZNK4dali7kernels17ResamplingFilters8GaussianEf(ptr dead_on_unwind writable sret(%"struct.dali::kernels::ResamplingFilter") align 8, ptr noundef nonnull align 8 dereferenceable(64), float noundef) #3

; Function Attrs: nounwind
declare void @_ZNK4dali7kernels17ResamplingFilters5CubicEf(ptr dead_on_unwind writable sret(%"struct.dali::kernels::ResamplingFilter") align 8, ptr noundef nonnull align 8 dereferenceable(64), float noundef) #3

; Function Attrs: nounwind
declare void @_ZNK4dali7kernels17ResamplingFilters8Lanczos3Ef(ptr dead_on_unwind writable sret(%"struct.dali::kernels::ResamplingFilter") align 8, ptr noundef nonnull align 8 dereferenceable(64), float noundef) #3

attributes #0 = { 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 #1 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #2 = { 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 #3 = { 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 = { noreturn nounwind }
attributes #5 = { 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, !11, i64 0}
!10 = !{!"_ZTSN4dali7kernels10FilterDescE", !11, i64 0, !12, i64 1, !13, i64 4}
!11 = !{!"_ZTSN4dali7kernels20ResamplingFilterTypeE", !7, i64 0}
!12 = !{!"bool", !7, i64 0}
!13 = !{!"float", !7, i64 0}
!14 = !{!10, !12, i64 1}
!15 = !{i8 0, i8 2}
!16 = !{}
!17 = !{!10, !13, i64 4}
!18 = !{!19, !13, i64 16}
!19 = !{!"_ZTSN4dali7kernels16ResamplingFilterE", !6, i64 0, !20, i64 8, !13, i64 12, !13, i64 16}
!20 = !{!"int", !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.dali::kernels::ResamplingFilter" = type { ptr, i32, float, float }

@.str.1 = external hidden unnamed_addr constant [95 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [18 x i8], align 1
@__PRETTY_FUNCTION__._ZN4dali7kernels10resampling19GetResamplingFilterEPKNS0_17ResamplingFiltersERKNS0_10FilterDescE = external hidden unnamed_addr constant [111 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [17 x i8], align 1

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #0

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #1

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_ZN4dali7kernels10resampling19GetResamplingFilterEPKNS0_17ResamplingFiltersERKNS0_10FilterDescE(ptr dead_on_unwind noalias writable sret(%"struct.dali::kernels::ResamplingFilter") align 8 %0, ptr noundef %1, ptr nocapture noundef nonnull readonly align 4 dereferenceable(8) %2) local_unnamed_addr #2 {
  %4 = load i8, ptr %2, align 4, !tbaa !5
  switch i8 %4, label %32 [
    i8 1, label %5
    i8 2, label %11
    i8 3, label %19
    i8 4, label %26
    i8 5, label %29
  ]

5:                                                ; preds = %3
  %6 = getelementptr inbounds i8, ptr %2, i64 1
  %7 = load i8, ptr %6, align 1, !tbaa !12, !range !13, !noundef !14
  %8 = trunc nuw i8 %7 to i1
  br i1 %8, label %9, label %10

9:                                                ; preds = %5
  tail call void @__assert_fail(ptr noundef nonnull @.str.4, ptr noundef nonnull @.str.1, i32 noundef 30, ptr noundef nonnull @__PRETTY_FUNCTION__._ZN4dali7kernels10resampling19GetResamplingFilterEPKNS0_17ResamplingFiltersERKNS0_10FilterDescE) #4
  unreachable

10:                                               ; preds = %5
  tail call void @_ZNK4dali7kernels17ResamplingFilters10TriangularEf(ptr dead_on_unwind writable sret(%"struct.dali::kernels::ResamplingFilter") align 8 %0, ptr noundef nonnull align 8 dereferenceable(64) %1, float noundef 1.000000e+00) #5
  br label %34

11:                                               ; preds = %3
  %12 = getelementptr inbounds i8, ptr %2, i64 1
  %13 = load i8, ptr %12, align 1, !tbaa !12, !range !13, !noundef !14
  %14 = trunc nuw i8 %13 to i1
  br i1 %14, label %16, label %15

15:                                               ; preds = %11
  tail call void @__assert_fail(ptr noundef nonnull @.str.5, ptr noundef nonnull @.str.1, i32 noundef 33, ptr noundef nonnull @__PRETTY_FUNCTION__._ZN4dali7kernels10resampling19GetResamplingFilterEPKNS0_17ResamplingFiltersERKNS0_10FilterDescE) #4
  unreachable

16:                                               ; preds = %11
  %17 = getelementptr inbounds i8, ptr %2, i64 4
  %18 = load float, ptr %17, align 4, !tbaa !15
  tail call void @_ZNK4dali7kernels17ResamplingFilters10TriangularEf(ptr dead_on_unwind writable sret(%"struct.dali::kernels::ResamplingFilter") align 8 %0, ptr noundef nonnull align 8 dereferenceable(64) %1, float noundef %18) #5
  br label %34

19:                                               ; preds = %3
  %20 = getelementptr inbounds i8, ptr %2, i64 4
  %21 = load float, ptr %20, align 4, !tbaa !15
  %22 = fmul float %21, 5.000000e-01
  %23 = fpext float %22 to double
  %24 = fdiv double %23, 0x3FF6A09E667F3BCD
  %25 = fptrunc double %24 to float
  tail call void @_ZNK4dali7kernels17ResamplingFilters8GaussianEf(ptr dead_on_unwind writable sret(%"struct.dali::kernels::ResamplingFilter") align 8 %0, ptr noundef nonnull align 8 dereferenceable(64) %1, float noundef %25) #5
  br label %34

26:                                               ; preds = %3
  %27 = getelementptr inbounds i8, ptr %2, i64 4
  %28 = load float, ptr %27, align 4, !tbaa !15
  tail call void @_ZNK4dali7kernels17ResamplingFilters5CubicEf(ptr dead_on_unwind writable sret(%"struct.dali::kernels::ResamplingFilter") align 8 %0, ptr noundef nonnull align 8 dereferenceable(64) %1, float noundef %28) #5
  br label %34

29:                                               ; preds = %3
  %30 = getelementptr inbounds i8, ptr %2, i64 4
  %31 = load float, ptr %30, align 4, !tbaa !15
  tail call void @_ZNK4dali7kernels17ResamplingFilters8Lanczos3Ef(ptr dead_on_unwind writable sret(%"struct.dali::kernels::ResamplingFilter") align 8 %0, ptr noundef nonnull align 8 dereferenceable(64) %1, float noundef %31) #5
  br label %34

32:                                               ; preds = %3
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(24) %0, i8 0, i64 24, i1 false)
  %33 = getelementptr inbounds i8, ptr %0, i64 16
  store float 1.000000e+00, ptr %33, align 8, !tbaa !16
  br label %34

34:                                               ; preds = %32, %29, %26, %19, %16, %10
  ret void
}

; Function Attrs: nounwind
declare void @_ZNK4dali7kernels17ResamplingFilters10TriangularEf(ptr dead_on_unwind writable sret(%"struct.dali::kernels::ResamplingFilter") align 8, ptr noundef nonnull align 8 dereferenceable(64), float noundef) local_unnamed_addr #3

; Function Attrs: nounwind
declare void @_ZNK4dali7kernels17ResamplingFilters8GaussianEf(ptr dead_on_unwind writable sret(%"struct.dali::kernels::ResamplingFilter") align 8, ptr noundef nonnull align 8 dereferenceable(64), float noundef) local_unnamed_addr #3

; Function Attrs: nounwind
declare void @_ZNK4dali7kernels17ResamplingFilters5CubicEf(ptr dead_on_unwind writable sret(%"struct.dali::kernels::ResamplingFilter") align 8, ptr noundef nonnull align 8 dereferenceable(64), float noundef) local_unnamed_addr #3

; Function Attrs: nounwind
declare void @_ZNK4dali7kernels17ResamplingFilters8Lanczos3Ef(ptr dead_on_unwind writable sret(%"struct.dali::kernels::ResamplingFilter") align 8, ptr noundef nonnull align 8 dereferenceable(64), float noundef) local_unnamed_addr #3

attributes #0 = { 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 #1 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #2 = { 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 #3 = { 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 = { noreturn nounwind }
attributes #5 = { 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, !7, i64 0}
!6 = !{!"_ZTSN4dali7kernels10FilterDescE", !7, i64 0, !10, i64 1, !11, i64 4}
!7 = !{!"_ZTSN4dali7kernels20ResamplingFilterTypeE", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"bool", !8, i64 0}
!11 = !{!"float", !8, i64 0}
!12 = !{!6, !10, i64 1}
!13 = !{i8 0, i8 2}
!14 = !{}
!15 = !{!6, !11, i64 4}
!16 = !{!17, !11, i64 16}
!17 = !{!"_ZTSN4dali7kernels16ResamplingFilterE", !18, i64 0, !19, i64 8, !11, i64 12, !11, i64 16}
!18 = !{!"any pointer", !8, i64 0}
!19 = !{!"int", !8, i64 0}


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