; 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 }

@.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_get_switching_status = external hidden unnamed_addr constant [102 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 i32 @arm_2d_scene_player_get_switching_status(ptr noundef nonnull %0) #1 {
  %2 = alloca i32, align 4
  %3 = alloca ptr, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  %4 = load ptr, ptr %3, 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 487, ptr noundef @__PRETTY_FUNCTION__.arm_2d_scene_player_get_switching_status) #2
  unreachable

8:                                                ; preds = %6
  %9 = load ptr, ptr %3, align 8, !tbaa !5
  %10 = getelementptr inbounds %struct.arm_2d_scene_player_t, ptr %9, i32 0, i32 2
  %11 = getelementptr inbounds %struct.anon.2, ptr %10, i32 0, i32 1
  %12 = load i16, ptr %11, align 8
  %13 = lshr i16 %12, 8
  %14 = and i16 %13, 1
  %15 = trunc i16 %14 to i8
  %16 = icmp ne i8 %15, 0
  br i1 %16, label %17, label %38

17:                                               ; preds = %8
  %18 = load ptr, ptr %3, align 8, !tbaa !5
  %19 = getelementptr inbounds %struct.arm_2d_scene_player_t, ptr %18, i32 0, i32 2
  %20 = getelementptr inbounds %struct.anon.2, ptr %19, i32 0, i32 1
  %21 = load i16, ptr %20, align 8
  %22 = lshr i16 %21, 10
  %23 = and i16 %22, 1
  %24 = trunc i16 %23 to i8
  %25 = icmp ne i8 %24, 0
  br i1 %25, label %26, label %37

26:                                               ; preds = %17
  %27 = load ptr, ptr %3, align 8, !tbaa !5
  %28 = getelementptr inbounds %struct.arm_2d_scene_player_t, ptr %27, i32 0, i32 2
  %29 = getelementptr inbounds %struct.anon.2, ptr %28, i32 0, i32 1
  %30 = load i16, ptr %29, align 8
  %31 = lshr i16 %30, 9
  %32 = and i16 %31, 1
  %33 = trunc i16 %32 to i8
  %34 = icmp ne i8 %33, 0
  br i1 %34, label %35, label %36

35:                                               ; preds = %26
  store i32 2, ptr %2, align 4
  br label %39

36:                                               ; preds = %26
  store i32 3, ptr %2, align 4
  br label %39

37:                                               ; preds = %17
  store i32 1, ptr %2, align 4
  br label %39

38:                                               ; preds = %8
  store i32 0, ptr %2, align 4
  br label %39

39:                                               ; preds = %38, %37, %36, %35
  %40 = load i32, ptr %2, align 4
  ret i32 %40
}

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


; 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: mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: read) uwtable
define dso_local range(i32 0, 4) i32 @arm_2d_scene_player_get_switching_status(ptr nocapture noundef nonnull readonly %0) local_unnamed_addr #0 {
  %2 = getelementptr inbounds i8, ptr %0, i64 424
  %3 = load i16, ptr %2, align 8
  %4 = and i16 %3, 256
  %.not = icmp eq i16 %4, 0
  br i1 %.not, label %9, label %5

5:                                                ; preds = %1
  %6 = and i16 %3, 1024
  %.not4 = icmp eq i16 %6, 0
  br i1 %.not4, label %9, label %7

7:                                                ; preds = %5
  %8 = and i16 %3, 512
  %.not5 = icmp eq i16 %8, 0
  %. = select i1 %.not5, i32 3, i32 2
  br label %9

9:                                                ; preds = %1, %5, %7
  %.0 = phi i32 [ %., %7 ], [ 1, %5 ], [ 0, %1 ]
  ret i32 %.0
}

attributes #0 = { mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: read) 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" }

!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)"}


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