; LLVM IR from Razakhel/RaZ :: extern/fastgltf/src (fastgltf)

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

; 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

; Function Attrs: mustprogress nounwind uwtable
declare noundef i64 @_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(32)) #1 align 2

; Function Attrs: mustprogress nounwind uwtable
declare noundef nonnull align 1 dereferenceable(1) ptr @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEixEm(ptr noundef nonnull align 8 dereferenceable(32), i64 noundef) #1 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN8fastgltf15prettyPrintJsonERNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE(ptr noundef nonnull align 8 dereferenceable(32) %0) #2 {
  %2 = alloca ptr, align 8
  %3 = alloca i64, align 8
  %4 = alloca i64, align 8
  %5 = alloca %class.anon.460, align 8
  store ptr %0, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #4
  store i64 0, ptr %3, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #4
  store i64 0, ptr %4, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 24, ptr %5) #4
  %6 = getelementptr inbounds %class.anon.460, ptr %5, i32 0, i32 0
  store ptr %3, ptr %6, align 8, !tbaa !5
  %7 = getelementptr inbounds %class.anon.460, ptr %5, i32 0, i32 1
  store ptr %4, ptr %7, align 8, !tbaa !5
  %8 = getelementptr inbounds %class.anon.460, ptr %5, i32 0, i32 2
  %9 = load ptr, ptr %2, align 8, !tbaa !5
  store ptr %9, ptr %8, align 8, !tbaa !5
  br label %10

10:                                               ; preds = %68, %1
  %11 = load i64, ptr %3, align 8, !tbaa !9
  %12 = load ptr, ptr %2, align 8, !tbaa !5
  %13 = call noundef i64 @_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(32) %12) #4
  %14 = icmp ult i64 %11, %13
  br i1 %14, label %15, label %69

15:                                               ; preds = %10
  %16 = load ptr, ptr %2, align 8, !tbaa !5
  %17 = load i64, ptr %3, align 8, !tbaa !9
  %18 = call noundef nonnull align 1 dereferenceable(1) ptr @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEixEm(ptr noundef nonnull align 8 dereferenceable(32) %16, i64 noundef %17)
  %19 = load i8, ptr %18, align 1, !tbaa !11
  %20 = sext i8 %19 to i32
  %21 = icmp eq i32 %20, 34
  br i1 %21, label %22, label %46

22:                                               ; preds = %15
  br label %23

23:                                               ; preds = %42, %22
  %24 = load i64, ptr %3, align 8, !tbaa !9
  %25 = add i64 %24, 1
  store i64 %25, ptr %3, align 8, !tbaa !9
  %26 = load ptr, ptr %2, align 8, !tbaa !5
  %27 = load i64, ptr %3, align 8, !tbaa !9
  %28 = call noundef nonnull align 1 dereferenceable(1) ptr @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEixEm(ptr noundef nonnull align 8 dereferenceable(32) %26, i64 noundef %27)
  %29 = load i8, ptr %28, align 1, !tbaa !11
  %30 = sext i8 %29 to i32
  %31 = icmp eq i32 %30, 34
  br i1 %31, label %32, label %41

32:                                               ; preds = %23
  %33 = load ptr, ptr %2, align 8, !tbaa !5
  %34 = load i64, ptr %3, align 8, !tbaa !9
  %35 = sub i64 %34, 1
  %36 = call noundef nonnull align 1 dereferenceable(1) ptr @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEixEm(ptr noundef nonnull align 8 dereferenceable(32) %33, i64 noundef %35)
  %37 = load i8, ptr %36, align 1, !tbaa !11
  %38 = sext i8 %37 to i32
  %39 = icmp ne i32 %38, 92
  br i1 %39, label %40, label %41

40:                                               ; preds = %32
  br label %43

41:                                               ; preds = %32, %23
  br label %42

42:                                               ; preds = %41
  br i1 true, label %23, label %43, !llvm.loop !12

43:                                               ; preds = %42, %40
  %44 = load i64, ptr %3, align 8, !tbaa !9
  %45 = add i64 %44, 1
  store i64 %45, ptr %3, align 8, !tbaa !9
  br label %46

46:                                               ; preds = %43, %15
  %47 = load ptr, ptr %2, align 8, !tbaa !5
  %48 = load i64, ptr %3, align 8, !tbaa !9
  %49 = call noundef nonnull align 1 dereferenceable(1) ptr @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEixEm(ptr noundef nonnull align 8 dereferenceable(32) %47, i64 noundef %48)
  %50 = load i8, ptr %49, align 1, !tbaa !11
  %51 = sext i8 %50 to i32
  switch i32 %51, label %65 [
    i32 123, label %52
    i32 91, label %52
    i32 125, label %57
    i32 93, label %57
    i32 44, label %62
  ]

52:                                               ; preds = %46, %46
  %53 = load i64, ptr %4, align 8, !tbaa !9
  %54 = add i64 %53, 1
  store i64 %54, ptr %4, align 8, !tbaa !9
  %55 = load i64, ptr %3, align 8, !tbaa !9
  %56 = add i64 %55, 1
  store i64 %56, ptr %3, align 8, !tbaa !9
  call void @"_ZZN8fastgltf15prettyPrintJsonERNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEENK3$_0clEv"(ptr noundef nonnull align 8 dereferenceable(24) %5)
  br label %68

57:                                               ; preds = %46, %46
  %58 = load i64, ptr %4, align 8, !tbaa !9
  %59 = add i64 %58, -1
  store i64 %59, ptr %4, align 8, !tbaa !9
  call void @"_ZZN8fastgltf15prettyPrintJsonERNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEENK3$_0clEv"(ptr noundef nonnull align 8 dereferenceable(24) %5)
  %60 = load i64, ptr %3, align 8, !tbaa !9
  %61 = add i64 %60, 1
  store i64 %61, ptr %3, align 8, !tbaa !9
  br label %68

62:                                               ; preds = %46
  %63 = load i64, ptr %3, align 8, !tbaa !9
  %64 = add i64 %63, 1
  store i64 %64, ptr %3, align 8, !tbaa !9
  call void @"_ZZN8fastgltf15prettyPrintJsonERNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEENK3$_0clEv"(ptr noundef nonnull align 8 dereferenceable(24) %5)
  br label %68

65:                                               ; preds = %46
  %66 = load i64, ptr %3, align 8, !tbaa !9
  %67 = add i64 %66, 1
  store i64 %67, ptr %3, align 8, !tbaa !9
  br label %68

68:                                               ; preds = %65, %62, %57, %52
  br label %10, !llvm.loop !14

69:                                               ; preds = %10
  call void @llvm.lifetime.end.p0(i64 24, ptr %5) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #4
  ret void
}

; Function Attrs: inlinehint mustprogress uwtable
declare hidden void @"_ZZN8fastgltf15prettyPrintJsonERNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEENK3$_0clEv"(ptr noundef nonnull align 8 dereferenceable(24)) #3 align 2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #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 = { 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 #4 = { 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 = !{!"long", !7, i64 0}
!11 = !{!7, !7, i64 0}
!12 = distinct !{!12, !13}
!13 = !{!"llvm.loop.mustprogress"}
!14 = distinct !{!14, !13}


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

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

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

; Function Attrs: mustprogress nounwind uwtable
declare noundef i64 @_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(32)) local_unnamed_addr #1 align 2

; Function Attrs: mustprogress nounwind uwtable
declare noundef nonnull align 1 dereferenceable(1) ptr @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEixEm(ptr noundef nonnull align 8 dereferenceable(32), i64 noundef) local_unnamed_addr #1 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN8fastgltf15prettyPrintJsonERNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE(ptr noundef nonnull align 8 dereferenceable(32) %0) local_unnamed_addr #2 {
  %2 = alloca i64, align 8
  %3 = alloca i64, align 8
  %4 = alloca %class.anon.460, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %2) #4
  store i64 0, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %3) #4
  store i64 0, ptr %3, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %4) #4
  store ptr %2, ptr %4, align 8, !tbaa !9
  %5 = getelementptr inbounds i8, ptr %4, i64 8
  store ptr %3, ptr %5, align 8, !tbaa !9
  %6 = getelementptr inbounds i8, ptr %4, i64 16
  store ptr %0, ptr %6, align 8, !tbaa !9
  %7 = call noundef i64 @_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(32) %0) #4
  %.not6 = icmp eq i64 %7, 0
  br i1 %.not6, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %1, %45
  %8 = load i64, ptr %2, align 8, !tbaa !5
  %9 = call noundef nonnull align 1 dereferenceable(1) ptr @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEixEm(ptr noundef nonnull align 8 dereferenceable(32) %0, i64 noundef %8)
  %10 = load i8, ptr %9, align 1, !tbaa !11
  %11 = icmp eq i8 %10, 34
  br i1 %11, label %.preheader, label %.lr.ph._crit_edge

.lr.ph._crit_edge:                                ; preds = %.lr.ph
  %.pre = load i64, ptr %2, align 8, !tbaa !5
  br label %25

.preheader:                                       ; preds = %.lr.ph, %.preheader.backedge
  %12 = load i64, ptr %2, align 8, !tbaa !5
  %13 = add i64 %12, 1
  store i64 %13, ptr %2, align 8, !tbaa !5
  %14 = call noundef nonnull align 1 dereferenceable(1) ptr @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEixEm(ptr noundef nonnull align 8 dereferenceable(32) %0, i64 noundef %13)
  %15 = load i8, ptr %14, align 1, !tbaa !11
  %16 = icmp eq i8 %15, 34
  br i1 %16, label %17, label %.preheader.backedge

.preheader.backedge:                              ; preds = %.preheader, %17
  br label %.preheader, !llvm.loop !12

17:                                               ; preds = %.preheader
  %18 = load i64, ptr %2, align 8, !tbaa !5
  %19 = add i64 %18, -1
  %20 = call noundef nonnull align 1 dereferenceable(1) ptr @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEixEm(ptr noundef nonnull align 8 dereferenceable(32) %0, i64 noundef %19)
  %21 = load i8, ptr %20, align 1, !tbaa !11
  %.not = icmp eq i8 %21, 92
  br i1 %.not, label %.preheader.backedge, label %22

22:                                               ; preds = %17
  %23 = load i64, ptr %2, align 8, !tbaa !5
  %24 = add i64 %23, 1
  store i64 %24, ptr %2, align 8, !tbaa !5
  br label %25

25:                                               ; preds = %.lr.ph._crit_edge, %22
  %26 = phi i64 [ %.pre, %.lr.ph._crit_edge ], [ %24, %22 ]
  %27 = call noundef nonnull align 1 dereferenceable(1) ptr @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEixEm(ptr noundef nonnull align 8 dereferenceable(32) %0, i64 noundef %26)
  %28 = load i8, ptr %27, align 1, !tbaa !11
  switch i8 %28, label %42 [
    i8 123, label %29
    i8 91, label %29
    i8 125, label %34
    i8 93, label %34
    i8 44, label %39
  ]

29:                                               ; preds = %25, %25
  %30 = load i64, ptr %3, align 8, !tbaa !5
  %31 = add i64 %30, 1
  store i64 %31, ptr %3, align 8, !tbaa !5
  %32 = load i64, ptr %2, align 8, !tbaa !5
  %33 = add i64 %32, 1
  store i64 %33, ptr %2, align 8, !tbaa !5
  call void @"_ZZN8fastgltf15prettyPrintJsonERNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEENK3$_0clEv"(ptr noundef nonnull align 8 dereferenceable(24) %4)
  br label %45

34:                                               ; preds = %25, %25
  %35 = load i64, ptr %3, align 8, !tbaa !5
  %36 = add i64 %35, -1
  store i64 %36, ptr %3, align 8, !tbaa !5
  call void @"_ZZN8fastgltf15prettyPrintJsonERNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEENK3$_0clEv"(ptr noundef nonnull align 8 dereferenceable(24) %4)
  %37 = load i64, ptr %2, align 8, !tbaa !5
  %38 = add i64 %37, 1
  store i64 %38, ptr %2, align 8, !tbaa !5
  br label %45

39:                                               ; preds = %25
  %40 = load i64, ptr %2, align 8, !tbaa !5
  %41 = add i64 %40, 1
  store i64 %41, ptr %2, align 8, !tbaa !5
  call void @"_ZZN8fastgltf15prettyPrintJsonERNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEENK3$_0clEv"(ptr noundef nonnull align 8 dereferenceable(24) %4)
  br label %45

42:                                               ; preds = %25
  %43 = load i64, ptr %2, align 8, !tbaa !5
  %44 = add i64 %43, 1
  store i64 %44, ptr %2, align 8, !tbaa !5
  br label %45

45:                                               ; preds = %42, %39, %34, %29
  %46 = load i64, ptr %2, align 8, !tbaa !5
  %47 = call noundef i64 @_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(32) %0) #4
  %48 = icmp ult i64 %46, %47
  br i1 %48, label %.lr.ph, label %._crit_edge, !llvm.loop !14

._crit_edge:                                      ; preds = %45, %1
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %4) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %2) #4
  ret void
}

; Function Attrs: inlinehint mustprogress uwtable
declare hidden void @"_ZZN8fastgltf15prettyPrintJsonERNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEENK3$_0clEv"(ptr noundef nonnull align 8 dereferenceable(24)) local_unnamed_addr #3 align 2

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #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 = { 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 #4 = { 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 = !{!"long", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = !{!7, !7, i64 0}
!12 = distinct !{!12, !13}
!13 = !{!"llvm.loop.mustprogress"}
!14 = distinct !{!14, !13}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,SROAPass,SimplifyCFGPass