; 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_init = external hidden unnamed_addr constant [99 x i8], align 1
@.str.19 = external hidden unnamed_addr constant [26 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 nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #1

; Function Attrs: nounwind uwtable
declare dso_local zeroext i1 @arm_2d_helper_pfb_append_dirty_regions_to_list(ptr noundef nonnull, ptr noundef nonnull, i64 noundef) #2

; Function Attrs: nounwind uwtable
declare dso_local ptr @arm_2d_dynamic_dirty_region_init(ptr noundef) #2

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

7:                                                ; preds = %2
  br label %9

8:                                                ; preds = %2
  call void @__assert_fail(ptr noundef @.str, ptr noundef @.str.1, i32 noundef 4341, ptr noundef @__PRETTY_FUNCTION__.arm_2d_helper_dirty_region_init) #3
  unreachable

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

12:                                               ; preds = %9
  br label %14

13:                                               ; preds = %9
  call void @__assert_fail(ptr noundef @.str.19, ptr noundef @.str.1, i32 noundef 4342, ptr noundef @__PRETTY_FUNCTION__.arm_2d_helper_dirty_region_init) #3
  unreachable

14:                                               ; preds = %12
  %15 = load ptr, ptr %3, align 8, !tbaa !5
  call void @llvm.memset.p0.i64(ptr align 8 %15, i8 0, i64 112, i1 false)
  %16 = load ptr, ptr %4, align 8, !tbaa !5
  %17 = load ptr, ptr %3, 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 1
  store ptr %16, ptr %19, align 8, !tbaa !9
  %20 = load ptr, ptr %3, align 8, !tbaa !5
  %21 = getelementptr inbounds %struct.arm_2d_helper_dirty_region_t, ptr %20, i32 0, i32 0
  %22 = getelementptr inbounds %struct.anon.33, ptr %21, i32 0, i32 0
  %23 = call ptr @arm_2d_dynamic_dirty_region_init(ptr noundef %22)
  %24 = load ptr, ptr %3, align 8, !tbaa !5
  %25 = getelementptr inbounds %struct.arm_2d_helper_dirty_region_t, ptr %24, i32 0, i32 1
  %26 = getelementptr inbounds %struct.arm_2d_helper_dirty_region_item_t, ptr %25, i32 0, i32 0
  %27 = getelementptr inbounds %struct.anon.34, ptr %26, i32 0, i32 4
  %28 = load i8, ptr %27, align 8
  %29 = and i8 %28, -5
  %30 = or i8 %29, 4
  store i8 %30, ptr %27, align 8
  %31 = load ptr, ptr %3, align 8, !tbaa !5
  %32 = load ptr, ptr %3, align 8, !tbaa !5
  %33 = getelementptr inbounds %struct.arm_2d_helper_dirty_region_t, ptr %32, i32 0, i32 1
  %34 = getelementptr inbounds %struct.arm_2d_helper_dirty_region_item_t, ptr %33, i32 0, i32 0
  %35 = getelementptr inbounds %struct.anon.34, ptr %34, i32 0, i32 1
  store ptr %31, ptr %35, align 8, !tbaa !19
  %36 = load ptr, ptr %3, align 8, !tbaa !5
  %37 = getelementptr inbounds %struct.arm_2d_helper_dirty_region_t, ptr %36, i32 0, i32 1
  %38 = getelementptr inbounds %struct.arm_2d_helper_dirty_region_item_t, ptr %37, i32 0, i32 0
  %39 = getelementptr inbounds %struct.anon.34, ptr %38, i32 0, i32 6
  store i16 -13570, ptr %39, align 2, !tbaa !20
  %40 = load ptr, ptr %4, align 8, !tbaa !5
  %41 = load ptr, ptr %3, align 8, !tbaa !5
  %42 = getelementptr inbounds %struct.arm_2d_helper_dirty_region_t, ptr %41, i32 0, i32 0
  %43 = getelementptr inbounds %struct.anon.33, ptr %42, i32 0, i32 0
  %44 = call zeroext i1 @arm_2d_helper_pfb_append_dirty_regions_to_list(ptr noundef %40, ptr noundef %43, i64 noundef 1)
  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 nounwind willreturn memory(argmem: write) }
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 }

!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 64}
!20 = !{!10, !16, i64 98}


; 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 nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #0

; Function Attrs: nounwind uwtable
declare dso_local zeroext i1 @arm_2d_helper_pfb_append_dirty_regions_to_list(ptr noundef nonnull, ptr noundef nonnull, i64 noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare dso_local ptr @arm_2d_dynamic_dirty_region_init(ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local void @arm_2d_helper_dirty_region_init(ptr noundef nonnull %0, ptr noundef nonnull %1) local_unnamed_addr #1 {
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(112) %0, i8 0, i64 112, i1 false)
  %3 = getelementptr inbounds i8, ptr %0, i64 32
  store ptr %1, ptr %3, align 8, !tbaa !5
  %4 = tail call ptr @arm_2d_dynamic_dirty_region_init(ptr noundef nonnull %0)
  %5 = getelementptr inbounds i8, ptr %0, i64 96
  %6 = load i8, ptr %5, align 8
  %7 = or i8 %6, 4
  store i8 %7, ptr %5, align 8
  %8 = getelementptr inbounds i8, ptr %0, i64 64
  store ptr %0, ptr %8, align 8, !tbaa !18
  %9 = getelementptr inbounds i8, ptr %0, i64 98
  store i16 -13570, ptr %9, align 2, !tbaa !19
  %10 = tail call zeroext i1 @arm_2d_helper_pfb_append_dirty_regions_to_list(ptr noundef %1, ptr noundef %0, i64 noundef 1)
  ret void
}

attributes #0 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: write) }
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" }

!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 64}
!19 = !{!6, !15, i64 98}


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