; 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 }
%struct.arm_2d_scene_t = type { [16 x i8], ptr, %union.arm_2d_colour_t, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, %struct.anon.44, [7 x i8], %struct.arm_2d_helper_dirty_region_t }
%union.arm_2d_colour_t = type { i32 }
%struct.anon.44 = type { i8 }
%struct.arm_2d_helper_dirty_region_t = type { [56 x i8], %struct.arm_2d_helper_dirty_region_item_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_load = external hidden unnamed_addr constant [52 x i8], align 1

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) #0

; Function Attrs: nounwind uwtable
define dso_local void @spin_zoom_widget_on_load(ptr noundef nonnull %0) #1 {
  %2 = alloca ptr, align 8
  %3 = alloca float, align 4
  %4 = alloca float, align 4
  store ptr %0, ptr %2, align 8, !tbaa !5
  %5 = load ptr, ptr %2, align 8, !tbaa !5
  %6 = icmp ne ptr null, %5
  br i1 %6, label %7, label %8

7:                                                ; preds = %1
  br label %9

8:                                                ; preds = %1
  call void @__assert_fail(ptr noundef @.str.2, ptr noundef @.str.1, i32 noundef 149, ptr noundef @__PRETTY_FUNCTION__.spin_zoom_widget_on_load) #4
  unreachable

9:                                                ; preds = %7
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #5
  store float 0x3FA99999A0000000, ptr %3, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #5
  store float 0x3F847AE140000000, ptr %4, align 4, !tbaa !9
  %10 = load ptr, ptr %2, align 8, !tbaa !5
  %11 = getelementptr inbounds %struct.spin_zoom_widget_t, ptr %10, i32 0, i32 0
  %12 = getelementptr inbounds %struct.anon, ptr %11, i32 0, i32 0
  %13 = getelementptr inbounds %struct.spin_zoom_widget_cfg_t, ptr %12, i32 0, i32 3
  %14 = getelementptr inbounds %struct.anon.2, ptr %13, i32 0, i32 2
  %15 = getelementptr inbounds %struct.anon.5, ptr %14, i32 0, i32 0
  %16 = load float, ptr %15, align 8, !tbaa !11
  %17 = fcmp ogt float %16, 0.000000e+00
  br i1 %17, label %18, label %26

18:                                               ; preds = %9
  %19 = load ptr, ptr %2, align 8, !tbaa !5
  %20 = getelementptr inbounds %struct.spin_zoom_widget_t, ptr %19, i32 0, i32 0
  %21 = getelementptr inbounds %struct.anon, ptr %20, i32 0, i32 0
  %22 = getelementptr inbounds %struct.spin_zoom_widget_cfg_t, ptr %21, i32 0, i32 3
  %23 = getelementptr inbounds %struct.anon.2, ptr %22, i32 0, i32 2
  %24 = getelementptr inbounds %struct.anon.5, ptr %23, i32 0, i32 0
  %25 = load float, ptr %24, align 8, !tbaa !11
  store float %25, ptr %3, align 4, !tbaa !9
  br label %26

26:                                               ; preds = %18, %9
  %27 = load ptr, ptr %2, align 8, !tbaa !5
  %28 = getelementptr inbounds %struct.spin_zoom_widget_t, ptr %27, i32 0, i32 0
  %29 = getelementptr inbounds %struct.anon, ptr %28, i32 0, i32 0
  %30 = getelementptr inbounds %struct.spin_zoom_widget_cfg_t, ptr %29, i32 0, i32 3
  %31 = getelementptr inbounds %struct.anon.2, ptr %30, i32 0, i32 2
  %32 = getelementptr inbounds %struct.anon.5, ptr %31, i32 0, i32 1
  %33 = load float, ptr %32, align 4, !tbaa !24
  %34 = fcmp ogt float %33, 0.000000e+00
  br i1 %34, label %35, label %43

35:                                               ; preds = %26
  %36 = load ptr, ptr %2, align 8, !tbaa !5
  %37 = getelementptr inbounds %struct.spin_zoom_widget_t, ptr %36, i32 0, i32 0
  %38 = getelementptr inbounds %struct.anon, ptr %37, i32 0, i32 0
  %39 = getelementptr inbounds %struct.spin_zoom_widget_cfg_t, ptr %38, i32 0, i32 3
  %40 = getelementptr inbounds %struct.anon.2, ptr %39, i32 0, i32 2
  %41 = getelementptr inbounds %struct.anon.5, ptr %40, i32 0, i32 1
  %42 = load float, ptr %41, align 4, !tbaa !24
  store float %42, ptr %4, align 4, !tbaa !9
  br label %43

43:                                               ; preds = %35, %26
  %44 = load ptr, ptr %2, align 8, !tbaa !5
  %45 = getelementptr inbounds %struct.spin_zoom_widget_t, ptr %44, i32 0, i32 0
  %46 = getelementptr inbounds %struct.anon, ptr %45, i32 0, i32 0
  %47 = getelementptr inbounds %struct.spin_zoom_widget_cfg_t, ptr %46, i32 0, i32 0
  %48 = load ptr, ptr %47, align 8, !tbaa !25
  %49 = icmp ne ptr null, %48
  br i1 %49, label %50, label %65

50:                                               ; preds = %43
  %51 = load ptr, ptr %2, align 8, !tbaa !5
  %52 = getelementptr inbounds %struct.spin_zoom_widget_t, ptr %51, i32 0, i32 1
  %53 = getelementptr inbounds %struct.anon.7, ptr %52, i32 0, i32 1
  %54 = load ptr, ptr %2, align 8, !tbaa !5
  %55 = getelementptr inbounds %struct.spin_zoom_widget_t, ptr %54, i32 0, i32 0
  %56 = getelementptr inbounds %struct.anon, ptr %55, i32 0, i32 0
  %57 = getelementptr inbounds %struct.spin_zoom_widget_cfg_t, ptr %56, i32 0, i32 0
  %58 = load ptr, ptr %57, align 8, !tbaa !25
  %59 = getelementptr inbounds %struct.arm_2d_scene_t, ptr %58, i32 0, i32 16
  %60 = load ptr, ptr %2, align 8, !tbaa !5
  %61 = getelementptr inbounds %struct.spin_zoom_widget_t, ptr %60, i32 0, i32 1
  %62 = getelementptr inbounds %struct.anon.7, ptr %61, i32 0, i32 0
  %63 = load float, ptr %3, align 4, !tbaa !9
  %64 = load float, ptr %4, align 4, !tbaa !9
  call void @arm_2d_helper_dirty_region_transform_init(ptr noundef %53, ptr noundef %59, ptr noundef %62, float noundef %63, float noundef %64)
  br label %65

65:                                               ; preds = %50, %43
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #5
  ret void
}

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #2

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

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #2

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 = { 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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { noreturn nounwind }
attributes #5 = { 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, !10, i64 64}
!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 = !{!7, !7, i64 0}
!25 = !{!12, !6, 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: nounwind uwtable
define dso_local void @spin_zoom_widget_on_load(ptr noundef nonnull %0) local_unnamed_addr #0 {
  %2 = load ptr, ptr %0, align 8, !tbaa !5
  %.not = icmp eq ptr %2, null
  br i1 %.not, label %13, label %3

3:                                                ; preds = %1
  %4 = getelementptr inbounds i8, ptr %0, i64 68
  %5 = load float, ptr %4, align 4, !tbaa !22
  %6 = fcmp ogt float %5, 0.000000e+00
  %.0 = select i1 %6, float %5, float 0x3F847AE140000000
  %7 = getelementptr inbounds i8, ptr %0, i64 64
  %8 = load float, ptr %7, align 8, !tbaa !23
  %9 = fcmp ogt float %8, 0.000000e+00
  %.011 = select i1 %9, float %8, float 0x3FA99999A0000000
  %10 = getelementptr inbounds i8, ptr %0, i64 80
  %11 = getelementptr inbounds i8, ptr %0, i64 280
  %12 = getelementptr inbounds i8, ptr %2, i64 128
  tail call void @arm_2d_helper_dirty_region_transform_init(ptr noundef nonnull %11, ptr noundef nonnull %12, ptr noundef nonnull %10, float noundef %.011, float noundef %.0) #2
  br label %13

13:                                               ; preds = %3, %1
  ret void
}

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

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 = { "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 }

!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, !9, i64 0}
!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 = !{!10, !10, i64 0}
!23 = !{!6, !15, i64 64}


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