; LLVM IR from NVIDIA/DALI :: dali/operators/decoder/audio (audio_decoder_impl)

; 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::TensorShape" = type { %"struct.dali::TensorShapeBase" }
%"struct.dali::TensorShapeBase" = type { %"class.dali::SmallVector" }
%"class.dali::SmallVector" = type { %union.anon, i64 }
%union.anon = type { %struct.anon, [32 x i8] }
%struct.anon = type { ptr, i64 }
%"struct.dali::AudioMetadata" = type <{ i64, i32, i32, i8, [7 x i8] }>

; 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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN4dali17DecodedAudioShapeERKNS_13AudioMetadataEfb(ptr dead_on_unwind noalias writable sret(%"struct.dali::TensorShape") align 8 %0, ptr noundef nonnull align 8 dereferenceable(17) %1, float noundef %2, i1 noundef zeroext %3) #1 {
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca float, align 4
  %8 = alloca i8, align 1
  %9 = alloca i8, align 1
  %10 = alloca i8, align 1
  %11 = alloca i32, align 4
  %12 = alloca i64, align 8
  store ptr %0, ptr %5, align 8
  store ptr %1, ptr %6, align 8, !tbaa !5
  store float %2, ptr %7, align 4, !tbaa !9
  %13 = zext i1 %3 to i8
  store i8 %13, ptr %8, align 1, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 1, ptr %9) #3
  %14 = load float, ptr %7, align 4, !tbaa !9
  %15 = fcmp ogt float %14, 0.000000e+00
  br i1 %15, label %16, label %23

16:                                               ; preds = %4
  %17 = load ptr, ptr %6, align 8, !tbaa !5
  %18 = getelementptr inbounds %"struct.dali::AudioMetadata", ptr %17, i32 0, i32 1
  %19 = load i32, ptr %18, align 8, !tbaa !13
  %20 = sitofp i32 %19 to float
  %21 = load float, ptr %7, align 4, !tbaa !9
  %22 = fcmp une float %20, %21
  br label %23

23:                                               ; preds = %16, %4
  %24 = phi i1 [ false, %4 ], [ %22, %16 ]
  %25 = zext i1 %24 to i8
  store i8 %25, ptr %9, align 1, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 1, ptr %10) #3
  %26 = load ptr, ptr %6, align 8, !tbaa !5
  %27 = getelementptr inbounds %"struct.dali::AudioMetadata", ptr %26, i32 0, i32 2
  %28 = load i32, ptr %27, align 4, !tbaa !17
  %29 = icmp sgt i32 %28, 1
  br i1 %29, label %30, label %33

30:                                               ; preds = %23
  %31 = load i8, ptr %8, align 1, !tbaa !11, !range !18, !noundef !19
  %32 = trunc i8 %31 to i1
  br label %33

33:                                               ; preds = %30, %23
  %34 = phi i1 [ false, %23 ], [ %32, %30 ]
  %35 = zext i1 %34 to i8
  store i8 %35, ptr %10, align 1, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #3
  %36 = load ptr, ptr %6, align 8, !tbaa !5
  %37 = getelementptr inbounds %"struct.dali::AudioMetadata", ptr %36, i32 0, i32 2
  %38 = load i32, ptr %37, align 4, !tbaa !17
  %39 = icmp eq i32 %38, 1
  br i1 %39, label %43, label %40

40:                                               ; preds = %33
  %41 = load i8, ptr %8, align 1, !tbaa !11, !range !18, !noundef !19
  %42 = trunc i8 %41 to i1
  br i1 %42, label %43, label %44

43:                                               ; preds = %40, %33
  br label %48

44:                                               ; preds = %40
  %45 = load ptr, ptr %6, align 8, !tbaa !5
  %46 = getelementptr inbounds %"struct.dali::AudioMetadata", ptr %45, i32 0, i32 2
  %47 = load i32, ptr %46, align 4, !tbaa !17
  br label %48

48:                                               ; preds = %44, %43
  %49 = phi i32 [ 1, %43 ], [ %47, %44 ]
  store i32 %49, ptr %11, align 4, !tbaa !20
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #3
  %50 = load i8, ptr %9, align 1, !tbaa !11, !range !18, !noundef !19
  %51 = trunc i8 %50 to i1
  br i1 %51, label %52, label %63

52:                                               ; preds = %48
  %53 = load ptr, ptr %6, align 8, !tbaa !5
  %54 = getelementptr inbounds %"struct.dali::AudioMetadata", ptr %53, i32 0, i32 0
  %55 = load i64, ptr %54, align 8, !tbaa !21
  %56 = load ptr, ptr %6, align 8, !tbaa !5
  %57 = getelementptr inbounds %"struct.dali::AudioMetadata", ptr %56, i32 0, i32 1
  %58 = load i32, ptr %57, align 8, !tbaa !13
  %59 = sitofp i32 %58 to double
  %60 = load float, ptr %7, align 4, !tbaa !9
  %61 = fpext float %60 to double
  %62 = call noundef i64 @_ZN4dali7kernels6signal10resampling16resampled_lengthEldd(i64 noundef %55, double noundef %59, double noundef %61)
  br label %67

63:                                               ; preds = %48
  %64 = load ptr, ptr %6, align 8, !tbaa !5
  %65 = getelementptr inbounds %"struct.dali::AudioMetadata", ptr %64, i32 0, i32 0
  %66 = load i64, ptr %65, align 8, !tbaa !21
  br label %67

67:                                               ; preds = %63, %52
  %68 = phi i64 [ %62, %52 ], [ %66, %63 ]
  store i64 %68, ptr %12, align 8, !tbaa !22
  %69 = load i8, ptr %8, align 1, !tbaa !11, !range !18, !noundef !19
  %70 = trunc i8 %69 to i1
  br i1 %70, label %71, label %73

71:                                               ; preds = %67
  %72 = load i64, ptr %12, align 8, !tbaa !22
  call void @_ZN4dali11TensorShapeILin1EEC2IJEvEElDpT_(ptr noundef nonnull align 8 dereferenceable(56) %0, i64 noundef %72)
  br label %76

73:                                               ; preds = %67
  %74 = load i64, ptr %12, align 8, !tbaa !22
  %75 = load i32, ptr %11, align 4, !tbaa !20
  call void @_ZN4dali11TensorShapeILin1EEC2IJiEvEElDpT_(ptr noundef nonnull align 8 dereferenceable(56) %0, i64 noundef %74, i32 noundef %75)
  br label %76

76:                                               ; preds = %73, %71
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #3
  call void @llvm.lifetime.end.p0(i64 1, ptr %10) #3
  call void @llvm.lifetime.end.p0(i64 1, ptr %9) #3
  ret void
}

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef i64 @_ZN4dali7kernels6signal10resampling16resampled_lengthEldd(i64 noundef, double noundef, double noundef) #2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN4dali11TensorShapeILin1EEC2IJEvEElDpT_(ptr noundef nonnull align 8 dereferenceable(56), i64 noundef) unnamed_addr #1 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN4dali11TensorShapeILin1EEC2IJiEvEElDpT_(ptr noundef nonnull align 8 dereferenceable(56), i64 noundef, i32 noundef) unnamed_addr #1 align 2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #2 = { inlinehint 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 }

!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 = !{!"float", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"bool", !7, i64 0}
!13 = !{!14, !16, i64 8}
!14 = !{!"_ZTSN4dali13AudioMetadataE", !15, i64 0, !16, i64 8, !16, i64 12, !12, i64 16}
!15 = !{!"long", !7, i64 0}
!16 = !{!"int", !7, i64 0}
!17 = !{!14, !16, i64 12}
!18 = !{i8 0, i8 2}
!19 = !{}
!20 = !{!16, !16, i64 0}
!21 = !{!14, !15, i64 0}
!22 = !{!15, !15, 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::TensorShape" = type { %"struct.dali::TensorShapeBase" }
%"struct.dali::TensorShapeBase" = type { %"class.dali::SmallVector" }
%"class.dali::SmallVector" = type { %union.anon, i64 }
%union.anon = type { %struct.anon, [32 x i8] }
%struct.anon = type { ptr, i64 }

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN4dali17DecodedAudioShapeERKNS_13AudioMetadataEfb(ptr dead_on_unwind noalias writable sret(%"struct.dali::TensorShape") align 8 %0, ptr nocapture noundef nonnull readonly align 8 dereferenceable(17) %1, float noundef %2, i1 noundef zeroext %3) local_unnamed_addr #0 {
  %5 = fcmp ogt float %2, 0.000000e+00
  %6 = getelementptr inbounds i8, ptr %1, i64 8
  %7 = load i32, ptr %6, align 8
  %8 = sitofp i32 %7 to float
  %9 = fcmp une float %8, %2
  %10 = select i1 %5, i1 %9, i1 false
  %11 = getelementptr inbounds i8, ptr %1, i64 12
  %12 = load i32, ptr %11, align 4, !tbaa !5
  %13 = load i64, ptr %1, align 8, !tbaa !12
  br i1 %10, label %14, label %18

14:                                               ; preds = %4
  %15 = sitofp i32 %7 to double
  %16 = fpext float %2 to double
  %17 = tail call noundef i64 @_ZN4dali7kernels6signal10resampling16resampled_lengthEldd(i64 noundef %13, double noundef %15, double noundef %16)
  br label %18

18:                                               ; preds = %4, %14
  %19 = phi i64 [ %17, %14 ], [ %13, %4 ]
  br i1 %3, label %20, label %21

20:                                               ; preds = %18
  tail call void @_ZN4dali11TensorShapeILin1EEC2IJEvEElDpT_(ptr noundef nonnull align 8 dereferenceable(56) %0, i64 noundef %19)
  br label %22

21:                                               ; preds = %18
  tail call void @_ZN4dali11TensorShapeILin1EEC2IJiEvEElDpT_(ptr noundef nonnull align 8 dereferenceable(56) %0, i64 noundef %19, i32 noundef %12)
  br label %22

22:                                               ; preds = %21, %20
  ret void
}

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef i64 @_ZN4dali7kernels6signal10resampling16resampled_lengthEldd(i64 noundef, double noundef, double noundef) local_unnamed_addr #1

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN4dali11TensorShapeILin1EEC2IJEvEElDpT_(ptr noundef nonnull align 8 dereferenceable(56), i64 noundef) unnamed_addr #0 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN4dali11TensorShapeILin1EEC2IJiEvEElDpT_(ptr noundef nonnull align 8 dereferenceable(56), i64 noundef, i32 noundef) unnamed_addr #0 align 2

attributes #0 = { 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 #1 = { inlinehint 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" }

!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, !10, i64 12}
!6 = !{!"_ZTSN4dali13AudioMetadataE", !7, i64 0, !10, i64 8, !10, i64 12, !11, i64 16}
!7 = !{!"long", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!"bool", !8, i64 0}
!12 = !{!6, !7, i64 0}


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