; LLVM IR from NVIDIA/DALI :: dali/c_api_2 (data_objects)

; 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"

%"class.std::__exception_ptr::exception_ptr" = type { ptr }

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

declare i32 @__gxx_personality_v0(...)

; 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
declare dso_local noundef ptr @_ZN4dali5c_api9ToPointerEP11_DALITensor(ptr noundef) #1

declare noundef i32 @_ZN4dali5c_api9CheckInitEv() #2

declare ptr @__cxa_begin_catch(ptr)

declare noundef i32 @_ZN4dali5c_api11HandleErrorENSt15__exception_ptr13exception_ptrE(ptr noundef) #2

; Function Attrs: nounwind
declare void @_ZSt17current_exceptionv(ptr dead_on_unwind writable sret(%"class.std::__exception_ptr::exception_ptr") align 8) #3

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_ZNSt15__exception_ptr13exception_ptrD2Ev(ptr noundef nonnull align 8 dereferenceable(8)) unnamed_addr #4 align 2

declare void @__cxa_end_catch()

; Function Attrs: noinline noreturn nounwind uwtable
declare hidden void @__clang_call_terminate(ptr noundef) #5

; Function Attrs: mustprogress uwtable
define dso_local i32 @daliTensorGetShape(ptr noundef %0, ptr noundef %1, ptr noundef %2) #1 personality ptr @__gxx_personality_v0 {
  %4 = alloca i32, align 4
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca i32, align 4
  %9 = alloca ptr, align 8
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca ptr, align 8
  %13 = alloca ptr, align 8
  %14 = alloca %"class.std::__exception_ptr::exception_ptr", align 8
  store ptr %0, ptr %5, align 8, !tbaa !5
  store ptr %1, ptr %6, align 8, !tbaa !5
  store ptr %2, ptr %7, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #7
  %15 = invoke noundef i32 @_ZN4dali5c_api9CheckInitEv()
          to label %16 unwind label %21

16:                                               ; preds = %3
  store i32 %15, ptr %8, align 4, !tbaa !9
  %17 = load i32, ptr %8, align 4, !tbaa !9
  %18 = icmp ne i32 %17, 0
  br i1 %18, label %19, label %25

19:                                               ; preds = %16
  %20 = load i32, ptr %8, align 4, !tbaa !9
  store i32 %20, ptr %4, align 4
  store i32 1, ptr %11, align 4
  br label %27

21:                                               ; preds = %3
  %22 = landingpad { ptr, i32 }
          catch ptr null
  %23 = extractvalue { ptr, i32 } %22, 0
  store ptr %23, ptr %9, align 8
  %24 = extractvalue { ptr, i32 } %22, 1
  store i32 %24, ptr %10, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #7
  br label %62

25:                                               ; preds = %16
  br label %26

26:                                               ; preds = %25
  store i32 0, ptr %11, align 4
  br label %27

27:                                               ; preds = %26, %19
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #7
  %28 = load i32, ptr %11, align 4
  switch i32 %28, label %83 [
    i32 0, label %29
    i32 1, label %73
  ]

29:                                               ; preds = %27
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #7
  %30 = load ptr, ptr %5, align 8, !tbaa !5
  %31 = invoke noundef ptr @_ZN4dali5c_api9ToPointerEP11_DALITensor(ptr noundef %30)
          to label %32 unwind label %45

32:                                               ; preds = %29
  store ptr %31, ptr %12, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #7
  %33 = load ptr, ptr %12, align 8, !tbaa !5
  %34 = load ptr, ptr %33, align 8, !tbaa !11
  %35 = getelementptr inbounds ptr, ptr %34, i64 12
  %36 = load ptr, ptr %35, align 8
  %37 = invoke noundef nonnull align 8 dereferenceable(56) ptr %36(ptr noundef nonnull align 8 dereferenceable(12) %33)
          to label %38 unwind label %49

38:                                               ; preds = %32
  store ptr %37, ptr %13, align 8, !tbaa !5
  %39 = load ptr, ptr %6, align 8, !tbaa !5
  %40 = icmp ne ptr %39, null
  br i1 %40, label %41, label %53

41:                                               ; preds = %38
  %42 = load ptr, ptr %13, align 8, !tbaa !5
  %43 = call noundef i32 @_ZNK4dali15TensorShapeBaseINS_11SmallVectorIlLm6ESaIlEEELin1EE10sample_dimEv(ptr noundef nonnull align 8 dereferenceable(56) %42) #7
  %44 = load ptr, ptr %6, align 8, !tbaa !5
  store i32 %43, ptr %44, align 4, !tbaa !13
  br label %53

45:                                               ; preds = %29
  %46 = landingpad { ptr, i32 }
          catch ptr null
  %47 = extractvalue { ptr, i32 } %46, 0
  store ptr %47, ptr %9, align 8
  %48 = extractvalue { ptr, i32 } %46, 1
  store i32 %48, ptr %10, align 4
  br label %61

49:                                               ; preds = %32
  %50 = landingpad { ptr, i32 }
          catch ptr null
  %51 = extractvalue { ptr, i32 } %50, 0
  store ptr %51, ptr %9, align 8
  %52 = extractvalue { ptr, i32 } %50, 1
  store i32 %52, ptr %10, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #7
  br label %61

53:                                               ; preds = %41, %38
  %54 = load ptr, ptr %7, align 8, !tbaa !5
  %55 = icmp ne ptr %54, null
  br i1 %55, label %56, label %60

56:                                               ; preds = %53
  %57 = load ptr, ptr %13, align 8, !tbaa !5
  %58 = call noundef ptr @_ZNK4dali15TensorShapeBaseINS_11SmallVectorIlLm6ESaIlEEELin1EE4dataEv(ptr noundef nonnull align 8 dereferenceable(56) %57) #7
  %59 = load ptr, ptr %7, align 8, !tbaa !5
  store ptr %58, ptr %59, align 8, !tbaa !5
  br label %60

60:                                               ; preds = %56, %53
  store i32 0, ptr %4, align 4
  store i32 1, ptr %11, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #7
  br label %73

61:                                               ; preds = %49, %45
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #7
  br label %62

62:                                               ; preds = %61, %21
  %63 = load ptr, ptr %9, align 8
  %64 = call ptr @__cxa_begin_catch(ptr %63) #7
  call void @_ZSt17current_exceptionv(ptr dead_on_unwind writable sret(%"class.std::__exception_ptr::exception_ptr") align 8 %14) #7
  %65 = invoke noundef i32 @_ZN4dali5c_api11HandleErrorENSt15__exception_ptr13exception_ptrE(ptr noundef %14)
          to label %66 unwind label %67

66:                                               ; preds = %62
  store i32 %65, ptr %4, align 4
  call void @_ZNSt15__exception_ptr13exception_ptrD2Ev(ptr noundef nonnull align 8 dereferenceable(8) %14) #7
  store i32 1, ptr %11, align 4
  call void @__cxa_end_catch()
  br label %73

67:                                               ; preds = %62
  %68 = landingpad { ptr, i32 }
          cleanup
  %69 = extractvalue { ptr, i32 } %68, 0
  store ptr %69, ptr %9, align 8
  %70 = extractvalue { ptr, i32 } %68, 1
  store i32 %70, ptr %10, align 4
  call void @_ZNSt15__exception_ptr13exception_ptrD2Ev(ptr noundef nonnull align 8 dereferenceable(8) %14) #7
  invoke void @__cxa_end_catch()
          to label %71 unwind label %80

71:                                               ; preds = %67
  br label %75

72:                                               ; No predecessors!
  unreachable

73:                                               ; preds = %66, %60, %27
  %74 = load i32, ptr %4, align 4
  ret i32 %74

75:                                               ; preds = %71
  %76 = load ptr, ptr %9, align 8
  %77 = load i32, ptr %10, align 4
  %78 = insertvalue { ptr, i32 } poison, ptr %76, 0
  %79 = insertvalue { ptr, i32 } %78, i32 %77, 1
  resume { ptr, i32 } %79

80:                                               ; preds = %67
  %81 = landingpad { ptr, i32 }
          catch ptr null
  %82 = extractvalue { ptr, i32 } %81, 0
  call void @__clang_call_terminate(ptr %82) #8
  unreachable

83:                                               ; preds = %27
  unreachable
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZNK4dali15TensorShapeBaseINS_11SmallVectorIlLm6ESaIlEEELin1EE10sample_dimEv(ptr noundef nonnull align 8 dereferenceable(56)) #6 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef ptr @_ZNK4dali15TensorShapeBaseINS_11SmallVectorIlLm6ESaIlEEELin1EE4dataEv(ptr noundef nonnull align 8 dereferenceable(56)) #6 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 = { "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 = { 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 #5 = { noinline noreturn nounwind uwtable "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 = { 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 #7 = { nounwind }
attributes #8 = { noreturn 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 = !{!"_ZTS12daliResult_t", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"vtable pointer", !8, i64 0}
!13 = !{!14, !14, i64 0}
!14 = !{!"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"

%"class.std::__exception_ptr::exception_ptr" = type { ptr }

declare i32 @__gxx_personality_v0(...)

; Function Attrs: mustprogress uwtable
declare dso_local noundef ptr @_ZN4dali5c_api9ToPointerEP11_DALITensor(ptr noundef) local_unnamed_addr #0

declare noundef i32 @_ZN4dali5c_api9CheckInitEv() local_unnamed_addr #1

declare ptr @__cxa_begin_catch(ptr) local_unnamed_addr

declare noundef i32 @_ZN4dali5c_api11HandleErrorENSt15__exception_ptr13exception_ptrE(ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind
declare void @_ZSt17current_exceptionv(ptr dead_on_unwind writable sret(%"class.std::__exception_ptr::exception_ptr") align 8) local_unnamed_addr #2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_ZNSt15__exception_ptr13exception_ptrD2Ev(ptr noundef nonnull align 8 dereferenceable(8)) unnamed_addr #3 align 2

declare void @__cxa_end_catch() local_unnamed_addr

; Function Attrs: noinline noreturn nounwind uwtable
declare hidden void @__clang_call_terminate(ptr noundef) local_unnamed_addr #4

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @daliTensorGetShape(ptr noundef %0, ptr noundef writeonly %1, ptr noundef writeonly %2) local_unnamed_addr #0 personality ptr @__gxx_personality_v0 {
  %4 = alloca %"class.std::__exception_ptr::exception_ptr", align 8
  %5 = invoke noundef i32 @_ZN4dali5c_api9CheckInitEv()
          to label %6 unwind label %7

6:                                                ; preds = %3
  %.not.not = icmp eq i32 %5, 0
  br i1 %.not.not, label %9, label %32

7:                                                ; preds = %3
  %8 = landingpad { ptr, i32 }
          catch ptr null
  br label %26

9:                                                ; preds = %6
  %10 = invoke noundef ptr @_ZN4dali5c_api9ToPointerEP11_DALITensor(ptr noundef %0)
          to label %11 unwind label %19

11:                                               ; preds = %9
  %12 = load ptr, ptr %10, align 8, !tbaa !5
  %13 = getelementptr inbounds i8, ptr %12, i64 96
  %14 = load ptr, ptr %13, align 8
  %15 = invoke noundef nonnull align 8 dereferenceable(56) ptr %14(ptr noundef nonnull align 8 dereferenceable(12) %10)
          to label %16 unwind label %21

16:                                               ; preds = %11
  %.not18 = icmp eq ptr %1, null
  br i1 %.not18, label %23, label %17

17:                                               ; preds = %16
  %18 = tail call noundef i32 @_ZNK4dali15TensorShapeBaseINS_11SmallVectorIlLm6ESaIlEEELin1EE10sample_dimEv(ptr noundef nonnull align 8 dereferenceable(56) %15) #6
  store i32 %18, ptr %1, align 4, !tbaa !8
  br label %23

19:                                               ; preds = %9
  %20 = landingpad { ptr, i32 }
          catch ptr null
  br label %26

21:                                               ; preds = %11
  %22 = landingpad { ptr, i32 }
          catch ptr null
  br label %26

23:                                               ; preds = %17, %16
  %.not19 = icmp eq ptr %2, null
  br i1 %.not19, label %32, label %24

24:                                               ; preds = %23
  %25 = tail call noundef ptr @_ZNK4dali15TensorShapeBaseINS_11SmallVectorIlLm6ESaIlEEELin1EE4dataEv(ptr noundef nonnull align 8 dereferenceable(56) %15) #6
  store ptr %25, ptr %2, align 8, !tbaa !11
  br label %32

26:                                               ; preds = %19, %21, %7
  %.pn.pn = phi { ptr, i32 } [ %8, %7 ], [ %22, %21 ], [ %20, %19 ]
  %.115 = extractvalue { ptr, i32 } %.pn.pn, 0
  %27 = tail call ptr @__cxa_begin_catch(ptr %.115) #6
  call void @_ZSt17current_exceptionv(ptr dead_on_unwind nonnull writable sret(%"class.std::__exception_ptr::exception_ptr") align 8 %4) #6
  %28 = invoke noundef i32 @_ZN4dali5c_api11HandleErrorENSt15__exception_ptr13exception_ptrE(ptr noundef nonnull %4)
          to label %29 unwind label %30

29:                                               ; preds = %26
  call void @_ZNSt15__exception_ptr13exception_ptrD2Ev(ptr noundef nonnull align 8 dereferenceable(8) %4) #6
  call void @__cxa_end_catch()
  br label %32

30:                                               ; preds = %26
  %31 = landingpad { ptr, i32 }
          cleanup
  call void @_ZNSt15__exception_ptr13exception_ptrD2Ev(ptr noundef nonnull align 8 dereferenceable(8) %4) #6
  invoke void @__cxa_end_catch()
          to label %33 unwind label %34

32:                                               ; preds = %6, %23, %24, %29
  %.1 = phi i32 [ %5, %6 ], [ %28, %29 ], [ 0, %24 ], [ 0, %23 ]
  ret i32 %.1

33:                                               ; preds = %30
  resume { ptr, i32 } %31

34:                                               ; preds = %30
  %35 = landingpad { ptr, i32 }
          catch ptr null
  %36 = extractvalue { ptr, i32 } %35, 0
  call void @__clang_call_terminate(ptr %36) #7
  unreachable
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZNK4dali15TensorShapeBaseINS_11SmallVectorIlLm6ESaIlEEELin1EE10sample_dimEv(ptr noundef nonnull align 8 dereferenceable(56)) local_unnamed_addr #5 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef ptr @_ZNK4dali15TensorShapeBaseINS_11SmallVectorIlLm6ESaIlEEELin1EE4dataEv(ptr noundef nonnull align 8 dereferenceable(56)) local_unnamed_addr #5 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 = { "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 "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 = { 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 #4 = { noinline noreturn nounwind uwtable "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 = { 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 #6 = { nounwind }
attributes #7 = { noreturn 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 = !{!"vtable pointer", !7, i64 0}
!7 = !{!"Simple C++ TBAA"}
!8 = !{!9, !9, i64 0}
!9 = !{!"int", !10, i64 0}
!10 = !{!"omnipotent char", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"any pointer", !10, i64 0}


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