; LLVM IR from ARM-software/Arm-2D :: Library/Source (arm_2d)

; 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.34, %union.anon.35 }
%union.anon.34 = type { %struct.arm_2d_location_t }
%struct.arm_2d_location_t = type { i16, i16 }
%union.anon.35 = type { %struct.arm_2d_size_t }
%struct.arm_2d_size_t = type { i16, i16 }

@.str.7 = external hidden unnamed_addr constant [94 x i8], align 1
@.str.12 = external hidden unnamed_addr constant [17 x i8], align 1
@__PRETTY_FUNCTION__.arm_2d_is_point_inside_region = external hidden unnamed_addr constant [88 x i8], align 1
@.str.13 = external hidden unnamed_addr constant [16 x i8], align 1

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

; Function Attrs: nounwind uwtable
define dso_local zeroext i1 @arm_2d_is_point_inside_region(ptr noundef nonnull %0, ptr noundef nonnull %1) #1 {
  %3 = alloca i1, align 1
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  %6 = load ptr, ptr %4, align 8, !tbaa !5
  %7 = icmp ne ptr %6, null
  br i1 %7, label %8, label %9

8:                                                ; preds = %2
  br label %10

9:                                                ; preds = %2
  call void @__assert_fail(ptr noundef @.str.12, ptr noundef @.str.7, i32 noundef 242, ptr noundef @__PRETTY_FUNCTION__.arm_2d_is_point_inside_region) #2
  unreachable

10:                                               ; preds = %8
  %11 = load ptr, ptr %5, align 8, !tbaa !5
  %12 = icmp ne ptr %11, null
  br i1 %12, label %13, label %14

13:                                               ; preds = %10
  br label %15

14:                                               ; preds = %10
  call void @__assert_fail(ptr noundef @.str.13, ptr noundef @.str.7, i32 noundef 243, ptr noundef @__PRETTY_FUNCTION__.arm_2d_is_point_inside_region) #2
  unreachable

15:                                               ; preds = %13
  br label %16

16:                                               ; preds = %15
  %17 = load ptr, ptr %4, align 8, !tbaa !5
  %18 = getelementptr inbounds %struct.arm_2d_region_t, ptr %17, i32 0, i32 1
  %19 = getelementptr inbounds %struct.arm_2d_size_t, ptr %18, i32 0, i32 0
  %20 = load i16, ptr %19, align 2, !tbaa !9
  %21 = sext i16 %20 to i32
  %22 = icmp eq i32 0, %21
  br i1 %22, label %30, label %23

23:                                               ; preds = %16
  %24 = load ptr, ptr %4, align 8, !tbaa !5
  %25 = getelementptr inbounds %struct.arm_2d_region_t, ptr %24, i32 0, i32 1
  %26 = getelementptr inbounds %struct.arm_2d_size_t, ptr %25, i32 0, i32 1
  %27 = load i16, ptr %26, align 2, !tbaa !9
  %28 = sext i16 %27 to i32
  %29 = icmp eq i32 0, %28
  br i1 %29, label %30, label %31

30:                                               ; preds = %23, %16
  br label %96

31:                                               ; preds = %23
  %32 = load ptr, ptr %5, align 8, !tbaa !5
  %33 = getelementptr inbounds %struct.arm_2d_location_t, ptr %32, i32 0, i32 0
  %34 = load i16, ptr %33, align 2, !tbaa !10
  %35 = sext i16 %34 to i32
  %36 = load ptr, ptr %4, align 8, !tbaa !5
  %37 = getelementptr inbounds %struct.arm_2d_region_t, ptr %36, i32 0, i32 0
  %38 = getelementptr inbounds %struct.arm_2d_location_t, ptr %37, i32 0, i32 0
  %39 = load i16, ptr %38, align 2, !tbaa !9
  %40 = sext i16 %39 to i32
  %41 = icmp slt i32 %35, %40
  br i1 %41, label %42, label %43

42:                                               ; preds = %31
  br label %96

43:                                               ; preds = %31
  %44 = load ptr, ptr %5, align 8, !tbaa !5
  %45 = getelementptr inbounds %struct.arm_2d_location_t, ptr %44, i32 0, i32 1
  %46 = load i16, ptr %45, align 2, !tbaa !13
  %47 = sext i16 %46 to i32
  %48 = load ptr, ptr %4, align 8, !tbaa !5
  %49 = getelementptr inbounds %struct.arm_2d_region_t, ptr %48, i32 0, i32 0
  %50 = getelementptr inbounds %struct.arm_2d_location_t, ptr %49, i32 0, i32 1
  %51 = load i16, ptr %50, align 2, !tbaa !9
  %52 = sext i16 %51 to i32
  %53 = icmp slt i32 %47, %52
  br i1 %53, label %54, label %55

54:                                               ; preds = %43
  br label %96

55:                                               ; preds = %43
  %56 = load ptr, ptr %5, align 8, !tbaa !5
  %57 = getelementptr inbounds %struct.arm_2d_location_t, ptr %56, i32 0, i32 0
  %58 = load i16, ptr %57, align 2, !tbaa !10
  %59 = sext i16 %58 to i32
  %60 = load ptr, ptr %4, align 8, !tbaa !5
  %61 = getelementptr inbounds %struct.arm_2d_region_t, ptr %60, i32 0, i32 0
  %62 = getelementptr inbounds %struct.arm_2d_location_t, ptr %61, i32 0, i32 0
  %63 = load i16, ptr %62, align 2, !tbaa !9
  %64 = sext i16 %63 to i32
  %65 = load ptr, ptr %4, align 8, !tbaa !5
  %66 = getelementptr inbounds %struct.arm_2d_region_t, ptr %65, i32 0, i32 1
  %67 = getelementptr inbounds %struct.arm_2d_size_t, ptr %66, i32 0, i32 0
  %68 = load i16, ptr %67, align 2, !tbaa !9
  %69 = sext i16 %68 to i32
  %70 = add nsw i32 %64, %69
  %71 = icmp sge i32 %59, %70
  br i1 %71, label %72, label %73

72:                                               ; preds = %55
  br label %96

73:                                               ; preds = %55
  %74 = load ptr, ptr %5, align 8, !tbaa !5
  %75 = getelementptr inbounds %struct.arm_2d_location_t, ptr %74, i32 0, i32 1
  %76 = load i16, ptr %75, align 2, !tbaa !13
  %77 = sext i16 %76 to i32
  %78 = load ptr, ptr %4, align 8, !tbaa !5
  %79 = getelementptr inbounds %struct.arm_2d_region_t, ptr %78, i32 0, i32 0
  %80 = getelementptr inbounds %struct.arm_2d_location_t, ptr %79, i32 0, i32 1
  %81 = load i16, ptr %80, align 2, !tbaa !9
  %82 = sext i16 %81 to i32
  %83 = load ptr, ptr %4, align 8, !tbaa !5
  %84 = getelementptr inbounds %struct.arm_2d_region_t, ptr %83, i32 0, i32 1
  %85 = getelementptr inbounds %struct.arm_2d_size_t, ptr %84, i32 0, i32 1
  %86 = load i16, ptr %85, align 2, !tbaa !9
  %87 = sext i16 %86 to i32
  %88 = add nsw i32 %82, %87
  %89 = icmp sge i32 %77, %88
  br i1 %89, label %90, label %91

90:                                               ; preds = %73
  br label %96

91:                                               ; preds = %73
  br label %92

92:                                               ; preds = %91
  br label %93

93:                                               ; preds = %92
  br label %94

94:                                               ; preds = %93
  br label %95

95:                                               ; preds = %94
  store i1 true, ptr %3, align 1
  br label %97

96:                                               ; preds = %90, %72, %54, %42, %30
  store i1 false, ptr %3, align 1
  br label %97

97:                                               ; preds = %96, %95
  %98 = load i1, ptr %3, align 1
  ret i1 %98
}

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 = { 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 = { 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 = !{!7, !7, i64 0}
!10 = !{!11, !12, i64 0}
!11 = !{!"arm_2d_location_t", !12, i64 0, !12, i64 2}
!12 = !{!"short", !7, i64 0}
!13 = !{!11, !12, i64 2}


; 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: read) uwtable
define dso_local noundef zeroext i1 @arm_2d_is_point_inside_region(ptr nocapture noundef nonnull readonly %0, ptr nocapture noundef nonnull readonly %1) local_unnamed_addr #0 {
  %3 = getelementptr inbounds i8, ptr %0, i64 4
  %4 = load i16, ptr %3, align 2, !tbaa !5
  %5 = sext i16 %4 to i32
  %6 = icmp eq i16 %4, 0
  br i1 %6, label %28, label %7

7:                                                ; preds = %2
  %8 = getelementptr inbounds i8, ptr %0, i64 6
  %9 = load i16, ptr %8, align 2, !tbaa !5
  %10 = sext i16 %9 to i32
  %11 = icmp eq i16 %9, 0
  br i1 %11, label %28, label %12

12:                                               ; preds = %7
  %13 = load i16, ptr %1, align 2, !tbaa !8
  %14 = load i16, ptr %0, align 2, !tbaa !5
  %15 = icmp slt i16 %13, %14
  br i1 %15, label %28, label %16

16:                                               ; preds = %12
  %17 = sext i16 %14 to i32
  %18 = sext i16 %13 to i32
  %19 = getelementptr inbounds i8, ptr %1, i64 2
  %20 = load i16, ptr %19, align 2, !tbaa !11
  %21 = sext i16 %20 to i32
  %22 = getelementptr inbounds i8, ptr %0, i64 2
  %23 = load i16, ptr %22, align 2, !tbaa !5
  %24 = sext i16 %23 to i32
  %25 = icmp sge i16 %20, %23
  %26 = add nsw i32 %17, %5
  %.not = icmp sgt i32 %26, %18
  %or.cond = select i1 %25, i1 %.not, i1 false
  %27 = add nsw i32 %24, %10
  %.not21 = icmp sgt i32 %27, %21
  %or.cond22 = select i1 %or.cond, i1 %.not21, i1 false
  br i1 %or.cond22, label %29, label %28

28:                                               ; preds = %16, %12, %2, %7
  br label %29

29:                                               ; preds = %16, %28
  %.0 = phi i1 [ false, %28 ], [ true, %16 ]
  ret i1 %.0
}

attributes #0 = { mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: read) 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)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"omnipotent char", !7, i64 0}
!7 = !{!"Simple C/C++ TBAA"}
!8 = !{!9, !10, i64 0}
!9 = !{!"arm_2d_location_t", !10, i64 0, !10, i64 2}
!10 = !{!"short", !6, i64 0}
!11 = !{!9, !10, i64 2}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IPSCCPPass,InstCombinePass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass