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

; 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 }
%struct.anon = type { ptr, %struct.anon.0, %struct.anon.1, i16, i16, i16, i16, ptr, %union.anon }
%struct.anon.0 = type { ptr, ptr }
%struct.anon.1 = type { ptr, ptr }
%union.anon = 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.59, %struct.anon.60, %union.anon.61, %struct.anon.63, %struct.anon.64, %struct.__arm_2d_transform_info_t, i8 }
%struct.arm_2d_op_core_t = type { %struct.anon.2, i64 }
%struct.anon.2 = type { ptr, ptr, %struct.anon.3, i8, %union.arm_2d_op_status_t, %struct.arm_2d_op_evt_t }
%struct.anon.3 = type { i8 }
%union.arm_2d_op_status_t = type { %struct.anon.4 }
%struct.anon.4 = type { i16 }
%struct.arm_2d_op_evt_t = type { ptr, ptr }
%struct.anon.59 = type { ptr, ptr }
%struct.anon.60 = type { ptr }
%union.anon.61 = type { %struct.anon.62 }
%struct.anon.62 = type { i32 }
%struct.anon.63 = type { ptr, %struct.arm_2d_tile_t }
%struct.arm_2d_tile_t = type { %union.anon.36, %union.anon.47, %union.anon.50 }
%union.anon.36 = type { %struct.anon.37 }
%struct.anon.37 = type { i8, %union.arm_2d_color_info_t, %union.anon.40 }
%union.arm_2d_color_info_t = type { %struct.anon.38 }
%struct.anon.38 = type { i8 }
%union.anon.40 = type { i16 }
%union.anon.47 = type { %struct.arm_2d_region_t }
%struct.arm_2d_region_t = type { %union.anon.48, %union.anon.49 }
%union.anon.48 = type { %struct.arm_2d_location_t }
%struct.arm_2d_location_t = type { i16, i16 }
%union.anon.49 = type { %struct.arm_2d_size_t }
%struct.arm_2d_size_t = type { i16, i16 }
%union.anon.50 = type { ptr }
%struct.anon.64 = type { ptr, ptr }
%struct.__arm_2d_transform_info_t = type { float, float, float, %struct.arm_2d_point_float_t, %union.anon.51, %struct.anon.52 }
%struct.arm_2d_point_float_t = type { float, float }
%union.anon.51 = type { i32 }
%struct.anon.52 = type { %struct.arm_2d_location_t, %struct.anon.53 }
%struct.anon.53 = type { %struct.arm_2d_region_t, %struct.arm_2d_tile_t }
%struct.__arm_2d_sub_task_t = type { %struct.anon.82 }
%struct.anon.82 = type <{ ptr, ptr, i8, i32, [3 x i8], %union.anon.83 }>
%union.anon.83 = type { %struct.__arm_2d_param_copy_orig_msk_t }
%struct.__arm_2d_param_copy_orig_msk_t = type { %union.anon.86, %struct.__arm_2d_tile_param_t, %struct.__arm_2d_tile_param_t }
%union.anon.86 = type { %struct.__arm_2d_param_copy_orig_t }
%struct.__arm_2d_param_copy_orig_t = type { %union.anon.85, %struct.__arm_2d_tile_param_t }
%union.anon.85 = 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_src_t = type { %struct.arm_2d_op_core_t, %struct.anon.13, %struct.anon.14, i32 }
%struct.anon.13 = type { ptr, ptr }
%struct.anon.14 = type { ptr }

@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
define dso_local i32 @__arm_2d_sw_convert_colour_to_gray8(ptr noundef %0) #1 {
  %2 = alloca i32, align 4
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca %struct.arm_2d_region_t, align 2
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #3
  %8 = load ptr, ptr %3, align 8, !tbaa !5
  %9 = getelementptr inbounds %struct.__arm_2d_sub_task_t, ptr %8, i32 0, i32 0
  %10 = getelementptr inbounds %struct.anon.82, ptr %9, i32 0, i32 1
  %11 = load ptr, ptr %10, align 8, !tbaa !9
  store ptr %11, ptr %4, align 8, !tbaa !5
  %12 = load ptr, ptr %4, align 8, !tbaa !5
  %13 = icmp eq ptr null, %12
  br i1 %13, label %14, label %15

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

15:                                               ; preds = %14, %1
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #3
  %16 = load ptr, ptr %4, align 8, !tbaa !5
  %17 = getelementptr inbounds %struct.arm_2d_op_src_t, ptr %16, i32 0, i32 2
  %18 = getelementptr inbounds %struct.anon.14, ptr %17, i32 0, i32 0
  %19 = load ptr, ptr %18, align 8, !tbaa !12
  %20 = call ptr @arm_2d_tile_get_root(ptr noundef %19, ptr noundef %5, ptr noundef null)
  store ptr %20, ptr %6, align 8, !tbaa !5
  %21 = load ptr, ptr %6, align 8, !tbaa !5
  %22 = icmp eq ptr null, %21
  br i1 %22, label %23, label %24

23:                                               ; preds = %15
  store i32 0, ptr %2, align 4
  store i32 1, ptr %7, align 4
  br label %166

24:                                               ; preds = %15
  %25 = load ptr, ptr %6, align 8, !tbaa !5
  %26 = getelementptr inbounds %struct.arm_2d_tile_t, ptr %25, i32 0, i32 0
  %27 = load i8, ptr %26, align 8
  %28 = lshr i8 %27, 1
  %29 = and i8 %28, 1
  %30 = icmp ne i8 %29, 0
  br i1 %30, label %32, label %31

31:                                               ; preds = %24
  store i32 -6, ptr %2, align 4
  store i32 1, ptr %7, align 4
  br label %166

32:                                               ; preds = %24
  %33 = load ptr, ptr %6, align 8, !tbaa !5
  %34 = getelementptr inbounds %struct.arm_2d_tile_t, ptr %33, i32 0, i32 0
  %35 = getelementptr inbounds %struct.anon.37, ptr %34, i32 0, i32 1
  %36 = load i8, ptr %35, align 1
  %37 = lshr i8 %36, 1
  %38 = and i8 %37, 7
  %39 = zext i8 %38 to i32
  switch i32 %39, label %164 [
    i32 6, label %40
    i32 4, label %69
    i32 5, label %98
  ]

40:                                               ; preds = %32
  %41 = load ptr, ptr %3, align 8, !tbaa !5
  %42 = getelementptr inbounds %struct.__arm_2d_sub_task_t, ptr %41, i32 0, i32 0
  %43 = getelementptr inbounds %struct.anon.82, ptr %42, i32 0, i32 5
  %44 = getelementptr inbounds %struct.__arm_2d_param_copy_t, ptr %43, i32 0, i32 0
  %45 = getelementptr inbounds %struct.__arm_2d_tile_param_t, ptr %44, i32 0, i32 0
  %46 = load ptr, ptr %45, align 8, !tbaa !22
  %47 = load ptr, ptr %3, align 8, !tbaa !5
  %48 = getelementptr inbounds %struct.__arm_2d_sub_task_t, ptr %47, i32 0, i32 0
  %49 = getelementptr inbounds %struct.anon.82, ptr %48, i32 0, i32 5
  %50 = getelementptr inbounds %struct.__arm_2d_param_copy_t, ptr %49, i32 0, i32 0
  %51 = getelementptr inbounds %struct.__arm_2d_tile_param_t, ptr %50, i32 0, i32 2
  %52 = load i16, ptr %51, align 4, !tbaa !22
  %53 = load ptr, ptr %3, align 8, !tbaa !5
  %54 = getelementptr inbounds %struct.__arm_2d_sub_task_t, ptr %53, i32 0, i32 0
  %55 = getelementptr inbounds %struct.anon.82, 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 !22
  %59 = load ptr, ptr %3, align 8, !tbaa !5
  %60 = getelementptr inbounds %struct.__arm_2d_sub_task_t, ptr %59, i32 0, i32 0
  %61 = getelementptr inbounds %struct.anon.82, 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 !22
  %65 = load ptr, ptr %3, align 8, !tbaa !5
  %66 = getelementptr inbounds %struct.__arm_2d_sub_task_t, ptr %65, i32 0, i32 0
  %67 = getelementptr inbounds %struct.anon.82, ptr %66, i32 0, i32 5
  %68 = getelementptr inbounds %struct.__arm_2d_param_copy_t, ptr %67, i32 0, i32 2
  call void @__arm_2d_impl_c8bit_copy(ptr noundef %46, i16 noundef signext %52, ptr noundef %58, i16 noundef signext %64, ptr noundef %68)
  br label %165

69:                                               ; preds = %32
  %70 = load ptr, ptr %3, align 8, !tbaa !5
  %71 = getelementptr inbounds %struct.__arm_2d_sub_task_t, ptr %70, i32 0, i32 0
  %72 = getelementptr inbounds %struct.anon.82, ptr %71, i32 0, i32 5
  %73 = getelementptr inbounds %struct.__arm_2d_param_copy_t, ptr %72, i32 0, i32 0
  %74 = getelementptr inbounds %struct.__arm_2d_tile_param_t, ptr %73, i32 0, i32 0
  %75 = load ptr, ptr %74, align 8, !tbaa !22
  %76 = load ptr, ptr %3, align 8, !tbaa !5
  %77 = getelementptr inbounds %struct.__arm_2d_sub_task_t, ptr %76, i32 0, i32 0
  %78 = getelementptr inbounds %struct.anon.82, ptr %77, i32 0, i32 5
  %79 = getelementptr inbounds %struct.__arm_2d_param_copy_t, ptr %78, i32 0, i32 0
  %80 = getelementptr inbounds %struct.__arm_2d_tile_param_t, ptr %79, i32 0, i32 2
  %81 = load i16, ptr %80, align 4, !tbaa !22
  %82 = load ptr, ptr %3, align 8, !tbaa !5
  %83 = getelementptr inbounds %struct.__arm_2d_sub_task_t, ptr %82, i32 0, i32 0
  %84 = getelementptr inbounds %struct.anon.82, ptr %83, i32 0, i32 5
  %85 = getelementptr inbounds %struct.__arm_2d_param_copy_t, ptr %84, i32 0, i32 1
  %86 = getelementptr inbounds %struct.__arm_2d_tile_param_t, ptr %85, i32 0, i32 0
  %87 = load ptr, ptr %86, align 8, !tbaa !22
  %88 = load ptr, ptr %3, align 8, !tbaa !5
  %89 = getelementptr inbounds %struct.__arm_2d_sub_task_t, ptr %88, i32 0, i32 0
  %90 = getelementptr inbounds %struct.anon.82, ptr %89, i32 0, i32 5
  %91 = getelementptr inbounds %struct.__arm_2d_param_copy_t, ptr %90, i32 0, i32 1
  %92 = getelementptr inbounds %struct.__arm_2d_tile_param_t, ptr %91, i32 0, i32 2
  %93 = load i16, ptr %92, align 4, !tbaa !22
  %94 = load ptr, ptr %3, align 8, !tbaa !5
  %95 = getelementptr inbounds %struct.__arm_2d_sub_task_t, ptr %94, i32 0, i32 0
  %96 = getelementptr inbounds %struct.anon.82, ptr %95, i32 0, i32 5
  %97 = getelementptr inbounds %struct.__arm_2d_param_copy_t, ptr %96, i32 0, i32 2
  call void @__arm_2d_impl_rgb565_to_gray8(ptr noundef %75, i16 noundef signext %81, ptr noundef %87, i16 noundef signext %93, ptr noundef %97)
  br label %165

98:                                               ; preds = %32
  %99 = load ptr, ptr %6, align 8, !tbaa !5
  %100 = getelementptr inbounds %struct.arm_2d_tile_t, ptr %99, i32 0, i32 0
  %101 = getelementptr inbounds %struct.anon.37, ptr %100, i32 0, i32 1
  %102 = load i8, ptr %101, align 1
  %103 = and i8 %102, 1
  %104 = icmp ne i8 %103, 0
  br i1 %104, label %105, label %134

105:                                              ; preds = %98
  %106 = load ptr, ptr %3, align 8, !tbaa !5
  %107 = getelementptr inbounds %struct.__arm_2d_sub_task_t, ptr %106, i32 0, i32 0
  %108 = getelementptr inbounds %struct.anon.82, ptr %107, i32 0, i32 5
  %109 = getelementptr inbounds %struct.__arm_2d_param_copy_t, ptr %108, i32 0, i32 0
  %110 = getelementptr inbounds %struct.__arm_2d_tile_param_t, ptr %109, i32 0, i32 0
  %111 = load ptr, ptr %110, align 8, !tbaa !22
  %112 = load ptr, ptr %3, align 8, !tbaa !5
  %113 = getelementptr inbounds %struct.__arm_2d_sub_task_t, ptr %112, i32 0, i32 0
  %114 = getelementptr inbounds %struct.anon.82, ptr %113, i32 0, i32 5
  %115 = getelementptr inbounds %struct.__arm_2d_param_copy_t, ptr %114, i32 0, i32 0
  %116 = getelementptr inbounds %struct.__arm_2d_tile_param_t, ptr %115, i32 0, i32 2
  %117 = load i16, ptr %116, align 4, !tbaa !22
  %118 = load ptr, ptr %3, align 8, !tbaa !5
  %119 = getelementptr inbounds %struct.__arm_2d_sub_task_t, ptr %118, i32 0, i32 0
  %120 = getelementptr inbounds %struct.anon.82, ptr %119, i32 0, i32 5
  %121 = getelementptr inbounds %struct.__arm_2d_param_copy_t, ptr %120, i32 0, i32 1
  %122 = getelementptr inbounds %struct.__arm_2d_tile_param_t, ptr %121, i32 0, i32 0
  %123 = load ptr, ptr %122, align 8, !tbaa !22
  %124 = load ptr, ptr %3, align 8, !tbaa !5
  %125 = getelementptr inbounds %struct.__arm_2d_sub_task_t, ptr %124, i32 0, i32 0
  %126 = getelementptr inbounds %struct.anon.82, ptr %125, i32 0, i32 5
  %127 = getelementptr inbounds %struct.__arm_2d_param_copy_t, ptr %126, i32 0, i32 1
  %128 = getelementptr inbounds %struct.__arm_2d_tile_param_t, ptr %127, i32 0, i32 2
  %129 = load i16, ptr %128, align 4, !tbaa !22
  %130 = load ptr, ptr %3, align 8, !tbaa !5
  %131 = getelementptr inbounds %struct.__arm_2d_sub_task_t, ptr %130, i32 0, i32 0
  %132 = getelementptr inbounds %struct.anon.82, ptr %131, i32 0, i32 5
  %133 = getelementptr inbounds %struct.__arm_2d_param_copy_t, ptr %132, i32 0, i32 2
  call void @__arm_2d_impl_ccca8888_to_gray8(ptr noundef %111, i16 noundef signext %117, ptr noundef %123, i16 noundef signext %129, ptr noundef %133)
  br label %163

134:                                              ; preds = %98
  %135 = load ptr, ptr %3, align 8, !tbaa !5
  %136 = getelementptr inbounds %struct.__arm_2d_sub_task_t, ptr %135, i32 0, i32 0
  %137 = getelementptr inbounds %struct.anon.82, ptr %136, i32 0, i32 5
  %138 = getelementptr inbounds %struct.__arm_2d_param_copy_t, ptr %137, i32 0, i32 0
  %139 = getelementptr inbounds %struct.__arm_2d_tile_param_t, ptr %138, i32 0, i32 0
  %140 = load ptr, ptr %139, align 8, !tbaa !22
  %141 = load ptr, ptr %3, align 8, !tbaa !5
  %142 = getelementptr inbounds %struct.__arm_2d_sub_task_t, ptr %141, i32 0, i32 0
  %143 = getelementptr inbounds %struct.anon.82, ptr %142, i32 0, i32 5
  %144 = getelementptr inbounds %struct.__arm_2d_param_copy_t, ptr %143, i32 0, i32 0
  %145 = getelementptr inbounds %struct.__arm_2d_tile_param_t, ptr %144, i32 0, i32 2
  %146 = load i16, ptr %145, align 4, !tbaa !22
  %147 = load ptr, ptr %3, align 8, !tbaa !5
  %148 = getelementptr inbounds %struct.__arm_2d_sub_task_t, ptr %147, i32 0, i32 0
  %149 = getelementptr inbounds %struct.anon.82, ptr %148, i32 0, i32 5
  %150 = getelementptr inbounds %struct.__arm_2d_param_copy_t, ptr %149, i32 0, i32 1
  %151 = getelementptr inbounds %struct.__arm_2d_tile_param_t, ptr %150, i32 0, i32 0
  %152 = load ptr, ptr %151, align 8, !tbaa !22
  %153 = load ptr, ptr %3, align 8, !tbaa !5
  %154 = getelementptr inbounds %struct.__arm_2d_sub_task_t, ptr %153, i32 0, i32 0
  %155 = getelementptr inbounds %struct.anon.82, ptr %154, i32 0, i32 5
  %156 = getelementptr inbounds %struct.__arm_2d_param_copy_t, ptr %155, i32 0, i32 1
  %157 = getelementptr inbounds %struct.__arm_2d_tile_param_t, ptr %156, i32 0, i32 2
  %158 = load i16, ptr %157, align 4, !tbaa !22
  %159 = load ptr, ptr %3, align 8, !tbaa !5
  %160 = getelementptr inbounds %struct.__arm_2d_sub_task_t, ptr %159, i32 0, i32 0
  %161 = getelementptr inbounds %struct.anon.82, ptr %160, i32 0, i32 5
  %162 = getelementptr inbounds %struct.__arm_2d_param_copy_t, ptr %161, i32 0, i32 2
  call void @__arm_2d_impl_cccn888_to_gray8(ptr noundef %140, i16 noundef signext %146, ptr noundef %152, i16 noundef signext %158, ptr noundef %162)
  br label %163

163:                                              ; preds = %134, %105
  br label %165

164:                                              ; preds = %32
  store i32 -11, ptr %2, align 4
  store i32 1, ptr %7, align 4
  br label %166

165:                                              ; preds = %163, %69, %40
  store i32 0, ptr %2, align 4
  store i32 1, ptr %7, align 4
  br label %166

166:                                              ; preds = %165, %164, %31, %23
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #3
  %167 = load i32, ptr %2, align 4
  ret i32 %167
}

declare ptr @arm_2d_tile_get_root(ptr noundef, ptr noundef, ptr noundef) #2

declare void @__arm_2d_impl_c8bit_copy(ptr noundef, i16 noundef signext, ptr noundef, i16 noundef signext, ptr noundef) #2

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

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

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

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

!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 = !{!13, !6, i64 64}
!13 = !{!"arm_2d_op_src_t", !14, i64 0, !19, i64 48, !20, i64 64, !21, i64 72}
!14 = !{!"arm_2d_op_core_t", !15, i64 0, !18, i64 40}
!15 = !{!"", !6, i64 0, !6, i64 8, !16, i64 16, !7, i64 17, !7, i64 18, !17, i64 24}
!16 = !{!"", !7, i64 0}
!17 = !{!"arm_2d_op_evt_t", !6, i64 0, !6, i64 8}
!18 = !{!"long", !7, i64 0}
!19 = !{!"", !6, i64 0, !6, i64 8}
!20 = !{!"", !6, i64 0}
!21 = !{!"int", !7, i64 0}
!22 = !{!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 }
%struct.anon = type { ptr, %struct.anon.0, %struct.anon.1, i16, i16, i16, i16, ptr, %union.anon }
%struct.anon.0 = type { ptr, ptr }
%struct.anon.1 = type { ptr, ptr }
%union.anon = 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.59, %struct.anon.60, %union.anon.61, %struct.anon.63, %struct.anon.64, %struct.__arm_2d_transform_info_t, i8 }
%struct.arm_2d_op_core_t = type { %struct.anon.2, i64 }
%struct.anon.2 = type { ptr, ptr, %struct.anon.3, i8, %union.arm_2d_op_status_t, %struct.arm_2d_op_evt_t }
%struct.anon.3 = type { i8 }
%union.arm_2d_op_status_t = type { %struct.anon.4 }
%struct.anon.4 = type { i16 }
%struct.arm_2d_op_evt_t = type { ptr, ptr }
%struct.anon.59 = type { ptr, ptr }
%struct.anon.60 = type { ptr }
%union.anon.61 = type { %struct.anon.62 }
%struct.anon.62 = type { i32 }
%struct.anon.63 = type { ptr, %struct.arm_2d_tile_t }
%struct.arm_2d_tile_t = type { %union.anon.36, %union.anon.47, %union.anon.50 }
%union.anon.36 = type { %struct.anon.37 }
%struct.anon.37 = type { i8, %union.arm_2d_color_info_t, %union.anon.40 }
%union.arm_2d_color_info_t = type { %struct.anon.38 }
%struct.anon.38 = type { i8 }
%union.anon.40 = type { i16 }
%union.anon.47 = type { %struct.arm_2d_region_t }
%struct.arm_2d_region_t = type { %union.anon.48, %union.anon.49 }
%union.anon.48 = type { %struct.arm_2d_location_t }
%struct.arm_2d_location_t = type { i16, i16 }
%union.anon.49 = type { %struct.arm_2d_size_t }
%struct.arm_2d_size_t = type { i16, i16 }
%union.anon.50 = type { ptr }
%struct.anon.64 = type { ptr, ptr }
%struct.__arm_2d_transform_info_t = type { float, float, float, %struct.arm_2d_point_float_t, %union.anon.51, %struct.anon.52 }
%struct.arm_2d_point_float_t = type { float, float }
%union.anon.51 = type { i32 }
%struct.anon.52 = type { %struct.arm_2d_location_t, %struct.anon.53 }
%struct.anon.53 = 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: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #0

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

; Function Attrs: nounwind uwtable
define dso_local range(i32 -11, 1) i32 @__arm_2d_sw_convert_colour_to_gray8(ptr noundef %0) local_unnamed_addr #1 {
  %2 = alloca %struct.arm_2d_region_t, align 2
  %3 = getelementptr inbounds i8, ptr %0, i64 8
  %4 = load ptr, ptr %3, align 8, !tbaa !5
  %5 = icmp eq ptr %4, null
  %spec.store.select = select i1 %5, ptr getelementptr inbounds (i8, ptr @ARM_2D_CTRL, i64 56), ptr %4
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %2) #3
  %6 = getelementptr inbounds i8, ptr %spec.store.select, i64 64
  %7 = load ptr, ptr %6, align 8, !tbaa !11
  %8 = call ptr @arm_2d_tile_get_root(ptr noundef %7, ptr noundef nonnull %2, ptr noundef null) #3
  %9 = icmp eq ptr %8, null
  br i1 %9, label %51, label %10

10:                                               ; preds = %1
  %11 = load i8, ptr %8, align 8
  %12 = and i8 %11, 2
  %.not = icmp eq i8 %12, 0
  br i1 %.not, label %51, label %13

13:                                               ; preds = %10
  %14 = getelementptr inbounds i8, ptr %8, i64 1
  %15 = load i8, ptr %14, align 1
  %16 = lshr i8 %15, 1
  %17 = and i8 %16, 7
  switch i8 %17, label %51 [
    i8 6, label %18
    i8 4, label %28
    i8 5, label %38
  ]

18:                                               ; preds = %13
  %19 = getelementptr inbounds i8, ptr %0, i64 24
  %20 = load ptr, ptr %19, align 8, !tbaa !21
  %21 = getelementptr inbounds i8, ptr %0, i64 36
  %22 = load i16, ptr %21, align 4, !tbaa !21
  %23 = getelementptr inbounds i8, ptr %0, i64 64
  %24 = load ptr, ptr %23, align 8, !tbaa !21
  %25 = getelementptr inbounds i8, ptr %0, i64 76
  %26 = load i16, ptr %25, align 4, !tbaa !21
  %27 = getelementptr inbounds i8, ptr %0, i64 104
  call void @__arm_2d_impl_c8bit_copy(ptr noundef %20, i16 noundef signext %22, ptr noundef %24, i16 noundef signext %26, ptr noundef nonnull %27) #3
  br label %51

28:                                               ; preds = %13
  %29 = getelementptr inbounds i8, ptr %0, i64 24
  %30 = load ptr, ptr %29, align 8, !tbaa !21
  %31 = getelementptr inbounds i8, ptr %0, i64 36
  %32 = load i16, ptr %31, align 4, !tbaa !21
  %33 = getelementptr inbounds i8, ptr %0, i64 64
  %34 = load ptr, ptr %33, align 8, !tbaa !21
  %35 = getelementptr inbounds i8, ptr %0, i64 76
  %36 = load i16, ptr %35, align 4, !tbaa !21
  %37 = getelementptr inbounds i8, ptr %0, i64 104
  call void @__arm_2d_impl_rgb565_to_gray8(ptr noundef %30, i16 noundef signext %32, ptr noundef %34, i16 noundef signext %36, ptr noundef nonnull %37)
  br label %51

38:                                               ; preds = %13
  %39 = and i8 %15, 1
  %.not28 = icmp eq i8 %39, 0
  %40 = getelementptr inbounds i8, ptr %0, i64 24
  %41 = load ptr, ptr %40, align 8, !tbaa !21
  %42 = getelementptr inbounds i8, ptr %0, i64 36
  %43 = load i16, ptr %42, align 4, !tbaa !21
  %44 = getelementptr inbounds i8, ptr %0, i64 64
  %45 = load ptr, ptr %44, align 8, !tbaa !21
  %46 = getelementptr inbounds i8, ptr %0, i64 76
  %47 = load i16, ptr %46, align 4, !tbaa !21
  %48 = getelementptr inbounds i8, ptr %0, i64 104
  br i1 %.not28, label %50, label %49

49:                                               ; preds = %38
  call void @__arm_2d_impl_ccca8888_to_gray8(ptr noundef %41, i16 noundef signext %43, ptr noundef %45, i16 noundef signext %47, ptr noundef nonnull %48)
  br label %51

50:                                               ; preds = %38
  call void @__arm_2d_impl_cccn888_to_gray8(ptr noundef %41, i16 noundef signext %43, ptr noundef %45, i16 noundef signext %47, ptr noundef nonnull %48)
  br label %51

51:                                               ; preds = %18, %28, %50, %49, %13, %10, %1
  %.0 = phi i32 [ 0, %1 ], [ -6, %10 ], [ -11, %13 ], [ 0, %49 ], [ 0, %50 ], [ 0, %28 ], [ 0, %18 ]
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %2) #3
  ret i32 %.0
}

declare ptr @arm_2d_tile_get_root(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #2

declare void @__arm_2d_impl_c8bit_copy(ptr noundef, i16 noundef signext, ptr noundef, i16 noundef signext, ptr noundef) local_unnamed_addr #2

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

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

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

attributes #0 = { mustprogress 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 = { "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 }

!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 = !{!12, !8, i64 64}
!12 = !{!"arm_2d_op_src_t", !13, i64 0, !18, i64 48, !19, i64 64, !20, i64 72}
!13 = !{!"arm_2d_op_core_t", !14, i64 0, !17, i64 40}
!14 = !{!"", !8, i64 0, !8, i64 8, !15, i64 16, !9, i64 17, !9, i64 18, !16, i64 24}
!15 = !{!"", !9, i64 0}
!16 = !{!"arm_2d_op_evt_t", !8, i64 0, !8, i64 8}
!17 = !{!"long", !9, i64 0}
!18 = !{!"", !8, i64 0, !8, i64 8}
!19 = !{!"", !8, i64 0}
!20 = !{!"int", !9, i64 0}
!21 = !{!9, !9, i64 0}


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