; 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_depose = external hidden unnamed_addr constant [47 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_depose(ptr noundef nonnull %0) #2 {
  %2 = alloca ptr, align 8
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca i64, align 8
  store ptr %0, ptr %2, align 8, !tbaa !5
  %8 = load ptr, ptr %2, align 8, !tbaa !5
  %9 = icmp ne ptr null, %8
  br i1 %9, label %10, label %11

10:                                               ; preds = %1
  br label %12

11:                                               ; preds = %1
  call void @__assert_fail(ptr noundef @.str, ptr noundef @.str.1, i32 noundef 185, ptr noundef @__PRETTY_FUNCTION__.progress_wheel_depose) #4
  unreachable

12:                                               ; preds = %10
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #5
  %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 4
  %16 = getelementptr inbounds [7 x %struct.arm_2d_op_trans_opa_t], ptr %15, i64 0, i64 0
  store ptr %16, ptr %3, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #5
  %17 = load ptr, ptr %3, align 8, !tbaa !5
  store ptr %17, ptr %4, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #5
  store ptr null, ptr %5, align 8, !tbaa !5
  br label %18

18:                                               ; preds = %44, %12
  %19 = load ptr, ptr %5, align 8, !tbaa !5
  %20 = getelementptr inbounds %struct.arm_2d_op_trans_opa_t, ptr %19, i32 1
  store ptr %20, ptr %5, align 8, !tbaa !5
  %21 = icmp eq ptr %19, null
  br i1 %21, label %22, label %24

22:                                               ; preds = %18
  %23 = load ptr, ptr %3, align 8, !tbaa !5
  br label %25

24:                                               ; preds = %18
  br label %25

25:                                               ; preds = %24, %22
  %26 = phi i32 [ 1, %22 ], [ 0, %24 ]
  %27 = icmp ne i32 %26, 0
  br i1 %27, label %29, label %28

28:                                               ; preds = %25
  store i32 2, ptr %6, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #5
  br label %45

29:                                               ; preds = %25
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #5
  store i64 7, ptr %7, align 8, !tbaa !9
  br label %30

30:                                               ; preds = %37, %29
  %31 = load i64, ptr %7, align 8, !tbaa !9
  %32 = icmp ugt i64 %31, 0
  br i1 %32, label %34, label %33

33:                                               ; preds = %30
  store i32 5, ptr %6, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #5
  br label %43

34:                                               ; preds = %30
  %35 = load ptr, ptr %4, align 8, !tbaa !5
  %36 = call ptr @arm_2d_op_depose(ptr noundef %35, i64 noundef 184)
  br label %37

37:                                               ; preds = %34
  %38 = load ptr, ptr %3, align 8, !tbaa !5
  %39 = getelementptr inbounds %struct.arm_2d_op_trans_opa_t, ptr %38, i32 1
  store ptr %39, ptr %3, align 8, !tbaa !5
  %40 = load ptr, ptr %3, align 8, !tbaa !5
  store ptr %40, ptr %4, align 8, !tbaa !5
  %41 = load i64, ptr %7, align 8, !tbaa !9
  %42 = add i64 %41, -1
  store i64 %42, ptr %7, align 8, !tbaa !9
  br label %30, !llvm.loop !11

43:                                               ; preds = %33
  br label %44

44:                                               ; preds = %43
  br label %18, !llvm.loop !13

45:                                               ; preds = %28
  %46 = load ptr, ptr %2, align 8, !tbaa !5
  %47 = getelementptr inbounds %struct.progress_wheel_t, ptr %46, i32 0, i32 0
  %48 = getelementptr inbounds %struct.anon, ptr %47, i32 0, i32 0
  %49 = getelementptr inbounds %struct.progress_wheel_cfg_t, ptr %48, i32 0, i32 6
  %50 = load i32, ptr %49, align 8
  %51 = and i32 %50, 1
  %52 = icmp ne i32 %51, 0
  br i1 %52, label %53, label %70

53:                                               ; preds = %45
  %54 = load ptr, ptr %2, align 8, !tbaa !5
  %55 = getelementptr inbounds %struct.progress_wheel_t, ptr %54, i32 0, i32 0
  %56 = getelementptr inbounds %struct.anon, ptr %55, i32 0, i32 1
  %57 = load ptr, ptr %56, align 8, !tbaa !14
  %58 = icmp ne ptr null, %57
  br i1 %58, label %59, label %70

59:                                               ; preds = %53
  %60 = load ptr, ptr %2, align 8, !tbaa !5
  %61 = getelementptr inbounds %struct.progress_wheel_t, ptr %60, i32 0, i32 0
  %62 = getelementptr inbounds %struct.anon, ptr %61, i32 0, i32 6
  %63 = load ptr, ptr %2, align 8, !tbaa !5
  %64 = getelementptr inbounds %struct.progress_wheel_t, ptr %63, i32 0, i32 0
  %65 = getelementptr inbounds %struct.anon, ptr %64, i32 0, i32 1
  %66 = load ptr, ptr %65, align 8, !tbaa !14
  call void @arm_2d_scene_player_dynamic_dirty_region_depose(ptr noundef %62, ptr noundef %66)
  %67 = load ptr, ptr %2, align 8, !tbaa !5
  %68 = getelementptr inbounds %struct.progress_wheel_t, ptr %67, i32 0, i32 0
  %69 = getelementptr inbounds %struct.anon, ptr %68, i32 0, i32 5
  call void @arm_2d_helper_dirty_region_transform_depose(ptr noundef %69)
  br label %70

70:                                               ; preds = %59, %53, %45
  ret void
}

declare ptr @arm_2d_op_depose(ptr noundef, i64 noundef) #3

declare void @arm_2d_scene_player_dynamic_dirty_region_depose(ptr noundef, ptr noundef) #3

declare void @arm_2d_helper_dirty_region_transform_depose(ptr noundef) #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 = !{!10, !10, i64 0}
!10 = !{!"long", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = distinct !{!13, !12}
!14 = !{!15, !6, i64 32}
!15 = !{!"progress_wheel_t", !16, i64 0}
!16 = !{!"", !17, i64 0, !6, i64 32, !20, i64 40, !20, i64 44, !7, i64 48, !21, i64 1336, !24, i64 1456, !25, i64 1488, !7, i64 1512, !18, i64 1514, !18, i64 1516, !18, i64 1518, !19, i64 1520}
!17 = !{!"progress_wheel_cfg_t", !6, i64 0, !6, i64 8, !18, i64 16, !18, i64 18, !18, i64 20, !18, i64 22, !19, i64 24, !19, i64 24, !19, i64 24, !19, i64 26}
!18 = !{!"short", !7, i64 0}
!19 = !{!"int", !7, i64 0}
!20 = !{!"float", !7, i64 0}
!21 = !{!"arm_2d_helper_dirty_region_transform_t", !20, i64 0, !7, i64 4, !20, 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 = !{!"arm_2d_region_list_item_t", !6, i64 0, !7, i64 8, !23, i64 16, !7, i64 24}
!25 = !{!"arm_2d_tile_t", !7, i64 0, !7, i64 4, !7, i64 16}


; 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_depose(ptr noundef nonnull %0) local_unnamed_addr #0 {
.preheader:
  %1 = getelementptr inbounds i8, ptr %0, i64 48
  %2 = tail call ptr @arm_2d_op_depose(ptr noundef nonnull %1, i64 noundef 184) #2
  %3 = getelementptr inbounds i8, ptr %0, i64 232
  %4 = tail call ptr @arm_2d_op_depose(ptr noundef nonnull %3, i64 noundef 184) #2
  %5 = getelementptr inbounds i8, ptr %0, i64 416
  %6 = tail call ptr @arm_2d_op_depose(ptr noundef nonnull %5, i64 noundef 184) #2
  %7 = getelementptr inbounds i8, ptr %0, i64 600
  %8 = tail call ptr @arm_2d_op_depose(ptr noundef nonnull %7, i64 noundef 184) #2
  %9 = getelementptr inbounds i8, ptr %0, i64 784
  %10 = tail call ptr @arm_2d_op_depose(ptr noundef nonnull %9, i64 noundef 184) #2
  %11 = getelementptr inbounds i8, ptr %0, i64 968
  %12 = tail call ptr @arm_2d_op_depose(ptr noundef nonnull %11, i64 noundef 184) #2
  %13 = getelementptr inbounds i8, ptr %0, i64 1152
  %14 = tail call ptr @arm_2d_op_depose(ptr noundef nonnull %13, i64 noundef 184) #2
  %15 = getelementptr inbounds i8, ptr %0, i64 24
  %16 = load i32, ptr %15, align 8
  %17 = and i32 %16, 1
  %.not = icmp eq i32 %17, 0
  br i1 %.not, label %24, label %18

18:                                               ; preds = %.preheader
  %19 = getelementptr inbounds i8, ptr %0, i64 32
  %20 = load ptr, ptr %19, align 8, !tbaa !5
  %.not18 = icmp eq ptr %20, null
  br i1 %.not18, label %24, label %21

21:                                               ; preds = %18
  %22 = getelementptr inbounds i8, ptr %0, i64 1456
  tail call void @arm_2d_scene_player_dynamic_dirty_region_depose(ptr noundef nonnull %22, ptr noundef nonnull %20) #2
  %23 = getelementptr inbounds i8, ptr %0, i64 1336
  tail call void @arm_2d_helper_dirty_region_transform_depose(ptr noundef nonnull %23) #2
  br label %24

24:                                               ; preds = %21, %18, %.preheader
  ret void
}

declare ptr @arm_2d_op_depose(ptr noundef, i64 noundef) local_unnamed_addr #1

declare void @arm_2d_scene_player_dynamic_dirty_region_depose(ptr noundef, ptr noundef) local_unnamed_addr #1

declare void @arm_2d_helper_dirty_region_transform_depose(ptr 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 32}
!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}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,LCSSAPass,LoopRotatePass,LoopSimplifyPass,SROAPass,SimplifyCFGPass,TailCallElimPass