; LLVM IR from ARM-software/Arm-2D :: Helper/Source (arm_2d_helper_control)

; 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_location_t = type { i16, i16 }
%struct.arm_2d_region_t = type { %union.anon, %union.anon.0 }
%union.anon = type { %struct.arm_2d_location_t }
%union.anon.0 = type { %struct.arm_2d_size_t }
%struct.arm_2d_size_t = type { i16, i16 }
%struct.arm_2d_control_node_t = type { %struct.anon, %struct.arm_2d_region_t }
%struct.anon = type { ptr, ptr, ptr }

@.str = external hidden unnamed_addr constant [25 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [91 x i8], align 1
@__PRETTY_FUNCTION__.arm_2d_helper_control_find_node_with_location = external hidden unnamed_addr constant [113 x i8], align 1

; Function Attrs: nounwind uwtable
declare dso_local ptr @arm_2d_helper_control_get_absolute_region(ptr noundef nonnull, ptr noundef nonnull, i1 noundef zeroext) #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 ptr @arm_2d_helper_control_find_node_with_location(ptr noundef nonnull %0, i32 %1) #0 {
  %3 = alloca ptr, align 8
  %4 = alloca %struct.arm_2d_location_t, align 2
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca i32, align 4
  %10 = alloca %struct.arm_2d_region_t, align 2
  %11 = alloca i8, align 1
  store i32 %1, ptr %4, align 2
  store ptr %0, ptr %5, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #4
  store ptr null, ptr %6, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #4
  store ptr null, ptr %7, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #4
  store ptr null, ptr %8, align 8, !tbaa !5
  %12 = load ptr, ptr %5, align 8, !tbaa !5
  store ptr %12, ptr %6, align 8, !tbaa !5
  %13 = load ptr, ptr %6, align 8, !tbaa !5
  %14 = icmp eq ptr null, %13
  br i1 %14, label %15, label %16

15:                                               ; preds = %2
  store ptr null, ptr %3, align 8
  store i32 1, ptr %9, align 4
  br label %76

16:                                               ; preds = %2
  %17 = load ptr, ptr %5, align 8, !tbaa !5
  %18 = getelementptr inbounds %struct.arm_2d_control_node_t, ptr %17, i32 0, i32 0
  %19 = getelementptr inbounds %struct.anon, ptr %18, i32 0, i32 1
  %20 = load ptr, ptr %19, align 8, !tbaa !9
  %21 = icmp eq ptr null, %20
  br i1 %21, label %22, label %23

22:                                               ; preds = %16
  br label %24

23:                                               ; preds = %16
  call void @__assert_fail(ptr noundef @.str, ptr noundef @.str.1, i32 noundef 172, ptr noundef @__PRETTY_FUNCTION__.arm_2d_helper_control_find_node_with_location) #5
  unreachable

24:                                               ; preds = %22
  br label %25

25:                                               ; preds = %73, %24
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #4
  call void @llvm.lifetime.start.p0(i64 1, ptr %11) #4
  store i8 0, ptr %11, align 1, !tbaa !13
  %26 = load ptr, ptr %6, align 8, !tbaa !5
  %27 = call ptr @arm_2d_helper_control_get_absolute_region(ptr noundef %26, ptr noundef %10, i1 noundef zeroext true)
  %28 = icmp ne ptr null, %27
  br i1 %28, label %29, label %32

29:                                               ; preds = %25
  %30 = call zeroext i1 @arm_2d_is_point_inside_region(ptr noundef %10, ptr noundef %4)
  %31 = zext i1 %30 to i8
  store i8 %31, ptr %11, align 1, !tbaa !13
  br label %32

32:                                               ; preds = %29, %25
  %33 = load i8, ptr %11, align 1, !tbaa !13, !range !15, !noundef !16
  %34 = trunc i8 %33 to i1
  br i1 %34, label %35, label %37

35:                                               ; preds = %32
  %36 = load ptr, ptr %6, align 8, !tbaa !5
  store ptr %36, ptr %7, align 8, !tbaa !5
  br label %37

37:                                               ; preds = %35, %32
  %38 = load ptr, ptr %6, align 8, !tbaa !5
  %39 = getelementptr inbounds %struct.arm_2d_control_node_t, ptr %38, i32 0, i32 0
  %40 = getelementptr inbounds %struct.anon, ptr %39, i32 0, i32 0
  %41 = load ptr, ptr %40, align 8, !tbaa !17
  %42 = icmp ne ptr null, %41
  br i1 %42, label %43, label %48

43:                                               ; preds = %37
  %44 = load ptr, ptr %6, align 8, !tbaa !5
  %45 = getelementptr inbounds %struct.arm_2d_control_node_t, ptr %44, i32 0, i32 0
  %46 = getelementptr inbounds %struct.anon, ptr %45, i32 0, i32 0
  %47 = load ptr, ptr %46, align 8, !tbaa !17
  store ptr %47, ptr %6, align 8, !tbaa !5
  store i32 3, ptr %9, align 4
  br label %70

48:                                               ; preds = %37
  %49 = load ptr, ptr %7, align 8, !tbaa !5
  %50 = icmp eq ptr null, %49
  br i1 %50, label %51, label %52

51:                                               ; preds = %48
  store i32 2, ptr %9, align 4
  br label %70

52:                                               ; preds = %48
  %53 = load ptr, ptr %7, align 8, !tbaa !5
  %54 = load ptr, ptr %8, align 8, !tbaa !5
  %55 = icmp eq ptr %53, %54
  br i1 %55, label %56, label %57

56:                                               ; preds = %52
  store i32 2, ptr %9, align 4
  br label %70

57:                                               ; preds = %52
  %58 = load ptr, ptr %7, align 8, !tbaa !5
  %59 = getelementptr inbounds %struct.arm_2d_control_node_t, ptr %58, i32 0, i32 0
  %60 = getelementptr inbounds %struct.anon, ptr %59, i32 0, i32 2
  %61 = load ptr, ptr %60, align 8, !tbaa !18
  %62 = icmp eq ptr null, %61
  br i1 %62, label %63, label %64

63:                                               ; preds = %57
  store i32 2, ptr %9, align 4
  br label %70

64:                                               ; preds = %57
  %65 = load ptr, ptr %7, align 8, !tbaa !5
  store ptr %65, ptr %8, align 8, !tbaa !5
  %66 = load ptr, ptr %7, align 8, !tbaa !5
  %67 = getelementptr inbounds %struct.arm_2d_control_node_t, ptr %66, i32 0, i32 0
  %68 = getelementptr inbounds %struct.anon, ptr %67, i32 0, i32 2
  %69 = load ptr, ptr %68, align 8, !tbaa !18
  store ptr %69, ptr %6, align 8, !tbaa !5
  store i32 0, ptr %9, align 4
  br label %70

70:                                               ; preds = %64, %63, %56, %51, %43
  call void @llvm.lifetime.end.p0(i64 1, ptr %11) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #4
  %71 = load i32, ptr %9, align 4
  switch i32 %71, label %78 [
    i32 0, label %72
    i32 3, label %73
    i32 2, label %74
  ]

72:                                               ; preds = %70
  br label %73

73:                                               ; preds = %72, %70
  br i1 true, label %25, label %74

74:                                               ; preds = %73, %70
  %75 = load ptr, ptr %7, align 8, !tbaa !5
  store ptr %75, ptr %3, align 8
  store i32 1, ptr %9, align 4
  br label %76

76:                                               ; preds = %74, %15
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #4
  %77 = load ptr, ptr %3, align 8
  ret ptr %77

78:                                               ; preds = %70
  unreachable
}

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

declare zeroext i1 @arm_2d_is_point_inside_region(ptr noundef, ptr noundef) #3

attributes #0 = { 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 #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 #3 = { "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 = { nounwind }
attributes #5 = { 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 8}
!10 = !{!"arm_2d_control_node_t", !11, i64 0, !12, i64 24}
!11 = !{!"", !6, i64 0, !6, i64 8, !6, i64 16}
!12 = !{!"arm_2d_region_t", !7, i64 0, !7, i64 4}
!13 = !{!14, !14, i64 0}
!14 = !{!"_Bool", !7, i64 0}
!15 = !{i8 0, i8 2}
!16 = !{}
!17 = !{!10, !6, i64 0}
!18 = !{!10, !6, i64 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"

%struct.arm_2d_location_t = type { i16, i16 }
%struct.arm_2d_region_t = type { %union.anon, %union.anon.0 }
%union.anon = type { %struct.arm_2d_location_t }
%union.anon.0 = type { %struct.arm_2d_size_t }
%struct.arm_2d_size_t = type { i16, i16 }

@.str = external hidden unnamed_addr constant [25 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [91 x i8], align 1
@__PRETTY_FUNCTION__.arm_2d_helper_control_find_node_with_location = external hidden unnamed_addr constant [113 x i8], align 1

; Function Attrs: nounwind uwtable
declare dso_local ptr @arm_2d_helper_control_get_absolute_region(ptr noundef nonnull, ptr noundef nonnull, i1 noundef zeroext) 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
define dso_local ptr @arm_2d_helper_control_find_node_with_location(ptr noundef nonnull %0, i32 %1) local_unnamed_addr #0 {
  %3 = alloca %struct.arm_2d_location_t, align 4
  %4 = alloca %struct.arm_2d_region_t, align 2
  store i32 %1, ptr %3, align 4
  %5 = getelementptr inbounds i8, ptr %0, i64 8
  %6 = load ptr, ptr %5, align 8, !tbaa !5
  %7 = icmp eq ptr %6, null
  br i1 %7, label %.preheader.outer, label %8

8:                                                ; preds = %2
  tail call void @__assert_fail(ptr noundef nonnull @.str, ptr noundef nonnull @.str.1, i32 noundef 172, ptr noundef nonnull @__PRETTY_FUNCTION__.arm_2d_helper_control_find_node_with_location) #4
  unreachable

.preheader:                                       ; preds = %.preheader.outer, %21
  %.020 = phi ptr [ %13, %21 ], [ %.020.ph, %.preheader.outer ]
  %.018 = phi ptr [ %12, %21 ], [ %.018.ph, %.preheader.outer ]
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %4) #5
  %9 = call ptr @arm_2d_helper_control_get_absolute_region(ptr noundef %.020, ptr noundef %4, i1 noundef zeroext true)
  %.not = icmp eq ptr %9, null
  br i1 %.not, label %.thread, label %10

10:                                               ; preds = %.preheader
  %11 = call zeroext i1 @arm_2d_is_point_inside_region(ptr noundef nonnull %4, ptr noundef nonnull %3) #5
  %cond.fr = freeze i1 %11
  %spec.select = select i1 %cond.fr, ptr %.020, ptr %.018
  br label %.thread

.thread:                                          ; preds = %10, %.preheader
  %12 = phi ptr [ %.018, %.preheader ], [ %spec.select, %10 ]
  %13 = load ptr, ptr %.020, align 8, !tbaa !12
  %.not25 = icmp eq ptr %13, null
  br i1 %.not25, label %14, label %21

14:                                               ; preds = %.thread
  %15 = icmp eq ptr %12, null
  %16 = icmp eq ptr %12, %.018.ph
  %or.cond = or i1 %15, %16
  br i1 %or.cond, label %.thread28, label %17

.thread28:                                        ; preds = %14
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %4) #5
  br label %.loopexit

17:                                               ; preds = %14
  %18 = getelementptr inbounds i8, ptr %12, i64 16
  %19 = load ptr, ptr %18, align 8, !tbaa !13
  %20 = icmp eq ptr %19, null
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %4) #5
  br i1 %20, label %.loopexit, label %.preheader.outer

.preheader.outer:                                 ; preds = %2, %17
  %.020.ph = phi ptr [ %19, %17 ], [ %0, %2 ]
  %.018.ph = phi ptr [ %12, %17 ], [ null, %2 ]
  br label %.preheader

21:                                               ; preds = %.thread
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %4) #5
  br label %.preheader

.loopexit:                                        ; preds = %17, %.thread28
  ret ptr %12
}

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

declare zeroext i1 @arm_2d_is_point_inside_region(ptr noundef, ptr noundef) local_unnamed_addr #3

attributes #0 = { 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 #1 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 #3 = { "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, !8, i64 8}
!6 = !{!"arm_2d_control_node_t", !7, i64 0, !11, i64 24}
!7 = !{!"", !8, i64 0, !8, i64 8, !8, i64 16}
!8 = !{!"any pointer", !9, i64 0}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C/C++ TBAA"}
!11 = !{!"arm_2d_region_t", !9, i64 0, !9, i64 4}
!12 = !{!6, !8, i64 0}
!13 = !{!6, !8, i64 16}


; Effective O3 passes: ADCEPass,CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LoopSimplifyPass,LoopUnrollPass,SROAPass,SimplifyCFGPass,TailCallElimPass