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

; 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::basic_string_view" = type { i64, ptr }
%"class.std::__exception_ptr::exception_ptr" = type { ptr }

@.str.18 = external hidden unnamed_addr constant [39 x i8], align 1
@.str.19 = external hidden unnamed_addr constant [23 x i8], align 1

; 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
define dso_local i32 @daliPipelineCreate(ptr noundef %0, ptr noundef %1) #1 personality ptr @__gxx_personality_v0 {
  %3 = alloca i32, align 4
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca ptr, align 8
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca %"class.std::basic_string_view", align 8
  %11 = alloca %"class.std::basic_string_view", align 8
  %12 = alloca %"class.std::__exception_ptr::exception_ptr", align 8
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #9
  %13 = invoke noundef i32 @_ZN4dali5c_api9CheckInitEv()
          to label %14 unwind label %19

14:                                               ; preds = %2
  store i32 %13, ptr %6, align 4, !tbaa !9
  %15 = load i32, ptr %6, align 4, !tbaa !9
  %16 = icmp ne i32 %15, 0
  br i1 %16, label %17, label %23

17:                                               ; preds = %14
  %18 = load i32, ptr %6, align 4, !tbaa !9
  store i32 %18, ptr %3, align 4
  store i32 1, ptr %9, align 4
  br label %25

19:                                               ; preds = %2
  %20 = landingpad { ptr, i32 }
          catch ptr null
  %21 = extractvalue { ptr, i32 } %20, 0
  store ptr %21, ptr %7, align 8
  %22 = extractvalue { ptr, i32 } %20, 1
  store i32 %22, ptr %8, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #9
  br label %53

23:                                               ; preds = %14
  br label %24

24:                                               ; preds = %23
  store i32 0, ptr %9, align 4
  br label %25

25:                                               ; preds = %24, %17
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #9
  %26 = load i32, ptr %9, align 4
  switch i32 %26, label %74 [
    i32 0, label %27
    i32 1, label %64
  ]

27:                                               ; preds = %25
  %28 = load ptr, ptr %4, align 8, !tbaa !5
  call void @_ZNSt17basic_string_viewIcSt11char_traitsIcEEC2EPKc(ptr noundef nonnull align 8 dereferenceable(16) %10, ptr noundef @.str.18) #9
  %29 = getelementptr inbounds { i64, ptr }, ptr %10, i32 0, i32 0
  %30 = load i64, ptr %29, align 8
  %31 = getelementptr inbounds { i64, ptr }, ptr %10, i32 0, i32 1
  %32 = load ptr, ptr %31, align 8
  invoke void @_ZN4dali5c_api12CheckNotNullIP13_DALIPipelineEEvPT_St17basic_string_viewIcSt11char_traitsIcEE(ptr noundef %28, i64 %30, ptr %32)
          to label %33 unwind label %45

33:                                               ; preds = %27
  %34 = load ptr, ptr %5, align 8, !tbaa !5
  call void @_ZNSt17basic_string_viewIcSt11char_traitsIcEEC2EPKc(ptr noundef nonnull align 8 dereferenceable(16) %11, ptr noundef @.str.19) #9
  %35 = getelementptr inbounds { i64, ptr }, ptr %11, i32 0, i32 0
  %36 = load i64, ptr %35, align 8
  %37 = getelementptr inbounds { i64, ptr }, ptr %11, i32 0, i32 1
  %38 = load ptr, ptr %37, align 8
  invoke void @_ZN4dali5c_api12CheckNotNullIK19_DALIPipelineParamsEEvPT_St17basic_string_viewIcSt11char_traitsIcEE(ptr noundef %34, i64 %36, ptr %38)
          to label %39 unwind label %45

39:                                               ; preds = %33
  %40 = invoke noalias noundef nonnull ptr @_Znwm(i64 noundef 32) #10
          to label %41 unwind label %45

41:                                               ; preds = %39
  %42 = load ptr, ptr %5, align 8, !tbaa !5
  invoke void @_ZN4dali5c_api15PipelineWrapperC1ERK19_DALIPipelineParams(ptr noundef nonnull align 8 dereferenceable(32) %40, ptr noundef nonnull align 8 dereferenceable(64) %42)
          to label %43 unwind label %49

43:                                               ; preds = %41
  %44 = load ptr, ptr %4, align 8, !tbaa !5
  store ptr %40, ptr %44, align 8, !tbaa !5
  store i32 0, ptr %3, align 4
  br label %64

45:                                               ; preds = %39, %33, %27
  %46 = landingpad { ptr, i32 }
          catch ptr null
  %47 = extractvalue { ptr, i32 } %46, 0
  store ptr %47, ptr %7, align 8
  %48 = extractvalue { ptr, i32 } %46, 1
  store i32 %48, ptr %8, align 4
  br label %53

49:                                               ; preds = %41
  %50 = landingpad { ptr, i32 }
          catch ptr null
  %51 = extractvalue { ptr, i32 } %50, 0
  store ptr %51, ptr %7, align 8
  %52 = extractvalue { ptr, i32 } %50, 1
  store i32 %52, ptr %8, align 4
  call void @_ZdlPvm(ptr noundef %40, i64 noundef 32) #11
  br label %53

53:                                               ; preds = %49, %45, %19
  %54 = load ptr, ptr %7, align 8
  %55 = call ptr @__cxa_begin_catch(ptr %54) #9
  call void @_ZSt17current_exceptionv(ptr dead_on_unwind writable sret(%"class.std::__exception_ptr::exception_ptr") align 8 %12) #9
  %56 = invoke noundef i32 @_ZN4dali5c_api11HandleErrorENSt15__exception_ptr13exception_ptrE(ptr noundef %12)
          to label %57 unwind label %58

57:                                               ; preds = %53
  store i32 %56, ptr %3, align 4
  call void @_ZNSt15__exception_ptr13exception_ptrD2Ev(ptr noundef nonnull align 8 dereferenceable(8) %12) #9
  store i32 1, ptr %9, align 4
  call void @__cxa_end_catch()
  br label %64

58:                                               ; preds = %53
  %59 = landingpad { ptr, i32 }
          cleanup
  %60 = extractvalue { ptr, i32 } %59, 0
  store ptr %60, ptr %7, align 8
  %61 = extractvalue { ptr, i32 } %59, 1
  store i32 %61, ptr %8, align 4
  call void @_ZNSt15__exception_ptr13exception_ptrD2Ev(ptr noundef nonnull align 8 dereferenceable(8) %12) #9
  invoke void @__cxa_end_catch()
          to label %62 unwind label %71

62:                                               ; preds = %58
  br label %66

63:                                               ; No predecessors!
  unreachable

64:                                               ; preds = %57, %43, %25
  %65 = load i32, ptr %3, align 4
  ret i32 %65

66:                                               ; preds = %62
  %67 = load ptr, ptr %7, align 8
  %68 = load i32, ptr %8, align 4
  %69 = insertvalue { ptr, i32 } poison, ptr %67, 0
  %70 = insertvalue { ptr, i32 } %69, i32 %68, 1
  resume { ptr, i32 } %70

71:                                               ; preds = %58
  %72 = landingpad { ptr, i32 }
          catch ptr null
  %73 = extractvalue { ptr, i32 } %72, 0
  call void @__clang_call_terminate(ptr %73) #12
  unreachable

74:                                               ; preds = %25
  unreachable
}

declare noundef i32 @_ZN4dali5c_api9CheckInitEv() #2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN4dali5c_api12CheckNotNullIP13_DALIPipelineEEvPT_St17basic_string_viewIcSt11char_traitsIcEE(ptr noundef, i64, ptr) #1

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN4dali5c_api12CheckNotNullIK19_DALIPipelineParamsEEvPT_St17basic_string_viewIcSt11char_traitsIcEE(ptr noundef, i64, ptr) #1

; Function Attrs: nobuiltin allocsize(0)
declare noundef nonnull ptr @_Znwm(i64 noundef) #4

; Function Attrs: nobuiltin nounwind
declare void @_ZdlPvm(ptr noundef, i64 noundef) #5

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) #6

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

declare void @__cxa_end_catch()

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

declare void @_ZN4dali5c_api15PipelineWrapperC1ERK19_DALIPipelineParams(ptr, ptr)

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 = { 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 = { nobuiltin allocsize(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 = { nobuiltin 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 #6 = { 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 #7 = { 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 #8 = { 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 #9 = { nounwind }
attributes #10 = { builtin allocsize(0) }
attributes #11 = { builtin nounwind }
attributes #12 = { 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}


; 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::basic_string_view" = type { i64, ptr }
%"class.std::__exception_ptr::exception_ptr" = type { ptr }

@.str.18 = external hidden unnamed_addr constant [39 x i8], align 1
@.str.19 = external hidden unnamed_addr constant [23 x i8], align 1

declare i32 @__gxx_personality_v0(...)

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

7:                                                ; preds = %2
  %.not.not = icmp eq i32 %6, 0
  br i1 %.not.not, label %10, label %32

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

10:                                               ; preds = %7
  call void @_ZNSt17basic_string_viewIcSt11char_traitsIcEEC2EPKc(ptr noundef nonnull align 8 dereferenceable(16) %3, ptr noundef @.str.18) #8
  %11 = load i64, ptr %3, align 8
  %12 = getelementptr inbounds i8, ptr %3, i64 8
  %13 = load ptr, ptr %12, align 8
  invoke void @_ZN4dali5c_api12CheckNotNullIP13_DALIPipelineEEvPT_St17basic_string_viewIcSt11char_traitsIcEE(ptr noundef %0, i64 %11, ptr %13)
          to label %14 unwind label %22

14:                                               ; preds = %10
  call void @_ZNSt17basic_string_viewIcSt11char_traitsIcEEC2EPKc(ptr noundef nonnull align 8 dereferenceable(16) %4, ptr noundef @.str.19) #8
  %15 = load i64, ptr %4, align 8
  %16 = getelementptr inbounds i8, ptr %4, i64 8
  %17 = load ptr, ptr %16, align 8
  invoke void @_ZN4dali5c_api12CheckNotNullIK19_DALIPipelineParamsEEvPT_St17basic_string_viewIcSt11char_traitsIcEE(ptr noundef %1, i64 %15, ptr %17)
          to label %18 unwind label %22

18:                                               ; preds = %14
  %19 = invoke noalias noundef nonnull dereferenceable(32) ptr @_Znwm(i64 noundef 32) #9
          to label %20 unwind label %22

20:                                               ; preds = %18
  invoke void @_ZN4dali5c_api15PipelineWrapperC1ERK19_DALIPipelineParams(ptr noundef nonnull align 8 dereferenceable(32) %19, ptr noundef nonnull align 8 dereferenceable(64) %1)
          to label %21 unwind label %24

21:                                               ; preds = %20
  store ptr %19, ptr %0, align 8, !tbaa !5
  br label %32

22:                                               ; preds = %18, %14, %10
  %23 = landingpad { ptr, i32 }
          catch ptr null
  br label %26

24:                                               ; preds = %20
  %25 = landingpad { ptr, i32 }
          catch ptr null
  call void @_ZdlPvm(ptr noundef nonnull %19, i64 noundef 32) #10
  br label %26

26:                                               ; preds = %24, %22, %8
  %.pn = phi { ptr, i32 } [ %25, %24 ], [ %23, %22 ], [ %9, %8 ]
  %.010 = extractvalue { ptr, i32 } %.pn, 0
  %27 = call ptr @__cxa_begin_catch(ptr %.010) #8
  call void @_ZSt17current_exceptionv(ptr dead_on_unwind nonnull writable sret(%"class.std::__exception_ptr::exception_ptr") align 8 %5) #8
  %28 = invoke noundef i32 @_ZN4dali5c_api11HandleErrorENSt15__exception_ptr13exception_ptrE(ptr noundef nonnull %5)
          to label %29 unwind label %30

29:                                               ; preds = %26
  call void @_ZNSt15__exception_ptr13exception_ptrD2Ev(ptr noundef nonnull align 8 dereferenceable(8) %5) #8
  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) %5) #8
  invoke void @__cxa_end_catch()
          to label %33 unwind label %34

32:                                               ; preds = %7, %29, %21
  %.1 = phi i32 [ %6, %7 ], [ 0, %21 ], [ %28, %29 ]
  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) #11
  unreachable
}

declare noundef i32 @_ZN4dali5c_api9CheckInitEv() local_unnamed_addr #1

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN4dali5c_api12CheckNotNullIP13_DALIPipelineEEvPT_St17basic_string_viewIcSt11char_traitsIcEE(ptr noundef, i64, ptr) local_unnamed_addr #0

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN4dali5c_api12CheckNotNullIK19_DALIPipelineParamsEEvPT_St17basic_string_viewIcSt11char_traitsIcEE(ptr noundef, i64, ptr) local_unnamed_addr #0

; Function Attrs: nobuiltin allocsize(0)
declare noundef nonnull ptr @_Znwm(i64 noundef) local_unnamed_addr #3

; Function Attrs: nobuiltin nounwind
declare void @_ZdlPvm(ptr noundef, i64 noundef) local_unnamed_addr #4

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 #5

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_ZNSt15__exception_ptr13exception_ptrD2Ev(ptr noundef nonnull align 8 dereferenceable(8)) unnamed_addr #6 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 #7

declare void @_ZN4dali5c_api15PipelineWrapperC1ERK19_DALIPipelineParams(ptr, ptr) local_unnamed_addr

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 = { 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 = { nobuiltin allocsize(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 = { nobuiltin 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 #5 = { 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 #6 = { 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 #7 = { 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 #8 = { nounwind }
attributes #9 = { builtin allocsize(0) }
attributes #10 = { builtin nounwind }
attributes #11 = { 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"}


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