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

; 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_helper_pfb_t = type { %struct.anon, %struct.anon.30 }
%struct.anon = type { %struct.arm_2d_helper_pfb_cfg_t, %struct.anon.4 }
%struct.arm_2d_helper_pfb_cfg_t = type { %struct.arm_2d_region_t, %struct.anon.1, %struct.anon.2, %struct.arm_2d_helper_pfb_dependency_t }
%struct.arm_2d_region_t = type { %union.anon, %union.anon.0 }
%union.anon = type { %struct.arm_2d_location_t }
%struct.arm_2d_location_t = type { i16, i16 }
%union.anon.0 = type { %struct.arm_2d_size_t }
%struct.arm_2d_size_t = type { i16, i16 }
%struct.anon.1 = type <{ ptr, %struct.arm_2d_size_t, i64, [4 x i8] }>
%struct.anon.2 = type { ptr, i8 }
%struct.arm_2d_helper_pfb_dependency_t = type { %struct.arm_2d_helper_render_evt_t, %struct.arm_2d_helper_draw_evt_t, %struct.arm_2d_evt_t, %struct.arm_2d_evt_t, %struct.anon.3, %struct.arm_2d_helper_before_flushing_evt_t }
%struct.arm_2d_helper_render_evt_t = type { ptr, ptr }
%struct.arm_2d_helper_draw_evt_t = type { ptr, ptr }
%struct.arm_2d_evt_t = type { ptr, ptr }
%struct.anon.3 = type { %struct.arm_2d_helper_draw_evt_t, ptr }
%struct.arm_2d_helper_before_flushing_evt_t = type { ptr, ptr }
%struct.anon.4 = type { %struct.arm_2d_location_t, %struct.arm_2d_region_t, ptr, %struct.anon.5, %struct.arm_2d_tile_t, %struct.arm_2d_size_t, i32, i8, i8, i16, %struct.anon.21, %union.arm_2d_colour_t, i64, ptr, ptr, ptr, %struct.anon.29, ptr }
%struct.anon.5 = type { ptr, ptr, ptr, ptr, %struct.arm_2d_region_list_item_t }
%struct.arm_2d_region_list_item_t = type { ptr, %struct.anon.6, %struct.arm_2d_region_t, %struct.anon.7 }
%struct.anon.6 = type { ptr }
%struct.anon.7 = type { i8, i8, i16 }
%struct.arm_2d_tile_t = type { %union.anon.8, %union.anon.19, %union.anon.20 }
%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 }
%union.anon.20 = type { ptr }
%struct.anon.21 = type { i32 }
%union.arm_2d_colour_t = type { i32 }
%struct.anon.29 = type { ptr, ptr }
%struct.anon.30 = type { i64, i32, i32 }

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

5:                                                ; preds = %1
  br label %7

6:                                                ; preds = %1
  call void @__assert_fail(ptr noundef @.str, ptr noundef @.str.1, i32 noundef 357, ptr noundef @__PRETTY_FUNCTION__.arm_2d_helper_pfb_deinit) #3
  unreachable

7:                                                ; preds = %5
  %8 = load ptr, ptr %2, align 8, !tbaa !5
  %9 = getelementptr inbounds %struct.arm_2d_helper_pfb_t, ptr %8, i32 0, i32 0
  %10 = getelementptr inbounds %struct.anon, ptr %9, i32 0, i32 1
  %11 = getelementptr inbounds %struct.anon.4, ptr %10, i32 0, i32 12
  %12 = load i64, ptr %11, align 8, !tbaa !9
  call void @arm_2d_port_free_semaphore(i64 noundef %12)
  ret void
}

declare void @arm_2d_port_free_semaphore(i64 noundef) #2

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 = { "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, !33, i64 288}
!10 = !{!"arm_2d_helper_pfb_t", !11, i64 0, !35, i64 344}
!11 = !{!"", !12, i64 0, !25, i64 152}
!12 = !{!"arm_2d_helper_pfb_cfg_t", !13, i64 0, !14, i64 8, !18, i64 32, !19, i64 48}
!13 = !{!"arm_2d_region_t", !7, i64 0, !7, i64 4}
!14 = !{!"", !6, i64 0, !15, i64 8, !17, i64 12, !17, i64 15, !17, i64 16, !17, i64 17, !17, i64 17, !17, i64 17, !17, i64 17, !17, i64 18, !17, i64 19, !17, i64 19}
!15 = !{!"arm_2d_size_t", !16, i64 0, !16, i64 2}
!16 = !{!"short", !7, i64 0}
!17 = !{!"int", !7, i64 0}
!18 = !{!"", !6, i64 0, !7, i64 8}
!19 = !{!"arm_2d_helper_pfb_dependency_t", !20, i64 0, !21, i64 16, !22, i64 32, !22, i64 48, !23, i64 64, !24, i64 88}
!20 = !{!"arm_2d_helper_render_evt_t", !6, i64 0, !6, i64 8}
!21 = !{!"arm_2d_helper_draw_evt_t", !6, i64 0, !6, i64 8}
!22 = !{!"arm_2d_evt_t", !6, i64 0, !6, i64 8}
!23 = !{!"", !21, i64 0, !6, i64 16}
!24 = !{!"arm_2d_helper_before_flushing_evt_t", !6, i64 0, !6, i64 8}
!25 = !{!"", !26, i64 0, !13, i64 4, !6, i64 16, !27, i64 24, !31, i64 88, !15, i64 112, !17, i64 116, !7, i64 120, !7, i64 121, !16, i64 122, !32, i64 124, !7, i64 128, !33, i64 136, !6, i64 144, !6, i64 152, !6, i64 160, !34, i64 168, !6, i64 184}
!26 = !{!"arm_2d_location_t", !16, i64 0, !16, i64 2}
!27 = !{!"", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !28, i64 32}
!28 = !{!"arm_2d_region_list_item_t", !6, i64 0, !29, i64 8, !13, i64 16, !30, i64 24}
!29 = !{!"", !6, i64 0}
!30 = !{!"", !7, i64 0, !7, i64 1, !7, i64 1, !16, i64 2, !16, i64 2, !16, i64 2, !16, i64 2}
!31 = !{!"arm_2d_tile_t", !7, i64 0, !7, i64 4, !7, i64 16}
!32 = !{!"", !17, i64 0, !17, i64 0, !17, i64 0, !17, i64 0, !17, i64 0, !17, i64 0, !17, i64 0, !17, i64 0, !17, i64 1, !17, i64 1, !17, i64 1, !17, i64 1, !17, i64 1, !17, i64 1, !17, i64 1, !17, i64 1, !17, i64 2}
!33 = !{!"long", !7, i64 0}
!34 = !{!"", !6, i64 0, !6, i64 8}
!35 = !{!"", !33, i64 0, !17, i64 8, !17, i64 12}


; 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_helper_pfb_deinit(ptr nocapture noundef nonnull readonly %0) local_unnamed_addr #0 {
  %2 = getelementptr inbounds i8, ptr %0, i64 288
  %3 = load i64, ptr %2, align 8, !tbaa !5
  tail call void @arm_2d_port_free_semaphore(i64 noundef %3) #2
  ret void
}

declare void @arm_2d_port_free_semaphore(i64 noundef) local_unnamed_addr #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 = { "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 = { 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, !32, i64 288}
!6 = !{!"arm_2d_helper_pfb_t", !7, i64 0, !34, i64 344}
!7 = !{!"", !8, i64 0, !24, i64 152}
!8 = !{!"arm_2d_helper_pfb_cfg_t", !9, i64 0, !12, i64 8, !17, i64 32, !18, i64 48}
!9 = !{!"arm_2d_region_t", !10, i64 0, !10, i64 4}
!10 = !{!"omnipotent char", !11, i64 0}
!11 = !{!"Simple C/C++ TBAA"}
!12 = !{!"", !13, i64 0, !14, i64 8, !16, i64 12, !16, i64 15, !16, i64 16, !16, i64 17, !16, i64 17, !16, i64 17, !16, i64 17, !16, i64 18, !16, i64 19, !16, i64 19}
!13 = !{!"any pointer", !10, i64 0}
!14 = !{!"arm_2d_size_t", !15, i64 0, !15, i64 2}
!15 = !{!"short", !10, i64 0}
!16 = !{!"int", !10, i64 0}
!17 = !{!"", !13, i64 0, !10, i64 8}
!18 = !{!"arm_2d_helper_pfb_dependency_t", !19, i64 0, !20, i64 16, !21, i64 32, !21, i64 48, !22, i64 64, !23, i64 88}
!19 = !{!"arm_2d_helper_render_evt_t", !13, i64 0, !13, i64 8}
!20 = !{!"arm_2d_helper_draw_evt_t", !13, i64 0, !13, i64 8}
!21 = !{!"arm_2d_evt_t", !13, i64 0, !13, i64 8}
!22 = !{!"", !20, i64 0, !13, i64 16}
!23 = !{!"arm_2d_helper_before_flushing_evt_t", !13, i64 0, !13, i64 8}
!24 = !{!"", !25, i64 0, !9, i64 4, !13, i64 16, !26, i64 24, !30, i64 88, !14, i64 112, !16, i64 116, !10, i64 120, !10, i64 121, !15, i64 122, !31, i64 124, !10, i64 128, !32, i64 136, !13, i64 144, !13, i64 152, !13, i64 160, !33, i64 168, !13, i64 184}
!25 = !{!"arm_2d_location_t", !15, i64 0, !15, i64 2}
!26 = !{!"", !13, i64 0, !13, i64 8, !13, i64 16, !13, i64 24, !27, i64 32}
!27 = !{!"arm_2d_region_list_item_t", !13, i64 0, !28, i64 8, !9, i64 16, !29, i64 24}
!28 = !{!"", !13, i64 0}
!29 = !{!"", !10, i64 0, !10, i64 1, !10, i64 1, !15, i64 2, !15, i64 2, !15, i64 2, !15, i64 2}
!30 = !{!"arm_2d_tile_t", !10, i64 0, !10, i64 4, !10, i64 16}
!31 = !{!"", !16, i64 0, !16, i64 0, !16, i64 0, !16, i64 0, !16, i64 0, !16, i64 0, !16, i64 0, !16, i64 0, !16, i64 1, !16, i64 1, !16, i64 1, !16, i64 1, !16, i64 1, !16, i64 1, !16, i64 1, !16, i64 1, !16, i64 2}
!32 = !{!"long", !10, i64 0}
!33 = !{!"", !13, i64 0, !13, i64 8}
!34 = !{!"", !32, i64 0, !16, i64 8, !16, i64 12}


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