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

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

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

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_ZN11__sanitizer12Unwind_TraceEP15_Unwind_ContextPv(ptr noundef, ptr noundef) #0

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

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(none)
declare i64 @llvm.expect.i64(i64, i64) #2

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

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN11__sanitizer18BufferedStackTrace15SlowUnwindStackEmj(ptr noundef nonnull align 8 dereferenceable(2072) %0, i64 noundef %1, i32 noundef %2) #0 align 2 {
  %4 = alloca ptr, align 8
  %5 = alloca i64, align 8
  %6 = alloca i32, align 4
  %7 = alloca i64, align 8
  %8 = alloca i64, align 8
  %9 = alloca %"struct.__sanitizer::UnwindTraceArg", align 8
  %10 = alloca i64, align 8
  store ptr %0, ptr %4, align 8, !tbaa !5
  store i64 %1, ptr %5, align 8, !tbaa !9
  store i32 %2, ptr %6, align 4, !tbaa !11
  %11 = load ptr, ptr %4, align 8
  br label %12

12:                                               ; preds = %3
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #6
  %13 = load i32, ptr %6, align 4, !tbaa !11
  %14 = zext i32 %13 to i64
  store i64 %14, ptr %7, align 8, !tbaa !13
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #6
  store i64 2, ptr %8, align 8, !tbaa !13
  %15 = load i64, ptr %7, align 8, !tbaa !13
  %16 = load i64, ptr %8, align 8, !tbaa !13
  %17 = icmp uge i64 %15, %16
  %18 = xor i1 %17, true
  %19 = xor i1 %18, true
  %20 = xor i1 %19, true
  %21 = zext i1 %20 to i64
  %22 = call i64 @llvm.expect.i64(i64 %21, i64 0)
  %23 = icmp ne i64 %22, 0
  br i1 %23, label %24, label %27

24:                                               ; preds = %12
  %25 = load i64, ptr %7, align 8, !tbaa !13
  %26 = load i64, ptr %8, align 8, !tbaa !13
  call void @_ZN11__sanitizer11CheckFailedEPKciS1_yy(ptr noundef @.str, i32 noundef 122, ptr noundef @.str.2, i64 noundef %25, i64 noundef %26) #7
  unreachable

27:                                               ; preds = %12
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #6
  br label %28

28:                                               ; preds = %27
  %29 = getelementptr inbounds %"struct.__sanitizer::StackTrace", ptr %11, i32 0, i32 1
  store i32 0, ptr %29, align 8, !tbaa !15
  call void @llvm.lifetime.start.p0(i64 16, ptr %9) #6
  %30 = getelementptr inbounds %"struct.__sanitizer::UnwindTraceArg", ptr %9, i32 0, i32 0
  store ptr %11, ptr %30, align 8, !tbaa !17
  %31 = getelementptr inbounds %"struct.__sanitizer::UnwindTraceArg", ptr %9, i32 0, i32 1
  %32 = load i32, ptr %6, align 4, !tbaa !11
  %33 = add i32 %32, 1
  %34 = call noundef i32 @_ZN11__sanitizer3MinIjEET_S1_S1_(i32 noundef %33, i32 noundef 256)
  store i32 %34, ptr %31, align 8, !tbaa !19
  %35 = call i32 @_Unwind_Backtrace(ptr noundef @_ZN11__sanitizer12Unwind_TraceEP15_Unwind_ContextPv, ptr noundef %9)
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #6
  %36 = load i64, ptr %5, align 8, !tbaa !9
  %37 = call noundef i64 @_ZN11__sanitizer18BufferedStackTrace15LocatePcInTraceEm(ptr noundef nonnull align 8 dereferenceable(2072) %11, i64 noundef %36)
  store i64 %37, ptr %10, align 8, !tbaa !9
  %38 = load i64, ptr %10, align 8, !tbaa !9
  %39 = icmp eq i64 %38, 0
  br i1 %39, label %40, label %45

40:                                               ; preds = %28
  %41 = getelementptr inbounds %"struct.__sanitizer::StackTrace", ptr %11, i32 0, i32 1
  %42 = load i32, ptr %41, align 8, !tbaa !15
  %43 = icmp ugt i32 %42, 1
  br i1 %43, label %44, label %45

44:                                               ; preds = %40
  store i64 1, ptr %10, align 8, !tbaa !9
  br label %45

45:                                               ; preds = %44, %40, %28
  %46 = load i64, ptr %10, align 8, !tbaa !9
  call void @_ZN11__sanitizer18BufferedStackTrace14PopStackFramesEm(ptr noundef nonnull align 8 dereferenceable(2072) %11, i64 noundef %46)
  %47 = load i64, ptr %5, align 8, !tbaa !9
  %48 = getelementptr inbounds %"struct.__sanitizer::BufferedStackTrace", ptr %11, i32 0, i32 1
  %49 = getelementptr inbounds [256 x i64], ptr %48, i64 0, i64 0
  store i64 %47, ptr %49, align 8, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #6
  call void @llvm.lifetime.end.p0(i64 16, ptr %9) #6
  ret void
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZN11__sanitizer3MinIjEET_S1_S1_(i32 noundef, i32 noundef) #4

declare i32 @_Unwind_Backtrace(ptr noundef, ptr noundef) #5

declare noundef i64 @_ZN11__sanitizer18BufferedStackTrace15LocatePcInTraceEm(ptr noundef nonnull align 8 dereferenceable(2072), i64 noundef) #5

declare void @_ZN11__sanitizer18BufferedStackTrace14PopStackFramesEm(ptr noundef nonnull align 8 dereferenceable(2072), i64 noundef) #5

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 = { nocallback nofree nosync nounwind willreturn memory(none) }
attributes #3 = { 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 #4 = { 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 #5 = { "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 = !{!18, !6, i64 0}
!18 = !{!"_ZTSN11__sanitizer14UnwindTraceArgE", !6, i64 0, !12, i64 8}
!19 = !{!18, !12, i64 8}


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

%"struct.__sanitizer::UnwindTraceArg" = type { ptr, i32 }

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

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_ZN11__sanitizer12Unwind_TraceEP15_Unwind_ContextPv(ptr noundef, ptr noundef) #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: noreturn
declare void @_ZN11__sanitizer11CheckFailedEPKciS1_yy(ptr noundef, i32 noundef, ptr noundef, i64 noundef, i64 noundef) 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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN11__sanitizer18BufferedStackTrace15SlowUnwindStackEmj(ptr noundef nonnull align 8 dereferenceable(2072) %0, i64 noundef %1, i32 noundef %2) local_unnamed_addr #0 align 2 {
  %4 = alloca %"struct.__sanitizer::UnwindTraceArg", align 8
  %5 = icmp ult i32 %2, 2
  br i1 %5, label %6, label %8, !prof !5

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

8:                                                ; preds = %3
  %9 = getelementptr inbounds i8, ptr %0, i64 8
  store i32 0, ptr %9, align 8, !tbaa !6
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %4) #6
  store ptr %0, ptr %4, align 8, !tbaa !12
  %10 = getelementptr inbounds i8, ptr %4, i64 8
  %11 = add i32 %2, 1
  %12 = tail call noundef i32 @_ZN11__sanitizer3MinIjEET_S1_S1_(i32 noundef %11, i32 noundef 256)
  store i32 %12, ptr %10, align 8, !tbaa !14
  %13 = call i32 @_Unwind_Backtrace(ptr noundef nonnull @_ZN11__sanitizer12Unwind_TraceEP15_Unwind_ContextPv, ptr noundef nonnull %4)
  %14 = call noundef i64 @_ZN11__sanitizer18BufferedStackTrace15LocatePcInTraceEm(ptr noundef nonnull align 8 dereferenceable(2072) %0, i64 noundef %1)
  %15 = icmp eq i64 %14, 0
  %16 = load i32, ptr %9, align 8
  %17 = icmp ugt i32 %16, 1
  %spec.select = zext i1 %17 to i64
  %.0 = select i1 %15, i64 %spec.select, i64 %14
  call void @_ZN11__sanitizer18BufferedStackTrace14PopStackFramesEm(ptr noundef nonnull align 8 dereferenceable(2072) %0, i64 noundef %.0)
  %18 = getelementptr inbounds i8, ptr %0, i64 16
  store i64 %1, ptr %18, align 8, !tbaa !15
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %4) #6
  ret void
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZN11__sanitizer3MinIjEET_S1_S1_(i32 noundef, i32 noundef) local_unnamed_addr #3

declare i32 @_Unwind_Backtrace(ptr noundef, ptr noundef) local_unnamed_addr #4

declare noundef i64 @_ZN11__sanitizer18BufferedStackTrace15LocatePcInTraceEm(ptr noundef nonnull align 8 dereferenceable(2072), i64 noundef) local_unnamed_addr #4

declare void @_ZN11__sanitizer18BufferedStackTrace14PopStackFramesEm(ptr noundef nonnull align 8 dereferenceable(2072), i64 noundef) local_unnamed_addr #4

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


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,LowerExpectIntrinsicPass,SROAPass,SimplifyCFGPass,TailCallElimPass