; 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.2 = external hidden unnamed_addr constant [15 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [94 x i8], align 1
@__PRETTY_FUNCTION__.arm_2d_get_absolute_location = external hidden unnamed_addr constant [96 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 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
define dso_local i32 @arm_2d_get_absolute_location(ptr noundef nonnull %0, i32 %1, i1 noundef zeroext %2) #2 {
  %4 = alloca %struct.arm_2d_location_t, align 2
  %5 = alloca %struct.arm_2d_location_t, align 2
  %6 = alloca ptr, align 8
  %7 = alloca i8, align 1
  store i32 %1, ptr %5, align 2
  store ptr %0, ptr %6, align 8, !tbaa !5
  %8 = zext i1 %2 to i8
  store i8 %8, ptr %7, align 1, !tbaa !9
  %9 = load ptr, ptr %6, align 8, !tbaa !5
  %10 = icmp ne ptr null, %9
  br i1 %10, label %11, label %12

11:                                               ; preds = %3
  br label %13

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

13:                                               ; preds = %11
  %14 = load i8, ptr %7, align 1, !tbaa !9, !range !11, !noundef !12
  %15 = trunc i8 %14 to i1
  br i1 %15, label %16, label %65

16:                                               ; preds = %13
  br label %17

17:                                               ; preds = %63, %16
  %18 = load ptr, ptr %6, align 8, !tbaa !5
  %19 = getelementptr inbounds %struct.arm_2d_tile_t, ptr %18, i32 0, i32 0
  %20 = load i8, ptr %19, align 8
  %21 = and i8 %20, 1
  %22 = icmp ne i8 %21, 0
  br i1 %22, label %31, label %23

23:                                               ; preds = %17
  %24 = load ptr, ptr %6, align 8, !tbaa !5
  %25 = getelementptr inbounds %struct.arm_2d_tile_t, ptr %24, i32 0, i32 0
  %26 = load i8, ptr %25, align 8
  %27 = lshr i8 %26, 4
  %28 = and i8 %27, 1
  %29 = icmp ne i8 %28, 0
  %30 = xor i1 %29, true
  br label %31

31:                                               ; preds = %23, %17
  %32 = phi i1 [ false, %17 ], [ %30, %23 ]
  br i1 %32, label %33, label %64

33:                                               ; preds = %31
  %34 = load ptr, ptr %6, align 8, !tbaa !5
  %35 = getelementptr inbounds %struct.arm_2d_tile_t, ptr %34, i32 0, i32 1
  %36 = getelementptr inbounds %struct.arm_2d_region_t, ptr %35, i32 0, i32 0
  %37 = getelementptr inbounds %struct.arm_2d_location_t, ptr %36, i32 0, i32 0
  %38 = load i16, ptr %37, align 4, !tbaa !13
  %39 = sext i16 %38 to i32
  %40 = getelementptr inbounds %struct.arm_2d_location_t, ptr %5, i32 0, i32 0
  %41 = load i16, ptr %40, align 2, !tbaa !14
  %42 = sext i16 %41 to i32
  %43 = add nsw i32 %42, %39
  %44 = trunc i32 %43 to i16
  store i16 %44, ptr %40, align 2, !tbaa !14
  %45 = load ptr, ptr %6, align 8, !tbaa !5
  %46 = getelementptr inbounds %struct.arm_2d_tile_t, ptr %45, i32 0, i32 1
  %47 = getelementptr inbounds %struct.arm_2d_region_t, ptr %46, i32 0, i32 0
  %48 = getelementptr inbounds %struct.arm_2d_location_t, ptr %47, i32 0, i32 1
  %49 = load i16, ptr %48, align 2, !tbaa !13
  %50 = sext i16 %49 to i32
  %51 = getelementptr inbounds %struct.arm_2d_location_t, ptr %5, i32 0, i32 1
  %52 = load i16, ptr %51, align 2, !tbaa !17
  %53 = sext i16 %52 to i32
  %54 = add nsw i32 %53, %50
  %55 = trunc i32 %54 to i16
  store i16 %55, ptr %51, align 2, !tbaa !17
  %56 = load ptr, ptr %6, align 8, !tbaa !5
  %57 = getelementptr inbounds %struct.arm_2d_tile_t, ptr %56, i32 0, i32 2
  %58 = load ptr, ptr %57, align 8, !tbaa !13
  store ptr %58, ptr %6, align 8, !tbaa !5
  %59 = load ptr, ptr %6, align 8, !tbaa !5
  %60 = icmp ne ptr null, %59
  br i1 %60, label %61, label %62

61:                                               ; preds = %33
  br label %63

62:                                               ; preds = %33
  call void @__assert_fail(ptr noundef @.str.2, ptr noundef @.str.7, i32 noundef 876, ptr noundef @__PRETTY_FUNCTION__.arm_2d_get_absolute_location) #3
  unreachable

63:                                               ; preds = %61
  br label %17, !llvm.loop !18

64:                                               ; preds = %31
  br label %105

65:                                               ; preds = %13
  br label %66

66:                                               ; preds = %103, %65
  %67 = load ptr, ptr %6, align 8, !tbaa !5
  %68 = getelementptr inbounds %struct.arm_2d_tile_t, ptr %67, i32 0, i32 0
  %69 = load i8, ptr %68, align 8
  %70 = and i8 %69, 1
  %71 = icmp ne i8 %70, 0
  %72 = xor i1 %71, true
  br i1 %72, label %73, label %104

73:                                               ; preds = %66
  %74 = load ptr, ptr %6, align 8, !tbaa !5
  %75 = getelementptr inbounds %struct.arm_2d_tile_t, ptr %74, i32 0, i32 1
  %76 = getelementptr inbounds %struct.arm_2d_region_t, ptr %75, i32 0, i32 0
  %77 = getelementptr inbounds %struct.arm_2d_location_t, ptr %76, i32 0, i32 0
  %78 = load i16, ptr %77, align 4, !tbaa !13
  %79 = sext i16 %78 to i32
  %80 = getelementptr inbounds %struct.arm_2d_location_t, ptr %5, i32 0, i32 0
  %81 = load i16, ptr %80, align 2, !tbaa !14
  %82 = sext i16 %81 to i32
  %83 = add nsw i32 %82, %79
  %84 = trunc i32 %83 to i16
  store i16 %84, ptr %80, align 2, !tbaa !14
  %85 = load ptr, ptr %6, align 8, !tbaa !5
  %86 = getelementptr inbounds %struct.arm_2d_tile_t, ptr %85, i32 0, i32 1
  %87 = getelementptr inbounds %struct.arm_2d_region_t, ptr %86, i32 0, i32 0
  %88 = getelementptr inbounds %struct.arm_2d_location_t, ptr %87, i32 0, i32 1
  %89 = load i16, ptr %88, align 2, !tbaa !13
  %90 = sext i16 %89 to i32
  %91 = getelementptr inbounds %struct.arm_2d_location_t, ptr %5, i32 0, i32 1
  %92 = load i16, ptr %91, align 2, !tbaa !17
  %93 = sext i16 %92 to i32
  %94 = add nsw i32 %93, %90
  %95 = trunc i32 %94 to i16
  store i16 %95, ptr %91, align 2, !tbaa !17
  %96 = load ptr, ptr %6, align 8, !tbaa !5
  %97 = getelementptr inbounds %struct.arm_2d_tile_t, ptr %96, i32 0, i32 2
  %98 = load ptr, ptr %97, align 8, !tbaa !13
  store ptr %98, ptr %6, align 8, !tbaa !5
  %99 = load ptr, ptr %6, align 8, !tbaa !5
  %100 = icmp ne ptr null, %99
  br i1 %100, label %101, label %102

101:                                              ; preds = %73
  br label %103

102:                                              ; preds = %73
  call void @__assert_fail(ptr noundef @.str.2, ptr noundef @.str.7, i32 noundef 885, ptr noundef @__PRETTY_FUNCTION__.arm_2d_get_absolute_location) #3
  unreachable

103:                                              ; preds = %101
  br label %66, !llvm.loop !20

104:                                              ; preds = %66
  br label %105

105:                                              ; preds = %104, %64
  call void @llvm.memcpy.p0.p0.i64(ptr align 2 %4, ptr align 2 %5, i64 4, i1 false), !tbaa.struct !21
  %106 = load i32, ptr %4, align 2
  ret i32 %106
}

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

!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, !10, i64 0}
!10 = !{!"_Bool", !7, i64 0}
!11 = !{i8 0, i8 2}
!12 = !{}
!13 = !{!7, !7, i64 0}
!14 = !{!15, !16, i64 0}
!15 = !{!"arm_2d_location_t", !16, i64 0, !16, i64 2}
!16 = !{!"short", !7, i64 0}
!17 = !{!15, !16, i64 2}
!18 = distinct !{!18, !19}
!19 = !{!"llvm.loop.mustprogress"}
!20 = distinct !{!20, !19}
!21 = !{i64 0, i64 2, !22, i64 2, i64 2, !22}
!22 = !{!16, !16, 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"

@.str.2 = external hidden unnamed_addr constant [15 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [94 x i8], align 1
@__PRETTY_FUNCTION__.arm_2d_get_absolute_location = external hidden unnamed_addr constant [96 x i8], align 1

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

; Function Attrs: nounwind uwtable
define dso_local i32 @arm_2d_get_absolute_location(ptr nocapture noundef nonnull readonly %0, i32 %1, i1 noundef zeroext %2) local_unnamed_addr #1 {
  %.sroa.6.0.extract.shift = lshr i32 %1, 16
  %.sroa.6.0.extract.trunc = trunc nuw i32 %.sroa.6.0.extract.shift to i16
  %.sroa.0.0.extract.trunc = trunc i32 %1 to i16
  br i1 %2, label %.preheader, label %.preheader21

.preheader:                                       ; preds = %3, %6
  %.sroa.0.0 = phi i16 [ %9, %6 ], [ %.sroa.0.0.extract.trunc, %3 ]
  %.0 = phi ptr [ %14, %6 ], [ %0, %3 ]
  %.sroa.6.0 = phi i16 [ %12, %6 ], [ %.sroa.6.0.extract.trunc, %3 ]
  %4 = load i8, ptr %.0, align 8
  %5 = and i8 %4, 17
  %or.cond = icmp eq i8 %5, 0
  br i1 %or.cond, label %6, label %.critedge

6:                                                ; preds = %.preheader
  %7 = getelementptr inbounds i8, ptr %.0, i64 4
  %8 = load i16, ptr %7, align 4, !tbaa !5
  %9 = add i16 %8, %.sroa.0.0
  %10 = getelementptr inbounds i8, ptr %.0, i64 6
  %11 = load i16, ptr %10, align 2, !tbaa !5
  %12 = add i16 %11, %.sroa.6.0
  %13 = getelementptr inbounds i8, ptr %.0, i64 16
  %14 = load ptr, ptr %13, align 8, !tbaa !5
  %.not20 = icmp eq ptr %14, null
  br i1 %.not20, label %15, label %.preheader, !llvm.loop !8

15:                                               ; preds = %6
  tail call void @__assert_fail(ptr noundef nonnull @.str.2, ptr noundef nonnull @.str.7, i32 noundef 876, ptr noundef nonnull @__PRETTY_FUNCTION__.arm_2d_get_absolute_location) #2
  unreachable

.preheader21:                                     ; preds = %3, %18
  %.sroa.0.1 = phi i16 [ %21, %18 ], [ %.sroa.0.0.extract.trunc, %3 ]
  %.1 = phi ptr [ %26, %18 ], [ %0, %3 ]
  %.sroa.6.1 = phi i16 [ %24, %18 ], [ %.sroa.6.0.extract.trunc, %3 ]
  %16 = load i8, ptr %.1, align 8
  %17 = and i8 %16, 1
  %.not = icmp eq i8 %17, 0
  br i1 %.not, label %18, label %.critedge

18:                                               ; preds = %.preheader21
  %19 = getelementptr inbounds i8, ptr %.1, i64 4
  %20 = load i16, ptr %19, align 4, !tbaa !5
  %21 = add i16 %20, %.sroa.0.1
  %22 = getelementptr inbounds i8, ptr %.1, i64 6
  %23 = load i16, ptr %22, align 2, !tbaa !5
  %24 = add i16 %23, %.sroa.6.1
  %25 = getelementptr inbounds i8, ptr %.1, i64 16
  %26 = load ptr, ptr %25, align 8, !tbaa !5
  %.not17 = icmp eq ptr %26, null
  br i1 %.not17, label %27, label %.preheader21, !llvm.loop !10

27:                                               ; preds = %18
  tail call void @__assert_fail(ptr noundef nonnull @.str.2, ptr noundef nonnull @.str.7, i32 noundef 885, ptr noundef nonnull @__PRETTY_FUNCTION__.arm_2d_get_absolute_location) #2
  unreachable

.critedge:                                        ; preds = %.preheader21, %.preheader
  %.sroa.0.2 = phi i16 [ %.sroa.0.0, %.preheader ], [ %.sroa.0.1, %.preheader21 ]
  %.sroa.6.2 = phi i16 [ %.sroa.6.0, %.preheader ], [ %.sroa.6.1, %.preheader21 ]
  %.sroa.2.0.insert.ext = zext i16 %.sroa.6.2 to i32
  %.sroa.2.0.insert.shift = shl nuw i32 %.sroa.2.0.insert.ext, 16
  %.sroa.014.0.insert.ext = zext i16 %.sroa.0.2 to i32
  %.sroa.014.0.insert.insert = or disjoint i32 %.sroa.2.0.insert.shift, %.sroa.014.0.insert.ext
  ret i32 %.sroa.014.0.insert.insert
}

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 = !{!"omnipotent char", !7, i64 0}
!7 = !{!"Simple C/C++ TBAA"}
!8 = distinct !{!8, !9}
!9 = !{!"llvm.loop.mustprogress"}
!10 = distinct !{!10, !9}


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