; LLVM IR from AngoraFuzzer/Angora :: llvm_mode/dfsan_rt/sanitizer_common (sanitizer_stacktrace)

; 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.__sanitizer::BufferedStackTrace" = type { %"struct.__sanitizer::StackTrace", [256 x i64], i64 }
%"struct.__sanitizer::StackTrace" = type { ptr, i32, i32 }

@.str = external hidden unnamed_addr constant [113 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [23 x i8], align 1

; 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(none)
declare i64 @llvm.expect.i64(i64, i64) #1

; Function Attrs: noreturn
declare void @_ZN11__sanitizer11CheckFailedEPKciS1_yy(ptr noundef, i32 noundef, ptr noundef, i64 noundef, i64 noundef) #2

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN11__sanitizer18BufferedStackTrace15FastUnwindStackEmmmmj(ptr noundef nonnull align 8 dereferenceable(2072) %0, i64 noundef %1, i64 noundef %2, i64 noundef %3, i64 noundef %4, i32 noundef %5) #3 align 2 {
  %7 = alloca ptr, align 8
  %8 = alloca i64, align 8
  %9 = alloca i64, align 8
  %10 = alloca i64, align 8
  %11 = alloca i64, align 8
  %12 = alloca i32, align 4
  %13 = alloca i64, align 8
  %14 = alloca i64, align 8
  %15 = alloca i64, align 8
  %16 = alloca i32, align 4
  %17 = alloca ptr, align 8
  %18 = alloca i64, align 8
  %19 = alloca i64, align 8
  store ptr %0, ptr %7, align 8, !tbaa !5
  store i64 %1, ptr %8, align 8, !tbaa !9
  store i64 %2, ptr %9, align 8, !tbaa !9
  store i64 %3, ptr %10, align 8, !tbaa !9
  store i64 %4, ptr %11, align 8, !tbaa !9
  store i32 %5, ptr %12, align 4, !tbaa !11
  %20 = load ptr, ptr %7, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #6
  %21 = call noundef i64 @_ZN11__sanitizer17GetPageSizeCachedEv()
  store i64 %21, ptr %13, align 8, !tbaa !9
  br label %22

22:                                               ; preds = %6
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #6
  %23 = load i32, ptr %12, align 4, !tbaa !11
  %24 = zext i32 %23 to i64
  store i64 %24, ptr %14, align 8, !tbaa !13
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #6
  store i64 2, ptr %15, align 8, !tbaa !13
  %25 = load i64, ptr %14, align 8, !tbaa !13
  %26 = load i64, ptr %15, align 8, !tbaa !13
  %27 = icmp uge i64 %25, %26
  %28 = xor i1 %27, true
  %29 = xor i1 %28, true
  %30 = xor i1 %29, true
  %31 = zext i1 %30 to i64
  %32 = call i64 @llvm.expect.i64(i64 %31, i64 0)
  %33 = icmp ne i64 %32, 0
  br i1 %33, label %34, label %37

34:                                               ; preds = %22
  %35 = load i64, ptr %14, align 8, !tbaa !13
  %36 = load i64, ptr %15, align 8, !tbaa !13
  call void @_ZN11__sanitizer11CheckFailedEPKciS1_yy(ptr noundef @.str, i32 noundef 70, ptr noundef @.str.2, i64 noundef %35, i64 noundef %36) #7
  unreachable

37:                                               ; preds = %22
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #6
  br label %38

38:                                               ; preds = %37
  br label %39

39:                                               ; preds = %38
  %40 = load i64, ptr %8, align 8, !tbaa !9
  %41 = getelementptr inbounds %"struct.__sanitizer::BufferedStackTrace", ptr %20, i32 0, i32 1
  %42 = getelementptr inbounds [256 x i64], ptr %41, i64 0, i64 0
  store i64 %40, ptr %42, align 8, !tbaa !9
  %43 = getelementptr inbounds %"struct.__sanitizer::StackTrace", ptr %20, i32 0, i32 1
  store i32 1, ptr %43, align 8, !tbaa !15
  %44 = load i64, ptr %10, align 8, !tbaa !9
  %45 = icmp ult i64 %44, 4096
  br i1 %45, label %46, label %47

46:                                               ; preds = %39
  store i32 1, ptr %16, align 4
  br label %103

47:                                               ; preds = %39
  call void @llvm.lifetime.start.p0(i64 8, ptr %17) #6
  %48 = load i64, ptr %9, align 8, !tbaa !9
  %49 = load i64, ptr %10, align 8, !tbaa !9
  %50 = load i64, ptr %11, align 8, !tbaa !9
  %51 = call noundef ptr @_ZN11__sanitizerL15GetCanonicFrameEmmm(i64 noundef %48, i64 noundef %49, i64 noundef %50)
  store ptr %51, ptr %17, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %18) #6
  %52 = load i64, ptr %11, align 8, !tbaa !9
  store i64 %52, ptr %18, align 8, !tbaa !9
  br label %53

53:                                               ; preds = %101, %47
  %54 = load ptr, ptr %17, align 8, !tbaa !5
  %55 = ptrtoint ptr %54 to i64
  %56 = load i64, ptr %10, align 8, !tbaa !9
  %57 = load i64, ptr %18, align 8, !tbaa !9
  %58 = call noundef zeroext i1 @_ZN11__sanitizerL12IsValidFrameEmmm(i64 noundef %55, i64 noundef %56, i64 noundef %57)
  br i1 %58, label %59, label %68

59:                                               ; preds = %53
  %60 = load ptr, ptr %17, align 8, !tbaa !5
  %61 = ptrtoint ptr %60 to i64
  %62 = call noundef zeroext i1 @_ZN11__sanitizer9IsAlignedEmm(i64 noundef %61, i64 noundef 8)
  br i1 %62, label %63, label %68

63:                                               ; preds = %59
  %64 = getelementptr inbounds %"struct.__sanitizer::StackTrace", ptr %20, i32 0, i32 1
  %65 = load i32, ptr %64, align 8, !tbaa !15
  %66 = load i32, ptr %12, align 4, !tbaa !11
  %67 = icmp ult i32 %65, %66
  br label %68

68:                                               ; preds = %63, %59, %53
  %69 = phi i1 [ false, %59 ], [ false, %53 ], [ %67, %63 ]
  br i1 %69, label %70, label %102

70:                                               ; preds = %68
  call void @llvm.lifetime.start.p0(i64 8, ptr %19) #6
  %71 = load ptr, ptr %17, align 8, !tbaa !5
  %72 = getelementptr inbounds i64, ptr %71, i64 1
  %73 = load i64, ptr %72, align 8, !tbaa !13
  store i64 %73, ptr %19, align 8, !tbaa !13
  %74 = load i64, ptr %19, align 8, !tbaa !13
  %75 = load i64, ptr %13, align 8, !tbaa !9
  %76 = icmp ult i64 %74, %75
  br i1 %76, label %77, label %78

77:                                               ; preds = %70
  store i32 5, ptr %16, align 4
  br label %99

78:                                               ; preds = %70
  %79 = load i64, ptr %19, align 8, !tbaa !13
  %80 = load i64, ptr %8, align 8, !tbaa !9
  %81 = icmp ne i64 %79, %80
  br i1 %81, label %82, label %90

82:                                               ; preds = %78
  %83 = load i64, ptr %19, align 8, !tbaa !13
  %84 = getelementptr inbounds %"struct.__sanitizer::BufferedStackTrace", ptr %20, i32 0, i32 1
  %85 = getelementptr inbounds %"struct.__sanitizer::StackTrace", ptr %20, i32 0, i32 1
  %86 = load i32, ptr %85, align 8, !tbaa !15
  %87 = add i32 %86, 1
  store i32 %87, ptr %85, align 8, !tbaa !15
  %88 = zext i32 %86 to i64
  %89 = getelementptr inbounds [256 x i64], ptr %84, i64 0, i64 %88
  store i64 %83, ptr %89, align 8, !tbaa !9
  br label %90

90:                                               ; preds = %82, %78
  %91 = load ptr, ptr %17, align 8, !tbaa !5
  %92 = ptrtoint ptr %91 to i64
  store i64 %92, ptr %18, align 8, !tbaa !9
  %93 = load ptr, ptr %17, align 8, !tbaa !5
  %94 = getelementptr inbounds i64, ptr %93, i64 0
  %95 = load i64, ptr %94, align 8, !tbaa !13
  %96 = load i64, ptr %10, align 8, !tbaa !9
  %97 = load i64, ptr %18, align 8, !tbaa !9
  %98 = call noundef ptr @_ZN11__sanitizerL15GetCanonicFrameEmmm(i64 noundef %95, i64 noundef %96, i64 noundef %97)
  store ptr %98, ptr %17, align 8, !tbaa !5
  store i32 0, ptr %16, align 4
  br label %99

99:                                               ; preds = %90, %77
  call void @llvm.lifetime.end.p0(i64 8, ptr %19) #6
  %100 = load i32, ptr %16, align 4
  switch i32 %100, label %106 [
    i32 0, label %101
    i32 5, label %102
  ]

101:                                              ; preds = %99
  br label %53, !llvm.loop !17

102:                                              ; preds = %99, %68
  call void @llvm.lifetime.end.p0(i64 8, ptr %18) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %17) #6
  store i32 0, ptr %16, align 4
  br label %103

103:                                              ; preds = %102, %46
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #6
  %104 = load i32, ptr %16, align 4
  switch i32 %104, label %106 [
    i32 0, label %105
    i32 1, label %105
  ]

105:                                              ; preds = %103, %103
  ret void

106:                                              ; preds = %103, %99
  unreachable
}

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef i64 @_ZN11__sanitizer17GetPageSizeCachedEv() #4

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare hidden noundef ptr @_ZN11__sanitizerL15GetCanonicFrameEmmm(i64 noundef, i64 noundef, i64 noundef) #5

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare hidden noundef zeroext i1 @_ZN11__sanitizerL12IsValidFrameEmmm(i64 noundef, i64 noundef, i64 noundef) #5

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZN11__sanitizer9IsAlignedEmm(i64 noundef, i64 noundef) #5

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

!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, !14, i64 0}
!14 = !{!"long long", !7, i64 0}
!15 = !{!16, !12, i64 8}
!16 = !{!"_ZTSN11__sanitizer10StackTraceE", !6, i64 0, !12, i64 8, !12, i64 12}
!17 = distinct !{!17, !18}
!18 = !{!"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 = external hidden unnamed_addr constant [113 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [23 x i8], align 1

; Function Attrs: noreturn
declare void @_ZN11__sanitizer11CheckFailedEPKciS1_yy(ptr noundef, i32 noundef, ptr noundef, i64 noundef, i64 noundef) local_unnamed_addr #0

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN11__sanitizer18BufferedStackTrace15FastUnwindStackEmmmmj(ptr nocapture noundef nonnull align 8 dereferenceable(2072) %0, i64 noundef %1, i64 noundef %2, i64 noundef %3, i64 noundef %4, i32 noundef %5) local_unnamed_addr #1 align 2 {
  %7 = tail call noundef i64 @_ZN11__sanitizer17GetPageSizeCachedEv()
  %8 = icmp ult i32 %5, 2
  br i1 %8, label %9, label %11, !prof !5

9:                                                ; preds = %6
  %10 = zext nneg i32 %5 to i64
  tail call void @_ZN11__sanitizer11CheckFailedEPKciS1_yy(ptr noundef nonnull @.str, i32 noundef 70, ptr noundef nonnull @.str.2, i64 noundef %10, i64 noundef 2) #4
  unreachable

11:                                               ; preds = %6
  %12 = getelementptr inbounds i8, ptr %0, i64 16
  store i64 %1, ptr %12, align 8, !tbaa !6
  %13 = getelementptr inbounds i8, ptr %0, i64 8
  store i32 1, ptr %13, align 8, !tbaa !10
  %14 = icmp ult i64 %3, 4096
  br i1 %14, label %.critedge, label %15

15:                                               ; preds = %11
  %16 = tail call noundef ptr @_ZN11__sanitizerL15GetCanonicFrameEmmm(i64 noundef %2, i64 noundef %3, i64 noundef %4)
  %17 = ptrtoint ptr %16 to i64
  %18 = tail call noundef zeroext i1 @_ZN11__sanitizerL12IsValidFrameEmmm(i64 noundef %17, i64 noundef %3, i64 noundef %4)
  br i1 %18, label %.lr.ph, label %.critedge

.lr.ph:                                           ; preds = %15, %33
  %19 = phi i64 [ %36, %33 ], [ %17, %15 ]
  %.02837 = phi ptr [ %35, %33 ], [ %16, %15 ]
  %20 = tail call noundef zeroext i1 @_ZN11__sanitizer9IsAlignedEmm(i64 noundef %19, i64 noundef 8)
  br i1 %20, label %21, label %.critedge

21:                                               ; preds = %.lr.ph
  %22 = load i32, ptr %13, align 8, !tbaa !10
  %23 = icmp ult i32 %22, %5
  br i1 %23, label %24, label %.critedge

24:                                               ; preds = %21
  %25 = getelementptr inbounds i8, ptr %.02837, i64 8
  %26 = load i64, ptr %25, align 8, !tbaa !14
  %27 = icmp ult i64 %26, %7
  br i1 %27, label %.critedge, label %28

28:                                               ; preds = %24
  %.not = icmp eq i64 %26, %1
  br i1 %.not, label %33, label %29

29:                                               ; preds = %28
  %30 = add nuw i32 %22, 1
  store i32 %30, ptr %13, align 8, !tbaa !10
  %31 = zext i32 %22 to i64
  %32 = getelementptr inbounds [256 x i64], ptr %12, i64 0, i64 %31
  store i64 %26, ptr %32, align 8, !tbaa !6
  br label %33

33:                                               ; preds = %28, %29
  %34 = load i64, ptr %.02837, align 8, !tbaa !14
  %35 = tail call noundef ptr @_ZN11__sanitizerL15GetCanonicFrameEmmm(i64 noundef %34, i64 noundef %3, i64 noundef %19)
  %36 = ptrtoint ptr %35 to i64
  %37 = tail call noundef zeroext i1 @_ZN11__sanitizerL12IsValidFrameEmmm(i64 noundef %36, i64 noundef %3, i64 noundef %19)
  br i1 %37, label %.lr.ph, label %.critedge

.critedge:                                        ; preds = %.lr.ph, %33, %21, %24, %15, %11
  ret void
}

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef i64 @_ZN11__sanitizer17GetPageSizeCachedEv() local_unnamed_addr #2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare hidden noundef ptr @_ZN11__sanitizerL15GetCanonicFrameEmmm(i64 noundef, i64 noundef, i64 noundef) local_unnamed_addr #3

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare hidden noundef zeroext i1 @_ZN11__sanitizerL12IsValidFrameEmmm(i64 noundef, i64 noundef, i64 noundef) local_unnamed_addr #3

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZN11__sanitizer9IsAlignedEmm(i64 noundef, i64 noundef) local_unnamed_addr #3

attributes #0 = { noreturn "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 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 = { 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 = { inlinehint 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 = { noreturn }

!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 = !{!"branch_weights", !"expected", i32 1, i32 2000}
!6 = !{!7, !7, i64 0}
!7 = !{!"long", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!11, !13, i64 8}
!11 = !{!"_ZTSN11__sanitizer10StackTraceE", !12, i64 0, !13, i64 8, !13, i64 12}
!12 = !{!"any pointer", !8, i64 0}
!13 = !{!"int", !8, i64 0}
!14 = !{!15, !15, i64 0}
!15 = !{!"long long", !8, i64 0}


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