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

; 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_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.arm_2d_helper_dirty_region_t = type { %struct.anon.33, %struct.arm_2d_helper_dirty_region_item_t }
%struct.anon.33 = type <{ %struct.arm_2d_region_list_item_t, ptr, ptr, i8, i32, [3 x i8] }>
%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.anon.7 = type { i8, i8, i16 }
%struct.arm_2d_helper_dirty_region_item_t = type { %struct.anon.34, %struct.arm_2d_region_t }
%struct.anon.34 = type { ptr, ptr, %union.anon.35, %struct.arm_2d_region_t, i8, i8, i16 }
%union.anon.35 = type { [2 x %struct.arm_2d_region_t] }
%struct.anon.36 = type { %struct.arm_2d_region_t, %union.anon.37 }
%union.anon.37 = type { %struct.arm_2d_region_t }

@.str = external hidden unnamed_addr constant [15 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [87 x i8], align 1
@.str.20 = external hidden unnamed_addr constant [21 x i8], align 1
@__PRETTY_FUNCTION__.__arm_2d_helper_dirty_region_update_dirty_regions = external hidden unnamed_addr constant [110 x i8], align 1

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) #0

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

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

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #2

; Function Attrs: nounwind uwtable
declare dso_local zeroext i8 @arm_2d_dynamic_dirty_region_wait_next(ptr noundef nonnull) #3

; Function Attrs: nounwind uwtable
declare dso_local void @arm_2d_dynamic_dirty_region_change_user_region_index_only(ptr noundef nonnull, i8 noundef zeroext) #3

; Function Attrs: nounwind uwtable
declare hidden void @__arm_2d_dynamic_dirty_region_update(ptr noundef nonnull, ptr noundef, ptr noundef, i8 noundef zeroext, i1 noundef zeroext) #3

declare ptr @arm_2d_region_get_minimal_enclosure(ptr noundef, ptr noundef, ptr noundef) #4

; Function Attrs: nounwind uwtable
define dso_local void @__arm_2d_helper_dirty_region_update_dirty_regions(ptr noundef nonnull %0, ptr noundef nonnull %1) #3 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca %struct.arm_2d_region_t, align 2
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  %6 = load ptr, ptr %3, align 8, !tbaa !5
  %7 = icmp ne ptr null, %6
  br i1 %7, label %8, label %9

8:                                                ; preds = %2
  br label %10

9:                                                ; preds = %2
  call void @__assert_fail(ptr noundef @.str, ptr noundef @.str.1, i32 noundef 4658, ptr noundef @__PRETTY_FUNCTION__.__arm_2d_helper_dirty_region_update_dirty_regions) #5
  unreachable

10:                                               ; preds = %8
  %11 = load ptr, ptr %4, align 8, !tbaa !5
  %12 = icmp ne ptr null, %11
  br i1 %12, label %13, label %14

13:                                               ; preds = %10
  br label %15

14:                                               ; preds = %10
  call void @__assert_fail(ptr noundef @.str.20, ptr noundef @.str.1, i32 noundef 4659, ptr noundef @__PRETTY_FUNCTION__.__arm_2d_helper_dirty_region_update_dirty_regions) #5
  unreachable

15:                                               ; preds = %13
  %16 = load ptr, ptr %3, align 8, !tbaa !5
  %17 = getelementptr inbounds %struct.arm_2d_helper_dirty_region_t, ptr %16, i32 0, i32 0
  %18 = getelementptr inbounds %struct.anon.33, ptr %17, i32 0, i32 0
  %19 = call zeroext i8 @arm_2d_dynamic_dirty_region_wait_next(ptr noundef %18)
  %20 = zext i8 %19 to i32
  switch i32 %20, label %189 [
    i32 0, label %21
    i32 1, label %21
    i32 2, label %168
    i32 3, label %190
  ]

21:                                               ; preds = %15, %15
  %22 = load ptr, ptr %3, align 8, !tbaa !5
  %23 = getelementptr inbounds %struct.arm_2d_helper_dirty_region_t, ptr %22, i32 0, i32 0
  %24 = getelementptr inbounds %struct.anon.33, ptr %23, i32 0, i32 2
  %25 = load ptr, ptr %24, align 8, !tbaa !9
  %26 = icmp ne ptr null, %25
  br i1 %26, label %27, label %163

27:                                               ; preds = %21
  br label %28

28:                                               ; preds = %62, %27
  %29 = load ptr, ptr %3, align 8, !tbaa !5
  %30 = getelementptr inbounds %struct.arm_2d_helper_dirty_region_t, ptr %29, i32 0, i32 0
  %31 = getelementptr inbounds %struct.anon.33, ptr %30, i32 0, i32 2
  %32 = load ptr, ptr %31, align 8, !tbaa !9
  %33 = getelementptr inbounds %struct.arm_2d_helper_dirty_region_item_t, ptr %32, i32 0, i32 0
  %34 = getelementptr inbounds %struct.anon.34, ptr %33, i32 0, i32 4
  %35 = load i8, ptr %34, align 8
  %36 = lshr i8 %35, 2
  %37 = and i8 %36, 1
  %38 = icmp ne i8 %37, 0
  br i1 %38, label %51, label %39

39:                                               ; preds = %28
  %40 = load ptr, ptr %3, align 8, !tbaa !5
  %41 = getelementptr inbounds %struct.arm_2d_helper_dirty_region_t, ptr %40, i32 0, i32 0
  %42 = getelementptr inbounds %struct.anon.33, ptr %41, i32 0, i32 2
  %43 = load ptr, ptr %42, align 8, !tbaa !9
  %44 = getelementptr inbounds %struct.arm_2d_helper_dirty_region_item_t, ptr %43, i32 0, i32 0
  %45 = getelementptr inbounds %struct.anon.34, ptr %44, i32 0, i32 4
  %46 = load i8, ptr %45, align 8
  %47 = lshr i8 %46, 1
  %48 = and i8 %47, 1
  %49 = icmp ne i8 %48, 0
  br i1 %49, label %51, label %50

50:                                               ; preds = %39
  br label %68

51:                                               ; preds = %39, %28
  %52 = load ptr, ptr %3, align 8, !tbaa !5
  %53 = getelementptr inbounds %struct.arm_2d_helper_dirty_region_t, ptr %52, i32 0, i32 0
  %54 = getelementptr inbounds %struct.anon.33, ptr %53, i32 0, i32 2
  %55 = load ptr, ptr %54, align 8, !tbaa !9
  %56 = getelementptr inbounds %struct.arm_2d_helper_dirty_region_item_t, ptr %55, i32 0, i32 0
  %57 = getelementptr inbounds %struct.anon.34, ptr %56, i32 0, i32 0
  %58 = load ptr, ptr %57, align 8, !tbaa !19
  %59 = load ptr, ptr %3, align 8, !tbaa !5
  %60 = getelementptr inbounds %struct.arm_2d_helper_dirty_region_t, ptr %59, i32 0, i32 0
  %61 = getelementptr inbounds %struct.anon.33, ptr %60, i32 0, i32 2
  store ptr %58, ptr %61, align 8, !tbaa !9
  br label %62

62:                                               ; preds = %51
  %63 = load ptr, ptr %3, align 8, !tbaa !5
  %64 = getelementptr inbounds %struct.arm_2d_helper_dirty_region_t, ptr %63, i32 0, i32 0
  %65 = getelementptr inbounds %struct.anon.33, ptr %64, i32 0, i32 2
  %66 = load ptr, ptr %65, align 8, !tbaa !9
  %67 = icmp ne ptr null, %66
  br i1 %67, label %28, label %68, !llvm.loop !20

68:                                               ; preds = %62, %50
  %69 = load ptr, ptr %3, align 8, !tbaa !5
  %70 = getelementptr inbounds %struct.arm_2d_helper_dirty_region_t, ptr %69, i32 0, i32 0
  %71 = getelementptr inbounds %struct.anon.33, ptr %70, i32 0, i32 2
  %72 = load ptr, ptr %71, align 8, !tbaa !9
  %73 = icmp eq ptr null, %72
  br i1 %73, label %74, label %78

74:                                               ; preds = %68
  %75 = load ptr, ptr %3, align 8, !tbaa !5
  %76 = getelementptr inbounds %struct.arm_2d_helper_dirty_region_t, ptr %75, i32 0, i32 0
  %77 = getelementptr inbounds %struct.anon.33, ptr %76, i32 0, i32 0
  call void @arm_2d_dynamic_dirty_region_change_user_region_index_only(ptr noundef %77, i8 noundef zeroext 3)
  br label %190

78:                                               ; preds = %68
  %79 = load ptr, ptr %3, align 8, !tbaa !5
  %80 = getelementptr inbounds %struct.arm_2d_helper_dirty_region_t, ptr %79, i32 0, i32 0
  %81 = getelementptr inbounds %struct.anon.33, ptr %80, i32 0, i32 2
  %82 = load ptr, ptr %81, align 8, !tbaa !9
  %83 = getelementptr inbounds %struct.arm_2d_helper_dirty_region_item_t, ptr %82, i32 0, i32 0
  %84 = getelementptr inbounds %struct.anon.34, ptr %83, i32 0, i32 4
  %85 = load i8, ptr %84, align 8
  %86 = and i8 %85, -5
  %87 = or i8 %86, 4
  store i8 %87, ptr %84, align 8
  %88 = load ptr, ptr %3, align 8, !tbaa !5
  %89 = getelementptr inbounds %struct.arm_2d_helper_dirty_region_t, ptr %88, i32 0, i32 0
  %90 = getelementptr inbounds %struct.anon.33, ptr %89, i32 0, i32 2
  %91 = load ptr, ptr %90, align 8, !tbaa !9
  %92 = getelementptr inbounds %struct.arm_2d_helper_dirty_region_item_t, ptr %91, i32 0, i32 0
  %93 = getelementptr inbounds %struct.anon.34, ptr %92, i32 0, i32 4
  %94 = load i8, ptr %93, align 8
  %95 = lshr i8 %94, 3
  %96 = and i8 %95, 1
  %97 = icmp ne i8 %96, 0
  br i1 %97, label %98, label %151

98:                                               ; preds = %78
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #6
  %99 = load ptr, ptr %3, align 8, !tbaa !5
  %100 = getelementptr inbounds %struct.arm_2d_helper_dirty_region_t, ptr %99, i32 0, i32 0
  %101 = getelementptr inbounds %struct.anon.33, ptr %100, i32 0, i32 2
  %102 = load ptr, ptr %101, align 8, !tbaa !9
  %103 = getelementptr inbounds %struct.arm_2d_helper_dirty_region_item_t, ptr %102, i32 0, i32 0
  %104 = getelementptr inbounds %struct.anon.34, ptr %103, i32 0, i32 2
  %105 = getelementptr inbounds %struct.anon.36, ptr %104, i32 0, i32 1
  call void @llvm.memcpy.p0.p0.i64(ptr align 2 %5, ptr align 8 %105, i64 8, i1 false), !tbaa.struct !22
  %106 = load ptr, ptr %3, align 8, !tbaa !5
  %107 = getelementptr inbounds %struct.arm_2d_helper_dirty_region_t, ptr %106, i32 0, i32 0
  %108 = getelementptr inbounds %struct.anon.33, ptr %107, i32 0, i32 2
  %109 = load ptr, ptr %108, align 8, !tbaa !9
  %110 = getelementptr inbounds %struct.arm_2d_helper_dirty_region_item_t, ptr %109, i32 0, i32 0
  %111 = getelementptr inbounds %struct.anon.34, ptr %110, i32 0, i32 3
  %112 = getelementptr inbounds %struct.arm_2d_region_t, ptr %111, i32 0, i32 1
  %113 = getelementptr inbounds %struct.arm_2d_size_t, ptr %112, i32 0, i32 1
  %114 = load i16, ptr %113, align 2, !tbaa !23
  %115 = sext i16 %114 to i32
  %116 = icmp sgt i32 %115, 0
  br i1 %116, label %117, label %137

117:                                              ; preds = %98
  %118 = load ptr, ptr %3, align 8, !tbaa !5
  %119 = getelementptr inbounds %struct.arm_2d_helper_dirty_region_t, ptr %118, i32 0, i32 0
  %120 = getelementptr inbounds %struct.anon.33, ptr %119, i32 0, i32 2
  %121 = load ptr, ptr %120, align 8, !tbaa !9
  %122 = getelementptr inbounds %struct.arm_2d_helper_dirty_region_item_t, ptr %121, i32 0, i32 0
  %123 = getelementptr inbounds %struct.anon.34, ptr %122, i32 0, i32 3
  %124 = getelementptr inbounds %struct.arm_2d_region_t, ptr %123, i32 0, i32 1
  %125 = getelementptr inbounds %struct.arm_2d_size_t, ptr %124, i32 0, i32 0
  %126 = load i16, ptr %125, align 4, !tbaa !23
  %127 = sext i16 %126 to i32
  %128 = icmp sgt i32 %127, 0
  br i1 %128, label %129, label %137

129:                                              ; preds = %117
  %130 = load ptr, ptr %3, align 8, !tbaa !5
  %131 = getelementptr inbounds %struct.arm_2d_helper_dirty_region_t, ptr %130, i32 0, i32 0
  %132 = getelementptr inbounds %struct.anon.33, ptr %131, i32 0, i32 2
  %133 = load ptr, ptr %132, align 8, !tbaa !9
  %134 = getelementptr inbounds %struct.arm_2d_helper_dirty_region_item_t, ptr %133, i32 0, i32 0
  %135 = getelementptr inbounds %struct.anon.34, ptr %134, i32 0, i32 3
  %136 = call ptr @arm_2d_region_get_minimal_enclosure(ptr noundef %5, ptr noundef %135, ptr noundef %5)
  br label %137

137:                                              ; preds = %129, %117, %98
  %138 = load ptr, ptr %3, align 8, !tbaa !5
  %139 = getelementptr inbounds %struct.arm_2d_helper_dirty_region_t, ptr %138, i32 0, i32 0
  %140 = getelementptr inbounds %struct.anon.33, ptr %139, i32 0, i32 0
  call void @__arm_2d_dynamic_dirty_region_update(ptr noundef %140, ptr noundef null, ptr noundef %5, i8 noundef zeroext 1, i1 noundef zeroext true)
  %141 = load ptr, ptr %3, align 8, !tbaa !5
  %142 = getelementptr inbounds %struct.arm_2d_helper_dirty_region_t, ptr %141, i32 0, i32 0
  %143 = getelementptr inbounds %struct.anon.33, ptr %142, i32 0, i32 2
  %144 = load ptr, ptr %143, align 8, !tbaa !9
  %145 = getelementptr inbounds %struct.arm_2d_helper_dirty_region_item_t, ptr %144, i32 0, i32 0
  %146 = getelementptr inbounds %struct.anon.34, ptr %145, i32 0, i32 0
  %147 = load ptr, ptr %146, align 8, !tbaa !19
  %148 = load ptr, ptr %3, align 8, !tbaa !5
  %149 = getelementptr inbounds %struct.arm_2d_helper_dirty_region_t, ptr %148, i32 0, i32 0
  %150 = getelementptr inbounds %struct.anon.33, ptr %149, i32 0, i32 2
  store ptr %147, ptr %150, align 8, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #6
  br label %162

151:                                              ; preds = %78
  %152 = load ptr, ptr %3, align 8, !tbaa !5
  %153 = getelementptr inbounds %struct.arm_2d_helper_dirty_region_t, ptr %152, i32 0, i32 0
  %154 = getelementptr inbounds %struct.anon.33, ptr %153, i32 0, i32 0
  %155 = load ptr, ptr %3, align 8, !tbaa !5
  %156 = getelementptr inbounds %struct.arm_2d_helper_dirty_region_t, ptr %155, i32 0, i32 0
  %157 = getelementptr inbounds %struct.anon.33, ptr %156, i32 0, i32 2
  %158 = load ptr, ptr %157, align 8, !tbaa !9
  %159 = getelementptr inbounds %struct.arm_2d_helper_dirty_region_item_t, ptr %158, i32 0, i32 0
  %160 = getelementptr inbounds %struct.anon.34, ptr %159, i32 0, i32 2
  %161 = getelementptr inbounds %struct.anon.36, ptr %160, i32 0, i32 1
  call void @__arm_2d_dynamic_dirty_region_update(ptr noundef %154, ptr noundef null, ptr noundef %161, i8 noundef zeroext 2, i1 noundef zeroext true)
  br label %162

162:                                              ; preds = %151, %137
  br label %167

163:                                              ; preds = %21
  %164 = load ptr, ptr %3, align 8, !tbaa !5
  %165 = getelementptr inbounds %struct.arm_2d_helper_dirty_region_t, ptr %164, i32 0, i32 0
  %166 = getelementptr inbounds %struct.anon.33, ptr %165, i32 0, i32 0
  call void @arm_2d_dynamic_dirty_region_change_user_region_index_only(ptr noundef %166, i8 noundef zeroext 3)
  br label %167

167:                                              ; preds = %163, %162
  br label %190

168:                                              ; preds = %15
  %169 = load ptr, ptr %3, align 8, !tbaa !5
  %170 = getelementptr inbounds %struct.arm_2d_helper_dirty_region_t, ptr %169, i32 0, i32 0
  %171 = getelementptr inbounds %struct.anon.33, ptr %170, i32 0, i32 0
  %172 = load ptr, ptr %3, align 8, !tbaa !5
  %173 = getelementptr inbounds %struct.arm_2d_helper_dirty_region_t, ptr %172, i32 0, i32 0
  %174 = getelementptr inbounds %struct.anon.33, ptr %173, i32 0, i32 2
  %175 = load ptr, ptr %174, align 8, !tbaa !9
  %176 = getelementptr inbounds %struct.arm_2d_helper_dirty_region_item_t, ptr %175, i32 0, i32 0
  %177 = getelementptr inbounds %struct.anon.34, ptr %176, i32 0, i32 2
  %178 = getelementptr inbounds %struct.anon.36, ptr %177, i32 0, i32 0
  call void @__arm_2d_dynamic_dirty_region_update(ptr noundef %171, ptr noundef null, ptr noundef %178, i8 noundef zeroext 1, i1 noundef zeroext true)
  %179 = load ptr, ptr %3, align 8, !tbaa !5
  %180 = getelementptr inbounds %struct.arm_2d_helper_dirty_region_t, ptr %179, i32 0, i32 0
  %181 = getelementptr inbounds %struct.anon.33, ptr %180, i32 0, i32 2
  %182 = load ptr, ptr %181, align 8, !tbaa !9
  %183 = getelementptr inbounds %struct.arm_2d_helper_dirty_region_item_t, ptr %182, i32 0, i32 0
  %184 = getelementptr inbounds %struct.anon.34, ptr %183, i32 0, i32 0
  %185 = load ptr, ptr %184, align 8, !tbaa !19
  %186 = load ptr, ptr %3, align 8, !tbaa !5
  %187 = getelementptr inbounds %struct.arm_2d_helper_dirty_region_t, ptr %186, i32 0, i32 0
  %188 = getelementptr inbounds %struct.anon.33, ptr %187, i32 0, i32 2
  store ptr %185, ptr %188, align 8, !tbaa !9
  br label %190

189:                                              ; preds = %15
  br label %190

190:                                              ; preds = %189, %168, %167, %74, %15
  ret void
}

attributes #0 = { noreturn nounwind "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 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { 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 #4 = { "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 = { noreturn nounwind }
attributes #6 = { 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/C++ TBAA"}
!9 = !{!10, !6, i64 40}
!10 = !{!"arm_2d_helper_dirty_region_t", !11, i64 0, !17, i64 56}
!11 = !{!"", !12, i64 0, !6, i64 32, !6, i64 40, !7, i64 48}
!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 = !{!"arm_2d_helper_dirty_region_item_t", !18, i64 0, !14, i64 48}
!18 = !{!"", !6, i64 0, !6, i64 8, !7, i64 16, !14, i64 32, !7, i64 40, !7, i64 40, !7, i64 40, !7, i64 40, !7, i64 41, !16, i64 42}
!19 = !{!17, !6, i64 0}
!20 = distinct !{!20, !21}
!21 = !{!"llvm.loop.mustprogress"}
!22 = !{i64 0, i64 4, !23, i64 4, i64 4, !23}
!23 = !{!7, !7, i64 0}


; 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"

%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 }

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

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

; Function Attrs: nounwind uwtable
declare dso_local zeroext i8 @arm_2d_dynamic_dirty_region_wait_next(ptr noundef nonnull) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare dso_local void @arm_2d_dynamic_dirty_region_change_user_region_index_only(ptr noundef nonnull, i8 noundef zeroext) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare hidden void @__arm_2d_dynamic_dirty_region_update(ptr noundef nonnull, ptr noundef, ptr noundef, i8 noundef zeroext, i1 noundef zeroext) local_unnamed_addr #1

declare ptr @arm_2d_region_get_minimal_enclosure(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
define dso_local void @__arm_2d_helper_dirty_region_update_dirty_regions(ptr noundef nonnull %0, ptr nocapture noundef nonnull readnone %1) local_unnamed_addr #1 {
  %3 = alloca %struct.arm_2d_region_t, align 8
  %4 = tail call zeroext i8 @arm_2d_dynamic_dirty_region_wait_next(ptr noundef %0)
  switch i8 %4, label %45 [
    i8 0, label %5
    i8 1, label %5
    i8 2, label %39
  ]

5:                                                ; preds = %2, %2
  %6 = getelementptr inbounds i8, ptr %0, i64 40
  %7 = load ptr, ptr %6, align 8, !tbaa !5
  %.not = icmp eq ptr %7, null
  br i1 %.not, label %38, label %.preheader

.preheader:                                       ; preds = %5, %11
  %.pr = phi ptr [ %12, %11 ], [ %7, %5 ]
  %8 = getelementptr inbounds i8, ptr %.pr, i64 40
  %9 = load i8, ptr %8, align 8
  %10 = and i8 %9, 6
  %or.cond = icmp eq i8 %10, 0
  br i1 %or.cond, label %13, label %11

11:                                               ; preds = %.preheader
  %12 = load ptr, ptr %.pr, align 8, !tbaa !18
  store ptr %12, ptr %6, align 8, !tbaa !5
  %.not29 = icmp eq ptr %12, null
  br i1 %.not29, label %.thread, label %.preheader, !llvm.loop !19

.thread:                                          ; preds = %11
  tail call void @arm_2d_dynamic_dirty_region_change_user_region_index_only(ptr noundef %0, i8 noundef zeroext 3)
  br label %45

13:                                               ; preds = %.preheader
  %14 = getelementptr inbounds i8, ptr %.pr, i64 40
  %15 = or disjoint i8 %9, 4
  store i8 %15, ptr %14, align 8
  %16 = load ptr, ptr %6, align 8, !tbaa !5
  %17 = getelementptr inbounds i8, ptr %16, i64 40
  %18 = load i8, ptr %17, align 8
  %19 = and i8 %18, 8
  %.not30 = icmp eq i8 %19, 0
  br i1 %.not30, label %36, label %20

20:                                               ; preds = %13
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %3) #3
  %21 = getelementptr inbounds i8, ptr %16, i64 24
  %22 = load i64, ptr %21, align 8
  store i64 %22, ptr %3, align 8
  %23 = getelementptr inbounds i8, ptr %16, i64 32
  %24 = getelementptr inbounds i8, ptr %16, i64 38
  %25 = load i16, ptr %24, align 2, !tbaa !21
  %26 = icmp sgt i16 %25, 0
  br i1 %26, label %27, label %33

27:                                               ; preds = %20
  %28 = getelementptr inbounds i8, ptr %16, i64 36
  %29 = load i16, ptr %28, align 4, !tbaa !21
  %30 = icmp sgt i16 %29, 0
  br i1 %30, label %31, label %33

31:                                               ; preds = %27
  %32 = call ptr @arm_2d_region_get_minimal_enclosure(ptr noundef nonnull %3, ptr noundef nonnull %23, ptr noundef nonnull %3) #3
  br label %33

33:                                               ; preds = %31, %27, %20
  call void @__arm_2d_dynamic_dirty_region_update(ptr noundef %0, ptr noundef null, ptr noundef nonnull %3, i8 noundef zeroext 1, i1 noundef zeroext true)
  %34 = load ptr, ptr %6, align 8, !tbaa !5
  %35 = load ptr, ptr %34, align 8, !tbaa !18
  store ptr %35, ptr %6, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #3
  br label %45

36:                                               ; preds = %13
  %37 = getelementptr inbounds i8, ptr %16, i64 24
  tail call void @__arm_2d_dynamic_dirty_region_update(ptr noundef %0, ptr noundef null, ptr noundef nonnull %37, i8 noundef zeroext 2, i1 noundef zeroext true)
  br label %45

38:                                               ; preds = %5
  tail call void @arm_2d_dynamic_dirty_region_change_user_region_index_only(ptr noundef %0, i8 noundef zeroext 3)
  br label %45

39:                                               ; preds = %2
  %40 = getelementptr inbounds i8, ptr %0, i64 40
  %41 = load ptr, ptr %40, align 8, !tbaa !5
  %42 = getelementptr inbounds i8, ptr %41, i64 16
  tail call void @__arm_2d_dynamic_dirty_region_update(ptr noundef %0, ptr noundef null, ptr noundef nonnull %42, i8 noundef zeroext 1, i1 noundef zeroext true)
  %43 = load ptr, ptr %40, align 8, !tbaa !5
  %44 = load ptr, ptr %43, align 8, !tbaa !18
  store ptr %44, ptr %40, align 8, !tbaa !5
  br label %45

45:                                               ; preds = %2, %38, %36, %33, %39, %.thread
  ret void
}

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 = { 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, !9, i64 40}
!6 = !{!"arm_2d_helper_dirty_region_t", !7, i64 0, !16, i64 56}
!7 = !{!"", !8, i64 0, !9, i64 32, !9, i64 40, !10, i64 48}
!8 = !{!"arm_2d_region_list_item_t", !9, i64 0, !12, i64 8, !13, i64 16, !14, i64 24}
!9 = !{!"any pointer", !10, i64 0}
!10 = !{!"omnipotent char", !11, i64 0}
!11 = !{!"Simple C/C++ TBAA"}
!12 = !{!"", !9, i64 0}
!13 = !{!"arm_2d_region_t", !10, i64 0, !10, i64 4}
!14 = !{!"", !10, i64 0, !10, i64 1, !10, i64 1, !15, i64 2, !15, i64 2, !15, i64 2, !15, i64 2}
!15 = !{!"short", !10, i64 0}
!16 = !{!"arm_2d_helper_dirty_region_item_t", !17, i64 0, !13, i64 48}
!17 = !{!"", !9, i64 0, !9, i64 8, !10, i64 16, !13, i64 32, !10, i64 40, !10, i64 40, !10, i64 40, !10, i64 40, !10, i64 41, !15, i64 42}
!18 = !{!16, !9, i64 0}
!19 = distinct !{!19, !20}
!20 = !{!"llvm.loop.mustprogress"}
!21 = !{!10, !10, i64 0}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SCCPPass,SROAPass,SimplifyCFGPass,TailCallElimPass