; LLVM IR from ARM-software/Arm-2D :: Helper/Source/arm_2d_helper_pfb.ll_ (arm_2d_helper_pfb_rotate180_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_size_t = type { i16, i16 }
%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 }
%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_rotate180_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
define dso_local ptr @__arm_2d_helper_pfb_rotate180_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 [1 x %struct.arm_2d_size_t], align 2
  %12 = 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
  %13 = load ptr, ptr %4, align 8, !tbaa !5
  %14 = icmp ne ptr null, %13
  br i1 %14, label %15, label %16

15:                                               ; preds = %3
  br label %17

16:                                               ; preds = %3
  call void @__assert_fail(ptr noundef @.str.17, ptr noundef @.str.1, i32 noundef 3892, ptr noundef @__PRETTY_FUNCTION__.__arm_2d_helper_pfb_rotate180_c8bit) #5
  unreachable

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

20:                                               ; preds = %17
  br label %22

21:                                               ; preds = %17
  call void @__assert_fail(ptr noundef @.str.18, ptr noundef @.str.1, i32 noundef 3893, ptr noundef @__PRETTY_FUNCTION__.__arm_2d_helper_pfb_rotate180_c8bit) #5
  unreachable

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

declare void @__arm_2d_impl_c8bit_copy_xy_mirror(ptr noundef, i16 noundef signext, ptr noundef, i16 noundef signext, ptr noundef) #4

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 = { "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 #5 = { noreturn nounwind }
attributes #6 = { 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 = !{!13, !11, i64 0}
!13 = !{!"arm_2d_size_t", !11, i64 0, !11, i64 2}
!14 = !{!13, !11, i64 2}
!15 = !{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}
!16 = !{!17, !6, i64 0}
!17 = !{!"arm_2d_pfb_t", !6, i64 0, !6, i64 8, !18, i64 16, !19, i64 40, !19, i64 43, !19, i64 43}
!18 = !{!"arm_2d_tile_t", !7, i64 0, !7, i64 4, !7, i64 16}
!19 = !{!"int", !7, i64 0}
!20 = !{!21, !11, i64 0}
!21 = !{!"arm_2d_location_t", !11, i64 0, !11, i64 2}
!22 = !{!21, !11, i64 2}
!23 = !{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"

%struct.arm_2d_size_t = type { i16, i16 }

; 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
define dso_local noundef nonnull ptr @__arm_2d_helper_pfb_rotate180_c8bit(ptr nocapture noundef nonnull readonly %0, ptr noundef nonnull returned %1, ptr nocapture noundef nonnull readonly %2) local_unnamed_addr #1 {
  %4 = alloca [1 x %struct.arm_2d_size_t], align 2
  %5 = getelementptr inbounds i8, ptr %0, i64 32
  %6 = load ptr, ptr %5, align 8, !tbaa !5
  %7 = getelementptr inbounds i8, ptr %1, i64 32
  %8 = load ptr, ptr %7, align 8, !tbaa !5
  %9 = getelementptr inbounds i8, ptr %0, i64 20
  %10 = getelementptr inbounds i8, ptr %0, i64 24
  %11 = getelementptr inbounds i8, ptr %4, i64 2
  %12 = getelementptr inbounds i8, ptr %1, i64 20
  %13 = load <2 x i16>, ptr %10, align 4, !tbaa !5
  %14 = extractelement <2 x i16> %13, i64 0
  store i16 %14, ptr %4, align 2, !tbaa !8
  %15 = extractelement <2 x i16> %13, i64 1
  store i16 %15, ptr %11, align 2, !tbaa !11
  call void @__arm_2d_impl_c8bit_copy_xy_mirror(ptr noundef %6, i16 noundef signext %14, ptr noundef %8, i16 noundef signext %14, ptr noundef nonnull %4) #3
  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 !12
  store ptr %8, ptr %7, align 8, !tbaa !5
  store ptr null, ptr %1, align 8, !tbaa !15
  %16 = load <2 x i16>, ptr %2, align 2, !tbaa !19
  %17 = load <2 x i16>, ptr %9, align 4, !tbaa !5
  %18 = add <2 x i16> %13, %17
  %19 = sub <2 x i16> %16, %18
  store <2 x i16> %19, ptr %12, align 4, !tbaa !19
  ret ptr %1
}

declare void @__arm_2d_impl_c8bit_copy_xy_mirror(ptr noundef, i16 noundef signext, ptr noundef, i16 noundef signext, ptr noundef) local_unnamed_addr #2

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


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