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

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

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_ZN5tracy20backtrace_initializeEPNS_15backtrace_stateEPKciPFvPvS3_iES4_PPFiS1_mPFiS4_mmS3_iS3_ES6_S4_E(ptr noundef %0, ptr noundef %1, i32 noundef %2, ptr noundef %3, ptr noundef %4, ptr noundef %5) #0 {
  %7 = alloca i32, align 4
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca i32, align 4
  %11 = alloca ptr, align 8
  %12 = alloca ptr, align 8
  %13 = alloca ptr, align 8
  %14 = alloca ptr, align 8
  %15 = alloca i32, align 4
  %16 = alloca i32, align 4
  %17 = alloca ptr, align 8
  %18 = alloca ptr, align 8
  store ptr %0, ptr %8, align 8, !tbaa !5
  store ptr %1, ptr %9, align 8, !tbaa !5
  store i32 %2, ptr %10, align 4, !tbaa !9
  store ptr %3, ptr %11, align 8, !tbaa !5
  store ptr %4, ptr %12, align 8, !tbaa !5
  store ptr %5, ptr %13, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #3
  store ptr @_ZN5tracyL13macho_nodebugEPNS_15backtrace_stateEmPFiPvmmPKciS4_EPFvS2_S4_iES2_, ptr %14, align 8, !tbaa !5
  %19 = load ptr, ptr %8, align 8, !tbaa !5
  %20 = load ptr, ptr %9, align 8, !tbaa !5
  %21 = load i32, ptr %10, align 4, !tbaa !9
  %22 = load ptr, ptr %11, align 8, !tbaa !5
  %23 = load ptr, ptr %12, align 8, !tbaa !5
  %24 = call noundef i32 @_ZN5tracyL9macho_addEPNS_15backtrace_stateEPKcilPKhmiPFvPvS3_iES6_PPFiS1_mPFiS6_mmS3_iS3_ES8_S6_EPi(ptr noundef %19, ptr noundef %20, i32 noundef %21, i64 noundef 0, ptr noundef null, i64 noundef 0, i32 noundef 0, ptr noundef %22, ptr noundef %23, ptr noundef %14, ptr noundef %15)
  %25 = icmp ne i32 %24, 0
  br i1 %25, label %27, label %26

26:                                               ; preds = %6
  store i32 0, ptr %7, align 4
  store i32 1, ptr %16, align 4
  br label %85

27:                                               ; preds = %6
  %28 = load ptr, ptr %8, align 8, !tbaa !5
  %29 = getelementptr inbounds %"struct.tracy::backtrace_state", ptr %28, i32 0, i32 1
  %30 = load i32, ptr %29, align 8, !tbaa !11
  %31 = icmp ne i32 %30, 0
  br i1 %31, label %48, label %32

32:                                               ; preds = %27
  %33 = load i32, ptr %15, align 4, !tbaa !9
  %34 = icmp ne i32 %33, 0
  br i1 %34, label %35, label %38

35:                                               ; preds = %32
  %36 = load ptr, ptr %8, align 8, !tbaa !5
  %37 = getelementptr inbounds %"struct.tracy::backtrace_state", ptr %36, i32 0, i32 5
  store ptr @_ZN5tracyL13macho_syminfoEPNS_15backtrace_stateEmPFvPvmPKcmmEPFvS2_S4_iES2_, ptr %37, align 8, !tbaa !13
  br label %47

38:                                               ; preds = %32
  %39 = load ptr, ptr %8, align 8, !tbaa !5
  %40 = getelementptr inbounds %"struct.tracy::backtrace_state", ptr %39, i32 0, i32 5
  %41 = load ptr, ptr %40, align 8, !tbaa !13
  %42 = icmp eq ptr %41, null
  br i1 %42, label %43, label %46

43:                                               ; preds = %38
  %44 = load ptr, ptr %8, align 8, !tbaa !5
  %45 = getelementptr inbounds %"struct.tracy::backtrace_state", ptr %44, i32 0, i32 5
  store ptr @_ZN5tracyL12macho_nosymsEPNS_15backtrace_stateEmPFvPvmPKcmmEPFvS2_S4_iES2_, ptr %45, align 8, !tbaa !13
  br label %46

46:                                               ; preds = %43, %38
  br label %47

47:                                               ; preds = %46, %35
  br label %57

48:                                               ; preds = %27
  %49 = load i32, ptr %15, align 4, !tbaa !9
  %50 = icmp ne i32 %49, 0
  br i1 %50, label %51, label %55

51:                                               ; preds = %48
  %52 = load ptr, ptr %8, align 8, !tbaa !5
  %53 = getelementptr inbounds %"struct.tracy::backtrace_state", ptr %52, i32 0, i32 5
  store ptr @_ZN5tracyL13macho_syminfoEPNS_15backtrace_stateEmPFvPvmPKcmmEPFvS2_S4_iES2_, ptr %17, align 8, !tbaa !5
  %54 = load i64, ptr %17, align 8
  store atomic i64 %54, ptr %53 release, align 8
  br label %56

55:                                               ; preds = %48
  call void @abort() #4
  unreachable

56:                                               ; preds = %51
  br label %57

57:                                               ; preds = %56, %47
  %58 = load ptr, ptr %8, align 8, !tbaa !5
  %59 = getelementptr inbounds %"struct.tracy::backtrace_state", ptr %58, i32 0, i32 1
  %60 = load i32, ptr %59, align 8, !tbaa !11
  %61 = icmp ne i32 %60, 0
  br i1 %61, label %67, label %62

62:                                               ; preds = %57
  %63 = load ptr, ptr %8, align 8, !tbaa !5
  %64 = getelementptr inbounds %"struct.tracy::backtrace_state", ptr %63, i32 0, i32 3
  %65 = load ptr, ptr %64, align 8, !tbaa !14
  %66 = load ptr, ptr %13, align 8, !tbaa !5
  store ptr %65, ptr %66, align 8, !tbaa !5
  br label %73

67:                                               ; preds = %57
  %68 = load ptr, ptr %8, align 8, !tbaa !5
  %69 = getelementptr inbounds %"struct.tracy::backtrace_state", ptr %68, i32 0, i32 3
  %70 = load atomic i64, ptr %69 acquire, align 8
  store i64 %70, ptr %18, align 8
  %71 = load ptr, ptr %18, align 8, !tbaa !5
  %72 = load ptr, ptr %13, align 8, !tbaa !5
  store ptr %71, ptr %72, align 8, !tbaa !5
  br label %73

73:                                               ; preds = %67, %62
  %74 = load ptr, ptr %13, align 8, !tbaa !5
  %75 = load ptr, ptr %74, align 8, !tbaa !5
  %76 = icmp eq ptr %75, null
  br i1 %76, label %81, label %77

77:                                               ; preds = %73
  %78 = load ptr, ptr %13, align 8, !tbaa !5
  %79 = load ptr, ptr %78, align 8, !tbaa !5
  %80 = icmp eq ptr %79, @_ZN5tracyL13macho_nodebugEPNS_15backtrace_stateEmPFiPvmmPKciS4_EPFvS2_S4_iES2_
  br i1 %80, label %81, label %84

81:                                               ; preds = %77, %73
  %82 = load ptr, ptr %14, align 8, !tbaa !5
  %83 = load ptr, ptr %13, align 8, !tbaa !5
  store ptr %82, ptr %83, align 8, !tbaa !5
  br label %84

84:                                               ; preds = %81, %77
  store i32 1, ptr %7, align 4
  store i32 1, ptr %16, align 4
  br label %85

85:                                               ; preds = %84, %26
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #3
  %86 = load i32, ptr %7, align 4
  ret i32 %86
}

; 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 i32 @_ZN5tracyL13macho_nodebugEPNS_15backtrace_stateEmPFiPvmmPKciS4_EPFvS2_S4_iES2_(ptr noundef, i64 noundef, ptr noundef, ptr noundef, ptr noundef) #0

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

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

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

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

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

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


; 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 @_ZN5tracy20backtrace_initializeEPNS_15backtrace_stateEPKciPFvPvS3_iES4_PPFiS1_mPFiS4_mmS3_iS3_ES6_S4_E(ptr noundef %0, ptr noundef %1, i32 noundef %2, ptr noundef %3, ptr noundef %4, ptr nocapture noundef writeonly %5) local_unnamed_addr #0 {
  %7 = alloca ptr, align 8
  %8 = alloca i32, align 4
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %7) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %8) #3
  store ptr @_ZN5tracyL13macho_nodebugEPNS_15backtrace_stateEmPFiPvmmPKciS4_EPFvS2_S4_iES2_, ptr %7, align 8, !tbaa !5
  %9 = call noundef i32 @_ZN5tracyL9macho_addEPNS_15backtrace_stateEPKcilPKhmiPFvPvS3_iES6_PPFiS1_mPFiS6_mmS3_iS3_ES8_S6_EPi(ptr noundef %0, ptr noundef %1, i32 noundef %2, i64 noundef 0, ptr noundef null, i64 noundef 0, i32 noundef 0, ptr noundef %3, ptr noundef %4, ptr noundef nonnull %7, ptr noundef nonnull %8)
  %.not = icmp eq i32 %9, 0
  br i1 %.not, label %34, label %10

10:                                               ; preds = %6
  %11 = getelementptr inbounds i8, ptr %0, i64 8
  %12 = load i32, ptr %11, align 8, !tbaa !9
  %.not21 = icmp eq i32 %12, 0
  %13 = load i32, ptr %8, align 4, !tbaa !12
  %.not22 = icmp eq i32 %13, 0
  br i1 %.not21, label %14, label %19

14:                                               ; preds = %10
  %15 = getelementptr inbounds i8, ptr %0, i64 40
  br i1 %.not22, label %16, label %.sink.split

16:                                               ; preds = %14
  %17 = load ptr, ptr %15, align 8, !tbaa !13
  %18 = icmp eq ptr %17, null
  br i1 %18, label %.sink.split, label %21

19:                                               ; preds = %10
  br i1 %.not22, label %20, label %24

20:                                               ; preds = %19
  call void @abort() #4
  unreachable

.sink.split:                                      ; preds = %16, %14
  %_ZN5tracyL13macho_syminfoEPNS_15backtrace_stateEmPFvPvmPKcmmEPFvS2_S4_iES2_.sink = phi ptr [ @_ZN5tracyL13macho_syminfoEPNS_15backtrace_stateEmPFvPvmPKcmmEPFvS2_S4_iES2_, %14 ], [ @_ZN5tracyL12macho_nosymsEPNS_15backtrace_stateEmPFvPvmPKcmmEPFvS2_S4_iES2_, %16 ]
  store ptr %_ZN5tracyL13macho_syminfoEPNS_15backtrace_stateEmPFvPvmPKcmmEPFvS2_S4_iES2_.sink, ptr %15, align 8, !tbaa !13
  br label %21

21:                                               ; preds = %.sink.split, %16
  %22 = getelementptr inbounds i8, ptr %0, i64 24
  %23 = load ptr, ptr %22, align 8, !tbaa !14
  br label %29

24:                                               ; preds = %19
  %25 = getelementptr inbounds i8, ptr %0, i64 40
  store atomic i64 ptrtoint (ptr @_ZN5tracyL13macho_syminfoEPNS_15backtrace_stateEmPFvPvmPKcmmEPFvS2_S4_iES2_ to i64), ptr %25 release, align 8
  %26 = getelementptr inbounds i8, ptr %0, i64 24
  %27 = load atomic i64, ptr %26 acquire, align 8
  %28 = inttoptr i64 %27 to ptr
  br label %29

29:                                               ; preds = %24, %21
  %storemerge = phi ptr [ %23, %21 ], [ %28, %24 ]
  store ptr %storemerge, ptr %5, align 8, !tbaa !5
  %30 = icmp eq ptr %storemerge, null
  %31 = icmp eq ptr %storemerge, @_ZN5tracyL13macho_nodebugEPNS_15backtrace_stateEmPFiPvmmPKciS4_EPFvS2_S4_iES2_
  %or.cond = or i1 %30, %31
  br i1 %or.cond, label %32, label %34

32:                                               ; preds = %29
  %33 = load ptr, ptr %7, align 8, !tbaa !5
  store ptr %33, ptr %5, align 8, !tbaa !5
  br label %34

34:                                               ; preds = %32, %29, %6
  %.0 = phi i32 [ 0, %6 ], [ 1, %29 ], [ 1, %32 ]
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %8) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %7) #3
  ret i32 %.0
}

; Function Attrs: mustprogress 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 i32 @_ZN5tracyL13macho_nodebugEPNS_15backtrace_stateEmPFiPvmmPKciS4_EPFvS2_S4_iES2_(ptr noundef, i64 noundef, ptr noundef, ptr noundef, ptr noundef) #0

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

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

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

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

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

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 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, !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 = !{!11, !11, i64 0}
!13 = !{!10, !6, i64 40}
!14 = !{!10, !6, i64 24}


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