; 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_location_t = type { i16, i16 }
%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.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_manual_switching_offset = external hidden unnamed_addr constant [97 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 nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #1

; Function Attrs: nounwind uwtable
define dso_local void @arm_2d_scene_player_set_manual_switching_offset(ptr noundef nonnull %0, i32 %1) #2 {
  %3 = alloca %struct.arm_2d_location_t, align 2
  %4 = alloca ptr, align 8
  store i32 %1, ptr %3, align 2
  store ptr %0, ptr %4, align 8, !tbaa !5
  %5 = load ptr, ptr %4, 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 461, ptr noundef @__PRETTY_FUNCTION__.arm_2d_scene_player_set_manual_switching_offset) #3
  unreachable

9:                                                ; preds = %7
  %10 = getelementptr inbounds %struct.arm_2d_location_t, ptr %3, i32 0, i32 0
  %11 = load i16, ptr %10, align 2, !tbaa !9
  %12 = sext i16 %11 to i32
  %13 = icmp slt i32 %12, 0
  br i1 %13, label %19, label %14

14:                                               ; preds = %9
  %15 = getelementptr inbounds %struct.arm_2d_location_t, ptr %3, i32 0, i32 1
  %16 = load i16, ptr %15, align 2, !tbaa !12
  %17 = sext i16 %16 to i32
  %18 = icmp slt i32 %17, 0
  br i1 %18, label %19, label %20

19:                                               ; preds = %14, %9
  br label %59

20:                                               ; preds = %14
  %21 = load ptr, ptr %4, align 8, !tbaa !5
  %22 = getelementptr inbounds %struct.arm_2d_scene_player_t, ptr %21, i32 0, i32 2
  %23 = getelementptr inbounds %struct.anon.2, ptr %22, i32 0, i32 1
  %24 = load i16, ptr %23, align 8
  %25 = and i16 %24, -3
  %26 = or i16 %25, 2
  store i16 %26, ptr %23, align 8
  %27 = load ptr, ptr %4, 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 2
  %30 = getelementptr inbounds %struct.anon.5, ptr %29, i32 0, i32 5
  call void @llvm.memcpy.p0.p0.i64(ptr align 2 %30, ptr align 2 %3, i64 4, i1 false), !tbaa.struct !13
  br label %31

31:                                               ; preds = %20
  br label %32

32:                                               ; preds = %31
  %33 = load ptr, ptr %4, align 8, !tbaa !5
  %34 = getelementptr inbounds %struct.arm_2d_scene_player_t, ptr %33, i32 0, i32 2
  %35 = getelementptr inbounds %struct.anon.2, ptr %34, i32 0, i32 2
  %36 = getelementptr inbounds %struct.anon.5, ptr %35, i32 0, i32 0
  %37 = load ptr, ptr %36, align 8, !tbaa !15
  %38 = icmp eq ptr null, %37
  br i1 %38, label %39, label %40

39:                                               ; preds = %32
  br label %59

40:                                               ; preds = %32
  %41 = load ptr, ptr %4, align 8, !tbaa !5
  %42 = getelementptr inbounds %struct.arm_2d_scene_player_t, ptr %41, i32 0, i32 2
  %43 = getelementptr inbounds %struct.anon.2, ptr %42, i32 0, i32 2
  %44 = getelementptr inbounds %struct.anon.5, ptr %43, i32 0, i32 0
  %45 = load ptr, ptr %44, align 8, !tbaa !15
  %46 = getelementptr inbounds %struct.anon, ptr %45, i32 0, i32 2
  %47 = load ptr, ptr %46, align 8, !tbaa !29
  %48 = icmp ne ptr null, %47
  br i1 %48, label %49, label %58

49:                                               ; preds = %40
  %50 = load ptr, ptr %4, align 8, !tbaa !5
  %51 = getelementptr inbounds %struct.arm_2d_scene_player_t, ptr %50, i32 0, i32 2
  %52 = getelementptr inbounds %struct.anon.2, ptr %51, i32 0, i32 2
  %53 = getelementptr inbounds %struct.anon.5, ptr %52, i32 0, i32 0
  %54 = load ptr, ptr %53, align 8, !tbaa !15
  %55 = getelementptr inbounds %struct.anon, ptr %54, i32 0, i32 2
  %56 = load ptr, ptr %55, align 8, !tbaa !29
  %57 = load ptr, ptr %4, align 8, !tbaa !5
  call void %56(ptr noundef %57)
  br label %58

58:                                               ; preds = %49, %40
  br label %59

59:                                               ; preds = %58, %39, %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 = { nocallback nofree 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 = { 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, !11, i64 0}
!10 = !{!"arm_2d_location_t", !11, i64 0, !11, i64 2}
!11 = !{!"short", !7, i64 0}
!12 = !{!10, !11, i64 2}
!13 = !{i64 0, i64 2, !14, i64 2, i64 2, !14}
!14 = !{!11, !11, i64 0}
!15 = !{!16, !6, i64 432}
!16 = !{!"arm_2d_scene_player_t", !17, i64 0, !21, i64 360, !23, i64 408}
!17 = !{!"arm_2d_helper_pfb_t", !7, i64 0, !18, i64 344}
!18 = !{!"", !19, i64 0, !20, i64 8, !20, i64 12}
!19 = !{!"long", !7, i64 0}
!20 = !{!"int", !7, i64 0}
!21 = !{!"", !20, i64 0, !20, i64 4, !19, i64 8, !19, i64 16, !20, i64 24, !22, i64 28, !11, i64 32, !11, i64 34, !20, i64 36, !19, i64 40}
!22 = !{!"float", !7, i64 0}
!23 = !{!"", !24, i64 0, !25, i64 16, !26, i64 24, !27, i64 176}
!24 = !{!"", !6, i64 0, !6, i64 8}
!25 = !{!"", !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}
!26 = !{!"", !6, i64 0, !7, i64 8, !11, i64 10, !7, i64 16, !7, i64 128, !10, i64 130, !11, i64 134, !11, i64 136, !19, i64 144}
!27 = !{!"", !28, i64 0, !28, i64 16}
!28 = !{!"arm_2d_scene_evt_t", !6, i64 0, !6, i64 8}
!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_manual_switching_offset(ptr noundef nonnull %0, i32 %1) local_unnamed_addr #0 {
  %3 = and i32 %1, -2147450880
  %or.cond.not = icmp eq i32 %3, 0
  br i1 %or.cond.not, label %4, label %16

4:                                                ; preds = %2
  %.sroa.3.0.extract.shift = lshr i32 %1, 16
  %.sroa.3.0.extract.trunc = trunc nuw i32 %.sroa.3.0.extract.shift to i16
  %.sroa.0.0.extract.trunc = trunc i32 %1 to i16
  %5 = getelementptr inbounds i8, ptr %0, i64 424
  %6 = load i16, ptr %5, align 8
  %7 = or i16 %6, 2
  store i16 %7, ptr %5, align 8
  %8 = getelementptr inbounds i8, ptr %0, i64 432
  %9 = getelementptr inbounds i8, ptr %0, i64 562
  store i16 %.sroa.0.0.extract.trunc, ptr %9, align 2, !tbaa !5
  %.sroa.3.0..sroa_idx = getelementptr inbounds i8, ptr %0, i64 564
  store i16 %.sroa.3.0.extract.trunc, ptr %.sroa.3.0..sroa_idx, align 2, !tbaa !5
  %10 = load ptr, ptr %8, align 8, !tbaa !9
  %11 = icmp eq ptr %10, null
  br i1 %11, label %16, label %12

12:                                               ; preds = %4
  %13 = getelementptr inbounds i8, ptr %10, i64 16
  %14 = load ptr, ptr %13, align 8, !tbaa !25
  %.not = icmp eq ptr %14, null
  br i1 %.not, label %16, label %15

15:                                               ; preds = %12
  tail call void %14(ptr noundef nonnull %0) #1
  br label %16

16:                                               ; preds = %12, %15, %4, %2
  ret void
}

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 = { 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 = !{!"short", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !19, i64 432}
!10 = !{!"arm_2d_scene_player_t", !11, i64 0, !15, i64 360, !17, i64 408}
!11 = !{!"arm_2d_helper_pfb_t", !7, i64 0, !12, i64 344}
!12 = !{!"", !13, i64 0, !14, i64 8, !14, i64 12}
!13 = !{!"long", !7, i64 0}
!14 = !{!"int", !7, i64 0}
!15 = !{!"", !14, i64 0, !14, i64 4, !13, i64 8, !13, i64 16, !14, i64 24, !16, i64 28, !6, i64 32, !6, i64 34, !14, i64 36, !13, i64 40}
!16 = !{!"float", !7, i64 0}
!17 = !{!"", !18, i64 0, !20, i64 16, !21, i64 24, !23, i64 176}
!18 = !{!"", !19, i64 0, !19, i64 8}
!19 = !{!"any pointer", !7, i64 0}
!20 = !{!"", !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}
!21 = !{!"", !19, i64 0, !7, i64 8, !6, i64 10, !7, i64 16, !7, i64 128, !22, i64 130, !6, i64 134, !6, i64 136, !13, i64 144}
!22 = !{!"arm_2d_location_t", !6, i64 0, !6, i64 2}
!23 = !{!"", !24, i64 0, !24, i64 16}
!24 = !{!"arm_2d_scene_evt_t", !19, i64 0, !19, i64 8}
!25 = !{!26, !19, i64 16}
!26 = !{!"", !7, i64 0, !19, i64 8, !19, i64 16, !19, i64 24}


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