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

; 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: nocallback nofree nosync nounwind willreturn memory(none)
declare ptr @llvm.returnaddress(i32 immarg) #3

; Function Attrs: mustprogress uwtable
define dso_local i32 @__dfsw_strncmp(ptr noundef %0, ptr noundef %1, i64 noundef %2, i32 noundef %3, i32 noundef %4, i32 noundef %5, ptr noundef %6) #4 {
  %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 i64, align 8
  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
  %17 = load i64, ptr %11, align 8, !tbaa !9
  %18 = icmp eq i64 %17, 0
  br i1 %18, label %19, label %21

19:                                               ; preds = %7
  %20 = load ptr, ptr %15, align 8, !tbaa !5
  store i32 0, ptr %20, align 4, !tbaa !11
  store i32 0, ptr %8, align 4
  br label %100

21:                                               ; preds = %7
  br label %22

22:                                               ; preds = %21
  %23 = icmp ne ptr @dfsan_weak_hook_strncmp, null
  br i1 %23, label %24, label %33

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

33:                                               ; preds = %24, %22
  br label %34

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

35:                                               ; preds = %97, %34
  %36 = load ptr, ptr %9, align 8, !tbaa !5
  %37 = load i64, ptr %16, align 8, !tbaa !9
  %38 = getelementptr inbounds i8, ptr %36, i64 %37
  %39 = load i8, ptr %38, align 1, !tbaa !13
  %40 = sext i8 %39 to i32
  %41 = load ptr, ptr %10, align 8, !tbaa !5
  %42 = load i64, ptr %16, 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 = icmp ne i32 %40, %45
  br i1 %46, label %66, label %47

47:                                               ; preds = %35
  %48 = load ptr, ptr %9, align 8, !tbaa !5
  %49 = load i64, ptr %16, align 8, !tbaa !9
  %50 = getelementptr inbounds i8, ptr %48, i64 %49
  %51 = load i8, ptr %50, align 1, !tbaa !13
  %52 = sext i8 %51 to i32
  %53 = icmp eq i32 %52, 0
  br i1 %53, label %66, label %54

54:                                               ; preds = %47
  %55 = load ptr, ptr %10, align 8, !tbaa !5
  %56 = load i64, ptr %16, align 8, !tbaa !9
  %57 = getelementptr inbounds i8, ptr %55, i64 %56
  %58 = load i8, ptr %57, align 1, !tbaa !13
  %59 = sext i8 %58 to i32
  %60 = icmp eq i32 %59, 0
  br i1 %60, label %66, label %61

61:                                               ; preds = %54
  %62 = load i64, ptr %16, align 8, !tbaa !9
  %63 = load i64, ptr %11, align 8, !tbaa !9
  %64 = sub i64 %63, 1
  %65 = icmp eq i64 %62, %64
  br i1 %65, label %66, label %96

66:                                               ; preds = %61, %54, %47, %35
  %67 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZN7__dfsan5flagsEv()
  %68 = getelementptr inbounds %"struct.__dfsan::Flags", ptr %67, i32 0, i32 2
  %69 = load i8, ptr %68, align 2, !tbaa !14, !range !17, !noundef !18
  %70 = trunc i8 %69 to i1
  br i1 %70, label %71, label %73

71:                                               ; preds = %66
  %72 = load ptr, ptr %15, align 8, !tbaa !5
  store i32 0, ptr %72, align 4, !tbaa !11
  br label %84

73:                                               ; preds = %66
  %74 = load ptr, ptr %9, align 8, !tbaa !5
  %75 = load i64, ptr %16, align 8, !tbaa !9
  %76 = add i64 %75, 1
  %77 = call i32 @dfsan_read_label(ptr noundef %74, i64 noundef %76)
  %78 = load ptr, ptr %10, align 8, !tbaa !5
  %79 = load i64, ptr %16, align 8, !tbaa !9
  %80 = add i64 %79, 1
  %81 = call i32 @dfsan_read_label(ptr noundef %78, i64 noundef %80)
  %82 = call i32 @dfsan_union(i32 noundef %77, i32 noundef %81)
  %83 = load ptr, ptr %15, align 8, !tbaa !5
  store i32 %82, ptr %83, align 4, !tbaa !11
  br label %84

84:                                               ; preds = %73, %71
  %85 = load ptr, ptr %9, align 8, !tbaa !5
  %86 = load i64, ptr %16, align 8, !tbaa !9
  %87 = getelementptr inbounds i8, ptr %85, i64 %86
  %88 = load i8, ptr %87, align 1, !tbaa !13
  %89 = sext i8 %88 to i32
  %90 = load ptr, ptr %10, align 8, !tbaa !5
  %91 = load i64, ptr %16, align 8, !tbaa !9
  %92 = getelementptr inbounds i8, ptr %90, i64 %91
  %93 = load i8, ptr %92, align 1, !tbaa !13
  %94 = sext i8 %93 to i32
  %95 = sub nsw i32 %89, %94
  store i32 %95, ptr %8, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #5
  br label %100

96:                                               ; preds = %61
  br label %97

97:                                               ; preds = %96
  %98 = load i64, ptr %16, align 8, !tbaa !9
  %99 = add i64 %98, 1
  store i64 %99, ptr %16, align 8, !tbaa !9
  br label %35, !llvm.loop !19

100:                                              ; preds = %84, %19
  %101 = load i32, ptr %8, align 4
  ret i32 %101
}

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

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

!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 nocallback nofree nosync nounwind willreturn memory(none)
declare ptr @llvm.returnaddress(i32 immarg) #2

; Function Attrs: mustprogress uwtable
define dso_local range(i32 -255, 256) i32 @__dfsw_strncmp(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 #3 {
  %8 = icmp eq i64 %2, 0
  br i1 %8, label %9, label %10

9:                                                ; preds = %7
  store i32 0, ptr %6, align 4, !tbaa !5
  br label %42

10:                                               ; preds = %7
  %.not = icmp eq ptr @dfsan_weak_hook_strncmp, null
  br i1 %.not, label %14, label %11

11:                                               ; preds = %10
  %12 = tail call ptr @llvm.returnaddress(i32 0)
  %13 = ptrtoint ptr %12 to i64
  tail call void @dfsan_weak_hook_strncmp(i64 noundef %13, ptr noundef %0, ptr noundef %1, i64 noundef %2, i32 noundef %3, i32 noundef %4, i32 noundef %5)
  br label %14

14:                                               ; preds = %10, %11
  %15 = add i64 %2, -1
  br label %16

16:                                               ; preds = %16, %14
  %.0 = phi i64 [ 0, %14 ], [ %24, %16 ]
  %17 = getelementptr inbounds i8, ptr %0, i64 %.0
  %18 = load i8, ptr %17, align 1, !tbaa !9
  %19 = getelementptr inbounds i8, ptr %1, i64 %.0
  %20 = load i8, ptr %19, align 1, !tbaa !9
  %.not33 = icmp ne i8 %18, %20
  %21 = icmp eq i8 %18, 0
  %or.cond = or i1 %21, %.not33
  %22 = icmp eq i8 %20, 0
  %or.cond34 = or i1 %22, %or.cond
  %23 = icmp eq i64 %.0, %15
  %or.cond36 = or i1 %23, %or.cond34
  %24 = add i64 %.0, 1
  br i1 %or.cond36, label %25, label %16, !llvm.loop !10

25:                                               ; preds = %16
  %26 = getelementptr inbounds i8, ptr %0, i64 %.0
  %27 = getelementptr inbounds i8, ptr %1, i64 %.0
  %28 = tail call noundef nonnull align 8 dereferenceable(16) ptr @_ZN7__dfsan5flagsEv()
  %29 = getelementptr inbounds i8, ptr %28, i64 2
  %30 = load i8, ptr %29, align 2, !tbaa !12, !range !16, !noundef !17
  %31 = trunc nuw i8 %30 to i1
  br i1 %31, label %36, label %32

32:                                               ; preds = %25
  %33 = tail call i32 @dfsan_read_label(ptr noundef nonnull %0, i64 noundef %24)
  %34 = tail call i32 @dfsan_read_label(ptr noundef nonnull %1, i64 noundef %24)
  %35 = tail call i32 @dfsan_union(i32 noundef %33, i32 noundef %34)
  br label %36

36:                                               ; preds = %25, %32
  %storemerge = phi i32 [ %35, %32 ], [ 0, %25 ]
  store i32 %storemerge, ptr %6, align 4, !tbaa !5
  %37 = load i8, ptr %26, align 1, !tbaa !9
  %38 = sext i8 %37 to i32
  %39 = load i8, ptr %27, align 1, !tbaa !9
  %40 = sext i8 %39 to i32
  %41 = sub nsw i32 %38, %40
  br label %42

42:                                               ; preds = %36, %9
  %.029 = phi i32 [ 0, %9 ], [ %41, %36 ]
  ret i32 %.029
}

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

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 nocallback nofree nosync nounwind willreturn memory(none) }
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" }

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


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