; 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_size_t = type { i16, i16 }
%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_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_item_set_extra_region = external hidden unnamed_addr constant [164 x i8], align 1
@.str.20 = external hidden unnamed_addr constant [21 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 i32 @arm_2d_helper_pfb_get_absolute_location(ptr noundef nonnull, i32) #3

; Function Attrs: nounwind uwtable
define dso_local void @arm_2d_helper_dirty_region_item_set_extra_region(ptr noundef nonnull %0, ptr noundef nonnull %1, ptr noundef %2, ptr noundef %3) #3 {
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca %struct.arm_2d_size_t, align 2
  %10 = alloca %struct.arm_2d_region_t, align 2
  %11 = alloca %struct.arm_2d_location_t, align 2
  %12 = alloca %struct.arm_2d_region_t, align 2
  %13 = alloca %struct.arm_2d_location_t, align 2
  %14 = alloca i32, align 4
  store ptr %0, ptr %5, align 8, !tbaa !5
  store ptr %1, ptr %6, align 8, !tbaa !5
  store ptr %2, ptr %7, align 8, !tbaa !5
  store ptr %3, ptr %8, align 8, !tbaa !5
  %15 = load ptr, ptr %5, align 8, !tbaa !5
  %16 = icmp ne ptr null, %15
  br i1 %16, label %17, label %18

17:                                               ; preds = %4
  br label %19

18:                                               ; preds = %4
  call void @__assert_fail(ptr noundef @.str, ptr noundef @.str.1, i32 noundef 4467, ptr noundef @__PRETTY_FUNCTION__.arm_2d_helper_dirty_region_item_set_extra_region) #5
  unreachable

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

22:                                               ; preds = %19
  br label %24

23:                                               ; preds = %19
  call void @__assert_fail(ptr noundef @.str.20, ptr noundef @.str.1, i32 noundef 4468, ptr noundef @__PRETTY_FUNCTION__.arm_2d_helper_dirty_region_item_set_extra_region) #5
  unreachable

24:                                               ; preds = %22
  %25 = load ptr, ptr %5, align 8, !tbaa !5
  %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 3
  %28 = getelementptr inbounds %struct.arm_2d_region_t, ptr %27, i32 0, i32 1
  %29 = getelementptr inbounds %struct.arm_2d_size_t, ptr %9, i32 0, i32 0
  store i16 0, ptr %29, align 2, !tbaa !9
  %30 = getelementptr inbounds %struct.arm_2d_size_t, ptr %9, i32 0, i32 1
  store i16 0, ptr %30, align 2, !tbaa !12
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %28, ptr align 2 %9, i64 4, i1 false), !tbaa.struct !13
  %31 = load ptr, ptr %8, align 8, !tbaa !5
  %32 = icmp eq ptr null, %31
  br i1 %32, label %33, label %34

33:                                               ; preds = %24
  br label %63

34:                                               ; preds = %24
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #6
  %35 = load ptr, ptr %8, align 8, !tbaa !5
  call void @llvm.memcpy.p0.p0.i64(ptr align 2 %10, ptr align 2 %35, i64 8, i1 false), !tbaa.struct !15
  br label %36

36:                                               ; preds = %34
  %37 = getelementptr inbounds %struct.arm_2d_region_t, ptr %10, i32 0, i32 0
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #6
  %38 = load ptr, ptr %6, align 8, !tbaa !5
  %39 = getelementptr inbounds %struct.arm_2d_region_t, ptr %10, i32 0, i32 0
  %40 = load i32, ptr %39, align 2
  %41 = call i32 @arm_2d_helper_pfb_get_absolute_location(ptr noundef %38, i32 %40)
  store i32 %41, ptr %11, align 2
  call void @llvm.memcpy.p0.p0.i64(ptr align 2 %37, ptr align 2 %11, i64 4, i1 false), !tbaa.struct !13
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #6
  %42 = load ptr, ptr %7, align 8, !tbaa !5
  %43 = icmp ne ptr null, %42
  br i1 %43, label %44, label %57

44:                                               ; preds = %36
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #6
  %45 = load ptr, ptr %7, align 8, !tbaa !5
  call void @llvm.memcpy.p0.p0.i64(ptr align 2 %12, ptr align 2 %45, i64 8, i1 false), !tbaa.struct !15
  %46 = getelementptr inbounds %struct.arm_2d_region_t, ptr %12, i32 0, i32 0
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #6
  %47 = load ptr, ptr %6, align 8, !tbaa !5
  %48 = getelementptr inbounds %struct.arm_2d_region_t, ptr %12, i32 0, i32 0
  %49 = load i32, ptr %48, align 2
  %50 = call i32 @arm_2d_helper_pfb_get_absolute_location(ptr noundef %47, i32 %49)
  store i32 %50, ptr %13, align 2
  call void @llvm.memcpy.p0.p0.i64(ptr align 2 %46, ptr align 2 %13, i64 4, i1 false), !tbaa.struct !13
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #6
  %51 = call zeroext i1 @arm_2d_region_intersect(ptr noundef %10, ptr noundef %12, ptr noundef %10)
  br i1 %51, label %53, label %52

52:                                               ; preds = %44
  store i32 2, ptr %14, align 4
  br label %54

53:                                               ; preds = %44
  store i32 0, ptr %14, align 4
  br label %54

54:                                               ; preds = %53, %52
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #6
  %55 = load i32, ptr %14, align 4
  switch i32 %55, label %64 [
    i32 0, label %56
    i32 2, label %62
  ]

56:                                               ; preds = %54
  br label %57

57:                                               ; preds = %56, %36
  %58 = load ptr, ptr %5, align 8, !tbaa !5
  %59 = getelementptr inbounds %struct.arm_2d_helper_dirty_region_item_t, ptr %58, i32 0, i32 0
  %60 = getelementptr inbounds %struct.anon.34, ptr %59, i32 0, i32 3
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %60, ptr align 2 %10, i64 8, i1 false), !tbaa.struct !15
  br label %61

61:                                               ; preds = %57
  br label %62

62:                                               ; preds = %61, %54
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #6
  br label %63

63:                                               ; preds = %62, %33
  ret void

64:                                               ; preds = %54
  unreachable
}

declare zeroext i1 @arm_2d_region_intersect(ptr noundef, ptr noundef, ptr noundef) #4

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, !11, i64 0}
!10 = !{!"arm_2d_size_t", !11, i64 0, !11, i64 2}
!11 = !{!"short", !7, i64 0}
!12 = !{!10, !11, i64 2}
!13 = !{i64 0, i64 2, !14, i64 2, i64 2, !14}
!14 = !{!11, !11, i64 0}
!15 = !{i64 0, i64 4, !16, i64 4, i64 4, !16}
!16 = !{!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 i32 @arm_2d_helper_pfb_get_absolute_location(ptr noundef nonnull, i32) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local void @arm_2d_helper_dirty_region_item_set_extra_region(ptr nocapture noundef nonnull writeonly %0, ptr noundef nonnull %1, ptr noundef readonly %2, ptr noundef readonly %3) local_unnamed_addr #1 {
  %5 = alloca %struct.arm_2d_region_t, align 8
  %6 = alloca %struct.arm_2d_region_t, align 8
  %7 = getelementptr inbounds i8, ptr %0, i64 32
  %8 = getelementptr inbounds i8, ptr %0, i64 36
  store i16 0, ptr %8, align 4, !tbaa !5
  %.sroa.2.0..sroa_idx = getelementptr inbounds i8, ptr %0, i64 38
  store i16 0, ptr %.sroa.2.0..sroa_idx, align 2, !tbaa !5
  %9 = icmp eq ptr %3, null
  br i1 %9, label %22, label %10

10:                                               ; preds = %4
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %5) #3
  %11 = load i64, ptr %3, align 2
  store i64 %11, ptr %5, align 8
  %12 = trunc i64 %11 to i32
  %13 = tail call i32 @arm_2d_helper_pfb_get_absolute_location(ptr noundef %1, i32 %12)
  store i32 %13, ptr %5, align 8
  %.not = icmp eq ptr %2, null
  br i1 %.not, label %19, label %14

14:                                               ; preds = %10
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %6) #3
  %15 = load i64, ptr %2, align 2
  store i64 %15, ptr %6, align 8
  %16 = trunc i64 %15 to i32
  %17 = tail call i32 @arm_2d_helper_pfb_get_absolute_location(ptr noundef %1, i32 %16)
  store i32 %17, ptr %6, align 8
  %18 = call zeroext i1 @arm_2d_region_intersect(ptr noundef nonnull %5, ptr noundef nonnull %6, ptr noundef nonnull %5) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %6) #3
  br i1 %18, label %19, label %21

19:                                               ; preds = %14, %10
  %20 = load i64, ptr %5, align 8
  store i64 %20, ptr %7, align 8
  br label %21

21:                                               ; preds = %14, %19
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %5) #3
  br label %22

22:                                               ; preds = %4, %21
  ret void
}

declare zeroext i1 @arm_2d_region_intersect(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #2

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, !6, i64 0}
!6 = !{!"short", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}


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