; LLVM IR from ARM-software/Arm-2D :: examples/common/benchmark (arm_2d_scene_benchmark_generic)

; 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.user_scene_benchmark_generic_t = type { %union.anon, %struct.anon.9 }
%union.anon = type { %struct.arm_2d_scene_t }
%struct.arm_2d_scene_t = type { [16 x i8], ptr, %union.arm_2d_colour_t, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, %struct.anon.6, [7 x i8], %struct.arm_2d_helper_dirty_region_t }
%union.arm_2d_colour_t = type { i32 }
%struct.anon.6 = type { i8 }
%struct.arm_2d_helper_dirty_region_t = type { [56 x i8], %struct.arm_2d_helper_dirty_region_item_t }
%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.7, %union.anon.8 }
%union.anon.7 = type { %struct.arm_2d_location_t }
%struct.arm_2d_location_t = type { i16, i16 }
%union.anon.8 = type { %struct.arm_2d_size_t }
%struct.arm_2d_size_t = type { i16, i16 }
%struct.anon.9 = type { [1 x i64], i8 }

@.str = external hidden unnamed_addr constant [22 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [112 x i8], align 1
@__PRETTY_FUNCTION__.__arm_2d_scene_benchmark_generic_init = external hidden unnamed_addr constant [129 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [15 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local ptr @__arm_2d_scene_benchmark_generic_init(ptr noundef nonnull %0, ptr noundef %1) #0 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i8, align 1
  %7 = alloca i32, align 4
  %8 = alloca %struct.user_scene_benchmark_generic_t, align 8
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 1, ptr %6) #7
  store i8 0, ptr %6, align 1, !tbaa !9
  %9 = load ptr, ptr %4, align 8, !tbaa !5
  %10 = icmp ne ptr null, %9
  br i1 %10, label %11, label %12

11:                                               ; preds = %2
  br label %13

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

13:                                               ; preds = %11
  %14 = load ptr, ptr %5, align 8, !tbaa !5
  %15 = icmp eq ptr null, %14
  br i1 %15, label %16, label %27

16:                                               ; preds = %13
  %17 = call noalias ptr @malloc(i64 noundef 256) #9
  store ptr %17, ptr %5, align 8, !tbaa !5
  %18 = load ptr, ptr %5, align 8, !tbaa !5
  %19 = icmp ne ptr null, %18
  br i1 %19, label %20, label %21

20:                                               ; preds = %16
  br label %22

21:                                               ; preds = %16
  call void @__assert_fail(ptr noundef @.str.2, ptr noundef @.str.1, i32 noundef 357, ptr noundef @__PRETTY_FUNCTION__.__arm_2d_scene_benchmark_generic_init) #8
  unreachable

22:                                               ; preds = %20
  %23 = load ptr, ptr %5, align 8, !tbaa !5
  %24 = icmp eq ptr null, %23
  br i1 %24, label %25, label %26

25:                                               ; preds = %22
  store ptr null, ptr %3, align 8
  store i32 1, ptr %7, align 4
  br label %58

26:                                               ; preds = %22
  br label %28

27:                                               ; preds = %13
  store i8 1, ptr %6, align 1, !tbaa !9
  br label %28

28:                                               ; preds = %27, %26
  %29 = load ptr, ptr %5, align 8, !tbaa !5
  call void @llvm.memset.p0.i64(ptr align 8 %29, i8 0, i64 256, i1 false)
  %30 = load ptr, ptr %5, align 8, !tbaa !5
  call void @llvm.memset.p0.i64(ptr align 8 %8, i8 0, i64 256, i1 false)
  %31 = getelementptr inbounds %struct.user_scene_benchmark_generic_t, ptr %8, i32 0, i32 0
  %32 = getelementptr inbounds %struct.arm_2d_scene_t, ptr %31, i32 0, i32 0
  %33 = getelementptr inbounds %struct.arm_2d_scene_t, ptr %31, i32 0, i32 1
  %34 = getelementptr inbounds %struct.arm_2d_scene_t, ptr %31, i32 0, i32 2
  %35 = getelementptr inbounds %struct.arm_2d_scene_t, ptr %31, i32 0, i32 3
  %36 = getelementptr inbounds %struct.arm_2d_scene_t, ptr %31, i32 0, i32 4
  %37 = getelementptr inbounds %struct.arm_2d_scene_t, ptr %31, i32 0, i32 5
  store ptr @__pfb_draw_scene_benchmark_generic_handler, ptr %37, align 8, !tbaa !11
  %38 = getelementptr inbounds %struct.arm_2d_scene_t, ptr %31, i32 0, i32 6
  %39 = getelementptr inbounds %struct.arm_2d_scene_t, ptr %31, i32 0, i32 7
  store ptr @__after_scene_benchmark_generic_switching, ptr %39, align 8, !tbaa !17
  %40 = getelementptr inbounds %struct.arm_2d_scene_t, ptr %31, i32 0, i32 8
  %41 = getelementptr inbounds %struct.arm_2d_scene_t, ptr %31, i32 0, i32 9
  %42 = getelementptr inbounds %struct.arm_2d_scene_t, ptr %31, i32 0, i32 10
  store ptr @__on_scene_benchmark_generic_frame_start, ptr %42, align 8, !tbaa !18
  %43 = getelementptr inbounds %struct.arm_2d_scene_t, ptr %31, i32 0, i32 11
  store ptr @__on_scene_benchmark_generic_frame_complete, ptr %43, align 8, !tbaa !19
  %44 = getelementptr inbounds %struct.arm_2d_scene_t, ptr %31, i32 0, i32 12
  %45 = getelementptr inbounds %struct.arm_2d_scene_t, ptr %31, i32 0, i32 13
  store ptr @__on_scene_benchmark_generic_depose, ptr %45, align 8, !tbaa !20
  %46 = getelementptr inbounds %struct.arm_2d_scene_t, ptr %31, i32 0, i32 14
  %47 = getelementptr inbounds %struct.arm_2d_scene_t, ptr %31, i32 0, i32 16
  %48 = getelementptr inbounds %struct.user_scene_benchmark_generic_t, ptr %8, i32 0, i32 1
  %49 = getelementptr inbounds %struct.anon.9, ptr %48, i32 0, i32 0
  %50 = getelementptr inbounds %struct.anon.9, ptr %48, i32 0, i32 1
  %51 = load i8, ptr %6, align 1, !tbaa !9, !range !21, !noundef !22
  %52 = trunc i8 %51 to i1
  %53 = zext i1 %52 to i8
  store i8 %53, ptr %50, align 8, !tbaa !23
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %30, ptr align 8 %8, i64 256, i1 false), !tbaa.struct !25
  call void @benchmark_generic_init()
  %54 = load ptr, ptr %4, align 8, !tbaa !5
  %55 = load ptr, ptr %5, align 8, !tbaa !5
  %56 = getelementptr inbounds %struct.user_scene_benchmark_generic_t, ptr %55, i32 0, i32 0
  call void @arm_2d_scene_player_append_scenes(ptr noundef %54, ptr noundef %56, i64 noundef 1)
  %57 = load ptr, ptr %5, align 8, !tbaa !5
  store ptr %57, ptr %3, align 8
  store i32 1, ptr %7, align 4
  br label %58

58:                                               ; preds = %28, %25
  call void @llvm.lifetime.end.p0(i64 1, ptr %6) #7
  %59 = load ptr, ptr %3, align 8
  ret ptr %59
}

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #1

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) #2

; Function Attrs: nounwind allocsize(0)
declare noalias ptr @malloc(i64 noundef) #3

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #4

; Function Attrs: nounwind uwtable
declare hidden i32 @__pfb_draw_scene_benchmark_generic_handler(ptr noundef, ptr noundef, i1 noundef zeroext) #0

; Function Attrs: nounwind uwtable
declare hidden void @__after_scene_benchmark_generic_switching(ptr noundef) #0

; Function Attrs: nounwind uwtable
declare hidden void @__on_scene_benchmark_generic_frame_start(ptr noundef) #0

; Function Attrs: nounwind uwtable
declare hidden void @__on_scene_benchmark_generic_frame_complete(ptr noundef) #0

; Function Attrs: nounwind uwtable
declare hidden void @__on_scene_benchmark_generic_depose(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) #5

declare void @benchmark_generic_init() #6

declare void @arm_2d_scene_player_append_scenes(ptr noundef, ptr noundef, i64 noundef) #6

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #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 willreturn memory(argmem: readwrite) }
attributes #2 = { 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 #3 = { nounwind allocsize(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 #4 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #5 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #6 = { "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 #7 = { nounwind }
attributes #8 = { noreturn nounwind }
attributes #9 = { nounwind allocsize(0) }

!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 = !{!"_Bool", !7, i64 0}
!11 = !{!12, !6, i64 48}
!12 = !{!"arm_2d_scene_t", !7, i64 0, !6, i64 16, !7, i64 24, !6, i64 32, !6, i64 40, !6, i64 48, !6, i64 56, !6, i64 64, !6, i64 72, !6, i64 80, !6, i64 88, !6, i64 96, !6, i64 104, !6, i64 112, !13, i64 120, !14, i64 128}
!13 = !{!"", !7, i64 0, !7, i64 0, !7, i64 0}
!14 = !{!"arm_2d_helper_dirty_region_t", !7, i64 0, !15, i64 56}
!15 = !{!"arm_2d_helper_dirty_region_item_t", !7, i64 0, !16, i64 48}
!16 = !{!"arm_2d_region_t", !7, i64 0, !7, i64 4}
!17 = !{!12, !6, i64 64}
!18 = !{!12, !6, i64 88}
!19 = !{!12, !6, i64 96}
!20 = !{!12, !6, i64 112}
!21 = !{i8 0, i8 2}
!22 = !{}
!23 = !{!24, !10, i64 8}
!24 = !{!"", !7, i64 0, !10, i64 8}
!25 = !{i64 0, i64 240, !26, i64 240, i64 8, !26, i64 248, i64 1, !9}
!26 = !{!7, !7, i64 0}


; 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 [112 x i8], align 1
@__PRETTY_FUNCTION__.__arm_2d_scene_benchmark_generic_init = external hidden unnamed_addr constant [129 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [15 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local noundef nonnull ptr @__arm_2d_scene_benchmark_generic_init(ptr noundef nonnull %0, ptr noundef %1) local_unnamed_addr #0 {
  %3 = icmp ne ptr %1, null
  br i1 %3, label %7, label %4

4:                                                ; preds = %2
  %5 = tail call noalias dereferenceable_or_null(256) ptr @malloc(i64 noundef 256) #5
  %.not = icmp eq ptr %5, null
  br i1 %.not, label %6, label %7

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

7:                                                ; preds = %2, %4
  %.014 = phi ptr [ %5, %4 ], [ %1, %2 ]
  %8 = zext i1 %3 to i8
  %.sroa.2.0..sroa_idx = getelementptr inbounds i8, ptr %.014, i64 48
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(48) %.014, i8 0, i64 48, i1 false)
  store ptr @__pfb_draw_scene_benchmark_generic_handler, ptr %.sroa.2.0..sroa_idx, align 8
  %.sroa.3.0..sroa_idx = getelementptr inbounds i8, ptr %.014, i64 56
  store ptr null, ptr %.sroa.3.0..sroa_idx, align 8
  %.sroa.31.0..sroa_idx = getelementptr inbounds i8, ptr %.014, i64 64
  store ptr @__after_scene_benchmark_generic_switching, ptr %.sroa.31.0..sroa_idx, align 8
  %.sroa.4.0..sroa_idx = getelementptr inbounds i8, ptr %.014, i64 72
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(16) %.sroa.4.0..sroa_idx, i8 0, i64 16, i1 false)
  %.sroa.42.0..sroa_idx = getelementptr inbounds i8, ptr %.014, i64 88
  store ptr @__on_scene_benchmark_generic_frame_start, ptr %.sroa.42.0..sroa_idx, align 8
  %.sroa.5.0..sroa_idx = getelementptr inbounds i8, ptr %.014, i64 96
  store ptr @__on_scene_benchmark_generic_frame_complete, ptr %.sroa.5.0..sroa_idx, align 8
  %.sroa.6.0..sroa_idx = getelementptr inbounds i8, ptr %.014, i64 104
  store ptr null, ptr %.sroa.6.0..sroa_idx, align 8
  %.sroa.63.0..sroa_idx = getelementptr inbounds i8, ptr %.014, i64 112
  store ptr @__on_scene_benchmark_generic_depose, ptr %.sroa.63.0..sroa_idx, align 8
  %.sroa.7.0..sroa_idx = getelementptr inbounds i8, ptr %.014, i64 120
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(128) %.sroa.7.0..sroa_idx, i8 0, i64 128, i1 false)
  %.sroa.74.0..sroa_idx = getelementptr inbounds i8, ptr %.014, i64 248
  store i8 %8, ptr %.sroa.74.0..sroa_idx, align 8, !tbaa !5
  %.sroa.8.0..sroa_idx = getelementptr inbounds i8, ptr %.014, i64 249
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 1 dereferenceable(7) %.sroa.8.0..sroa_idx, i8 0, i64 7, i1 false)
  tail call void @benchmark_generic_init() #7
  tail call void @arm_2d_scene_player_append_scenes(ptr noundef nonnull %0, ptr noundef nonnull %.014, i64 noundef 1) #7
  ret ptr %.014
}

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #1

; Function Attrs: mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @malloc(i64 noundef) local_unnamed_addr #2

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #3

; Function Attrs: nounwind uwtable
declare hidden i32 @__pfb_draw_scene_benchmark_generic_handler(ptr noundef, ptr noundef, i1 noundef zeroext) #0

; Function Attrs: nounwind uwtable
declare hidden void @__after_scene_benchmark_generic_switching(ptr noundef) #0

; Function Attrs: nounwind uwtable
declare hidden void @__on_scene_benchmark_generic_frame_start(ptr noundef) #0

; Function Attrs: nounwind uwtable
declare hidden void @__on_scene_benchmark_generic_frame_complete(ptr noundef) #0

; Function Attrs: nounwind uwtable
declare hidden void @__on_scene_benchmark_generic_depose(ptr noundef) #0

declare void @benchmark_generic_init() local_unnamed_addr #4

declare void @arm_2d_scene_player_append_scenes(ptr noundef, ptr noundef, i64 noundef) local_unnamed_addr #4

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 = { 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 #2 = { mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite) "alloc-family"="malloc" "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 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #4 = { "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 #5 = { nounwind allocsize(0) }
attributes #6 = { noreturn nounwind }
attributes #7 = { 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 = !{!"_Bool", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}


; Effective O3 passes: CorrelatedValuePropagationPass,DSEPass,EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,MemCpyOptPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass