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

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

%union.arm_2d_colour_t = type { i32 }
%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 }
%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_enable_drawing_canvas_colour = external hidden unnamed_addr constant [94 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 nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #1

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

; 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) #2

; Function Attrs: nounwind uwtable
define dso_local void @__arm_2d_helper_pfb_enable_drawing_canvas_colour(ptr noundef nonnull %0, i32 %1) #3 {
  %3 = alloca %union.arm_2d_colour_t, align 4
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  %6 = alloca ptr, align 8
  %7 = getelementptr inbounds %union.arm_2d_colour_t, ptr %3, i32 0, i32 0
  store i32 %1, ptr %7, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  %8 = load ptr, ptr %4, align 8, !tbaa !5
  %9 = icmp ne ptr null, %8
  br i1 %9, label %10, label %11

10:                                               ; preds = %2
  br label %12

11:                                               ; preds = %2
  call void @__assert_fail(ptr noundef @.str, ptr noundef @.str.1, i32 noundef 431, ptr noundef @__PRETTY_FUNCTION__.__arm_2d_helper_pfb_enable_drawing_canvas_colour) #4
  unreachable

12:                                               ; preds = %10
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #5
  store i32 0, ptr %5, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #5
  store ptr null, ptr %6, align 8, !tbaa !5
  br label %13

13:                                               ; preds = %18, %12
  %14 = load ptr, ptr %6, align 8, !tbaa !5
  %15 = getelementptr inbounds i32, ptr %14, i32 1
  store ptr %15, ptr %6, align 8, !tbaa !5
  %16 = icmp eq ptr %14, null
  br i1 %16, label %18, label %17

17:                                               ; preds = %13
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #5
  br label %30

18:                                               ; preds = %13
  %19 = load ptr, ptr %4, align 8, !tbaa !5
  %20 = getelementptr inbounds %struct.arm_2d_helper_pfb_t, ptr %19, i32 0, i32 0
  %21 = getelementptr inbounds %struct.anon, ptr %20, i32 0, i32 1
  %22 = getelementptr inbounds %struct.anon.4, ptr %21, i32 0, i32 10
  %23 = load i32, ptr %22, align 4
  %24 = and i32 %23, -513
  %25 = or i32 %24, 0
  store i32 %25, ptr %22, align 4
  %26 = load ptr, ptr %4, align 8, !tbaa !5
  %27 = getelementptr inbounds %struct.arm_2d_helper_pfb_t, ptr %26, i32 0, i32 0
  %28 = getelementptr inbounds %struct.anon, ptr %27, i32 0, i32 1
  %29 = getelementptr inbounds %struct.anon.4, ptr %28, i32 0, i32 11
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %29, ptr align 4 %3, i64 4, i1 false), !tbaa.struct !11
  br label %13, !llvm.loop !13

30:                                               ; preds = %17
  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 nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { 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 #4 = { noreturn nounwind }
attributes #5 = { 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 = !{!"int", !7, i64 0}
!11 = !{i64 0, i64 4, !12}
!12 = !{!7, !7, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}


; 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: readwrite) uwtable
define dso_local void @__arm_2d_helper_pfb_enable_drawing_canvas_colour(ptr nocapture noundef nonnull %0, i32 %1) local_unnamed_addr #0 {
  %3 = getelementptr inbounds i8, ptr %0, i64 276
  %.promoted = load i32, ptr %3, align 4
  %4 = and i32 %.promoted, -513
  %5 = getelementptr inbounds i8, ptr %0, i64 280
  store i32 %4, ptr %3, align 4
  store i32 %1, ptr %5, align 8, !tbaa !5
  ret void
}

attributes #0 = { mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: readwrite) 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)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"omnipotent char", !7, i64 0}
!7 = !{!"Simple C/C++ TBAA"}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,LICMPass,LoopRotatePass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass