; 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_tile_t = type { %union.anon.24, %union.anon.33, %union.anon.36 }
%union.anon.24 = type { %struct.anon.25 }
%struct.anon.25 = type { i8, %union.arm_2d_color_info_t, %union.anon.26 }
%union.arm_2d_color_info_t = type { %struct.anon.3 }
%struct.anon.3 = type { i8 }
%union.anon.26 = type { i16 }
%union.anon.33 = type { %struct.arm_2d_region_t }
%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 }
%union.anon.36 = type { ptr }

@.str.7 = external hidden unnamed_addr constant [94 x i8], align 1
@.str.17 = external hidden unnamed_addr constant [17 x i8], align 1
@__PRETTY_FUNCTION__.arm_2d_tile_region_diff = external hidden unnamed_addr constant [106 x i8], align 1
@.str.18 = external hidden unnamed_addr constant [20 x i8], align 1
@.str.19 = external hidden unnamed_addr constant [17 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
declare dso_local ptr @arm_2d_tile_get_absolute_location(ptr noundef nonnull, ptr noundef nonnull) #2

; Function Attrs: nounwind uwtable
define dso_local ptr @arm_2d_tile_region_diff(ptr noundef nonnull %0, ptr noundef nonnull %1, ptr noundef nonnull %2) #2 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca %struct.arm_2d_location_t, align 2
  %9 = alloca %struct.arm_2d_location_t, align 2
  %10 = alloca i32, align 4
  store ptr %0, ptr %5, align 8, !tbaa !5
  store ptr %1, ptr %6, align 8, !tbaa !5
  store ptr %2, ptr %7, align 8, !tbaa !5
  %11 = load ptr, ptr %5, align 8, !tbaa !5
  %12 = icmp ne ptr null, %11
  br i1 %12, label %13, label %14

13:                                               ; preds = %3
  br label %15

14:                                               ; preds = %3
  call void @__assert_fail(ptr noundef @.str.17, ptr noundef @.str.7, i32 noundef 766, ptr noundef @__PRETTY_FUNCTION__.arm_2d_tile_region_diff) #3
  unreachable

15:                                               ; preds = %13
  %16 = load ptr, ptr %6, align 8, !tbaa !5
  %17 = icmp ne ptr null, %16
  br i1 %17, label %18, label %19

18:                                               ; preds = %15
  br label %20

19:                                               ; preds = %15
  call void @__assert_fail(ptr noundef @.str.18, ptr noundef @.str.7, i32 noundef 767, ptr noundef @__PRETTY_FUNCTION__.arm_2d_tile_region_diff) #3
  unreachable

20:                                               ; preds = %18
  %21 = load ptr, ptr %7, align 8, !tbaa !5
  %22 = icmp ne ptr null, %21
  br i1 %22, label %23, label %24

23:                                               ; preds = %20
  br label %25

24:                                               ; preds = %20
  call void @__assert_fail(ptr noundef @.str.19, ptr noundef @.str.7, i32 noundef 768, ptr noundef @__PRETTY_FUNCTION__.arm_2d_tile_region_diff) #3
  unreachable

25:                                               ; preds = %23
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #4
  %26 = load ptr, ptr %5, align 8, !tbaa !5
  %27 = getelementptr inbounds %struct.arm_2d_tile_t, ptr %26, i32 0, i32 1
  %28 = getelementptr inbounds %struct.arm_2d_region_t, ptr %27, i32 0, i32 1
  %29 = getelementptr inbounds %struct.arm_2d_size_t, ptr %28, i32 0, i32 0
  %30 = load i16, ptr %29, align 4, !tbaa !9
  %31 = sext i16 %30 to i32
  %32 = load ptr, ptr %6, align 8, !tbaa !5
  %33 = getelementptr inbounds %struct.arm_2d_tile_t, ptr %32, i32 0, i32 1
  %34 = getelementptr inbounds %struct.arm_2d_region_t, ptr %33, i32 0, i32 1
  %35 = getelementptr inbounds %struct.arm_2d_size_t, ptr %34, i32 0, i32 0
  %36 = load i16, ptr %35, align 4, !tbaa !9
  %37 = sext i16 %36 to i32
  %38 = sub nsw i32 %31, %37
  %39 = trunc i32 %38 to i16
  %40 = load ptr, ptr %7, align 8, !tbaa !5
  %41 = getelementptr inbounds %struct.arm_2d_region_t, ptr %40, i32 0, i32 1
  %42 = getelementptr inbounds %struct.arm_2d_size_t, ptr %41, i32 0, i32 0
  store i16 %39, ptr %42, align 2, !tbaa !9
  %43 = load ptr, ptr %5, align 8, !tbaa !5
  %44 = getelementptr inbounds %struct.arm_2d_tile_t, ptr %43, i32 0, i32 1
  %45 = getelementptr inbounds %struct.arm_2d_region_t, ptr %44, i32 0, i32 1
  %46 = getelementptr inbounds %struct.arm_2d_size_t, ptr %45, i32 0, i32 1
  %47 = load i16, ptr %46, align 2, !tbaa !9
  %48 = sext i16 %47 to i32
  %49 = load ptr, ptr %6, align 8, !tbaa !5
  %50 = getelementptr inbounds %struct.arm_2d_tile_t, ptr %49, i32 0, i32 1
  %51 = getelementptr inbounds %struct.arm_2d_region_t, ptr %50, i32 0, i32 1
  %52 = getelementptr inbounds %struct.arm_2d_size_t, ptr %51, i32 0, i32 1
  %53 = load i16, ptr %52, align 2, !tbaa !9
  %54 = sext i16 %53 to i32
  %55 = sub nsw i32 %48, %54
  %56 = trunc i32 %55 to i16
  %57 = load ptr, ptr %7, align 8, !tbaa !5
  %58 = getelementptr inbounds %struct.arm_2d_region_t, ptr %57, i32 0, i32 1
  %59 = getelementptr inbounds %struct.arm_2d_size_t, ptr %58, i32 0, i32 1
  store i16 %56, ptr %59, align 2, !tbaa !9
  %60 = load ptr, ptr %5, align 8, !tbaa !5
  %61 = call ptr @arm_2d_tile_get_absolute_location(ptr noundef %60, ptr noundef %8)
  store ptr %61, ptr %5, align 8, !tbaa !5
  %62 = load ptr, ptr %6, align 8, !tbaa !5
  %63 = call ptr @arm_2d_tile_get_absolute_location(ptr noundef %62, ptr noundef %9)
  store ptr %63, ptr %6, align 8, !tbaa !5
  %64 = load ptr, ptr %5, align 8, !tbaa !5
  %65 = load ptr, ptr %6, align 8, !tbaa !5
  %66 = icmp ne ptr %64, %65
  br i1 %66, label %67, label %68

67:                                               ; preds = %25
  store ptr null, ptr %4, align 8
  store i32 1, ptr %10, align 4
  br label %92

68:                                               ; preds = %25
  %69 = getelementptr inbounds %struct.arm_2d_location_t, ptr %8, i32 0, i32 0
  %70 = load i16, ptr %69, align 2, !tbaa !10
  %71 = sext i16 %70 to i32
  %72 = getelementptr inbounds %struct.arm_2d_location_t, ptr %9, i32 0, i32 0
  %73 = load i16, ptr %72, align 2, !tbaa !10
  %74 = sext i16 %73 to i32
  %75 = sub nsw i32 %71, %74
  %76 = trunc i32 %75 to i16
  %77 = load ptr, ptr %7, align 8, !tbaa !5
  %78 = getelementptr inbounds %struct.arm_2d_region_t, ptr %77, i32 0, i32 0
  %79 = getelementptr inbounds %struct.arm_2d_location_t, ptr %78, i32 0, i32 0
  store i16 %76, ptr %79, align 2, !tbaa !9
  %80 = getelementptr inbounds %struct.arm_2d_location_t, ptr %8, i32 0, i32 1
  %81 = load i16, ptr %80, align 2, !tbaa !13
  %82 = sext i16 %81 to i32
  %83 = getelementptr inbounds %struct.arm_2d_location_t, ptr %9, i32 0, i32 1
  %84 = load i16, ptr %83, align 2, !tbaa !13
  %85 = sext i16 %84 to i32
  %86 = sub nsw i32 %82, %85
  %87 = trunc i32 %86 to i16
  %88 = load ptr, ptr %7, align 8, !tbaa !5
  %89 = getelementptr inbounds %struct.arm_2d_region_t, ptr %88, i32 0, i32 0
  %90 = getelementptr inbounds %struct.arm_2d_location_t, ptr %89, i32 0, i32 1
  store i16 %87, ptr %90, align 2, !tbaa !9
  %91 = load ptr, ptr %7, align 8, !tbaa !5
  store ptr %91, ptr %4, align 8
  store i32 1, ptr %10, align 4
  br label %92

92:                                               ; preds = %68, %67
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #4
  %93 = load ptr, ptr %4, align 8
  ret ptr %93
}

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 = !{!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"

%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 ptr @arm_2d_tile_get_absolute_location(ptr noundef nonnull, ptr noundef nonnull) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local noundef ptr @arm_2d_tile_region_diff(ptr noundef nonnull %0, ptr noundef nonnull %1, ptr noundef nonnull writeonly %2) local_unnamed_addr #1 {
  %4 = alloca %struct.arm_2d_location_t, align 4
  %5 = alloca %struct.arm_2d_location_t, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %4) #2
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %5) #2
  %6 = getelementptr inbounds i8, ptr %0, i64 8
  %7 = load i16, ptr %6, align 4, !tbaa !5
  %8 = getelementptr inbounds i8, ptr %1, i64 8
  %9 = load i16, ptr %8, align 4, !tbaa !5
  %10 = sub i16 %7, %9
  %11 = getelementptr inbounds i8, ptr %2, i64 4
  store i16 %10, ptr %11, align 2, !tbaa !5
  %12 = getelementptr inbounds i8, ptr %0, i64 10
  %13 = load i16, ptr %12, align 2, !tbaa !5
  %14 = getelementptr inbounds i8, ptr %1, i64 10
  %15 = load i16, ptr %14, align 2, !tbaa !5
  %16 = sub i16 %13, %15
  %17 = getelementptr inbounds i8, ptr %2, i64 6
  store i16 %16, ptr %17, align 2, !tbaa !5
  %18 = call ptr @arm_2d_tile_get_absolute_location(ptr noundef %0, ptr noundef %4)
  %19 = call ptr @arm_2d_tile_get_absolute_location(ptr noundef %1, ptr noundef %5)
  %.not = icmp eq ptr %18, %19
  br i1 %.not, label %20, label %24

20:                                               ; preds = %3
  %21 = load <2 x i16>, ptr %4, align 4, !tbaa !8
  %22 = load <2 x i16>, ptr %5, align 4, !tbaa !8
  %23 = sub <2 x i16> %21, %22
  store <2 x i16> %23, ptr %2, align 2, !tbaa !5
  br label %24

24:                                               ; preds = %3, %20
  %.0 = phi ptr [ %2, %20 ], [ null, %3 ]
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %5) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %4) #2
  ret ptr %.0
}

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: EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,SLPVectorizerPass,SROAPass,SimplifyCFGPass