; LLVM IR from ARM-software/Arm-2D :: Helper/Source (arm_2d_helper_scene)

; 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_scene_player_t = type { %struct.arm_2d_helper_pfb_t, %struct.anon.1, %struct.anon.2 }
%struct.arm_2d_helper_pfb_t = type { [344 x i8], %struct.anon.0 }
%struct.anon.0 = type { i64, i32, i32 }
%struct.anon.1 = type { i32, i32, i64, i64, i32, float, i16, i16, i32, i64 }
%struct.anon.2 = type { %struct.anon.3, %struct.anon.4, %struct.anon.5, %struct.anon.31 }
%struct.anon.3 = type { ptr, ptr }
%struct.anon.4 = type { i16, i8, i8 }
%struct.anon.5 = type { ptr, i8, i16, %union.anon, %union.__arm_2d_helper_scene_switch_t, %struct.arm_2d_location_t, i16, i16, i64 }
%union.anon = type { %struct.anon.23 }
%struct.anon.23 = type { %struct.arm_2d_tile_t, %struct.arm_2d_filter_iir_blur_descriptor_t }
%struct.arm_2d_tile_t = type { %union.anon.8, %union.anon.19, %union.anon.22 }
%union.anon.8 = type { %struct.anon.9 }
%struct.anon.9 = type { i8, %union.arm_2d_color_info_t, %union.anon.12 }
%union.arm_2d_color_info_t = type { %struct.anon.10 }
%struct.anon.10 = type { i8 }
%union.anon.12 = type { i16 }
%union.anon.19 = type { %struct.arm_2d_region_t }
%struct.arm_2d_region_t = type { %union.anon.20, %union.anon.21 }
%union.anon.20 = type { %struct.arm_2d_location_t }
%union.anon.21 = type { %struct.arm_2d_size_t }
%struct.arm_2d_size_t = type { i16, i16 }
%union.anon.22 = type { ptr }
%struct.arm_2d_filter_iir_blur_descriptor_t = type { [72 x i8], %struct.arm_2d_scratch_mem_t }
%struct.arm_2d_scratch_mem_t = type { %union.anon.24, i64 }
%union.anon.24 = type { %union.anon.25 }
%union.anon.25 = type { %struct.anon.26 }
%struct.anon.26 = type { i32 }
%union.__arm_2d_helper_scene_switch_t = type { i16 }
%struct.arm_2d_location_t = type { i16, i16 }
%struct.anon.31 = type { %struct.arm_2d_scene_evt_t, %struct.arm_2d_scene_evt_t }
%struct.arm_2d_scene_evt_t = type { ptr, ptr }
%struct.anon = type { i8, ptr, ptr, ptr }

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

7:                                                ; preds = %2
  br label %9

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

9:                                                ; preds = %7
  %10 = load i64, ptr %4, align 8, !tbaa !9
  %11 = icmp slt i64 %10, 0
  br i1 %11, label %12, label %29

12:                                               ; preds = %9
  %13 = load ptr, ptr %3, align 8, !tbaa !5
  %14 = getelementptr inbounds %struct.arm_2d_scene_player_t, ptr %13, i32 0, i32 2
  %15 = getelementptr inbounds %struct.anon.2, ptr %14, i32 0, i32 1
  %16 = load i16, ptr %15, align 8
  %17 = and i16 %16, -3
  %18 = or i16 %17, 2
  store i16 %18, ptr %15, align 8
  %19 = load ptr, ptr %3, align 8, !tbaa !5
  %20 = getelementptr inbounds %struct.arm_2d_scene_player_t, ptr %19, i32 0, i32 2
  %21 = getelementptr inbounds %struct.anon.2, ptr %20, i32 0, i32 2
  %22 = getelementptr inbounds %struct.anon.5, ptr %21, i32 0, i32 5
  %23 = getelementptr inbounds %struct.arm_2d_location_t, ptr %22, i32 0, i32 0
  store i16 -1, ptr %23, align 2, !tbaa !11
  %24 = load ptr, ptr %3, align 8, !tbaa !5
  %25 = getelementptr inbounds %struct.arm_2d_scene_player_t, ptr %24, i32 0, i32 2
  %26 = getelementptr inbounds %struct.anon.2, ptr %25, i32 0, i32 2
  %27 = getelementptr inbounds %struct.anon.5, ptr %26, i32 0, i32 5
  %28 = getelementptr inbounds %struct.arm_2d_location_t, ptr %27, i32 0, i32 1
  store i16 -1, ptr %28, align 2, !tbaa !26
  br label %60

29:                                               ; preds = %9
  %30 = load ptr, ptr %3, align 8, !tbaa !5
  %31 = getelementptr inbounds %struct.arm_2d_scene_player_t, ptr %30, i32 0, i32 2
  %32 = getelementptr inbounds %struct.anon.2, ptr %31, i32 0, i32 1
  %33 = load i16, ptr %32, align 8
  %34 = and i16 %33, -3
  %35 = or i16 %34, 0
  store i16 %35, ptr %32, align 8
  %36 = load i64, ptr %4, align 8, !tbaa !9
  %37 = icmp slt i64 %36, 65535
  br i1 %37, label %38, label %40

38:                                               ; preds = %29
  %39 = load i64, ptr %4, align 8, !tbaa !9
  br label %41

40:                                               ; preds = %29
  br label %41

41:                                               ; preds = %40, %38
  %42 = phi i64 [ %39, %38 ], [ 65535, %40 ]
  %43 = trunc i64 %42 to i16
  %44 = load ptr, ptr %3, align 8, !tbaa !5
  %45 = getelementptr inbounds %struct.arm_2d_scene_player_t, ptr %44, i32 0, i32 2
  %46 = getelementptr inbounds %struct.anon.2, ptr %45, i32 0, i32 2
  %47 = getelementptr inbounds %struct.anon.5, ptr %46, i32 0, i32 7
  store i16 %43, ptr %47, align 8, !tbaa !27
  %48 = load i64, ptr %4, align 8, !tbaa !9
  %49 = icmp sgt i64 %48, 200
  br i1 %49, label %50, label %52

50:                                               ; preds = %41
  %51 = load i64, ptr %4, align 8, !tbaa !9
  br label %53

52:                                               ; preds = %41
  br label %53

53:                                               ; preds = %52, %50
  %54 = phi i64 [ %51, %50 ], [ 200, %52 ]
  %55 = trunc i64 %54 to i16
  %56 = load ptr, ptr %3, align 8, !tbaa !5
  %57 = getelementptr inbounds %struct.arm_2d_scene_player_t, ptr %56, i32 0, i32 2
  %58 = getelementptr inbounds %struct.anon.2, ptr %57, i32 0, i32 2
  %59 = getelementptr inbounds %struct.anon.5, ptr %58, i32 0, i32 7
  store i16 %55, ptr %59, align 8, !tbaa !27
  br label %60

60:                                               ; preds = %53, %12
  br label %61

61:                                               ; preds = %60
  %62 = load ptr, ptr %3, align 8, !tbaa !5
  %63 = getelementptr inbounds %struct.arm_2d_scene_player_t, ptr %62, i32 0, i32 2
  %64 = getelementptr inbounds %struct.anon.2, ptr %63, i32 0, i32 2
  %65 = getelementptr inbounds %struct.anon.5, ptr %64, i32 0, i32 0
  %66 = load ptr, ptr %65, align 8, !tbaa !28
  %67 = icmp eq ptr null, %66
  br i1 %67, label %68, label %69

68:                                               ; preds = %61
  br label %88

69:                                               ; preds = %61
  %70 = load ptr, ptr %3, align 8, !tbaa !5
  %71 = getelementptr inbounds %struct.arm_2d_scene_player_t, ptr %70, i32 0, i32 2
  %72 = getelementptr inbounds %struct.anon.2, ptr %71, i32 0, i32 2
  %73 = getelementptr inbounds %struct.anon.5, ptr %72, i32 0, i32 0
  %74 = load ptr, ptr %73, align 8, !tbaa !28
  %75 = getelementptr inbounds %struct.anon, ptr %74, i32 0, i32 2
  %76 = load ptr, ptr %75, align 8, !tbaa !29
  %77 = icmp ne ptr null, %76
  br i1 %77, label %78, label %87

78:                                               ; preds = %69
  %79 = load ptr, ptr %3, align 8, !tbaa !5
  %80 = getelementptr inbounds %struct.arm_2d_scene_player_t, ptr %79, i32 0, i32 2
  %81 = getelementptr inbounds %struct.anon.2, ptr %80, i32 0, i32 2
  %82 = getelementptr inbounds %struct.anon.5, ptr %81, i32 0, i32 0
  %83 = load ptr, ptr %82, align 8, !tbaa !28
  %84 = getelementptr inbounds %struct.anon, ptr %83, i32 0, i32 2
  %85 = load ptr, ptr %84, align 8, !tbaa !29
  %86 = load ptr, ptr %3, align 8, !tbaa !5
  call void %85(ptr noundef %86)
  br label %87

87:                                               ; preds = %78, %69
  br label %88

88:                                               ; preds = %87, %68
  ret void
}

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 = { 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, !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 = !{!12, !18, i64 562}
!12 = !{!"arm_2d_scene_player_t", !13, i64 0, !16, i64 360, !19, i64 408}
!13 = !{!"arm_2d_helper_pfb_t", !7, i64 0, !14, i64 344}
!14 = !{!"", !10, i64 0, !15, i64 8, !15, i64 12}
!15 = !{!"int", !7, i64 0}
!16 = !{!"", !15, i64 0, !15, i64 4, !10, i64 8, !10, i64 16, !15, i64 24, !17, i64 28, !18, i64 32, !18, i64 34, !15, i64 36, !10, i64 40}
!17 = !{!"float", !7, i64 0}
!18 = !{!"short", !7, i64 0}
!19 = !{!"", !20, i64 0, !21, i64 16, !22, i64 24, !24, i64 176}
!20 = !{!"", !6, i64 0, !6, i64 8}
!21 = !{!"", !7, i64 0, !7, i64 0, !7, i64 0, !7, i64 0, !7, i64 1, !7, i64 1, !7, i64 1, !7, i64 1, !7, i64 2, !7, i64 2, !7, i64 2, !7, i64 2, !7, i64 2, !7, i64 2, !7, i64 3}
!22 = !{!"", !6, i64 0, !7, i64 8, !18, i64 10, !7, i64 16, !7, i64 128, !23, i64 130, !18, i64 134, !18, i64 136, !10, i64 144}
!23 = !{!"arm_2d_location_t", !18, i64 0, !18, i64 2}
!24 = !{!"", !25, i64 0, !25, i64 16}
!25 = !{!"arm_2d_scene_evt_t", !6, i64 0, !6, i64 8}
!26 = !{!12, !18, i64 564}
!27 = !{!12, !18, i64 568}
!28 = !{!12, !6, i64 432}
!29 = !{!30, !6, i64 16}
!30 = !{!"", !7, i64 0, !6, i64 8, !6, i64 16, !6, i64 24}


; 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 @arm_2d_scene_player_set_auto_switching_period(ptr noundef nonnull %0, i64 noundef %1) local_unnamed_addr #0 {
  %3 = icmp slt i64 %1, 0
  %4 = getelementptr inbounds i8, ptr %0, i64 424
  %5 = load i16, ptr %4, align 8
  br i1 %3, label %6, label %10

6:                                                ; preds = %2
  %7 = or i16 %5, 2
  store i16 %7, ptr %4, align 8
  %8 = getelementptr inbounds i8, ptr %0, i64 562
  store i16 -1, ptr %8, align 2, !tbaa !5
  %9 = getelementptr inbounds i8, ptr %0, i64 564
  store i16 -1, ptr %9, align 2, !tbaa !24
  br label %15

10:                                               ; preds = %2
  %11 = and i16 %5, -3
  store i16 %11, ptr %4, align 8
  %12 = getelementptr inbounds i8, ptr %0, i64 568
  %13 = tail call i64 @llvm.umax.i64(i64 %1, i64 200)
  %14 = trunc i64 %13 to i16
  store i16 %14, ptr %12, align 8, !tbaa !25
  br label %15

15:                                               ; preds = %6, %10
  %16 = getelementptr inbounds i8, ptr %0, i64 432
  %17 = load ptr, ptr %16, align 8, !tbaa !26
  %18 = icmp eq ptr %17, null
  br i1 %18, label %23, label %19

19:                                               ; preds = %15
  %20 = getelementptr inbounds i8, ptr %17, i64 16
  %21 = load ptr, ptr %20, align 8, !tbaa !27
  %.not = icmp eq ptr %21, null
  br i1 %.not, label %23, label %22

22:                                               ; preds = %19
  tail call void %21(ptr noundef nonnull %0) #2
  br label %23

23:                                               ; preds = %19, %22, %15
  ret void
}

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i64 @llvm.umax.i64(i64, i64) #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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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, !15, i64 562}
!6 = !{!"arm_2d_scene_player_t", !7, i64 0, !13, i64 360, !16, i64 408}
!7 = !{!"arm_2d_helper_pfb_t", !8, i64 0, !10, i64 344}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"", !11, i64 0, !12, i64 8, !12, i64 12}
!11 = !{!"long", !8, i64 0}
!12 = !{!"int", !8, i64 0}
!13 = !{!"", !12, i64 0, !12, i64 4, !11, i64 8, !11, i64 16, !12, i64 24, !14, i64 28, !15, i64 32, !15, i64 34, !12, i64 36, !11, i64 40}
!14 = !{!"float", !8, i64 0}
!15 = !{!"short", !8, i64 0}
!16 = !{!"", !17, i64 0, !19, i64 16, !20, i64 24, !22, i64 176}
!17 = !{!"", !18, i64 0, !18, i64 8}
!18 = !{!"any pointer", !8, i64 0}
!19 = !{!"", !8, i64 0, !8, i64 0, !8, i64 0, !8, i64 0, !8, i64 1, !8, i64 1, !8, i64 1, !8, i64 1, !8, i64 2, !8, i64 2, !8, i64 2, !8, i64 2, !8, i64 2, !8, i64 2, !8, i64 3}
!20 = !{!"", !18, i64 0, !8, i64 8, !15, i64 10, !8, i64 16, !8, i64 128, !21, i64 130, !15, i64 134, !15, i64 136, !11, i64 144}
!21 = !{!"arm_2d_location_t", !15, i64 0, !15, i64 2}
!22 = !{!"", !23, i64 0, !23, i64 16}
!23 = !{!"arm_2d_scene_evt_t", !18, i64 0, !18, i64 8}
!24 = !{!6, !15, i64 564}
!25 = !{!6, !15, i64 568}
!26 = !{!6, !18, i64 432}
!27 = !{!28, !18, i64 16}
!28 = !{!"", !8, i64 0, !18, i64 8, !18, i64 16, !18, i64 24}


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