; LLVM IR from AngoraFuzzer/Angora :: llvm_mode/dfsan_rt/sanitizer_common (sanitizer_procmaps_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::ProcSelfMapsBuff" = type { ptr, i64, i64 }
%"class.__sanitizer::StaticSpinMutex" = type { %"struct.__sanitizer::atomic_uint8_t" }
%"struct.__sanitizer::atomic_uint8_t" = type { i8 }
%"class.__sanitizer::GenericScopedLock" = type { ptr }

@_ZN11__sanitizer19MemoryMappingLayout22cached_proc_self_maps_E = external dso_local global %"struct.__sanitizer::ProcSelfMapsBuff", align 8
@_ZN11__sanitizer19MemoryMappingLayout11cache_lock_E = external dso_local global %"class.__sanitizer::StaticSpinMutex", 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(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #0

declare void @_ZN11__sanitizer12ReadProcMapsEPNS_16ProcSelfMapsBuffE(ptr noundef) #1

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN11__sanitizer19MemoryMappingLayout19CacheMemoryMappingsEv() #2 align 2 personality ptr @__gxx_personality_v0 {
  %1 = alloca %"class.__sanitizer::GenericScopedLock", align 8
  %2 = alloca %"struct.__sanitizer::ProcSelfMapsBuff", align 8
  %3 = alloca ptr, align 8
  %4 = alloca i32, align 4
  call void @llvm.lifetime.start.p0(i64 8, ptr %1) #5
  call void @_ZN11__sanitizer17GenericScopedLockINS_15StaticSpinMutexEEC2EPS1_(ptr noundef nonnull align 8 dereferenceable(8) %1, ptr noundef @_ZN11__sanitizer19MemoryMappingLayout11cache_lock_E)
  call void @llvm.lifetime.start.p0(i64 24, ptr %2) #5
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %2, ptr align 8 @_ZN11__sanitizer19MemoryMappingLayout22cached_proc_self_maps_E, i64 24, i1 false), !tbaa.struct !5
  invoke void @_ZN11__sanitizer12ReadProcMapsEPNS_16ProcSelfMapsBuffE(ptr noundef @_ZN11__sanitizer19MemoryMappingLayout22cached_proc_self_maps_E)
          to label %5 unwind label %9

5:                                                ; preds = %0
  %6 = load i64, ptr getelementptr inbounds (%"struct.__sanitizer::ProcSelfMapsBuff", ptr @_ZN11__sanitizer19MemoryMappingLayout22cached_proc_self_maps_E, i32 0, i32 1), align 8, !tbaa !12
  %7 = icmp eq i64 %6, 0
  br i1 %7, label %8, label %13

8:                                                ; preds = %5
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 @_ZN11__sanitizer19MemoryMappingLayout22cached_proc_self_maps_E, ptr align 8 %2, i64 24, i1 false), !tbaa.struct !5
  br label %24

9:                                                ; preds = %17, %0
  %10 = landingpad { ptr, i32 }
          cleanup
  %11 = extractvalue { ptr, i32 } %10, 0
  store ptr %11, ptr %3, align 8
  %12 = extractvalue { ptr, i32 } %10, 1
  store i32 %12, ptr %4, align 4
  call void @llvm.lifetime.end.p0(i64 24, ptr %2) #5
  call void @_ZN11__sanitizer17GenericScopedLockINS_15StaticSpinMutexEED2Ev(ptr noundef nonnull align 8 dereferenceable(8) %1) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %1) #5
  br label %25

13:                                               ; preds = %5
  %14 = getelementptr inbounds %"struct.__sanitizer::ProcSelfMapsBuff", ptr %2, i32 0, i32 1
  %15 = load i64, ptr %14, align 8, !tbaa !12
  %16 = icmp ne i64 %15, 0
  br i1 %16, label %17, label %23

17:                                               ; preds = %13
  %18 = getelementptr inbounds %"struct.__sanitizer::ProcSelfMapsBuff", ptr %2, i32 0, i32 0
  %19 = load ptr, ptr %18, align 8, !tbaa !14
  %20 = getelementptr inbounds %"struct.__sanitizer::ProcSelfMapsBuff", ptr %2, i32 0, i32 1
  %21 = load i64, ptr %20, align 8, !tbaa !12
  invoke void @_ZN11__sanitizer10UnmapOrDieEPvm(ptr noundef %19, i64 noundef %21)
          to label %22 unwind label %9

22:                                               ; preds = %17
  br label %23

23:                                               ; preds = %22, %13
  br label %24

24:                                               ; preds = %23, %8
  call void @llvm.lifetime.end.p0(i64 24, ptr %2) #5
  call void @_ZN11__sanitizer17GenericScopedLockINS_15StaticSpinMutexEED2Ev(ptr noundef nonnull align 8 dereferenceable(8) %1) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %1) #5
  ret void

25:                                               ; preds = %9
  %26 = load ptr, ptr %3, align 8
  %27 = load i32, ptr %4, align 4
  %28 = insertvalue { ptr, i32 } poison, ptr %26, 0
  %29 = insertvalue { ptr, i32 } %28, i32 %27, 1
  resume { ptr, i32 } %29
}

declare void @_ZN11__sanitizer10UnmapOrDieEPvm(ptr noundef, i64 noundef) #1

declare i32 @__gxx_personality_v0(...)

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN11__sanitizer17GenericScopedLockINS_15StaticSpinMutexEEC2EPS1_(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef) unnamed_addr #2 align 2

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #3

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN11__sanitizer17GenericScopedLockINS_15StaticSpinMutexEED2Ev(ptr noundef nonnull align 8 dereferenceable(8)) unnamed_addr #4 align 2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { "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 = { 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 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
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 = { 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 = !{i64 0, i64 8, !6, i64 8, i64 8, !10, i64 16, i64 8, !10}
!6 = !{!7, !7, i64 0}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!11, !11, i64 0}
!11 = !{!"long", !8, i64 0}
!12 = !{!13, !11, i64 8}
!13 = !{!"_ZTSN11__sanitizer16ProcSelfMapsBuffE", !7, i64 0, !11, i64 8, !11, i64 16}
!14 = !{!13, !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"

%"struct.__sanitizer::ProcSelfMapsBuff" = type { ptr, i64, i64 }
%"class.__sanitizer::StaticSpinMutex" = type { %"struct.__sanitizer::atomic_uint8_t" }
%"struct.__sanitizer::atomic_uint8_t" = type { i8 }
%"class.__sanitizer::GenericScopedLock" = type { ptr }

@_ZN11__sanitizer19MemoryMappingLayout22cached_proc_self_maps_E = external dso_local global %"struct.__sanitizer::ProcSelfMapsBuff", align 8
@_ZN11__sanitizer19MemoryMappingLayout11cache_lock_E = external dso_local global %"class.__sanitizer::StaticSpinMutex", align 1

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

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

declare void @_ZN11__sanitizer12ReadProcMapsEPNS_16ProcSelfMapsBuffE(ptr noundef) local_unnamed_addr #1

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN11__sanitizer19MemoryMappingLayout19CacheMemoryMappingsEv() local_unnamed_addr #2 align 2 personality ptr @__gxx_personality_v0 {
  %1 = alloca %"class.__sanitizer::GenericScopedLock", align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %1) #4
  call void @_ZN11__sanitizer17GenericScopedLockINS_15StaticSpinMutexEEC2EPS1_(ptr noundef nonnull align 8 dereferenceable(8) %1, ptr noundef nonnull @_ZN11__sanitizer19MemoryMappingLayout11cache_lock_E)
  %.sroa.0.0.copyload = load ptr, ptr @_ZN11__sanitizer19MemoryMappingLayout22cached_proc_self_maps_E, align 8, !tbaa !5
  %2 = load <2 x i64>, ptr getelementptr inbounds (i8, ptr @_ZN11__sanitizer19MemoryMappingLayout22cached_proc_self_maps_E, i64 8), align 8, !tbaa !9
  invoke void @_ZN11__sanitizer12ReadProcMapsEPNS_16ProcSelfMapsBuffE(ptr noundef nonnull @_ZN11__sanitizer19MemoryMappingLayout22cached_proc_self_maps_E)
          to label %3 unwind label %7

3:                                                ; preds = %0
  %4 = load i64, ptr getelementptr inbounds (i8, ptr @_ZN11__sanitizer19MemoryMappingLayout22cached_proc_self_maps_E, i64 8), align 8, !tbaa !11
  %5 = icmp eq i64 %4, 0
  br i1 %5, label %6, label %9

6:                                                ; preds = %3
  store ptr %.sroa.0.0.copyload, ptr @_ZN11__sanitizer19MemoryMappingLayout22cached_proc_self_maps_E, align 8, !tbaa !5
  store <2 x i64> %2, ptr getelementptr inbounds (i8, ptr @_ZN11__sanitizer19MemoryMappingLayout22cached_proc_self_maps_E, i64 8), align 8, !tbaa !9
  br label %12

7:                                                ; preds = %11, %0
  %8 = landingpad { ptr, i32 }
          cleanup
  call void @_ZN11__sanitizer17GenericScopedLockINS_15StaticSpinMutexEED2Ev(ptr noundef nonnull align 8 dereferenceable(8) %1) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %1) #4
  resume { ptr, i32 } %8

9:                                                ; preds = %3
  %10 = extractelement <2 x i64> %2, i64 0
  %.not = icmp eq i64 %10, 0
  br i1 %.not, label %12, label %11

11:                                               ; preds = %9
  invoke void @_ZN11__sanitizer10UnmapOrDieEPvm(ptr noundef %.sroa.0.0.copyload, i64 noundef %10)
          to label %12 unwind label %7

12:                                               ; preds = %9, %11, %6
  call void @_ZN11__sanitizer17GenericScopedLockINS_15StaticSpinMutexEED2Ev(ptr noundef nonnull align 8 dereferenceable(8) %1) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %1) #4
  ret void
}

declare void @_ZN11__sanitizer10UnmapOrDieEPvm(ptr noundef, i64 noundef) local_unnamed_addr #1

declare i32 @__gxx_personality_v0(...)

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN11__sanitizer17GenericScopedLockINS_15StaticSpinMutexEEC2EPS1_(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef) unnamed_addr #2 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN11__sanitizer17GenericScopedLockINS_15StaticSpinMutexEED2Ev(ptr noundef nonnull align 8 dereferenceable(8)) unnamed_addr #3 align 2

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { "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 = { 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 = { 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 = { 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, !10, i64 8}
!12 = !{!"_ZTSN11__sanitizer16ProcSelfMapsBuffE", !6, i64 0, !10, i64 8, !10, i64 16}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,SLPVectorizerPass,SROAPass,SimplifyCFGPass