; LLVM IR from NVIDIA/DALI :: dali/operators/sequence/optical_flow/optical_flow_impl (optical_flow_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._NV_OF_EXECUTE_INPUT_PARAMS = type { ptr, ptr, ptr, i32, i32, ptr, i32, i32, ptr }
%"class.dali::optical_flow::OpticalFlowAdapter" = type { ptr, %"struct.dali::optical_flow::OpticalFlowParams" }
%"struct.dali::optical_flow::OpticalFlowParams" = type <{ float, i32, i32, i8, i8, [2 x i8] }>

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_ZN4dali12optical_flow15OpticalFlowImpl23GenerateExecuteInParamsEP22NvOFGPUBufferHandle_stS3_S3_(ptr dead_on_unwind noalias writable sret(%struct._NV_OF_EXECUTE_INPUT_PARAMS) align 8 %0, ptr noundef nonnull align 8 dereferenceable(489) %1, ptr noundef %2, ptr noundef %3, ptr noundef %4) #0 align 2 {
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  store ptr %1, ptr %6, align 8, !tbaa !5
  store ptr %2, ptr %7, align 8, !tbaa !5
  store ptr %3, ptr %8, align 8, !tbaa !5
  store ptr %4, ptr %9, align 8, !tbaa !5
  %10 = load ptr, ptr %6, align 8
  call void @llvm.memset.p0.i64(ptr align 8 %0, i8 0, i64 56, i1 false)
  %11 = load ptr, ptr %7, align 8, !tbaa !5
  %12 = getelementptr inbounds %struct._NV_OF_EXECUTE_INPUT_PARAMS, ptr %0, i32 0, i32 0
  store ptr %11, ptr %12, align 8, !tbaa !9
  %13 = load ptr, ptr %8, align 8, !tbaa !5
  %14 = getelementptr inbounds %struct._NV_OF_EXECUTE_INPUT_PARAMS, ptr %0, i32 0, i32 1
  store ptr %13, ptr %14, align 8, !tbaa !13
  %15 = getelementptr inbounds %"class.dali::optical_flow::OpticalFlowAdapter", ptr %10, i32 0, i32 1
  %16 = getelementptr inbounds %"struct.dali::optical_flow::OpticalFlowParams", ptr %15, i32 0, i32 3
  %17 = load i8, ptr %16, align 4, !tbaa !14, !range !19, !noundef !20
  %18 = trunc i8 %17 to i1
  %19 = zext i1 %18 to i64
  %20 = select i1 %18, i32 0, i32 1
  %21 = getelementptr inbounds %struct._NV_OF_EXECUTE_INPUT_PARAMS, ptr %0, i32 0, i32 3
  store i32 %20, ptr %21, align 8, !tbaa !21
  %22 = load ptr, ptr %9, align 8, !tbaa !5
  %23 = getelementptr inbounds %struct._NV_OF_EXECUTE_INPUT_PARAMS, ptr %0, i32 0, i32 2
  store ptr %22, ptr %23, align 8, !tbaa !22
  ret void
}

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

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 nounwind willreturn memory(argmem: write) }

!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, !6, i64 0}
!10 = !{!"_ZTS27_NV_OF_EXECUTE_INPUT_PARAMS", !6, i64 0, !6, i64 8, !6, i64 16, !11, i64 24, !12, i64 28, !6, i64 32, !12, i64 40, !12, i64 44, !6, i64 48}
!11 = !{!"_ZTS11_NV_OF_BOOL", !7, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{!10, !6, i64 8}
!14 = !{!15, !18, i64 20}
!15 = !{!"_ZTSN4dali12optical_flow18OpticalFlowAdapterINS_10ComputeGPUEEE", !16, i64 8}
!16 = !{!"_ZTSN4dali12optical_flow17OpticalFlowParamsE", !17, i64 0, !12, i64 4, !12, i64 8, !18, i64 12, !18, i64 13}
!17 = !{!"float", !7, i64 0}
!18 = !{!"bool", !7, i64 0}
!19 = !{i8 0, i8 2}
!20 = !{}
!21 = !{!10, !11, i64 24}
!22 = !{!10, !6, i64 16}


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

; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: readwrite) uwtable
define dso_local void @_ZN4dali12optical_flow15OpticalFlowImpl23GenerateExecuteInParamsEP22NvOFGPUBufferHandle_stS3_S3_(ptr dead_on_unwind noalias nocapture writable writeonly sret(%struct._NV_OF_EXECUTE_INPUT_PARAMS) align 8 %0, ptr nocapture noundef nonnull readonly align 8 dereferenceable(489) %1, ptr noundef %2, ptr noundef %3, ptr noundef %4) local_unnamed_addr #0 align 2 {
  %6 = getelementptr inbounds i8, ptr %0, i64 24
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(56) %6, i8 0, i64 32, i1 false)
  store ptr %2, ptr %0, align 8, !tbaa !5
  %7 = getelementptr inbounds i8, ptr %0, i64 8
  store ptr %3, ptr %7, align 8, !tbaa !12
  %8 = getelementptr inbounds i8, ptr %1, i64 20
  %9 = load i8, ptr %8, align 4, !tbaa !13, !range !18, !noundef !19
  %10 = xor i8 %9, 1
  %not. = zext nneg i8 %10 to i32
  %11 = getelementptr inbounds i8, ptr %0, i64 24
  store i32 %not., ptr %11, align 8, !tbaa !20
  %12 = getelementptr inbounds i8, ptr %0, i64 16
  store ptr %4, ptr %12, align 8, !tbaa !21
  ret void
}

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

attributes #0 = { mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: readwrite) 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 nounwind willreturn memory(argmem: write) }

!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 = !{!"_ZTS27_NV_OF_EXECUTE_INPUT_PARAMS", !7, i64 0, !7, i64 8, !7, i64 16, !10, i64 24, !11, i64 28, !7, i64 32, !11, i64 40, !11, i64 44, !7, i64 48}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"_ZTS11_NV_OF_BOOL", !8, i64 0}
!11 = !{!"int", !8, i64 0}
!12 = !{!6, !7, i64 8}
!13 = !{!14, !17, i64 20}
!14 = !{!"_ZTSN4dali12optical_flow18OpticalFlowAdapterINS_10ComputeGPUEEE", !15, i64 8}
!15 = !{!"_ZTSN4dali12optical_flow17OpticalFlowParamsE", !16, i64 0, !11, i64 4, !11, i64 8, !17, i64 12, !17, i64 13}
!16 = !{!"float", !8, i64 0}
!17 = !{!"bool", !8, i64 0}
!18 = !{i8 0, i8 2}
!19 = !{}
!20 = !{!6, !10, i64 24}
!21 = !{!6, !7, i64 16}


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