; 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.std::pair" = type { i64, 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 { i64, i64 } @_ZN4dali22ProcessOffsetAndLengthERKNS_13AudioMetadataEdd(ptr noundef nonnull align 8 dereferenceable(17) %0, double noundef %1, double noundef %2) #1 {
  %4 = alloca %"struct.std::pair", align 8
  %5 = alloca ptr, align 8
  %6 = alloca double, align 8
  %7 = alloca double, align 8
  %8 = alloca i64, align 8
  %9 = alloca i64, align 8
  store ptr %0, ptr %5, align 8, !tbaa !5
  store double %1, ptr %6, align 8, !tbaa !9
  store double %2, ptr %7, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #3
  store i64 0, ptr %8, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #3
  %10 = load ptr, ptr %5, align 8, !tbaa !5
  %11 = getelementptr inbounds %"struct.dali::AudioMetadata", ptr %10, i32 0, i32 0
  %12 = load i64, ptr %11, align 8, !tbaa !13
  store i64 %12, ptr %9, align 8, !tbaa !11
  %13 = load double, ptr %6, align 8, !tbaa !9
  %14 = fcmp oge double %13, 0.000000e+00
  br i1 %14, label %15, label %23

15:                                               ; preds = %3
  %16 = load double, ptr %6, align 8, !tbaa !9
  %17 = load ptr, ptr %5, align 8, !tbaa !5
  %18 = getelementptr inbounds %"struct.dali::AudioMetadata", ptr %17, i32 0, i32 1
  %19 = load i32, ptr %18, align 8, !tbaa !17
  %20 = sitofp i32 %19 to double
  %21 = fmul double %16, %20
  %22 = fptosi double %21 to i64
  store i64 %22, ptr %8, align 8, !tbaa !11
  br label %23

23:                                               ; preds = %15, %3
  %24 = load double, ptr %7, align 8, !tbaa !9
  %25 = fcmp oge double %24, 0.000000e+00
  br i1 %25, label %26, label %34

26:                                               ; preds = %23
  %27 = load double, ptr %7, align 8, !tbaa !9
  %28 = load ptr, ptr %5, align 8, !tbaa !5
  %29 = getelementptr inbounds %"struct.dali::AudioMetadata", ptr %28, i32 0, i32 1
  %30 = load i32, ptr %29, align 8, !tbaa !17
  %31 = sitofp i32 %30 to double
  %32 = fmul double %27, %31
  %33 = fptosi double %32 to i64
  store i64 %33, ptr %9, align 8, !tbaa !11
  br label %34

34:                                               ; preds = %26, %23
  %35 = load i64, ptr %8, align 8, !tbaa !11
  %36 = load i64, ptr %9, align 8, !tbaa !11
  %37 = add nsw i64 %35, %36
  %38 = load ptr, ptr %5, align 8, !tbaa !5
  %39 = getelementptr inbounds %"struct.dali::AudioMetadata", ptr %38, i32 0, i32 0
  %40 = load i64, ptr %39, align 8, !tbaa !13
  %41 = icmp sgt i64 %37, %40
  br i1 %41, label %42, label %48

42:                                               ; preds = %34
  %43 = load ptr, ptr %5, align 8, !tbaa !5
  %44 = getelementptr inbounds %"struct.dali::AudioMetadata", ptr %43, i32 0, i32 0
  %45 = load i64, ptr %44, align 8, !tbaa !13
  %46 = load i64, ptr %8, align 8, !tbaa !11
  %47 = sub nsw i64 %45, %46
  store i64 %47, ptr %9, align 8, !tbaa !11
  br label %48

48:                                               ; preds = %42, %34
  call void @_ZNSt4pairIllEC2IRlS2_TnNSt9enable_ifIXaaclsr5_PCCPE22_MoveConstructiblePairIT_T0_EEclsr5_PCCPE30_ImplicitlyMoveConvertiblePairIS4_S5_EEEbE4typeELb1EEEOS4_OS5_(ptr noundef nonnull align 8 dereferenceable(16) %4, ptr noundef nonnull align 8 dereferenceable(8) %8, ptr noundef nonnull align 8 dereferenceable(8) %9)
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #3
  %49 = load { i64, i64 }, ptr %4, align 8
  ret { i64, i64 } %49
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSt4pairIllEC2IRlS2_TnNSt9enable_ifIXaaclsr5_PCCPE22_MoveConstructiblePairIT_T0_EEclsr5_PCCPE30_ImplicitlyMoveConvertiblePairIS4_S5_EEEbE4typeELb1EEEOS4_OS5_(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 8 dereferenceable(8), ptr noundef nonnull align 8 dereferenceable(8)) unnamed_addr #2 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 = { 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 = !{!"double", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"long", !7, i64 0}
!13 = !{!14, !12, i64 0}
!14 = !{!"_ZTSN4dali13AudioMetadataE", !12, i64 0, !15, i64 8, !15, i64 12, !16, i64 16}
!15 = !{!"int", !7, i64 0}
!16 = !{!"bool", !7, i64 0}
!17 = !{!14, !15, i64 8}


; 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.std::pair" = type { i64, i64 }

; 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

; Function Attrs: mustprogress nounwind uwtable
define dso_local { i64, i64 } @_ZN4dali22ProcessOffsetAndLengthERKNS_13AudioMetadataEdd(ptr nocapture noundef nonnull readonly align 8 dereferenceable(17) %0, double noundef %1, double noundef %2) local_unnamed_addr #1 {
  %4 = alloca %"struct.std::pair", align 8
  %5 = alloca i64, align 8
  %6 = alloca i64, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %5) #2
  store i64 0, ptr %5, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %6) #2
  %7 = load i64, ptr %0, align 8, !tbaa !9
  store i64 %7, ptr %6, align 8, !tbaa !5
  %8 = fcmp ult double %1, 0.000000e+00
  br i1 %8, label %15, label %9

9:                                                ; preds = %3
  %10 = getelementptr inbounds i8, ptr %0, i64 8
  %11 = load i32, ptr %10, align 8, !tbaa !13
  %12 = sitofp i32 %11 to double
  %13 = fmul double %12, %1
  %14 = fptosi double %13 to i64
  store i64 %14, ptr %5, align 8, !tbaa !5
  br label %15

15:                                               ; preds = %9, %3
  %16 = phi i64 [ %14, %9 ], [ 0, %3 ]
  %17 = fcmp ult double %2, 0.000000e+00
  br i1 %17, label %24, label %18

18:                                               ; preds = %15
  %19 = getelementptr inbounds i8, ptr %0, i64 8
  %20 = load i32, ptr %19, align 8, !tbaa !13
  %21 = sitofp i32 %20 to double
  %22 = fmul double %21, %2
  %23 = fptosi double %22 to i64
  store i64 %23, ptr %6, align 8, !tbaa !5
  br label %24

24:                                               ; preds = %18, %15
  %25 = phi i64 [ %23, %18 ], [ %7, %15 ]
  %26 = add nsw i64 %25, %16
  %27 = icmp sgt i64 %26, %7
  br i1 %27, label %28, label %30

28:                                               ; preds = %24
  %29 = sub nsw i64 %7, %16
  store i64 %29, ptr %6, align 8, !tbaa !5
  br label %30

30:                                               ; preds = %28, %24
  call void @_ZNSt4pairIllEC2IRlS2_TnNSt9enable_ifIXaaclsr5_PCCPE22_MoveConstructiblePairIT_T0_EEclsr5_PCCPE30_ImplicitlyMoveConvertiblePairIS4_S5_EEEbE4typeELb1EEEOS4_OS5_(ptr noundef nonnull align 8 dereferenceable(16) %4, ptr noundef nonnull align 8 dereferenceable(8) %5, ptr noundef nonnull align 8 dereferenceable(8) %6)
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %6) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %5) #2
  %.fca.0.load = load i64, ptr %4, align 8
  %.fca.0.insert = insertvalue { i64, i64 } poison, i64 %.fca.0.load, 0
  %.fca.1.gep = getelementptr inbounds i8, ptr %4, i64 8
  %.fca.1.load = load i64, ptr %.fca.1.gep, align 8
  %.fca.1.insert = insertvalue { i64, i64 } %.fca.0.insert, i64 %.fca.1.load, 1
  ret { i64, i64 } %.fca.1.insert
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSt4pairIllEC2IRlS2_TnNSt9enable_ifIXaaclsr5_PCCPE22_MoveConstructiblePairIT_T0_EEclsr5_PCCPE30_ImplicitlyMoveConvertiblePairIS4_S5_EEEbE4typeELb1EEEOS4_OS5_(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 8 dereferenceable(8), ptr noundef nonnull align 8 dereferenceable(8)) unnamed_addr #1 align 2

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #2 = { 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, !6, i64 0}
!10 = !{!"_ZTSN4dali13AudioMetadataE", !6, i64 0, !11, i64 8, !11, i64 12, !12, i64 16}
!11 = !{!"int", !7, i64 0}
!12 = !{!"bool", !7, i64 0}
!13 = !{!10, !11, i64 8}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass