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

; 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 }
%struct.anon.30 = type { i8, i8 }

@.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_switching_mode = external hidden unnamed_addr constant [111 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [107 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_switching_mode(ptr noundef nonnull %0, ptr noundef %1, i16 noundef zeroext %2) #1 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i16, align 2
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  store i16 %2, ptr %6, align 2, !tbaa !9
  %7 = load ptr, ptr %4, align 8, !tbaa !5
  %8 = icmp ne ptr null, %7
  br i1 %8, label %9, label %10

9:                                                ; preds = %3
  br label %11

10:                                               ; preds = %3
  call void @__assert_fail(ptr noundef @.str, ptr noundef @.str.1, i32 noundef 403, ptr noundef @__PRETTY_FUNCTION__.__arm_2d_scene_player_set_switching_mode) #2
  unreachable

11:                                               ; preds = %9
  %12 = load ptr, ptr %5, align 8, !tbaa !5
  %13 = load ptr, ptr %4, 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 2
  %16 = getelementptr inbounds %struct.anon.5, ptr %15, i32 0, i32 0
  store ptr %12, ptr %16, align 8, !tbaa !11
  %17 = load ptr, ptr %5, align 8, !tbaa !5
  %18 = icmp eq ptr null, %17
  br i1 %18, label %19, label %20

19:                                               ; preds = %11
  br label %42

20:                                               ; preds = %11
  %21 = load i16, ptr %6, align 2, !tbaa !9
  %22 = zext i16 %21 to i32
  %23 = and i32 %22, 12288
  %24 = ashr i32 %23, 12
  %25 = icmp slt i32 %24, 3
  br i1 %25, label %26, label %27

26:                                               ; preds = %20
  br label %28

27:                                               ; preds = %20
  call void @__assert_fail(ptr noundef @.str.4, ptr noundef @.str.1, i32 noundef 413, ptr noundef @__PRETTY_FUNCTION__.__arm_2d_scene_player_set_switching_mode) #2
  unreachable

28:                                               ; preds = %26
  %29 = load i16, ptr %6, align 2, !tbaa !9
  %30 = load ptr, ptr %4, 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 2
  %33 = getelementptr inbounds %struct.anon.5, ptr %32, i32 0, i32 4
  store i16 %29, ptr %33, align 8, !tbaa !26
  %34 = load ptr, ptr %5, align 8, !tbaa !5
  %35 = getelementptr inbounds %struct.anon, ptr %34, i32 0, i32 0
  %36 = load i8, ptr %35, align 8, !tbaa !27
  %37 = load ptr, ptr %4, align 8, !tbaa !5
  %38 = getelementptr inbounds %struct.arm_2d_scene_player_t, ptr %37, i32 0, i32 2
  %39 = getelementptr inbounds %struct.anon.2, ptr %38, i32 0, i32 2
  %40 = getelementptr inbounds %struct.anon.5, ptr %39, i32 0, i32 4
  %41 = getelementptr inbounds %struct.anon.30, ptr %40, i32 0, i32 0
  store i8 %36, ptr %41, align 8, !tbaa !26
  br label %42

42:                                               ; preds = %28, %19
  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 = !{!"short", !7, i64 0}
!11 = !{!12, !6, i64 432}
!12 = !{!"arm_2d_scene_player_t", !13, i64 0, !17, i64 360, !19, i64 408}
!13 = !{!"arm_2d_helper_pfb_t", !7, i64 0, !14, i64 344}
!14 = !{!"", !15, i64 0, !16, i64 8, !16, i64 12}
!15 = !{!"long", !7, i64 0}
!16 = !{!"int", !7, i64 0}
!17 = !{!"", !16, i64 0, !16, i64 4, !15, i64 8, !15, i64 16, !16, i64 24, !18, i64 28, !10, i64 32, !10, i64 34, !16, i64 36, !15, i64 40}
!18 = !{!"float", !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, !10, i64 10, !7, i64 16, !7, i64 128, !23, i64 130, !10, i64 134, !10, i64 136, !15, i64 144}
!23 = !{!"arm_2d_location_t", !10, i64 0, !10, i64 2}
!24 = !{!"", !25, i64 0, !25, i64 16}
!25 = !{!"arm_2d_scene_evt_t", !6, i64 0, !6, i64 8}
!26 = !{!7, !7, i64 0}
!27 = !{!28, !7, i64 0}
!28 = !{!"", !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"

@.str.1 = external hidden unnamed_addr constant [89 x i8], align 1
@__PRETTY_FUNCTION__.__arm_2d_scene_player_set_switching_mode = external hidden unnamed_addr constant [111 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [107 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: nounwind uwtable
define dso_local void @__arm_2d_scene_player_set_switching_mode(ptr nocapture noundef nonnull writeonly %0, ptr noundef %1, i16 noundef zeroext %2) local_unnamed_addr #1 {
  %4 = getelementptr inbounds i8, ptr %0, i64 432
  store ptr %1, ptr %4, align 8, !tbaa !5
  %5 = icmp eq ptr %1, null
  br i1 %5, label %12, label %6

6:                                                ; preds = %3
  %7 = and i16 %2, 12288
  %.not = icmp eq i16 %7, 12288
  br i1 %.not, label %8, label %9

8:                                                ; preds = %6
  tail call void @__assert_fail(ptr noundef nonnull @.str.4, ptr noundef nonnull @.str.1, i32 noundef 413, ptr noundef nonnull @__PRETTY_FUNCTION__.__arm_2d_scene_player_set_switching_mode) #2
  unreachable

9:                                                ; preds = %6
  %10 = getelementptr inbounds i8, ptr %0, i64 560
  store i16 %2, ptr %10, align 8, !tbaa !24
  %11 = load i8, ptr %1, align 8, !tbaa !25
  store i8 %11, ptr %10, align 8, !tbaa !24
  br label %12

12:                                               ; preds = %3, %9
  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, !18, i64 432}
!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 = !{!8, !8, i64 0}
!25 = !{!26, !8, i64 0}
!26 = !{!"", !8, i64 0, !18, i64 8, !18, i64 16, !18, i64 24}


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