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

; 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: mustprogress uwtable
declare dso_local void @_Z14load_image_stbPKci(ptr dead_on_unwind noalias writable sret(%struct.image) align 8, ptr noundef, i32 noundef) #1

; Function Attrs: mustprogress uwtable
define dso_local void @_Z6imreadPKc(ptr dead_on_unwind noalias writable sret(%struct.image) align 8 %0, ptr noundef %1) #1 {
  %3 = alloca ptr, align 8
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  store ptr %1, ptr %3, align 8, !tbaa !5
  %9 = load ptr, ptr %3, align 8, !tbaa !5
  call void @_Z14load_image_stbPKci(ptr dead_on_unwind writable sret(%struct.image) align 8 %0, ptr noundef %9, i32 noundef 0)
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #2
  store i32 0, ptr %4, align 4, !tbaa !9
  br label %10

10:                                               ; preds = %64, %2
  %11 = load i32, ptr %4, align 4, !tbaa !9
  %12 = getelementptr inbounds %struct.image, ptr %0, i32 0, i32 2
  %13 = load i32, ptr %12, align 8, !tbaa !11
  %14 = icmp slt i32 %11, %13
  br i1 %14, label %16, label %15

15:                                               ; preds = %10
  store i32 2, ptr %5, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #2
  br label %67

16:                                               ; preds = %10
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #2
  store i32 0, ptr %6, align 4, !tbaa !9
  br label %17

17:                                               ; preds = %60, %16
  %18 = load i32, ptr %6, align 4, !tbaa !9
  %19 = getelementptr inbounds %struct.image, ptr %0, i32 0, i32 1
  %20 = load i32, ptr %19, align 4, !tbaa !13
  %21 = icmp slt i32 %18, %20
  br i1 %21, label %23, label %22

22:                                               ; preds = %17
  store i32 5, ptr %5, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #2
  br label %63

23:                                               ; preds = %17
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #2
  store i32 0, ptr %7, align 4, !tbaa !9
  br label %24

24:                                               ; preds = %56, %23
  %25 = load i32, ptr %7, align 4, !tbaa !9
  %26 = getelementptr inbounds %struct.image, ptr %0, i32 0, i32 0
  %27 = load i32, ptr %26, align 8, !tbaa !14
  %28 = icmp slt i32 %25, %27
  br i1 %28, label %30, label %29

29:                                               ; preds = %24
  store i32 8, ptr %5, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #2
  br label %59

30:                                               ; preds = %24
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #2
  %31 = load i32, ptr %4, align 4, !tbaa !9
  %32 = getelementptr inbounds %struct.image, ptr %0, i32 0, i32 1
  %33 = load i32, ptr %32, align 4, !tbaa !13
  %34 = mul nsw i32 %31, %33
  %35 = getelementptr inbounds %struct.image, ptr %0, i32 0, i32 0
  %36 = load i32, ptr %35, align 8, !tbaa !14
  %37 = mul nsw i32 %34, %36
  %38 = load i32, ptr %6, align 4, !tbaa !9
  %39 = getelementptr inbounds %struct.image, ptr %0, i32 0, i32 0
  %40 = load i32, ptr %39, align 8, !tbaa !14
  %41 = mul nsw i32 %38, %40
  %42 = add nsw i32 %37, %41
  %43 = load i32, ptr %7, align 4, !tbaa !9
  %44 = add nsw i32 %42, %43
  store i32 %44, ptr %8, align 4, !tbaa !9
  %45 = getelementptr inbounds %struct.image, ptr %0, i32 0, i32 3
  %46 = load ptr, ptr %45, align 8, !tbaa !15
  %47 = load i32, ptr %8, align 4, !tbaa !9
  %48 = sext i32 %47 to i64
  %49 = getelementptr inbounds float, ptr %46, i64 %48
  %50 = load float, ptr %49, align 4, !tbaa !16
  %51 = getelementptr inbounds %struct.image, ptr %0, i32 0, i32 3
  %52 = load ptr, ptr %51, align 8, !tbaa !15
  %53 = load i32, ptr %8, align 4, !tbaa !9
  %54 = sext i32 %53 to i64
  %55 = getelementptr inbounds float, ptr %52, i64 %54
  store float %50, ptr %55, align 4, !tbaa !16
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #2
  br label %56

56:                                               ; preds = %30
  %57 = load i32, ptr %7, align 4, !tbaa !9
  %58 = add nsw i32 %57, 1
  store i32 %58, ptr %7, align 4, !tbaa !9
  br label %24, !llvm.loop !18

59:                                               ; preds = %29
  br label %60

60:                                               ; preds = %59
  %61 = load i32, ptr %6, align 4, !tbaa !9
  %62 = add nsw i32 %61, 1
  store i32 %62, ptr %6, align 4, !tbaa !9
  br label %17, !llvm.loop !20

63:                                               ; preds = %22
  br label %64

64:                                               ; preds = %63
  %65 = load i32, ptr %4, align 4, !tbaa !9
  %66 = add nsw i32 %65, 1
  store i32 %66, ptr %4, align 4, !tbaa !9
  br label %10, !llvm.loop !21

67:                                               ; preds = %15
  ret void
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #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++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !10, i64 8}
!12 = !{!"_ZTS5image", !10, i64 0, !10, i64 4, !10, i64 8, !6, i64 16}
!13 = !{!12, !10, i64 4}
!14 = !{!12, !10, i64 0}
!15 = !{!12, !6, i64 16}
!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 uwtable
declare dso_local void @_Z14load_image_stbPKci(ptr dead_on_unwind noalias writable sret(%struct.image) align 8, ptr noundef, i32 noundef) local_unnamed_addr #0

; Function Attrs: mustprogress uwtable
define dso_local void @_Z6imreadPKc(ptr dead_on_unwind noalias writable sret(%struct.image) align 8 %0, ptr noundef %1) local_unnamed_addr #0 {
._crit_edge17:
  tail call void @_Z14load_image_stbPKci(ptr dead_on_unwind writable sret(%struct.image) align 8 %0, ptr noundef %1, i32 noundef 0)
  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" }

!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)"}


; Effective O3 passes: ADCEPass,EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopRotatePass,LoopSimplifyCFGPass,LoopSimplifyPass,SROAPass,SimplifyCFGPass,TailCallElimPass