; 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.1 = external hidden unnamed_addr constant [42 x i8], align 1

; Function Attrs: mustprogress uwtable
declare dso_local noundef i64 @_ZN11__sanitizer12Unwind_GetIPEP15_Unwind_Context(ptr noundef) #0

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_ZN11__sanitizer12Unwind_TraceEP15_Unwind_ContextPv(ptr noundef %0, ptr noundef %1) #0 {
  %3 = alloca i32, align 4
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i64, align 8
  %8 = alloca i64, align 8
  %9 = alloca i64, align 8
  %10 = alloca i64, align 8
  %11 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #5
  %12 = load ptr, ptr %5, align 8, !tbaa !5
  store ptr %12, ptr %6, align 8, !tbaa !5
  br label %13

13:                                               ; preds = %2
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #5
  %14 = load ptr, ptr %6, align 8, !tbaa !5
  %15 = getelementptr inbounds %"struct.__sanitizer::UnwindTraceArg", ptr %14, i32 0, i32 0
  %16 = load ptr, ptr %15, align 8, !tbaa !9
  %17 = getelementptr inbounds %"struct.__sanitizer::StackTrace", ptr %16, i32 0, i32 1
  %18 = load i32, ptr %17, align 8, !tbaa !12
  %19 = zext i32 %18 to i64
  store i64 %19, ptr %7, align 8, !tbaa !14
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #5
  %20 = load ptr, ptr %6, align 8, !tbaa !5
  %21 = getelementptr inbounds %"struct.__sanitizer::UnwindTraceArg", ptr %20, i32 0, i32 1
  %22 = load i32, ptr %21, align 8, !tbaa !16
  %23 = zext i32 %22 to i64
  store i64 %23, ptr %8, align 8, !tbaa !14
  %24 = load i64, ptr %7, align 8, !tbaa !14
  %25 = load i64, ptr %8, align 8, !tbaa !14
  %26 = icmp ult i64 %24, %25
  %27 = xor i1 %26, true
  %28 = xor i1 %27, true
  %29 = xor i1 %28, true
  %30 = zext i1 %29 to i64
  %31 = call i64 @llvm.expect.i64(i64 %30, i64 0)
  %32 = icmp ne i64 %31, 0
  br i1 %32, label %33, label %36

33:                                               ; preds = %13
  %34 = load i64, ptr %7, align 8, !tbaa !14
  %35 = load i64, ptr %8, align 8, !tbaa !14
  call void @_ZN11__sanitizer11CheckFailedEPKciS1_yy(ptr noundef @.str, i32 noundef 109, ptr noundef @.str.1, i64 noundef %34, i64 noundef %35) #6
  unreachable

36:                                               ; preds = %13
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #5
  br label %37

37:                                               ; preds = %36
  br label %38

38:                                               ; preds = %37
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #5
  %39 = load ptr, ptr %4, align 8, !tbaa !5
  %40 = call noundef i64 @_ZN11__sanitizer12Unwind_GetIPEP15_Unwind_Context(ptr noundef %39)
  store i64 %40, ptr %9, align 8, !tbaa !17
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #5
  %41 = call noundef i64 @_ZN11__sanitizer17GetPageSizeCachedEv()
  store i64 %41, ptr %10, align 8, !tbaa !17
  %42 = load i64, ptr %9, align 8, !tbaa !17
  %43 = load i64, ptr %10, align 8, !tbaa !17
  %44 = icmp ult i64 %42, %43
  br i1 %44, label %45, label %46

45:                                               ; preds = %38
  store i32 4, ptr %3, align 4
  store i32 1, ptr %11, align 4
  br label %71

46:                                               ; preds = %38
  %47 = load i64, ptr %9, align 8, !tbaa !17
  %48 = load ptr, ptr %6, align 8, !tbaa !5
  %49 = getelementptr inbounds %"struct.__sanitizer::UnwindTraceArg", ptr %48, i32 0, i32 0
  %50 = load ptr, ptr %49, align 8, !tbaa !9
  %51 = getelementptr inbounds %"struct.__sanitizer::BufferedStackTrace", ptr %50, i32 0, i32 1
  %52 = load ptr, ptr %6, align 8, !tbaa !5
  %53 = getelementptr inbounds %"struct.__sanitizer::UnwindTraceArg", ptr %52, i32 0, i32 0
  %54 = load ptr, ptr %53, align 8, !tbaa !9
  %55 = getelementptr inbounds %"struct.__sanitizer::StackTrace", ptr %54, i32 0, i32 1
  %56 = load i32, ptr %55, align 8, !tbaa !12
  %57 = add i32 %56, 1
  store i32 %57, ptr %55, align 8, !tbaa !12
  %58 = zext i32 %56 to i64
  %59 = getelementptr inbounds [256 x i64], ptr %51, i64 0, i64 %58
  store i64 %47, ptr %59, align 8, !tbaa !17
  %60 = load ptr, ptr %6, align 8, !tbaa !5
  %61 = getelementptr inbounds %"struct.__sanitizer::UnwindTraceArg", ptr %60, i32 0, i32 0
  %62 = load ptr, ptr %61, align 8, !tbaa !9
  %63 = getelementptr inbounds %"struct.__sanitizer::StackTrace", ptr %62, i32 0, i32 1
  %64 = load i32, ptr %63, align 8, !tbaa !12
  %65 = load ptr, ptr %6, align 8, !tbaa !5
  %66 = getelementptr inbounds %"struct.__sanitizer::UnwindTraceArg", ptr %65, i32 0, i32 1
  %67 = load i32, ptr %66, align 8, !tbaa !16
  %68 = icmp eq i32 %64, %67
  br i1 %68, label %69, label %70

69:                                               ; preds = %46
  store i32 4, ptr %3, align 4
  store i32 1, ptr %11, align 4
  br label %71

70:                                               ; preds = %46
  store i32 0, ptr %3, align 4
  store i32 1, ptr %11, align 4
  br label %71

71:                                               ; preds = %70, %69, %45
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #5
  %72 = load i32, ptr %3, align 4
  ret i32 %72
}

; 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: inlinehint mustprogress uwtable
declare dso_local noundef i64 @_ZN11__sanitizer17GetPageSizeCachedEv() #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 = { 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 = { 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 = { nounwind }
attributes #6 = { 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, !6, i64 0}
!10 = !{!"_ZTSN11__sanitizer14UnwindTraceArgE", !6, i64 0, !11, i64 8}
!11 = !{!"int", !7, i64 0}
!12 = !{!13, !11, i64 8}
!13 = !{!"_ZTSN11__sanitizer10StackTraceE", !6, i64 0, !11, i64 8, !11, i64 12}
!14 = !{!15, !15, i64 0}
!15 = !{!"long long", !7, i64 0}
!16 = !{!10, !11, i64 8}
!17 = !{!18, !18, i64 0}
!18 = !{!"long", !7, i64 0}


; 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 [123 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [42 x i8], align 1

; Function Attrs: mustprogress uwtable
declare dso_local noundef i64 @_ZN11__sanitizer12Unwind_GetIPEP15_Unwind_Context(ptr noundef) local_unnamed_addr #0

; Function Attrs: mustprogress uwtable
define dso_local noundef range(i32 0, 5) i32 @_ZN11__sanitizer12Unwind_TraceEP15_Unwind_ContextPv(ptr noundef %0, ptr nocapture noundef readonly %1) local_unnamed_addr #0 {
  %3 = load ptr, ptr %1, align 8, !tbaa !5
  %4 = getelementptr inbounds i8, ptr %3, i64 8
  %5 = load i32, ptr %4, align 8, !tbaa !11
  %6 = getelementptr inbounds i8, ptr %1, i64 8
  %7 = load i32, ptr %6, align 8, !tbaa !13
  %.not = icmp ult i32 %5, %7
  br i1 %.not, label %11, label %8, !prof !14

8:                                                ; preds = %2
  %9 = zext i32 %7 to i64
  %10 = zext i32 %5 to i64
  tail call void @_ZN11__sanitizer11CheckFailedEPKciS1_yy(ptr noundef nonnull @.str, i32 noundef 109, ptr noundef nonnull @.str.1, i64 noundef %10, i64 noundef %9) #3
  unreachable

11:                                               ; preds = %2
  %12 = tail call noundef i64 @_ZN11__sanitizer12Unwind_GetIPEP15_Unwind_Context(ptr noundef %0)
  %13 = tail call noundef i64 @_ZN11__sanitizer17GetPageSizeCachedEv()
  %14 = icmp ult i64 %12, %13
  br i1 %14, label %25, label %15

15:                                               ; preds = %11
  %16 = load ptr, ptr %1, align 8, !tbaa !5
  %17 = getelementptr inbounds i8, ptr %16, i64 16
  %18 = getelementptr inbounds i8, ptr %16, i64 8
  %19 = load i32, ptr %18, align 8, !tbaa !11
  %20 = add i32 %19, 1
  store i32 %20, ptr %18, align 8, !tbaa !11
  %21 = zext i32 %19 to i64
  %22 = getelementptr inbounds [256 x i64], ptr %17, i64 0, i64 %21
  store i64 %12, ptr %22, align 8, !tbaa !15
  %23 = load i32, ptr %6, align 8, !tbaa !13
  %24 = icmp eq i32 %20, %23
  %. = select i1 %24, i32 4, i32 0
  br label %25

25:                                               ; preds = %15, %11
  %.0 = phi i32 [ 4, %11 ], [ %., %15 ]
  ret i32 %.0
}

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

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

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


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