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

; 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::MallocFreeHook" = type { ptr, ptr }

@_ZN11__sanitizerL7MFHooksE = external hidden global [5 x %"struct.__sanitizer::MallocFreeHook"], align 16

; 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(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #0

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

8:                                                ; preds = %28, %2
  %9 = load i32, ptr %5, align 4, !tbaa !11
  %10 = icmp slt i32 %9, 5
  br i1 %10, label %12, label %11

11:                                               ; preds = %8
  store i32 2, ptr %6, align 4
  br label %31

12:                                               ; preds = %8
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #2
  %13 = load i32, ptr %5, align 4, !tbaa !11
  %14 = sext i32 %13 to i64
  %15 = getelementptr inbounds [5 x %"struct.__sanitizer::MallocFreeHook"], ptr @_ZN11__sanitizerL7MFHooksE, i64 0, i64 %14
  %16 = getelementptr inbounds %"struct.__sanitizer::MallocFreeHook", ptr %15, i32 0, i32 0
  %17 = load ptr, ptr %16, align 16, !tbaa !13
  store ptr %17, ptr %7, align 8, !tbaa !5
  %18 = load ptr, ptr %7, align 8, !tbaa !5
  %19 = icmp ne ptr %18, null
  br i1 %19, label %21, label %20

20:                                               ; preds = %12
  store i32 1, ptr %6, align 4
  br label %25

21:                                               ; preds = %12
  %22 = load ptr, ptr %7, align 8, !tbaa !5
  %23 = load ptr, ptr %3, align 8, !tbaa !5
  %24 = load i64, ptr %4, align 8, !tbaa !9
  call void %22(ptr noundef %23, i64 noundef %24)
  store i32 0, ptr %6, align 4
  br label %25

25:                                               ; preds = %21, %20
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #2
  %26 = load i32, ptr %6, align 4
  switch i32 %26, label %31 [
    i32 0, label %27
  ]

27:                                               ; preds = %25
  br label %28

28:                                               ; preds = %27
  %29 = load i32, ptr %5, align 4, !tbaa !11
  %30 = add nsw i32 %29, 1
  store i32 %30, ptr %5, align 4, !tbaa !11
  br label %8, !llvm.loop !15

31:                                               ; preds = %25, %11
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #2
  %32 = load i32, ptr %6, align 4
  switch i32 %32, label %34 [
    i32 2, label %33
    i32 1, label %33
  ]

33:                                               ; preds = %31, %31
  ret void

34:                                               ; preds = %31
  unreachable
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { 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, !6, i64 0}
!14 = !{!"_ZTSN11__sanitizer14MallocFreeHookE", !6, i64 0, !6, i64 8}
!15 = distinct !{!15, !16}
!16 = !{!"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"

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

@_ZN11__sanitizerL7MFHooksE = external hidden local_unnamed_addr global [5 x %"struct.__sanitizer::MallocFreeHook"], align 16

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN11__sanitizer14RunMallocHooksEPKvm(ptr noundef %0, i64 noundef %1) local_unnamed_addr #0 {
  %3 = load ptr, ptr @_ZN11__sanitizerL7MFHooksE, align 16, !tbaa !5
  %.not.not = icmp eq ptr %3, null
  br i1 %.not.not, label %.critedge, label %4

4:                                                ; preds = %2
  tail call void %3(ptr noundef %0, i64 noundef %1)
  %5 = load ptr, ptr getelementptr inbounds (i8, ptr @_ZN11__sanitizerL7MFHooksE, i64 16), align 16, !tbaa !5
  %.not.not.1 = icmp eq ptr %5, null
  br i1 %.not.not.1, label %.critedge, label %6

6:                                                ; preds = %4
  tail call void %5(ptr noundef %0, i64 noundef %1)
  %7 = load ptr, ptr getelementptr inbounds (i8, ptr @_ZN11__sanitizerL7MFHooksE, i64 32), align 16, !tbaa !5
  %.not.not.2 = icmp eq ptr %7, null
  br i1 %.not.not.2, label %.critedge, label %8

8:                                                ; preds = %6
  tail call void %7(ptr noundef %0, i64 noundef %1)
  %9 = load ptr, ptr getelementptr inbounds (i8, ptr @_ZN11__sanitizerL7MFHooksE, i64 48), align 16, !tbaa !5
  %.not.not.3 = icmp eq ptr %9, null
  br i1 %.not.not.3, label %.critedge, label %10

10:                                               ; preds = %8
  tail call void %9(ptr noundef %0, i64 noundef %1)
  %11 = load ptr, ptr getelementptr inbounds (i8, ptr @_ZN11__sanitizerL7MFHooksE, i64 64), align 16, !tbaa !5
  %.not.not.4 = icmp eq ptr %11, null
  br i1 %.not.not.4, label %.critedge, label %12

12:                                               ; preds = %10
  tail call void %11(ptr noundef %0, i64 noundef %1)
  br label %.critedge

.critedge:                                        ; preds = %12, %10, %8, %6, %4, %2
  ret void
}

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

!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__sanitizer14MallocFreeHookE", !7, i64 0, !7, i64 8}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,LoopRotatePass,SROAPass,SimplifyCFGPass,TailCallElimPass