; LLVM IR from ARM-software/Arm-2D :: examples/common/controls (spin_zoom_widget)

; 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.spin_zoom_widget_t = type { %struct.anon, %struct.anon.7 }
%struct.anon = type { %struct.spin_zoom_widget_cfg_t }
%struct.spin_zoom_widget_cfg_t = type { ptr, %struct.anon.0, ptr, %struct.anon.2, i32 }
%struct.anon.0 = type { ptr, ptr, %union.anon, %union.anon.1 }
%union.anon = type { %struct.arm_2d_point_float_t }
%struct.arm_2d_point_float_t = type { float, float }
%union.anon.1 = type { i16 }
%struct.anon.2 = type { %struct.anon.3, %struct.anon.4, %struct.anon.5 }
%struct.anon.3 = type { float, i32 }
%struct.anon.4 = type { float, i32 }
%struct.anon.5 = type { float, %union.anon.6, float }
%union.anon.6 = type { float }
%struct.anon.7 = type { %union.anon.8, %struct.arm_2d_helper_dirty_region_transform_t }
%union.anon.8 = type { %struct.arm_2d_op_trans_msk_opa_t }
%struct.arm_2d_op_trans_msk_opa_t = type { %struct.arm_2d_op_core_t, %struct.anon.30, %struct.anon.31, %union.anon.32, %struct.anon.34, %struct.anon.35, %struct.__arm_2d_transform_info_t, i8 }
%struct.arm_2d_op_core_t = type { [40 x i8], i64 }
%struct.anon.30 = type { ptr, ptr }
%struct.anon.31 = type { ptr }
%union.anon.32 = type { %struct.anon.33 }
%struct.anon.33 = type { i32 }
%struct.anon.34 = type { ptr, %struct.arm_2d_tile_t }
%struct.arm_2d_tile_t = type { %union.anon.14, %union.anon.25, %union.anon.28 }
%union.anon.14 = type { %struct.anon.15 }
%struct.anon.15 = type { i8, %union.arm_2d_color_info_t, %union.anon.18 }
%union.arm_2d_color_info_t = type { %struct.anon.16 }
%struct.anon.16 = type { i8 }
%union.anon.18 = type { i16 }
%union.anon.25 = type { %struct.arm_2d_region_t }
%struct.arm_2d_region_t = type { %union.anon.26, %union.anon.27 }
%union.anon.26 = type { %struct.arm_2d_location_t }
%struct.arm_2d_location_t = type { i16, i16 }
%union.anon.27 = type { %struct.arm_2d_size_t }
%struct.arm_2d_size_t = type { i16, i16 }
%union.anon.28 = type { ptr }
%struct.anon.35 = type { ptr, ptr }
%struct.__arm_2d_transform_info_t = type { float, float, float, %struct.arm_2d_point_float_t, %union.anon.29, [40 x i8] }
%union.anon.29 = type { i32 }
%struct.arm_2d_helper_dirty_region_transform_t = type { float, %union.anon.36, float, [4 x i8], %struct.arm_2d_helper_dirty_region_item_t, [48 x i8] }
%union.anon.36 = type { float }
%struct.arm_2d_helper_dirty_region_item_t = type { [48 x i8], %struct.arm_2d_region_t }

@.str.1 = external hidden unnamed_addr constant [97 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [15 x i8], align 1
@__PRETTY_FUNCTION__.spin_zoom_widget_on_frame_start_f32 = external hidden unnamed_addr constant [77 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 nosync nounwind speculatable willreturn memory(none)
declare float @llvm.fmuladd.f32(float, float, float) #2

declare void @__arm_2d_helper_dirty_region_transform_update_value0(ptr noundef, float noundef, float noundef) #3

declare void @arm_2d_helper_dirty_region_transform_on_frame_start(ptr noundef) #3

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

13:                                               ; preds = %3
  br label %15

14:                                               ; preds = %3
  call void @__assert_fail(ptr noundef @.str.2, ptr noundef @.str.1, i32 noundef 197, ptr noundef @__PRETTY_FUNCTION__.spin_zoom_widget_on_frame_start_f32) #5
  unreachable

15:                                               ; preds = %13
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #6
  %16 = load float, ptr %5, align 4, !tbaa !9
  %17 = load ptr, ptr %4, align 8, !tbaa !5
  %18 = getelementptr inbounds %struct.spin_zoom_widget_t, ptr %17, i32 0, i32 0
  %19 = getelementptr inbounds %struct.anon, ptr %18, i32 0, i32 0
  %20 = getelementptr inbounds %struct.spin_zoom_widget_cfg_t, ptr %19, i32 0, i32 3
  %21 = getelementptr inbounds %struct.anon.2, ptr %20, i32 0, i32 0
  %22 = getelementptr inbounds %struct.anon.3, ptr %21, i32 0, i32 1
  %23 = load i32, ptr %22, align 4, !tbaa !11
  %24 = sitofp i32 %23 to float
  %25 = fsub float %16, %24
  store float %25, ptr %7, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #6
  %26 = load ptr, ptr %4, align 8, !tbaa !5
  %27 = getelementptr inbounds %struct.spin_zoom_widget_t, ptr %26, i32 0, i32 0
  %28 = getelementptr inbounds %struct.anon, ptr %27, i32 0, i32 0
  %29 = getelementptr inbounds %struct.spin_zoom_widget_cfg_t, ptr %28, i32 0, i32 3
  %30 = getelementptr inbounds %struct.anon.2, ptr %29, i32 0, i32 1
  %31 = getelementptr inbounds %struct.anon.4, ptr %30, i32 0, i32 0
  %32 = load float, ptr %31, align 8, !tbaa !24
  %33 = load ptr, ptr %4, align 8, !tbaa !5
  %34 = getelementptr inbounds %struct.spin_zoom_widget_t, ptr %33, i32 0, i32 0
  %35 = getelementptr inbounds %struct.anon, ptr %34, i32 0, i32 0
  %36 = getelementptr inbounds %struct.spin_zoom_widget_cfg_t, ptr %35, i32 0, i32 3
  %37 = getelementptr inbounds %struct.anon.2, ptr %36, i32 0, i32 0
  %38 = getelementptr inbounds %struct.anon.3, ptr %37, i32 0, i32 0
  %39 = load float, ptr %38, align 8, !tbaa !25
  %40 = fsub float %32, %39
  store float %40, ptr %8, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #6
  %41 = load ptr, ptr %4, align 8, !tbaa !5
  %42 = getelementptr inbounds %struct.spin_zoom_widget_t, ptr %41, i32 0, i32 0
  %43 = getelementptr inbounds %struct.anon, ptr %42, i32 0, i32 0
  %44 = getelementptr inbounds %struct.spin_zoom_widget_cfg_t, ptr %43, i32 0, i32 3
  %45 = getelementptr inbounds %struct.anon.2, ptr %44, i32 0, i32 1
  %46 = getelementptr inbounds %struct.anon.4, ptr %45, i32 0, i32 1
  %47 = load i32, ptr %46, align 4, !tbaa !26
  %48 = load ptr, ptr %4, align 8, !tbaa !5
  %49 = getelementptr inbounds %struct.spin_zoom_widget_t, ptr %48, i32 0, i32 0
  %50 = getelementptr inbounds %struct.anon, ptr %49, i32 0, i32 0
  %51 = getelementptr inbounds %struct.spin_zoom_widget_cfg_t, ptr %50, i32 0, i32 3
  %52 = getelementptr inbounds %struct.anon.2, ptr %51, i32 0, i32 0
  %53 = getelementptr inbounds %struct.anon.3, ptr %52, i32 0, i32 1
  %54 = load i32, ptr %53, align 4, !tbaa !11
  %55 = sub nsw i32 %47, %54
  store i32 %55, ptr %9, align 4, !tbaa !27
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #6
  %56 = load float, ptr %7, align 4, !tbaa !9
  %57 = load i32, ptr %9, align 4, !tbaa !27
  %58 = sitofp i32 %57 to float
  %59 = fdiv float %56, %58
  %60 = load float, ptr %8, align 4, !tbaa !9
  %61 = load ptr, ptr %4, align 8, !tbaa !5
  %62 = getelementptr inbounds %struct.spin_zoom_widget_t, ptr %61, i32 0, i32 0
  %63 = getelementptr inbounds %struct.anon, ptr %62, i32 0, i32 0
  %64 = getelementptr inbounds %struct.spin_zoom_widget_cfg_t, ptr %63, i32 0, i32 3
  %65 = getelementptr inbounds %struct.anon.2, ptr %64, i32 0, i32 0
  %66 = getelementptr inbounds %struct.anon.3, ptr %65, i32 0, i32 0
  %67 = load float, ptr %66, align 8, !tbaa !25
  %68 = call float @llvm.fmuladd.f32(float %59, float %60, float %67)
  store float %68, ptr %10, align 4, !tbaa !9
  %69 = load ptr, ptr %4, align 8, !tbaa !5
  %70 = getelementptr inbounds %struct.spin_zoom_widget_t, ptr %69, i32 0, i32 1
  %71 = getelementptr inbounds %struct.anon.7, ptr %70, i32 0, i32 1
  %72 = load float, ptr %10, align 4, !tbaa !9
  %73 = load float, ptr %6, align 4, !tbaa !9
  call void @__arm_2d_helper_dirty_region_transform_update_value0(ptr noundef %71, float noundef %72, float noundef %73)
  %74 = load ptr, ptr %4, align 8, !tbaa !5
  %75 = getelementptr inbounds %struct.spin_zoom_widget_t, ptr %74, i32 0, i32 1
  %76 = getelementptr inbounds %struct.anon.7, ptr %75, i32 0, i32 1
  call void @arm_2d_helper_dirty_region_transform_on_frame_start(ptr noundef %76)
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #6
  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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #3 = { "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 = { 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 #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 = !{!10, !10, i64 0}
!10 = !{!"float", !7, i64 0}
!11 = !{!12, !18, i64 52}
!12 = !{!"spin_zoom_widget_t", !13, i64 0, !20, i64 80}
!13 = !{!"", !14, i64 0}
!14 = !{!"spin_zoom_widget_cfg_t", !6, i64 0, !15, i64 8, !6, i64 40, !16, i64 48, !18, i64 76}
!15 = !{!"", !6, i64 0, !6, i64 8, !7, i64 16, !7, i64 24}
!16 = !{!"", !17, i64 0, !17, i64 8, !19, i64 16}
!17 = !{!"", !10, i64 0, !18, i64 4}
!18 = !{!"int", !7, i64 0}
!19 = !{!"", !10, i64 0, !7, i64 4, !10, i64 8}
!20 = !{!"", !7, i64 0, !21, i64 200}
!21 = !{!"arm_2d_helper_dirty_region_transform_t", !10, i64 0, !7, i64 4, !10, i64 8, !22, i64 16, !7, i64 72}
!22 = !{!"arm_2d_helper_dirty_region_item_t", !7, i64 0, !23, i64 48}
!23 = !{!"arm_2d_region_t", !7, i64 0, !7, i64 4}
!24 = !{!12, !10, i64 56}
!25 = !{!12, !10, i64 48}
!26 = !{!12, !18, i64 60}
!27 = !{!18, !18, 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 nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare float @llvm.fmuladd.f32(float, float, float) #0

declare void @__arm_2d_helper_dirty_region_transform_update_value0(ptr noundef, float noundef, float noundef) local_unnamed_addr #1

declare void @arm_2d_helper_dirty_region_transform_on_frame_start(ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local void @spin_zoom_widget_on_frame_start_f32(ptr noundef nonnull %0, float noundef %1, float noundef %2) local_unnamed_addr #2 {
  %4 = getelementptr inbounds i8, ptr %0, i64 48
  %5 = getelementptr inbounds i8, ptr %0, i64 52
  %6 = load i32, ptr %5, align 4, !tbaa !5
  %7 = sitofp i32 %6 to float
  %8 = fsub float %1, %7
  %9 = getelementptr inbounds i8, ptr %0, i64 56
  %10 = load float, ptr %9, align 8, !tbaa !22
  %11 = load float, ptr %4, align 8, !tbaa !23
  %12 = fsub float %10, %11
  %13 = getelementptr inbounds i8, ptr %0, i64 60
  %14 = load i32, ptr %13, align 4, !tbaa !24
  %15 = sub nsw i32 %14, %6
  %16 = sitofp i32 %15 to float
  %17 = fdiv float %8, %16
  %18 = tail call float @llvm.fmuladd.f32(float %17, float %12, float %11)
  %19 = getelementptr inbounds i8, ptr %0, i64 280
  tail call void @__arm_2d_helper_dirty_region_transform_update_value0(ptr noundef nonnull %19, float noundef %18, float noundef %2) #3
  tail call void @arm_2d_helper_dirty_region_transform_on_frame_start(ptr noundef nonnull %19) #3
  ret void
}

attributes #0 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #1 = { "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 = { 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 = { 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, !16, i64 52}
!6 = !{!"spin_zoom_widget_t", !7, i64 0, !18, i64 80}
!7 = !{!"", !8, i64 0}
!8 = !{!"spin_zoom_widget_cfg_t", !9, i64 0, !12, i64 8, !9, i64 40, !13, i64 48, !16, i64 76}
!9 = !{!"any pointer", !10, i64 0}
!10 = !{!"omnipotent char", !11, i64 0}
!11 = !{!"Simple C/C++ TBAA"}
!12 = !{!"", !9, i64 0, !9, i64 8, !10, i64 16, !10, i64 24}
!13 = !{!"", !14, i64 0, !14, i64 8, !17, i64 16}
!14 = !{!"", !15, i64 0, !16, i64 4}
!15 = !{!"float", !10, i64 0}
!16 = !{!"int", !10, i64 0}
!17 = !{!"", !15, i64 0, !10, i64 4, !15, i64 8}
!18 = !{!"", !10, i64 0, !19, i64 200}
!19 = !{!"arm_2d_helper_dirty_region_transform_t", !15, i64 0, !10, i64 4, !15, i64 8, !20, i64 16, !10, i64 72}
!20 = !{!"arm_2d_helper_dirty_region_item_t", !10, i64 0, !21, i64 48}
!21 = !{!"arm_2d_region_t", !10, i64 0, !10, i64 4}
!22 = !{!6, !15, i64 56}
!23 = !{!6, !15, i64 48}
!24 = !{!6, !16, i64 60}


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