; LLVM IR from OAID/AutoKernel :: autokernel_plugin/tests/common/tengine_operations.ll (Z13imread2tflite5imageiiPfS0_)

; 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.image = type { i32, i32, i32, ptr }

; 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: 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) #1

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z10make_imageiii(ptr dead_on_unwind noalias writable sret(%struct.image) align 8, i32 noundef, i32 noundef, i32 noundef) #2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_Z10free_image5image(ptr noundef byval(%struct.image) align 8) #3

; Function Attrs: mustprogress uwtable
define dso_local void @_Z13imread2tflite5imageiiPfS0_(ptr dead_on_unwind noalias writable sret(%struct.image) align 8 %0, ptr noundef byval(%struct.image) align 8 %1, i32 noundef %2, i32 noundef %3, ptr noundef %4, ptr noundef %5) #2 {
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca %struct.image, align 8
  %12 = alloca i32, align 4
  %13 = alloca i32, align 4
  %14 = alloca i32, align 4
  %15 = alloca i32, align 4
  %16 = alloca i32, align 4
  %17 = alloca %struct.image, align 8
  store i32 %2, ptr %7, align 4, !tbaa !5
  store i32 %3, ptr %8, align 4, !tbaa !5
  store ptr %4, ptr %9, align 8, !tbaa !9
  store ptr %5, ptr %10, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 24, ptr %11) #4
  %18 = load i32, ptr %7, align 4, !tbaa !5
  %19 = load i32, ptr %8, align 4, !tbaa !5
  %20 = getelementptr inbounds %struct.image, ptr %1, i32 0, i32 2
  %21 = load i32, ptr %20, align 8, !tbaa !11
  call void @_Z10make_imageiii(ptr dead_on_unwind writable sret(%struct.image) align 8 %11, i32 noundef %18, i32 noundef %19, i32 noundef %21)
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %0, ptr align 8 %11, i64 24, i1 false), !tbaa.struct !13
  call void @llvm.lifetime.end.p0(i64 24, ptr %11) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #4
  store i32 0, ptr %12, align 4, !tbaa !5
  br label %22

22:                                               ; preds = %93, %6
  %23 = load i32, ptr %12, align 4, !tbaa !5
  %24 = getelementptr inbounds %struct.image, ptr %1, i32 0, i32 2
  %25 = load i32, ptr %24, align 8, !tbaa !11
  %26 = icmp slt i32 %23, %25
  br i1 %26, label %28, label %27

27:                                               ; preds = %22
  store i32 2, ptr %13, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #4
  br label %96

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

29:                                               ; preds = %89, %28
  %30 = load i32, ptr %14, align 4, !tbaa !5
  %31 = getelementptr inbounds %struct.image, ptr %1, i32 0, i32 1
  %32 = load i32, ptr %31, align 4, !tbaa !14
  %33 = icmp slt i32 %30, %32
  br i1 %33, label %35, label %34

34:                                               ; preds = %29
  store i32 5, ptr %13, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #4
  br label %92

35:                                               ; preds = %29
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #4
  store i32 0, ptr %15, align 4, !tbaa !5
  br label %36

36:                                               ; preds = %85, %35
  %37 = load i32, ptr %15, align 4, !tbaa !5
  %38 = getelementptr inbounds %struct.image, ptr %1, i32 0, i32 0
  %39 = load i32, ptr %38, align 8, !tbaa !15
  %40 = icmp slt i32 %37, %39
  br i1 %40, label %42, label %41

41:                                               ; preds = %36
  store i32 8, ptr %13, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #4
  br label %88

42:                                               ; preds = %36
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #4
  %43 = load i32, ptr %7, align 4, !tbaa !5
  %44 = load i32, ptr %8, align 4, !tbaa !5
  %45 = mul nsw i32 %43, %44
  store i32 %45, ptr %16, align 4, !tbaa !5
  %46 = getelementptr inbounds %struct.image, ptr %1, i32 0, i32 3
  %47 = load ptr, ptr %46, align 8, !tbaa !16
  %48 = load i32, ptr %12, align 4, !tbaa !5
  %49 = load i32, ptr %16, align 4, !tbaa !5
  %50 = mul nsw i32 %48, %49
  %51 = load i32, ptr %14, align 4, !tbaa !5
  %52 = load i32, ptr %7, align 4, !tbaa !5
  %53 = mul nsw i32 %51, %52
  %54 = add nsw i32 %50, %53
  %55 = load i32, ptr %15, align 4, !tbaa !5
  %56 = add nsw i32 %54, %55
  %57 = sext i32 %56 to i64
  %58 = getelementptr inbounds float, ptr %47, i64 %57
  %59 = load float, ptr %58, align 4, !tbaa !17
  %60 = load ptr, ptr %9, align 8, !tbaa !9
  %61 = load i32, ptr %12, align 4, !tbaa !5
  %62 = sext i32 %61 to i64
  %63 = getelementptr inbounds float, ptr %60, i64 %62
  %64 = load float, ptr %63, align 4, !tbaa !17
  %65 = fsub float %59, %64
  %66 = load ptr, ptr %10, align 8, !tbaa !9
  %67 = load i32, ptr %12, align 4, !tbaa !5
  %68 = sext i32 %67 to i64
  %69 = getelementptr inbounds float, ptr %66, i64 %68
  %70 = load float, ptr %69, align 4, !tbaa !17
  %71 = fmul float %65, %70
  %72 = getelementptr inbounds %struct.image, ptr %0, i32 0, i32 3
  %73 = load ptr, ptr %72, align 8, !tbaa !16
  %74 = load i32, ptr %14, align 4, !tbaa !5
  %75 = load i32, ptr %7, align 4, !tbaa !5
  %76 = mul nsw i32 %74, %75
  %77 = mul nsw i32 %76, 3
  %78 = load i32, ptr %15, align 4, !tbaa !5
  %79 = mul nsw i32 %78, 3
  %80 = add nsw i32 %77, %79
  %81 = load i32, ptr %12, align 4, !tbaa !5
  %82 = add nsw i32 %80, %81
  %83 = sext i32 %82 to i64
  %84 = getelementptr inbounds float, ptr %73, i64 %83
  store float %71, ptr %84, align 4, !tbaa !17
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #4
  br label %85

85:                                               ; preds = %42
  %86 = load i32, ptr %15, align 4, !tbaa !5
  %87 = add nsw i32 %86, 1
  store i32 %87, ptr %15, align 4, !tbaa !5
  br label %36, !llvm.loop !19

88:                                               ; preds = %41
  br label %89

89:                                               ; preds = %88
  %90 = load i32, ptr %14, align 4, !tbaa !5
  %91 = add nsw i32 %90, 1
  store i32 %91, ptr %14, align 4, !tbaa !5
  br label %29, !llvm.loop !21

92:                                               ; preds = %34
  br label %93

93:                                               ; preds = %92
  %94 = load i32, ptr %12, align 4, !tbaa !5
  %95 = add nsw i32 %94, 1
  store i32 %95, ptr %12, align 4, !tbaa !5
  br label %22, !llvm.loop !22

96:                                               ; preds = %27
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %17, ptr align 8 %1, i64 24, i1 false), !tbaa.struct !13
  call void @_Z10free_image5image(ptr noundef byval(%struct.image) align 8 %17)
  ret void
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { mustprogress 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 = { mustprogress 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 = { 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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = !{!12, !6, i64 8}
!12 = !{!"_ZTS5image", !6, i64 0, !6, i64 4, !6, i64 8, !10, i64 16}
!13 = !{i64 0, i64 4, !5, i64 4, i64 4, !5, i64 8, i64 4, !5, i64 16, i64 8, !9}
!14 = !{!12, !6, i64 4}
!15 = !{!12, !6, i64 0}
!16 = !{!12, !10, i64 16}
!17 = !{!18, !18, i64 0}
!18 = !{!"float", !7, i64 0}
!19 = distinct !{!19, !20}
!20 = !{!"llvm.loop.mustprogress"}
!21 = distinct !{!21, !20}
!22 = distinct !{!22, !20}


; 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.image = type { i32, i32, i32, ptr }

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z10make_imageiii(ptr dead_on_unwind noalias writable sret(%struct.image) align 8, i32 noundef, i32 noundef, i32 noundef) local_unnamed_addr #0

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_Z10free_image5image(ptr noundef byval(%struct.image) align 8) local_unnamed_addr #1

; Function Attrs: mustprogress uwtable
define dso_local void @_Z13imread2tflite5imageiiPfS0_(ptr dead_on_unwind noalias nocapture writable sret(%struct.image) align 8 %0, ptr nocapture noundef readonly byval(%struct.image) align 8 %1, i32 noundef %2, i32 noundef %3, ptr nocapture noundef readonly %4, ptr nocapture noundef readonly %5) local_unnamed_addr #0 {
  %7 = getelementptr inbounds i8, ptr %1, i64 8
  %8 = load i32, ptr %7, align 8, !tbaa !5
  tail call void @_Z10make_imageiii(ptr dead_on_unwind nonnull writable sret(%struct.image) align 8 %0, i32 noundef %2, i32 noundef %3, i32 noundef %8)
  %9 = icmp sgt i32 %8, 0
  br i1 %9, label %.preheader24.lr.ph, label %._crit_edge

.preheader24.lr.ph:                               ; preds = %6
  %10 = getelementptr inbounds i8, ptr %1, i64 4
  %11 = load i32, ptr %10, align 4, !tbaa !11
  %factor.op.mul26 = mul i32 %3, %2
  %12 = icmp sgt i32 %11, 0
  %13 = load i32, ptr %1, align 8
  %14 = getelementptr inbounds i8, ptr %1, i64 16
  %15 = load ptr, ptr %14, align 8
  %16 = getelementptr inbounds i8, ptr %0, i64 16
  %17 = load ptr, ptr %16, align 8
  %18 = icmp sgt i32 %13, 0
  %or.cond = select i1 %12, i1 %18, i1 false
  br i1 %or.cond, label %.preheader24.us.us.preheader, label %._crit_edge

.preheader24.us.us.preheader:                     ; preds = %.preheader24.lr.ph
  %19 = sext i32 %2 to i64
  %wide.trip.count46 = zext nneg i32 %8 to i64
  %wide.trip.count41 = zext nneg i32 %11 to i64
  %wide.trip.count = zext nneg i32 %13 to i64
  %xtraiter = and i64 %wide.trip.count, 1
  %20 = icmp eq i32 %13, 1
  %unroll_iter = and i64 %wide.trip.count, 2147483646
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br label %.preheader24.us.us

.preheader24.us.us:                               ; preds = %.preheader24.us.us.preheader, %._crit_edge28.split.us.us.us
  %indvars.iv43 = phi i64 [ 0, %.preheader24.us.us.preheader ], [ %indvars.iv.next44, %._crit_edge28.split.us.us.us ]
  %21 = trunc nuw nsw i64 %indvars.iv43 to i32
  %factor.op.mul.reass.us.us = mul i32 %factor.op.mul26, %21
  %22 = getelementptr inbounds float, ptr %4, i64 %indvars.iv43
  %23 = getelementptr inbounds float, ptr %5, i64 %indvars.iv43
  %24 = sext i32 %factor.op.mul.reass.us.us to i64
  %invariant.gep48 = getelementptr float, ptr %15, i64 %24
  %invariant.gep = getelementptr float, ptr %17, i64 %indvars.iv43
  br label %.preheader.us.us.us

.preheader.us.us.us:                              ; preds = %._crit_edge.us.us.us, %.preheader24.us.us
  %indvars.iv38 = phi i64 [ %indvars.iv.next39, %._crit_edge.us.us.us ], [ 0, %.preheader24.us.us ]
  %25 = mul nsw i64 %indvars.iv38, %19
  %gep49 = getelementptr float, ptr %invariant.gep48, i64 %25
  br i1 %20, label %._crit_edge.us.us.us.unr-lcssa, label %.preheader.us.us.us.new

.preheader.us.us.us.new:                          ; preds = %.preheader.us.us.us, %.preheader.us.us.us.new
  %indvars.iv = phi i64 [ %indvars.iv.next.1, %.preheader.us.us.us.new ], [ 0, %.preheader.us.us.us ]
  %niter = phi i64 [ %niter.next.1, %.preheader.us.us.us.new ], [ 0, %.preheader.us.us.us ]
  %26 = getelementptr float, ptr %gep49, i64 %indvars.iv
  %27 = load float, ptr %26, align 4, !tbaa !12
  %28 = load float, ptr %22, align 4, !tbaa !12
  %29 = fsub float %27, %28
  %30 = load float, ptr %23, align 4, !tbaa !12
  %31 = fmul float %29, %30
  %32 = add i64 %indvars.iv, %25
  %sext = mul i64 %32, 12884901888
  %33 = ashr exact i64 %sext, 30
  %gep = getelementptr i8, ptr %invariant.gep, i64 %33
  store float %31, ptr %gep, align 4, !tbaa !12
  %indvars.iv.next = or disjoint i64 %indvars.iv, 1
  %34 = getelementptr float, ptr %gep49, i64 %indvars.iv.next
  %35 = load float, ptr %34, align 4, !tbaa !12
  %36 = load float, ptr %22, align 4, !tbaa !12
  %37 = fsub float %35, %36
  %38 = load float, ptr %23, align 4, !tbaa !12
  %39 = fmul float %37, %38
  %40 = add i64 %indvars.iv.next, %25
  %sext.1 = mul i64 %40, 12884901888
  %41 = ashr exact i64 %sext.1, 30
  %gep.1 = getelementptr i8, ptr %invariant.gep, i64 %41
  store float %39, ptr %gep.1, align 4, !tbaa !12
  %indvars.iv.next.1 = add nuw nsw i64 %indvars.iv, 2
  %niter.next.1 = add i64 %niter, 2
  %niter.ncmp.1 = icmp eq i64 %niter.next.1, %unroll_iter
  br i1 %niter.ncmp.1, label %._crit_edge.us.us.us.unr-lcssa, label %.preheader.us.us.us.new, !llvm.loop !14

._crit_edge.us.us.us.unr-lcssa:                   ; preds = %.preheader.us.us.us.new, %.preheader.us.us.us
  %indvars.iv.unr = phi i64 [ 0, %.preheader.us.us.us ], [ %indvars.iv.next.1, %.preheader.us.us.us.new ]
  br i1 %lcmp.mod.not, label %._crit_edge.us.us.us, label %._crit_edge.us.us.us.epilog-lcssa

._crit_edge.us.us.us.epilog-lcssa:                ; preds = %._crit_edge.us.us.us.unr-lcssa
  %42 = getelementptr float, ptr %gep49, i64 %indvars.iv.unr
  %43 = load float, ptr %42, align 4, !tbaa !12
  %44 = load float, ptr %22, align 4, !tbaa !12
  %45 = fsub float %43, %44
  %46 = load float, ptr %23, align 4, !tbaa !12
  %47 = fmul float %45, %46
  %48 = add i64 %indvars.iv.unr, %25
  %sext.epil = mul i64 %48, 12884901888
  %49 = ashr exact i64 %sext.epil, 30
  %gep.epil = getelementptr i8, ptr %invariant.gep, i64 %49
  store float %47, ptr %gep.epil, align 4, !tbaa !12
  br label %._crit_edge.us.us.us

._crit_edge.us.us.us:                             ; preds = %._crit_edge.us.us.us.unr-lcssa, %._crit_edge.us.us.us.epilog-lcssa
  %indvars.iv.next39 = add nuw nsw i64 %indvars.iv38, 1
  %exitcond42.not = icmp eq i64 %indvars.iv.next39, %wide.trip.count41
  br i1 %exitcond42.not, label %._crit_edge28.split.us.us.us, label %.preheader.us.us.us, !llvm.loop !16

._crit_edge28.split.us.us.us:                     ; preds = %._crit_edge.us.us.us
  %indvars.iv.next44 = add nuw nsw i64 %indvars.iv43, 1
  %exitcond47.not = icmp eq i64 %indvars.iv.next44, %wide.trip.count46
  br i1 %exitcond47.not, label %._crit_edge, label %.preheader24.us.us, !llvm.loop !17

._crit_edge:                                      ; preds = %._crit_edge28.split.us.us.us, %.preheader24.lr.ph, %6
  tail call void @_Z10free_image5image(ptr noundef nonnull byval(%struct.image) align 8 %1)
  ret void
}

attributes #0 = { mustprogress 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 #1 = { mustprogress 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, !7, i64 8}
!6 = !{!"_ZTS5image", !7, i64 0, !7, i64 4, !7, i64 8, !10, i64 16}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"any pointer", !8, i64 0}
!11 = !{!6, !7, i64 4}
!12 = !{!13, !13, i64 0}
!13 = !{!"float", !8, i64 0}
!14 = distinct !{!14, !15}
!15 = !{!"llvm.loop.mustprogress"}
!16 = distinct !{!16, !15}
!17 = distinct !{!17, !15}


; Effective O3 passes: DSEPass,EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopInstSimplifyPass,LoopRotatePass,LoopSimplifyCFGPass,LoopSimplifyPass,LoopUnrollPass,MemCpyOptPass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass