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

; 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 uwtable
define dso_local void @_Z9imread2tf5imageiiPfS0_(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 = %89, %6
  %23 = load i32, ptr %12, align 4, !tbaa !5
  %24 = load i32, ptr %8, align 4, !tbaa !5
  %25 = icmp slt i32 %23, %24
  br i1 %25, label %27, label %26

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

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

28:                                               ; preds = %85, %27
  %29 = load i32, ptr %14, align 4, !tbaa !5
  %30 = load i32, ptr %7, align 4, !tbaa !5
  %31 = icmp slt i32 %29, %30
  br i1 %31, label %33, label %32

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

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

34:                                               ; preds = %81, %33
  %35 = load i32, ptr %15, align 4, !tbaa !5
  %36 = icmp slt i32 %35, 3
  br i1 %36, label %38, label %37

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

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

81:                                               ; preds = %38
  %82 = load i32, ptr %15, align 4, !tbaa !5
  %83 = add nsw i32 %82, 1
  store i32 %83, ptr %15, align 4, !tbaa !5
  br label %34, !llvm.loop !17

84:                                               ; preds = %37
  br label %85

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

88:                                               ; preds = %32
  br label %89

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

92:                                               ; preds = %26
  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
}

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

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, !10, i64 16}
!15 = !{!16, !16, i64 0}
!16 = !{!"float", !7, i64 0}
!17 = distinct !{!17, !18}
!18 = !{!"llvm.loop.mustprogress"}
!19 = distinct !{!19, !18}
!20 = distinct !{!20, !18}


; 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 uwtable
define dso_local void @_Z9imread2tf5imageiiPfS0_(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 %3, 0
  br i1 %9, label %.preheader28.lr.ph, label %._crit_edge32

.preheader28.lr.ph:                               ; preds = %6
  %10 = icmp sgt i32 %2, 0
  %11 = mul nsw i32 %3, %2
  %12 = getelementptr inbounds i8, ptr %1, i64 16
  %13 = load ptr, ptr %12, align 8
  %14 = getelementptr inbounds i8, ptr %0, i64 16
  %15 = load ptr, ptr %14, align 8
  br i1 %10, label %.preheader28.us.preheader, label %._crit_edge32

.preheader28.us.preheader:                        ; preds = %.preheader28.lr.ph
  %16 = zext nneg i32 %2 to i64
  %wide.trip.count39 = zext nneg i32 %3 to i64
  %17 = getelementptr inbounds i8, ptr %4, i64 4
  %18 = getelementptr inbounds i8, ptr %5, i64 4
  %invariant.gep = getelementptr i8, ptr %15, i64 4
  %19 = shl nuw i32 %11, 1
  %20 = getelementptr inbounds i8, ptr %4, i64 8
  %21 = getelementptr inbounds i8, ptr %5, i64 8
  %invariant.gep42 = getelementptr i8, ptr %15, i64 8
  br label %.preheader28.us

.preheader28.us:                                  ; preds = %.preheader28.us.preheader, %._crit_edge.us
  %indvars.iv36 = phi i64 [ 0, %.preheader28.us.preheader ], [ %indvars.iv.next37, %._crit_edge.us ]
  %22 = mul nuw nsw i64 %indvars.iv36, %16
  br label %.preheader.us

.preheader.us:                                    ; preds = %.preheader28.us, %.preheader.us
  %indvars.iv = phi i64 [ 0, %.preheader28.us ], [ %indvars.iv.next, %.preheader.us ]
  %23 = add nuw nsw i64 %indvars.iv, %22
  %24 = trunc nuw i64 %23 to i32
  %sext = mul i64 %23, 12884901888
  %25 = ashr exact i64 %sext, 32
  %sext41 = shl i64 %23, 32
  %26 = ashr exact i64 %sext41, 30
  %27 = getelementptr inbounds i8, ptr %13, i64 %26
  %28 = load float, ptr %27, align 4, !tbaa !11
  %29 = load float, ptr %4, align 4, !tbaa !11
  %30 = fsub float %28, %29
  %31 = load float, ptr %5, align 4, !tbaa !11
  %32 = fmul float %30, %31
  %33 = getelementptr inbounds float, ptr %15, i64 %25
  store float %32, ptr %33, align 4, !tbaa !11
  %34 = add i32 %11, %24
  %35 = sext i32 %34 to i64
  %36 = getelementptr inbounds float, ptr %13, i64 %35
  %37 = load float, ptr %36, align 4, !tbaa !11
  %38 = load float, ptr %17, align 4, !tbaa !11
  %39 = fsub float %37, %38
  %40 = load float, ptr %18, align 4, !tbaa !11
  %41 = fmul float %39, %40
  %gep = getelementptr float, ptr %invariant.gep, i64 %25
  store float %41, ptr %gep, align 4, !tbaa !11
  %42 = add i32 %19, %24
  %43 = sext i32 %42 to i64
  %44 = getelementptr inbounds float, ptr %13, i64 %43
  %45 = load float, ptr %44, align 4, !tbaa !11
  %46 = load float, ptr %20, align 4, !tbaa !11
  %47 = fsub float %45, %46
  %48 = load float, ptr %21, align 4, !tbaa !11
  %49 = fmul float %47, %48
  %gep43 = getelementptr float, ptr %invariant.gep42, i64 %25
  store float %49, ptr %gep43, align 4, !tbaa !11
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, %16
  br i1 %exitcond.not, label %._crit_edge.us, label %.preheader.us, !llvm.loop !13

._crit_edge.us:                                   ; preds = %.preheader.us
  %indvars.iv.next37 = add nuw nsw i64 %indvars.iv36, 1
  %exitcond40.not = icmp eq i64 %indvars.iv.next37, %wide.trip.count39
  br i1 %exitcond40.not, label %._crit_edge32, label %.preheader28.us, !llvm.loop !15

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

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

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 = !{!12, !12, i64 0}
!12 = !{!"float", !8, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}
!15 = distinct !{!15, !14}


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