; 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_pfb_t = type { %struct.anon, %struct.anon.30 }
%struct.anon = type { %struct.arm_2d_helper_pfb_cfg_t, %struct.anon.4 }
%struct.arm_2d_helper_pfb_cfg_t = type { %struct.arm_2d_region_t, %struct.anon.1, %struct.anon.2, %struct.arm_2d_helper_pfb_dependency_t }
%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.1 = type <{ ptr, %struct.arm_2d_size_t, i64, [4 x i8] }>
%struct.anon.2 = type { ptr, i8 }
%struct.arm_2d_helper_pfb_dependency_t = type { %struct.arm_2d_helper_render_evt_t, %struct.arm_2d_helper_draw_evt_t, %struct.arm_2d_evt_t, %struct.arm_2d_evt_t, %struct.anon.3, %struct.arm_2d_helper_before_flushing_evt_t }
%struct.arm_2d_helper_render_evt_t = type { ptr, ptr }
%struct.arm_2d_helper_draw_evt_t = type { ptr, ptr }
%struct.arm_2d_evt_t = type { ptr, ptr }
%struct.anon.3 = type { %struct.arm_2d_helper_draw_evt_t, ptr }
%struct.arm_2d_helper_before_flushing_evt_t = type { ptr, ptr }
%struct.anon.4 = type { %struct.arm_2d_location_t, %struct.arm_2d_region_t, ptr, %struct.anon.5, %struct.arm_2d_tile_t, %struct.arm_2d_size_t, i32, i8, i8, i16, %struct.anon.21, %union.arm_2d_colour_t, i64, ptr, ptr, ptr, %struct.anon.29, ptr }
%struct.anon.5 = type { ptr, ptr, ptr, ptr, %struct.arm_2d_region_list_item_t }
%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_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 }
%struct.anon.21 = type { i32 }
%union.arm_2d_colour_t = type { i32 }
%struct.anon.29 = type { ptr, ptr }
%struct.anon.30 = type { i64, i32, i32 }

@.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_pfb_disable_dirty_region_optimization = external hidden unnamed_addr constant [81 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
define dso_local zeroext i1 @arm_2d_helper_pfb_disable_dirty_region_optimization(ptr noundef nonnull %0) #2 {
  %2 = alloca ptr, align 8
  %3 = alloca i8, align 1
  %4 = alloca i32, align 4
  %5 = alloca ptr, align 8
  store ptr %0, ptr %2, align 8, !tbaa !5
  %6 = load ptr, ptr %2, align 8, !tbaa !5
  %7 = icmp ne ptr null, %6
  br i1 %7, label %8, label %9

8:                                                ; preds = %1
  br label %10

9:                                                ; preds = %1
  call void @__assert_fail(ptr noundef @.str, ptr noundef @.str.1, i32 noundef 809, ptr noundef @__PRETTY_FUNCTION__.arm_2d_helper_pfb_disable_dirty_region_optimization) #3
  unreachable

10:                                               ; preds = %8
  call void @llvm.lifetime.start.p0(i64 1, ptr %3) #4
  store i8 0, ptr %3, align 1, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #4
  store i32 0, ptr %4, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #4
  store ptr null, ptr %5, align 8, !tbaa !5
  br label %11

11:                                               ; preds = %16, %10
  %12 = load ptr, ptr %5, align 8, !tbaa !5
  %13 = getelementptr inbounds i32, ptr %12, i32 1
  store ptr %13, ptr %5, align 8, !tbaa !5
  %14 = icmp eq ptr %12, null
  br i1 %14, label %16, label %15

15:                                               ; preds = %11
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #4
  br label %39

16:                                               ; preds = %11
  %17 = load ptr, ptr %2, align 8, !tbaa !5
  %18 = getelementptr inbounds %struct.arm_2d_helper_pfb_t, ptr %17, i32 0, i32 0
  %19 = getelementptr inbounds %struct.anon, ptr %18, i32 0, i32 1
  %20 = getelementptr inbounds %struct.anon.4, ptr %19, i32 0, i32 10
  %21 = load i32, ptr %20, align 4
  %22 = and i32 %21, 1
  %23 = icmp ne i32 %22, 0
  %24 = zext i1 %23 to i8
  store i8 %24, ptr %3, align 1, !tbaa !9
  %25 = load ptr, ptr %2, align 8, !tbaa !5
  %26 = getelementptr inbounds %struct.arm_2d_helper_pfb_t, ptr %25, i32 0, i32 0
  %27 = getelementptr inbounds %struct.anon, ptr %26, i32 0, i32 1
  %28 = getelementptr inbounds %struct.anon.4, ptr %27, i32 0, i32 10
  %29 = load i32, ptr %28, align 4
  %30 = and i32 %29, -3
  %31 = or i32 %30, 0
  store i32 %31, ptr %28, align 4
  %32 = load ptr, ptr %2, align 8, !tbaa !5
  %33 = getelementptr inbounds %struct.arm_2d_helper_pfb_t, ptr %32, i32 0, i32 0
  %34 = getelementptr inbounds %struct.anon, ptr %33, i32 0, i32 1
  %35 = getelementptr inbounds %struct.anon.4, ptr %34, i32 0, i32 10
  %36 = load i32, ptr %35, align 4
  %37 = and i32 %36, -5
  %38 = or i32 %37, 4
  store i32 %38, ptr %35, align 4
  br label %11, !llvm.loop !13

39:                                               ; preds = %15
  %40 = load i8, ptr %3, align 1, !tbaa !9, !range !15, !noundef !16
  %41 = trunc i8 %40 to i1
  call void @llvm.lifetime.end.p0(i64 1, ptr %3) #4
  ret i1 %41
}

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, !10, i64 0}
!10 = !{!"_Bool", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}
!15 = !{i8 0, i8 2}
!16 = !{}


; 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 nofree norecurse nosync nounwind willreturn memory(argmem: readwrite) uwtable
define dso_local zeroext i1 @arm_2d_helper_pfb_disable_dirty_region_optimization(ptr nocapture noundef nonnull %0) local_unnamed_addr #0 {
  %2 = getelementptr inbounds i8, ptr %0, i64 276
  %.promoted = load i32, ptr %2, align 4
  %3 = and i32 %.promoted, -7
  %4 = or disjoint i32 %3, 4
  %5 = and i32 %.promoted, 1
  %6 = icmp ne i32 %5, 0
  store i32 %4, ptr %2, align 4
  ret i1 %6
}

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


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,LCSSAPass,LICMPass,LoopRotatePass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass