; LLVM IR from ARM-software/Arm-2D :: Helper/Source/arm_2d_helper_pfb.ll_ (arm_2d_helper_pfb_rotate270_c8bit)

; 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_pfb_t = type { ptr, ptr, %struct.arm_2d_tile_t, i32 }
%struct.arm_2d_tile_t = type { %union.anon.8, %union.anon.19, %union.anon.20 }
%union.anon.8 = type { %struct.anon.9 }
%struct.anon.9 = type { i8, %union.arm_2d_color_info_t, %union.anon.12 }
%union.arm_2d_color_info_t = type { %struct.anon.10 }
%struct.anon.10 = type { i8 }
%union.anon.12 = type { i16 }
%union.anon.19 = type { %struct.arm_2d_region_t }
%struct.arm_2d_region_t = type { %union.anon, %union.anon.0 }
%union.anon = type { %struct.arm_2d_location_t }
%union.anon.0 = type { %struct.arm_2d_size_t }
%struct.arm_2d_size_t = type { i16, i16 }
%union.anon.20 = type { ptr }

@.str.1 = external hidden unnamed_addr constant [87 x i8], align 1
@.str.17 = external hidden unnamed_addr constant [17 x i8], align 1
@.str.18 = external hidden unnamed_addr constant [18 x i8], align 1
@__PRETTY_FUNCTION__.__arm_2d_helper_pfb_rotate270_c8bit = external hidden unnamed_addr constant [105 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: 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) #2

; Function Attrs: nounwind uwtable
declare dso_local void @__arm_2d_rotate_270_c8bit(ptr noalias noundef, ptr noalias noundef, i64 noundef, i64 noundef, i64 noundef) #3

; Function Attrs: nounwind uwtable
define dso_local ptr @__arm_2d_helper_pfb_rotate270_c8bit(ptr noundef nonnull %0, ptr noundef nonnull %1, ptr noundef nonnull %2) #3 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca i16, align 2
  %10 = alloca i16, align 2
  %11 = 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
  store ptr %2, ptr %6, align 8, !tbaa !5
  %12 = load ptr, ptr %4, align 8, !tbaa !5
  %13 = icmp ne ptr null, %12
  br i1 %13, label %14, label %15

14:                                               ; preds = %3
  br label %16

15:                                               ; preds = %3
  call void @__assert_fail(ptr noundef @.str.17, ptr noundef @.str.1, i32 noundef 3788, ptr noundef @__PRETTY_FUNCTION__.__arm_2d_helper_pfb_rotate270_c8bit) #4
  unreachable

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

19:                                               ; preds = %16
  br label %21

20:                                               ; preds = %16
  call void @__assert_fail(ptr noundef @.str.18, ptr noundef @.str.1, i32 noundef 3789, ptr noundef @__PRETTY_FUNCTION__.__arm_2d_helper_pfb_rotate270_c8bit) #4
  unreachable

21:                                               ; preds = %19
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #5
  %22 = load ptr, ptr %4, align 8, !tbaa !5
  %23 = getelementptr inbounds %struct.arm_2d_pfb_t, ptr %22, i32 0, i32 2
  %24 = getelementptr inbounds %struct.arm_2d_tile_t, ptr %23, i32 0, i32 2
  %25 = load ptr, ptr %24, align 8, !tbaa !9
  store ptr %25, ptr %7, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #5
  %26 = load ptr, ptr %5, align 8, !tbaa !5
  %27 = getelementptr inbounds %struct.arm_2d_pfb_t, ptr %26, i32 0, i32 2
  %28 = getelementptr inbounds %struct.arm_2d_tile_t, ptr %27, i32 0, i32 2
  %29 = load ptr, ptr %28, align 8, !tbaa !9
  store ptr %29, ptr %8, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 2, ptr %9) #5
  %30 = load ptr, ptr %4, align 8, !tbaa !5
  %31 = getelementptr inbounds %struct.arm_2d_pfb_t, ptr %30, i32 0, i32 2
  %32 = getelementptr inbounds %struct.arm_2d_tile_t, ptr %31, i32 0, i32 1
  %33 = getelementptr inbounds %struct.arm_2d_region_t, ptr %32, i32 0, i32 1
  %34 = getelementptr inbounds %struct.arm_2d_size_t, ptr %33, i32 0, i32 0
  %35 = load i16, ptr %34, align 4, !tbaa !9
  store i16 %35, ptr %9, align 2, !tbaa !10
  call void @llvm.lifetime.start.p0(i64 2, ptr %10) #5
  %36 = load ptr, ptr %4, align 8, !tbaa !5
  %37 = getelementptr inbounds %struct.arm_2d_pfb_t, ptr %36, i32 0, i32 2
  %38 = getelementptr inbounds %struct.arm_2d_tile_t, ptr %37, i32 0, i32 1
  %39 = getelementptr inbounds %struct.arm_2d_region_t, ptr %38, i32 0, i32 1
  %40 = getelementptr inbounds %struct.arm_2d_size_t, ptr %39, i32 0, i32 1
  %41 = load i16, ptr %40, align 2, !tbaa !9
  store i16 %41, ptr %10, align 2, !tbaa !10
  %42 = load ptr, ptr %7, align 8, !tbaa !5
  %43 = load ptr, ptr %8, align 8, !tbaa !5
  %44 = load i16, ptr %9, align 2, !tbaa !10
  %45 = sext i16 %44 to i64
  %46 = load i16, ptr %10, align 2, !tbaa !10
  %47 = sext i16 %46 to i64
  %48 = load i16, ptr %10, align 2, !tbaa !10
  %49 = sext i16 %48 to i64
  call void @__arm_2d_rotate_270_c8bit(ptr noundef %42, ptr noundef %43, i64 noundef %45, i64 noundef %47, i64 noundef %49)
  %50 = load ptr, ptr %5, align 8, !tbaa !5
  %51 = load ptr, ptr %4, align 8, !tbaa !5
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %50, ptr align 8 %51, i64 48, i1 false), !tbaa.struct !12
  %52 = load ptr, ptr %8, align 8, !tbaa !5
  %53 = load ptr, ptr %5, align 8, !tbaa !5
  %54 = getelementptr inbounds %struct.arm_2d_pfb_t, ptr %53, i32 0, i32 2
  %55 = getelementptr inbounds %struct.arm_2d_tile_t, ptr %54, i32 0, i32 2
  store ptr %52, ptr %55, align 8, !tbaa !9
  %56 = load ptr, ptr %5, align 8, !tbaa !5
  %57 = getelementptr inbounds %struct.arm_2d_pfb_t, ptr %56, i32 0, i32 0
  store ptr null, ptr %57, align 8, !tbaa !13
  %58 = load i16, ptr %10, align 2, !tbaa !10
  %59 = load ptr, ptr %5, align 8, !tbaa !5
  %60 = getelementptr inbounds %struct.arm_2d_pfb_t, ptr %59, i32 0, i32 2
  %61 = getelementptr inbounds %struct.arm_2d_tile_t, ptr %60, i32 0, i32 1
  %62 = getelementptr inbounds %struct.arm_2d_region_t, ptr %61, i32 0, i32 1
  %63 = getelementptr inbounds %struct.arm_2d_size_t, ptr %62, i32 0, i32 0
  store i16 %58, ptr %63, align 4, !tbaa !9
  %64 = load i16, ptr %9, align 2, !tbaa !10
  %65 = load ptr, ptr %5, align 8, !tbaa !5
  %66 = getelementptr inbounds %struct.arm_2d_pfb_t, ptr %65, i32 0, i32 2
  %67 = getelementptr inbounds %struct.arm_2d_tile_t, ptr %66, i32 0, i32 1
  %68 = getelementptr inbounds %struct.arm_2d_region_t, ptr %67, i32 0, i32 1
  %69 = getelementptr inbounds %struct.arm_2d_size_t, ptr %68, i32 0, i32 1
  store i16 %64, ptr %69, align 2, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #5
  %70 = getelementptr inbounds %struct.arm_2d_location_t, ptr %11, i32 0, i32 0
  %71 = load ptr, ptr %4, align 8, !tbaa !5
  %72 = getelementptr inbounds %struct.arm_2d_pfb_t, ptr %71, i32 0, i32 2
  %73 = getelementptr inbounds %struct.arm_2d_tile_t, ptr %72, i32 0, i32 1
  %74 = getelementptr inbounds %struct.arm_2d_region_t, ptr %73, i32 0, i32 0
  %75 = getelementptr inbounds %struct.arm_2d_location_t, ptr %74, i32 0, i32 1
  %76 = load i16, ptr %75, align 2, !tbaa !9
  store i16 %76, ptr %70, align 2, !tbaa !17
  %77 = getelementptr inbounds %struct.arm_2d_location_t, ptr %11, i32 0, i32 1
  %78 = load ptr, ptr %6, align 8, !tbaa !5
  %79 = getelementptr inbounds %struct.arm_2d_size_t, ptr %78, i32 0, i32 0
  %80 = load i16, ptr %79, align 2, !tbaa !19
  %81 = sext i16 %80 to i32
  %82 = load ptr, ptr %4, align 8, !tbaa !5
  %83 = getelementptr inbounds %struct.arm_2d_pfb_t, ptr %82, i32 0, i32 2
  %84 = getelementptr inbounds %struct.arm_2d_tile_t, ptr %83, i32 0, i32 1
  %85 = getelementptr inbounds %struct.arm_2d_region_t, ptr %84, i32 0, i32 0
  %86 = getelementptr inbounds %struct.arm_2d_location_t, ptr %85, i32 0, i32 0
  %87 = load i16, ptr %86, align 4, !tbaa !9
  %88 = sext i16 %87 to i32
  %89 = load i16, ptr %9, align 2, !tbaa !10
  %90 = sext i16 %89 to i32
  %91 = add nsw i32 %88, %90
  %92 = sub nsw i32 %91, 1
  %93 = sub nsw i32 %81, %92
  %94 = sub nsw i32 %93, 1
  %95 = trunc i32 %94 to i16
  store i16 %95, ptr %77, align 2, !tbaa !21
  %96 = load ptr, ptr %5, align 8, !tbaa !5
  %97 = getelementptr inbounds %struct.arm_2d_pfb_t, ptr %96, i32 0, i32 2
  %98 = getelementptr inbounds %struct.arm_2d_tile_t, ptr %97, i32 0, i32 1
  %99 = getelementptr inbounds %struct.arm_2d_region_t, ptr %98, i32 0, i32 0
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %99, ptr align 2 %11, i64 4, i1 false), !tbaa.struct !22
  %100 = load ptr, ptr %5, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #5
  call void @llvm.lifetime.end.p0(i64 2, ptr %10) #5
  call void @llvm.lifetime.end.p0(i64 2, ptr %9) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #5
  ret ptr %100
}

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 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { 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 #4 = { noreturn nounwind }
attributes #5 = { 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, !11, i64 0}
!11 = !{!"short", !7, i64 0}
!12 = !{i64 0, i64 8, !5, i64 8, i64 8, !5, i64 16, i64 4, !9, i64 20, i64 8, !9, i64 32, i64 8, !9, i64 40, i64 4, !9}
!13 = !{!14, !6, i64 0}
!14 = !{!"arm_2d_pfb_t", !6, i64 0, !6, i64 8, !15, i64 16, !16, i64 40, !16, i64 43, !16, i64 43}
!15 = !{!"arm_2d_tile_t", !7, i64 0, !7, i64 4, !7, i64 16}
!16 = !{!"int", !7, i64 0}
!17 = !{!18, !11, i64 0}
!18 = !{!"arm_2d_location_t", !11, i64 0, !11, i64 2}
!19 = !{!20, !11, i64 0}
!20 = !{!"arm_2d_size_t", !11, i64 0, !11, i64 2}
!21 = !{!18, !11, i64 2}
!22 = !{i64 0, i64 2, !10, i64 2, i64 2, !10}


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

; Function Attrs: nounwind uwtable
declare dso_local void @__arm_2d_rotate_270_c8bit(ptr noalias noundef, ptr noalias noundef, i64 noundef, i64 noundef, i64 noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local noundef nonnull ptr @__arm_2d_helper_pfb_rotate270_c8bit(ptr nocapture noundef nonnull readonly %0, ptr noundef nonnull returned %1, ptr nocapture noundef nonnull readonly %2) local_unnamed_addr #1 {
  %4 = getelementptr inbounds i8, ptr %0, i64 32
  %5 = load ptr, ptr %4, align 8, !tbaa !5
  %6 = getelementptr inbounds i8, ptr %1, i64 32
  %7 = load ptr, ptr %6, align 8, !tbaa !5
  %8 = getelementptr inbounds i8, ptr %0, i64 20
  %9 = getelementptr inbounds i8, ptr %0, i64 24
  %10 = load i16, ptr %9, align 4, !tbaa !5
  %11 = getelementptr inbounds i8, ptr %0, i64 26
  %12 = load i16, ptr %11, align 2, !tbaa !5
  %13 = sext i16 %10 to i64
  %14 = sext i16 %12 to i64
  tail call void @__arm_2d_rotate_270_c8bit(ptr noundef %5, ptr noundef %7, i64 noundef %13, i64 noundef %14, i64 noundef %14)
  tail call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(48) %1, ptr noundef nonnull align 8 dereferenceable(48) %0, i64 48, i1 false), !tbaa.struct !8
  store ptr %7, ptr %6, align 8, !tbaa !5
  store ptr null, ptr %1, align 8, !tbaa !11
  %15 = getelementptr inbounds i8, ptr %1, i64 20
  %16 = getelementptr inbounds i8, ptr %1, i64 24
  store i16 %12, ptr %16, align 4, !tbaa !5
  %17 = getelementptr inbounds i8, ptr %1, i64 26
  store i16 %10, ptr %17, align 2, !tbaa !5
  %18 = getelementptr inbounds i8, ptr %0, i64 22
  %19 = load i16, ptr %18, align 2, !tbaa !5
  %20 = load i16, ptr %2, align 2, !tbaa !15
  %21 = load i16, ptr %8, align 4, !tbaa !5
  %22 = add i16 %10, %21
  %23 = sub i16 %20, %22
  store i16 %19, ptr %15, align 4, !tbaa !18
  %.sroa.4.0..sroa_idx = getelementptr inbounds i8, ptr %1, i64 22
  store i16 %23, ptr %.sroa.4.0..sroa_idx, align 2, !tbaa !18
  ret ptr %1
}

attributes #0 = { mustprogress nocallback nofree 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" }

!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 = !{i64 0, i64 8, !9, i64 8, i64 8, !9, i64 16, i64 4, !5, i64 20, i64 8, !5, i64 32, i64 8, !5, i64 40, i64 4, !5}
!9 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !6, i64 0}
!11 = !{!12, !10, i64 0}
!12 = !{!"arm_2d_pfb_t", !10, i64 0, !10, i64 8, !13, i64 16, !14, i64 40, !14, i64 43, !14, i64 43}
!13 = !{!"arm_2d_tile_t", !6, i64 0, !6, i64 4, !6, i64 16}
!14 = !{!"int", !6, i64 0}
!15 = !{!16, !17, i64 0}
!16 = !{!"arm_2d_size_t", !17, i64 0, !17, i64 2}
!17 = !{!"short", !6, i64 0}
!18 = !{!17, !17, i64 0}


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