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

; 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_helper_3fb_t = type { %struct.anon.31 }
%struct.anon.31 = type { %struct.arm_2d_helper_3fb_cfg_t, %struct.anon.32 }
%struct.arm_2d_helper_3fb_cfg_t = type { %struct.arm_2d_size_t, i8, [3 x i64], %struct.arm_2d_helper_2d_copy_evt_t, %struct.arm_2d_helper_dma_copy_evt_t }
%struct.arm_2d_size_t = type { i16, i16 }
%struct.arm_2d_helper_2d_copy_evt_t = type { ptr, ptr }
%struct.arm_2d_helper_dma_copy_evt_t = type { ptr, ptr }
%struct.anon.32 = type { i8, [3 x i8], i64, i8 }

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

12:                                               ; preds = %1
  br label %14

13:                                               ; preds = %1
  call void @__assert_fail(ptr noundef @.str, ptr noundef @.str.1, i32 noundef 3260, ptr noundef @__PRETTY_FUNCTION__.arm_2d_helper_3fb_get_flush_pointer) #3
  unreachable

14:                                               ; preds = %12
  call void @llvm.lifetime.start.p0(i64 1, ptr %3) #4
  call void @llvm.lifetime.start.p0(i64 1, ptr %4) #4
  call void @llvm.lifetime.start.p0(i64 1, ptr %5) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #4
  store i32 0, ptr %6, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #4
  store ptr null, ptr %7, align 8, !tbaa !5
  br label %15

15:                                               ; preds = %20, %14
  %16 = load ptr, ptr %7, align 8, !tbaa !5
  %17 = getelementptr inbounds i32, ptr %16, i32 1
  store ptr %17, ptr %7, align 8, !tbaa !5
  %18 = icmp eq ptr %16, null
  br i1 %18, label %20, label %19

19:                                               ; preds = %15
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #4
  br label %38

20:                                               ; preds = %15
  %21 = load ptr, ptr %2, align 8, !tbaa !5
  %22 = getelementptr inbounds %struct.arm_2d_helper_3fb_t, ptr %21, i32 0, i32 0
  %23 = getelementptr inbounds %struct.anon.31, ptr %22, i32 0, i32 1
  %24 = load i8, ptr %23, align 8
  %25 = lshr i8 %24, 2
  %26 = and i8 %25, 3
  store i8 %26, ptr %3, align 1, !tbaa !11
  %27 = load ptr, ptr %2, align 8, !tbaa !5
  %28 = getelementptr inbounds %struct.arm_2d_helper_3fb_t, ptr %27, i32 0, i32 0
  %29 = getelementptr inbounds %struct.anon.31, ptr %28, i32 0, i32 1
  %30 = load i8, ptr %29, align 8
  %31 = lshr i8 %30, 4
  %32 = and i8 %31, 3
  store i8 %32, ptr %4, align 1, !tbaa !11
  %33 = load ptr, ptr %2, align 8, !tbaa !5
  %34 = getelementptr inbounds %struct.arm_2d_helper_3fb_t, ptr %33, i32 0, i32 0
  %35 = getelementptr inbounds %struct.anon.31, ptr %34, i32 0, i32 1
  %36 = load i8, ptr %35, align 8
  %37 = lshr i8 %36, 6
  store i8 %37, ptr %5, align 1, !tbaa !11
  br label %15, !llvm.loop !12

38:                                               ; preds = %19
  %39 = load i8, ptr %4, align 1, !tbaa !11
  %40 = zext i8 %39 to i32
  %41 = icmp ne i32 3, %40
  br i1 %41, label %42, label %92

42:                                               ; preds = %38
  %43 = load i8, ptr %5, align 1, !tbaa !11
  %44 = zext i8 %43 to i32
  %45 = icmp eq i32 3, %44
  br i1 %45, label %46, label %92

46:                                               ; preds = %42
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #4
  store i32 0, ptr %8, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #4
  store ptr null, ptr %9, align 8, !tbaa !5
  br label %47

47:                                               ; preds = %52, %46
  %48 = load ptr, ptr %9, align 8, !tbaa !5
  %49 = getelementptr inbounds i32, ptr %48, i32 1
  store ptr %49, ptr %9, align 8, !tbaa !5
  %50 = icmp eq ptr %48, null
  br i1 %50, label %52, label %51

51:                                               ; preds = %47
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #4
  br label %91

52:                                               ; preds = %47
  %53 = load ptr, ptr %2, align 8, !tbaa !5
  %54 = getelementptr inbounds %struct.arm_2d_helper_3fb_t, ptr %53, i32 0, i32 0
  %55 = getelementptr inbounds %struct.anon.31, ptr %54, i32 0, i32 1
  %56 = getelementptr inbounds %struct.anon.32, ptr %55, i32 0, i32 1
  %57 = load i8, ptr %3, align 1, !tbaa !11
  %58 = zext i8 %57 to i64
  %59 = getelementptr inbounds [3 x i8], ptr %56, i64 0, i64 %58
  store i8 2, ptr %59, align 1, !tbaa !11
  %60 = load i8, ptr %3, align 1, !tbaa !11
  %61 = load ptr, ptr %2, align 8, !tbaa !5
  %62 = getelementptr inbounds %struct.arm_2d_helper_3fb_t, ptr %61, i32 0, i32 0
  %63 = getelementptr inbounds %struct.anon.31, ptr %62, i32 0, i32 1
  %64 = load i8, ptr %63, align 8
  %65 = and i8 %60, 3
  %66 = shl i8 %65, 6
  %67 = and i8 %64, 63
  %68 = or i8 %67, %66
  store i8 %68, ptr %63, align 8
  %69 = load ptr, ptr %2, align 8, !tbaa !5
  %70 = getelementptr inbounds %struct.arm_2d_helper_3fb_t, ptr %69, i32 0, i32 0
  %71 = getelementptr inbounds %struct.anon.31, ptr %70, i32 0, i32 1
  %72 = getelementptr inbounds %struct.anon.32, ptr %71, i32 0, i32 1
  %73 = load i8, ptr %4, align 1, !tbaa !11
  %74 = zext i8 %73 to i64
  %75 = getelementptr inbounds [3 x i8], ptr %72, i64 0, i64 %74
  store i8 6, ptr %75, align 1, !tbaa !11
  %76 = load i8, ptr %4, align 1, !tbaa !11
  %77 = load ptr, ptr %2, align 8, !tbaa !5
  %78 = getelementptr inbounds %struct.arm_2d_helper_3fb_t, ptr %77, i32 0, i32 0
  %79 = getelementptr inbounds %struct.anon.31, ptr %78, i32 0, i32 1
  %80 = load i8, ptr %79, align 8
  %81 = and i8 %76, 3
  %82 = shl i8 %81, 2
  %83 = and i8 %80, -13
  %84 = or i8 %83, %82
  store i8 %84, ptr %79, align 8
  %85 = load ptr, ptr %2, align 8, !tbaa !5
  %86 = getelementptr inbounds %struct.arm_2d_helper_3fb_t, ptr %85, i32 0, i32 0
  %87 = getelementptr inbounds %struct.anon.31, ptr %86, i32 0, i32 1
  %88 = load i8, ptr %87, align 8
  %89 = and i8 %88, -49
  %90 = or i8 %89, 48
  store i8 %90, ptr %87, align 8
  br label %47, !llvm.loop !14

91:                                               ; preds = %51
  br label %92

92:                                               ; preds = %91, %42, %38
  %93 = load ptr, ptr %2, align 8, !tbaa !5
  %94 = getelementptr inbounds %struct.arm_2d_helper_3fb_t, ptr %93, i32 0, i32 0
  %95 = getelementptr inbounds %struct.anon.31, ptr %94, i32 0, i32 0
  %96 = getelementptr inbounds %struct.arm_2d_helper_3fb_cfg_t, ptr %95, i32 0, i32 2
  %97 = load ptr, ptr %2, align 8, !tbaa !5
  %98 = getelementptr inbounds %struct.arm_2d_helper_3fb_t, ptr %97, i32 0, i32 0
  %99 = getelementptr inbounds %struct.anon.31, ptr %98, i32 0, i32 1
  %100 = load i8, ptr %99, align 8
  %101 = lshr i8 %100, 2
  %102 = and i8 %101, 3
  %103 = zext i8 %102 to i64
  %104 = getelementptr inbounds [3 x i64], ptr %96, i64 0, i64 %103
  %105 = load i64, ptr %104, align 8, !tbaa !15
  %106 = inttoptr i64 %105 to ptr
  call void @llvm.lifetime.end.p0(i64 1, ptr %5) #4
  call void @llvm.lifetime.end.p0(i64 1, ptr %4) #4
  call void @llvm.lifetime.end.p0(i64 1, ptr %3) #4
  ret ptr %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 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 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!7, !7, i64 0}
!12 = distinct !{!12, !13}
!13 = !{!"llvm.loop.mustprogress"}
!14 = distinct !{!14, !13}
!15 = !{!16, !16, i64 0}
!16 = !{!"long", !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"

; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: readwrite) uwtable
define dso_local ptr @arm_2d_helper_3fb_get_flush_pointer(ptr nocapture noundef nonnull %0) local_unnamed_addr #0 {
  %2 = getelementptr inbounds i8, ptr %0, i64 64
  %3 = load i8, ptr %2, align 8
  %4 = lshr i8 %3, 2
  %5 = lshr i8 %3, 4
  %6 = and i8 %4, 3
  %7 = and i8 %5, 3
  %8 = icmp ne i8 %7, 3
  %9 = icmp ugt i8 %3, -65
  %or.cond = and i1 %8, %9
  br i1 %or.cond, label %.preheader, label %20

.preheader:                                       ; preds = %1
  %10 = getelementptr inbounds i8, ptr %0, i64 65
  %11 = zext nneg i8 %6 to i64
  %12 = getelementptr inbounds [3 x i8], ptr %10, i64 0, i64 %11
  %13 = zext nneg i8 %7 to i64
  %14 = getelementptr inbounds [3 x i8], ptr %10, i64 0, i64 %13
  store i8 2, ptr %12, align 1, !tbaa !5
  store i8 6, ptr %14, align 1, !tbaa !5
  %15 = shl i8 %4, 6
  %16 = shl nuw nsw i8 %5, 2
  %17 = and i8 %3, 3
  %18 = or disjoint i8 %17, %15
  %19 = or disjoint i8 %16, %18
  store i8 %19, ptr %2, align 8
  %.pre25 = and i8 %5, 3
  br label %20

20:                                               ; preds = %.preheader, %1
  %.pre-phi26 = phi i8 [ %.pre25, %.preheader ], [ %6, %1 ]
  %21 = getelementptr inbounds i8, ptr %0, i64 8
  %22 = zext nneg i8 %.pre-phi26 to i64
  %23 = getelementptr inbounds [3 x i64], ptr %21, i64 0, i64 %22
  %24 = load i64, ptr %23, align 8, !tbaa !8
  %25 = inttoptr i64 %24 to ptr
  ret ptr %25
}

attributes #0 = { mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: readwrite) 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 = !{!9, !9, i64 0}
!9 = !{!"long", !6, i64 0}


; Effective O3 passes: BDCEPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,LCSSAPass,LICMPass,LoopRotatePass,LoopSimplifyPass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass