; 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_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 }
%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 }
%union.anon.20 = type { ptr }

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

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

declare ptr @__arm_2d_tile_get_virtual_screen_or_root(ptr noundef, ptr noundef, ptr noundef, ptr noundef, i1 noundef zeroext) #1

; Function Attrs: nounwind uwtable
define dso_local zeroext i1 @arm_2d_helper_pfb_is_region_being_drawing(ptr noundef %0, ptr noundef %1, ptr noundef %2) #2 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i8, align 1
  %8 = alloca %struct.arm_2d_tile_t, align 8
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  store ptr %2, ptr %6, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 1, ptr %7) #3
  store i8 0, ptr %7, align 1, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 24, ptr %8) #3
  %9 = load ptr, ptr %4, align 8, !tbaa !5
  %10 = icmp eq ptr null, %9
  br i1 %10, label %15, label %11

11:                                               ; preds = %3
  %12 = load ptr, ptr %4, align 8, !tbaa !5
  %13 = ptrtoint ptr %12 to i64
  %14 = icmp eq i64 -1, %13
  br i1 %14, label %15, label %17

15:                                               ; preds = %11, %3
  %16 = call ptr @arm_2d_get_default_frame_buffer()
  store ptr %16, ptr %4, align 8, !tbaa !5
  br label %17

17:                                               ; preds = %15, %11
  %18 = load ptr, ptr %5, align 8, !tbaa !5
  %19 = icmp ne ptr null, %18
  br i1 %19, label %20, label %27

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

23:                                               ; preds = %20
  %24 = load ptr, ptr %4, align 8, !tbaa !5
  %25 = load ptr, ptr %5, align 8, !tbaa !5
  %26 = call ptr @arm_2d_tile_generate_child(ptr noundef %24, ptr noundef %25, ptr noundef %8, i1 noundef zeroext false)
  store ptr %26, ptr %4, align 8, !tbaa !5
  br label %27

27:                                               ; preds = %23, %20, %17
  br label %28

28:                                               ; preds = %27
  %29 = load ptr, ptr %4, align 8, !tbaa !5
  %30 = icmp eq ptr null, %29
  br i1 %30, label %31, label %32

31:                                               ; preds = %28
  br label %40

32:                                               ; preds = %28
  %33 = load ptr, ptr %4, align 8, !tbaa !5
  %34 = load ptr, ptr %6, align 8, !tbaa !5
  %35 = call ptr @__arm_2d_tile_get_virtual_screen_or_root(ptr noundef %33, ptr noundef null, ptr noundef null, ptr noundef %34, i1 noundef zeroext false)
  %36 = icmp ne ptr null, %35
  br i1 %36, label %37, label %38

37:                                               ; preds = %32
  store i8 1, ptr %7, align 1, !tbaa !9
  br label %38

38:                                               ; preds = %37, %32
  br label %39

39:                                               ; preds = %38
  br label %40

40:                                               ; preds = %39, %31
  %41 = load i8, ptr %7, align 1, !tbaa !9, !range !11, !noundef !12
  %42 = trunc i8 %41 to i1
  call void @llvm.lifetime.end.p0(i64 24, ptr %8) #3
  call void @llvm.lifetime.end.p0(i64 1, ptr %7) #3
  ret i1 %42
}

declare ptr @arm_2d_get_default_frame_buffer() #1

declare ptr @arm_2d_tile_generate_child(ptr noundef, ptr noundef, ptr noundef, i1 noundef zeroext) #1

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


; 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_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 }
%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 }
%union.anon.20 = type { ptr }

; 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

declare ptr @__arm_2d_tile_get_virtual_screen_or_root(ptr noundef, ptr noundef, ptr noundef, ptr noundef, i1 noundef zeroext) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local zeroext i1 @arm_2d_helper_pfb_is_region_being_drawing(ptr noundef %0, ptr noundef %1, ptr noundef %2) local_unnamed_addr #2 {
  %4 = alloca %struct.arm_2d_tile_t, align 8
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %4) #3
  %magicptr = ptrtoint ptr %0 to i64
  switch i64 %magicptr, label %7 [
    i64 -1, label %5
    i64 0, label %5
  ]

5:                                                ; preds = %3, %3
  %6 = tail call ptr @arm_2d_get_default_frame_buffer() #3
  br label %7

7:                                                ; preds = %3, %5
  %.013 = phi ptr [ %6, %5 ], [ %0, %3 ]
  %8 = icmp ne ptr %1, null
  %9 = icmp ne ptr %.013, null
  %or.cond4 = select i1 %8, i1 %9, i1 false
  br i1 %or.cond4, label %10, label %12

10:                                               ; preds = %7
  %11 = call ptr @arm_2d_tile_generate_child(ptr noundef nonnull %.013, ptr noundef nonnull %1, ptr noundef nonnull %4, i1 noundef zeroext false) #3
  br label %12

12:                                               ; preds = %7, %10
  %.1 = phi ptr [ %11, %10 ], [ %.013, %7 ]
  %13 = icmp eq ptr %.1, null
  br i1 %13, label %16, label %14

14:                                               ; preds = %12
  %15 = call ptr @__arm_2d_tile_get_virtual_screen_or_root(ptr noundef nonnull %.1, ptr noundef null, ptr noundef null, ptr noundef %2, i1 noundef zeroext false) #3
  %.not = icmp ne ptr %15, null
  br label %16

16:                                               ; preds = %14, %12
  %.0 = phi i1 [ false, %12 ], [ %.not, %14 ]
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %4) #3
  ret i1 %.0
}

declare ptr @arm_2d_get_default_frame_buffer() local_unnamed_addr #1

declare ptr @arm_2d_tile_generate_child(ptr noundef, ptr noundef, ptr noundef, i1 noundef zeroext) local_unnamed_addr #1

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


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