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

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

%"class.__sanitizer::ThreadLister" = type <{ i32, i32, %"class.__sanitizer::InternalScopedBuffer", i8, [7 x i8], ptr, i32, [4 x i8] }>
%"class.__sanitizer::InternalScopedBuffer" = type { ptr, i64 }
%"struct.__sanitizer::linux_dirent" = type { i64, i64, i16, [256 x i8] }

; 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 noundef i32 @_ZN11__sanitizer12ThreadLister10GetNextTIDEv(ptr noundef nonnull align 8 dereferenceable(44) %0) #1 align 2 {
  %2 = alloca i32, align 4
  %3 = alloca ptr, align 8
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  %6 = load ptr, ptr %3, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #4
  store i32 -1, ptr %4, align 4, !tbaa !9
  br label %7

7:                                                ; preds = %64, %1
  %8 = getelementptr inbounds %"class.__sanitizer::ThreadLister", ptr %6, i32 0, i32 3
  %9 = load i8, ptr %8, align 8, !tbaa !11, !range !16, !noundef !17
  %10 = trunc i8 %9 to i1
  br i1 %10, label %11, label %12

11:                                               ; preds = %7
  store i32 -1, ptr %2, align 4
  store i32 1, ptr %5, align 4
  br label %69

12:                                               ; preds = %7
  %13 = getelementptr inbounds %"class.__sanitizer::ThreadLister", ptr %6, i32 0, i32 5
  %14 = load ptr, ptr %13, align 8, !tbaa !18
  %15 = getelementptr inbounds %"class.__sanitizer::ThreadLister", ptr %6, i32 0, i32 2
  %16 = getelementptr inbounds %"class.__sanitizer::ThreadLister", ptr %6, i32 0, i32 6
  %17 = load i32, ptr %16, align 8, !tbaa !19
  %18 = sext i32 %17 to i64
  %19 = call noundef nonnull align 1 dereferenceable(1) ptr @_ZN11__sanitizer20InternalScopedBufferIcEixEm(ptr noundef nonnull align 8 dereferenceable(16) %15, i64 noundef %18)
  %20 = icmp uge ptr %14, %19
  br i1 %20, label %21, label %24

21:                                               ; preds = %12
  %22 = call noundef zeroext i1 @_ZN11__sanitizer12ThreadLister19GetDirectoryEntriesEv(ptr noundef nonnull align 8 dereferenceable(44) %6)
  br i1 %22, label %24, label %23

23:                                               ; preds = %21
  store i32 -1, ptr %2, align 4
  store i32 1, ptr %5, align 4
  br label %69

24:                                               ; preds = %21, %12
  %25 = getelementptr inbounds %"class.__sanitizer::ThreadLister", ptr %6, i32 0, i32 5
  %26 = load ptr, ptr %25, align 8, !tbaa !18
  %27 = getelementptr inbounds %"struct.__sanitizer::linux_dirent", ptr %26, i32 0, i32 0
  %28 = load i64, ptr %27, align 8, !tbaa !20
  %29 = icmp ne i64 %28, 0
  br i1 %29, label %30, label %53

30:                                               ; preds = %24
  %31 = getelementptr inbounds %"class.__sanitizer::ThreadLister", ptr %6, i32 0, i32 5
  %32 = load ptr, ptr %31, align 8, !tbaa !18
  %33 = getelementptr inbounds %"struct.__sanitizer::linux_dirent", ptr %32, i32 0, i32 3
  %34 = getelementptr inbounds [256 x i8], ptr %33, i64 0, i64 0
  %35 = load i8, ptr %34, align 2, !tbaa !23
  %36 = sext i8 %35 to i32
  %37 = icmp sge i32 %36, 48
  br i1 %37, label %38, label %53

38:                                               ; preds = %30
  %39 = getelementptr inbounds %"class.__sanitizer::ThreadLister", ptr %6, i32 0, i32 5
  %40 = load ptr, ptr %39, align 8, !tbaa !18
  %41 = getelementptr inbounds %"struct.__sanitizer::linux_dirent", ptr %40, i32 0, i32 3
  %42 = getelementptr inbounds [256 x i8], ptr %41, i64 0, i64 0
  %43 = load i8, ptr %42, align 2, !tbaa !23
  %44 = sext i8 %43 to i32
  %45 = icmp sle i32 %44, 57
  br i1 %45, label %46, label %53

46:                                               ; preds = %38
  %47 = getelementptr inbounds %"class.__sanitizer::ThreadLister", ptr %6, i32 0, i32 5
  %48 = load ptr, ptr %47, align 8, !tbaa !18
  %49 = getelementptr inbounds %"struct.__sanitizer::linux_dirent", ptr %48, i32 0, i32 3
  %50 = getelementptr inbounds [256 x i8], ptr %49, i64 0, i64 0
  %51 = call noundef i64 @_ZN11__sanitizer14internal_atollEPKc(ptr noundef %50)
  %52 = trunc i64 %51 to i32
  store i32 %52, ptr %4, align 4, !tbaa !9
  br label %53

53:                                               ; preds = %46, %38, %30, %24
  %54 = getelementptr inbounds %"class.__sanitizer::ThreadLister", ptr %6, i32 0, i32 5
  %55 = load ptr, ptr %54, align 8, !tbaa !18
  %56 = getelementptr inbounds %"class.__sanitizer::ThreadLister", ptr %6, i32 0, i32 5
  %57 = load ptr, ptr %56, align 8, !tbaa !18
  %58 = getelementptr inbounds %"struct.__sanitizer::linux_dirent", ptr %57, i32 0, i32 2
  %59 = load i16, ptr %58, align 8, !tbaa !24
  %60 = zext i16 %59 to i32
  %61 = sext i32 %60 to i64
  %62 = getelementptr inbounds i8, ptr %55, i64 %61
  %63 = getelementptr inbounds %"class.__sanitizer::ThreadLister", ptr %6, i32 0, i32 5
  store ptr %62, ptr %63, align 8, !tbaa !18
  br label %64

64:                                               ; preds = %53
  %65 = load i32, ptr %4, align 4, !tbaa !9
  %66 = icmp slt i32 %65, 0
  br i1 %66, label %7, label %67, !llvm.loop !25

67:                                               ; preds = %64
  %68 = load i32, ptr %4, align 4, !tbaa !9
  store i32 %68, ptr %2, align 4
  store i32 1, ptr %5, align 4
  br label %69

69:                                               ; preds = %67, %23, %11
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #4
  %70 = load i32, ptr %2, align 4
  ret i32 %70
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 1 dereferenceable(1) ptr @_ZN11__sanitizer20InternalScopedBufferIcEixEm(ptr noundef nonnull align 8 dereferenceable(16), i64 noundef) #2 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZN11__sanitizer12ThreadLister19GetDirectoryEntriesEv(ptr noundef nonnull align 8 dereferenceable(44)) #1 align 2

declare noundef i64 @_ZN11__sanitizer14internal_atollEPKc(ptr noundef) #3

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 = { 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 #3 = { "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 = !{!"int", !7, i64 0}
!11 = !{!12, !15, i64 24}
!12 = !{!"_ZTSN11__sanitizer12ThreadListerE", !10, i64 0, !10, i64 4, !13, i64 8, !15, i64 24, !6, i64 32, !10, i64 40}
!13 = !{!"_ZTSN11__sanitizer20InternalScopedBufferIcEE", !6, i64 0, !14, i64 8}
!14 = !{!"long", !7, i64 0}
!15 = !{!"bool", !7, i64 0}
!16 = !{i8 0, i8 2}
!17 = !{}
!18 = !{!12, !6, i64 32}
!19 = !{!12, !10, i64 40}
!20 = !{!21, !14, i64 0}
!21 = !{!"_ZTSN11__sanitizer12linux_direntE", !14, i64 0, !14, i64 8, !22, i64 16, !7, i64 18}
!22 = !{!"short", !7, i64 0}
!23 = !{!7, !7, i64 0}
!24 = !{!21, !22, i64 16}
!25 = distinct !{!25, !26}
!26 = !{!"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"

; Function Attrs: mustprogress uwtable
define dso_local noundef range(i32 -1, -2147483648) i32 @_ZN11__sanitizer12ThreadLister10GetNextTIDEv(ptr noundef nonnull align 8 dereferenceable(44) %0) local_unnamed_addr #0 align 2 {
  %2 = getelementptr inbounds i8, ptr %0, i64 24
  %3 = getelementptr inbounds i8, ptr %0, i64 32
  %4 = getelementptr inbounds i8, ptr %0, i64 8
  %5 = getelementptr inbounds i8, ptr %0, i64 40
  br label %6

6:                                                ; preds = %26, %1
  %.0 = phi i32 [ -1, %1 ], [ %.1, %26 ]
  %7 = load i8, ptr %2, align 8, !tbaa !5, !range !14, !noundef !15
  %8 = trunc nuw i8 %7 to i1
  br i1 %8, label %33, label %9

9:                                                ; preds = %6
  %10 = load ptr, ptr %3, align 8, !tbaa !16
  %11 = load i32, ptr %5, align 8, !tbaa !17
  %12 = sext i32 %11 to i64
  %13 = tail call noundef nonnull align 1 dereferenceable(1) ptr @_ZN11__sanitizer20InternalScopedBufferIcEixEm(ptr noundef nonnull align 8 dereferenceable(16) %4, i64 noundef %12)
  %.not = icmp ult ptr %10, %13
  br i1 %.not, label %16, label %14

14:                                               ; preds = %9
  %15 = tail call noundef zeroext i1 @_ZN11__sanitizer12ThreadLister19GetDirectoryEntriesEv(ptr noundef nonnull align 8 dereferenceable(44) %0)
  br i1 %15, label %16, label %33

16:                                               ; preds = %14, %9
  %17 = load ptr, ptr %3, align 8, !tbaa !16
  %18 = load i64, ptr %17, align 8, !tbaa !18
  %.not5 = icmp eq i64 %18, 0
  br i1 %.not5, label %26, label %19

19:                                               ; preds = %16
  %20 = getelementptr inbounds i8, ptr %17, i64 18
  %21 = load i8, ptr %20, align 2, !tbaa !21
  %22 = add i8 %21, -48
  %or.cond = icmp ult i8 %22, 10
  br i1 %or.cond, label %23, label %26

23:                                               ; preds = %19
  %24 = tail call noundef i64 @_ZN11__sanitizer14internal_atollEPKc(ptr noundef nonnull %20)
  %25 = trunc i64 %24 to i32
  %.pre = load ptr, ptr %3, align 8, !tbaa !16
  br label %26

26:                                               ; preds = %23, %19, %16
  %27 = phi ptr [ %.pre, %23 ], [ %17, %19 ], [ %17, %16 ]
  %.1 = phi i32 [ %25, %23 ], [ %.0, %19 ], [ %.0, %16 ]
  %28 = getelementptr inbounds i8, ptr %27, i64 16
  %29 = load i16, ptr %28, align 8, !tbaa !22
  %30 = zext i16 %29 to i64
  %31 = getelementptr inbounds i8, ptr %27, i64 %30
  store ptr %31, ptr %3, align 8, !tbaa !16
  %32 = icmp slt i32 %.1, 0
  br i1 %32, label %6, label %33, !llvm.loop !23

33:                                               ; preds = %26, %14, %6
  %.03 = phi i32 [ -1, %6 ], [ -1, %14 ], [ %.1, %26 ]
  ret i32 %.03
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 1 dereferenceable(1) ptr @_ZN11__sanitizer20InternalScopedBufferIcEixEm(ptr noundef nonnull align 8 dereferenceable(16), i64 noundef) local_unnamed_addr #1 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZN11__sanitizer12ThreadLister19GetDirectoryEntriesEv(ptr noundef nonnull align 8 dereferenceable(44)) local_unnamed_addr #0 align 2

declare noundef i64 @_ZN11__sanitizer14internal_atollEPKc(ptr noundef) 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 = { 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 #2 = { "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, !13, i64 24}
!6 = !{!"_ZTSN11__sanitizer12ThreadListerE", !7, i64 0, !7, i64 4, !10, i64 8, !13, i64 24, !11, i64 32, !7, i64 40}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"_ZTSN11__sanitizer20InternalScopedBufferIcEE", !11, i64 0, !12, i64 8}
!11 = !{!"any pointer", !8, i64 0}
!12 = !{!"long", !8, i64 0}
!13 = !{!"bool", !8, i64 0}
!14 = !{i8 0, i8 2}
!15 = !{}
!16 = !{!6, !11, i64 32}
!17 = !{!6, !7, i64 40}
!18 = !{!19, !12, i64 0}
!19 = !{!"_ZTSN11__sanitizer12linux_direntE", !12, i64 0, !12, i64 8, !20, i64 16, !8, i64 18}
!20 = !{!"short", !8, i64 0}
!21 = !{!8, !8, i64 0}
!22 = !{!19, !20, i64 16}
!23 = distinct !{!23, !24}
!24 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,LICMPass,SROAPass,SimplifyCFGPass,TailCallElimPass