; 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.arm_2d_point_float_t = type { float, float }
%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 }
%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.spin_zoom_widget_mode_t = type { ptr }

@.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_show_with_normal_pivot = external hidden unnamed_addr constant [151 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [34 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_show_with_normal_pivot(ptr noundef nonnull %0, ptr noundef nonnull %1, ptr noundef %2, ptr noundef %3, i8 noundef zeroext %4) #2 {
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca i8, align 1
  %11 = alloca %struct.arm_2d_point_float_t, align 4
  %12 = alloca ptr, align 8
  store ptr %0, ptr %6, align 8, !tbaa !5
  store ptr %1, ptr %7, align 8, !tbaa !5
  store ptr %2, ptr %8, align 8, !tbaa !5
  store ptr %3, ptr %9, align 8, !tbaa !5
  store i8 %4, ptr %10, align 1, !tbaa !9
  %13 = load ptr, ptr %7, align 8, !tbaa !5
  %14 = ptrtoint ptr %13 to i64
  %15 = icmp eq i64 -1, %14
  br i1 %15, label %16, label %18

16:                                               ; preds = %5
  %17 = call ptr @arm_2d_get_default_frame_buffer()
  store ptr %17, ptr %7, align 8, !tbaa !5
  br label %18

18:                                               ; preds = %16, %5
  %19 = load ptr, ptr %7, align 8, !tbaa !5
  %20 = icmp eq ptr null, %19
  br i1 %20, label %21, label %22

21:                                               ; preds = %18
  br label %76

22:                                               ; preds = %18
  %23 = load ptr, ptr %6, align 8, !tbaa !5
  %24 = icmp ne ptr null, %23
  br i1 %24, label %25, label %26

25:                                               ; preds = %22
  br label %27

26:                                               ; preds = %22
  call void @__assert_fail(ptr noundef @.str.2, ptr noundef @.str.1, i32 noundef 237, ptr noundef @__PRETTY_FUNCTION__.spin_zoom_widget_show_with_normal_pivot) #4
  unreachable

27:                                               ; preds = %25
  %28 = load ptr, ptr %6, align 8, !tbaa !5
  %29 = getelementptr inbounds %struct.spin_zoom_widget_t, ptr %28, i32 0, i32 0
  %30 = getelementptr inbounds %struct.anon, ptr %29, i32 0, i32 0
  %31 = getelementptr inbounds %struct.spin_zoom_widget_cfg_t, ptr %30, i32 0, i32 2
  %32 = load ptr, ptr %31, align 8, !tbaa !10
  %33 = icmp ne ptr null, %32
  br i1 %33, label %34, label %35

34:                                               ; preds = %27
  br label %36

35:                                               ; preds = %27
  call void @__assert_fail(ptr noundef @.str.3, ptr noundef @.str.1, i32 noundef 238, ptr noundef @__PRETTY_FUNCTION__.spin_zoom_widget_show_with_normal_pivot) #4
  unreachable

36:                                               ; preds = %34
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #5
  store ptr null, ptr %12, align 8, !tbaa !5
  %37 = load ptr, ptr %9, align 8, !tbaa !5
  %38 = icmp ne ptr null, %37
  br i1 %38, label %39, label %50

39:                                               ; preds = %36
  %40 = load ptr, ptr %9, align 8, !tbaa !5
  %41 = getelementptr inbounds %struct.arm_2d_location_t, ptr %40, i32 0, i32 0
  %42 = load i16, ptr %41, align 2, !tbaa !24
  %43 = sitofp i16 %42 to float
  %44 = getelementptr inbounds %struct.arm_2d_point_float_t, ptr %11, i32 0, i32 0
  store float %43, ptr %44, align 4, !tbaa !27
  %45 = load ptr, ptr %9, align 8, !tbaa !5
  %46 = getelementptr inbounds %struct.arm_2d_location_t, ptr %45, i32 0, i32 1
  %47 = load i16, ptr %46, align 2, !tbaa !29
  %48 = sitofp i16 %47 to float
  %49 = getelementptr inbounds %struct.arm_2d_point_float_t, ptr %11, i32 0, i32 1
  store float %48, ptr %49, align 4, !tbaa !30
  store ptr %11, ptr %12, align 8, !tbaa !5
  br label %50

50:                                               ; preds = %39, %36
  %51 = load ptr, ptr %6, align 8, !tbaa !5
  %52 = getelementptr inbounds %struct.spin_zoom_widget_t, ptr %51, i32 0, i32 0
  %53 = getelementptr inbounds %struct.anon, ptr %52, i32 0, i32 0
  %54 = getelementptr inbounds %struct.spin_zoom_widget_cfg_t, ptr %53, i32 0, i32 2
  %55 = load ptr, ptr %54, align 8, !tbaa !10
  %56 = getelementptr inbounds %struct.spin_zoom_widget_mode_t, ptr %55, i32 0, i32 0
  %57 = load ptr, ptr %56, align 8, !tbaa !31
  %58 = icmp eq ptr null, %57
  br i1 %58, label %59, label %60

59:                                               ; preds = %50
  br label %74

60:                                               ; preds = %50
  %61 = load ptr, ptr %6, 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 2
  %65 = load ptr, ptr %64, align 8, !tbaa !10
  %66 = getelementptr inbounds %struct.spin_zoom_widget_mode_t, ptr %65, i32 0, i32 0
  %67 = load ptr, ptr %66, align 8, !tbaa !31
  %68 = load ptr, ptr %6, align 8, !tbaa !5
  %69 = load ptr, ptr %7, align 8, !tbaa !5
  %70 = load ptr, ptr %8, align 8, !tbaa !5
  %71 = load ptr, ptr %12, align 8, !tbaa !5
  %72 = load i8, ptr %10, align 1, !tbaa !9
  %73 = call i32 %67(ptr noundef %68, ptr noundef %69, ptr noundef %70, ptr noundef %71, i8 noundef zeroext %72)
  br label %74

74:                                               ; preds = %60, %59
  %75 = phi i32 [ 0, %59 ], [ %73, %60 ]
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #5
  br label %76

76:                                               ; preds = %74, %21
  ret void
}

declare ptr @arm_2d_get_default_frame_buffer() #3

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 = { "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 = !{!7, !7, i64 0}
!10 = !{!11, !6, i64 40}
!11 = !{!"spin_zoom_widget_t", !12, i64 0, !20, i64 80}
!12 = !{!"", !13, i64 0}
!13 = !{!"spin_zoom_widget_cfg_t", !6, i64 0, !14, i64 8, !6, i64 40, !15, i64 48, !18, i64 76}
!14 = !{!"", !6, i64 0, !6, i64 8, !7, i64 16, !7, i64 24}
!15 = !{!"", !16, i64 0, !16, i64 8, !19, i64 16}
!16 = !{!"", !17, i64 0, !18, i64 4}
!17 = !{!"float", !7, i64 0}
!18 = !{!"int", !7, i64 0}
!19 = !{!"", !17, i64 0, !7, i64 4, !17, i64 8}
!20 = !{!"", !7, i64 0, !21, i64 200}
!21 = !{!"arm_2d_helper_dirty_region_transform_t", !17, i64 0, !7, i64 4, !17, 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 = !{!25, !26, i64 0}
!25 = !{!"arm_2d_location_t", !26, i64 0, !26, i64 2}
!26 = !{!"short", !7, i64 0}
!27 = !{!28, !17, i64 0}
!28 = !{!"arm_2d_point_float_t", !17, i64 0, !17, i64 4}
!29 = !{!25, !26, i64 2}
!30 = !{!28, !17, i64 4}
!31 = !{!32, !6, i64 0}
!32 = !{!"spin_zoom_widget_mode_t", !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"

%struct.arm_2d_point_float_t = type { float, float }

@.str.1 = external hidden unnamed_addr constant [97 x i8], align 1
@__PRETTY_FUNCTION__.spin_zoom_widget_show_with_normal_pivot = external hidden unnamed_addr constant [151 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [34 x i8], align 1

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

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

; Function Attrs: mustprogress 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_show_with_normal_pivot(ptr noundef nonnull %0, ptr noundef nonnull %1, ptr noundef %2, ptr noundef readonly %3, i8 noundef zeroext %4) local_unnamed_addr #2 {
  %6 = alloca %struct.arm_2d_point_float_t, align 8
  %7 = icmp eq ptr %1, inttoptr (i64 -1 to ptr)
  br i1 %7, label %8, label %.thread

8:                                                ; preds = %5
  %9 = tail call ptr @arm_2d_get_default_frame_buffer() #4
  %10 = icmp eq ptr %9, null
  br i1 %10, label %24, label %.thread

.thread:                                          ; preds = %5, %8
  %.01318 = phi ptr [ %9, %8 ], [ %1, %5 ]
  %11 = getelementptr inbounds i8, ptr %0, i64 40
  %12 = load ptr, ptr %11, align 8, !tbaa !5
  %.not = icmp eq ptr %12, null
  br i1 %.not, label %13, label %14

13:                                               ; preds = %.thread
  tail call void @__assert_fail(ptr noundef nonnull @.str.3, ptr noundef nonnull @.str.1, i32 noundef 238, ptr noundef nonnull @__PRETTY_FUNCTION__.spin_zoom_widget_show_with_normal_pivot) #5
  unreachable

14:                                               ; preds = %.thread
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %6) #4
  %.not16 = icmp eq ptr %3, null
  br i1 %.not16, label %18, label %15

15:                                               ; preds = %14
  %16 = load <2 x i16>, ptr %3, align 2, !tbaa !22
  %17 = sitofp <2 x i16> %16 to <2 x float>
  store <2 x float> %17, ptr %6, align 8, !tbaa !24
  br label %18

18:                                               ; preds = %15, %14
  %.0 = phi ptr [ %6, %15 ], [ null, %14 ]
  %19 = load ptr, ptr %12, align 8, !tbaa !25
  %20 = icmp eq ptr %19, null
  br i1 %20, label %23, label %21

21:                                               ; preds = %18
  %22 = call i32 %19(ptr noundef nonnull %0, ptr noundef nonnull %.01318, ptr noundef %2, ptr noundef %.0, i8 noundef zeroext %4) #4
  br label %23

23:                                               ; preds = %18, %21
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %6) #4
  br label %24

24:                                               ; preds = %8, %23
  ret void
}

declare ptr @arm_2d_get_default_frame_buffer() local_unnamed_addr #3

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 = { mustprogress 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 = { "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 }
attributes #5 = { noreturn 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 40}
!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 = !{!23, !23, i64 0}
!23 = !{!"short", !10, i64 0}
!24 = !{!15, !15, i64 0}
!25 = !{!26, !9, i64 0}
!26 = !{!"spin_zoom_widget_mode_t", !9, i64 0}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,PostOrderFunctionAttrsPass,SLPVectorizerPass,SROAPass,SimplifyCFGPass,TailCallElimPass