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

; 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 nounwind uwtable
declare hidden void @_ZL13set_pixelData5imageiiif(ptr noundef byval(%struct.image) align 8, i32 noundef, i32 noundef, i32 noundef, float noundef) #2

; Function Attrs: mustprogress uwtable
define dso_local void @_Z10draw_label5imageiiS_PKf(ptr noundef byval(%struct.image) align 8 %0, i32 noundef %1, i32 noundef %2, ptr noundef byval(%struct.image) align 8 %3, ptr noundef %4) #3 {
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca ptr, align 8
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  %13 = alloca i32, align 4
  %14 = alloca float, align 4
  %15 = alloca %struct.image, align 8
  %16 = alloca %struct.image, align 8
  store i32 %1, ptr %6, align 4, !tbaa !5
  store i32 %2, ptr %7, align 4, !tbaa !5
  store ptr %4, ptr %8, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #4
  %17 = getelementptr inbounds %struct.image, ptr %3, i32 0, i32 0
  %18 = load i32, ptr %17, align 8, !tbaa !11
  store i32 %18, ptr %9, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #4
  %19 = getelementptr inbounds %struct.image, ptr %3, i32 0, i32 1
  %20 = load i32, ptr %19, align 4, !tbaa !13
  store i32 %20, ptr %10, align 4, !tbaa !5
  %21 = load i32, ptr %6, align 4, !tbaa !5
  %22 = load i32, ptr %10, align 4, !tbaa !5
  %23 = sub nsw i32 %21, %22
  %24 = icmp sge i32 %23, 0
  br i1 %24, label %25, label %29

25:                                               ; preds = %5
  %26 = load i32, ptr %6, align 4, !tbaa !5
  %27 = load i32, ptr %10, align 4, !tbaa !5
  %28 = sub nsw i32 %26, %27
  store i32 %28, ptr %6, align 4, !tbaa !5
  br label %29

29:                                               ; preds = %25, %5
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #4
  store i32 0, ptr %12, align 4, !tbaa !5
  br label %30

30:                                               ; preds = %91, %29
  %31 = load i32, ptr %12, align 4, !tbaa !5
  %32 = load i32, ptr %10, align 4, !tbaa !5
  %33 = icmp slt i32 %31, %32
  br i1 %33, label %34, label %41

34:                                               ; preds = %30
  %35 = load i32, ptr %12, align 4, !tbaa !5
  %36 = load i32, ptr %6, align 4, !tbaa !5
  %37 = add nsw i32 %35, %36
  %38 = getelementptr inbounds %struct.image, ptr %0, i32 0, i32 1
  %39 = load i32, ptr %38, align 4, !tbaa !13
  %40 = icmp slt i32 %37, %39
  br label %41

41:                                               ; preds = %34, %30
  %42 = phi i1 [ false, %30 ], [ %40, %34 ]
  br i1 %42, label %43, label %94

43:                                               ; preds = %41
  store i32 0, ptr %11, align 4, !tbaa !5
  br label %44

44:                                               ; preds = %87, %43
  %45 = load i32, ptr %11, align 4, !tbaa !5
  %46 = load i32, ptr %9, align 4, !tbaa !5
  %47 = icmp slt i32 %45, %46
  br i1 %47, label %48, label %55

48:                                               ; preds = %44
  %49 = load i32, ptr %11, align 4, !tbaa !5
  %50 = load i32, ptr %7, align 4, !tbaa !5
  %51 = add nsw i32 %49, %50
  %52 = getelementptr inbounds %struct.image, ptr %0, i32 0, i32 0
  %53 = load i32, ptr %52, align 8, !tbaa !11
  %54 = icmp slt i32 %51, %53
  br label %55

55:                                               ; preds = %48, %44
  %56 = phi i1 [ false, %44 ], [ %54, %48 ]
  br i1 %56, label %57, label %90

57:                                               ; preds = %55
  store i32 0, ptr %13, align 4, !tbaa !5
  br label %58

58:                                               ; preds = %83, %57
  %59 = load i32, ptr %13, align 4, !tbaa !5
  %60 = getelementptr inbounds %struct.image, ptr %3, i32 0, i32 2
  %61 = load i32, ptr %60, align 8, !tbaa !14
  %62 = icmp slt i32 %59, %61
  br i1 %62, label %63, label %86

63:                                               ; preds = %58
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #4
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %15, ptr align 8 %3, i64 24, i1 false), !tbaa.struct !15
  %64 = load i32, ptr %11, align 4, !tbaa !5
  %65 = load i32, ptr %12, align 4, !tbaa !5
  %66 = load i32, ptr %13, align 4, !tbaa !5
  %67 = call noundef double @_ZL13get_pixelData5imageiii(ptr noundef byval(%struct.image) align 8 %15, i32 noundef %64, i32 noundef %65, i32 noundef %66)
  %68 = fptrunc double %67 to float
  store float %68, ptr %14, align 4, !tbaa !16
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %16, ptr align 8 %0, i64 24, i1 false), !tbaa.struct !15
  %69 = load i32, ptr %11, align 4, !tbaa !5
  %70 = load i32, ptr %7, align 4, !tbaa !5
  %71 = add nsw i32 %69, %70
  %72 = load i32, ptr %12, align 4, !tbaa !5
  %73 = load i32, ptr %6, align 4, !tbaa !5
  %74 = add nsw i32 %72, %73
  %75 = load i32, ptr %13, align 4, !tbaa !5
  %76 = load ptr, ptr %8, align 8, !tbaa !9
  %77 = load i32, ptr %13, align 4, !tbaa !5
  %78 = sext i32 %77 to i64
  %79 = getelementptr inbounds float, ptr %76, i64 %78
  %80 = load float, ptr %79, align 4, !tbaa !16
  %81 = load float, ptr %14, align 4, !tbaa !16
  %82 = fmul float %80, %81
  call void @_ZL13set_pixelData5imageiiif(ptr noundef byval(%struct.image) align 8 %16, i32 noundef %71, i32 noundef %74, i32 noundef %75, float noundef %82)
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #4
  br label %83

83:                                               ; preds = %63
  %84 = load i32, ptr %13, align 4, !tbaa !5
  %85 = add nsw i32 %84, 1
  store i32 %85, ptr %13, align 4, !tbaa !5
  br label %58, !llvm.loop !18

86:                                               ; preds = %58
  br label %87

87:                                               ; preds = %86
  %88 = load i32, ptr %11, align 4, !tbaa !5
  %89 = add nsw i32 %88, 1
  store i32 %89, ptr %11, align 4, !tbaa !5
  br label %44, !llvm.loop !20

90:                                               ; preds = %55
  br label %91

91:                                               ; preds = %90
  %92 = load i32, ptr %12, align 4, !tbaa !5
  %93 = add nsw i32 %92, 1
  store i32 %93, ptr %12, align 4, !tbaa !5
  br label %30, !llvm.loop !21

94:                                               ; preds = %41
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #4
  ret void
}

; Function Attrs: mustprogress nounwind uwtable
declare hidden noundef double @_ZL13get_pixelData5imageiii(ptr noundef byval(%struct.image) align 8, i32 noundef, i32 noundef, i32 noundef) #2

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


; 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 nounwind uwtable
declare hidden void @_ZL13set_pixelData5imageiiif(ptr noundef byval(%struct.image) align 8, i32 noundef, i32 noundef, i32 noundef, float noundef) local_unnamed_addr #0

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_Z10draw_label5imageiiS_PKf(ptr nocapture noundef readonly byval(%struct.image) align 8 %0, i32 noundef %1, i32 noundef %2, ptr nocapture noundef readonly byval(%struct.image) align 8 %3, ptr nocapture noundef readonly %4) local_unnamed_addr #0 {
  %6 = load i32, ptr %3, align 8, !tbaa !5
  %.fr = freeze i32 %6
  %7 = getelementptr inbounds i8, ptr %3, i64 4
  %8 = load i32, ptr %7, align 4, !tbaa !11
  %9 = sub nsw i32 %1, %8
  %10 = icmp slt i32 %9, 0
  %spec.select = select i1 %10, i32 %1, i32 %9
  %11 = icmp sgt i32 %8, 0
  br i1 %11, label %.lr.ph, label %.critedge

.lr.ph:                                           ; preds = %5
  %12 = icmp sgt i32 %.fr, 0
  %13 = getelementptr inbounds i8, ptr %3, i64 8
  %14 = load i32, ptr %13, align 8
  %.fr51 = freeze i32 %14
  %15 = icmp sgt i32 %.fr51, 0
  %or.cond = and i1 %12, %15
  br i1 %or.cond, label %.lr.ph.split.us.split.us.preheader, label %.critedge

.lr.ph.split.us.split.us.preheader:               ; preds = %.lr.ph
  %16 = load i32, ptr %0, align 8
  %17 = getelementptr inbounds i8, ptr %0, i64 4
  %18 = load i32, ptr %17, align 4, !tbaa !11
  %smax57 = tail call i32 @llvm.smax.i32(i32 %16, i32 %2)
  %19 = sub i32 %smax57, %2
  %smax60 = tail call i32 @llvm.smax.i32(i32 %spec.select, i32 %18)
  %20 = sub i32 %smax60, %spec.select
  %wide.trip.count = zext nneg i32 %.fr51 to i64
  br label %.lr.ph.split.us.split.us

.lr.ph.split.us.split.us:                         ; preds = %.lr.ph.split.us.split.us.preheader, %.critedge2.us.us
  %.02939.us.us = phi i32 [ %22, %.critedge2.us.us ], [ 0, %.lr.ph.split.us.split.us.preheader ]
  %21 = add nsw i32 %.02939.us.us, %spec.select
  %exitcond61.not = icmp eq i32 %.02939.us.us, %20
  br i1 %exitcond61.not, label %.critedge, label %.preheader34.us.us

.critedge2.us.us:                                 ; preds = %._crit_edge.us.us.us, %.preheader34.us.us
  %22 = add nuw nsw i32 %.02939.us.us, 1
  %exitcond62.not = icmp eq i32 %22, %8
  br i1 %exitcond62.not, label %.critedge, label %.lr.ph.split.us.split.us, !llvm.loop !12

.preheader34.us.us:                               ; preds = %.lr.ph.split.us.split.us, %._crit_edge.us.us.us
  %.03036.us.us.us = phi i32 [ %30, %._crit_edge.us.us.us ], [ 0, %.lr.ph.split.us.split.us ]
  %23 = add nsw i32 %.03036.us.us.us, %2
  %exitcond58.not = icmp eq i32 %.03036.us.us.us, %19
  br i1 %exitcond58.not, label %.critedge2.us.us, label %.preheader.us.us.us

.preheader.us.us.us:                              ; preds = %.preheader34.us.us, %.preheader.us.us.us
  %indvars.iv = phi i64 [ %indvars.iv.next, %.preheader.us.us.us ], [ 0, %.preheader34.us.us ]
  %24 = trunc nuw nsw i64 %indvars.iv to i32
  %25 = tail call noundef double @_ZL13get_pixelData5imageiii(ptr noundef nonnull byval(%struct.image) align 8 %3, i32 noundef %.03036.us.us.us, i32 noundef %.02939.us.us, i32 noundef %24)
  %26 = fptrunc double %25 to float
  %27 = getelementptr inbounds float, ptr %4, i64 %indvars.iv
  %28 = load float, ptr %27, align 4, !tbaa !14
  %29 = fmul float %28, %26
  tail call void @_ZL13set_pixelData5imageiiif(ptr noundef nonnull byval(%struct.image) align 8 %0, i32 noundef %23, i32 noundef %21, i32 noundef %24, float noundef %29)
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, %wide.trip.count
  br i1 %exitcond.not, label %._crit_edge.us.us.us, label %.preheader.us.us.us, !llvm.loop !16

._crit_edge.us.us.us:                             ; preds = %.preheader.us.us.us
  %30 = add nuw nsw i32 %.03036.us.us.us, 1
  %exitcond59.not = icmp eq i32 %30, %.fr
  br i1 %exitcond59.not, label %.critedge2.us.us, label %.preheader34.us.us, !llvm.loop !17

.critedge:                                        ; preds = %.lr.ph.split.us.split.us, %.critedge2.us.us, %.lr.ph, %5
  ret void
}

; Function Attrs: mustprogress nounwind uwtable
declare hidden noundef double @_ZL13get_pixelData5imageiii(ptr noundef byval(%struct.image) align 8, i32 noundef, i32 noundef, i32 noundef) local_unnamed_addr #0

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.smax.i32(i32, i32) #1

attributes #0 = { 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 #1 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }

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


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