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

; 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_strcasecmp(ptr noundef %0, ptr noundef %1, i32 noundef %2, i32 noundef %3, ptr noundef %4) #3 {
  %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
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #5
  store i64 0, ptr %11, align 8, !tbaa !11
  br label %12

12:                                               ; preds = %71, %5
  %13 = load ptr, ptr %6, align 8, !tbaa !5
  %14 = load i64, ptr %11, align 8, !tbaa !11
  %15 = getelementptr inbounds i8, ptr %13, i64 %14
  %16 = load i8, ptr %15, align 1, !tbaa !13
  %17 = sext i8 %16 to i32
  %18 = call i32 @tolower(i32 noundef %17) #6
  %19 = load ptr, ptr %7, align 8, !tbaa !5
  %20 = load i64, ptr %11, align 8, !tbaa !11
  %21 = getelementptr inbounds i8, ptr %19, i64 %20
  %22 = load i8, ptr %21, align 1, !tbaa !13
  %23 = sext i8 %22 to i32
  %24 = call i32 @tolower(i32 noundef %23) #6
  %25 = icmp ne i32 %18, %24
  br i1 %25, label %40, label %26

26:                                               ; preds = %12
  %27 = load ptr, ptr %6, align 8, !tbaa !5
  %28 = load i64, ptr %11, align 8, !tbaa !11
  %29 = getelementptr inbounds i8, ptr %27, i64 %28
  %30 = load i8, ptr %29, align 1, !tbaa !13
  %31 = sext i8 %30 to i32
  %32 = icmp eq i32 %31, 0
  br i1 %32, label %40, label %33

33:                                               ; preds = %26
  %34 = load ptr, ptr %7, align 8, !tbaa !5
  %35 = load i64, ptr %11, align 8, !tbaa !11
  %36 = getelementptr inbounds i8, ptr %34, i64 %35
  %37 = load i8, ptr %36, align 1, !tbaa !13
  %38 = sext i8 %37 to i32
  %39 = icmp eq i32 %38, 0
  br i1 %39, label %40, label %70

40:                                               ; preds = %33, %26, %12
  %41 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZN7__dfsan5flagsEv()
  %42 = getelementptr inbounds %"struct.__dfsan::Flags", ptr %41, i32 0, i32 2
  %43 = load i8, ptr %42, align 2, !tbaa !14, !range !17, !noundef !18
  %44 = trunc i8 %43 to i1
  br i1 %44, label %45, label %47

45:                                               ; preds = %40
  %46 = load ptr, ptr %10, align 8, !tbaa !5
  store i32 0, ptr %46, align 4, !tbaa !9
  br label %58

47:                                               ; preds = %40
  %48 = load ptr, ptr %6, align 8, !tbaa !5
  %49 = load i64, ptr %11, align 8, !tbaa !11
  %50 = add i64 %49, 1
  %51 = call i32 @dfsan_read_label(ptr noundef %48, i64 noundef %50)
  %52 = load ptr, ptr %7, align 8, !tbaa !5
  %53 = load i64, ptr %11, align 8, !tbaa !11
  %54 = add i64 %53, 1
  %55 = call i32 @dfsan_read_label(ptr noundef %52, i64 noundef %54)
  %56 = call i32 @dfsan_union(i32 noundef %51, i32 noundef %55)
  %57 = load ptr, ptr %10, align 8, !tbaa !5
  store i32 %56, ptr %57, align 4, !tbaa !9
  br label %58

58:                                               ; preds = %47, %45
  %59 = load ptr, ptr %6, align 8, !tbaa !5
  %60 = load i64, ptr %11, align 8, !tbaa !11
  %61 = getelementptr inbounds i8, ptr %59, i64 %60
  %62 = load i8, ptr %61, align 1, !tbaa !13
  %63 = sext i8 %62 to i32
  %64 = load ptr, ptr %7, align 8, !tbaa !5
  %65 = load i64, ptr %11, align 8, !tbaa !11
  %66 = getelementptr inbounds i8, ptr %64, i64 %65
  %67 = load i8, ptr %66, align 1, !tbaa !13
  %68 = sext i8 %67 to i32
  %69 = sub nsw i32 %63, %68
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #5
  ret i32 %69

70:                                               ; preds = %33
  br label %71

71:                                               ; preds = %70
  %72 = load i64, ptr %11, align 8, !tbaa !11
  %73 = add i64 %72, 1
  store i64 %73, ptr %11, align 8, !tbaa !11
  br label %12, !llvm.loop !19
}

; Function Attrs: nounwind willreturn memory(read)
declare i32 @tolower(i32 noundef) #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 = { nounwind willreturn memory(read) "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 }
attributes #6 = { nounwind willreturn memory(read) }

!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 uwtable
define dso_local range(i32 -255, 256) i32 @__dfsw_strcasecmp(ptr noundef %0, ptr noundef %1, i32 noundef %2, i32 noundef %3, ptr nocapture noundef writeonly %4) local_unnamed_addr #2 {
  br label %6

6:                                                ; preds = %6, %5
  %.0 = phi i64 [ 0, %5 ], [ %17, %6 ]
  %7 = getelementptr inbounds i8, ptr %0, i64 %.0
  %8 = load i8, ptr %7, align 1, !tbaa !5
  %9 = sext i8 %8 to i32
  %10 = tail call i32 @tolower(i32 noundef %9) #4
  %11 = getelementptr inbounds i8, ptr %1, i64 %.0
  %12 = load i8, ptr %11, align 1, !tbaa !5
  %13 = sext i8 %12 to i32
  %14 = tail call i32 @tolower(i32 noundef %13) #4
  %.not = icmp ne i32 %10, %14
  %15 = icmp eq i8 %8, 0
  %or.cond = or i1 %15, %.not
  %16 = icmp eq i8 %12, 0
  %or.cond18 = or i1 %16, %or.cond
  %17 = add i64 %.0, 1
  br i1 %or.cond18, label %18, label %6, !llvm.loop !8

18:                                               ; preds = %6
  %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 !10, !range !14, !noundef !15
  %22 = trunc nuw i8 %21 to i1
  br i1 %22, label %27, label %23

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

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

; Function Attrs: mustprogress nofree nounwind willreturn memory(read)
declare i32 @tolower(i32 noundef) local_unnamed_addr #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 nofree nounwind willreturn memory(read) "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 willreturn memory(read) }

!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