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

; 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.progress_wheel_t = type { %struct.anon }
%struct.anon = type { %struct.progress_wheel_cfg_t, ptr, float, float, [7 x %struct.arm_2d_op_trans_opa_t], %struct.arm_2d_helper_dirty_region_transform_t, %struct.arm_2d_region_list_item_t, %struct.arm_2d_tile_t, i8, i16, i16, i16, i32 }
%struct.progress_wheel_cfg_t = type { ptr, ptr, i16, i16, i16, i16, i32 }
%struct.arm_2d_op_trans_opa_t = type { %struct.arm_2d_op_core_t, %struct.anon.0, %struct.anon.1, %union.anon, %struct.anon.3, %struct.__arm_2d_transform_info_t, i8 }
%struct.arm_2d_op_core_t = type { [40 x i8], i64 }
%struct.anon.0 = type { ptr, ptr }
%struct.anon.1 = type { ptr }
%union.anon = type { %struct.anon.2 }
%struct.anon.2 = type { i32 }
%struct.anon.3 = type { ptr, %struct.arm_2d_tile_t }
%struct.__arm_2d_transform_info_t = type { float, float, float, %struct.arm_2d_point_float_t, %union.anon.19, [40 x i8] }
%struct.arm_2d_point_float_t = type { float, float }
%union.anon.19 = type { i32 }
%struct.arm_2d_helper_dirty_region_transform_t = type { float, %union.anon.20, float, [4 x i8], %struct.arm_2d_helper_dirty_region_item_t, [48 x i8] }
%union.anon.20 = type { float }
%struct.arm_2d_helper_dirty_region_item_t = type { [48 x i8], %struct.arm_2d_region_t }
%struct.arm_2d_region_t = type { %union.anon.16, %union.anon.17 }
%union.anon.16 = type { %struct.arm_2d_location_t }
%struct.arm_2d_location_t = type { i16, i16 }
%union.anon.17 = type { %struct.arm_2d_size_t }
%struct.arm_2d_size_t = type { i16, i16 }
%struct.arm_2d_region_list_item_t = type { ptr, [8 x i8], %struct.arm_2d_region_t, [4 x i8] }
%struct.arm_2d_tile_t = type { %union.anon.4, %union.anon.15, %union.anon.18 }
%union.anon.4 = type { %struct.anon.5 }
%struct.anon.5 = type { i8, %union.arm_2d_color_info_t, %union.anon.8 }
%union.arm_2d_color_info_t = type { %struct.anon.6 }
%struct.anon.6 = type { i8 }
%union.anon.8 = type { i16 }
%union.anon.15 = type { %struct.arm_2d_region_t }
%union.anon.18 = type { ptr }

@.str = external hidden unnamed_addr constant [15 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [95 x i8], align 1
@__PRETTY_FUNCTION__.progress_wheel_on_frame_start = external hidden unnamed_addr constant [55 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 @progress_wheel_on_frame_start(ptr noundef nonnull %0) #2 {
  %2 = alloca ptr, align 8
  %3 = alloca float, align 4
  store ptr %0, ptr %2, align 8, !tbaa !5
  %4 = load ptr, ptr %2, align 8, !tbaa !5
  %5 = icmp ne ptr null, %4
  br i1 %5, label %6, label %7

6:                                                ; preds = %1
  br label %8

7:                                                ; preds = %1
  call void @__assert_fail(ptr noundef @.str, ptr noundef @.str.1, i32 noundef 218, ptr noundef @__PRETTY_FUNCTION__.progress_wheel_on_frame_start) #6
  unreachable

8:                                                ; preds = %6
  %9 = load ptr, ptr %2, align 8, !tbaa !5
  %10 = getelementptr inbounds %struct.progress_wheel_t, ptr %9, i32 0, i32 0
  %11 = getelementptr inbounds %struct.anon, ptr %10, i32 0, i32 11
  %12 = load i16, ptr %11, align 2, !tbaa !9
  %13 = load ptr, ptr %2, align 8, !tbaa !5
  %14 = getelementptr inbounds %struct.progress_wheel_t, ptr %13, i32 0, i32 0
  %15 = getelementptr inbounds %struct.anon, ptr %14, i32 0, i32 10
  store i16 %12, ptr %15, align 4, !tbaa !21
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #7
  %16 = load ptr, ptr %2, align 8, !tbaa !5
  %17 = getelementptr inbounds %struct.progress_wheel_t, ptr %16, i32 0, i32 0
  %18 = getelementptr inbounds %struct.anon, ptr %17, i32 0, i32 10
  %19 = load i16, ptr %18, align 4, !tbaa !21
  %20 = sitofp i16 %19 to float
  %21 = fdiv float %20, 1.000000e+01
  %22 = load ptr, ptr %2, align 8, !tbaa !5
  %23 = getelementptr inbounds %struct.progress_wheel_t, ptr %22, i32 0, i32 0
  %24 = getelementptr inbounds %struct.anon, ptr %23, i32 0, i32 0
  %25 = getelementptr inbounds %struct.progress_wheel_cfg_t, ptr %24, i32 0, i32 6
  %26 = load i32, ptr %25, align 8
  %27 = lshr i32 %26, 2
  %28 = and i32 %27, 3
  %29 = uitofp i32 %28 to float
  %30 = call float @llvm.fmuladd.f32(float 9.000000e+01, float %29, float %21)
  store float %30, ptr %3, align 4, !tbaa !22
  %31 = load float, ptr %3, align 4, !tbaa !22
  %32 = call float @fmodf(float noundef %31, float noundef 3.600000e+02) #7
  store float %32, ptr %3, align 4, !tbaa !22
  %33 = load float, ptr %3, align 4, !tbaa !22
  %34 = fmul float %33, 0x400921FB40000000
  %35 = fdiv float %34, 1.800000e+02
  %36 = load ptr, ptr %2, align 8, !tbaa !5
  %37 = getelementptr inbounds %struct.progress_wheel_t, ptr %36, i32 0, i32 0
  %38 = getelementptr inbounds %struct.anon, ptr %37, i32 0, i32 3
  store float %35, ptr %38, align 4, !tbaa !23
  %39 = load ptr, ptr %2, align 8, !tbaa !5
  %40 = getelementptr inbounds %struct.progress_wheel_t, ptr %39, i32 0, i32 0
  %41 = getelementptr inbounds %struct.anon, ptr %40, i32 0, i32 0
  %42 = getelementptr inbounds %struct.progress_wheel_cfg_t, ptr %41, i32 0, i32 6
  %43 = load i32, ptr %42, align 8
  %44 = and i32 %43, 1
  %45 = icmp ne i32 %44, 0
  br i1 %45, label %46, label %60

46:                                               ; preds = %8
  %47 = load ptr, ptr %2, align 8, !tbaa !5
  %48 = getelementptr inbounds %struct.progress_wheel_t, ptr %47, i32 0, i32 0
  %49 = getelementptr inbounds %struct.anon, ptr %48, i32 0, i32 6
  call void @arm_2d_dynamic_dirty_region_on_frame_start(ptr noundef %49, i8 noundef zeroext -1)
  %50 = load ptr, ptr %2, align 8, !tbaa !5
  %51 = getelementptr inbounds %struct.progress_wheel_t, ptr %50, i32 0, i32 0
  %52 = getelementptr inbounds %struct.anon, ptr %51, i32 0, i32 5
  %53 = load ptr, ptr %2, align 8, !tbaa !5
  %54 = getelementptr inbounds %struct.progress_wheel_t, ptr %53, i32 0, i32 0
  %55 = getelementptr inbounds %struct.anon, ptr %54, i32 0, i32 3
  %56 = load float, ptr %55, align 4, !tbaa !23
  call void @__arm_2d_helper_dirty_region_transform_update_value0(ptr noundef %52, float noundef %56, float noundef 1.000000e+00)
  %57 = load ptr, ptr %2, align 8, !tbaa !5
  %58 = getelementptr inbounds %struct.progress_wheel_t, ptr %57, i32 0, i32 0
  %59 = getelementptr inbounds %struct.anon, ptr %58, i32 0, i32 5
  call void @arm_2d_helper_dirty_region_transform_on_frame_start(ptr noundef %59)
  br label %60

60:                                               ; preds = %46, %8
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #7
  ret void
}

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

; Function Attrs: nounwind
declare float @fmodf(float noundef, float noundef) #4

declare void @arm_2d_dynamic_dirty_region_on_frame_start(ptr noundef, i8 noundef zeroext) #5

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

declare void @arm_2d_helper_dirty_region_transform_on_frame_start(ptr noundef) #5

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 = { 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 #5 = { "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 #6 = { noreturn nounwind }
attributes #7 = { 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, !13, i64 1518}
!10 = !{!"progress_wheel_t", !11, i64 0}
!11 = !{!"", !12, i64 0, !6, i64 32, !15, i64 40, !15, i64 44, !7, i64 48, !16, i64 1336, !19, i64 1456, !20, i64 1488, !7, i64 1512, !13, i64 1514, !13, i64 1516, !13, i64 1518, !14, i64 1520}
!12 = !{!"progress_wheel_cfg_t", !6, i64 0, !6, i64 8, !13, i64 16, !13, i64 18, !13, i64 20, !13, i64 22, !14, i64 24, !14, i64 24, !14, i64 24, !14, i64 26}
!13 = !{!"short", !7, i64 0}
!14 = !{!"int", !7, i64 0}
!15 = !{!"float", !7, i64 0}
!16 = !{!"arm_2d_helper_dirty_region_transform_t", !15, i64 0, !7, i64 4, !15, i64 8, !17, i64 16, !7, i64 72}
!17 = !{!"arm_2d_helper_dirty_region_item_t", !7, i64 0, !18, i64 48}
!18 = !{!"arm_2d_region_t", !7, i64 0, !7, i64 4}
!19 = !{!"arm_2d_region_list_item_t", !6, i64 0, !7, i64 8, !18, i64 16, !7, i64 24}
!20 = !{!"arm_2d_tile_t", !7, i64 0, !7, i64 4, !7, i64 16}
!21 = !{!10, !13, i64 1516}
!22 = !{!15, !15, i64 0}
!23 = !{!10, !15, i64 44}


; 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 @progress_wheel_on_frame_start(ptr noundef nonnull %0) local_unnamed_addr #0 {
  %2 = getelementptr inbounds i8, ptr %0, i64 1518
  %3 = load i16, ptr %2, align 2, !tbaa !5
  %4 = getelementptr inbounds i8, ptr %0, i64 1516
  store i16 %3, ptr %4, align 4, !tbaa !20
  %5 = sitofp i16 %3 to float
  %6 = fdiv float %5, 1.000000e+01
  %7 = getelementptr inbounds i8, ptr %0, i64 24
  %8 = load i32, ptr %7, align 8
  %9 = lshr i32 %8, 2
  %10 = and i32 %9, 3
  %11 = uitofp nneg i32 %10 to float
  %12 = tail call float @llvm.fmuladd.f32(float %11, float 9.000000e+01, float %6)
  %13 = tail call float @fmodf(float noundef %12, float noundef 3.600000e+02) #4
  %14 = fmul float %13, 0x400921FB40000000
  %15 = fdiv float %14, 1.800000e+02
  %16 = getelementptr inbounds i8, ptr %0, i64 44
  store float %15, ptr %16, align 4, !tbaa !21
  %17 = load i32, ptr %7, align 8
  %18 = and i32 %17, 1
  %.not = icmp eq i32 %18, 0
  br i1 %.not, label %23, label %19

19:                                               ; preds = %1
  %20 = getelementptr inbounds i8, ptr %0, i64 1456
  tail call void @arm_2d_dynamic_dirty_region_on_frame_start(ptr noundef nonnull %20, i8 noundef zeroext -1) #4
  %21 = getelementptr inbounds i8, ptr %0, i64 1336
  %22 = load float, ptr %16, align 4, !tbaa !21
  tail call void @__arm_2d_helper_dirty_region_transform_update_value0(ptr noundef nonnull %21, float noundef %22, float noundef 1.000000e+00) #4
  tail call void @arm_2d_helper_dirty_region_transform_on_frame_start(ptr noundef nonnull %21) #4
  br label %23

23:                                               ; preds = %19, %1
  ret void
}

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

; Function Attrs: mustprogress nofree nounwind willreturn memory(write)
declare float @fmodf(float noundef, float noundef) local_unnamed_addr #2

declare void @arm_2d_dynamic_dirty_region_on_frame_start(ptr noundef, i8 noundef zeroext) local_unnamed_addr #3

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

declare void @arm_2d_helper_dirty_region_transform_on_frame_start(ptr noundef) local_unnamed_addr #3

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 = { mustprogress nofree nounwind willreturn memory(write) "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 }

!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, !12, i64 1518}
!6 = !{!"progress_wheel_t", !7, i64 0}
!7 = !{!"", !8, i64 0, !9, i64 32, !14, i64 40, !14, i64 44, !10, i64 48, !15, i64 1336, !18, i64 1456, !19, i64 1488, !10, i64 1512, !12, i64 1514, !12, i64 1516, !12, i64 1518, !13, i64 1520}
!8 = !{!"progress_wheel_cfg_t", !9, i64 0, !9, i64 8, !12, i64 16, !12, i64 18, !12, i64 20, !12, i64 22, !13, i64 24, !13, i64 24, !13, i64 24, !13, i64 26}
!9 = !{!"any pointer", !10, i64 0}
!10 = !{!"omnipotent char", !11, i64 0}
!11 = !{!"Simple C/C++ TBAA"}
!12 = !{!"short", !10, i64 0}
!13 = !{!"int", !10, i64 0}
!14 = !{!"float", !10, i64 0}
!15 = !{!"arm_2d_helper_dirty_region_transform_t", !14, i64 0, !10, i64 4, !14, i64 8, !16, i64 16, !10, i64 72}
!16 = !{!"arm_2d_helper_dirty_region_item_t", !10, i64 0, !17, i64 48}
!17 = !{!"arm_2d_region_t", !10, i64 0, !10, i64 4}
!18 = !{!"arm_2d_region_list_item_t", !9, i64 0, !10, i64 8, !17, i64 16, !10, i64 24}
!19 = !{!"arm_2d_tile_t", !10, i64 0, !10, i64 4, !10, i64 16}
!20 = !{!6, !12, i64 1516}
!21 = !{!6, !14, i64 44}


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