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

; 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_runtime_feature_t = type { i8 }
%struct.arm_2d_op_core_t = type { %struct.anon, i64 }
%struct.anon = type { ptr, ptr, %struct.anon.0, i8, %union.arm_2d_op_status_t, %struct.arm_2d_op_evt_t }
%struct.anon.0 = type { i8 }
%union.arm_2d_op_status_t = type { %struct.anon.1 }
%struct.anon.1 = type { i16 }
%struct.arm_2d_op_evt_t = type { ptr, ptr }
%struct.anon.2 = type { %union.arm_2d_color_info_t, %union.anon, i8, i8, %union.anon.6, %union.anon.10 }
%union.arm_2d_color_info_t = type { %struct.anon.3 }
%struct.anon.3 = type { i8 }
%union.anon = type { %struct.anon.5 }
%struct.anon.5 = type { i8 }
%union.anon.6 = type { %struct.anon.7 }
%struct.anon.7 = type { i8, i8 }
%union.anon.10 = type { [2 x ptr] }

@ARM_2D_RUNTIME_FEATURE = external dso_local global %struct.arm_2d_runtime_feature_t, align 1

; 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_op_frontend_op_decoder(ptr noundef %0) #1 {
  %2 = alloca ptr, align 8
  %3 = alloca i32, align 4
  store ptr %0, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #2
  %4 = load ptr, ptr %2, align 8, !tbaa !5
  %5 = getelementptr inbounds %struct.arm_2d_op_core_t, ptr %4, i32 0, i32 0
  %6 = getelementptr inbounds %struct.anon, ptr %5, i32 0, i32 1
  %7 = load ptr, ptr %6, align 8, !tbaa !9
  %8 = getelementptr inbounds %struct.anon.2, ptr %7, i32 0, i32 1
  %9 = load i8, ptr %8, align 1, !tbaa !15
  %10 = zext i8 %9 to i32
  %11 = and i32 %10, 3
  switch i32 %11, label %20 [
    i32 3, label %12
    i32 2, label %16
  ]

12:                                               ; preds = %1
  %13 = load ptr, ptr %2, align 8, !tbaa !5
  call void @__arm_2d_op_use_default_frame_buffer(ptr noundef %13)
  %14 = load ptr, ptr %2, align 8, !tbaa !5
  %15 = call i32 @__arm_2d_op_frontend_region_process_with_src(ptr noundef %14)
  store i32 %15, ptr %3, align 4, !tbaa !16
  br label %23

16:                                               ; preds = %1
  %17 = load ptr, ptr %2, align 8, !tbaa !5
  call void @__arm_2d_op_use_default_frame_buffer(ptr noundef %17)
  %18 = load ptr, ptr %2, align 8, !tbaa !5
  %19 = call i32 @__arm_2d_op_frontend_region_process(ptr noundef %18)
  store i32 %19, ptr %3, align 4, !tbaa !16
  br label %23

20:                                               ; preds = %1
  %21 = load ptr, ptr %2, align 8, !tbaa !5
  %22 = call i32 @__arm_2d_op_frontend_control(ptr noundef %21)
  store i32 %22, ptr %3, align 4, !tbaa !16
  br label %23

23:                                               ; preds = %20, %16, %12
  %24 = load i32, ptr %3, align 4, !tbaa !16
  %25 = icmp eq i32 -3, %24
  br i1 %25, label %26, label %32

26:                                               ; preds = %23
  %27 = load i8, ptr @ARM_2D_RUNTIME_FEATURE, align 1
  %28 = and i8 %27, 1
  %29 = icmp ne i8 %28, 0
  br i1 %29, label %30, label %31

30:                                               ; preds = %26
  store i32 0, ptr %3, align 4, !tbaa !16
  br label %31

31:                                               ; preds = %30, %26
  br label %32

32:                                               ; preds = %31, %23
  %33 = load i32, ptr %3, align 4, !tbaa !16
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #2
  ret i32 %33
}

; Function Attrs: nounwind uwtable
declare hidden void @__arm_2d_op_use_default_frame_buffer(ptr noundef) #1

; Function Attrs: nounwind uwtable
declare hidden i32 @__arm_2d_op_frontend_region_process_with_src(ptr noundef) #1

; Function Attrs: nounwind uwtable
declare hidden i32 @__arm_2d_op_frontend_region_process(ptr noundef) #1

; Function Attrs: nounwind uwtable
declare hidden i32 @__arm_2d_op_frontend_control(ptr 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 = { 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_op_core_t", !11, i64 0, !14, i64 40}
!11 = !{!"", !6, i64 0, !6, i64 8, !12, i64 16, !7, i64 17, !7, i64 18, !13, i64 24}
!12 = !{!"", !7, i64 0}
!13 = !{!"arm_2d_op_evt_t", !6, i64 0, !6, i64 8}
!14 = !{!"long", !7, i64 0}
!15 = !{!7, !7, i64 0}
!16 = !{!17, !17, i64 0}
!17 = !{!"int", !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_runtime_feature_t = type { i8 }

@ARM_2D_RUNTIME_FEATURE = external dso_local local_unnamed_addr global %struct.arm_2d_runtime_feature_t, align 1

; Function Attrs: nounwind uwtable
define dso_local i32 @__arm_2d_op_frontend_op_decoder(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 = getelementptr inbounds i8, ptr %3, i64 1
  %5 = load i8, ptr %4, align 1, !tbaa !14
  %6 = and i8 %5, 3
  switch i8 %6, label %11 [
    i8 3, label %7
    i8 2, label %9
  ]

7:                                                ; preds = %1
  tail call void @__arm_2d_op_use_default_frame_buffer(ptr noundef nonnull %0)
  %8 = tail call i32 @__arm_2d_op_frontend_region_process_with_src(ptr noundef nonnull %0)
  br label %13

9:                                                ; preds = %1
  tail call void @__arm_2d_op_use_default_frame_buffer(ptr noundef nonnull %0)
  %10 = tail call i32 @__arm_2d_op_frontend_region_process(ptr noundef nonnull %0)
  br label %13

11:                                               ; preds = %1
  %12 = tail call i32 @__arm_2d_op_frontend_control(ptr noundef nonnull %0)
  br label %13

13:                                               ; preds = %11, %9, %7
  %.0 = phi i32 [ %12, %11 ], [ %10, %9 ], [ %8, %7 ]
  %14 = icmp eq i32 %.0, -3
  %15 = load i8, ptr @ARM_2D_RUNTIME_FEATURE, align 1
  %16 = and i8 %15, 1
  %.not = icmp eq i8 %16, 0
  %spec.select = select i1 %.not, i32 -3, i32 0
  %.1 = select i1 %14, i32 %spec.select, i32 %.0
  ret i32 %.1
}

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

; Function Attrs: nounwind uwtable
declare hidden i32 @__arm_2d_op_frontend_region_process_with_src(ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare hidden i32 @__arm_2d_op_frontend_region_process(ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare hidden i32 @__arm_2d_op_frontend_control(ptr noundef) local_unnamed_addr #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_op_core_t", !7, i64 0, !13, i64 40}
!7 = !{!"", !8, i64 0, !8, i64 8, !11, i64 16, !9, i64 17, !9, i64 18, !12, i64 24}
!8 = !{!"any pointer", !9, i64 0}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C/C++ TBAA"}
!11 = !{!"", !9, i64 0}
!12 = !{!"arm_2d_op_evt_t", !8, i64 0, !8, i64 8}
!13 = !{!"long", !9, i64 0}
!14 = !{!9, !9, i64 0}


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