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

; 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_strcmp(ptr noundef %0, ptr noundef %1, i32 noundef %2, i32 noundef %3, ptr noundef %4) #4 {
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca ptr, align 8
  %11 = alloca i64, align 8
  store ptr %0, ptr %6, align 8, !tbaa !5
  store ptr %1, ptr %7, align 8, !tbaa !5
  store i32 %2, ptr %8, align 4, !tbaa !9
  store i32 %3, ptr %9, align 4, !tbaa !9
  store ptr %4, ptr %10, align 8, !tbaa !5
  br label %12

12:                                               ; preds = %5
  %13 = icmp ne ptr @dfsan_weak_hook_strcmp, null
  br i1 %13, label %14, label %21

14:                                               ; preds = %12
  %15 = call ptr @llvm.returnaddress(i32 0)
  %16 = ptrtoint ptr %15 to i64
  %17 = load ptr, ptr %6, align 8, !tbaa !5
  %18 = load ptr, ptr %7, align 8, !tbaa !5
  %19 = load i32, ptr %8, align 4, !tbaa !9
  %20 = load i32, ptr %9, align 4, !tbaa !9
  call void @dfsan_weak_hook_strcmp(i64 noundef %16, ptr noundef %17, ptr noundef %18, i32 noundef %19, i32 noundef %20)
  br label %21

21:                                               ; preds = %14, %12
  br label %22

22:                                               ; preds = %21
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #5
  store i64 0, ptr %11, align 8, !tbaa !11
  br label %23

23:                                               ; preds = %80, %22
  %24 = load ptr, ptr %6, align 8, !tbaa !5
  %25 = load i64, ptr %11, align 8, !tbaa !11
  %26 = getelementptr inbounds i8, ptr %24, i64 %25
  %27 = load i8, ptr %26, align 1, !tbaa !13
  %28 = sext i8 %27 to i32
  %29 = load ptr, ptr %7, align 8, !tbaa !5
  %30 = load i64, ptr %11, align 8, !tbaa !11
  %31 = getelementptr inbounds i8, ptr %29, i64 %30
  %32 = load i8, ptr %31, align 1, !tbaa !13
  %33 = sext i8 %32 to i32
  %34 = icmp ne i32 %28, %33
  br i1 %34, label %49, label %35

35:                                               ; preds = %23
  %36 = load ptr, ptr %6, align 8, !tbaa !5
  %37 = load i64, ptr %11, align 8, !tbaa !11
  %38 = getelementptr inbounds i8, ptr %36, i64 %37
  %39 = load i8, ptr %38, align 1, !tbaa !13
  %40 = sext i8 %39 to i32
  %41 = icmp eq i32 %40, 0
  br i1 %41, label %49, label %42

42:                                               ; preds = %35
  %43 = load ptr, ptr %7, align 8, !tbaa !5
  %44 = load i64, ptr %11, align 8, !tbaa !11
  %45 = getelementptr inbounds i8, ptr %43, i64 %44
  %46 = load i8, ptr %45, align 1, !tbaa !13
  %47 = sext i8 %46 to i32
  %48 = icmp eq i32 %47, 0
  br i1 %48, label %49, label %79

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

54:                                               ; preds = %49
  %55 = load ptr, ptr %10, align 8, !tbaa !5
  store i32 0, ptr %55, align 4, !tbaa !9
  br label %67

56:                                               ; preds = %49
  %57 = load ptr, ptr %6, align 8, !tbaa !5
  %58 = load i64, ptr %11, align 8, !tbaa !11
  %59 = add i64 %58, 1
  %60 = call i32 @dfsan_read_label(ptr noundef %57, i64 noundef %59)
  %61 = load ptr, ptr %7, align 8, !tbaa !5
  %62 = load i64, ptr %11, align 8, !tbaa !11
  %63 = add i64 %62, 1
  %64 = call i32 @dfsan_read_label(ptr noundef %61, i64 noundef %63)
  %65 = call i32 @dfsan_union(i32 noundef %60, i32 noundef %64)
  %66 = load ptr, ptr %10, align 8, !tbaa !5
  store i32 %65, ptr %66, align 4, !tbaa !9
  br label %67

67:                                               ; preds = %56, %54
  %68 = load ptr, ptr %6, align 8, !tbaa !5
  %69 = load i64, ptr %11, align 8, !tbaa !11
  %70 = getelementptr inbounds i8, ptr %68, i64 %69
  %71 = load i8, ptr %70, align 1, !tbaa !13
  %72 = sext i8 %71 to i32
  %73 = load ptr, ptr %7, align 8, !tbaa !5
  %74 = load i64, ptr %11, align 8, !tbaa !11
  %75 = getelementptr inbounds i8, ptr %73, i64 %74
  %76 = load i8, ptr %75, align 1, !tbaa !13
  %77 = sext i8 %76 to i32
  %78 = sub nsw i32 %72, %77
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #5
  ret i32 %78

79:                                               ; preds = %42
  br label %80

80:                                               ; preds = %79
  %81 = load i64, ptr %11, align 8, !tbaa !11
  %82 = add i64 %81, 1
  store i64 %82, ptr %11, align 8, !tbaa !11
  br label %23, !llvm.loop !19
}

declare extern_weak void @dfsan_weak_hook_strcmp(i64 noundef, ptr noundef, ptr 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 = !{!"int", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"long", !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_strcmp(ptr noundef %0, ptr noundef %1, i32 noundef %2, i32 noundef %3, ptr nocapture noundef writeonly %4) local_unnamed_addr #3 {
  %.not = icmp eq ptr @dfsan_weak_hook_strcmp, null
  br i1 %.not, label %.preheader, label %6

6:                                                ; preds = %5
  %7 = tail call ptr @llvm.returnaddress(i32 0)
  %8 = ptrtoint ptr %7 to i64
  tail call void @dfsan_weak_hook_strcmp(i64 noundef %8, ptr noundef %0, ptr noundef %1, i32 noundef %2, i32 noundef %3)
  br label %.preheader

.preheader:                                       ; preds = %5, %6
  br label %9

9:                                                ; preds = %.preheader, %9
  %.0 = phi i64 [ %16, %9 ], [ 0, %.preheader ]
  %10 = getelementptr inbounds i8, ptr %0, i64 %.0
  %11 = load i8, ptr %10, align 1, !tbaa !5
  %12 = getelementptr inbounds i8, ptr %1, i64 %.0
  %13 = load i8, ptr %12, align 1, !tbaa !5
  %.not24 = icmp ne i8 %11, %13
  %14 = icmp eq i8 %11, 0
  %or.cond = or i1 %14, %.not24
  %15 = icmp eq i8 %13, 0
  %or.cond25 = or i1 %15, %or.cond
  %16 = add i64 %.0, 1
  br i1 %or.cond25, label %17, label %9, !llvm.loop !8

17:                                               ; preds = %9
  %18 = tail call noundef nonnull align 8 dereferenceable(16) ptr @_ZN7__dfsan5flagsEv()
  %19 = getelementptr inbounds i8, ptr %18, i64 2
  %20 = load i8, ptr %19, align 2, !tbaa !10, !range !14, !noundef !15
  %21 = trunc nuw i8 %20 to i1
  br i1 %21, label %26, label %22

22:                                               ; preds = %17
  %23 = tail call i32 @dfsan_read_label(ptr noundef nonnull %0, i64 noundef %16)
  %24 = tail call i32 @dfsan_read_label(ptr noundef nonnull %1, i64 noundef %16)
  %25 = tail call i32 @dfsan_union(i32 noundef %23, i32 noundef %24)
  br label %26

26:                                               ; preds = %17, %22
  %storemerge = phi i32 [ %25, %22 ], [ 0, %17 ]
  %27 = getelementptr inbounds i8, ptr %1, i64 %.0
  %28 = getelementptr inbounds i8, ptr %0, i64 %.0
  store i32 %storemerge, ptr %4, align 4, !tbaa !16
  %29 = load i8, ptr %28, align 1, !tbaa !5
  %30 = sext i8 %29 to i32
  %31 = load i8, ptr %27, align 1, !tbaa !5
  %32 = sext i8 %31 to i32
  %33 = sub nsw i32 %30, %32
  ret i32 %33
}

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


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