; LLVM IR from ermig1979/Simd :: src/Test/TestCompare.ll (ZN4Test9FullEqualERKN4Simd4ViewINS0_9AllocatorEEES5_)

; 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.Simd::View" = type <{ i64, i64, i64, i32, [4 x i8], ptr, i8, [7 x i8] }>

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_ZN4Test9FullEqualERKN4Simd4ViewINS0_9AllocatorEEES5_(ptr noundef nonnull align 8 dereferenceable(41) %0, ptr noundef nonnull align 8 dereferenceable(41) %1) #0 {
  %3 = alloca i1, align 1
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i64, align 8
  %7 = alloca i64, align 8
  %8 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #4
  %9 = load ptr, ptr %4, align 8, !tbaa !5
  %10 = call noundef i64 @_ZNK4Simd4ViewINS_9AllocatorEE9PixelSizeEv(ptr noundef nonnull align 8 dereferenceable(41) %9)
  %11 = load ptr, ptr %4, align 8, !tbaa !5
  %12 = getelementptr inbounds %"struct.Simd::View", ptr %11, i32 0, i32 0
  %13 = load i64, ptr %12, align 8, !tbaa !9
  %14 = mul i64 %10, %13
  store i64 %14, ptr %6, align 8, !tbaa !14
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #4
  store i64 0, ptr %7, align 8, !tbaa !14
  br label %15

15:                                               ; preds = %46, %2
  %16 = load i64, ptr %7, align 8, !tbaa !14
  %17 = load ptr, ptr %4, align 8, !tbaa !5
  %18 = getelementptr inbounds %"struct.Simd::View", ptr %17, i32 0, i32 1
  %19 = load i64, ptr %18, align 8, !tbaa !15
  %20 = icmp ult i64 %16, %19
  br i1 %20, label %22, label %21

21:                                               ; preds = %15
  store i32 2, ptr %8, align 4
  br label %49

22:                                               ; preds = %15
  %23 = load ptr, ptr %4, align 8, !tbaa !5
  %24 = getelementptr inbounds %"struct.Simd::View", ptr %23, i32 0, i32 5
  %25 = load ptr, ptr %24, align 8, !tbaa !16
  %26 = load i64, ptr %7, align 8, !tbaa !14
  %27 = load ptr, ptr %4, align 8, !tbaa !5
  %28 = getelementptr inbounds %"struct.Simd::View", ptr %27, i32 0, i32 2
  %29 = load i64, ptr %28, align 8, !tbaa !17
  %30 = mul i64 %26, %29
  %31 = getelementptr inbounds i8, ptr %25, i64 %30
  %32 = load ptr, ptr %5, align 8, !tbaa !5
  %33 = getelementptr inbounds %"struct.Simd::View", ptr %32, i32 0, i32 5
  %34 = load ptr, ptr %33, align 8, !tbaa !16
  %35 = load i64, ptr %7, align 8, !tbaa !14
  %36 = load ptr, ptr %5, align 8, !tbaa !5
  %37 = getelementptr inbounds %"struct.Simd::View", ptr %36, i32 0, i32 2
  %38 = load i64, ptr %37, align 8, !tbaa !17
  %39 = mul i64 %35, %38
  %40 = getelementptr inbounds i8, ptr %34, i64 %39
  %41 = load i64, ptr %6, align 8, !tbaa !14
  %42 = call i32 @memcmp(ptr noundef %31, ptr noundef %40, i64 noundef %41) #5
  %43 = icmp ne i32 %42, 0
  br i1 %43, label %44, label %45

44:                                               ; preds = %22
  store i1 false, ptr %3, align 1
  store i32 1, ptr %8, align 4
  br label %49

45:                                               ; preds = %22
  br label %46

46:                                               ; preds = %45
  %47 = load i64, ptr %7, align 8, !tbaa !14
  %48 = add i64 %47, 1
  store i64 %48, ptr %7, align 8, !tbaa !14
  br label %15, !llvm.loop !18

49:                                               ; preds = %44, %21
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #4
  %50 = load i32, ptr %8, align 4
  switch i32 %50, label %52 [
    i32 2, label %51
  ]

51:                                               ; preds = %49
  store i1 true, ptr %3, align 1
  store i32 1, ptr %8, align 4
  br label %52

52:                                               ; preds = %51, %49
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #4
  %53 = load i1, ptr %3, align 1
  ret i1 %53
}

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

; Function Attrs: alwaysinline mustprogress uwtable
declare dso_local noundef i64 @_ZNK4Simd4ViewINS_9AllocatorEE9PixelSizeEv(ptr noundef nonnull align 8 dereferenceable(41)) #2 align 2

; Function Attrs: nounwind willreturn memory(read)
declare i32 @memcmp(ptr noundef, ptr noundef, i64 noundef) #3

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

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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { alwaysinline 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 = { 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 }
attributes #5 = { 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, !11, i64 0}
!10 = !{!"_ZTSN4Simd4ViewINS_9AllocatorEEE", !11, i64 0, !11, i64 8, !11, i64 16, !12, i64 24, !6, i64 32, !13, i64 40}
!11 = !{!"long", !7, i64 0}
!12 = !{!"_ZTSN4Simd4ViewINS_9AllocatorEE6FormatE", !7, i64 0}
!13 = !{!"bool", !7, i64 0}
!14 = !{!11, !11, i64 0}
!15 = !{!10, !11, i64 8}
!16 = !{!10, !6, i64 32}
!17 = !{!10, !11, i64 16}
!18 = distinct !{!18, !19}
!19 = !{!"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 zeroext i1 @_ZN4Test9FullEqualERKN4Simd4ViewINS0_9AllocatorEEES5_(ptr noundef nonnull align 8 dereferenceable(41) %0, ptr nocapture noundef nonnull readonly align 8 dereferenceable(41) %1) local_unnamed_addr #0 {
  %3 = tail call noundef i64 @_ZNK4Simd4ViewINS_9AllocatorEE9PixelSizeEv(ptr noundef nonnull align 8 dereferenceable(41) %0)
  %4 = load i64, ptr %0, align 8, !tbaa !5
  %5 = mul i64 %4, %3
  %6 = getelementptr inbounds i8, ptr %0, i64 8
  %7 = load i64, ptr %6, align 8, !tbaa !13
  %.not1516 = icmp eq i64 %7, 0
  br i1 %.not1516, label %.critedge, label %.lr.ph

.lr.ph:                                           ; preds = %2
  %8 = getelementptr inbounds i8, ptr %0, i64 32
  %9 = load ptr, ptr %8, align 8, !tbaa !14
  %10 = getelementptr inbounds i8, ptr %0, i64 16
  %11 = load i64, ptr %10, align 8, !tbaa !15
  %12 = getelementptr inbounds i8, ptr %1, i64 32
  %13 = load ptr, ptr %12, align 8, !tbaa !14
  %14 = getelementptr inbounds i8, ptr %1, i64 16
  %15 = load i64, ptr %14, align 8, !tbaa !15
  %bcmp21 = tail call i32 @bcmp(ptr %9, ptr %13, i64 %5)
  %.not22 = icmp eq i32 %bcmp21, 0
  br i1 %.not22, label %.lr.ph24, label %.critedge

.lr.ph24:                                         ; preds = %.lr.ph, %17
  %.0131723 = phi i64 [ %16, %17 ], [ 0, %.lr.ph ]
  %16 = add nuw i64 %.0131723, 1
  %exitcond = icmp eq i64 %16, %7
  br i1 %exitcond, label %.critedge.loopexit, label %17, !llvm.loop !16

17:                                               ; preds = %.lr.ph24
  %18 = mul i64 %11, %16
  %19 = getelementptr inbounds i8, ptr %9, i64 %18
  %20 = mul i64 %15, %16
  %21 = getelementptr inbounds i8, ptr %13, i64 %20
  %bcmp = tail call i32 @bcmp(ptr %19, ptr %21, i64 %5)
  %.not = icmp eq i32 %bcmp, 0
  br i1 %.not, label %.lr.ph24, label %.critedge.loopexit, !llvm.loop !16

.critedge.loopexit:                               ; preds = %17, %.lr.ph24
  %.not15.le = icmp uge i64 %16, %7
  br label %.critedge

.critedge:                                        ; preds = %.critedge.loopexit, %.lr.ph, %2
  %.not15.lcssa = phi i1 [ true, %2 ], [ false, %.lr.ph ], [ %.not15.le, %.critedge.loopexit ]
  ret i1 %.not15.lcssa
}

; Function Attrs: alwaysinline mustprogress uwtable
declare dso_local noundef i64 @_ZNK4Simd4ViewINS_9AllocatorEE9PixelSizeEv(ptr noundef nonnull align 8 dereferenceable(41)) local_unnamed_addr #1 align 2

; Function Attrs: nofree nounwind willreturn memory(argmem: read)
declare i32 @bcmp(ptr nocapture, ptr nocapture, i64) 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 = { alwaysinline 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 = { nofree nounwind willreturn memory(argmem: 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, !7, i64 0}
!6 = !{!"_ZTSN4Simd4ViewINS_9AllocatorEEE", !7, i64 0, !7, i64 8, !7, i64 16, !10, i64 24, !11, i64 32, !12, i64 40}
!7 = !{!"long", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"_ZTSN4Simd4ViewINS_9AllocatorEE6FormatE", !8, i64 0}
!11 = !{!"any pointer", !8, i64 0}
!12 = !{!"bool", !8, i64 0}
!13 = !{!6, !7, i64 8}
!14 = !{!6, !11, i64 32}
!15 = !{!6, !7, i64 16}
!16 = distinct !{!16, !17}
!17 = !{!"llvm.loop.mustprogress"}


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