; LLVM IR from TobiasKozel/VAE :: external/tracy/libbacktrace (dwarf)

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

%"struct.tracy::backtrace_state" = type { ptr, i32, ptr, ptr, ptr, ptr, ptr, i32, i32, ptr }
%"struct.tracy::dwarf_data" = type { ptr, ptr, i64, ptr, i64, ptr, i64, %"struct.tracy::dwarf_sections", i32, %"struct.tracy::function_vector" }
%"struct.tracy::dwarf_sections" = type { [9 x ptr], [9 x i64] }
%"struct.tracy::function_vector" = type { %"struct.tracy::backtrace_vector", i64 }
%"struct.tracy::backtrace_vector" = type { ptr, i64, i64 }

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_ZN5tracy19backtrace_dwarf_addEPNS_15backtrace_stateEmPKNS_14dwarf_sectionsEiPNS_10dwarf_dataEPFvPvPKciES7_PPFiS1_mPFiS7_mmS9_iS9_ESB_S7_EPS6_(ptr noundef %0, i64 noundef %1, ptr noundef %2, i32 noundef %3, ptr noundef %4, ptr noundef %5, ptr noundef %6, ptr noundef %7, ptr noundef %8) #0 {
  %10 = alloca i32, align 4
  %11 = alloca ptr, align 8
  %12 = alloca i64, align 8
  %13 = alloca ptr, align 8
  %14 = alloca i32, align 4
  %15 = alloca ptr, align 8
  %16 = alloca ptr, align 8
  %17 = alloca ptr, align 8
  %18 = alloca ptr, align 8
  %19 = alloca ptr, align 8
  %20 = alloca ptr, align 8
  %21 = alloca i32, align 4
  %22 = alloca ptr, align 8
  %23 = alloca ptr, align 8
  %24 = alloca ptr, align 8
  %25 = alloca ptr, align 8
  store ptr %0, ptr %11, align 8, !tbaa !5
  store i64 %1, ptr %12, align 8, !tbaa !9
  store ptr %2, ptr %13, align 8, !tbaa !5
  store i32 %3, ptr %14, align 4, !tbaa !11
  store ptr %4, ptr %15, align 8, !tbaa !5
  store ptr %5, ptr %16, align 8, !tbaa !5
  store ptr %6, ptr %17, align 8, !tbaa !5
  store ptr %7, ptr %18, align 8, !tbaa !5
  store ptr %8, ptr %19, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %20) #3
  %26 = load ptr, ptr %11, align 8, !tbaa !5
  %27 = load i64, ptr %12, align 8, !tbaa !9
  %28 = load ptr, ptr %13, align 8, !tbaa !5
  %29 = load i32, ptr %14, align 4, !tbaa !11
  %30 = load ptr, ptr %15, align 8, !tbaa !5
  %31 = load ptr, ptr %16, align 8, !tbaa !5
  %32 = load ptr, ptr %17, align 8, !tbaa !5
  %33 = call noundef ptr @_ZN5tracyL16build_dwarf_dataEPNS_15backtrace_stateEmPKNS_14dwarf_sectionsEiPNS_10dwarf_dataEPFvPvPKciES7_(ptr noundef %26, i64 noundef %27, ptr noundef %28, i32 noundef %29, ptr noundef %30, ptr noundef %31, ptr noundef %32)
  store ptr %33, ptr %20, align 8, !tbaa !5
  %34 = load ptr, ptr %20, align 8, !tbaa !5
  %35 = icmp eq ptr %34, null
  br i1 %35, label %36, label %37

36:                                               ; preds = %9
  store i32 0, ptr %10, align 4
  store i32 1, ptr %21, align 4
  br label %92

37:                                               ; preds = %9
  %38 = load ptr, ptr %19, align 8, !tbaa !5
  %39 = icmp ne ptr %38, null
  br i1 %39, label %40, label %43

40:                                               ; preds = %37
  %41 = load ptr, ptr %20, align 8, !tbaa !5
  %42 = load ptr, ptr %19, align 8, !tbaa !5
  store ptr %41, ptr %42, align 8, !tbaa !5
  br label %43

43:                                               ; preds = %40, %37
  %44 = load ptr, ptr %11, align 8, !tbaa !5
  %45 = getelementptr inbounds %"struct.tracy::backtrace_state", ptr %44, i32 0, i32 1
  %46 = load i32, ptr %45, align 8, !tbaa !13
  %47 = icmp ne i32 %46, 0
  br i1 %47, label %63, label %48

48:                                               ; preds = %43
  call void @llvm.lifetime.start.p0(i64 8, ptr %22) #3
  %49 = load ptr, ptr %11, align 8, !tbaa !5
  %50 = getelementptr inbounds %"struct.tracy::backtrace_state", ptr %49, i32 0, i32 4
  store ptr %50, ptr %22, align 8, !tbaa !5
  br label %51

51:                                               ; preds = %56, %48
  %52 = load ptr, ptr %22, align 8, !tbaa !5
  %53 = load ptr, ptr %52, align 8, !tbaa !5
  %54 = icmp ne ptr %53, null
  br i1 %54, label %55, label %60

55:                                               ; preds = %51
  br label %56

56:                                               ; preds = %55
  %57 = load ptr, ptr %22, align 8, !tbaa !5
  %58 = load ptr, ptr %57, align 8, !tbaa !5
  %59 = getelementptr inbounds %"struct.tracy::dwarf_data", ptr %58, i32 0, i32 0
  store ptr %59, ptr %22, align 8, !tbaa !5
  br label %51, !llvm.loop !15

60:                                               ; preds = %51
  %61 = load ptr, ptr %20, align 8, !tbaa !5
  %62 = load ptr, ptr %22, align 8, !tbaa !5
  store ptr %61, ptr %62, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 8, ptr %22) #3
  br label %90

63:                                               ; preds = %43
  br label %64

64:                                               ; preds = %88, %63
  br label %65

65:                                               ; preds = %64
  call void @llvm.lifetime.start.p0(i64 8, ptr %23) #3
  %66 = load ptr, ptr %11, align 8, !tbaa !5
  %67 = getelementptr inbounds %"struct.tracy::backtrace_state", ptr %66, i32 0, i32 4
  store ptr %67, ptr %23, align 8, !tbaa !5
  br label %68

68:                                               ; preds = %81, %65
  br label %69

69:                                               ; preds = %68
  call void @llvm.lifetime.start.p0(i64 8, ptr %24) #3
  %70 = load ptr, ptr %23, align 8, !tbaa !5
  %71 = load atomic i64, ptr %70 acquire, align 8
  store i64 %71, ptr %25, align 8
  %72 = load ptr, ptr %25, align 8, !tbaa !5
  store ptr %72, ptr %24, align 8, !tbaa !5
  %73 = load ptr, ptr %24, align 8, !tbaa !5
  %74 = icmp eq ptr %73, null
  br i1 %74, label %75, label %76

75:                                               ; preds = %69
  store i32 8, ptr %21, align 4
  br label %79

76:                                               ; preds = %69
  %77 = load ptr, ptr %24, align 8, !tbaa !5
  %78 = getelementptr inbounds %"struct.tracy::dwarf_data", ptr %77, i32 0, i32 0
  store ptr %78, ptr %23, align 8, !tbaa !5
  store i32 0, ptr %21, align 4
  br label %79

79:                                               ; preds = %76, %75
  call void @llvm.lifetime.end.p0(i64 8, ptr %24) #3
  %80 = load i32, ptr %21, align 4
  switch i32 %80, label %94 [
    i32 0, label %81
    i32 8, label %82
  ]

81:                                               ; preds = %79
  br label %68, !llvm.loop !17

82:                                               ; preds = %79
  call void @abort() #4
  unreachable

83:                                               ; No predecessors!
  br i1 true, label %84, label %85

84:                                               ; preds = %83
  store i32 6, ptr %21, align 4
  br label %86

85:                                               ; preds = %83
  store i32 0, ptr %21, align 4
  br label %86

86:                                               ; preds = %85, %84
  call void @llvm.lifetime.end.p0(i64 8, ptr %23) #3
  %87 = load i32, ptr %21, align 4
  switch i32 %87, label %94 [
    i32 0, label %88
    i32 6, label %89
  ]

88:                                               ; preds = %86
  br label %64, !llvm.loop !18

89:                                               ; preds = %86
  br label %90

90:                                               ; preds = %89, %60
  %91 = load ptr, ptr %18, align 8, !tbaa !5
  store ptr @_ZN5tracyL14dwarf_filelineEPNS_15backtrace_stateEmPFiPvmmPKciS4_EPFvS2_S4_iES2_, ptr %91, align 8, !tbaa !5
  store i32 1, ptr %10, align 4
  store i32 1, ptr %21, align 4
  br label %92

92:                                               ; preds = %90, %36
  call void @llvm.lifetime.end.p0(i64 8, ptr %20) #3
  %93 = load i32, ptr %10, align 4
  ret i32 %93

94:                                               ; preds = %86, %79
  unreachable
}

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

; Function Attrs: mustprogress uwtable
declare hidden noundef ptr @_ZN5tracyL16build_dwarf_dataEPNS_15backtrace_stateEmPKNS_14dwarf_sectionsEiPNS_10dwarf_dataEPFvPvPKciES7_(ptr noundef, i64 noundef, ptr noundef, i32 noundef, ptr noundef, ptr noundef, ptr noundef) #0

; 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 @abort() #2

; Function Attrs: mustprogress uwtable
declare hidden noundef i32 @_ZN5tracyL14dwarf_filelineEPNS_15backtrace_stateEmPFiPvmmPKciS4_EPFvS2_S4_iES2_(ptr noundef, i64 noundef, ptr noundef, ptr noundef, ptr noundef) #0

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 = { 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 = { nounwind }
attributes #4 = { 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 = !{!"long", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{!14, !12, i64 8}
!14 = !{!"_ZTSN5tracy15backtrace_stateE", !6, i64 0, !12, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !6, i64 48, !12, i64 56, !12, i64 60, !6, i64 64}
!15 = distinct !{!15, !16}
!16 = !{!"llvm.loop.mustprogress"}
!17 = distinct !{!17, !16}
!18 = distinct !{!18, !16}


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

; Function Attrs: mustprogress uwtable
define dso_local noundef range(i32 0, 2) i32 @_ZN5tracy19backtrace_dwarf_addEPNS_15backtrace_stateEmPKNS_14dwarf_sectionsEiPNS_10dwarf_dataEPFvPvPKciES7_PPFiS1_mPFiS7_mmS9_iS9_ESB_S7_EPS6_(ptr noundef %0, i64 noundef %1, ptr noundef %2, i32 noundef %3, ptr noundef %4, ptr noundef %5, ptr noundef %6, ptr nocapture noundef writeonly %7, ptr noundef writeonly %8) local_unnamed_addr #0 {
  %10 = tail call noundef ptr @_ZN5tracyL16build_dwarf_dataEPNS_15backtrace_stateEmPKNS_14dwarf_sectionsEiPNS_10dwarf_dataEPFvPvPKciES7_(ptr noundef %0, i64 noundef %1, ptr noundef %2, i32 noundef %3, ptr noundef %4, ptr noundef %5, ptr noundef %6)
  %11 = icmp eq ptr %10, null
  br i1 %11, label %24, label %12

12:                                               ; preds = %9
  %.not = icmp eq ptr %8, null
  br i1 %.not, label %14, label %13

13:                                               ; preds = %12
  store ptr %10, ptr %8, align 8, !tbaa !5
  br label %14

14:                                               ; preds = %13, %12
  %15 = getelementptr inbounds i8, ptr %0, i64 8
  %16 = load i32, ptr %15, align 8, !tbaa !9
  %.not31 = icmp eq i32 %16, 0
  %17 = getelementptr inbounds i8, ptr %0, i64 32
  br i1 %.not31, label %.preheader, label %.preheader33

.preheader:                                       ; preds = %14, %.preheader
  %.026 = phi ptr [ %18, %.preheader ], [ %17, %14 ]
  %18 = load ptr, ptr %.026, align 8, !tbaa !5
  %.not32 = icmp eq ptr %18, null
  br i1 %.not32, label %19, label %.preheader, !llvm.loop !12

19:                                               ; preds = %.preheader
  store ptr %10, ptr %.026, align 8, !tbaa !5
  store ptr @_ZN5tracyL14dwarf_filelineEPNS_15backtrace_stateEmPFiPvmmPKciS4_EPFvS2_S4_iES2_, ptr %7, align 8, !tbaa !5
  br label %24

.preheader33:                                     ; preds = %14, %.preheader33
  %.025 = phi ptr [ %22, %.preheader33 ], [ %17, %14 ]
  %20 = load atomic i64, ptr %.025 acquire, align 8
  %21 = icmp eq i64 %20, 0
  %22 = inttoptr i64 %20 to ptr
  br i1 %21, label %23, label %.preheader33

23:                                               ; preds = %.preheader33
  tail call void @abort() #2
  unreachable

24:                                               ; preds = %9, %19
  %.0 = phi i32 [ 1, %19 ], [ 0, %9 ]
  ret i32 %.0
}

; Function Attrs: mustprogress uwtable
declare hidden noundef ptr @_ZN5tracyL16build_dwarf_dataEPNS_15backtrace_stateEmPKNS_14dwarf_sectionsEiPNS_10dwarf_dataEPFvPvPKciES7_(ptr noundef, i64 noundef, ptr noundef, i32 noundef, ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #0

; Function Attrs: noreturn nounwind
declare void @abort() local_unnamed_addr #1

; Function Attrs: mustprogress uwtable
declare hidden noundef i32 @_ZN5tracyL14dwarf_filelineEPNS_15backtrace_stateEmPFiPvmmPKciS4_EPFvS2_S4_iES2_(ptr noundef, i64 noundef, ptr noundef, ptr noundef, ptr noundef) #0

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 = { 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 #2 = { 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, !11, i64 8}
!10 = !{!"_ZTSN5tracy15backtrace_stateE", !6, i64 0, !11, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !6, i64 48, !11, i64 56, !11, i64 60, !6, i64 64}
!11 = !{!"int", !7, i64 0}
!12 = distinct !{!12, !13}
!13 = !{!"llvm.loop.mustprogress"}


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