; LLVM IR from AngoraFuzzer/Angora :: llvm_mode/dfsan_rt/dfsan/dfsan_custom.ll_ (dfsw_memcmp)

; 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.__dfsan::Flags" = type { i8, i8, i8, ptr }

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(16) ptr @_ZN7__dfsan5flagsEv() #1

declare i32 @dfsan_union(i32 noundef, i32 noundef) #2

declare i32 @dfsan_read_label(ptr noundef, i64 noundef) #2

; 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 i32 @__dfsw_memcmp(ptr noundef %0, ptr noundef %1, i64 noundef %2, i32 noundef %3, i32 noundef %4, i32 noundef %5, ptr noundef %6) #3 {
  %8 = alloca i32, align 4
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca i64, align 8
  %12 = alloca i32, align 4
  %13 = alloca i32, align 4
  %14 = alloca i32, align 4
  %15 = alloca ptr, align 8
  %16 = alloca ptr, align 8
  %17 = alloca ptr, align 8
  %18 = alloca i64, align 8
  %19 = alloca i32, align 4
  store ptr %0, ptr %9, align 8, !tbaa !5
  store ptr %1, ptr %10, align 8, !tbaa !5
  store i64 %2, ptr %11, align 8, !tbaa !9
  store i32 %3, ptr %12, align 4, !tbaa !11
  store i32 %4, ptr %13, align 4, !tbaa !11
  store i32 %5, ptr %14, align 4, !tbaa !11
  store ptr %6, ptr %15, align 8, !tbaa !5
  br label %20

20:                                               ; preds = %7
  %21 = icmp ne ptr @dfsan_weak_hook_memcmp, null
  br i1 %21, label %22, label %31

22:                                               ; preds = %20
  %23 = call ptr @llvm.returnaddress(i32 0)
  %24 = ptrtoint ptr %23 to i64
  %25 = load ptr, ptr %9, align 8, !tbaa !5
  %26 = load ptr, ptr %10, align 8, !tbaa !5
  %27 = load i64, ptr %11, align 8, !tbaa !9
  %28 = load i32, ptr %12, align 4, !tbaa !11
  %29 = load i32, ptr %13, align 4, !tbaa !11
  %30 = load i32, ptr %14, align 4, !tbaa !11
  call void @dfsan_weak_hook_memcmp(i64 noundef %24, ptr noundef %25, ptr noundef %26, i64 noundef %27, i32 noundef %28, i32 noundef %29, i32 noundef %30)
  br label %31

31:                                               ; preds = %22, %20
  br label %32

32:                                               ; preds = %31
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #5
  %33 = load ptr, ptr %9, align 8, !tbaa !5
  store ptr %33, ptr %16, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %17) #5
  %34 = load ptr, ptr %10, align 8, !tbaa !5
  store ptr %34, ptr %17, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %18) #5
  store i64 0, ptr %18, align 8, !tbaa !9
  br label %35

35:                                               ; preds = %83, %32
  %36 = load i64, ptr %18, align 8, !tbaa !9
  %37 = load i64, ptr %11, align 8, !tbaa !9
  %38 = icmp ne i64 %36, %37
  br i1 %38, label %40, label %39

39:                                               ; preds = %35
  store i32 4, ptr %19, align 4
  br label %86

40:                                               ; preds = %35
  %41 = load ptr, ptr %16, align 8, !tbaa !5
  %42 = load i64, ptr %18, align 8, !tbaa !9
  %43 = getelementptr inbounds i8, ptr %41, i64 %42
  %44 = load i8, ptr %43, align 1, !tbaa !13
  %45 = sext i8 %44 to i32
  %46 = load ptr, ptr %17, align 8, !tbaa !5
  %47 = load i64, ptr %18, align 8, !tbaa !9
  %48 = getelementptr inbounds i8, ptr %46, i64 %47
  %49 = load i8, ptr %48, align 1, !tbaa !13
  %50 = sext i8 %49 to i32
  %51 = icmp ne i32 %45, %50
  br i1 %51, label %52, label %82

52:                                               ; preds = %40
  %53 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZN7__dfsan5flagsEv()
  %54 = getelementptr inbounds %"struct.__dfsan::Flags", ptr %53, i32 0, i32 2
  %55 = load i8, ptr %54, align 2, !tbaa !14, !range !17, !noundef !18
  %56 = trunc i8 %55 to i1
  br i1 %56, label %57, label %59

57:                                               ; preds = %52
  %58 = load ptr, ptr %15, align 8, !tbaa !5
  store i32 0, ptr %58, align 4, !tbaa !11
  br label %70

59:                                               ; preds = %52
  %60 = load ptr, ptr %16, align 8, !tbaa !5
  %61 = load i64, ptr %18, align 8, !tbaa !9
  %62 = add i64 %61, 1
  %63 = call i32 @dfsan_read_label(ptr noundef %60, i64 noundef %62)
  %64 = load ptr, ptr %17, align 8, !tbaa !5
  %65 = load i64, ptr %18, align 8, !tbaa !9
  %66 = add i64 %65, 1
  %67 = call i32 @dfsan_read_label(ptr noundef %64, i64 noundef %66)
  %68 = call i32 @dfsan_union(i32 noundef %63, i32 noundef %67)
  %69 = load ptr, ptr %15, align 8, !tbaa !5
  store i32 %68, ptr %69, align 4, !tbaa !11
  br label %70

70:                                               ; preds = %59, %57
  %71 = load ptr, ptr %16, align 8, !tbaa !5
  %72 = load i64, ptr %18, align 8, !tbaa !9
  %73 = getelementptr inbounds i8, ptr %71, i64 %72
  %74 = load i8, ptr %73, align 1, !tbaa !13
  %75 = sext i8 %74 to i32
  %76 = load ptr, ptr %17, align 8, !tbaa !5
  %77 = load i64, ptr %18, align 8, !tbaa !9
  %78 = getelementptr inbounds i8, ptr %76, i64 %77
  %79 = load i8, ptr %78, align 1, !tbaa !13
  %80 = sext i8 %79 to i32
  %81 = sub nsw i32 %75, %80
  store i32 %81, ptr %8, align 4
  store i32 1, ptr %19, align 4
  br label %86

82:                                               ; preds = %40
  br label %83

83:                                               ; preds = %82
  %84 = load i64, ptr %18, align 8, !tbaa !9
  %85 = add i64 %84, 1
  store i64 %85, ptr %18, align 8, !tbaa !9
  br label %35, !llvm.loop !19

86:                                               ; preds = %70, %39
  call void @llvm.lifetime.end.p0(i64 8, ptr %18) #5
  %87 = load i32, ptr %19, align 4
  switch i32 %87, label %105 [
    i32 4, label %88
  ]

88:                                               ; preds = %86
  %89 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZN7__dfsan5flagsEv()
  %90 = getelementptr inbounds %"struct.__dfsan::Flags", ptr %89, i32 0, i32 2
  %91 = load i8, ptr %90, align 2, !tbaa !14, !range !17, !noundef !18
  %92 = trunc i8 %91 to i1
  br i1 %92, label %93, label %95

93:                                               ; preds = %88
  %94 = load ptr, ptr %15, align 8, !tbaa !5
  store i32 0, ptr %94, align 4, !tbaa !11
  br label %104

95:                                               ; preds = %88
  %96 = load ptr, ptr %16, align 8, !tbaa !5
  %97 = load i64, ptr %11, align 8, !tbaa !9
  %98 = call i32 @dfsan_read_label(ptr noundef %96, i64 noundef %97)
  %99 = load ptr, ptr %17, align 8, !tbaa !5
  %100 = load i64, ptr %11, align 8, !tbaa !9
  %101 = call i32 @dfsan_read_label(ptr noundef %99, i64 noundef %100)
  %102 = call i32 @dfsan_union(i32 noundef %98, i32 noundef %101)
  %103 = load ptr, ptr %15, align 8, !tbaa !5
  store i32 %102, ptr %103, align 4, !tbaa !11
  br label %104

104:                                              ; preds = %95, %93
  store i32 0, ptr %8, align 4
  store i32 1, ptr %19, align 4
  br label %105

105:                                              ; preds = %104, %86
  call void @llvm.lifetime.end.p0(i64 8, ptr %17) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #5
  %106 = load i32, ptr %8, align 4
  ret i32 %106
}

declare extern_weak void @dfsan_weak_hook_memcmp(i64 noundef, ptr noundef, ptr noundef, i64 noundef, i32 noundef, i32 noundef, i32 noundef) #2

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(none)
declare ptr @llvm.returnaddress(i32 immarg) #4

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { inlinehint 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" }
attributes #3 = { 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 #4 = { nocallback nofree nosync nounwind willreturn memory(none) }
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 = !{!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 = !{!7, !7, i64 0}
!14 = !{!15, !16, i64 2}
!15 = !{!"_ZTSN7__dfsan5FlagsE", !16, i64 0, !16, i64 1, !16, i64 2, !6, i64 8}
!16 = !{!"bool", !7, i64 0}
!17 = !{i8 0, i8 2}
!18 = !{}
!19 = distinct !{!19, !20}
!20 = !{!"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: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(16) ptr @_ZN7__dfsan5flagsEv() local_unnamed_addr #0

declare i32 @dfsan_union(i32 noundef, i32 noundef) local_unnamed_addr #1

declare i32 @dfsan_read_label(ptr noundef, i64 noundef) local_unnamed_addr #1

; Function Attrs: mustprogress uwtable
define dso_local i32 @__dfsw_memcmp(ptr noundef %0, ptr noundef %1, i64 noundef %2, i32 noundef %3, i32 noundef %4, i32 noundef %5, ptr nocapture noundef writeonly %6) local_unnamed_addr #2 {
  %.not = icmp eq ptr @dfsan_weak_hook_memcmp, null
  br i1 %.not, label %11, label %8

8:                                                ; preds = %7
  %9 = tail call ptr @llvm.returnaddress(i32 0)
  %10 = ptrtoint ptr %9 to i64
  tail call void @dfsan_weak_hook_memcmp(i64 noundef %10, ptr noundef %0, ptr noundef %1, i64 noundef %2, i32 noundef %3, i32 noundef %4, i32 noundef %5)
  br label %11

11:                                               ; preds = %7, %8
  %.not3441 = icmp eq i64 %2, 0
  br i1 %.not3441, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %11, %28
  %.03242 = phi i64 [ %29, %28 ], [ 0, %11 ]
  %12 = getelementptr inbounds i8, ptr %0, i64 %.03242
  %13 = load i8, ptr %12, align 1, !tbaa !5
  %14 = getelementptr inbounds i8, ptr %1, i64 %.03242
  %15 = load i8, ptr %14, align 1, !tbaa !5
  %.not35 = icmp eq i8 %13, %15
  br i1 %.not35, label %28, label %16

16:                                               ; preds = %.lr.ph
  %17 = getelementptr inbounds i8, ptr %0, i64 %.03242
  %18 = getelementptr inbounds i8, ptr %1, i64 %.03242
  %19 = tail call noundef nonnull align 8 dereferenceable(16) ptr @_ZN7__dfsan5flagsEv()
  %20 = getelementptr inbounds i8, ptr %19, i64 2
  %21 = load i8, ptr %20, align 2, !tbaa !8, !range !12, !noundef !13
  %22 = trunc nuw i8 %21 to i1
  br i1 %22, label %30, label %23

23:                                               ; preds = %16
  %24 = add i64 %.03242, 1
  %25 = tail call i32 @dfsan_read_label(ptr noundef nonnull %0, i64 noundef %24)
  %26 = tail call i32 @dfsan_read_label(ptr noundef nonnull %1, i64 noundef %24)
  %27 = tail call i32 @dfsan_union(i32 noundef %25, i32 noundef %26)
  br label %30

28:                                               ; preds = %.lr.ph
  %29 = add nuw i64 %.03242, 1
  %.not34 = icmp eq i64 %29, %2
  br i1 %.not34, label %._crit_edge, label %.lr.ph, !llvm.loop !14

30:                                               ; preds = %23, %16
  %storemerge = phi i32 [ %27, %23 ], [ 0, %16 ]
  store i32 %storemerge, ptr %6, align 4, !tbaa !16
  %31 = load i8, ptr %17, align 1, !tbaa !5
  %32 = sext i8 %31 to i32
  %33 = load i8, ptr %18, align 1, !tbaa !5
  %34 = sext i8 %33 to i32
  %35 = sub nsw i32 %32, %34
  br label %45

._crit_edge:                                      ; preds = %28, %11
  %36 = tail call noundef nonnull align 8 dereferenceable(16) ptr @_ZN7__dfsan5flagsEv()
  %37 = getelementptr inbounds i8, ptr %36, i64 2
  %38 = load i8, ptr %37, align 2, !tbaa !8, !range !12, !noundef !13
  %39 = trunc nuw i8 %38 to i1
  br i1 %39, label %44, label %40

40:                                               ; preds = %._crit_edge
  %41 = tail call i32 @dfsan_read_label(ptr noundef %0, i64 noundef %2)
  %42 = tail call i32 @dfsan_read_label(ptr noundef %1, i64 noundef %2)
  %43 = tail call i32 @dfsan_union(i32 noundef %41, i32 noundef %42)
  br label %44

44:                                               ; preds = %._crit_edge, %40
  %storemerge36 = phi i32 [ %43, %40 ], [ 0, %._crit_edge ]
  store i32 %storemerge36, ptr %6, align 4, !tbaa !16
  br label %45

45:                                               ; preds = %30, %44
  %.1 = phi i32 [ 0, %44 ], [ %35, %30 ]
  ret i32 %.1
}

declare extern_weak void @dfsan_weak_hook_memcmp(i64 noundef, ptr noundef, ptr noundef, i64 noundef, i32 noundef, i32 noundef, i32 noundef) #1

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(none)
declare ptr @llvm.returnaddress(i32 immarg) #3

attributes #0 = { inlinehint 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 #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 nocallback nofree nosync nounwind willreturn memory(none) }

!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 = !{!"omnipotent char", !7, i64 0}
!7 = !{!"Simple C++ TBAA"}
!8 = !{!9, !10, i64 2}
!9 = !{!"_ZTSN7__dfsan5FlagsE", !10, i64 0, !10, i64 1, !10, i64 2, !11, i64 8}
!10 = !{!"bool", !6, i64 0}
!11 = !{!"any pointer", !6, i64 0}
!12 = !{i8 0, i8 2}
!13 = !{}
!14 = distinct !{!14, !15}
!15 = !{!"llvm.loop.mustprogress"}
!16 = !{!17, !17, i64 0}
!17 = !{!"int", !6, i64 0}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass