; 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.14 = external hidden unnamed_addr constant [17 x i8], align 1
@.str.15 = external hidden unnamed_addr constant [20 x i8], align 1
@__PRETTY_FUNCTION__.arm_2d_tile_shape_compare = external hidden unnamed_addr constant [85 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_root(ptr noundef nonnull, ptr noundef, ptr noundef) #2

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

11:                                               ; preds = %2
  br label %13

12:                                               ; preds = %2
  call void @__assert_fail(ptr noundef @.str.14, ptr noundef @.str.7, i32 noundef 710, ptr noundef @__PRETTY_FUNCTION__.arm_2d_tile_shape_compare) #3
  unreachable

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

16:                                               ; preds = %13
  br label %18

17:                                               ; preds = %13
  call void @__assert_fail(ptr noundef @.str.15, ptr noundef @.str.7, i32 noundef 711, ptr noundef @__PRETTY_FUNCTION__.arm_2d_tile_shape_compare) #3
  unreachable

18:                                               ; preds = %16
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #4
  %19 = load ptr, ptr %4, align 8, !tbaa !5
  %20 = call ptr @arm_2d_tile_get_root(ptr noundef %19, ptr noundef %6, ptr noundef null)
  store ptr %20, ptr %4, align 8, !tbaa !5
  %21 = load ptr, ptr %5, align 8, !tbaa !5
  %22 = call ptr @arm_2d_tile_get_root(ptr noundef %21, ptr noundef %7, ptr noundef null)
  store ptr %22, ptr %5, align 8, !tbaa !5
  %23 = load ptr, ptr %4, align 8, !tbaa !5
  %24 = icmp eq ptr null, %23
  br i1 %24, label %25, label %30

25:                                               ; preds = %18
  %26 = load ptr, ptr %5, align 8, !tbaa !5
  %27 = icmp ne ptr null, %26
  br i1 %27, label %28, label %29

28:                                               ; preds = %25
  store i32 -1, ptr %3, align 4
  store i32 1, ptr %8, align 4
  br label %79

29:                                               ; preds = %25
  store i32 0, ptr %3, align 4
  store i32 1, ptr %8, align 4
  br label %79

30:                                               ; preds = %18
  %31 = load ptr, ptr %5, align 8, !tbaa !5
  %32 = icmp eq ptr null, %31
  br i1 %32, label %33, label %34

33:                                               ; preds = %30
  store i32 1, ptr %3, align 4
  store i32 1, ptr %8, align 4
  br label %79

34:                                               ; preds = %30
  br label %35

35:                                               ; preds = %34
  %36 = getelementptr inbounds %struct.arm_2d_region_t, ptr %6, i32 0, i32 1
  %37 = getelementptr inbounds %struct.arm_2d_size_t, ptr %36, i32 0, i32 0
  %38 = load i16, ptr %37, align 2, !tbaa !9
  %39 = sext i16 %38 to i32
  %40 = getelementptr inbounds %struct.arm_2d_region_t, ptr %7, i32 0, i32 1
  %41 = getelementptr inbounds %struct.arm_2d_size_t, ptr %40, i32 0, i32 0
  %42 = load i16, ptr %41, align 2, !tbaa !9
  %43 = sext i16 %42 to i32
  %44 = icmp slt i32 %39, %43
  br i1 %44, label %45, label %46

45:                                               ; preds = %35
  store i32 -1, ptr %3, align 4
  store i32 1, ptr %8, align 4
  br label %79

46:                                               ; preds = %35
  %47 = getelementptr inbounds %struct.arm_2d_region_t, ptr %6, i32 0, i32 1
  %48 = getelementptr inbounds %struct.arm_2d_size_t, ptr %47, i32 0, i32 1
  %49 = load i16, ptr %48, align 2, !tbaa !9
  %50 = sext i16 %49 to i32
  %51 = getelementptr inbounds %struct.arm_2d_region_t, ptr %7, 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 = icmp slt i32 %50, %54
  br i1 %55, label %56, label %57

56:                                               ; preds = %46
  store i32 -1, ptr %3, align 4
  store i32 1, ptr %8, align 4
  br label %79

57:                                               ; preds = %46
  %58 = getelementptr inbounds %struct.arm_2d_region_t, ptr %6, i32 0, i32 1
  %59 = getelementptr inbounds %struct.arm_2d_size_t, ptr %58, i32 0, i32 0
  %60 = load i16, ptr %59, align 2, !tbaa !9
  %61 = sext i16 %60 to i32
  %62 = getelementptr inbounds %struct.arm_2d_region_t, ptr %7, i32 0, i32 1
  %63 = getelementptr inbounds %struct.arm_2d_size_t, ptr %62, i32 0, i32 0
  %64 = load i16, ptr %63, align 2, !tbaa !9
  %65 = sext i16 %64 to i32
  %66 = icmp eq i32 %61, %65
  br i1 %66, label %67, label %78

67:                                               ; preds = %57
  %68 = getelementptr inbounds %struct.arm_2d_region_t, ptr %6, i32 0, i32 1
  %69 = getelementptr inbounds %struct.arm_2d_size_t, ptr %68, i32 0, i32 1
  %70 = load i16, ptr %69, align 2, !tbaa !9
  %71 = sext i16 %70 to i32
  %72 = getelementptr inbounds %struct.arm_2d_region_t, ptr %7, i32 0, i32 1
  %73 = getelementptr inbounds %struct.arm_2d_size_t, ptr %72, i32 0, i32 1
  %74 = load i16, ptr %73, align 2, !tbaa !9
  %75 = sext i16 %74 to i32
  %76 = icmp eq i32 %71, %75
  br i1 %76, label %77, label %78

77:                                               ; preds = %67
  store i32 0, ptr %3, align 4
  store i32 1, ptr %8, align 4
  br label %79

78:                                               ; preds = %67, %57
  store i32 1, ptr %3, align 4
  store i32 1, ptr %8, align 4
  br label %79

79:                                               ; preds = %78, %77, %56, %45, %33, %29, %28
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #4
  %80 = load i32, ptr %3, align 4
  ret i32 %80
}

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}


; 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_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 }

; 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_root(ptr noundef nonnull, ptr noundef, ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local range(i32 -1, 2) i32 @arm_2d_tile_shape_compare(ptr noundef nonnull %0, ptr noundef nonnull %1) local_unnamed_addr #1 {
  %3 = alloca %struct.arm_2d_region_t, align 2
  %4 = alloca %struct.arm_2d_region_t, align 2
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %3) #2
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %4) #2
  %5 = call ptr @arm_2d_tile_get_root(ptr noundef %0, ptr noundef nonnull %3, ptr noundef null)
  %6 = call ptr @arm_2d_tile_get_root(ptr noundef %1, ptr noundef nonnull %4, ptr noundef null)
  %7 = icmp eq ptr %5, null
  br i1 %7, label %8, label %9

8:                                                ; preds = %2
  %.not = icmp ne ptr %6, null
  %. = sext i1 %.not to i32
  br label %26

9:                                                ; preds = %2
  %10 = icmp eq ptr %6, null
  br i1 %10, label %26, label %11

11:                                               ; preds = %9
  %12 = getelementptr inbounds i8, ptr %3, i64 4
  %13 = load i16, ptr %12, align 2, !tbaa !5
  %14 = getelementptr inbounds i8, ptr %4, i64 4
  %15 = load i16, ptr %14, align 2, !tbaa !5
  %16 = icmp slt i16 %13, %15
  br i1 %16, label %26, label %17

17:                                               ; preds = %11
  %18 = getelementptr inbounds i8, ptr %3, i64 6
  %19 = load i16, ptr %18, align 2, !tbaa !5
  %20 = getelementptr inbounds i8, ptr %4, i64 6
  %21 = load i16, ptr %20, align 2, !tbaa !5
  %22 = icmp slt i16 %19, %21
  br i1 %22, label %26, label %23

23:                                               ; preds = %17
  %24 = icmp ne i16 %13, %15
  %25 = icmp ne i16 %19, %21
  %or.cond.not = or i1 %24, %25
  %spec.select = zext i1 %or.cond.not to i32
  br label %26

26:                                               ; preds = %23, %17, %11, %9, %8
  %.0 = phi i32 [ %., %8 ], [ 1, %9 ], [ -1, %11 ], [ -1, %17 ], [ %spec.select, %23 ]
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %4) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #2
  ret i32 %.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"}


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