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

; 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_byte_fifo_t = type { %struct.anon.17 }
%struct.anon.17 = type { ptr, i16, i16, %struct.__arm_2d_fifo_reader_pointer, %struct.__arm_2d_fifo_reader_pointer }
%struct.__arm_2d_fifo_reader_pointer = type { i16, i16 }

@.str.1 = external hidden unnamed_addr constant [83 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [15 x i8], align 1
@__PRETTY_FUNCTION__.arm_2d_byte_fifo_enqueue = external hidden unnamed_addr constant [62 x i8], 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: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) #1

; Function Attrs: nounwind uwtable
define dso_local zeroext i1 @arm_2d_byte_fifo_enqueue(ptr noundef nonnull %0, i8 noundef zeroext %1) #2 {
  %3 = alloca i1, align 1
  %4 = alloca ptr, align 8
  %5 = alloca i8, align 1
  %6 = alloca i8, align 1
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca ptr, align 8
  store ptr %0, ptr %4, align 8, !tbaa !5
  store i8 %1, ptr %5, align 1, !tbaa !9
  %10 = load ptr, ptr %4, align 8, !tbaa !5
  %11 = icmp ne ptr null, %10
  br i1 %11, label %12, label %13

12:                                               ; preds = %2
  br label %14

13:                                               ; preds = %2
  call void @__assert_fail(ptr noundef @.str.4, ptr noundef @.str.1, i32 noundef 922, ptr noundef @__PRETTY_FUNCTION__.arm_2d_byte_fifo_enqueue) #3
  unreachable

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

20:                                               ; preds = %14
  store i1 false, ptr %3, align 1
  store i32 1, ptr %7, align 4
  br label %96

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

22:                                               ; preds = %92, %21
  %23 = load ptr, ptr %9, align 8, !tbaa !5
  %24 = getelementptr inbounds i32, ptr %23, i32 1
  store ptr %24, ptr %9, align 8, !tbaa !5
  %25 = icmp eq ptr %23, null
  br i1 %25, label %27, label %26

26:                                               ; preds = %22
  store i32 2, ptr %7, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #4
  br label %93

27:                                               ; preds = %22
  br label %28

28:                                               ; preds = %27
  %29 = load ptr, ptr %4, align 8, !tbaa !5
  %30 = getelementptr inbounds %struct.arm_2d_byte_fifo_t, ptr %29, i32 0, i32 0
  %31 = getelementptr inbounds %struct.anon.17, ptr %30, i32 0, i32 2
  %32 = load i16, ptr %31, align 2, !tbaa !19
  %33 = zext i16 %32 to i32
  %34 = load ptr, ptr %4, align 8, !tbaa !5
  %35 = getelementptr inbounds %struct.arm_2d_byte_fifo_t, ptr %34, i32 0, i32 0
  %36 = getelementptr inbounds %struct.anon.17, ptr %35, i32 0, i32 3
  %37 = getelementptr inbounds %struct.__arm_2d_fifo_reader_pointer, ptr %36, i32 0, i32 0
  %38 = load i16, ptr %37, align 4, !tbaa !20
  %39 = zext i16 %38 to i32
  %40 = icmp eq i32 %33, %39
  br i1 %40, label %41, label %50

41:                                               ; preds = %28
  %42 = load ptr, ptr %4, align 8, !tbaa !5
  %43 = getelementptr inbounds %struct.arm_2d_byte_fifo_t, ptr %42, i32 0, i32 0
  %44 = getelementptr inbounds %struct.anon.17, ptr %43, i32 0, i32 3
  %45 = getelementptr inbounds %struct.__arm_2d_fifo_reader_pointer, ptr %44, i32 0, i32 1
  %46 = load i16, ptr %45, align 2, !tbaa !21
  %47 = zext i16 %46 to i32
  %48 = icmp sgt i32 %47, 0
  br i1 %48, label %49, label %50

49:                                               ; preds = %41
  br label %92

50:                                               ; preds = %41, %28
  %51 = load i8, ptr %5, align 1, !tbaa !9
  %52 = load ptr, ptr %4, align 8, !tbaa !5
  %53 = getelementptr inbounds %struct.arm_2d_byte_fifo_t, ptr %52, i32 0, i32 0
  %54 = getelementptr inbounds %struct.anon.17, ptr %53, i32 0, i32 0
  %55 = load ptr, ptr %54, align 8, !tbaa !12
  %56 = load ptr, ptr %4, align 8, !tbaa !5
  %57 = getelementptr inbounds %struct.arm_2d_byte_fifo_t, ptr %56, i32 0, i32 0
  %58 = getelementptr inbounds %struct.anon.17, ptr %57, i32 0, i32 2
  %59 = load i16, ptr %58, align 2, !tbaa !19
  %60 = add i16 %59, 1
  store i16 %60, ptr %58, align 2, !tbaa !19
  %61 = zext i16 %59 to i64
  %62 = getelementptr inbounds i8, ptr %55, i64 %61
  store i8 %51, ptr %62, align 1, !tbaa !9
  %63 = load ptr, ptr %4, align 8, !tbaa !5
  %64 = getelementptr inbounds %struct.arm_2d_byte_fifo_t, ptr %63, i32 0, i32 0
  %65 = getelementptr inbounds %struct.anon.17, ptr %64, i32 0, i32 2
  %66 = load i16, ptr %65, align 2, !tbaa !19
  %67 = zext i16 %66 to i32
  %68 = load ptr, ptr %4, align 8, !tbaa !5
  %69 = getelementptr inbounds %struct.arm_2d_byte_fifo_t, ptr %68, i32 0, i32 0
  %70 = getelementptr inbounds %struct.anon.17, ptr %69, i32 0, i32 1
  %71 = load i16, ptr %70, align 8, !tbaa !22
  %72 = zext i16 %71 to i32
  %73 = icmp sge i32 %67, %72
  br i1 %73, label %74, label %78

74:                                               ; preds = %50
  %75 = load ptr, ptr %4, align 8, !tbaa !5
  %76 = getelementptr inbounds %struct.arm_2d_byte_fifo_t, ptr %75, i32 0, i32 0
  %77 = getelementptr inbounds %struct.anon.17, ptr %76, i32 0, i32 2
  store i16 0, ptr %77, align 2, !tbaa !19
  br label %78

78:                                               ; preds = %74, %50
  %79 = load ptr, ptr %4, align 8, !tbaa !5
  %80 = getelementptr inbounds %struct.arm_2d_byte_fifo_t, ptr %79, i32 0, i32 0
  %81 = getelementptr inbounds %struct.anon.17, ptr %80, i32 0, i32 3
  %82 = getelementptr inbounds %struct.__arm_2d_fifo_reader_pointer, ptr %81, i32 0, i32 1
  %83 = load i16, ptr %82, align 2, !tbaa !21
  %84 = add i16 %83, 1
  store i16 %84, ptr %82, align 2, !tbaa !21
  %85 = load ptr, ptr %4, align 8, !tbaa !5
  %86 = getelementptr inbounds %struct.arm_2d_byte_fifo_t, ptr %85, i32 0, i32 0
  %87 = getelementptr inbounds %struct.anon.17, ptr %86, i32 0, i32 4
  %88 = getelementptr inbounds %struct.__arm_2d_fifo_reader_pointer, ptr %87, i32 0, i32 1
  %89 = load i16, ptr %88, align 2, !tbaa !23
  %90 = add i16 %89, 1
  store i16 %90, ptr %88, align 2, !tbaa !23
  store i8 1, ptr %6, align 1, !tbaa !10
  br label %91

91:                                               ; preds = %78
  br label %92

92:                                               ; preds = %91, %49
  br label %22, !llvm.loop !24

93:                                               ; preds = %26
  %94 = load i8, ptr %6, align 1, !tbaa !10, !range !26, !noundef !27
  %95 = trunc i8 %94 to i1
  store i1 %95, ptr %3, align 1
  store i32 1, ptr %7, align 4
  br label %96

96:                                               ; preds = %93, %20
  call void @llvm.lifetime.end.p0(i64 1, ptr %6) #4
  %97 = load i1, ptr %3, align 1
  ret i1 %97
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #2 = { 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 #3 = { noreturn nounwind }
attributes #4 = { 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 = !{!7, !7, i64 0}
!10 = !{!11, !11, i64 0}
!11 = !{!"_Bool", !7, i64 0}
!12 = !{!13, !6, i64 0}
!13 = !{!"arm_2d_byte_fifo_t", !14, i64 0}
!14 = !{!"", !6, i64 0, !15, i64 8, !15, i64 10, !16, i64 12, !16, i64 16}
!15 = !{!"short", !7, i64 0}
!16 = !{!"__arm_2d_fifo_reader_pointer", !15, i64 0, !15, i64 2}
!17 = !{!18, !18, i64 0}
!18 = !{!"int", !7, i64 0}
!19 = !{!13, !15, i64 10}
!20 = !{!13, !15, i64 12}
!21 = !{!13, !15, i64 14}
!22 = !{!13, !15, i64 8}
!23 = !{!13, !15, i64 18}
!24 = distinct !{!24, !25}
!25 = !{!"llvm.loop.mustprogress"}
!26 = !{i8 0, i8 2}
!27 = !{}


; 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(write, argmem: readwrite, inaccessiblemem: none) uwtable
define dso_local noundef zeroext i1 @arm_2d_byte_fifo_enqueue(ptr nocapture noundef nonnull %0, i8 noundef zeroext %1) local_unnamed_addr #0 {
  %3 = load ptr, ptr %0, align 8, !tbaa !5
  %4 = icmp eq ptr %3, null
  br i1 %4, label %.loopexit, label %.preheader

.preheader:                                       ; preds = %2
  %5 = getelementptr inbounds i8, ptr %0, i64 10
  %6 = getelementptr inbounds i8, ptr %0, i64 12
  %7 = getelementptr inbounds i8, ptr %0, i64 14
  %8 = getelementptr inbounds i8, ptr %0, i64 8
  %9 = getelementptr inbounds i8, ptr %0, i64 18
  %10 = load i16, ptr %5, align 2, !tbaa !13
  %11 = load i16, ptr %6, align 4, !tbaa !14
  %12 = icmp eq i16 %10, %11
  br i1 %12, label %13, label %15

13:                                               ; preds = %.preheader
  %14 = load i16, ptr %7, align 2, !tbaa !15
  %.not = icmp eq i16 %14, 0
  br i1 %.not, label %15, label %.loopexit

15:                                               ; preds = %13, %.preheader
  %16 = add i16 %10, 1
  store i16 %16, ptr %5, align 2, !tbaa !13
  %17 = zext i16 %10 to i64
  %18 = getelementptr inbounds i8, ptr %3, i64 %17
  store i8 %1, ptr %18, align 1, !tbaa !16
  %19 = load i16, ptr %5, align 2, !tbaa !13
  %20 = load i16, ptr %8, align 8, !tbaa !17
  %.not17 = icmp ult i16 %19, %20
  br i1 %.not17, label %22, label %21

21:                                               ; preds = %15
  store i16 0, ptr %5, align 2, !tbaa !13
  br label %22

22:                                               ; preds = %21, %15
  %23 = load i16, ptr %7, align 2, !tbaa !15
  %24 = add i16 %23, 1
  store i16 %24, ptr %7, align 2, !tbaa !15
  %25 = load i16, ptr %9, align 2, !tbaa !18
  %26 = add i16 %25, 1
  store i16 %26, ptr %9, align 2, !tbaa !18
  br label %.loopexit

.loopexit:                                        ; preds = %22, %13, %2
  %.015 = phi i1 [ false, %2 ], [ false, %13 ], [ true, %22 ]
  ret i1 %.015
}

attributes #0 = { mustprogress nofree norecurse nosync nounwind willreturn memory(write, argmem: readwrite, inaccessiblemem: none) 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 0}
!6 = !{!"arm_2d_byte_fifo_t", !7, i64 0}
!7 = !{!"", !8, i64 0, !11, i64 8, !11, i64 10, !12, i64 12, !12, i64 16}
!8 = !{!"any pointer", !9, i64 0}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C/C++ TBAA"}
!11 = !{!"short", !9, i64 0}
!12 = !{!"__arm_2d_fifo_reader_pointer", !11, i64 0, !11, i64 2}
!13 = !{!6, !11, i64 10}
!14 = !{!6, !11, i64 12}
!15 = !{!6, !11, i64 14}
!16 = !{!9, !9, i64 0}
!17 = !{!6, !11, i64 8}
!18 = !{!6, !11, i64 18}


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