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

; 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_dirty_region_transform_t = type { float, %union.anon.38, float, %struct.arm_2d_helper_dirty_region_item_t, %struct.anon.39 }
%union.anon.38 = type { float }
%struct.arm_2d_helper_dirty_region_item_t = type { %struct.anon.34, %struct.arm_2d_region_t }
%struct.anon.34 = type { ptr, ptr, %union.anon.35, %struct.arm_2d_region_t, i8, i8, i16 }
%union.anon.35 = type { [2 x %struct.arm_2d_region_t] }
%struct.arm_2d_region_t = type { %union.anon, %union.anon.0 }
%union.anon = type { %struct.arm_2d_location_t }
%struct.arm_2d_location_t = type { i16, i16 }
%union.anon.0 = type { %struct.arm_2d_size_t }
%struct.arm_2d_size_t = type { i16, i16 }
%struct.anon.39 = type { ptr, ptr, %struct.anon.40, %struct.anon.41, %struct.anon.42, i8 }
%struct.anon.40 = type { float, float }
%struct.anon.41 = type { float, float }
%struct.anon.42 = type { float, float }

@.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_dirty_region_transform_update_value0 = external hidden unnamed_addr constant [114 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 void @__arm_2d_helper_dirty_region_transform_update_value0(ptr noundef nonnull %0, float noundef %1, float noundef %2) #2 {
  %4 = alloca ptr, align 8
  %5 = alloca float, align 4
  %6 = alloca float, align 4
  %7 = alloca float, align 4
  %8 = alloca i32, align 4
  %9 = alloca ptr, align 8
  %10 = alloca float, align 4
  %11 = alloca i32, align 4
  %12 = alloca ptr, align 8
  store ptr %0, ptr %4, align 8, !tbaa !5
  store float %1, ptr %5, align 4, !tbaa !9
  store float %2, ptr %6, align 4, !tbaa !9
  %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, ptr noundef @.str.1, i32 noundef 4931, ptr noundef @__PRETTY_FUNCTION__.__arm_2d_helper_dirty_region_transform_update_value0) #3
  unreachable

17:                                               ; preds = %15
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #4
  store float 0.000000e+00, ptr %7, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #4
  store i32 0, ptr %8, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #4
  store ptr null, ptr %9, align 8, !tbaa !5
  br label %18

18:                                               ; preds = %56, %17
  %19 = load ptr, ptr %9, align 8, !tbaa !5
  %20 = getelementptr inbounds i32, ptr %19, i32 1
  store ptr %20, ptr %9, align 8, !tbaa !5
  %21 = icmp eq ptr %19, null
  br i1 %21, label %23, label %22

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

23:                                               ; preds = %18
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #4
  %24 = load ptr, ptr %4, align 8, !tbaa !5
  %25 = getelementptr inbounds %struct.arm_2d_helper_dirty_region_transform_t, ptr %24, i32 0, i32 4
  %26 = getelementptr inbounds %struct.anon.39, ptr %25, i32 0, i32 2
  %27 = getelementptr inbounds %struct.anon.40, ptr %26, i32 0, i32 0
  %28 = load float, ptr %27, align 8, !tbaa !13
  %29 = load float, ptr %5, align 4, !tbaa !9
  %30 = fsub float %28, %29
  store float %30, ptr %10, align 4, !tbaa !9
  %31 = load float, ptr %10, align 4, !tbaa !9
  %32 = fcmp ogt float %31, 0.000000e+00
  br i1 %32, label %33, label %35

33:                                               ; preds = %23
  %34 = load float, ptr %10, align 4, !tbaa !9
  br label %38

35:                                               ; preds = %23
  %36 = load float, ptr %10, align 4, !tbaa !9
  %37 = fneg float %36
  br label %38

38:                                               ; preds = %35, %33
  %39 = phi float [ %34, %33 ], [ %37, %35 ]
  store float %39, ptr %10, align 4, !tbaa !9
  %40 = load float, ptr %10, align 4, !tbaa !9
  %41 = load ptr, ptr %4, align 8, !tbaa !5
  %42 = getelementptr inbounds %struct.arm_2d_helper_dirty_region_transform_t, ptr %41, i32 0, i32 4
  %43 = getelementptr inbounds %struct.anon.39, ptr %42, i32 0, i32 2
  %44 = getelementptr inbounds %struct.anon.40, ptr %43, i32 0, i32 1
  %45 = load float, ptr %44, align 4, !tbaa !22
  %46 = fcmp oge float %40, %45
  br i1 %46, label %47, label %56

47:                                               ; preds = %38
  %48 = load float, ptr %5, align 4, !tbaa !9
  %49 = load ptr, ptr %4, align 8, !tbaa !5
  %50 = getelementptr inbounds %struct.arm_2d_helper_dirty_region_transform_t, ptr %49, i32 0, i32 4
  %51 = getelementptr inbounds %struct.anon.39, ptr %50, i32 0, i32 2
  %52 = getelementptr inbounds %struct.anon.40, ptr %51, i32 0, i32 0
  store float %48, ptr %52, align 8, !tbaa !13
  %53 = load ptr, ptr %4, align 8, !tbaa !5
  %54 = getelementptr inbounds %struct.arm_2d_helper_dirty_region_transform_t, ptr %53, i32 0, i32 4
  %55 = getelementptr inbounds %struct.anon.39, ptr %54, i32 0, i32 5
  store i8 1, ptr %55, align 8, !tbaa !23
  br label %56

56:                                               ; preds = %47, %38
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #4
  br label %18, !llvm.loop !24

57:                                               ; preds = %22
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #4
  store i32 0, ptr %11, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #4
  store ptr null, ptr %12, align 8, !tbaa !5
  br label %58

58:                                               ; preds = %96, %57
  %59 = load ptr, ptr %12, align 8, !tbaa !5
  %60 = getelementptr inbounds i32, ptr %59, i32 1
  store ptr %60, ptr %12, align 8, !tbaa !5
  %61 = icmp eq ptr %59, null
  br i1 %61, label %63, label %62

62:                                               ; preds = %58
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #4
  br label %97

63:                                               ; preds = %58
  %64 = load ptr, ptr %4, align 8, !tbaa !5
  %65 = getelementptr inbounds %struct.arm_2d_helper_dirty_region_transform_t, ptr %64, i32 0, i32 4
  %66 = getelementptr inbounds %struct.anon.39, ptr %65, i32 0, i32 3
  %67 = getelementptr inbounds %struct.anon.41, ptr %66, i32 0, i32 0
  %68 = load float, ptr %67, align 8, !tbaa !26
  %69 = load float, ptr %6, align 4, !tbaa !9
  %70 = fsub float %68, %69
  store float %70, ptr %7, align 4, !tbaa !9
  %71 = load float, ptr %7, align 4, !tbaa !9
  %72 = fcmp ogt float %71, 0.000000e+00
  br i1 %72, label %73, label %75

73:                                               ; preds = %63
  %74 = load float, ptr %7, align 4, !tbaa !9
  br label %78

75:                                               ; preds = %63
  %76 = load float, ptr %7, align 4, !tbaa !9
  %77 = fneg float %76
  br label %78

78:                                               ; preds = %75, %73
  %79 = phi float [ %74, %73 ], [ %77, %75 ]
  store float %79, ptr %7, align 4, !tbaa !9
  %80 = load float, ptr %7, align 4, !tbaa !9
  %81 = load ptr, ptr %4, align 8, !tbaa !5
  %82 = getelementptr inbounds %struct.arm_2d_helper_dirty_region_transform_t, ptr %81, i32 0, i32 4
  %83 = getelementptr inbounds %struct.anon.39, ptr %82, i32 0, i32 3
  %84 = getelementptr inbounds %struct.anon.41, ptr %83, i32 0, i32 1
  %85 = load float, ptr %84, align 4, !tbaa !27
  %86 = fcmp oge float %80, %85
  br i1 %86, label %87, label %96

87:                                               ; preds = %78
  %88 = load float, ptr %6, align 4, !tbaa !9
  %89 = load ptr, ptr %4, align 8, !tbaa !5
  %90 = getelementptr inbounds %struct.arm_2d_helper_dirty_region_transform_t, ptr %89, i32 0, i32 4
  %91 = getelementptr inbounds %struct.anon.39, ptr %90, i32 0, i32 3
  %92 = getelementptr inbounds %struct.anon.41, ptr %91, i32 0, i32 0
  store float %88, ptr %92, align 8, !tbaa !26
  %93 = load ptr, ptr %4, align 8, !tbaa !5
  %94 = getelementptr inbounds %struct.arm_2d_helper_dirty_region_transform_t, ptr %93, i32 0, i32 4
  %95 = getelementptr inbounds %struct.anon.39, ptr %94, i32 0, i32 5
  store i8 1, ptr %95, align 8, !tbaa !23
  br label %96

96:                                               ; preds = %87, %78
  br label %58, !llvm.loop !28

97:                                               ; preds = %62
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #4
  ret void
}

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 = !{!"float", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{!14, !10, i64 88}
!14 = !{!"arm_2d_helper_dirty_region_transform_t", !10, i64 0, !7, i64 4, !10, i64 8, !15, i64 16, !19, i64 72}
!15 = !{!"arm_2d_helper_dirty_region_item_t", !16, i64 0, !17, i64 48}
!16 = !{!"", !6, i64 0, !6, i64 8, !7, i64 16, !17, i64 32, !7, i64 40, !7, i64 40, !7, i64 40, !7, i64 40, !7, i64 41, !18, i64 42}
!17 = !{!"arm_2d_region_t", !7, i64 0, !7, i64 4}
!18 = !{!"short", !7, i64 0}
!19 = !{!"", !6, i64 0, !6, i64 8, !20, i64 16, !20, i64 24, !20, i64 32, !21, i64 40}
!20 = !{!"", !10, i64 0, !10, i64 4}
!21 = !{!"_Bool", !7, i64 0}
!22 = !{!14, !10, i64 92}
!23 = !{!14, !21, i64 112}
!24 = distinct !{!24, !25}
!25 = !{!"llvm.loop.mustprogress"}
!26 = !{!14, !10, i64 96}
!27 = !{!14, !10, i64 100}
!28 = distinct !{!28, !25}


; 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 void @__arm_2d_helper_dirty_region_transform_update_value0(ptr nocapture noundef nonnull %0, float noundef %1, float noundef %2) local_unnamed_addr #0 {
  %4 = getelementptr inbounds i8, ptr %0, i64 88
  %5 = getelementptr inbounds i8, ptr %0, i64 92
  %6 = load float, ptr %5, align 4, !tbaa !5
  %.promoted = load float, ptr %4, align 8, !tbaa !18
  %7 = getelementptr inbounds i8, ptr %0, i64 112
  %8 = fsub float %.promoted, %1
  %9 = fcmp ogt float %8, 0.000000e+00
  %10 = fneg float %8
  %11 = select i1 %9, float %8, float %10
  %12 = fcmp ult float %11, %6
  br i1 %12, label %.preheader, label %13

13:                                               ; preds = %3
  store float %1, ptr %4, align 8, !tbaa !18
  store i8 1, ptr %7, align 8, !tbaa !19
  br label %.preheader

.preheader:                                       ; preds = %13, %3
  %14 = getelementptr inbounds i8, ptr %0, i64 96
  %15 = getelementptr inbounds i8, ptr %0, i64 100
  %16 = load float, ptr %15, align 4, !tbaa !20
  %.promoted24 = load float, ptr %14, align 8, !tbaa !21
  %17 = fsub float %.promoted24, %2
  %18 = fcmp ogt float %17, 0.000000e+00
  %19 = fneg float %17
  %20 = select i1 %18, float %17, float %19
  %21 = fcmp ult float %20, %16
  br i1 %21, label %23, label %22

22:                                               ; preds = %.preheader
  store float %2, ptr %14, align 8, !tbaa !21
  store i8 1, ptr %7, align 8, !tbaa !19
  br label %23

23:                                               ; preds = %22, %.preheader
  ret void
}

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, !7, i64 92}
!6 = !{!"arm_2d_helper_dirty_region_transform_t", !7, i64 0, !8, i64 4, !7, i64 8, !10, i64 16, !15, i64 72}
!7 = !{!"float", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"arm_2d_helper_dirty_region_item_t", !11, i64 0, !13, i64 48}
!11 = !{!"", !12, i64 0, !12, i64 8, !8, i64 16, !13, i64 32, !8, i64 40, !8, i64 40, !8, i64 40, !8, i64 40, !8, i64 41, !14, i64 42}
!12 = !{!"any pointer", !8, i64 0}
!13 = !{!"arm_2d_region_t", !8, i64 0, !8, i64 4}
!14 = !{!"short", !8, i64 0}
!15 = !{!"", !12, i64 0, !12, i64 8, !16, i64 16, !16, i64 24, !16, i64 32, !17, i64 40}
!16 = !{!"", !7, i64 0, !7, i64 4}
!17 = !{!"_Bool", !8, i64 0}
!18 = !{!6, !7, i64 88}
!19 = !{!6, !17, i64 112}
!20 = !{!6, !7, i64 100}
!21 = !{!6, !7, i64 96}


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