; 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_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_transform_t = type { float, %union.anon.38, float, %struct.arm_2d_helper_dirty_region_item_t, %struct.anon.39 }
%union.anon.38 = type { float }
%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.39 = type { ptr, ptr, %struct.anon.40, %struct.anon.41, %struct.anon.42, i8 }
%struct.anon.40 = type { float, float }
%struct.anon.41 = type { float, float }
%struct.anon.42 = type { float, float }
%struct.arm_2d_op_t = type { %struct.arm_2d_op_core_t, %struct.anon.43 }
%struct.arm_2d_op_core_t = type { [40 x i8], i64 }
%struct.anon.43 = type { ptr, ptr }
%struct.arm_2d_tile_t = type { %union.anon.8, %union.anon.19, %union.anon.20 }
%union.anon.8 = type { %struct.anon.9 }
%struct.anon.9 = type { i8, %union.arm_2d_color_info_t, %union.anon.12 }
%union.arm_2d_color_info_t = type { %struct.anon.10 }
%struct.anon.10 = type { i8 }
%union.anon.12 = type { i16 }
%union.anon.19 = type { %struct.arm_2d_region_t }
%union.anon.20 = type { ptr }

@.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_transform_update = external hidden unnamed_addr constant [123 x i8], align 1
@.str.23 = external hidden unnamed_addr constant [27 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 void @__arm_2d_helper_dirty_region_item_update(ptr noundef nonnull, ptr noundef nonnull, ptr noundef, ptr noundef) #3

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

13:                                               ; preds = %3
  br label %15

14:                                               ; preds = %3
  call void @__assert_fail(ptr noundef @.str, ptr noundef @.str.1, i32 noundef 4838, ptr noundef @__PRETTY_FUNCTION__.arm_2d_helper_dirty_region_transform_update) #4
  unreachable

15:                                               ; preds = %13
  %16 = load ptr, ptr %5, align 8, !tbaa !5
  %17 = load i8, ptr %6, align 1, !tbaa !9, !range !11, !noundef !12
  %18 = trunc i8 %17 to i1
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #5
  %19 = load ptr, ptr %4, align 8, !tbaa !5
  %20 = getelementptr inbounds %struct.arm_2d_helper_dirty_region_transform_t, ptr %19, i32 0, i32 4
  %21 = getelementptr inbounds %struct.anon.39, ptr %20, i32 0, i32 0
  %22 = load ptr, ptr %21, align 8, !tbaa !13
  %23 = getelementptr inbounds %struct.arm_2d_op_t, ptr %22, i32 0, i32 1
  %24 = getelementptr inbounds %struct.anon.43, ptr %23, i32 0, i32 0
  %25 = load ptr, ptr %24, align 8, !tbaa !22
  store ptr %25, ptr %7, align 8, !tbaa !5
  %26 = load ptr, ptr %7, align 8, !tbaa !5
  %27 = icmp eq ptr null, %26
  br i1 %27, label %28, label %29

28:                                               ; preds = %15
  store i32 1, ptr %8, align 4
  br label %87

29:                                               ; preds = %15
  %30 = load ptr, ptr %7, align 8, !tbaa !5
  %31 = getelementptr inbounds %struct.arm_2d_tile_t, ptr %30, i32 0, i32 2
  %32 = load ptr, ptr %31, align 8, !tbaa !27
  %33 = icmp ne ptr null, %32
  br i1 %33, label %34, label %35

34:                                               ; preds = %29
  br label %36

35:                                               ; preds = %29
  call void @__assert_fail(ptr noundef @.str.23, ptr noundef @.str.1, i32 noundef 4847, ptr noundef @__PRETTY_FUNCTION__.arm_2d_helper_dirty_region_transform_update) #4
  unreachable

36:                                               ; preds = %34
  %37 = load ptr, ptr %5, align 8, !tbaa !5
  %38 = icmp ne ptr null, %37
  br i1 %38, label %39, label %75

39:                                               ; preds = %36
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #5
  %40 = load ptr, ptr %5, align 8, !tbaa !5
  call void @llvm.memcpy.p0.p0.i64(ptr align 2 %9, ptr align 2 %40, i64 8, i1 false), !tbaa.struct !28
  %41 = load ptr, ptr %7, align 8, !tbaa !5
  %42 = getelementptr inbounds %struct.arm_2d_tile_t, ptr %41, i32 0, i32 1
  %43 = getelementptr inbounds %struct.arm_2d_region_t, ptr %42, i32 0, i32 0
  %44 = getelementptr inbounds %struct.arm_2d_location_t, ptr %43, i32 0, i32 0
  %45 = load i16, ptr %44, align 4, !tbaa !27
  %46 = sext i16 %45 to i32
  %47 = getelementptr inbounds %struct.arm_2d_region_t, ptr %9, i32 0, i32 0
  %48 = getelementptr inbounds %struct.arm_2d_location_t, ptr %47, i32 0, i32 0
  %49 = load i16, ptr %48, align 2, !tbaa !27
  %50 = sext i16 %49 to i32
  %51 = sub nsw i32 %50, %46
  %52 = trunc i32 %51 to i16
  store i16 %52, ptr %48, align 2, !tbaa !27
  %53 = load ptr, ptr %7, align 8, !tbaa !5
  %54 = getelementptr inbounds %struct.arm_2d_tile_t, ptr %53, i32 0, i32 1
  %55 = getelementptr inbounds %struct.arm_2d_region_t, ptr %54, i32 0, i32 0
  %56 = getelementptr inbounds %struct.arm_2d_location_t, ptr %55, i32 0, i32 1
  %57 = load i16, ptr %56, align 2, !tbaa !27
  %58 = sext i16 %57 to i32
  %59 = getelementptr inbounds %struct.arm_2d_region_t, ptr %9, i32 0, i32 0
  %60 = getelementptr inbounds %struct.arm_2d_location_t, ptr %59, i32 0, i32 1
  %61 = load i16, ptr %60, align 2, !tbaa !27
  %62 = sext i16 %61 to i32
  %63 = sub nsw i32 %62, %58
  %64 = trunc i32 %63 to i16
  store i16 %64, ptr %60, align 2, !tbaa !27
  %65 = load ptr, ptr %4, align 8, !tbaa !5
  %66 = getelementptr inbounds %struct.arm_2d_helper_dirty_region_transform_t, ptr %65, i32 0, i32 3
  %67 = load ptr, ptr %7, align 8, !tbaa !5
  %68 = load ptr, ptr %4, align 8, !tbaa !5
  %69 = getelementptr inbounds %struct.arm_2d_helper_dirty_region_transform_t, ptr %68, i32 0, i32 4
  %70 = getelementptr inbounds %struct.anon.39, ptr %69, i32 0, i32 0
  %71 = load ptr, ptr %70, align 8, !tbaa !13
  %72 = getelementptr inbounds %struct.arm_2d_op_t, ptr %71, i32 0, i32 1
  %73 = getelementptr inbounds %struct.anon.43, ptr %72, i32 0, i32 1
  %74 = load ptr, ptr %73, align 8, !tbaa !29
  call void @__arm_2d_helper_dirty_region_item_update(ptr noundef %66, ptr noundef %67, ptr noundef %9, ptr noundef %74)
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #5
  br label %86

75:                                               ; preds = %36
  %76 = load ptr, ptr %4, align 8, !tbaa !5
  %77 = getelementptr inbounds %struct.arm_2d_helper_dirty_region_transform_t, ptr %76, i32 0, i32 3
  %78 = load ptr, ptr %7, align 8, !tbaa !5
  %79 = load ptr, ptr %4, align 8, !tbaa !5
  %80 = getelementptr inbounds %struct.arm_2d_helper_dirty_region_transform_t, ptr %79, i32 0, i32 4
  %81 = getelementptr inbounds %struct.anon.39, ptr %80, i32 0, i32 0
  %82 = load ptr, ptr %81, align 8, !tbaa !13
  %83 = getelementptr inbounds %struct.arm_2d_op_t, ptr %82, i32 0, i32 1
  %84 = getelementptr inbounds %struct.anon.43, ptr %83, i32 0, i32 1
  %85 = load ptr, ptr %84, align 8, !tbaa !29
  call void @__arm_2d_helper_dirty_region_item_update(ptr noundef %77, ptr noundef %78, ptr noundef null, ptr noundef %85)
  br label %86

86:                                               ; preds = %75, %39
  store i32 0, ptr %8, align 4
  br label %87

87:                                               ; preds = %86, %28
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #5
  %88 = load i32, ptr %8, align 4
  switch i32 %88, label %90 [
    i32 0, label %89
    i32 1, label %89
  ]

89:                                               ; preds = %87, %87
  ret void

90:                                               ; preds = %87
  unreachable
}

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 = { noreturn nounwind }
attributes #5 = { 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, !10, i64 0}
!10 = !{!"_Bool", !7, i64 0}
!11 = !{i8 0, i8 2}
!12 = !{}
!13 = !{!14, !6, i64 72}
!14 = !{!"arm_2d_helper_dirty_region_transform_t", !15, i64 0, !7, i64 4, !15, i64 8, !16, i64 16, !20, i64 72}
!15 = !{!"float", !7, i64 0}
!16 = !{!"arm_2d_helper_dirty_region_item_t", !17, i64 0, !18, i64 48}
!17 = !{!"", !6, i64 0, !6, i64 8, !7, i64 16, !18, i64 32, !7, i64 40, !7, i64 40, !7, i64 40, !7, i64 40, !7, i64 41, !19, i64 42}
!18 = !{!"arm_2d_region_t", !7, i64 0, !7, i64 4}
!19 = !{!"short", !7, i64 0}
!20 = !{!"", !6, i64 0, !6, i64 8, !21, i64 16, !21, i64 24, !21, i64 32, !10, i64 40}
!21 = !{!"", !15, i64 0, !15, i64 4}
!22 = !{!23, !6, i64 48}
!23 = !{!"arm_2d_op_t", !24, i64 0, !26, i64 48}
!24 = !{!"arm_2d_op_core_t", !7, i64 0, !25, i64 40}
!25 = !{!"long", !7, i64 0}
!26 = !{!"", !6, i64 0, !6, i64 8}
!27 = !{!7, !7, i64 0}
!28 = !{i64 0, i64 4, !27, i64 4, i64 4, !27}
!29 = !{!23, !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"

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

@.str.1 = external hidden unnamed_addr constant [87 x i8], align 1
@__PRETTY_FUNCTION__.arm_2d_helper_dirty_region_transform_update = external hidden unnamed_addr constant [123 x i8], align 1
@.str.23 = external hidden unnamed_addr constant [27 x i8], align 1

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

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

; Function Attrs: mustprogress 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 void @__arm_2d_helper_dirty_region_item_update(ptr noundef nonnull, ptr noundef nonnull, ptr noundef, ptr noundef) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
define dso_local void @arm_2d_helper_dirty_region_transform_update(ptr noundef nonnull %0, ptr noundef readonly %1, i1 noundef zeroext %2) local_unnamed_addr #2 {
  %4 = alloca %struct.arm_2d_region_t, align 8
  %5 = getelementptr inbounds i8, ptr %0, i64 72
  %6 = load ptr, ptr %5, align 8, !tbaa !5
  %7 = getelementptr inbounds i8, ptr %6, i64 48
  %8 = load ptr, ptr %7, align 8, !tbaa !18
  %9 = icmp eq ptr %8, null
  br i1 %9, label %32, label %10

10:                                               ; preds = %3
  %11 = getelementptr inbounds i8, ptr %8, i64 16
  %12 = load ptr, ptr %11, align 8, !tbaa !23
  %.not = icmp eq ptr %12, null
  br i1 %.not, label %13, label %14

13:                                               ; preds = %10
  tail call void @__assert_fail(ptr noundef nonnull @.str.23, ptr noundef nonnull @.str.1, i32 noundef 4847, ptr noundef nonnull @__PRETTY_FUNCTION__.arm_2d_helper_dirty_region_transform_update) #3
  unreachable

14:                                               ; preds = %10
  %.not16 = icmp eq ptr %1, null
  br i1 %.not16, label %28, label %15

15:                                               ; preds = %14
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %4) #4
  %16 = load i64, ptr %1, align 2
  store i64 %16, ptr %4, align 8
  %17 = getelementptr inbounds i8, ptr %8, i64 4
  %18 = lshr i64 %16, 16
  %19 = load <2 x i16>, ptr %17, align 4, !tbaa !23
  %20 = trunc i64 %16 to i16
  %21 = insertelement <2 x i16> poison, i16 %20, i64 0
  %22 = trunc i64 %18 to i16
  %23 = insertelement <2 x i16> %21, i16 %22, i64 1
  %24 = sub <2 x i16> %23, %19
  store <2 x i16> %24, ptr %4, align 8, !tbaa !23
  %25 = getelementptr inbounds i8, ptr %0, i64 16
  %26 = getelementptr inbounds i8, ptr %6, i64 56
  %27 = load ptr, ptr %26, align 8, !tbaa !24
  call void @__arm_2d_helper_dirty_region_item_update(ptr noundef %25, ptr noundef %8, ptr noundef nonnull %4, ptr noundef %27)
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %4) #4
  br label %32

28:                                               ; preds = %14
  %29 = getelementptr inbounds i8, ptr %0, i64 16
  %30 = getelementptr inbounds i8, ptr %6, i64 56
  %31 = load ptr, ptr %30, align 8, !tbaa !24
  tail call void @__arm_2d_helper_dirty_region_item_update(ptr noundef %29, ptr noundef %8, ptr noundef null, ptr noundef %31)
  br label %32

32:                                               ; preds = %15, %28, %3
  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 = { mustprogress 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, !12, i64 72}
!6 = !{!"arm_2d_helper_dirty_region_transform_t", !7, i64 0, !8, i64 4, !7, i64 8, !10, i64 16, !15, i64 72}
!7 = !{!"float", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"arm_2d_helper_dirty_region_item_t", !11, i64 0, !13, i64 48}
!11 = !{!"", !12, i64 0, !12, i64 8, !8, i64 16, !13, i64 32, !8, i64 40, !8, i64 40, !8, i64 40, !8, i64 40, !8, i64 41, !14, i64 42}
!12 = !{!"any pointer", !8, i64 0}
!13 = !{!"arm_2d_region_t", !8, i64 0, !8, i64 4}
!14 = !{!"short", !8, i64 0}
!15 = !{!"", !12, i64 0, !12, i64 8, !16, i64 16, !16, i64 24, !16, i64 32, !17, i64 40}
!16 = !{!"", !7, i64 0, !7, i64 4}
!17 = !{!"_Bool", !8, i64 0}
!18 = !{!19, !12, i64 48}
!19 = !{!"arm_2d_op_t", !20, i64 0, !22, i64 48}
!20 = !{!"arm_2d_op_core_t", !8, i64 0, !21, i64 40}
!21 = !{!"long", !8, i64 0}
!22 = !{!"", !12, i64 0, !12, i64 8}
!23 = !{!8, !8, i64 0}
!24 = !{!19, !12, i64 56}


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