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

; 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

; 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) #1

; Function Attrs: nounwind uwtable
declare dso_local zeroext i1 @arm_2d_is_point_inside_region(ptr noundef nonnull, ptr noundef nonnull) #2

; Function Attrs: nounwind uwtable
define dso_local signext i8 @arm_2d_is_region_inside_target(ptr noundef nonnull %0, ptr noundef nonnull %1) #2 {
  %3 = alloca i8, align 1
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca %struct.arm_2d_location_t, align 2
  %7 = alloca %struct.arm_2d_location_t, align 2
  %8 = alloca i32, align 4
  %9 = alloca %struct.arm_2d_location_t, align 2
  %10 = alloca %struct.arm_2d_location_t, align 2
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  br label %11

11:                                               ; preds = %2
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #3
  %12 = load ptr, ptr %4, align 8, !tbaa !5
  %13 = getelementptr inbounds %struct.arm_2d_region_t, ptr %12, i32 0, i32 0
  call void @llvm.memcpy.p0.p0.i64(ptr align 2 %6, ptr align 2 %13, i64 4, i1 false), !tbaa.struct !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #3
  %14 = getelementptr inbounds %struct.arm_2d_location_t, ptr %7, i32 0, i32 0
  %15 = load ptr, ptr %4, align 8, !tbaa !5
  %16 = getelementptr inbounds %struct.arm_2d_region_t, ptr %15, i32 0, i32 0
  %17 = getelementptr inbounds %struct.arm_2d_location_t, ptr %16, i32 0, i32 0
  %18 = load i16, ptr %17, align 2, !tbaa !12
  %19 = sext i16 %18 to i32
  %20 = load ptr, ptr %4, align 8, !tbaa !5
  %21 = getelementptr inbounds %struct.arm_2d_region_t, ptr %20, i32 0, i32 1
  %22 = getelementptr inbounds %struct.arm_2d_size_t, ptr %21, i32 0, i32 0
  %23 = load i16, ptr %22, align 2, !tbaa !12
  %24 = sext i16 %23 to i32
  %25 = add nsw i32 %19, %24
  %26 = sub nsw i32 %25, 1
  %27 = trunc i32 %26 to i16
  store i16 %27, ptr %14, align 2, !tbaa !13
  %28 = getelementptr inbounds %struct.arm_2d_location_t, ptr %7, i32 0, i32 1
  %29 = load ptr, ptr %4, align 8, !tbaa !5
  %30 = getelementptr inbounds %struct.arm_2d_region_t, ptr %29, i32 0, i32 0
  %31 = getelementptr inbounds %struct.arm_2d_location_t, ptr %30, i32 0, i32 1
  %32 = load i16, ptr %31, align 2, !tbaa !12
  %33 = sext i16 %32 to i32
  %34 = load ptr, ptr %4, align 8, !tbaa !5
  %35 = getelementptr inbounds %struct.arm_2d_region_t, ptr %34, i32 0, i32 1
  %36 = getelementptr inbounds %struct.arm_2d_size_t, ptr %35, i32 0, i32 1
  %37 = load i16, ptr %36, align 2, !tbaa !12
  %38 = sext i16 %37 to i32
  %39 = add nsw i32 %33, %38
  %40 = sub nsw i32 %39, 1
  %41 = trunc i32 %40 to i16
  store i16 %41, ptr %28, align 2, !tbaa !15
  %42 = load ptr, ptr %5, align 8, !tbaa !5
  %43 = call zeroext i1 @arm_2d_is_point_inside_region(ptr noundef %42, ptr noundef %6)
  br i1 %43, label %44, label %48

44:                                               ; preds = %11
  %45 = load ptr, ptr %5, align 8, !tbaa !5
  %46 = call zeroext i1 @arm_2d_is_point_inside_region(ptr noundef %45, ptr noundef %7)
  br i1 %46, label %47, label %48

47:                                               ; preds = %44
  store i8 1, ptr %3, align 1
  store i32 1, ptr %8, align 4
  br label %49

48:                                               ; preds = %44, %11
  store i32 0, ptr %8, align 4
  br label %49

49:                                               ; preds = %48, %47
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #3
  %50 = load i32, ptr %8, align 4
  switch i32 %50, label %97 [
    i32 0, label %51
    i32 1, label %95
  ]

51:                                               ; preds = %49
  br label %52

52:                                               ; preds = %51
  br label %53

53:                                               ; preds = %52
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #3
  %54 = load ptr, ptr %5, align 8, !tbaa !5
  %55 = getelementptr inbounds %struct.arm_2d_region_t, ptr %54, i32 0, i32 0
  call void @llvm.memcpy.p0.p0.i64(ptr align 2 %9, ptr align 2 %55, i64 4, i1 false), !tbaa.struct !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #3
  %56 = getelementptr inbounds %struct.arm_2d_location_t, ptr %10, i32 0, i32 0
  %57 = load ptr, ptr %5, align 8, !tbaa !5
  %58 = getelementptr inbounds %struct.arm_2d_region_t, ptr %57, i32 0, i32 0
  %59 = getelementptr inbounds %struct.arm_2d_location_t, ptr %58, i32 0, i32 0
  %60 = load i16, ptr %59, align 2, !tbaa !12
  %61 = sext i16 %60 to i32
  %62 = load ptr, ptr %5, align 8, !tbaa !5
  %63 = getelementptr inbounds %struct.arm_2d_region_t, ptr %62, i32 0, i32 1
  %64 = getelementptr inbounds %struct.arm_2d_size_t, ptr %63, i32 0, i32 0
  %65 = load i16, ptr %64, align 2, !tbaa !12
  %66 = sext i16 %65 to i32
  %67 = add nsw i32 %61, %66
  %68 = sub nsw i32 %67, 1
  %69 = trunc i32 %68 to i16
  store i16 %69, ptr %56, align 2, !tbaa !13
  %70 = getelementptr inbounds %struct.arm_2d_location_t, ptr %10, i32 0, i32 1
  %71 = load ptr, ptr %5, align 8, !tbaa !5
  %72 = getelementptr inbounds %struct.arm_2d_region_t, ptr %71, i32 0, i32 0
  %73 = getelementptr inbounds %struct.arm_2d_location_t, ptr %72, i32 0, i32 1
  %74 = load i16, ptr %73, align 2, !tbaa !12
  %75 = sext i16 %74 to i32
  %76 = load ptr, ptr %5, align 8, !tbaa !5
  %77 = getelementptr inbounds %struct.arm_2d_region_t, ptr %76, i32 0, i32 1
  %78 = getelementptr inbounds %struct.arm_2d_size_t, ptr %77, i32 0, i32 1
  %79 = load i16, ptr %78, align 2, !tbaa !12
  %80 = sext i16 %79 to i32
  %81 = add nsw i32 %75, %80
  %82 = sub nsw i32 %81, 1
  %83 = trunc i32 %82 to i16
  store i16 %83, ptr %70, align 2, !tbaa !15
  %84 = load ptr, ptr %4, align 8, !tbaa !5
  %85 = call zeroext i1 @arm_2d_is_point_inside_region(ptr noundef %84, ptr noundef %9)
  br i1 %85, label %86, label %90

86:                                               ; preds = %53
  %87 = load ptr, ptr %4, align 8, !tbaa !5
  %88 = call zeroext i1 @arm_2d_is_point_inside_region(ptr noundef %87, ptr noundef %10)
  br i1 %88, label %89, label %90

89:                                               ; preds = %86
  store i8 -1, ptr %3, align 1
  store i32 1, ptr %8, align 4
  br label %91

90:                                               ; preds = %86, %53
  store i32 0, ptr %8, align 4
  br label %91

91:                                               ; preds = %90, %89
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #3
  %92 = load i32, ptr %8, align 4
  switch i32 %92, label %97 [
    i32 0, label %93
    i32 1, label %95
  ]

93:                                               ; preds = %91
  br label %94

94:                                               ; preds = %93
  store i8 0, ptr %3, align 1
  br label %95

95:                                               ; preds = %94, %91, %49
  %96 = load i8, ptr %3, align 1
  ret i8 %96

97:                                               ; preds = %91, %49
  unreachable
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree 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 = { 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 = !{i64 0, i64 2, !10, i64 2, i64 2, !10}
!10 = !{!11, !11, i64 0}
!11 = !{!"short", !7, i64 0}
!12 = !{!7, !7, i64 0}
!13 = !{!14, !11, i64 0}
!14 = !{!"arm_2d_location_t", !11, i64 0, !11, i64 2}
!15 = !{!14, !11, 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"

%struct.arm_2d_location_t = type { i16, i16 }

; 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

; Function Attrs: nounwind uwtable
declare dso_local zeroext i1 @arm_2d_is_point_inside_region(ptr noundef nonnull, ptr noundef nonnull) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local signext range(i8 -1, 2) i8 @arm_2d_is_region_inside_target(ptr noundef nonnull %0, ptr noundef nonnull %1) local_unnamed_addr #1 {
  %3 = alloca %struct.arm_2d_location_t, align 4
  %4 = alloca %struct.arm_2d_location_t, align 4
  %5 = alloca %struct.arm_2d_location_t, align 4
  %6 = alloca %struct.arm_2d_location_t, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %3) #2
  %7 = load i32, ptr %0, align 2
  store i32 %7, ptr %3, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %4) #2
  %8 = getelementptr inbounds i8, ptr %0, i64 4
  %9 = bitcast i32 %7 to <2 x i16>
  %10 = load <2 x i16>, ptr %8, align 2, !tbaa !5
  %11 = add <2 x i16> %9, <i16 -1, i16 -1>
  %12 = add <2 x i16> %11, %10
  store <2 x i16> %12, ptr %4, align 4, !tbaa !8
  %13 = call zeroext i1 @arm_2d_is_point_inside_region(ptr noundef %1, ptr noundef %3)
  br i1 %13, label %14, label %17

14:                                               ; preds = %2
  %15 = call zeroext i1 @arm_2d_is_point_inside_region(ptr noundef %1, ptr noundef %4)
  br i1 %15, label %16, label %17

16:                                               ; preds = %14
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %4) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %3) #2
  br label %29

17:                                               ; preds = %2, %14
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %4) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %3) #2
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %5) #2
  %18 = load i32, ptr %1, align 2
  store i32 %18, ptr %5, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %6) #2
  %19 = getelementptr inbounds i8, ptr %1, i64 4
  %20 = bitcast i32 %18 to <2 x i16>
  %21 = load <2 x i16>, ptr %19, align 2, !tbaa !5
  %22 = add <2 x i16> %20, <i16 -1, i16 -1>
  %23 = add <2 x i16> %22, %21
  store <2 x i16> %23, ptr %6, align 4, !tbaa !8
  %24 = call zeroext i1 @arm_2d_is_point_inside_region(ptr noundef %0, ptr noundef %5)
  br i1 %24, label %25, label %28

25:                                               ; preds = %17
  %26 = call zeroext i1 @arm_2d_is_point_inside_region(ptr noundef %0, ptr noundef %6)
  br i1 %26, label %27, label %28

27:                                               ; preds = %25
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %6) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %5) #2
  br label %29

28:                                               ; preds = %17, %25
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %6) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %5) #2
  br label %29

29:                                               ; preds = %28, %27, %16
  %.2 = phi i8 [ 1, %16 ], [ 0, %28 ], [ -1, %27 ]
  ret i8 %.2
}

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


; Effective O3 passes: BDCEPass,CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,ReassociatePass,SCCPPass,SLPVectorizerPass,SROAPass,SimplifyCFGPass