; LLVM IR from khushmmehta/Scorch-V :: src/ScorchVkEngine/Abstractions (VulkanMemoryAllocator)

; 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.VmaJsonWriter = type <{ ptr, %class.VmaVector.0, i8, [7 x i8] }>
%class.VmaVector.0 = type { %struct.VmaStlAllocator.1, ptr, i64, i64 }
%struct.VmaStlAllocator.1 = type { ptr }

@.str.2 = external hidden unnamed_addr constant [84 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [15 x i8], align 1
@__PRETTY_FUNCTION__._ZN13VmaJsonWriter14ContinueStringEPKc = external hidden unnamed_addr constant [49 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.12 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.13 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.14 = external hidden unnamed_addr constant [42 x i8], align 1

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN16VmaStringBuilder3AddEPKc(ptr noundef nonnull align 8 dereferenceable(32), ptr noundef) #0 align 2

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

; Function Attrs: nounwind willreturn memory(read)
declare i64 @strlen(ptr noundef) #2

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

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) #3

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN16VmaStringBuilder3AddEc(ptr noundef nonnull align 8 dereferenceable(32), i8 noundef signext) #0 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN13VmaJsonWriter14ContinueStringEPKc(ptr noundef nonnull align 8 dereferenceable(41) %0, ptr noundef %1) #0 align 2 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca i64, align 8
  %6 = alloca i64, align 8
  %7 = alloca i8, align 1
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  %8 = load ptr, ptr %3, align 8
  %9 = getelementptr inbounds %class.VmaJsonWriter, ptr %8, i32 0, i32 2
  %10 = load i8, ptr %9, align 8, !tbaa !9, !range !15, !noundef !16
  %11 = trunc i8 %10 to i1
  br i1 %11, label %12, label %13

12:                                               ; preds = %2
  br label %15

13:                                               ; preds = %2
  call void @__assert_fail(ptr noundef @.str.6, ptr noundef @.str.2, i32 noundef 5708, ptr noundef @__PRETTY_FUNCTION__._ZN13VmaJsonWriter14ContinueStringEPKc) #4
  unreachable

14:                                               ; No predecessors!
  br label %15

15:                                               ; preds = %14, %12
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #5
  %16 = load ptr, ptr %4, align 8, !tbaa !5
  %17 = call i64 @strlen(ptr noundef %16) #6
  store i64 %17, ptr %5, align 8, !tbaa !17
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #5
  store i64 0, ptr %6, align 8, !tbaa !17
  br label %18

18:                                               ; preds = %72, %15
  %19 = load i64, ptr %6, align 8, !tbaa !17
  %20 = load i64, ptr %5, align 8, !tbaa !17
  %21 = icmp ult i64 %19, %20
  br i1 %21, label %23, label %22

22:                                               ; preds = %18
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #5
  br label %75

23:                                               ; preds = %18
  call void @llvm.lifetime.start.p0(i64 1, ptr %7) #5
  %24 = load ptr, ptr %4, align 8, !tbaa !5
  %25 = load i64, ptr %6, align 8, !tbaa !17
  %26 = getelementptr inbounds i8, ptr %24, i64 %25
  %27 = load i8, ptr %26, align 1, !tbaa !18
  store i8 %27, ptr %7, align 1, !tbaa !18
  %28 = load i8, ptr %7, align 1, !tbaa !18
  %29 = sext i8 %28 to i32
  %30 = icmp eq i32 %29, 92
  br i1 %30, label %31, label %34

31:                                               ; preds = %23
  %32 = getelementptr inbounds %class.VmaJsonWriter, ptr %8, i32 0, i32 0
  %33 = load ptr, ptr %32, align 8, !tbaa !19
  call void @_ZN16VmaStringBuilder3AddEPKc(ptr noundef nonnull align 8 dereferenceable(32) %33, ptr noundef @.str.7)
  br label %71

34:                                               ; preds = %23
  %35 = load i8, ptr %7, align 1, !tbaa !18
  %36 = sext i8 %35 to i32
  %37 = icmp eq i32 %36, 34
  br i1 %37, label %38, label %41

38:                                               ; preds = %34
  %39 = getelementptr inbounds %class.VmaJsonWriter, ptr %8, i32 0, i32 0
  %40 = load ptr, ptr %39, align 8, !tbaa !19
  call void @_ZN16VmaStringBuilder3AddEPKc(ptr noundef nonnull align 8 dereferenceable(32) %40, ptr noundef @.str.8)
  br label %70

41:                                               ; preds = %34
  %42 = load i8, ptr %7, align 1, !tbaa !18
  %43 = zext i8 %42 to i32
  %44 = icmp sge i32 %43, 32
  br i1 %44, label %45, label %49

45:                                               ; preds = %41
  %46 = getelementptr inbounds %class.VmaJsonWriter, ptr %8, i32 0, i32 0
  %47 = load ptr, ptr %46, align 8, !tbaa !19
  %48 = load i8, ptr %7, align 1, !tbaa !18
  call void @_ZN16VmaStringBuilder3AddEc(ptr noundef nonnull align 8 dereferenceable(32) %47, i8 noundef signext %48)
  br label %69

49:                                               ; preds = %41
  %50 = load i8, ptr %7, align 1, !tbaa !18
  %51 = sext i8 %50 to i32
  switch i32 %51, label %67 [
    i32 8, label %52
    i32 12, label %55
    i32 10, label %58
    i32 13, label %61
    i32 9, label %64
  ]

52:                                               ; preds = %49
  %53 = getelementptr inbounds %class.VmaJsonWriter, ptr %8, i32 0, i32 0
  %54 = load ptr, ptr %53, align 8, !tbaa !19
  call void @_ZN16VmaStringBuilder3AddEPKc(ptr noundef nonnull align 8 dereferenceable(32) %54, ptr noundef @.str.9)
  br label %68

55:                                               ; preds = %49
  %56 = getelementptr inbounds %class.VmaJsonWriter, ptr %8, i32 0, i32 0
  %57 = load ptr, ptr %56, align 8, !tbaa !19
  call void @_ZN16VmaStringBuilder3AddEPKc(ptr noundef nonnull align 8 dereferenceable(32) %57, ptr noundef @.str.10)
  br label %68

58:                                               ; preds = %49
  %59 = getelementptr inbounds %class.VmaJsonWriter, ptr %8, i32 0, i32 0
  %60 = load ptr, ptr %59, align 8, !tbaa !19
  call void @_ZN16VmaStringBuilder3AddEPKc(ptr noundef nonnull align 8 dereferenceable(32) %60, ptr noundef @.str.11)
  br label %68

61:                                               ; preds = %49
  %62 = getelementptr inbounds %class.VmaJsonWriter, ptr %8, i32 0, i32 0
  %63 = load ptr, ptr %62, align 8, !tbaa !19
  call void @_ZN16VmaStringBuilder3AddEPKc(ptr noundef nonnull align 8 dereferenceable(32) %63, ptr noundef @.str.12)
  br label %68

64:                                               ; preds = %49
  %65 = getelementptr inbounds %class.VmaJsonWriter, ptr %8, i32 0, i32 0
  %66 = load ptr, ptr %65, align 8, !tbaa !19
  call void @_ZN16VmaStringBuilder3AddEPKc(ptr noundef nonnull align 8 dereferenceable(32) %66, ptr noundef @.str.13)
  br label %68

67:                                               ; preds = %49
  call void @__assert_fail(ptr noundef @.str.14, ptr noundef @.str.2, i32 noundef 5744, ptr noundef @__PRETTY_FUNCTION__._ZN13VmaJsonWriter14ContinueStringEPKc) #4
  unreachable

68:                                               ; preds = %64, %61, %58, %55, %52
  br label %69

69:                                               ; preds = %68, %45
  br label %70

70:                                               ; preds = %69, %38
  br label %71

71:                                               ; preds = %70, %31
  call void @llvm.lifetime.end.p0(i64 1, ptr %7) #5
  br label %72

72:                                               ; preds = %71
  %73 = load i64, ptr %6, align 8, !tbaa !17
  %74 = add i64 %73, 1
  store i64 %74, ptr %6, align 8, !tbaa !17
  br label %18, !llvm.loop !20

75:                                               ; preds = %22
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #5
  ret void
}

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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { nounwind willreturn memory(read) "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 = { noreturn 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 = { noreturn nounwind }
attributes #5 = { nounwind }
attributes #6 = { nounwind willreturn memory(read) }

!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, !14, i64 40}
!10 = !{!"_ZTS13VmaJsonWriter", !6, i64 0, !11, i64 8, !14, i64 40}
!11 = !{!"_ZTS9VmaVectorIN13VmaJsonWriter9StackItemE15VmaStlAllocatorIS1_EE", !12, i64 0, !6, i64 8, !13, i64 16, !13, i64 24}
!12 = !{!"_ZTS15VmaStlAllocatorIN13VmaJsonWriter9StackItemEE", !6, i64 0}
!13 = !{!"long", !7, i64 0}
!14 = !{!"bool", !7, i64 0}
!15 = !{i8 0, i8 2}
!16 = !{}
!17 = !{!13, !13, i64 0}
!18 = !{!7, !7, i64 0}
!19 = !{!10, !6, i64 0}
!20 = distinct !{!20, !21}
!21 = !{!"llvm.loop.mustprogress"}


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

@.str.2 = external hidden unnamed_addr constant [84 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [15 x i8], align 1
@__PRETTY_FUNCTION__._ZN13VmaJsonWriter14ContinueStringEPKc = external hidden unnamed_addr constant [49 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.12 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.13 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.14 = external hidden unnamed_addr constant [42 x i8], align 1

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN16VmaStringBuilder3AddEPKc(ptr noundef nonnull align 8 dereferenceable(32), ptr noundef) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress nofree nounwind willreturn memory(argmem: read)
declare i64 @strlen(ptr nocapture noundef) local_unnamed_addr #1

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN16VmaStringBuilder3AddEc(ptr noundef nonnull align 8 dereferenceable(32), i8 noundef signext) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN13VmaJsonWriter14ContinueStringEPKc(ptr nocapture noundef nonnull readonly align 8 dereferenceable(41) %0, ptr nocapture noundef readonly %1) local_unnamed_addr #0 align 2 {
  %3 = getelementptr inbounds i8, ptr %0, i64 40
  %4 = load i8, ptr %3, align 8, !tbaa !5, !range !14, !noundef !15
  %5 = trunc nuw i8 %4 to i1
  br i1 %5, label %7, label %6

6:                                                ; preds = %2
  tail call void @__assert_fail(ptr noundef nonnull @.str.6, ptr noundef nonnull @.str.2, i32 noundef 5708, ptr noundef nonnull @__PRETTY_FUNCTION__._ZN13VmaJsonWriter14ContinueStringEPKc) #3
  unreachable

7:                                                ; preds = %2
  %8 = tail call i64 @strlen(ptr noundef nonnull dereferenceable(1) %1) #4
  %.not = icmp eq i64 %8, 0
  br i1 %.not, label %._crit_edge, label %.lr.ph

._crit_edge:                                      ; preds = %31, %7
  ret void

.lr.ph:                                           ; preds = %7, %31
  %.012 = phi i64 [ %32, %31 ], [ 0, %7 ]
  %9 = getelementptr inbounds i8, ptr %1, i64 %.012
  %10 = load i8, ptr %9, align 1, !tbaa !16
  switch i8 %10, label %15 [
    i8 92, label %11
    i8 34, label %13
  ]

11:                                               ; preds = %.lr.ph
  %12 = load ptr, ptr %0, align 8, !tbaa !17
  tail call void @_ZN16VmaStringBuilder3AddEPKc(ptr noundef nonnull align 8 dereferenceable(32) %12, ptr noundef nonnull @.str.7)
  br label %31

13:                                               ; preds = %.lr.ph
  %14 = load ptr, ptr %0, align 8, !tbaa !17
  tail call void @_ZN16VmaStringBuilder3AddEPKc(ptr noundef nonnull align 8 dereferenceable(32) %14, ptr noundef nonnull @.str.8)
  br label %31

15:                                               ; preds = %.lr.ph
  %16 = icmp ugt i8 %10, 31
  br i1 %16, label %17, label %19

17:                                               ; preds = %15
  %18 = load ptr, ptr %0, align 8, !tbaa !17
  tail call void @_ZN16VmaStringBuilder3AddEc(ptr noundef nonnull align 8 dereferenceable(32) %18, i8 noundef signext %10)
  br label %31

19:                                               ; preds = %15
  switch i8 %10, label %30 [
    i8 8, label %20
    i8 12, label %22
    i8 10, label %24
    i8 13, label %26
    i8 9, label %28
  ]

20:                                               ; preds = %19
  %21 = load ptr, ptr %0, align 8, !tbaa !17
  tail call void @_ZN16VmaStringBuilder3AddEPKc(ptr noundef nonnull align 8 dereferenceable(32) %21, ptr noundef nonnull @.str.9)
  br label %31

22:                                               ; preds = %19
  %23 = load ptr, ptr %0, align 8, !tbaa !17
  tail call void @_ZN16VmaStringBuilder3AddEPKc(ptr noundef nonnull align 8 dereferenceable(32) %23, ptr noundef nonnull @.str.10)
  br label %31

24:                                               ; preds = %19
  %25 = load ptr, ptr %0, align 8, !tbaa !17
  tail call void @_ZN16VmaStringBuilder3AddEPKc(ptr noundef nonnull align 8 dereferenceable(32) %25, ptr noundef nonnull @.str.11)
  br label %31

26:                                               ; preds = %19
  %27 = load ptr, ptr %0, align 8, !tbaa !17
  tail call void @_ZN16VmaStringBuilder3AddEPKc(ptr noundef nonnull align 8 dereferenceable(32) %27, ptr noundef nonnull @.str.12)
  br label %31

28:                                               ; preds = %19
  %29 = load ptr, ptr %0, align 8, !tbaa !17
  tail call void @_ZN16VmaStringBuilder3AddEPKc(ptr noundef nonnull align 8 dereferenceable(32) %29, ptr noundef nonnull @.str.13)
  br label %31

30:                                               ; preds = %19
  tail call void @__assert_fail(ptr noundef nonnull @.str.14, ptr noundef nonnull @.str.2, i32 noundef 5744, ptr noundef nonnull @__PRETTY_FUNCTION__._ZN13VmaJsonWriter14ContinueStringEPKc) #3
  unreachable

31:                                               ; preds = %13, %20, %22, %24, %26, %28, %17, %11
  %32 = add nuw i64 %.012, 1
  %exitcond.not = icmp eq i64 %32, %8
  br i1 %exitcond.not, label %._crit_edge, label %.lr.ph, !llvm.loop !18
}

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 = { mustprogress nofree nounwind willreturn memory(argmem: read) "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 = { noreturn 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 = { noreturn nounwind }
attributes #4 = { nounwind willreturn memory(read) }

!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, !13, i64 40}
!6 = !{!"_ZTS13VmaJsonWriter", !7, i64 0, !10, i64 8, !13, i64 40}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"_ZTS9VmaVectorIN13VmaJsonWriter9StackItemE15VmaStlAllocatorIS1_EE", !11, i64 0, !7, i64 8, !12, i64 16, !12, i64 24}
!11 = !{!"_ZTS15VmaStlAllocatorIN13VmaJsonWriter9StackItemEE", !7, i64 0}
!12 = !{!"long", !8, i64 0}
!13 = !{!"bool", !8, i64 0}
!14 = !{i8 0, i8 2}
!15 = !{}
!16 = !{!8, !8, i64 0}
!17 = !{!6, !7, i64 0}
!18 = distinct !{!18, !19}
!19 = !{!"llvm.loop.mustprogress"}


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