; LLVM IR from Razakhel/RaZ :: extern/simdjson (simdjson)

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

; 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

declare i32 @__gxx_personality_v0(...)

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

; Function Attrs: inlinehint mustprogress uwtable
declare hidden noundef i32 @_ZN8simdjson8internalL30detect_supported_architecturesEv() #2

; Function Attrs: mustprogress uwtable
declare dso_local noundef ptr @_ZN8simdjson8internal25get_unsupported_singletonEv() #3

; Function Attrs: mustprogress uwtable
declare hidden noundef nonnull align 8 dereferenceable(16) ptr @_ZN8simdjson8internalL37get_available_implementation_pointersEv() #3

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef ptr @_ZNKSt16initializer_listIPKN8simdjson14implementationEE5beginEv(ptr noundef nonnull align 8 dereferenceable(16)) #4 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef ptr @_ZNKSt16initializer_listIPKN8simdjson14implementationEE3endEv(ptr noundef nonnull align 8 dereferenceable(16)) #4 align 2

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef ptr @_ZNK8simdjson8internal29available_implementation_list21detect_best_supportedEv(ptr noundef nonnull align 1 dereferenceable(1) %0) #4 align 2 personality ptr @__gxx_personality_v0 {
  %2 = alloca ptr, align 8
  %3 = alloca ptr, align 8
  %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
  store ptr %0, ptr %3, align 8, !tbaa !5
  %11 = load ptr, ptr %3, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #5
  %12 = invoke noundef i32 @_ZN8simdjson8internalL30detect_supported_architecturesEv()
          to label %13 unwind label %58

13:                                               ; preds = %1
  store i32 %12, ptr %4, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #5
  %14 = invoke noundef nonnull align 8 dereferenceable(16) ptr @_ZN8simdjson8internalL37get_available_implementation_pointersEv()
          to label %15 unwind label %58

15:                                               ; preds = %13
  store ptr %14, ptr %5, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #5
  %16 = load ptr, ptr %5, align 8, !tbaa !5
  %17 = call noundef ptr @_ZNKSt16initializer_listIPKN8simdjson14implementationEE5beginEv(ptr noundef nonnull align 8 dereferenceable(16) %16) #5
  store ptr %17, ptr %6, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #5
  %18 = load ptr, ptr %5, align 8, !tbaa !5
  %19 = call noundef ptr @_ZNKSt16initializer_listIPKN8simdjson14implementationEE3endEv(ptr noundef nonnull align 8 dereferenceable(16) %18) #5
  store ptr %19, ptr %7, align 8, !tbaa !5
  br label %20

20:                                               ; preds = %48, %15
  %21 = load ptr, ptr %6, align 8, !tbaa !5
  %22 = load ptr, ptr %7, align 8, !tbaa !5
  %23 = icmp ne ptr %21, %22
  br i1 %23, label %25, label %24

24:                                               ; preds = %20
  store i32 2, ptr %8, align 4
  br label %51

25:                                               ; preds = %20
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #5
  %26 = load ptr, ptr %6, align 8, !tbaa !5
  %27 = load ptr, ptr %26, align 8, !tbaa !5
  store ptr %27, ptr %9, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #5
  %28 = load ptr, ptr %9, align 8, !tbaa !5
  %29 = load ptr, ptr %28, align 8, !tbaa !11
  %30 = getelementptr inbounds ptr, ptr %29, i64 2
  %31 = load ptr, ptr %30, align 8
  %32 = invoke noundef i32 %31(ptr noundef nonnull align 8 dereferenceable(44) %28)
          to label %33 unwind label %58

33:                                               ; preds = %25
  store i32 %32, ptr %10, align 4, !tbaa !9
  %34 = load i32, ptr %4, align 4, !tbaa !9
  %35 = load i32, ptr %10, align 4, !tbaa !9
  %36 = and i32 %34, %35
  %37 = load i32, ptr %10, align 4, !tbaa !9
  %38 = icmp eq i32 %36, %37
  br i1 %38, label %39, label %41

39:                                               ; preds = %33
  %40 = load ptr, ptr %9, align 8, !tbaa !5
  store ptr %40, ptr %2, align 8
  store i32 1, ptr %8, align 4
  br label %42

41:                                               ; preds = %33
  store i32 0, ptr %8, align 4
  br label %42

42:                                               ; preds = %41, %39
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #5
  %43 = load i32, ptr %8, align 4
  switch i32 %43, label %45 [
    i32 0, label %44
  ]

44:                                               ; preds = %42
  store i32 0, ptr %8, align 4
  br label %45

45:                                               ; preds = %44, %42
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #5
  %46 = load i32, ptr %8, align 4
  switch i32 %46, label %51 [
    i32 0, label %47
  ]

47:                                               ; preds = %45
  br label %48

48:                                               ; preds = %47
  %49 = load ptr, ptr %6, align 8, !tbaa !5
  %50 = getelementptr inbounds ptr, ptr %49, i32 1
  store ptr %50, ptr %6, align 8, !tbaa !5
  br label %20

51:                                               ; preds = %45, %24
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #5
  %52 = load i32, ptr %8, align 4
  switch i32 %52, label %56 [
    i32 2, label %53
  ]

53:                                               ; preds = %51
  %54 = invoke noundef ptr @_ZN8simdjson8internal25get_unsupported_singletonEv()
          to label %55 unwind label %58

55:                                               ; preds = %53
  store ptr %54, ptr %2, align 8
  store i32 1, ptr %8, align 4
  br label %56

56:                                               ; preds = %55, %51
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #5
  %57 = load ptr, ptr %2, align 8
  ret ptr %57

58:                                               ; preds = %53, %25, %13, %1
  %59 = landingpad { ptr, i32 }
          catch ptr null
  %60 = extractvalue { ptr, i32 } %59, 0
  call void @__clang_call_terminate(ptr %60) #6
  unreachable
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #2 = { inlinehint 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 #3 = { 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 #4 = { 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 = { nounwind }
attributes #6 = { 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 = !{!"int", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"vtable pointer", !8, 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"

declare i32 @__gxx_personality_v0(...)

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

; Function Attrs: inlinehint mustprogress uwtable
declare hidden noundef i32 @_ZN8simdjson8internalL30detect_supported_architecturesEv() local_unnamed_addr #1

; Function Attrs: mustprogress uwtable
declare dso_local noundef ptr @_ZN8simdjson8internal25get_unsupported_singletonEv() local_unnamed_addr #2

; Function Attrs: mustprogress uwtable
declare hidden noundef nonnull align 8 dereferenceable(16) ptr @_ZN8simdjson8internalL37get_available_implementation_pointersEv() local_unnamed_addr #2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef ptr @_ZNKSt16initializer_listIPKN8simdjson14implementationEE5beginEv(ptr noundef nonnull align 8 dereferenceable(16)) local_unnamed_addr #3 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef ptr @_ZNKSt16initializer_listIPKN8simdjson14implementationEE3endEv(ptr noundef nonnull align 8 dereferenceable(16)) local_unnamed_addr #3 align 2

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef ptr @_ZNK8simdjson8internal29available_implementation_list21detect_best_supportedEv(ptr nocapture noundef nonnull readnone align 1 dereferenceable(1) %0) local_unnamed_addr #3 align 2 personality ptr @__gxx_personality_v0 {
  %2 = invoke noundef i32 @_ZN8simdjson8internalL30detect_supported_architecturesEv()
          to label %3 unwind label %.loopexit.split-lp

3:                                                ; preds = %1
  %4 = invoke noundef nonnull align 8 dereferenceable(16) ptr @_ZN8simdjson8internalL37get_available_implementation_pointersEv()
          to label %5 unwind label %.loopexit.split-lp

5:                                                ; preds = %3
  %6 = tail call noundef ptr @_ZNKSt16initializer_listIPKN8simdjson14implementationEE5beginEv(ptr noundef nonnull align 8 dereferenceable(16) %4) #4
  %7 = tail call noundef ptr @_ZNKSt16initializer_listIPKN8simdjson14implementationEE3endEv(ptr noundef nonnull align 8 dereferenceable(16) %4) #4
  %.not24 = icmp eq ptr %6, %7
  br i1 %.not24, label %._crit_edge, label %.lr.ph

8:                                                ; preds = %15
  %9 = getelementptr inbounds i8, ptr %.01725, i64 8
  %.not = icmp eq ptr %9, %7
  br i1 %.not, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %5, %8
  %.01725 = phi ptr [ %9, %8 ], [ %6, %5 ]
  %10 = load ptr, ptr %.01725, align 8, !tbaa !5
  %11 = load ptr, ptr %10, align 8, !tbaa !9
  %12 = getelementptr inbounds i8, ptr %11, i64 16
  %13 = load ptr, ptr %12, align 8
  %14 = invoke noundef i32 %13(ptr noundef nonnull align 8 dereferenceable(44) %10)
          to label %15 unwind label %.loopexit

15:                                               ; preds = %.lr.ph
  %16 = and i32 %14, %2
  %.not20 = icmp eq i32 %16, %14
  br i1 %.not20, label %.loopexit22, label %8

._crit_edge:                                      ; preds = %8, %5
  %17 = invoke noundef ptr @_ZN8simdjson8internal25get_unsupported_singletonEv()
          to label %.loopexit22 unwind label %.loopexit.split-lp

.loopexit22:                                      ; preds = %15, %._crit_edge
  %.3 = phi ptr [ %17, %._crit_edge ], [ %10, %15 ]
  ret ptr %.3

.loopexit:                                        ; preds = %.lr.ph
  %lpad.loopexit = landingpad { ptr, i32 }
          catch ptr null
  br label %18

.loopexit.split-lp:                               ; preds = %1, %3, %._crit_edge
  %lpad.loopexit.split-lp = landingpad { ptr, i32 }
          catch ptr null
  br label %18

18:                                               ; preds = %.loopexit.split-lp, %.loopexit
  %lpad.phi = phi { ptr, i32 } [ %lpad.loopexit, %.loopexit ], [ %lpad.loopexit.split-lp, %.loopexit.split-lp ]
  %19 = extractvalue { ptr, i32 } %lpad.phi, 0
  tail call void @__clang_call_terminate(ptr %19) #5
  unreachable
}

attributes #0 = { 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 #1 = { inlinehint 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 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 = { 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 = { nounwind }
attributes #5 = { 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 = !{!"vtable pointer", !8, i64 0}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass