; 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_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.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 }
%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] }

@.str = external hidden unnamed_addr constant [15 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [87 x i8], align 1
@__PRETTY_FUNCTION__.arm_2d_helper_dirty_region_depose = external hidden unnamed_addr constant [101 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: nounwind uwtable
declare dso_local zeroext i1 @arm_2d_helper_pfb_remove_dirty_regions_from_list(ptr noundef nonnull, ptr noundef nonnull, i64 noundef) #2

; Function Attrs: nounwind uwtable
declare dso_local void @arm_2d_dynamic_dirty_region_depose(ptr noundef nonnull) #2

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

6:                                                ; preds = %1
  br label %8

7:                                                ; preds = %1
  call void @__assert_fail(ptr noundef @.str, ptr noundef @.str.1, i32 noundef 4433, ptr noundef @__PRETTY_FUNCTION__.arm_2d_helper_dirty_region_depose) #3
  unreachable

8:                                                ; preds = %6
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #4
  %9 = load ptr, ptr %2, align 8, !tbaa !5
  %10 = getelementptr inbounds %struct.arm_2d_helper_dirty_region_t, ptr %9, i32 0, i32 0
  %11 = getelementptr inbounds %struct.anon.33, ptr %10, i32 0, i32 1
  %12 = load ptr, ptr %11, align 8, !tbaa !9
  store ptr %12, ptr %3, align 8, !tbaa !5
  %13 = load ptr, ptr %3, align 8, !tbaa !5
  %14 = icmp ne ptr null, %13
  br i1 %14, label %15, label %21

15:                                               ; preds = %8
  %16 = load ptr, ptr %3, align 8, !tbaa !5
  %17 = load ptr, ptr %2, align 8, !tbaa !5
  %18 = getelementptr inbounds %struct.arm_2d_helper_dirty_region_t, ptr %17, i32 0, i32 0
  %19 = getelementptr inbounds %struct.anon.33, ptr %18, i32 0, i32 0
  %20 = call zeroext i1 @arm_2d_helper_pfb_remove_dirty_regions_from_list(ptr noundef %16, ptr noundef %19, i64 noundef 1)
  br label %21

21:                                               ; preds = %15, %8
  %22 = load ptr, ptr %2, 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 0
  call void @arm_2d_dynamic_dirty_region_depose(ptr noundef %24)
  %25 = load ptr, ptr %2, align 8, !tbaa !5
  %26 = getelementptr inbounds %struct.arm_2d_helper_dirty_region_t, ptr %25, i32 0, i32 1
  %27 = getelementptr inbounds %struct.arm_2d_helper_dirty_region_item_t, ptr %26, i32 0, i32 0
  %28 = getelementptr inbounds %struct.anon.34, ptr %27, i32 0, i32 0
  %29 = load ptr, ptr %28, align 8, !tbaa !19
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #4
  ret ptr %29
}

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 = { 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 #3 = { noreturn nounwind }
attributes #4 = { 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 32}
!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 = !{!10, !6, i64 56}


; 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: nounwind uwtable
declare dso_local zeroext i1 @arm_2d_helper_pfb_remove_dirty_regions_from_list(ptr noundef nonnull, ptr noundef nonnull, i64 noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare dso_local void @arm_2d_dynamic_dirty_region_depose(ptr noundef nonnull) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local ptr @arm_2d_helper_dirty_region_depose(ptr noundef nonnull %0) local_unnamed_addr #0 {
  %2 = getelementptr inbounds i8, ptr %0, i64 32
  %3 = load ptr, ptr %2, align 8, !tbaa !5
  %.not = icmp eq ptr %3, null
  br i1 %.not, label %6, label %4

4:                                                ; preds = %1
  %5 = tail call zeroext i1 @arm_2d_helper_pfb_remove_dirty_regions_from_list(ptr noundef %3, ptr noundef %0, i64 noundef 1)
  br label %6

6:                                                ; preds = %4, %1
  tail call void @arm_2d_dynamic_dirty_region_depose(ptr noundef %0)
  %7 = getelementptr inbounds i8, ptr %0, i64 56
  %8 = load ptr, ptr %7, align 8, !tbaa !18
  ret ptr %8
}

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, !9, i64 32}
!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 = !{!6, !9, i64 56}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,SROAPass,SimplifyCFGPass,TailCallElimPass