; LLVM IR from ARM-software/Arm-2D :: Library/Source/arm_2d_alpha_blending.ll_ (arm_2d_cccn888_sw_colour_filling_with_mask)

; 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_op_control = type { %struct.anon.10 }
%struct.anon.10 = type { ptr, %struct.anon.11, %struct.anon.12, i16, i16, i16, i16, ptr, %union.anon.13 }
%struct.anon.11 = type { ptr, ptr }
%struct.anon.12 = type { ptr, ptr }
%union.anon.13 = type { %struct.arm_2d_op_trans_msk_opa_t }
%struct.arm_2d_op_trans_msk_opa_t = type { %struct.arm_2d_op_core_t, %struct.anon.67, %struct.anon.68, %union.anon.69, %struct.anon.71, %struct.anon.72, %struct.__arm_2d_transform_info_t, i8 }
%struct.arm_2d_op_core_t = type { %struct.anon.14, i64 }
%struct.anon.14 = type { ptr, ptr, %struct.anon.15, i8, %union.arm_2d_op_status_t, %struct.arm_2d_op_evt_t }
%struct.anon.15 = type { i8 }
%union.arm_2d_op_status_t = type { %struct.anon.16 }
%struct.anon.16 = type { i16 }
%struct.arm_2d_op_evt_t = type { ptr, ptr }
%struct.anon.67 = type { ptr, ptr }
%struct.anon.68 = type { ptr }
%union.anon.69 = type { %struct.anon.70 }
%struct.anon.70 = type { i32 }
%struct.anon.71 = type { ptr, %struct.arm_2d_tile_t }
%struct.arm_2d_tile_t = type { %union.anon.48, %union.anon.57, %union.anon.58 }
%union.anon.48 = type { %struct.anon.49 }
%struct.anon.49 = type { i8, %union.arm_2d_color_info_t, %union.anon.50 }
%union.arm_2d_color_info_t = type { %struct.anon.1 }
%struct.anon.1 = type { i8 }
%union.anon.50 = type { i16 }
%union.anon.57 = type { %struct.arm_2d_region_t }
%struct.arm_2d_region_t = type { %union.anon.3, %union.anon.4 }
%union.anon.3 = type { %struct.arm_2d_location_t }
%struct.arm_2d_location_t = type { i16, i16 }
%union.anon.4 = type { %struct.arm_2d_size_t }
%struct.arm_2d_size_t = type { i16, i16 }
%union.anon.58 = type { ptr }
%struct.anon.72 = type { ptr, ptr }
%struct.__arm_2d_transform_info_t = type { float, float, float, %struct.arm_2d_point_float_t, %union.anon.59, %struct.anon.60 }
%struct.arm_2d_point_float_t = type { float, float }
%union.anon.59 = type { i32 }
%struct.anon.60 = type { %struct.arm_2d_location_t, %struct.anon.61 }
%struct.anon.61 = type { %struct.arm_2d_region_t, %struct.arm_2d_tile_t }
%struct.__arm_2d_sub_task_t = type { %struct.anon.0 }
%struct.anon.0 = type <{ ptr, ptr, i8, i32, [3 x i8], %union.anon }>
%union.anon = type { %struct.__arm_2d_param_copy_orig_msk_t }
%struct.__arm_2d_param_copy_orig_msk_t = type { %union.anon.7, %struct.__arm_2d_tile_param_t, %struct.__arm_2d_tile_param_t }
%union.anon.7 = type { %struct.__arm_2d_param_copy_orig_t }
%struct.__arm_2d_param_copy_orig_t = type { %union.anon.6, %struct.__arm_2d_tile_param_t }
%union.anon.6 = type { %struct.__arm_2d_param_copy_t }
%struct.__arm_2d_param_copy_t = type { %struct.__arm_2d_tile_param_t, %struct.__arm_2d_tile_param_t, %struct.arm_2d_size_t }
%struct.__arm_2d_tile_param_t = type { ptr, i32, i16, %union.arm_2d_color_info_t, i8, %struct.arm_2d_region_t, %struct.arm_2d_region_t, ptr }
%struct.arm_2d_op_fill_cl_msk_t = type { %struct.arm_2d_op_core_t, %struct.anon.20, %struct.anon.21, i32, %union.anon.22 }
%struct.anon.20 = type { ptr, ptr }
%struct.anon.21 = type { ptr }
%union.anon.22 = type { i32 }

@ARM_2D_CTRL = external global %struct.__arm_2d_op_control, align 8

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

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

; Function Attrs: nounwind uwtable
declare dso_local void @__arm_2d_impl_cccn888_colour_filling_mask(ptr noalias noundef, i16 noundef signext, ptr noalias noundef, i16 noundef signext, ptr noalias noundef, i32 noundef) #1

; Function Attrs: nounwind uwtable
declare dso_local void @__arm_2d_impl_cccn888_colour_filling_channel_mask(ptr noalias noundef, i16 noundef signext, ptr noalias noundef, i16 noundef signext, ptr noalias noundef, i32 noundef) #1

; Function Attrs: nounwind uwtable
define dso_local i32 @__arm_2d_cccn888_sw_colour_filling_with_mask(ptr noundef %0) #1 {
  %2 = alloca ptr, align 8
  %3 = alloca ptr, align 8
  store ptr %0, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #2
  %4 = load ptr, ptr %2, align 8, !tbaa !5
  %5 = getelementptr inbounds %struct.__arm_2d_sub_task_t, ptr %4, i32 0, i32 0
  %6 = getelementptr inbounds %struct.anon.0, ptr %5, i32 0, i32 1
  %7 = load ptr, ptr %6, align 8, !tbaa !9
  store ptr %7, ptr %3, align 8, !tbaa !5
  %8 = load ptr, ptr %3, align 8, !tbaa !5
  %9 = icmp eq ptr null, %8
  br i1 %9, label %10, label %11

10:                                               ; preds = %1
  store ptr getelementptr inbounds (%struct.anon.10, ptr @ARM_2D_CTRL, i32 0, i32 8), ptr %3, align 8, !tbaa !5
  br label %11

11:                                               ; preds = %10, %1
  %12 = load ptr, ptr %2, align 8, !tbaa !5
  %13 = getelementptr inbounds %struct.__arm_2d_sub_task_t, ptr %12, i32 0, i32 0
  %14 = getelementptr inbounds %struct.anon.0, ptr %13, i32 0, i32 5
  %15 = getelementptr inbounds %struct.__arm_2d_param_copy_t, ptr %14, i32 0, i32 0
  %16 = getelementptr inbounds %struct.__arm_2d_tile_param_t, ptr %15, i32 0, i32 3
  %17 = load i8, ptr %16, align 2, !tbaa !12
  %18 = zext i8 %17 to i32
  %19 = icmp eq i32 107, %18
  br i1 %19, label %20, label %52

20:                                               ; preds = %11
  %21 = load ptr, ptr %2, align 8, !tbaa !5
  %22 = getelementptr inbounds %struct.__arm_2d_sub_task_t, ptr %21, i32 0, i32 0
  %23 = getelementptr inbounds %struct.anon.0, ptr %22, i32 0, i32 5
  %24 = getelementptr inbounds %struct.__arm_2d_param_copy_t, ptr %23, i32 0, i32 1
  %25 = getelementptr inbounds %struct.__arm_2d_tile_param_t, ptr %24, i32 0, i32 0
  %26 = load ptr, ptr %25, align 8, !tbaa !12
  %27 = load ptr, ptr %2, align 8, !tbaa !5
  %28 = getelementptr inbounds %struct.__arm_2d_sub_task_t, ptr %27, i32 0, i32 0
  %29 = getelementptr inbounds %struct.anon.0, ptr %28, i32 0, i32 5
  %30 = getelementptr inbounds %struct.__arm_2d_param_copy_t, ptr %29, i32 0, i32 1
  %31 = getelementptr inbounds %struct.__arm_2d_tile_param_t, ptr %30, i32 0, i32 2
  %32 = load i16, ptr %31, align 4, !tbaa !12
  %33 = load ptr, ptr %2, align 8, !tbaa !5
  %34 = getelementptr inbounds %struct.__arm_2d_sub_task_t, ptr %33, i32 0, i32 0
  %35 = getelementptr inbounds %struct.anon.0, ptr %34, i32 0, i32 5
  %36 = getelementptr inbounds %struct.__arm_2d_param_copy_t, ptr %35, i32 0, i32 0
  %37 = getelementptr inbounds %struct.__arm_2d_tile_param_t, ptr %36, i32 0, i32 0
  %38 = load ptr, ptr %37, align 8, !tbaa !12
  %39 = load ptr, ptr %2, align 8, !tbaa !5
  %40 = getelementptr inbounds %struct.__arm_2d_sub_task_t, ptr %39, i32 0, i32 0
  %41 = getelementptr inbounds %struct.anon.0, ptr %40, i32 0, i32 5
  %42 = getelementptr inbounds %struct.__arm_2d_param_copy_t, ptr %41, i32 0, i32 0
  %43 = getelementptr inbounds %struct.__arm_2d_tile_param_t, ptr %42, i32 0, i32 2
  %44 = load i16, ptr %43, align 4, !tbaa !12
  %45 = load ptr, ptr %2, align 8, !tbaa !5
  %46 = getelementptr inbounds %struct.__arm_2d_sub_task_t, ptr %45, i32 0, i32 0
  %47 = getelementptr inbounds %struct.anon.0, ptr %46, i32 0, i32 5
  %48 = getelementptr inbounds %struct.__arm_2d_param_copy_t, ptr %47, i32 0, i32 2
  %49 = load ptr, ptr %3, align 8, !tbaa !5
  %50 = getelementptr inbounds %struct.arm_2d_op_fill_cl_msk_t, ptr %49, i32 0, i32 4
  %51 = load i32, ptr %50, align 4, !tbaa !12
  call void @__arm_2d_impl_cccn888_colour_filling_channel_mask(ptr noundef %26, i16 noundef signext %32, ptr noundef %38, i16 noundef signext %44, ptr noundef %48, i32 noundef %51)
  br label %84

52:                                               ; preds = %11
  %53 = load ptr, ptr %2, align 8, !tbaa !5
  %54 = getelementptr inbounds %struct.__arm_2d_sub_task_t, ptr %53, i32 0, i32 0
  %55 = getelementptr inbounds %struct.anon.0, ptr %54, i32 0, i32 5
  %56 = getelementptr inbounds %struct.__arm_2d_param_copy_t, ptr %55, i32 0, i32 1
  %57 = getelementptr inbounds %struct.__arm_2d_tile_param_t, ptr %56, i32 0, i32 0
  %58 = load ptr, ptr %57, align 8, !tbaa !12
  %59 = load ptr, ptr %2, align 8, !tbaa !5
  %60 = getelementptr inbounds %struct.__arm_2d_sub_task_t, ptr %59, i32 0, i32 0
  %61 = getelementptr inbounds %struct.anon.0, ptr %60, i32 0, i32 5
  %62 = getelementptr inbounds %struct.__arm_2d_param_copy_t, ptr %61, i32 0, i32 1
  %63 = getelementptr inbounds %struct.__arm_2d_tile_param_t, ptr %62, i32 0, i32 2
  %64 = load i16, ptr %63, align 4, !tbaa !12
  %65 = load ptr, ptr %2, align 8, !tbaa !5
  %66 = getelementptr inbounds %struct.__arm_2d_sub_task_t, ptr %65, i32 0, i32 0
  %67 = getelementptr inbounds %struct.anon.0, ptr %66, i32 0, i32 5
  %68 = getelementptr inbounds %struct.__arm_2d_param_copy_t, ptr %67, i32 0, i32 0
  %69 = getelementptr inbounds %struct.__arm_2d_tile_param_t, ptr %68, i32 0, i32 0
  %70 = load ptr, ptr %69, align 8, !tbaa !12
  %71 = load ptr, ptr %2, align 8, !tbaa !5
  %72 = getelementptr inbounds %struct.__arm_2d_sub_task_t, ptr %71, i32 0, i32 0
  %73 = getelementptr inbounds %struct.anon.0, ptr %72, i32 0, i32 5
  %74 = getelementptr inbounds %struct.__arm_2d_param_copy_t, ptr %73, i32 0, i32 0
  %75 = getelementptr inbounds %struct.__arm_2d_tile_param_t, ptr %74, i32 0, i32 2
  %76 = load i16, ptr %75, align 4, !tbaa !12
  %77 = load ptr, ptr %2, align 8, !tbaa !5
  %78 = getelementptr inbounds %struct.__arm_2d_sub_task_t, ptr %77, i32 0, i32 0
  %79 = getelementptr inbounds %struct.anon.0, ptr %78, i32 0, i32 5
  %80 = getelementptr inbounds %struct.__arm_2d_param_copy_t, ptr %79, i32 0, i32 2
  %81 = load ptr, ptr %3, align 8, !tbaa !5
  %82 = getelementptr inbounds %struct.arm_2d_op_fill_cl_msk_t, ptr %81, i32 0, i32 4
  %83 = load i32, ptr %82, align 4, !tbaa !12
  call void @__arm_2d_impl_cccn888_colour_filling_mask(ptr noundef %58, i16 noundef signext %64, ptr noundef %70, i16 noundef signext %76, ptr noundef %80, i32 noundef %83)
  br label %84

84:                                               ; preds = %52, %20
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #2
  ret i32 0
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { 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, !6, i64 8}
!10 = !{!"__arm_2d_sub_task_t", !11, i64 0}
!11 = !{!"", !6, i64 0, !6, i64 8, !7, i64 16, !7, i64 17, !7, i64 24}
!12 = !{!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"

%struct.__arm_2d_op_control = type { %struct.anon.10 }
%struct.anon.10 = type { ptr, %struct.anon.11, %struct.anon.12, i16, i16, i16, i16, ptr, %union.anon.13 }
%struct.anon.11 = type { ptr, ptr }
%struct.anon.12 = type { ptr, ptr }
%union.anon.13 = type { %struct.arm_2d_op_trans_msk_opa_t }
%struct.arm_2d_op_trans_msk_opa_t = type { %struct.arm_2d_op_core_t, %struct.anon.67, %struct.anon.68, %union.anon.69, %struct.anon.71, %struct.anon.72, %struct.__arm_2d_transform_info_t, i8 }
%struct.arm_2d_op_core_t = type { %struct.anon.14, i64 }
%struct.anon.14 = type { ptr, ptr, %struct.anon.15, i8, %union.arm_2d_op_status_t, %struct.arm_2d_op_evt_t }
%struct.anon.15 = type { i8 }
%union.arm_2d_op_status_t = type { %struct.anon.16 }
%struct.anon.16 = type { i16 }
%struct.arm_2d_op_evt_t = type { ptr, ptr }
%struct.anon.67 = type { ptr, ptr }
%struct.anon.68 = type { ptr }
%union.anon.69 = type { %struct.anon.70 }
%struct.anon.70 = type { i32 }
%struct.anon.71 = type { ptr, %struct.arm_2d_tile_t }
%struct.arm_2d_tile_t = type { %union.anon.48, %union.anon.57, %union.anon.58 }
%union.anon.48 = type { %struct.anon.49 }
%struct.anon.49 = type { i8, %union.arm_2d_color_info_t, %union.anon.50 }
%union.arm_2d_color_info_t = type { %struct.anon.1 }
%struct.anon.1 = type { i8 }
%union.anon.50 = type { i16 }
%union.anon.57 = type { %struct.arm_2d_region_t }
%struct.arm_2d_region_t = type { %union.anon.3, %union.anon.4 }
%union.anon.3 = type { %struct.arm_2d_location_t }
%struct.arm_2d_location_t = type { i16, i16 }
%union.anon.4 = type { %struct.arm_2d_size_t }
%struct.arm_2d_size_t = type { i16, i16 }
%union.anon.58 = type { ptr }
%struct.anon.72 = type { ptr, ptr }
%struct.__arm_2d_transform_info_t = type { float, float, float, %struct.arm_2d_point_float_t, %union.anon.59, %struct.anon.60 }
%struct.arm_2d_point_float_t = type { float, float }
%union.anon.59 = type { i32 }
%struct.anon.60 = type { %struct.arm_2d_location_t, %struct.anon.61 }
%struct.anon.61 = type { %struct.arm_2d_region_t, %struct.arm_2d_tile_t }

@ARM_2D_CTRL = external local_unnamed_addr global %struct.__arm_2d_op_control, align 8

; Function Attrs: nounwind uwtable
declare dso_local void @__arm_2d_impl_cccn888_colour_filling_mask(ptr noalias noundef, i16 noundef signext, ptr noalias noundef, i16 noundef signext, ptr noalias noundef, i32 noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare dso_local void @__arm_2d_impl_cccn888_colour_filling_channel_mask(ptr noalias noundef, i16 noundef signext, ptr noalias noundef, i16 noundef signext, ptr noalias noundef, i32 noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local noundef i32 @__arm_2d_cccn888_sw_colour_filling_with_mask(ptr noundef %0) local_unnamed_addr #0 {
  %2 = getelementptr inbounds i8, ptr %0, i64 8
  %3 = load ptr, ptr %2, align 8, !tbaa !5
  %4 = icmp eq ptr %3, null
  %spec.store.select = select i1 %4, ptr getelementptr inbounds (i8, ptr @ARM_2D_CTRL, i64 56), ptr %3
  %5 = getelementptr inbounds i8, ptr %0, i64 24
  %6 = getelementptr inbounds i8, ptr %0, i64 38
  %7 = load i8, ptr %6, align 2, !tbaa !11
  %8 = icmp eq i8 %7, 107
  %9 = getelementptr inbounds i8, ptr %0, i64 64
  %10 = load ptr, ptr %9, align 8, !tbaa !11
  %11 = getelementptr inbounds i8, ptr %0, i64 76
  %12 = load i16, ptr %11, align 4, !tbaa !11
  %13 = load ptr, ptr %5, align 8, !tbaa !11
  %14 = getelementptr inbounds i8, ptr %0, i64 36
  %15 = load i16, ptr %14, align 4, !tbaa !11
  %16 = getelementptr inbounds i8, ptr %0, i64 104
  %17 = getelementptr inbounds i8, ptr %spec.store.select, i64 76
  %18 = load i32, ptr %17, align 4, !tbaa !11
  br i1 %8, label %19, label %20

19:                                               ; preds = %1
  tail call void @__arm_2d_impl_cccn888_colour_filling_channel_mask(ptr noundef %10, i16 noundef signext %12, ptr noundef %13, i16 noundef signext %15, ptr noundef nonnull %16, i32 noundef %18)
  br label %21

20:                                               ; preds = %1
  tail call void @__arm_2d_impl_cccn888_colour_filling_mask(ptr noundef %10, i16 noundef signext %12, ptr noundef %13, i16 noundef signext %15, ptr noundef nonnull %16, i32 noundef %18)
  br label %21

21:                                               ; preds = %20, %19
  ret i32 0
}

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

!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, !8, i64 8}
!6 = !{!"__arm_2d_sub_task_t", !7, i64 0}
!7 = !{!"", !8, i64 0, !8, i64 8, !9, i64 16, !9, i64 17, !9, i64 24}
!8 = !{!"any pointer", !9, i64 0}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C/C++ TBAA"}
!11 = !{!9, !9, i64 0}


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