; 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 = external hidden unnamed_addr constant [75 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 @spin_zoom_widget_on_frame_start(ptr noundef nonnull %0, i32 noundef %1, float noundef %2) #2 {
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  %6 = alloca float, align 4
  %7 = alloca i32, 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 i32 %1, ptr %5, align 4, !tbaa !9
  store float %2, ptr %6, align 4, !tbaa !11
  %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 176, ptr noundef @__PRETTY_FUNCTION__.spin_zoom_widget_on_frame_start) #5
  unreachable

15:                                               ; preds = %13
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #6
  %16 = load i32, 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 !13
  %24 = sub nsw i32 %16, %23
  store i32 %24, ptr %7, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #6
  %25 = load ptr, ptr %4, align 8, !tbaa !5
  %26 = getelementptr inbounds %struct.spin_zoom_widget_t, ptr %25, i32 0, i32 0
  %27 = getelementptr inbounds %struct.anon, ptr %26, i32 0, i32 0
  %28 = getelementptr inbounds %struct.spin_zoom_widget_cfg_t, ptr %27, i32 0, i32 3
  %29 = getelementptr inbounds %struct.anon.2, ptr %28, i32 0, i32 1
  %30 = getelementptr inbounds %struct.anon.4, ptr %29, i32 0, i32 0
  %31 = load float, ptr %30, align 8, !tbaa !25
  %32 = load ptr, ptr %4, align 8, !tbaa !5
  %33 = getelementptr inbounds %struct.spin_zoom_widget_t, ptr %32, i32 0, i32 0
  %34 = getelementptr inbounds %struct.anon, ptr %33, i32 0, i32 0
  %35 = getelementptr inbounds %struct.spin_zoom_widget_cfg_t, ptr %34, i32 0, i32 3
  %36 = getelementptr inbounds %struct.anon.2, ptr %35, i32 0, i32 0
  %37 = getelementptr inbounds %struct.anon.3, ptr %36, i32 0, i32 0
  %38 = load float, ptr %37, align 8, !tbaa !26
  %39 = fsub float %31, %38
  store float %39, ptr %8, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #6
  %40 = load ptr, ptr %4, align 8, !tbaa !5
  %41 = getelementptr inbounds %struct.spin_zoom_widget_t, ptr %40, i32 0, i32 0
  %42 = getelementptr inbounds %struct.anon, ptr %41, i32 0, i32 0
  %43 = getelementptr inbounds %struct.spin_zoom_widget_cfg_t, ptr %42, i32 0, i32 3
  %44 = getelementptr inbounds %struct.anon.2, ptr %43, i32 0, i32 1
  %45 = getelementptr inbounds %struct.anon.4, ptr %44, i32 0, i32 1
  %46 = load i32, ptr %45, align 4, !tbaa !27
  %47 = load ptr, ptr %4, align 8, !tbaa !5
  %48 = getelementptr inbounds %struct.spin_zoom_widget_t, ptr %47, i32 0, i32 0
  %49 = getelementptr inbounds %struct.anon, ptr %48, i32 0, i32 0
  %50 = getelementptr inbounds %struct.spin_zoom_widget_cfg_t, ptr %49, i32 0, i32 3
  %51 = getelementptr inbounds %struct.anon.2, ptr %50, i32 0, i32 0
  %52 = getelementptr inbounds %struct.anon.3, ptr %51, i32 0, i32 1
  %53 = load i32, ptr %52, align 4, !tbaa !13
  %54 = sub nsw i32 %46, %53
  store i32 %54, ptr %9, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #6
  %55 = load i32, ptr %7, align 4, !tbaa !9
  %56 = sitofp i32 %55 to float
  %57 = load i32, ptr %9, align 4, !tbaa !9
  %58 = sitofp i32 %57 to float
  %59 = fdiv float %56, %58
  %60 = load float, ptr %8, align 4, !tbaa !11
  %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 !26
  %68 = call float @llvm.fmuladd.f32(float %59, float %60, float %67)
  store float %68, ptr %10, align 4, !tbaa !11
  %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 !11
  %73 = load float, ptr %6, align 4, !tbaa !11
  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
}

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare float @llvm.fmuladd.f32(float, float, float) #3

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

declare void @arm_2d_helper_dirty_region_transform_on_frame_start(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 = { 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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"float", !7, i64 0}
!13 = !{!14, !10, i64 52}
!14 = !{!"spin_zoom_widget_t", !15, i64 0, !21, i64 80}
!15 = !{!"", !16, i64 0}
!16 = !{!"spin_zoom_widget_cfg_t", !6, i64 0, !17, i64 8, !6, i64 40, !18, i64 48, !10, i64 76}
!17 = !{!"", !6, i64 0, !6, i64 8, !7, i64 16, !7, i64 24}
!18 = !{!"", !19, i64 0, !19, i64 8, !20, i64 16}
!19 = !{!"", !12, i64 0, !10, i64 4}
!20 = !{!"", !12, i64 0, !7, i64 4, !12, i64 8}
!21 = !{!"", !7, i64 0, !22, i64 200}
!22 = !{!"arm_2d_helper_dirty_region_transform_t", !12, i64 0, !7, i64 4, !12, i64 8, !23, i64 16, !7, i64 72}
!23 = !{!"arm_2d_helper_dirty_region_item_t", !7, i64 0, !24, i64 48}
!24 = !{!"arm_2d_region_t", !7, i64 0, !7, i64 4}
!25 = !{!14, !12, i64 56}
!26 = !{!14, !12, i64 48}
!27 = !{!14, !10, i64 60}


; 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: nounwind uwtable
define dso_local void @spin_zoom_widget_on_frame_start(ptr noundef nonnull %0, i32 noundef %1, float noundef %2) local_unnamed_addr #0 {
  %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 = sub nsw i32 %1, %6
  %8 = getelementptr inbounds i8, ptr %0, i64 56
  %9 = load float, ptr %8, align 8, !tbaa !22
  %10 = load float, ptr %4, align 8, !tbaa !23
  %11 = fsub float %9, %10
  %12 = getelementptr inbounds i8, ptr %0, i64 60
  %13 = load i32, ptr %12, align 4, !tbaa !24
  %14 = sub nsw i32 %13, %6
  %15 = sitofp i32 %7 to float
  %16 = sitofp i32 %14 to float
  %17 = fdiv float %15, %16
  %18 = tail call float @llvm.fmuladd.f32(float %17, float %11, float %10)
  %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
}

; Function Attrs: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare float @llvm.fmuladd.f32(float, float, float) #1

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

declare void @arm_2d_helper_dirty_region_transform_on_frame_start(ptr noundef) local_unnamed_addr #2

attributes #0 = { 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 #1 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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, !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