; LLVM IR from ARM-software/Arm-2D :: Helper/Source (arm_2d_helper_pfb)

; 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.arm_2d_region_list_item_t = type { ptr, %struct.anon.6, %struct.arm_2d_region_t, %struct.anon.7 }
%struct.anon.6 = type { ptr }
%struct.arm_2d_region_t = type { %union.anon, %union.anon.0 }
%union.anon = type { %struct.arm_2d_location_t }
%struct.arm_2d_location_t = type { i16, i16 }
%union.anon.0 = type { %struct.arm_2d_size_t }
%struct.arm_2d_size_t = type { i16, i16 }
%struct.anon.7 = type { i8, i8, i16 }

; Function Attrs: nounwind uwtable
define dso_local zeroext i1 @arm_2d_helper_pfb_remove_dirty_regions_from_list(ptr noundef nonnull %0, ptr noundef nonnull %1, i64 noundef %2) #0 {
  %4 = alloca i1, align 1
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i64, align 8
  store ptr %0, ptr %5, align 8, !tbaa !5
  store ptr %1, ptr %6, align 8, !tbaa !5
  store i64 %2, ptr %7, align 8, !tbaa !9
  br label %8

8:                                                ; preds = %3
  %9 = load ptr, ptr %6, align 8, !tbaa !5
  %10 = icmp eq ptr null, %9
  br i1 %10, label %17, label %11

11:                                               ; preds = %8
  %12 = load i64, ptr %7, align 8, !tbaa !9
  %13 = icmp eq i64 0, %12
  br i1 %13, label %17, label %14

14:                                               ; preds = %11
  %15 = load ptr, ptr %5, align 8, !tbaa !5
  %16 = icmp eq ptr null, %15
  br i1 %16, label %17, label %18

17:                                               ; preds = %14, %11, %8
  br label %48

18:                                               ; preds = %14
  br label %19

19:                                               ; preds = %43, %18
  br label %20

20:                                               ; preds = %36, %19
  %21 = load ptr, ptr %5, align 8, !tbaa !5
  %22 = load ptr, ptr %21, align 8, !tbaa !5
  %23 = icmp ne ptr null, %22
  br i1 %23, label %24, label %40

24:                                               ; preds = %20
  %25 = load ptr, ptr %5, align 8, !tbaa !5
  %26 = load ptr, ptr %25, align 8, !tbaa !5
  %27 = load ptr, ptr %6, align 8, !tbaa !5
  %28 = icmp eq ptr %26, %27
  br i1 %28, label %29, label %36

29:                                               ; preds = %24
  %30 = load ptr, ptr %6, align 8, !tbaa !5
  %31 = getelementptr inbounds %struct.arm_2d_region_list_item_t, ptr %30, i32 0, i32 0
  %32 = load ptr, ptr %31, align 8, !tbaa !11
  %33 = load ptr, ptr %5, align 8, !tbaa !5
  store ptr %32, ptr %33, align 8, !tbaa !5
  %34 = load ptr, ptr %6, align 8, !tbaa !5
  %35 = getelementptr inbounds %struct.arm_2d_region_list_item_t, ptr %34, i32 0, i32 0
  store ptr null, ptr %35, align 8, !tbaa !11
  br label %40

36:                                               ; preds = %24
  %37 = load ptr, ptr %5, align 8, !tbaa !5
  %38 = load ptr, ptr %37, align 8, !tbaa !5
  %39 = getelementptr inbounds %struct.arm_2d_region_list_item_t, ptr %38, i32 0, i32 0
  store ptr %39, ptr %5, align 8, !tbaa !5
  br label %20, !llvm.loop !17

40:                                               ; preds = %29, %20
  %41 = load ptr, ptr %6, align 8, !tbaa !5
  %42 = getelementptr inbounds %struct.arm_2d_region_list_item_t, ptr %41, i32 1
  store ptr %42, ptr %6, align 8, !tbaa !5
  br label %43

43:                                               ; preds = %40
  %44 = load i64, ptr %7, align 8, !tbaa !9
  %45 = add i64 %44, -1
  store i64 %45, ptr %7, align 8, !tbaa !9
  %46 = icmp ne i64 %45, 0
  br i1 %46, label %19, label %47, !llvm.loop !19

47:                                               ; preds = %43
  store i1 true, ptr %4, align 1
  br label %49

48:                                               ; preds = %17
  store i1 false, ptr %4, align 1
  br label %49

49:                                               ; preds = %48, %47
  %50 = load i1, ptr %4, align 1
  ret i1 %50
}

attributes #0 = { 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" }

!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/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"long", !7, i64 0}
!11 = !{!12, !6, i64 0}
!12 = !{!"arm_2d_region_list_item_t", !6, i64 0, !13, i64 8, !14, i64 16, !15, i64 24}
!13 = !{!"", !6, i64 0}
!14 = !{!"arm_2d_region_t", !7, i64 0, !7, i64 4}
!15 = !{!"", !7, i64 0, !7, i64 1, !7, i64 1, !16, i64 2, !16, i64 2, !16, i64 2, !16, i64 2}
!16 = !{!"short", !7, i64 0}
!17 = distinct !{!17, !18}
!18 = !{!"llvm.loop.mustprogress"}
!19 = distinct !{!19, !18}


; 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: nofree norecurse nosync nounwind memory(readwrite, inaccessiblemem: none) uwtable
define dso_local noundef zeroext i1 @arm_2d_helper_pfb_remove_dirty_regions_from_list(ptr nocapture noundef nonnull %0, ptr noundef nonnull %1, i64 noundef %2) local_unnamed_addr #0 {
  %4 = icmp ne i64 %2, 0
  br i1 %4, label %.preheader.preheader, label %.loopexit22

.preheader.preheader:                             ; preds = %3
  %xtraiter = and i64 %2, 1
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br i1 %lcmp.mod.not, label %.preheader.prol.loopexit, label %.preheader.prol

.preheader.prol:                                  ; preds = %.preheader.preheader, %6
  %.1.prol = phi ptr [ %5, %6 ], [ %0, %.preheader.preheader ]
  %5 = load ptr, ptr %.1.prol, align 8, !tbaa !5
  %.not.prol = icmp eq ptr %5, null
  br i1 %.not.prol, label %.loopexit.prol, label %6

6:                                                ; preds = %.preheader.prol
  %7 = icmp eq ptr %5, %1
  br i1 %7, label %8, label %.preheader.prol, !llvm.loop !9

8:                                                ; preds = %6
  %9 = load ptr, ptr %1, align 8, !tbaa !11
  store ptr %9, ptr %.1.prol, align 8, !tbaa !5
  store ptr null, ptr %1, align 8, !tbaa !11
  br label %.loopexit.prol

.loopexit.prol:                                   ; preds = %.preheader.prol, %8
  %10 = getelementptr inbounds i8, ptr %1, i64 32
  %11 = add nsw i64 %2, -1
  br label %.preheader.prol.loopexit

.preheader.prol.loopexit:                         ; preds = %.loopexit.prol, %.preheader.preheader
  %.016.unr = phi ptr [ %0, %.preheader.preheader ], [ %.1.prol, %.loopexit.prol ]
  %.015.unr = phi ptr [ %1, %.preheader.preheader ], [ %10, %.loopexit.prol ]
  %.0.unr = phi i64 [ %2, %.preheader.preheader ], [ %11, %.loopexit.prol ]
  %12 = icmp eq i64 %2, 1
  br i1 %12, label %.loopexit22, label %.preheader

.preheader:                                       ; preds = %.preheader.prol.loopexit, %.loopexit.1
  %.016 = phi ptr [ %.1.1, %.loopexit.1 ], [ %.016.unr, %.preheader.prol.loopexit ]
  %.015 = phi ptr [ %26, %.loopexit.1 ], [ %.015.unr, %.preheader.prol.loopexit ]
  %.0 = phi i64 [ %27, %.loopexit.1 ], [ %.0.unr, %.preheader.prol.loopexit ]
  br label %13

13:                                               ; preds = %15, %.preheader
  %.1 = phi ptr [ %.016, %.preheader ], [ %14, %15 ]
  %14 = load ptr, ptr %.1, align 8, !tbaa !5
  %.not = icmp eq ptr %14, null
  br i1 %.not, label %.loopexit, label %15

15:                                               ; preds = %13
  %16 = icmp eq ptr %14, %.015
  br i1 %16, label %17, label %13, !llvm.loop !9

17:                                               ; preds = %15
  %18 = load ptr, ptr %.015, align 8, !tbaa !11
  store ptr %18, ptr %.1, align 8, !tbaa !5
  store ptr null, ptr %.015, align 8, !tbaa !11
  br label %.loopexit

.loopexit:                                        ; preds = %13, %17
  %19 = getelementptr inbounds i8, ptr %.015, i64 32
  br label %20

20:                                               ; preds = %22, %.loopexit
  %.1.1 = phi ptr [ %.1, %.loopexit ], [ %21, %22 ]
  %21 = load ptr, ptr %.1.1, align 8, !tbaa !5
  %.not.1 = icmp eq ptr %21, null
  br i1 %.not.1, label %.loopexit.1, label %22

22:                                               ; preds = %20
  %23 = icmp eq ptr %21, %19
  br i1 %23, label %24, label %20, !llvm.loop !9

24:                                               ; preds = %22
  %25 = load ptr, ptr %19, align 8, !tbaa !11
  store ptr %25, ptr %.1.1, align 8, !tbaa !5
  store ptr null, ptr %19, align 8, !tbaa !11
  br label %.loopexit.1

.loopexit.1:                                      ; preds = %20, %24
  %26 = getelementptr inbounds i8, ptr %.015, i64 64
  %27 = add i64 %.0, -2
  %.not21.1 = icmp eq i64 %27, 0
  br i1 %.not21.1, label %.loopexit22, label %.preheader, !llvm.loop !17

.loopexit22:                                      ; preds = %.preheader.prol.loopexit, %.loopexit.1, %3
  ret i1 %4
}

attributes #0 = { nofree norecurse nosync nounwind memory(readwrite, inaccessiblemem: none) 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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = !{!12, !6, i64 0}
!12 = !{!"arm_2d_region_list_item_t", !6, i64 0, !13, i64 8, !14, i64 16, !15, i64 24}
!13 = !{!"", !6, i64 0}
!14 = !{!"arm_2d_region_t", !7, i64 0, !7, i64 4}
!15 = !{!"", !7, i64 0, !7, i64 1, !7, i64 1, !16, i64 2, !16, i64 2, !16, i64 2, !16, i64 2}
!16 = !{!"short", !7, i64 0}
!17 = distinct !{!17, !10}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass